AssessCalib_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file AssessCalib_module.cc
3 // \brief Make TTree with reconstructed and true energies
4 // \author Christopher Backhouse - bckhouse@caltech.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 // Framework includes
15 #include "fhiclcpp/ParameterSet.h"
16 
17 #include "Calibrator/Calibrator.h"
18 #include "Geometry/Geometry.h"
20 #include "MCCheater/BackTracker.h"
21 #include "RecoBase/CellHit.h"
22 #include "RecoBase/RecoHit.h"
23 
24 #include "TTree.h"
25 
26 namespace{
27  // Variables for the tree
28  int gPlane, gCell, gView;
29  double gPE;
30  double gTrueE;
31  double gW;
32  double gPECorr;
33  double gGeV;
34 }
35 
36 namespace calib
37 {
38  /// Make TTree with reconstructed and true energies
40  {
41  public:
42  explicit AssessCalib(const fhicl::ParameterSet& pset);
43  ~AssessCalib();
44 
45  void beginJob();
46 
47  void reconfigure(const fhicl::ParameterSet& pset);
48 
49  void analyze(const art::Event& evt);
50 
51  protected:
53 
54  TTree* fTree;
55  };
56 
57  //.......................................................................
59  : EDAnalyzer(pset)
60  {
61  reconfigure(pset);
62  }
63 
64  //......................................................................
66  {
67  }
68 
69  //......................................................................
71  {
72  fCellHitLabel = pset.get<std::string>("CellHitLabel");
73  }
74 
75  //......................................................................
77  {
79 
80  fTree = tfs->make<TTree>("tree", "tree");
81 
82  fTree->Branch("plane", &gPlane);
83  fTree->Branch("cell", &gCell);
84  fTree->Branch("view", &gView);
85  fTree->Branch("pe", &gPE);
86  fTree->Branch("trueE", &gTrueE);
87  fTree->Branch("W", &gW);
88  fTree->Branch("pecorr", &gPECorr);
89  fTree->Branch("gev", &gGeV);
90  }
91 
92  //......................................................................
94  {
98 
100  evt.getByLabel(fCellHitLabel, chits);
101 
102  const unsigned int N = chits->size();
103  for(unsigned int chitIdx = 0; chitIdx < N; ++chitIdx){
104  art::Ptr<rb::CellHit> chit(chits, chitIdx);
105  if(bt->IsNoise(chit)) continue;
106 
107  const std::vector<sim::FLSHit> flss = bt->HitToFLSHit(chit);
108  if(flss.empty()) continue;
109 
110  gPlane = chit->Plane();
111  gCell = chit->Cell();
112  gView = int(chit->View());
113  gPE = chit->PE();
114 
115  gTrueE = 0;
116  for(const sim::FLSHit& fls: flss) gTrueE += fls.GetEdep();
117 
118  double xyz[3];
119  bt->HitToXYZ(chit).GetXYZ(xyz);
120 
121  double world[3];
122  geom->Plane(gPlane)->Cell(gCell)->LocalToWorld(xyz, world);
123  const double W = world[1-gView];
124 
125  gW = W;
126 
127  const rb::RecoHit rhit(cal->MakeRecoHit(*chit, W));
128 
129  if(!rhit.IsCalibrated()) continue;
130 
131  gPECorr = rhit.PECorr();
132  gGeV = rhit.GeV();
133 
134  fTree->Fill();
135  } // end for chitIdx
136  }
137 
139 
140 } // end namespace calib
141 ////////////////////////////////////////////////////////////////////////
back track the reconstruction to the simulation
void LocalToWorld(const double *local, double *world) const
Definition: CellGeo.cxx:80
unsigned short Plane() const
Definition: CellHit.h:39
geo::View_t View() const
Definition: CellHit.h:41
const CellGeo * Cell(int icell) const
Definition: PlaneGeo.h:48
void reconfigure(const fhicl::ParameterSet &pset)
rb::RecoHit MakeRecoHit(rb::CellHit const &cellhit, double w)
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
const PlaneGeo * Plane(unsigned int i) const
DEFINE_ART_MODULE(TestTMapFile)
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
unsigned short Cell() const
Definition: CellHit.h:40
Make TTree with reconstructed and true energies.
CDPStorage service.
std::vector< sim::FLSHit > HitToFLSHit(const rb::CellHit &hit) const
All the FLSHits that contributed to this hit, sorted from most to least light.
T get(std::string const &key) const
Definition: ParameterSet.h:231
float PE() const
Definition: CellHit.h:42
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void analyze(const art::Event &evt)
void geom(int which=0)
Definition: geom.C:163
float PECorr() const
Definition: RecoHit.cxx:47
TVector3 HitToXYZ(art::Ptr< rb::CellHit > const &hit, bool useBirksE=false) const
Returns the XYZ position of the energy deposition for a given hit.
AssessCalib(const fhicl::ParameterSet &pset)
#define W(x)
Encapsulate the geometry of one entire detector (near, far, ndos)