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::RunningT0Tagging Class Reference
Inheritance diagram for sbnd::RunningT0Tagging:

Classes

struct  Config
 

Public Types

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

Public Member Functions

 RunningT0Tagging (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 fCRTHitLabel
 name of CRT hit producer More...
 
art::InputTag fCRTTrackLabel
 name of CRT track producer More...
 
art::InputTag fTPCTrackLabel
 name of TPC track producer More...
 
bool fVerbose
 print information about what's going on More...
 
CRTT0MatchAlg fCRTHitMatch
 CRT hit - TPC track matching algorithms. More...
 
CRTTrackMatchAlg fCRTTrackMatch
 CRT track - TPC track matching algorithms. More...
 
int nTotal = 0
 
int nCrtHitMatched = 0
 
int nCrtHitCorrect = 0
 
int nCrtTrackMatched = 0
 
int nCrtTrackCorrect = 0
 

Detailed Description

Definition at line 44 of file RunningT0Tagging_module.cc.

Member Typedef Documentation

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

Definition at line 88 of file RunningT0Tagging_module.cc.

Constructor & Destructor Documentation

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

Definition at line 125 of file RunningT0Tagging_module.cc.

126  : EDAnalyzer(config)
127  , fSimModuleLabel (config().SimModuleLabel())
128  , fCRTHitLabel (config().CRTHitLabel())
129  , fCRTTrackLabel (config().CRTTrackLabel())
130  , fTPCTrackLabel (config().TPCTrackLabel())
131  , fVerbose (config().Verbose())
132  , fCRTHitMatch (config().CRTHitMatch())
133  , fCRTTrackMatch (config().CRTTrackMatch())
134  {
135 
136  } //RunningT0Tagging()
BEGIN_PROLOG Verbose
art::InputTag fCRTHitLabel
name of CRT hit producer
art::InputTag fSimModuleLabel
name of detsim producer
CRTT0MatchAlg fCRTHitMatch
CRT hit - TPC track matching algorithms.
BEGIN_PROLOG don t mess with this TPCTrackLabel
CRTTrackMatchAlg fCRTTrackMatch
CRT track - TPC track matching algorithms.
bool fVerbose
print information about what&#39;s going on
art::InputTag fTPCTrackLabel
name of TPC track producer
art::InputTag fCRTTrackLabel
name of CRT track producer

Member Function Documentation

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

Definition at line 148 of file RunningT0Tagging_module.cc.

149  {
150 
151  // Fetch basic event info
152  if(fVerbose){
153  std::cout<<"============================================"<<std::endl
154  <<"Run = "<<event.run()<<", SubRun = "<<event.subRun()<<", Event = "<<event.id().event()<<std::endl
155  <<"============================================"<<std::endl;
156  }
157 
158  //----------------------------------------------------------------------------------------------------------
159  // GETTING PRODUCTS
160  //----------------------------------------------------------------------------------------------------------
161 
162  // Get g4 particles
163  auto particleHandle = event.getValidHandle<std::vector<simb::MCParticle>>(fSimModuleLabel);
164  // Put into a map for easier access
165  std::map<int, simb::MCParticle> particles;
166  for (auto const& particle: (*particleHandle)){
167  int partID = particle.TrackId();
168  particles[partID] = particle;
169  }
170 
171  // Get CRT hits from the event
172  auto crtHitHandle = event.getValidHandle<std::vector<sbn::crt::CRTHit>>(fCRTHitLabel);
173  std::vector<sbn::crt::CRTHit> crtHits;
174  for(auto const& hit : (*crtHitHandle)){
175  crtHits.push_back(hit);
176  }
177 
178  // Get CRT tracks from the event
179  auto crtTrackHandle = event.getValidHandle<std::vector<sbn::crt::CRTTrack>>(fCRTTrackLabel);
180  std::vector<sbn::crt::CRTTrack> crtTracks;
181  for(auto const& track : (*crtTrackHandle)){
182  crtTracks.push_back(track);
183  }
184 
185  // Get reconstructed tracks from the event
186  auto tpcTrackHandle = event.getValidHandle<std::vector<recob::Track>>(fTPCTrackLabel);
187 
188  // Get the associated hits
189  art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event, fTPCTrackLabel);
190 
191  //----------------------------------------------------------------------------------------------------------
192  // RUNNING THE T0 TAGGING
193  //----------------------------------------------------------------------------------------------------------
194 
195  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
196  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clockData);
197 
198  // Loop over reconstructed tracks
199  for (auto const& tpcTrack : (*tpcTrackHandle)){
200  // Get the associated hits
201  std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.ID());
202 
203  // Get the true particle
204  int trackTrueID = RecoUtils::TrueParticleIDFromTotalRecoHits(clockData, hits, false);
205  if(particles.find(trackTrueID) == particles.end()) continue;
206 
207  // Only consider primary muons
208  if(!(std::abs(particles[trackTrueID].PdgCode()) == 13 && particles[trackTrueID].Mother() == 0)) continue;
209 
210  // Only consider particles inside the reco hit time window
211  double trueTime = particles[trackTrueID].T() * 1e-3; // [us]
212  if(fVerbose) std::cout<<"True track time = "<<trueTime<<" us\n";
213 
214  nTotal++;
215 
216  // Calculate t0 from CRT hit matching
217  double hitT0 = fCRTHitMatch.T0FromCRTHits(detProp, tpcTrack, crtHits, event);
218  if(hitT0 == -99999){
219  if(fVerbose) std::cout<<"Couldn't match to CRT hit.\n";
220  }
221  else{
222  nCrtHitMatched++;
223  if(fVerbose) std::cout<<"Hit matched time = "<<hitT0<<" us\n";
224  if(std::abs(trueTime - hitT0) < 2) nCrtHitCorrect++;
225  }
226  // Calculate t0 from CRT track matching
227  double trackT0 = fCRTTrackMatch.T0FromCRTTracks(detProp, tpcTrack, crtTracks, event);
228  if(trackT0 == -99999){
229  if(fVerbose) std::cout<<"Couldn't match to CRT track.\n";
230  }
231  else{
233  if(fVerbose) std::cout<<"Track matched time = "<<trackT0<<" us\n";
234  if(std::abs(trueTime - trackT0) < 2) nCrtTrackCorrect++;
235  }
236 
237  if(fVerbose) std::cout<<"\n";
238 
239  }
240 
241 
242  } // RunningT0Tagging::analyze()
process_name use argoneut_mc_hitfinder track
process_name hit
Definition: cheaterreco.fcl:51
art::InputTag fCRTHitLabel
name of CRT hit producer
T abs(T value)
art::InputTag fSimModuleLabel
name of detsim producer
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
CRTT0MatchAlg fCRTHitMatch
CRT hit - TPC track matching algorithms.
CRTTrackMatchAlg fCRTTrackMatch
CRT track - TPC track matching algorithms.
double T0FromCRTHits(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTHit > crtHits, const art::Event &event)
bool fVerbose
print information about what&#39;s going on
do i e
double T0FromCRTTracks(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
art::InputTag fTPCTrackLabel
name of TPC track producer
art::InputTag fCRTTrackLabel
name of CRT track producer
BEGIN_PROLOG could also be cout
auto const detProp
void sbnd::RunningT0Tagging::beginJob ( )
overridevirtual

Definition at line 139 of file RunningT0Tagging_module.cc.

140  {
141 
142  // Initial output
143  if(fVerbose) std::cout<<"----------------- Running CRT t0 tagging example -------------------"<<std::endl;
144 
145  } // RunningT0Tagging::beginJob()
bool fVerbose
print information about what&#39;s going on
BEGIN_PROLOG could also be cout
void sbnd::RunningT0Tagging::endJob ( )
overridevirtual

Definition at line 245 of file RunningT0Tagging_module.cc.

245  {
246 
247  std::cout<<"Running CRT t0 tagging:\n"
248  <<"-- CRT hit matching:\n"
249  <<"---- Efficiency = "<<((double)nCrtHitMatched/nTotal)*100<<"%\n"
250  <<"---- Purity = "<<((double)nCrtHitCorrect/nCrtHitMatched)*100<<"%\n"
251  <<"-- CRT track matching:\n"
252  <<"---- Efficiency = "<<((double)nCrtTrackMatched/nTotal)*100<<"%\n"
253  <<"---- Purity = "<<((double)nCrtTrackCorrect/nCrtTrackMatched)*100<<"%\n";
254 
255  } // RunningT0Tagging::endJob()
BEGIN_PROLOG could also be cout

Member Data Documentation

art::InputTag sbnd::RunningT0Tagging::fCRTHitLabel
private

name of CRT hit producer

Definition at line 106 of file RunningT0Tagging_module.cc.

CRTT0MatchAlg sbnd::RunningT0Tagging::fCRTHitMatch
private

CRT hit - TPC track matching algorithms.

Definition at line 111 of file RunningT0Tagging_module.cc.

art::InputTag sbnd::RunningT0Tagging::fCRTTrackLabel
private

name of CRT track producer

Definition at line 107 of file RunningT0Tagging_module.cc.

CRTTrackMatchAlg sbnd::RunningT0Tagging::fCRTTrackMatch
private

CRT track - TPC track matching algorithms.

Definition at line 112 of file RunningT0Tagging_module.cc.

art::InputTag sbnd::RunningT0Tagging::fSimModuleLabel
private

name of detsim producer

Definition at line 105 of file RunningT0Tagging_module.cc.

art::InputTag sbnd::RunningT0Tagging::fTPCTrackLabel
private

name of TPC track producer

Definition at line 108 of file RunningT0Tagging_module.cc.

bool sbnd::RunningT0Tagging::fVerbose
private

print information about what's going on

Definition at line 109 of file RunningT0Tagging_module.cc.

int sbnd::RunningT0Tagging::nCrtHitCorrect = 0
private

Definition at line 117 of file RunningT0Tagging_module.cc.

int sbnd::RunningT0Tagging::nCrtHitMatched = 0
private

Definition at line 116 of file RunningT0Tagging_module.cc.

int sbnd::RunningT0Tagging::nCrtTrackCorrect = 0
private

Definition at line 119 of file RunningT0Tagging_module.cc.

int sbnd::RunningT0Tagging::nCrtTrackMatched = 0
private

Definition at line 118 of file RunningT0Tagging_module.cc.

int sbnd::RunningT0Tagging::nTotal = 0
private

Definition at line 115 of file RunningT0Tagging_module.cc.


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