FillParentInfo.cxx
Go to the documentation of this file.
2 
3 #include "CosRej/CosRejObj.h"
4 #include "CVN/func/Result.h"
6 #include "NumuEnergy/NumuE.h"
7 #include "ReMId/ReMId.h"
8 #include "RecoBase/FitSum.h"
9 #include "RecoBase/Vertex.h"
10 
12 
16 #include "Geometry/Geometry.h"
17 
18 namespace caf
19 {
20 
21  // -------------------------------------------------------
22 
24  caf::SRMRCCParent& srparent,
25  const art::Event& evt)
26  {
27 
28  const int parentSliceIndex = parent.ParentIndex();
29  srparent.slcidx = parentSliceIndex;
30  srparent.eff = parent.ParentEff();
31  srparent.pur = parent.ParentPur();
32 
34  evt.getByLabel(slicelabel, sliceHandle);
35 
36  art::Ptr<rb::Cluster> parentSlice(sliceHandle,
37  parentSliceIndex);
38 
39  // find numu objects associated with parentslice
40  art::FindOneP<cvn::Result> cvnassn({parentSlice},
41  evt,
42  cvnlabel);
43  std::string loadtrack = "";
44  if ( whattracker == "kalman" ) loadtrack = trklabelkalman;
45  if ( whattracker == "bpf" ) loadtrack = trklabelbpf;
46  art::FindManyP<rb::Track> trackassn({parentSlice},
47  evt,
48  loadtrack);
49  art::FindOneP<numue::NumuE> numueassn({parentSlice},
50  evt,
51  numuelabel);
52  art::FindOneP<cosrej::CosRejObj> cosrejassn({parentSlice},
53  evt,
54  cosrejlabel);
55  FillSliceInfo( parentSlice, srparent);
56  if(cvnassn.isValid() &&
57  trackassn.isValid() &&
58  cosrejassn.isValid() &&
59  numueassn.isValid()){
60  FillNumuInfo( cvnassn.at(0),
61  trackassn.at(0),
62  numueassn.at(0),
63  cosrejassn.at(0),
64  evt,
65  srparent,
66  parentSlice );
67  }
68  }// end of FillParentInfo
69 
70 
71  // -------------------------------------------------------
72 
74  const std::vector< art::Ptr<rb::Track>>& trks,
75  const art::Ptr<numue::NumuE>& numuE,
76  const art::Ptr<cosrej::CosRejObj>& cosrejobj,
77  const art::Event& evt,
79  const art::Ptr<rb::Cluster>& slice)
80  {
81  // CVNm is the sum of the first four matches of cvn's output
82  if (cvn) parent.cvnm = cvn->fOutput[0];
83 
84  if(trks.empty())
85  return;
86 
87  // Fill variables if Kalman track module was used
88  if ( whattracker == "kalman" ){
89  art::FindOneP<remid::ReMId> remidassn(trks, evt, remidlabel);
90  if(remidassn.isValid()){
91  int ntrk = trks.size();
92  int muidx = -1;
93  float maxremid = -1;
94  for ( int itrk = 0; itrk < ntrk; itrk++ ){
95  art::Ptr<remid::ReMId> remid = remidassn.at(itrk);
96  if(!remid)
97  continue;
98  if(remid->Value() > maxremid){
99  maxremid = remid->Value();
100  muidx = itrk;
101  }
102  }// end loop over tracks
103 
104 
105  art::Ptr<rb::Track> mutrk = trks[muidx];
107 
108  parent.remid = maxremid;
109  parent.muonstart = mutrk->Start();
110  parent.muonstop = mutrk->Stop();
111 
112  if(muE.at(0))
113  parent.muE = muE.at(0)->E();
114 
115  } // end of isValid
116  } // end of Kalman case
117  if ( whattracker == "bpf" ){
118  double muonpid = -1;
119  /// Find the prong with the highest CVN score for mu
120  /// Get respective track and use it's info for filling the vars
121 
122  art::Ptr<rb::Prong> mostMuLikeProng;
123  art::Ptr<rb::Track> mostMuLikeTrack;
124  art::FindManyP<rb::Vertex> fmElastic ({slice}, evt, vtxlabel);
125  std::vector<art::Ptr<rb::Vertex>> elastics = fmElastic.at(0);
126 
127  if( elastics.size() > 0 ){
128  art::FindManyP<rb::Prong> fmFuzzyProng3D ( elastics, evt, pronglabel );
129  std::vector< art::Ptr<rb::Prong> > prongs = fmFuzzyProng3D.at(0);
130  art::FindManyP<rb::PID> fmCVNParticleResult(prongs, evt, cvnpronglabel );
131  for ( unsigned int iPng = 0; iPng < prongs.size(); ++iPng ) {
132  art::Ptr<rb::Prong> prong = prongs[iPng];
133  std::vector<art::Ptr<rb::PID>> cvnparts = fmCVNParticleResult.at(iPng);
134  for ( unsigned int j=0; j<cvnparts.size(); ++j ){
135  if ( abs(cvnparts[j]->Pdg()) == 13 ){
136  double thisPid = cvnparts[j]->Value();
137  if ( thisPid > muonpid ) {
138  muonpid = thisPid;
139  mostMuLikeProng = prongs[iPng];
140  }
141  }
142  }
143  /// for prongs with the length > 500 assume those are muons
144  if ( cvnparts.size() == 0 && fmCVNParticleResult.isValid() && prong->TotalLength() > 500){
145  muonpid = 1;
146  mostMuLikeProng = prongs[iPng];
147  }
148  } // end of prong loop
149  } // end of vtx
150 
151  art::FindManyP<rb::Track> fmMuLikeTracks ( {mostMuLikeProng}, evt, trklabelbpf);
152  std::vector< art::Ptr<rb::Track> > MuLikeTracks = fmMuLikeTracks.at(0);
153  art::FindManyP<rb::FitSum> fmBPFFitSums ( MuLikeTracks, evt, trklabelbpf );
154  double muonEnergy = -1;
155 
156  for ( unsigned int trackId = 0; trackId < MuLikeTracks.size(); ++trackId ){
157  if ( fmBPFFitSums.isValid() ){
158  std::vector<art::Ptr<rb::FitSum>> bpfFitSums = fmBPFFitSums.at(trackId);
159  if ( abs(bpfFitSums[0]->PDG()) == 13 ) {
160  muonEnergy = bpfFitSums[0]->FourMom().E();
161  mostMuLikeTrack=MuLikeTracks[trackId];
162  }
163  }
164  }
165 
166  art::Ptr<rb::Track> mutrk = mostMuLikeTrack;
167  parent.remid = muonpid;
168  parent.muonstart = mutrk->Start();
169  parent.muonstop = mutrk->Stop();
170 
171  parent.muE = muonEnergy;
172  } // end of bpf case
173 
174  if(cosrejobj){
175  parent.muonyattrans = cosrejobj->KalYPosAtTrans();
176  parent.muonfwdcell = cosrejobj->KalFwdCellND();
177  parent.muonbkcell = cosrejobj->KalBakCellND();
178  }
179  if(numuE){
180  parent.numuE = numuE->E();
181  parent.hadEinmucat = numuE->NDHadCalCat() +
182  numuE->NDHadCalTran();
183  }
184 
185  }// End of FillNumuInfo
186 
187  // -------------------------------------------------------
188 
189 
192  {
194  unsigned int mincellsfromedge = 500;
195  int nhit = slice->NCell();
196  for(int i = 0; i < parent.nhit; i++){
197  int plane = slice->Cell(i)->Plane();
198  unsigned int cell = slice->Cell(i)->Cell();
199  unsigned int cellsfromedge =
200  std::min(geom->Plane(plane)->Ncells()-1-cell,
201  cell);
202  if(cellsfromedge < mincellsfromedge)
203  mincellsfromedge = cellsfromedge;
204  }
205  parent.ncellsfromedge = mincellsfromedge;
206  parent.nhit = nhit;
207  parent.contplanes = slice->MostContiguousPlanes(geo::kXorY);
208  parent.firstplane = slice->MinPlane();
209  parent.lastplane = slice->MaxPlane();
210 
211  }
212 
213  // -------------------------------------------------------
214 
215 }// end of namespace murem
216 
const std::string slicelabel
const std::string remidlabel
float remid
ReMId value of the parent slice.
Definition: SRMRCCParent.h:44
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
const std::string cvnlabel
float E() const
Definition: Energy.cxx:27
float KalYPosAtTrans() const
Definition: CosRejObj.cxx:682
int ncellsfromedge
number of cells from detector edge
Definition: SRMRCCParent.h:37
X or Y views.
Definition: PlaneGeo.h:30
float hadEinmucat
hadronic energy in muon catcher and transition planes
Definition: SRMRCCParent.h:64
unsigned short Plane() const
Definition: CellHit.h:39
SRVector3D muonstart
muon track start
Definition: SRMRCCParent.h:49
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const std::string cvnpronglabel
nhit
Definition: demo1.py:25
float pur
Purity with which this event matched to the parent slice.
Definition: SRMRCCParent.h:30
const std::string pronglabel
void abs(TH1 *hist)
int KalBakCellND() const
Definition: CosRejObj.cxx:670
const PlaneGeo * Plane(unsigned int i) const
virtual TVector3 Start() const
Definition: Prong.h:73
Defines an enumeration for prong classification.
int firstplane
first plane in slice
Definition: SRMRCCParent.h:39
std::vector< float > fOutput
Vector of outputs from neural net.
Definition: Result.h:30
double Value() const
Definition: PID.h:22
float muonyattrans
muon y position at transition plane
Definition: SRMRCCParent.h:53
unsigned short Cell() const
Definition: CellHit.h:40
float numuE
energy of parent slice
Definition: SRMRCCParent.h:60
float ParentEff() const
Returns the efficiency of MRCC slice wrt the parent.
Definition: MRCCParent.h:41
void FillNumuInfo(const art::Ptr< cvn::Result > &cvn, const std::vector< art::Ptr< rb::Track >> &trks, const art::Ptr< numue::NumuE > &numuE, const art::Ptr< cosrej::CosRejObj > &cosrejobj, const art::Event &evt, SRMRCCParent &parent, const art::Ptr< rb::Cluster > &slice)
virtual double TotalLength() const
Distance along prong to reach last cell hit.
Definition: Prong.cxx:186
const std::string trklabelkalman
Result for CVN.
void FillSliceInfo(const art::Ptr< rb::Cluster > &slice, SRMRCCParent &parent)
void FillMRCCParentInfo(const murem::MRCCParent &parent, caf::SRMRCCParent &srparent, const art::Event &evt)
int evt
float muE
energy of muon
Definition: SRMRCCParent.h:62
const std::string vtxlabel
const double j
Definition: BetheBloch.cxx:29
float cvnm
CVNm value of the parent slice.
Definition: SRMRCCParent.h:46
SRVector3D muonstop
muon track stop
Definition: SRMRCCParent.h:51
const std::string trklabelbpf
int lastplane
last plane in slice
Definition: SRMRCCParent.h:41
Vertex location in position and time.
float NDHadCalTran() const
Definition: NumuE.cxx:334
float eff
Efficiency with which this event matched to the parent slice.
Definition: SRMRCCParent.h:28
An SRMRCCParent holds information about the slice that was parent to the current slice. It is currently being used by Muon Removed Charged Current Analysis.
Definition: SRMRCCParent.h:18
unsigned int MinPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.cxx:462
int contplanes
number of contiguous planes
Definition: SRMRCCParent.h:35
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
const std::string whattracker
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
int muonfwdcell
forward projected distance of muon end from detector edge in cells
Definition: SRMRCCParent.h:55
const std::string numuelabel
int MostContiguousPlanes(geo::View_t view) const
Longest run of adjacent planes with hits.
Definition: Cluster.cxx:635
void geom(int which=0)
Definition: geom.C:163
int nhit
number of hits in parent slice
Definition: SRMRCCParent.h:33
int KalFwdCellND() const
Definition: CosRejObj.cxx:658
unsigned int MaxPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.cxx:508
A PID for muons.
Definition: FillPIDs.h:10
This module creates Common Analysis Files.
Definition: FileReducer.h:10
int muonbkcell
backward projected distance of muon start from detector edge in cells
Definition: SRMRCCParent.h:57
int ParentIndex() const
Returns the index of the parent slice.
Definition: MRCCParent.h:35
int slcidx
Index of the parent slice.
Definition: SRMRCCParent.h:25
T min(const caf::Proxy< T > &a, T b)
TVector3 Stop() const
Position of the final trajectory point.
Definition: Track.cxx:186
float ParentPur() const
Returns the purity of MRCC slice wrt the parent.
Definition: MRCCParent.h:47
float NDHadCalCat() const
Definition: NumuE.cxx:339
Encapsulate the geometry of one entire detector (near, far, ndos)
const std::string cosrejlabel