All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
sbnd::GettingT0Tags Class Reference
Inheritance diagram for sbnd::GettingT0Tags:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 GettingT0Tags (Parameters const &config)
 
virtual void beginJob () override
 
virtual void analyze (const art::Event &event) override
 
virtual void endJob () override
 

Private Attributes

art::InputTag fSimModuleLabel
 name of detsim producer More...
 
art::InputTag fCRTHitT0Label
 name of CRT hit matching module More...
 
art::InputTag fCRTTrackT0Label
 name of CRT track matching module More...
 
art::InputTag fTPCTrackLabel
 name of TPC track producer More...
 
bool fVerbose
 print information about what's going on More...
 
int nTotal = 0
 
int nCrtHitMatched = 0
 
int nCrtHitCorrect = 0
 
int nCrtTrackMatched = 0
 
int nCrtTrackCorrect = 0
 

Detailed Description

Definition at line 42 of file GettingT0Tags_module.cc.

Member Typedef Documentation

using sbnd::GettingT0Tags::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 78 of file GettingT0Tags_module.cc.

Constructor & Destructor Documentation

sbnd::GettingT0Tags::GettingT0Tags ( Parameters const &  config)
explicit

Definition at line 112 of file GettingT0Tags_module.cc.

113  : EDAnalyzer(config)
114  , fSimModuleLabel (config().SimModuleLabel())
115  , fCRTHitT0Label (config().CRTHitT0Label())
116  , fCRTTrackT0Label (config().CRTTrackT0Label())
117  , fTPCTrackLabel (config().TPCTrackLabel())
118  , fVerbose (config().Verbose())
119  {
120 
121  } //GettingT0Tags()
BEGIN_PROLOG Verbose
art::InputTag fTPCTrackLabel
name of TPC track producer
art::InputTag fCRTTrackT0Label
name of CRT track matching module
BEGIN_PROLOG don t mess with this TPCTrackLabel
bool fVerbose
print information about what&#39;s going on
art::InputTag fSimModuleLabel
name of detsim producer
art::InputTag fCRTHitT0Label
name of CRT hit matching module

Member Function Documentation

void sbnd::GettingT0Tags::analyze ( const art::Event &  event)
overridevirtual

Definition at line 133 of file GettingT0Tags_module.cc.

134  {
135 
136  // Fetch basic event info
137  if(fVerbose){
138  std::cout<<"============================================"<<std::endl
139  <<"Run = "<<event.run()<<", SubRun = "<<event.subRun()<<", Event = "<<event.id().event()<<std::endl
140  <<"============================================"<<std::endl;
141  }
142 
143  //----------------------------------------------------------------------------------------------------------
144  // GETTING PRODUCTS
145  //----------------------------------------------------------------------------------------------------------
146 
147  // Get g4 particles
148  auto particleHandle = event.getValidHandle<std::vector<simb::MCParticle>>(fSimModuleLabel);
149  // Put into a map for easier access
150  std::map<int, simb::MCParticle> particles;
151  for (auto const& particle: (*particleHandle)){
152  int partID = particle.TrackId();
153  particles[partID] = particle;
154  }
155 
156  // Get reconstructed tracks from the event
157  auto tpcTrackHandle = event.getValidHandle<std::vector<recob::Track>>(fTPCTrackLabel);
158 
159  // Get the associated hits
160  art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event, fTPCTrackLabel);
161 
162  // Get the associated T0 from CRT hit matching
163  art::FindManyP<anab::T0> findManyHitT0(tpcTrackHandle, event, fCRTHitT0Label);
164 
165  // Get the associated T0 from CRT track matching
166  art::FindManyP<anab::T0> findManyTrackT0(tpcTrackHandle, event, fCRTTrackT0Label);
167 
168  //----------------------------------------------------------------------------------------------------------
169  // GETTING THE T0 TAGS
170  //----------------------------------------------------------------------------------------------------------
171 
172  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
173 
174  // Loop over reconstructed tracks
175  for (auto const& tpcTrack : (*tpcTrackHandle)){
176  // Get the associated hits
177  std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
178 
179  // Get the true particle
180  int trackTrueID = RecoUtils::TrueParticleIDFromTotalRecoHits(clockData, hits, false);
181  if(particles.find(trackTrueID) == particles.end()) continue;
182 
183  // Only consider primary muons
184  if(!(std::abs(particles[trackTrueID].PdgCode()) == 13 && particles[trackTrueID].Mother() == 0)) continue;
185 
186  // Only consider particles inside the reco hit time window
187  double trueTime = particles[trackTrueID].T() * 1e-3; // [us]
188  if(fVerbose) std::cout<<"True track time = "<<trueTime<<" us\n";
189 
190  nTotal++;
191 
192  // Retrieve the t0 from CRT hit matching
193  std::vector<art::Ptr<anab::T0>> hitT0s = findManyHitT0.at(tpcTrack.ID());
194  if(hitT0s.size() < 1){
195  if(fVerbose) std::cout<<"No matching CRT hit.\n";
196  }
197  else{
198  nCrtHitMatched++;
199  double hitT0 = hitT0s[0]->Time() * 1e-3; // [us]
200  if(fVerbose) std::cout<<"Hit matched time = "<<hitT0<<" us\n";
201  if(std::abs(trueTime - hitT0) < 2) nCrtHitCorrect++;
202  }
203 
204  // Retrieve the t0 from CRT track matching
205  std::vector<art::Ptr<anab::T0>> trackT0s = findManyTrackT0.at(tpcTrack.ID());
206  if(trackT0s.size() < 1){
207  if(fVerbose) std::cout<<"No matching CRT track.\n";
208  }
209  else{
211  double trackT0 = trackT0s[0]->Time() * 1e-3; // [us]
212  if(fVerbose) std::cout<<"Track matched time = "<<trackT0<<" us\n";
213  if(std::abs(trueTime - trackT0) < 2) nCrtTrackCorrect++;
214  }
215 
216  if(fVerbose) std::cout<<"\n";
217 
218  }
219 
220 
221  } // GettingT0Tags::analyze()
art::InputTag fTPCTrackLabel
name of TPC track producer
art::InputTag fCRTTrackT0Label
name of CRT track matching module
T abs(T value)
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
bool fVerbose
print information about what&#39;s going on
art::InputTag fSimModuleLabel
name of detsim producer
do i e
art::InputTag fCRTHitT0Label
name of CRT hit matching module
BEGIN_PROLOG could also be cout
void sbnd::GettingT0Tags::beginJob ( )
overridevirtual

Definition at line 124 of file GettingT0Tags_module.cc.

125  {
126 
127  // Initial output
128  if(fVerbose) std::cout<<"----------------- Getting CRT t0 tags example -------------------"<<std::endl;
129 
130  } // GettingT0Tags::beginJob()
bool fVerbose
print information about what&#39;s going on
BEGIN_PROLOG could also be cout
void sbnd::GettingT0Tags::endJob ( )
overridevirtual

Definition at line 224 of file GettingT0Tags_module.cc.

224  {
225 
226  std::cout<<"Getting CRT t0 tags from reco file:\n"
227  <<"-- CRT hit matching:\n"
228  <<"---- Efficiency = "<<((double)nCrtHitMatched/nTotal)*100<<"%\n"
229  <<"---- Purity = "<<((double)nCrtHitCorrect/nCrtHitMatched)*100<<"%\n"
230  <<"-- CRT track matching:\n"
231  <<"---- Efficiency = "<<((double)nCrtTrackMatched/nTotal)*100<<"%\n"
232  <<"---- Purity = "<<((double)nCrtTrackCorrect/nCrtTrackMatched)*100<<"%\n";
233 
234  } // GettingT0Tags::endJob()
BEGIN_PROLOG could also be cout

Member Data Documentation

art::InputTag sbnd::GettingT0Tags::fCRTHitT0Label
private

name of CRT hit matching module

Definition at line 96 of file GettingT0Tags_module.cc.

art::InputTag sbnd::GettingT0Tags::fCRTTrackT0Label
private

name of CRT track matching module

Definition at line 97 of file GettingT0Tags_module.cc.

art::InputTag sbnd::GettingT0Tags::fSimModuleLabel
private

name of detsim producer

Definition at line 95 of file GettingT0Tags_module.cc.

art::InputTag sbnd::GettingT0Tags::fTPCTrackLabel
private

name of TPC track producer

Definition at line 98 of file GettingT0Tags_module.cc.

bool sbnd::GettingT0Tags::fVerbose
private

print information about what's going on

Definition at line 99 of file GettingT0Tags_module.cc.

int sbnd::GettingT0Tags::nCrtHitCorrect = 0
private

Definition at line 104 of file GettingT0Tags_module.cc.

int sbnd::GettingT0Tags::nCrtHitMatched = 0
private

Definition at line 103 of file GettingT0Tags_module.cc.

int sbnd::GettingT0Tags::nCrtTrackCorrect = 0
private

Definition at line 106 of file GettingT0Tags_module.cc.

int sbnd::GettingT0Tags::nCrtTrackMatched = 0
private

Definition at line 105 of file GettingT0Tags_module.cc.

int sbnd::GettingT0Tags::nTotal = 0
private

Definition at line 102 of file GettingT0Tags_module.cc.


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