FillEnergies.cxx
Go to the documentation of this file.
2 
4 #include "Geometry/Geometry.h"
5 
6 #include "RecoBase/Cluster.h"
7 #include "RecoBase/RecoHit.h"
8 #include "RecoBase/Shower.h"
9 
11 #include "NumuEnergy/NumuE.h"
12 
14 
16 
17 namespace caf
18 {
19  //......................................................................
21  caf::SRNumuEnergy& sre)
22  {
23  sre.E = e.E();
24  sre.calccE = e.CalCCE();
25  sre.trkqeE = e.TrkQEE();
26  sre.trknonqeE = e.TrkNonQEE();
27  sre.trkccE = e.TrkCCE();
28  sre.angleE = e.AngleQEE();
29  sre.angleerror = e.AngleQEError();
30  sre.recomuonE = e.RecoMuonE();
32  sre.ucrecomuonE = e.UCMuonENonSingle();
33  sre.recotrkcchadE = e.RecoTrkCCHadE();
34  sre.hadcalE = e.HadCalE();
35  sre.hadtrkE = e.HadTrkE();
36  sre.ndtrklenact = e.NDTrkLenAct();
37  sre.ndtrklencat = e.NDTrkLenCat();
38  sre.ndtrkcalactE = e.NDTrkCalAct();
39  sre.ndtrkcaltranE = e.NDTrkCalTran();
40  sre.ndtrkcalcatE = e.NDTrkCalCat();
41  sre.ndhadcalactE = e.NDHadCalAct();
42  sre.ndhadcaltranE = e.NDHadCalTran();
43  sre.ndhadcalcatE = e.NDHadCalCat();
44  sre.ndhadtrkactE = e.NDHadTrkAct();
45  sre.ndhadtrktranE = e.NDHadTrkTran();
46  sre.ndhadtrkcatE = e.NDHadTrkCat();
47  sre.ndtrktranx = e.NDTrkTranX();
48  sre.ndtrktrany = e.NDTrkTranY();
49 
51 
52  sre.mc.truemuonE = e.MCTrueMuonE();
54  sre.mc.truegoodmuon = e.MCGoodTrueMuon();
55  }
56 
57  void FillNumuLSTMEnergyVars(const LSTME::LSTMEnergy& artE, float& lstmmuon, float& lstmnu)
58  {
59  lstmmuon = artE.primaryE;
60  lstmnu = artE.totalE;
61  }
62 
63  //......................................................................
64  void FillNueEnergyVars(const rb::Cluster& slice,const SRVertexBranch& srVertexBranch
65  , caf::SRNueEnergy& sre)
66  {
67  sre.rawgevslice = slice.TotalGeV();
68 // sre.rawgevshw = shw.TotalGeV();
69 // sre.rawgevhad = slice.TotalGeV()-shw.TotalGeV();
70 
71  if(srVertexBranch.elastic.IsValid == 0 ) return;
72  if(srVertexBranch.elastic.fuzzyk.png.size() < 1) return;
73 
74  double CVNem_CalE = 0.0;
75  double TotCalE = 0.0;
76  for(unsigned int fuzzkProngIdx = 0; fuzzkProngIdx < srVertexBranch.elastic.fuzzyk.png.size(); ++fuzzkProngIdx){
77  const SRFuzzyKProng &srPng = srVertexBranch.elastic.fuzzyk.png[fuzzkProngIdx];
78  double png_CalE = srVertexBranch.elastic.fuzzyk.png[fuzzkProngIdx].shwlid.calE;
79 
80  TotCalE += png_CalE;
81  double emPID = srPng.cvnpart.electronid + srPng.cvnpart.pizeroid + srPng.cvnpart.photonid;
82  double hadPID = srPng.cvnpart.muonid + srPng.cvnpart.protonid + srPng.cvnpart.neutronid + srPng.cvnpart.pionid + srPng.cvnpart.otherid;
83  if ( emPID < 0 ) continue;
84  if ( emPID >= hadPID ) CVNem_CalE += png_CalE;
85  else continue;
86  }//end iPng
87  if( CVNem_CalE == 0.0) CVNem_CalE = srVertexBranch.elastic.fuzzyk.png[0].shwlid.calE;
88  sre.rawgevshw = CVNem_CalE;
89 
90  if(srVertexBranch.elastic.fuzzyk.png2d.size() < 1) TotCalE +=0.0;
91  else{
92  for(unsigned int iPng = 0; iPng < srVertexBranch.elastic.fuzzyk.png2d.size(); ++iPng){
93  TotCalE += srVertexBranch.elastic.fuzzyk.png2d[iPng].calE;
94  }
95  }
96  TotCalE += srVertexBranch.elastic.fuzzyk.orphCalE;
97  sre.rawgevhad = std::max(TotCalE - CVNem_CalE, 0.0);
98  }
99 
100  //......................................................................
101  void FillHadClustVars(const rb::Cluster& hadclust,
102  caf::SRHadClust& srhadclust)
103  {
106 
107  const double wx = (hadclust.NXCell() > 0) ? hadclust.W(hadclust.XCell(0).get()) : 0;
108  const double wy = (hadclust.NYCell() > 0) ? hadclust.W(hadclust.YCell(0).get()) : 0;
109 
110  // Variables needed:
111  // Holds contiguous planes info:
112  unsigned int cellsFromEdge = -1;
113 
114  // Hit counters:
115  int nCalHit = 0;
116  int nMipHit = 0;
117 
118  unsigned int minCellsFromEdge = 99999999;
119 
120  // Loop over hadclust in question here:
121  for(unsigned int hitIdx = 0; hitIdx < hadclust.NCell(); ++hitIdx)
122  {
123  const art::Ptr<rb::CellHit>& chit = hadclust.Cell(hitIdx);
124  // Get calbrated reco hit:
125  const rb::RecoHit rhit(cal->MakeRecoHit(*chit,
126  chit->View() == geo::kX ? wx : wy));
127 
128  const int planeNum = chit->Plane();
129  cellsFromEdge = std::min((unsigned int)chit->Cell(), geom->Plane(planeNum)->Ncells() - 1 - chit->Cell());
130 
131  if(cellsFromEdge < minCellsFromEdge)
132  {
133  minCellsFromEdge = cellsFromEdge;
134  }
135 
136  // Make sure things have been calibrated:
137  if(!rhit.IsCalibrated())
138  {
139  // LOG_DEBUG("CAFMaker") << "Not calibrated?! "
140  // << chit->Plane() << " " << chit->Cell();
141  continue;
142  }
143 
144  // Count up both the total calibrated hits
145  // and the MIP hits from 100-245 PECorr
146  // Count up total hits:
147  nCalHit++;
148  // Count up MIP hits:
149  if ( (rhit.PECorr()>100.0) && (rhit.PECorr()<245.0) ) nMipHit++;
150  } // end of hadclust loop
151 
152  srhadclust.nhit = hadclust.NCell();
153  srhadclust.ncalhit = nCalHit;
154  srhadclust.nmiphit = nMipHit;
155  srhadclust.ncontplanes = hadclust.MostContiguousPlanes(geo::kXorY);
156  if (!(hadclust.NCell()==0)){
157 
158  srhadclust.firstplane = hadclust.MinPlane();
159  srhadclust.lastplane = hadclust.MaxPlane();
160  srhadclust.firstcell = hadclust.MinCell(geo::kXorY);
161  srhadclust.lastcell = hadclust.MaxCell(geo::kXorY);
162  srhadclust.ncellsfromedge = minCellsFromEdge;
163 
164  srhadclust.calE = hadclust.CalorimetricEnergy();
165 
166  TVector3 boxmin, boxmax, meanpos;
167  hadclust.MinMaxMeanXYZ(boxmin, boxmax, meanpos);
168  srhadclust.boxmin = boxmin;
169  srhadclust.boxmax = boxmax;
170  srhadclust.meanpos = meanpos;
171 
172  // TBrowser can't draw DBL_MAX
173  if (hadclust.NXCell()==0){
174  srhadclust.boxmin.SetX(-5555);
175  srhadclust.boxmax.SetX(5555);
176  }
177  if (hadclust.NYCell()==0){
178  srhadclust.boxmin.SetY(-5555);
179  srhadclust.boxmax.SetY(5555);
180  }
181 
182  } // end of loop over variables to only fill for hadclust if it has hits
183  else{
184  srhadclust.firstplane = 0;
185  srhadclust.lastplane = 0;
186  srhadclust.firstcell = 0;
187  srhadclust.lastcell = 0;
188  srhadclust.ncellsfromedge = 0;
189 
190  srhadclust.calE = -5;
191 
192  srhadclust.boxmin = TVector3(-5555,-5555,-5555);
193  srhadclust.boxmax = TVector3(-5555,-5555,-5555);
194  srhadclust.meanpos = TVector3(-5555,-5555,-5555);
195  }
196  }
197 
198 } // end namespace caf
199 
200 
T max(const caf::Proxy< T > &a, T b)
float angleerror
1-sigma error from using quasielastic angle formula for neutrino energy
Definition: SRNumuEnergy.h:30
virtual double W(const rb::CellHit *chit) const
Estimate the unmeasured coordinate of chit.
Definition: Cluster.cxx:121
float neutronid
Likelihood neutron.
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
float rawgevhad
Uncorrected hadronic energy [GeV].
Definition: SRNueEnergy.h:20
float NDTrkLenCat() const
Definition: NumuE.cxx:309
float pionid
Likelihood pion.
float muonid
Likelihood muon.
float orphCalE
calorimetric energy of hits that don&#39;t appear in any FuzzyK prongs
Definition: SRFuzzyK.h:30
art::Ptr< rb::CellHit > XCell(unsigned int xIdx) const
Get the ith cell in the x-view.
Definition: Cluster.cxx:157
float E() const
Definition: Energy.cxx:27
float ndhadcalactE
Near detector – hadronic calorimetric energy NOT on the muon track in active region [GeV]...
Definition: SRNumuEnergy.h:42
float NDTrkTranY() const
Definition: NumuE.cxx:369
float ndtrklenact
Near detector – muon track length in active region [cm].
Definition: SRNumuEnergy.h:37
unsigned int ncellsfromedge
minimum number of cells to edge of detector
Definition: SRHadClust.h:30
float ndtrkcaltranE
Near detector – muon calorimetric energy in transition plane [GeV].
Definition: SRNumuEnergy.h:40
SRHadClust hadclust
Cluster information for hits in slice but not on muon track (track with higest ReMId value) ...
Definition: SRNumuEnergy.h:50
std::vector< SRProng > png2d
Vector of 2D prong objects.
Definition: SRFuzzyK.h:20
void SetX(float _x)
Definition: SRVector3D.h:28
float trknonqeE
Track length non-quasielastic neutrino energy [GeV].
Definition: SRNumuEnergy.h:26
X or Y views.
Definition: PlaneGeo.h:30
float rawgevslice
Uncorrected slice energy [GeV].
Definition: SRNueEnergy.h:21
unsigned short Plane() const
Definition: CellHit.h:39
std::vector< SRFuzzyKProng > png
Vector of 3D prong objects.
Definition: SRFuzzyK.h:19
geo::View_t View() const
Definition: CellHit.h:41
Overarching information for a numu hadronic cluster.
Definition: SRHadClust.h:15
float ndtrkcalcatE
Near detector – muon calorimetric energy in muon catcher [GeV].
Definition: SRNumuEnergy.h:41
float calccE
Calorimetric charged current neutrino energy [GeV].
Definition: SRNumuEnergy.h:24
Vertical planes which measure X.
Definition: PlaneGeo.h:28
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
float NDTrkLenAct() const
Definition: NumuE.cxx:304
float truemuoncatcherE
ND value: true energy of muon as it crosses the transition plane into muon catcher [GeV]...
rb::RecoHit MakeRecoHit(rb::CellHit const &cellhit, double w)
unsigned int ncontplanes
number of continuous planes
Definition: SRHadClust.h:25
A collection of associated CellHits.
Definition: Cluster.h:47
float NDHadTrkTran() const
Definition: NumuE.cxx:349
void FillHadClustVars(const rb::Cluster &hadclust, caf::SRHadClust &srhadclust)
unsigned int MaxCell(geo::View_t view) const
Definition: Cluster.cxx:518
float TrkCCE() const
Definition: NumuE.cxx:254
float ucrecomuonE1trk
Reconstructed muon energy for uncontained single track events at the FarDet from TMVA [GeV]...
Definition: SRNumuEnergy.h:32
SRVector3D meanpos
Mean position of hits in cluster, weighted by charge [cm].
Definition: SRHadClust.h:34
const PlaneGeo * Plane(unsigned int i) const
unsigned int nhit
number of hits
Definition: SRHadClust.h:22
float NDTrkCalAct() const
Definition: NumuE.cxx:314
rb::Cluster HadCluster() const
Definition: NumuE.cxx:389
float RecoTrkCCHadE() const
Definition: NumuE.cxx:274
float ndhadtrkactE
Near detector – hadronic calorimetric energy on the muon track in active region [GeV].
Definition: SRNumuEnergy.h:45
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
float RecoMuonE() const
Definition: NumuE.cxx:269
unsigned short Cell() const
Definition: CellHit.h:40
float photonid
Likelihood photon.
float UCMuonESingle() const
Definition: NumuE.cxx:294
float electronid
Likelihood electron.
float trkccE
Track length cc neutrino energy [GeV].
Definition: SRNumuEnergy.h:27
SRCVNParticleResult cvnpart
CVN prongID information for 4 views.
Definition: SRProng.h:50
float ndhadcalcatE
Near detector – hadronic calorimetric energy NOT on the muon track in muon catcher [GeV]...
Definition: SRNumuEnergy.h:44
double CalorimetricEnergy(EEnergyCalcScheme escheme=kRecomputeEnergy) const
Simple estimate of neutrino energy.
Definition: Cluster.cxx:439
float trkqeE
Track length quasielastic neutrino energy [GeV].
Definition: SRNumuEnergy.h:25
float hadtrkE
Hadronic calorimetric energy on the muon track[GeV].
Definition: SRNumuEnergy.h:36
Vectors of reconstructed vertices found by various algorithms.
float HadTrkE() const
Definition: NumuE.cxx:284
art::Ptr< rb::CellHit > YCell(unsigned int yIdx) const
Get the ith cell in the y-view.
Definition: Cluster.cxx:165
void FillNumuLSTMEnergyVars(const LSTME::LSTMEnergy &artE, float &lstmmuon, float &lstmnu)
float ndtrktranx
Near detector – if muon track crosses transition plane, the x location [cm].
Definition: SRNumuEnergy.h:48
Numu energy estimator output.
Definition: SRNumuEnergy.h:17
unsigned int nmiphit
number of minimum ionizing hits
Definition: SRHadClust.h:24
bool IsCalibrated() const
You MUST check here before accessing PECorr, MIP or GeV.
Definition: RecoHit.cxx:35
void FillNumuEnergyVars(const numue::NumuE &e, caf::SRNumuEnergy &sre)
float ucrecomuonE
Reconstructed muon energy for uncontained non-single track events at the FarDet from TMVA [GeV]...
Definition: SRNumuEnergy.h:33
float angleE
Quasielastic angle formula neutrino energy [GeV].
Definition: SRNumuEnergy.h:29
SRTrueNumuEnergy mc
True information used for retuning numu energy fits.
Definition: SRNumuEnergy.h:51
float E
Neutrino energy, set to match trkccE [GeV].
Definition: SRNumuEnergy.h:23
float protonid
Likelihood proton.
float UCMuonENonSingle() const
Definition: NumuE.cxx:299
float NDHadCalTran() const
Definition: NumuE.cxx:334
float AngleQEE() const
Definition: NumuE.cxx:259
unsigned int NYCell() const
Number of cells in the y-view.
Definition: Cluster.h:108
float calE
Calorimetric energy of the cluster [GeV].
Definition: SRHadClust.h:31
unsigned int MinPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.cxx:462
float HadCalE() const
Definition: NumuE.cxx:279
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
float ndhadcaltranE
Near detector – hadronic calorimetric energy NOT on the muon track in transition plane [GeV]...
Definition: SRNumuEnergy.h:43
float ndtrkcalactE
Near detector – muon calorimetric energy in active region [GeV].
Definition: SRNumuEnergy.h:39
float AngleQEError() const
Definition: NumuE.cxx:264
T const * get() const
Definition: Ptr.h:321
float rawgevshw
Uncorrected leading shower energy [GeV].
Definition: SRNueEnergy.h:19
float ndtrklencat
Near detector – muon track length in muon catcher [cm].
Definition: SRNumuEnergy.h:38
float otherid
Likelihood other.
float pizeroid
Likelihood pizero.
unsigned int NXCell() const
Number of cells in the x-view.
Definition: Cluster.h:106
unsigned int MinCell(geo::View_t view) const
Definition: Cluster.cxx:472
SRElastic elastic
Single vertex found by Elastic Arms.
int MostContiguousPlanes(geo::View_t view) const
Longest run of adjacent planes with hits.
Definition: Cluster.cxx:635
float NDHadCalAct() const
Definition: NumuE.cxx:329
void geom(int which=0)
Definition: geom.C:163
unsigned int lastcell
last cell
Definition: SRHadClust.h:29
unsigned int ncalhit
number of hits with calibration
Definition: SRHadClust.h:23
float CalCCE() const
Definition: NumuE.cxx:239
float MCTrueMuonE() const
Definition: NumuE.cxx:374
float TrkNonQEE() const
Definition: NumuE.cxx:249
double TotalGeV(EEnergyCalcScheme escheme=kRecomputeEnergy) const
Simple sum of the estimated GeV of all the hits.
Definition: Cluster.cxx:378
float ndtrktrany
Near detector – if muon track crosses transition plane, the y location [cm].
Definition: SRNumuEnergy.h:49
unsigned int MaxPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.cxx:508
SRFuzzyK fuzzyk
Primary 3D prong object.
Definition: SRElastic.h:44
float ndhadtrktranE
Near detector – hadronic calorimetric energy on the muon track in transition plane [GeV]...
Definition: SRNumuEnergy.h:46
float recotrkcchadE
Reconstructed hadronic energy for track cc neutrino energy estimator [GeV].
Definition: SRNumuEnergy.h:34
void MinMaxMeanXYZ(TVector3 &lo, TVector3 &hi, TVector3 &mean, rb::AveragingScheme scheme=kDefaultScheme) const
Gets the min/max/mean all at once, called by the functions above.
Definition: Cluster.cxx:582
This module creates Common Analysis Files.
Definition: FileReducer.h:10
SRVector3D boxmin
Minimum coordinates box containing all the hits [cm].
Definition: SRHadClust.h:32
float PECorr() const
Definition: RecoHit.cxx:47
T min(const caf::Proxy< T > &a, T b)
bool MCGoodTrueMuon() const
Definition: NumuE.cxx:384
bool truegoodmuon
Have a primary muon that contributes to at least three hits in each view.
float ndhadtrkcatE
Near detector – hadronic calorimetric energy on the muon track in muon catcher [GeV].
Definition: SRNumuEnergy.h:47
float NDTrkCalTran() const
Definition: NumuE.cxx:319
Float_t e
Definition: plot.C:35
unsigned int firstcell
first cell
Definition: SRHadClust.h:28
float NDHadTrkCat() const
Definition: NumuE.cxx:354
Nue energy estimator output in the standard record.
Definition: SRNueEnergy.h:13
float MCTrueMuonCatcherE() const
Definition: NumuE.cxx:379
float NDHadCalCat() const
Definition: NumuE.cxx:339
float TrkQEE() const
Definition: NumuE.cxx:244
void SetY(float _y)
Definition: SRVector3D.h:29
Encapsulate the geometry of one entire detector (near, far, ndos)
float hadcalE
Hadronic calorimetric energy NOT on the muon track[GeV].
Definition: SRNumuEnergy.h:35
unsigned int firstplane
first plane
Definition: SRHadClust.h:26
void FillNueEnergyVars(const rb::Cluster &slice, const SRVertexBranch &srVertexBranch, caf::SRNueEnergy &sre)
float truemuonE
True energy of primary muon [GeV].
unsigned int lastplane
last plane
Definition: SRHadClust.h:27
float recomuonE
Reconstructed muon energy for all neutrino energy estimators [GeV].
Definition: SRNumuEnergy.h:31
SRVector3D boxmax
Maximum coordinates box containing all the hits [cm].
Definition: SRHadClust.h:33
float NDHadTrkAct() const
Definition: NumuE.cxx:344
float NDTrkCalCat() const
Definition: NumuE.cxx:324
float NDTrkTranX() const
Definition: NumuE.cxx:364