Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
gar::MomentumPerformance Class Reference
Inheritance diagram for gar::MomentumPerformance:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 MomentumPerformance (fhicl::ParameterSet const &p)
 
 MomentumPerformance (MomentumPerformance const &)=delete
 
 MomentumPerformance (MomentumPerformance &&)=delete
 
MomentumPerformanceoperator= (MomentumPerformance const &)=delete
 
MomentumPerformanceoperator= (MomentumPerformance &&)=delete
 
virtual void beginJob () override
 
void analyze (art::Event const &e) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void ClearVectors ()
 
void FillVectors (art::Event const &e)
 
void processIonizationInfo (rec::TrackIoniz &ion, float ionizeTruncate, float &forwardIonVal, float &backwardIonVal)
 
float processOneDirection (std::vector< std::pair< float, float >> SigData, float ionizeTruncate)
 

Static Private Member Functions

static bool lessThan_byE (std::pair< float, float > a, std::pair< float, float > b)
 

Private Attributes

double ItsInTulsa [3]
 
std::string fGeantLabel
 
std::string fTPCClusterLabel
 
std::string fTrackLabel
 
float fIonizTruncate
 
TTree * fTree
 
cheat::BackTrackerCorefBack
 
Int_t fRun
 
Int_t fSubRun
 
Int_t fEvent
 
Int_t fNeutrinoType
 
Int_t fCCNC
 
Int_t fMode
 
Int_t fInteractionType
 
Float_t fMCVertexX
 
Float_t fMCVertexY
 
Float_t fMCVertexZ
 
std::vector< Int_t > fMCP_PDG
 
std::vector< Float_t > fMCP_X
 
std::vector< Float_t > fMCP_Y
 
std::vector< Float_t > fMCP_Z
 
std::vector< Float_t > fMCP_PX
 
std::vector< Float_t > fMCP_PY
 
std::vector< Float_t > fMCP_PZ
 
std::vector< Float_t > fMCP_Time
 
std::vector< Int_t > fBackMatchNo
 
std::vector< ULong64_t > fTrackIDNumber
 
std::vector< Float_t > fTrackX
 
std::vector< Float_t > fTrackY
 
std::vector< Float_t > fTrackZ
 
std::vector< Float_t > fTrackPX
 
std::vector< Float_t > fTrackPY
 
std::vector< Float_t > fTrackPZ
 
std::vector< Int_t > fTrackQ
 
std::vector< Float_t > fTrackLen
 
std::vector< Int_t > fNTPCClustersOnTrack
 
std::vector< Float_t > fTrackAvgIon
 
std::vector< Int_t > fNhitPicked
 
std::vector< Int_t > fNhitMatched
 
std::vector< Float_t > fTrackMCcosT
 
std::vector< Float_t > fTrackMCdelX
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 50 of file MomentumPerformance_module.cc.

Constructor & Destructor Documentation

gar::MomentumPerformance::MomentumPerformance ( fhicl::ParameterSet const &  p)
explicit

Definition at line 156 of file MomentumPerformance_module.cc.

156  : EDAnalyzer(p) {
157 
158  fGeantLabel = p.get<std::string>("GEANTLabel","geant");
159  fTPCClusterLabel = p.get<std::string>("TPCClusterLabel","tpccluster");
160  fTrackLabel = p.get<std::string>("TrackLabel","track");
161 
162  fIonizTruncate = p.get<float>("IonizTruncate", 0.70);
163 
164 
165 
166  consumesMany<std::vector<simb::MCTruth> >();
167  consumes<std::vector<simb::MCParticle> >(fGeantLabel);
168 
169  consumes<std::vector<rec::TPCCluster> >(fTPCClusterLabel);
170  consumes<art::Assns<rec::Track, rec::TPCCluster> >(fTPCClusterLabel);
171  consumes<std::vector<rec::Track> >(fTrackLabel);
172  consumes<std::vector<rec::TrackIoniz>>(fTrackLabel);
173  consumes<art::Assns<rec::TrackIoniz, rec::Track>>(fTrackLabel);
174 
175 } // end constructor
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
gar::MomentumPerformance::MomentumPerformance ( MomentumPerformance const &  )
delete
gar::MomentumPerformance::MomentumPerformance ( MomentumPerformance &&  )
delete

Member Function Documentation

void gar::MomentumPerformance::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 244 of file MomentumPerformance_module.cc.

244  {
245 
246  ClearVectors();
248  fTree->Fill();
249  return;
250 }
void FillVectors(art::Event const &e)
Event finding and building.
void gar::MomentumPerformance::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 182 of file MomentumPerformance_module.cc.

182  {
183 
185  ItsInTulsa[0] = euclid->GetOriginX();
186  ItsInTulsa[1] = euclid->GetOriginY();
187  ItsInTulsa[2] = euclid->GetOriginZ();
188 
190  fTree = tfs->make<TTree>("GArAnaTree","GArAnaTree");
191 
192  cheat::BackTrackerCore const* const_bt = gar::providerFrom<cheat::BackTracker>();
193  fBack = const_cast<cheat::BackTrackerCore*>(const_bt);
194 
195 
196 
197  fTree->Branch("Run", &fRun, "Run/I");
198  fTree->Branch("SubRun", &fSubRun, "SubRun/I");
199  fTree->Branch("Event", &fEvent, "Event/I");
200 
201  fTree->Branch("NType", &fNeutrinoType, "Event/I");
202  fTree->Branch("CCNC", &fCCNC, "Event/I");
203  fTree->Branch("Mode", &fMode, "Event/I");
204  fTree->Branch("InterT", &fInteractionType, "Event/I");
205  fTree->Branch("MCVertX", &fMCVertexX, "Event/F");
206  fTree->Branch("MCVertY", &fMCVertexY, "Event/F");
207  fTree->Branch("MCVertZ", &fMCVertexZ, "Event/F");
208 
209  fTree->Branch("MCP_PDG", &fMCP_PDG);
210  fTree->Branch("MCP_X", &fMCP_X);
211  fTree->Branch("MCP_Y", &fMCP_Y);
212  fTree->Branch("MCP_Z", &fMCP_Z);
213  fTree->Branch("MCP_PX", &fMCP_PX);
214  fTree->Branch("MCP_PY", &fMCP_PY);
215  fTree->Branch("MCP_PZ", &fMCP_PZ);
216  fTree->Branch("MCP_Time", &fMCP_Time);
217 
218  fTree->Branch("BackMatchNo", &fBackMatchNo);
219  fTree->Branch("TrackIDNumber", &fTrackIDNumber);
220  fTree->Branch("TrackX", &fTrackX);
221  fTree->Branch("TrackY", &fTrackY);
222  fTree->Branch("TrackZ", &fTrackZ);
223  fTree->Branch("TrackPX", &fTrackPX);
224  fTree->Branch("TrackPY", &fTrackPY);
225  fTree->Branch("TrackPZ", &fTrackPZ);
226  fTree->Branch("TrackQ", &fTrackQ);
227  fTree->Branch("TrackLen", &fTrackLen);
228  fTree->Branch("NTPCClustersOnTrack", &fNTPCClustersOnTrack);
229  fTree->Branch("TrackAvgIon", &fTrackAvgIon);
230 
231  fTree->Branch("NhitPicked", &fNhitPicked);
232  fTree->Branch("NhitMatched", &fNhitMatched);
233  fTree->Branch("TrackMCcosT", &fTrackMCcosT);
234  fTree->Branch("TrackMCdelX", &fTrackMCdelX);
235 
236  return;
237 } // End of :MomentumPerformance::beginJob
std::vector< Int_t > fNTPCClustersOnTrack
cheat::BackTrackerCore * fBack
std::vector< ULong64_t > fTrackIDNumber
void gar::MomentumPerformance::ClearVectors ( )
private

Definition at line 257 of file MomentumPerformance_module.cc.

257  {
258  // clear out all our vectors
259  fMCP_PDG.clear();
260  fMCP_X.clear();
261  fMCP_Y.clear();
262  fMCP_Z.clear();
263  fMCP_PX.clear();
264  fMCP_PY.clear();
265  fMCP_PZ.clear();
266  fMCP_Time.clear();
267 
268  fBackMatchNo.clear();
269  fTrackIDNumber.clear();
270  fTrackX.clear();
271  fTrackY.clear();
272  fTrackZ.clear();
273  fTrackPX.clear();
274  fTrackPY.clear();
275  fTrackPZ.clear();
276  fTrackQ.clear();
277  fTrackLen.clear();
278  fTrackAvgIon.clear();
279  fNTPCClustersOnTrack.clear();
280 
281  fTrackMCcosT.clear();
282  fTrackMCdelX.clear();
283 
284  return;
285 } // end :MomentumPerformance::ClearVectors
std::vector< Int_t > fNTPCClustersOnTrack
std::vector< ULong64_t > fTrackIDNumber
void gar::MomentumPerformance::FillVectors ( art::Event const &  e)
private

Definition at line 292 of file MomentumPerformance_module.cc.

292  {
293 
294 
295 
296  // ============= Get art handles ==========================================
297  // Get handles for MCinfo, also good for MCPTrajectory. Want to get all
298  // MCTruths, regardless of generator label.
299 
300  auto mctruthHandles = event.getMany<std::vector<simb::MCTruth> >();
301 
302  if (mctruthHandles.size()!=1) {
303  throw cet::exception("MomentumPerformance") << " Need just 1 simb::MCTruth"
304  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
305  }
306 
307  auto MCPHandle = event.getHandle< std::vector<simb::MCParticle> >(fGeantLabel);
308  if (!MCPHandle) {
309  throw cet::exception("MomentumPerformance") << " No simb::MCParticle"
310  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
311  }
312 
313  // Get handles for Tracks and their ionizations; also Assn's to TPCClusters, TrackIoniz
314  art::FindOneP<rec::TrackIoniz>* findIonization = NULL;
315 
316  auto TrackHandle = event.getHandle< std::vector<rec::Track> >(fTrackLabel);
317  if (!TrackHandle) {
318  throw cet::exception("MomentumPerformance") << " No rec::Track"
319  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
320  }
321 
322  auto TrackIonHandle = event.getHandle< std::vector<rec::TrackIoniz> >(fTrackLabel);
323  if (!TrackIonHandle) {
324  throw cet::exception("MomentumPerformance") << " No rec::TrackIoniz"
325  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
326  }
327  findIonization = new art::FindOneP<rec::TrackIoniz>(TrackHandle,event,fTrackLabel);
328 
329 
330 
331 
332 
333  // ============= Pull art handles =========================================
334  fRun = event.run();
335  fSubRun = event.subRun();
336  fEvent = event.id().event();
337 
338 
339 
340  // save MCTruth info. This analysis is designed for single-interaction MC
341  for ( simb::MCTruth const& mct : *(mctruthHandles.at(0)) ) {
342  if (!mct.NeutrinoSet()) return;
343  simb::MCNeutrino nuw = mct.GetNeutrino();
344  fNeutrinoType = nuw.Nu().PdgCode();
345  fCCNC = nuw.CCNC();
346  fMode = nuw.Mode();
348  fMCVertexX = nuw.Nu().EndX();
349  fMCVertexY = nuw.Nu().EndY();
350  fMCVertexZ = nuw.Nu().EndZ();
351  } // end MC info from MCTruth
352 
353  typedef int TrkId;
354  std::unordered_map<TrkId, Int_t> TrackIdToIndex;
355  Int_t index = 0;
356  for ( auto const& mcp : *MCPHandle ) {
357  int TrackId = mcp.TrackId();
358  TrackIdToIndex[TrackId] = index++;
359  }
360 
361 
362 
363  for ( simb::MCParticle mcp : *MCPHandle ) {
364  // If mcp.Mother() == 0, particle is from initial vertex;
365  TrkId momTrkId = mcp.Mother();
366  int momPDG = 0;
367  if (momTrkId>0) {
368  if(TrackIdToIndex.find(momTrkId) != TrackIdToIndex.end()){
369  Int_t momIndex = TrackIdToIndex[momTrkId];
370  momPDG = (*MCPHandle).at(momIndex).PdgCode();
371  } else {
372  throw cet::exception("MomentumPerformance") << " mcp trackid "
373  << mcp.TrackId() << " pdg code " << mcp.PdgCode()
374  << " could not find mother trk id " << momTrkId
375  << " in the TrackIdToIndex map; creating process is "
376  << mcp.Process() << "\nLine " << __LINE__ << " in file "
377  << __FILE__ << std::endl;
378  }
379  }
380  if (momPDG != 0) continue;
381 
382 
383 
384  // Pick up muons, electrons, charged pions, protons
385  int thisPDG = mcp.PdgCode();
386  bool isTrackable =
387  abs(thisPDG)==13 || abs(thisPDG)==11 || abs(thisPDG)==211 || abs(thisPDG)==2212;
388  if (!isTrackable) continue;
389 
390  const TLorentzVector& positionMCP = mcp.Position(0);
391  const TLorentzVector& momentumMCP = mcp.Momentum(0);
392 
393 
394 
395  // OK get the matching tracks from the backtracker. First collect yer tracks
396  std::vector<art::Ptr<rec::Track>> allTracks;
397  auto const trackPtrMaker = art::PtrMaker<rec::Track>(event,TrackHandle.id());
398  for (size_t iTrack=0; iTrack<TrackHandle->size(); ++iTrack ) {
399  allTracks.push_back( trackPtrMaker(iTrack) );
400  }
401 
402  std::vector<art::Ptr<rec::Track>> matchedTracks;
403  matchedTracks = fBack->MCParticleToTracks(&mcp,allTracks);
404 
405 
406 
407  // Which track end you want?
408  float minDist = 1e6;
409  int pickedTrack = -1;
411  size_t iTrack;
412  for (iTrack=0; iTrack<matchedTracks.size(); ++iTrack) {
413  rec::Track track = *(matchedTracks[iTrack]);
414  float distStart = std::hypot(track.Vertex()[0] -positionMCP[0],
415  track.Vertex()[1] -positionMCP[1],
416  track.Vertex()[2] -positionMCP[2]);
417  float distEnd = std::hypot(track.End()[0] -positionMCP[0],
418  track.End()[1] -positionMCP[1],
419  track.End()[2] -positionMCP[2]);
420  if (distStart<distEnd) {
421  if (distStart<minDist) {
422  pickedTrack = iTrack;
423  minDist = distStart;
424  kate = rec::TrackEndBeg;
425  }
426  } else {
427  if (distEnd<minDist) {
428  pickedTrack = iTrack;
429  minDist = distEnd;
430  kate = rec::TrackEndEnd;
431  }
432  }
433  }
434  if (pickedTrack == -1) continue;
435 
436 
437 
438  // Save that tracks info; but first you need the corresponding MC info
439  fMCP_PDG.push_back(thisPDG);
440  fMCP_X.push_back(positionMCP.X());
441  fMCP_Y.push_back(positionMCP.Y());
442  fMCP_Z.push_back(positionMCP.Z());
443  fMCP_PX.push_back(momentumMCP.Px());
444  fMCP_PY.push_back(momentumMCP.Py());
445  fMCP_PZ.push_back(momentumMCP.Pz());
446  fMCP_Time.push_back(mcp.T());
447 
448  fBackMatchNo.push_back(iTrack);
449  rec::Track theTrack = *(matchedTracks[pickedTrack]);
450  fTrackIDNumber.push_back(theTrack.getIDNumber());
451 
452  TVector3* trackInPhase; TVector3* trackInSpace;
453 
454  if (kate==rec::TrackEndBeg) {
455  fTrackX.push_back (theTrack.Vertex()[0]);
456  fTrackY.push_back (theTrack.Vertex()[1]);
457  fTrackZ.push_back (theTrack.Vertex()[2]);
458  fTrackPX.push_back (theTrack.Momentum_beg()*theTrack.VtxDir()[0]);
459  fTrackPY.push_back (theTrack.Momentum_beg()*theTrack.VtxDir()[1]);
460  fTrackPZ.push_back (theTrack.Momentum_beg()*theTrack.VtxDir()[2]);
461  fTrackQ.push_back (theTrack.ChargeBeg());
462  fTrackLen.push_back(theTrack.LengthBackward());
463  trackInPhase = new TVector3( theTrack.VtxDir() );
464  trackInSpace = new TVector3( theTrack.Vertex() );
465  } else {
466  fTrackX.push_back (theTrack.End()[0]);
467  fTrackY.push_back (theTrack.End()[1]);
468  fTrackZ.push_back (theTrack.End()[2]);
469  fTrackPX.push_back (theTrack.Momentum_end()*theTrack.EndDir()[0]);
470  fTrackPY.push_back (theTrack.Momentum_end()*theTrack.EndDir()[1]);
471  fTrackPZ.push_back (theTrack.Momentum_end()*theTrack.EndDir()[2]);
472  fTrackQ.push_back (theTrack.ChargeEnd());
473  fTrackLen.push_back(theTrack.LengthForward());
474  trackInPhase = new TVector3( theTrack.EndDir() );
475  trackInSpace = new TVector3( theTrack.End() );
476  }
477  fNTPCClustersOnTrack.push_back(theTrack.NHits());
478 
479 
480  // What fraction of the hits in all tracks matched to this MCParticle
481  // are in the pickedTrack?
482  int num, den; num = den = 0;
483  for (int iTrack_local=0; iTrack_local<(int)matchedTracks.size(); ++iTrack_local) {
484  rec::Track thisTrack = *(matchedTracks[iTrack_local]);
485  std::vector<art::Ptr<rec::Hit>> umlazi = fBack->TrackToHits(&thisTrack);
486  den += umlazi.size();
487  if (iTrack_local == pickedTrack) num += umlazi.size();
488  }
489  fNhitPicked.push_back(num);
490  fNhitMatched.push_back(den);
491 
492  // And spatial track-matching info
493  float cosT = (*trackInPhase)[0]*momentumMCP.Px()
494  +(*trackInPhase)[1]*momentumMCP.Py()
495  +(*trackInPhase)[2]*momentumMCP.Pz();
496  cosT /= momentumMCP.P();
497  fTrackMCcosT.push_back(cosT);
498 
499  TVector3 vecX( (*trackInSpace)[0] -positionMCP.X(),
500  (*trackInSpace)[1] -positionMCP.Y(),
501  (*trackInSpace)[2] -positionMCP.Z() );
502  float delX = vecX.Cross(*trackInPhase).Mag();
503  fTrackMCdelX.push_back(delX);
504 
505 
506 
507  // Need to determine which track in TrackHandle is the one
508  // picked from matchedTracks
509  int iPickedTrack = -1;
510  for (size_t iTrack_local=0; iTrack_local<TrackHandle->size(); ++iTrack_local ) {
511  if ( allTracks[iTrack_local]->getIDNumber() == theTrack.getIDNumber() ) {
512  iPickedTrack = iTrack_local;
513  break;
514  }
515  }
516  if (iPickedTrack>=0 && findIonization->isValid()) {
517  // No calibration for now. Someday this should all be in reco
518  rec::TrackIoniz ionization = *(findIonization->at(iPickedTrack));
519  float avgIonF, avgIonB;
520  processIonizationInfo(ionization, fIonizTruncate, avgIonF, avgIonB);
521  if (kate==rec::TrackEndBeg) {
522  fTrackAvgIon.push_back( avgIonF );
523  } else {
524  fTrackAvgIon.push_back( avgIonB );
525  }
526  } else {
527  // must push_back something so that fTrackAvgIon is of correct size.
528  fTrackAvgIon.push_back( 0.0 );
529  }
530 
531  } // end loop on MCParticles
532 
533 } // end MomentumPerformance::FillVectors
void processIonizationInfo(rec::TrackIoniz &ion, float ionizeTruncate, float &forwardIonVal, float &backwardIonVal)
int PdgCode() const
Definition: MCParticle.h:212
int CCNC() const
Definition: MCNeutrino.h:148
int TrackEnd
Definition: Track.h:32
std::vector< art::Ptr< rec::Track > > MCParticleToTracks(simb::MCParticle *const p, std::vector< art::Ptr< rec::Track >> const &tracks)
std::vector< art::Ptr< rec::Hit > > const TrackToHits(rec::Track *const t)
double EndZ() const
Definition: MCParticle.h:228
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
TrackEnd const TrackEndEnd
Definition: Track.h:33
double EndY() const
Definition: MCParticle.h:227
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
Definition: hypot.h:60
int InteractionType() const
Definition: MCNeutrino.h:150
T abs(T value)
std::vector< Int_t > fNTPCClustersOnTrack
cheat::BackTrackerCore * fBack
TrackEnd const TrackEndBeg
Definition: Track.h:33
std::vector< ULong64_t > fTrackIDNumber
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
Event generator information.
Definition: MCTruth.h:32
double EndX() const
Definition: MCParticle.h:226
Event generator information.
Definition: MCNeutrino.h:18
int Mode() const
Definition: MCNeutrino.h:149
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
static bool gar::MomentumPerformance::lessThan_byE ( std::pair< float, float >  a,
std::pair< float, float >  b 
)
inlinestaticprivate

Definition at line 78 of file MomentumPerformance_module.cc.

79  {return a.first < b.first;}
const double a
static bool * b
Definition: config.cpp:1043
MomentumPerformance& gar::MomentumPerformance::operator= ( MomentumPerformance const &  )
delete
MomentumPerformance& gar::MomentumPerformance::operator= ( MomentumPerformance &&  )
delete
void gar::MomentumPerformance::processIonizationInfo ( rec::TrackIoniz ion,
float  ionizeTruncate,
float &  forwardIonVal,
float &  backwardIonVal 
)
private

Definition at line 541 of file MomentumPerformance_module.cc.

542  {
543 
544  // NO CALIBRATION SERVICE FOR NOW
545 
546  std::vector<std::pair<float,float>> SigData = ion.getFWD_dSigdXs();
547  forwardIonVal = processOneDirection(SigData, ionizeTruncate);
548 
549  SigData = ion.getBAK_dSigdXs();
550  backwardIonVal = processOneDirection(SigData, ionizeTruncate);
551 
552  return;
553 }
float processOneDirection(std::vector< std::pair< float, float >> SigData, float ionizeTruncate)
float gar::MomentumPerformance::processOneDirection ( std::vector< std::pair< float, float >>  SigData,
float  ionizeTruncate 
)
private

Definition at line 557 of file MomentumPerformance_module.cc.

557  {
558 
559  std::vector<std::pair<float,float>> dEvsX; // Ionization vs distance along track
560 
561  // The first hit on the track never had its ionization info stored. Not a problem
562  // really. Each pair is a hit and the step along the track that ends at the hit
563  // For the last hit, just take the step from the n-1 hit; don't guess some distance
564  // to (nonexistant!) n+1 hit. Using pointer arithmetic because you are a real K&R
565  // C nerd! Except that C++ doesn't know you are such a nerd and if
566  // SigData.size()==0, then SigData.end()-1 is 0xFFFFFFFFFFFFFFF8.
567  if (SigData.size()==0) return 0.0;
568  float distAlongTrack = 0;
569  std::vector<std::pair<float,float>>::iterator littlebit = SigData.begin();
570  for (; littlebit<(SigData.end()-1); ++littlebit) {
571  float dE = std::get<0>(*littlebit);
572  // tpctrackfit2_module.cc fills the TrackIoniz data product so that
573  // this quantity is really dL > 0 not dX, a coordinate on the drift axis
574  float dX = std::get<1>(*littlebit);
575  distAlongTrack += dX; // But count full step to get hit position on track
576  // Take dX to be 1/2 the previous + last segment
577  dX += std::get<1>(*(littlebit+1));
578  float dEdX = dE/(0.5*dX);
579 
580  std::pair pushme = std::make_pair(dEdX,distAlongTrack);
581  dEvsX.push_back( pushme );
582  }
583 
584  // Get the truncated mean; first sort then take mean
585  std::sort(dEvsX.begin(),dEvsX.end(), lessThan_byE);
586 
587  // Get the dEdX vs length data, truncated.
588  int goUpTo = ionizeTruncate * dEvsX.size() +0.5;
589  if (goUpTo > (int)dEvsX.size()) goUpTo = dEvsX.size();
590  int i = 1; float returnvalue = 0;
591  littlebit = dEvsX.begin();
592  for (; littlebit<dEvsX.end(); ++littlebit) {
593  returnvalue += std::get<0>(*littlebit);
594  ++i;
595  if (i>goUpTo) break;
596  }
597  returnvalue /= goUpTo;
598  return returnvalue;
599 }
double dEdX(double KE, const simb::MCParticle *part)
static bool lessThan_byE(std::pair< float, float > a, std::pair< float, float > b)

Member Data Documentation

cheat::BackTrackerCore* gar::MomentumPerformance::fBack
private

Definition at line 99 of file MomentumPerformance_module.cc.

std::vector<Int_t> gar::MomentumPerformance::fBackMatchNo
private

Definition at line 129 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fCCNC
private

Definition at line 111 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fEvent
private

Definition at line 107 of file MomentumPerformance_module.cc.

std::string gar::MomentumPerformance::fGeantLabel
private

Definition at line 88 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fInteractionType
private

Definition at line 113 of file MomentumPerformance_module.cc.

float gar::MomentumPerformance::fIonizTruncate
private

Definition at line 93 of file MomentumPerformance_module.cc.

std::vector<Int_t> gar::MomentumPerformance::fMCP_PDG
private

Definition at line 119 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_PX
private

Definition at line 123 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_PY
private

Definition at line 124 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_PZ
private

Definition at line 125 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_Time
private

Definition at line 126 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_X
private

Definition at line 120 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_Y
private

Definition at line 121 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fMCP_Z
private

Definition at line 122 of file MomentumPerformance_module.cc.

Float_t gar::MomentumPerformance::fMCVertexX
private

Definition at line 114 of file MomentumPerformance_module.cc.

Float_t gar::MomentumPerformance::fMCVertexY
private

Definition at line 115 of file MomentumPerformance_module.cc.

Float_t gar::MomentumPerformance::fMCVertexZ
private

Definition at line 116 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fMode
private

Definition at line 112 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fNeutrinoType
private

Definition at line 110 of file MomentumPerformance_module.cc.

std::vector<Int_t> gar::MomentumPerformance::fNhitMatched
private

Definition at line 144 of file MomentumPerformance_module.cc.

std::vector<Int_t> gar::MomentumPerformance::fNhitPicked
private

Definition at line 143 of file MomentumPerformance_module.cc.

std::vector<Int_t> gar::MomentumPerformance::fNTPCClustersOnTrack
private

Definition at line 139 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fRun
private

Definition at line 105 of file MomentumPerformance_module.cc.

Int_t gar::MomentumPerformance::fSubRun
private

Definition at line 106 of file MomentumPerformance_module.cc.

std::string gar::MomentumPerformance::fTPCClusterLabel
private

Definition at line 89 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackAvgIon
private

Definition at line 140 of file MomentumPerformance_module.cc.

std::vector<ULong64_t> gar::MomentumPerformance::fTrackIDNumber
private

Definition at line 130 of file MomentumPerformance_module.cc.

std::string gar::MomentumPerformance::fTrackLabel
private

Definition at line 90 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackLen
private

Definition at line 138 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackMCcosT
private

Definition at line 145 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackMCdelX
private

Definition at line 146 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackPX
private

Definition at line 134 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackPY
private

Definition at line 135 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackPZ
private

Definition at line 136 of file MomentumPerformance_module.cc.

std::vector<Int_t> gar::MomentumPerformance::fTrackQ
private

Definition at line 137 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackX
private

Definition at line 131 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackY
private

Definition at line 132 of file MomentumPerformance_module.cc.

std::vector<Float_t> gar::MomentumPerformance::fTrackZ
private

Definition at line 133 of file MomentumPerformance_module.cc.

TTree* gar::MomentumPerformance::fTree
private

Definition at line 96 of file MomentumPerformance_module.cc.

double gar::MomentumPerformance::ItsInTulsa[3]
private

Definition at line 85 of file MomentumPerformance_module.cc.


The documentation for this class was generated from the following file: