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

Public Member Functions

 CRTT0Matching (fhicl::ParameterSet const &p)
 
 CRTT0Matching (CRTT0Matching const &)=delete
 
 CRTT0Matching (CRTT0Matching &&)=delete
 
CRTT0Matchingoperator= (CRTT0Matching const &)=delete
 
CRTT0Matchingoperator= (CRTT0Matching &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
void endJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 

Private Attributes

std::vector< art::InputTag > fTpcTrackModuleLabel
 name of track producer More...
 
std::vector< art::InputTag > fPFParticleLabel
 labels for source of PFParticle More...
 
art::InputTag fCrtHitModuleLabel
 name of crt producer More...
 
art::InputTag fTriggerLabel
 labels for trigger More...
 
CRTT0MatchAlg t0Alg
 
geo::GeometryCore const * fGeometryService
 pointer to Geometry provider More...
 
icarus::crt::CRTCommonUtilsfCrtutils
 
TTree * fTree
 
int fEvent
 number of the event being processed More...
 
int fRun
 number of the run being processed More...
 
int fSubRun
 number of the sub-run being processed More...
 
vector< int > fCrtRegion
 
vector< double > fDCA
 
vector< double > fDOL
 
vector< double > fT0
 
vector< double > ftpcx
 
vector< double > ftpcy
 
vector< double > ftpcz
 
vector< double > fcrtx
 
vector< double > fcrty
 
vector< double > fcrtz
 
vector< double > fpandorat0
 Track T0 based on Pandora (Cathode Crossing Track) More...
 
vector< int > fcryo
 cryo number More...
 
vector< int > fntracks
 total number of tracks More...
 
unsigned int m_gate_type
 
std::string m_gate_name
 
uint64_t m_trigger_timestamp
 
uint64_t m_gate_start_timestamp
 
uint64_t m_trigger_gate_diff
 
uint64_t m_gate_crt_diff
 
std::map< std::string, TH1F * > hDCA
 
std::map< std::string, TH1F * > hMatchDCA
 
std::map< std::string, TH1F * > hNoMatchDCA
 
std::map< std::string, TH1F * > hDoL
 
std::map< std::string, TH1F * > hMatchDoL
 
std::map< std::string, TH1F * > hNoMatchDoL
 
std::map< std::string, TH1F * > hT0
 
std::map< std::string, TH1F * > hMatchT0
 
std::map< std::string, TH1F * > hNoMatchT0
 

Detailed Description

Definition at line 68 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

Constructor & Destructor Documentation

icarus::CRTT0Matching::CRTT0Matching ( fhicl::ParameterSet const &  p)
explicit

Definition at line 149 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

150  : EDProducer(p), t0Alg(p.get<fhicl::ParameterSet>("T0Alg"))
152  // Initialize member data here, if know don't want to reconfigure on the fly
153  {
154 
155  // Call appropriate produces<>() functions here.
156  produces< std::vector<anab::T0> >();
157  produces< art::Assns<recob::Track , anab::T0> >();
158  produces< art::Assns<sbn::crt::CRTHit, anab::T0> >();
159 
160  fGeometryService = lar::providerFrom<geo::Geometry>();
161  reconfigure(p);
162 
163  } // CRTT0Matching()
pdgs p
Definition: selectors.fcl:22
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
void reconfigure(fhicl::ParameterSet const &p)
icarus::CRTT0Matching::CRTT0Matching ( CRTT0Matching const &  )
delete
icarus::CRTT0Matching::CRTT0Matching ( CRTT0Matching &&  )
delete

Member Function Documentation

void icarus::CRTT0Matching::beginJob ( )
override

Definition at line 175 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

176  {
177  // Access tfileservice to handle creating and writing histograms
178  art::ServiceHandle<art::TFileService> tfs;
179 
180  fTree = tfs->make<TTree>("matchTree","CRTHit - TPC track matching analysis");
181 
182  fTree->Branch("Event", &fEvent, "Event/I");
183  fTree->Branch("SubRun", &fSubRun, "SubRun/I");
184  fTree->Branch("Run", &fRun, "Run/I");
185  fTree->Branch("crtRegion", "std::vector<int>", &fCrtRegion);
186  fTree->Branch("DCA", "std::vector<double>", &fDCA);
187  fTree->Branch("DOL", "std::vector<double>", &fDOL);
188  fTree->Branch("t0", "std::vector<double>", &fT0);
189  fTree->Branch("tpcx", "std::vector<double>", &ftpcx);
190  fTree->Branch("tpcy", "std::vector<double>", &ftpcy);
191  fTree->Branch("tpcz", "std::vector<double>", &ftpcz);
192  fTree->Branch("crtx", "std::vector<double>", &fcrtx);
193  fTree->Branch("crty", "std::vector<double>", &fcrty);
194  fTree->Branch("crtz", "std::vector<double>", &fcrtz);
195  fTree->Branch("cryo", "std::vector<int>", &fcryo);
196  fTree->Branch("ntracks", "std::vector<int>", &fntracks);
197  fTree->Branch("pandorat0", "std::vector<double>", &fpandorat0);
198  fTree->Branch("gate_type", &m_gate_type, "gate_type/b");
199  fTree->Branch("gate_name", &m_gate_name);
200  fTree->Branch("trigger_timestamp", &m_trigger_timestamp, "trigger_timestamp/l");
201  fTree->Branch("gate_start_timestamp", &m_gate_start_timestamp, "gate_start_timestamp/l");
202  fTree->Branch("trigger_gate_diff", &m_trigger_gate_diff, "trigger_gate_diff/l");
203  fTree->Branch("gate_crt_diff",&m_gate_crt_diff, "gate_crt_diff/l");
204 
205  for(int i = 30; i < 50 + 1; i++){
206  std::string tagger = "All";
207  if (i >= 35 && i < 40) continue;
208  if (i==48 || i==49) continue;
209  // if(i < ){
210  tagger = fCrtutils->GetRegionNameFromNum(i);//fCrtGeo.GetTagger(i).name;
211  // std::cout << "tagger: " << tagger.c_str() << std::endl;
212  hDCA[tagger] = tfs->make<TH1F>(Form("DCA_%s", tagger.c_str()), "", 50, 0, 100);
213  hDoL[tagger] = tfs->make<TH1F>(Form("DoL_%s", tagger.c_str()), "", 100, 0, 0.25);
214  hT0[tagger] = tfs->make<TH1F>(Form("T0_%s", tagger.c_str()), "", 600, -3000, 3000);
215  }
216 
217  } // CRTT0Matching::beginJob()
vector< double > fpandorat0
Track T0 based on Pandora (Cathode Crossing Track)
int fEvent
number of the event being processed
int fRun
number of the run being processed
vector< int > fntracks
total number of tracks
art::ServiceHandle< art::TFileService > tfs
int fSubRun
number of the sub-run being processed
void icarus::CRTT0Matching::endJob ( )
override

Definition at line 392 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

393  {
394 
395  } // CRTT0Matching::endJob()
CRTT0Matching& icarus::CRTT0Matching::operator= ( CRTT0Matching const &  )
delete
CRTT0Matching& icarus::CRTT0Matching::operator= ( CRTT0Matching &&  )
delete
void icarus::CRTT0Matching::produce ( art::Event &  e)
override

Definition at line 219 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

220  {
221  fDCA.clear();
222  fDOL.clear();
223  fT0.clear();
224  fcrtx.clear();
225  fcrty.clear();
226  fcrtz.clear();
227  ftpcx.clear();
228  ftpcy.clear();
229  ftpcz.clear();
230  fCrtRegion.clear();
231  fpandorat0.clear();
232  fcryo.clear();
233  fntracks.clear();
234  fEvent = event.id().event();
235  fRun = event.run();
236  fSubRun = event.subRun();
237 
238  // Create anab::T0 objects and make association with recob::Track
239  std::unique_ptr< std::vector<anab::T0> > T0col( new std::vector<anab::T0>);
240  std::unique_ptr< art::Assns<recob::Track, anab::T0> > Trackassn( new art::Assns<recob::Track, anab::T0>);
241  std::unique_ptr< art::Assns <sbn::crt::CRTHit, anab::T0> > t0_crthit_assn( new art::Assns<sbn::crt::CRTHit, anab::T0> );
242 
243  //add trigger info
244  if( !fTriggerLabel.empty() ) {
245 
246  art::Handle<sbn::ExtraTriggerInfo> trigger_handle;
247  event.getByLabel( fTriggerLabel, trigger_handle );
248  if( trigger_handle.isValid() ) {
249  sbn::triggerSource bit = trigger_handle->sourceType;
250  m_gate_type = (unsigned int)bit;
251  m_gate_name = bitName(bit);
252  m_trigger_timestamp = trigger_handle->triggerTimestamp;
253  m_gate_start_timestamp = trigger_handle->beamGateTimestamp;
254  m_trigger_gate_diff = trigger_handle->triggerTimestamp - trigger_handle->beamGateTimestamp;
255 
256  }
257  else{
258  mf::LogError("CRTT0Matching:") << "No raw::Trigger associated to label: " << fTriggerLabel.label() << "\n" ;
259  }
260  }
261  else {
262  mf::LogError("CRTT0Matching:") << "Trigger Data product " << fTriggerLabel.label() << " not found!\n" ;
263  }
264 
265  // Retrieve CRT hit list
266  art::Handle<std::vector<sbn::crt::CRTHit>> crtListHandle;
267  std::vector<art::Ptr<sbn::crt::CRTHit>> crtList;
268  if(event.getByLabel(fCrtHitModuleLabel, crtListHandle))
269  art::fill_ptr_vector(crtList, crtListHandle);
270 
271  std::vector<sbn::crt::CRTHit> crtHits;
272  for (auto const& crtHit : crtList){
273  crtHits.push_back(*crtHit);
274  }
275 
276  // Retrieve track list
277  for(const auto& trackLabel : fTpcTrackModuleLabel){
278 
279  auto it = &trackLabel - fTpcTrackModuleLabel.data();
280 
281  art::Handle< std::vector<recob::Track> > trackListHandle;
282  std::vector<art::Ptr<recob::Track> > trackList;
283  if (event.getByLabel(trackLabel,trackListHandle))
284  art::fill_ptr_vector(trackList, trackListHandle);
285 
286  // if (event.getByLabel(fTpcTrackModuleLabel,trackListHandle))
287  // std::cout << "crtlabel: " << fCrtHitModuleLabel << " , Tpctrklabel: " << fTpcTrackModuleLabel << std::endl;
288 
289  mf::LogInfo("CRTT0Matching")
290  <<"Number of reconstructed tracks = "<<trackList.size()<<"\n"
291  <<"Number of CRT hits = "<<crtList.size();
292 
293  fntracks.push_back(trackList.size());
294  //Get PFParticles
295  auto pfpListHandle = event.getValidHandle<std::vector<recob::PFParticle> >(fPFParticleLabel[it]);
296  if (!pfpListHandle.isValid()) continue;
297 
298  //Get PFParticle-Track association
299  art::FindManyP<recob::PFParticle> fmpfp(trackListHandle, event, trackLabel);
300 
301  //Get T0-PFParticle association
302  art::FindManyP<anab::T0> fmt0pandora(pfpListHandle, event, fPFParticleLabel[it]);
303 
304 
305  if (trackListHandle.isValid() && crtListHandle.isValid() ){
306 
307  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event);
308  art::FindManyP<recob::Hit> findManyHits(trackListHandle, event, trackLabel);
309 
310  // Loop over all the reconstructed tracks
311  for(size_t track_i = 0; track_i < trackList.size(); track_i++) {
312 
313  double t0 = -99999999;
314  //Find PFParticle for track i
315  //art::Ptr::key() gives the index in the vector
316  auto pfps = fmpfp.at(trackList[track_i]->ID());
317 
318  if (!pfps.empty()){
319  //Find T0 for PFParticle
320  auto t0s = fmt0pandora.at(pfps[0].key());
321  if (!t0s.empty()){
322 
323  t0 = t0s[0]->Time(); //Get T0
324  }
325  }
326 
327  std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(trackList[track_i]->ID());
328  if (hits.size() == 0) continue;
329  int const cryoNumber = hits[0]->WireID().Cryostat;
330  // std::pair<double, double> matchedTime = t0Alg.T0AndDCAFromCRTHits(detProp, *trackList[track_i], crtHits, event);
331  matchCand closest = t0Alg.GetClosestCRTHit(detProp, *trackList[track_i], hits, crtHits, m_gate_start_timestamp);
332  // std::vector <matchCand> closestvec = t0Alg.GetClosestCRTHit(detProp, *trackList[track_i], crtHits, event);
333  // matchCand closest = closestvec.back();
334 
335  if(closest.dca >=0 ){
336  mf::LogInfo("CRTT0Matching")
337  <<"Matched time = "<<closest.t0<<" [us] to track "<<trackList[track_i]->ID()<<" with DCA = "<<closest.dca;
338  T0col->push_back(anab::T0(closest.t0*1e3, trackList[track_i]->ID(), closest.thishit.plane, (int)closest.extrapLen, closest.dca));
339  util::CreateAssn(*this, event, *T0col, trackList[track_i], *Trackassn);
340 
341  //std::cout << "---------------------- line #156 " << std::endl;
342  double sin_angle = -99999;
343  if(closest.dca != -99999){
344  auto start = trackList[track_i]->Vertex<TVector3>();
345  //auto end = trackList[track_i]->End<TVector3>();
346  hDCA[closest.thishit.tagger]->Fill(closest.dca);
347  //hDCA["All"]->Fill(closest.dca);
348  sin_angle = closest.dca/closest.extrapLen;
349  hDoL[closest.thishit.tagger]->Fill(sin_angle);
350  // hDoL["All"]->Fill(sin_angle);
351  hT0[closest.thishit.tagger]->Fill(closest.t0);
352  fDCA.push_back(closest.dca);
353  fDOL.push_back(sin_angle);
354  fT0.push_back(closest.t0);
355  fcryo.push_back(cryoNumber);
356  fpandorat0.push_back(t0);
357  ftpcx.push_back(start.X());
358  ftpcy.push_back(start.Y());
359  ftpcz.push_back(start.Z());
360  fcrtx.push_back(closest.thishit.x_pos);
361  fcrty.push_back(closest.thishit.y_pos);
362  fcrtz.push_back(closest.thishit.z_pos);
363  // fCrtRegion.push_back(closest.thishit.tagger);
364  fCrtRegion.push_back(fCrtutils->AuxDetRegionNameToNum(closest.thishit.tagger));
365  }
366  //find this CRThit in the collection
367  // note this does not work (both the loop and the assoc !!)
368  unsigned CRThitIndex = std::numeric_limits<unsigned>::max();
369  for (int ic=0; ic<(int)crtList.size(); ++ic){
370  if (crtList[ic]->ts0_ns==closest.thishit.ts0_ns && crtList[ic]->z_pos==closest.thishit.z_pos && crtList[ic]->peshit==closest.thishit.peshit)
371  CRThitIndex=ic;
372  // std::cout << "CRThitIndex: \t" << CRThitIndex << std::endl;
373  }
374  if (CRThitIndex != std::numeric_limits<unsigned>::max()){
375  // std::cout <<"CRThitIndex: " << CRThitIndex << " passed......: \t" << std::endl;
376  util::CreateAssn(*this, event, *T0col, crtList[CRThitIndex], *t0_crthit_assn);
377  }
378  } // DCA check
379 
380  } // Loop over tracks
381 
382  } // Validity check
383 
384  } // all track labels in a vector
385  event.put(std::move(T0col));
386  event.put(std::move(Trackassn));
387  event.put(std::move(t0_crthit_assn));
388  fTree->Fill();
389  } // CRTT0Matching::produce()
vector< double > fpandorat0
Track T0 based on Pandora (Cathode Crossing Track)
int fEvent
number of the event being processed
std::vector< art::InputTag > fTpcTrackModuleLabel
name of track producer
art::InputTag fCrtHitModuleLabel
name of crt producer
Definition: T0.h:16
int fRun
number of the run being processed
std::string bitName(triggerSource bit)
Returns a mnemonic short name of the beam type.
Definition: BeamBits.h:267
std::vector< art::InputTag > fPFParticleLabel
labels for source of PFParticle
vector< int > fntracks
total number of tracks
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
matchCand GetClosestCRTHit(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::pair< double, double > t0MinMax, std::vector< sbn::crt::CRTHit > crtHits, int driftDirection, uint64_t &trigger_timestamp)
triggerSource
Type of beam or beam gate or other trigger source.
Definition: BeamBits.h:97
auto const detProp
int fSubRun
number of the sub-run being processed
void icarus::CRTT0Matching::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 166 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

167  {
168  fTpcTrackModuleLabel = p.get< std::vector<art::InputTag>>("TpcTrackModuleLabel", {"pandoraTrackGausCryoE"});
169  fCrtHitModuleLabel = p.get<art::InputTag> ("CrtHitModuleLabel", "crthit");
170  fPFParticleLabel = p.get< std::vector<art::InputTag> >("PFParticleLabel", {""});
171  fTriggerLabel = p.get<art::InputTag>("TriggerLabel","daqTrigger");
172  } // CRTT0Matching::reconfigure()
std::vector< art::InputTag > fTpcTrackModuleLabel
name of track producer
pdgs p
Definition: selectors.fcl:22
art::InputTag fCrtHitModuleLabel
name of crt producer
std::vector< art::InputTag > fPFParticleLabel
labels for source of PFParticle

Member Data Documentation

art::InputTag icarus::CRTT0Matching::fCrtHitModuleLabel
private

name of crt producer

Definition at line 98 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

vector<int> icarus::CRTT0Matching::fCrtRegion
private
icarus::crt::CRTCommonUtils* icarus::CRTT0Matching::fCrtutils
private
vector<double> icarus::CRTT0Matching::fcrtx
private
vector<double> icarus::CRTT0Matching::fcrty
private
vector<double> icarus::CRTT0Matching::fcrtz
private
vector<int> icarus::CRTT0Matching::fcryo
private

cryo number

Definition at line 122 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

vector<double> icarus::CRTT0Matching::fDCA
private
vector<double> icarus::CRTT0Matching::fDOL
private
int icarus::CRTT0Matching::fEvent
private

number of the event being processed

Definition at line 108 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

geo::GeometryCore const* icarus::CRTT0Matching::fGeometryService
private

pointer to Geometry provider

Definition at line 103 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

vector<int> icarus::CRTT0Matching::fntracks
private

total number of tracks

Definition at line 123 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

vector<double> icarus::CRTT0Matching::fpandorat0
private

Track T0 based on Pandora (Cathode Crossing Track)

Definition at line 121 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

std::vector<art::InputTag> icarus::CRTT0Matching::fPFParticleLabel
private

labels for source of PFParticle

Definition at line 97 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

int icarus::CRTT0Matching::fRun
private

number of the run being processed

Definition at line 109 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

int icarus::CRTT0Matching::fSubRun
private

number of the sub-run being processed

Definition at line 110 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

vector<double> icarus::CRTT0Matching::fT0
private
std::vector<art::InputTag> icarus::CRTT0Matching::fTpcTrackModuleLabel
private

name of track producer

Definition at line 96 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

vector<double> icarus::CRTT0Matching::ftpcx
private
vector<double> icarus::CRTT0Matching::ftpcy
private
vector<double> icarus::CRTT0Matching::ftpcz
private
TTree* icarus::CRTT0Matching::fTree
private
art::InputTag icarus::CRTT0Matching::fTriggerLabel
private

labels for trigger

Definition at line 99 of file icaruscode/icaruscode/CRT/CRTT0Matching_module.cc.

std::map<std::string, TH1F*> icarus::CRTT0Matching::hDCA
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hDoL
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hMatchDCA
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hMatchDoL
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hMatchT0
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hNoMatchDCA
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hNoMatchDoL
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hNoMatchT0
private
std::map<std::string, TH1F*> icarus::CRTT0Matching::hT0
private
uint64_t icarus::CRTT0Matching::m_gate_crt_diff
private
std::string icarus::CRTT0Matching::m_gate_name
private
uint64_t icarus::CRTT0Matching::m_gate_start_timestamp
private
unsigned int icarus::CRTT0Matching::m_gate_type
private
uint64_t icarus::CRTT0Matching::m_trigger_gate_diff
private
uint64_t icarus::CRTT0Matching::m_trigger_timestamp
private
CRTT0MatchAlg icarus::CRTT0Matching::t0Alg
private

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