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

Public Member Functions

 CRTTrackProducer (fhicl::ParameterSet const &p)
 
 CRTTrackProducer (CRTTrackProducer const &)=delete
 
 CRTTrackProducer (CRTTrackProducer &&)=delete
 
CRTTrackProduceroperator= (CRTTrackProducer const &)=delete
 
CRTTrackProduceroperator= (CRTTrackProducer &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

string fDataLabelHits
 
int fTrackMethodType
 
int fStoreTrack
 
bool fUseTopPlane
 
CRTTrackRecoAlg trackAlg
 

Detailed Description

Definition at line 50 of file icaruscode/icaruscode/CRT/CRTTrackProducer_module.cc.

Constructor & Destructor Documentation

icarus::crt::CRTTrackProducer::CRTTrackProducer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 115 of file icaruscode/icaruscode/CRT/CRTTrackProducer_module.cc.

116  : EDProducer{p}, trackAlg(p.get<fhicl::ParameterSet>("TrackAlg"))
117  {
118  // Initialize member data here.
119  fDataLabelHits = p.get<string>("DataLabelHits"); // CRTHit producer module name
120  // fDataLabelTZeros = p.get<string>("DataLabelTZeros"); // CRTTzero producer module name
121  fStoreTrack = p.get<int> ("StoreTrack"); // method 1 = all, method 2 = ave, method 3 = pure, method 4 = top plane
122  fTrackMethodType = p.get<int> ("TrackMethodType"); // Print stuff
123  fUseTopPlane = p.get<bool> ("UseTopPlane"); // Use hits from the top plane (SBND specific)
124 
125  // Call appropriate produces<>() functions here.
126  if(fStoreTrack == 1){
127  produces< vector<sbn::crt::CRTTrack> >();
128  produces< art::Assns<sbn::crt::CRTTrack , sbn::crt::CRTHit> >();
129  }
130 
131  } // CRTTrackProducer()
pdgs p
Definition: selectors.fcl:22
icarus::crt::CRTTrackProducer::CRTTrackProducer ( CRTTrackProducer const &  )
delete
icarus::crt::CRTTrackProducer::CRTTrackProducer ( CRTTrackProducer &&  )
delete

Member Function Documentation

void icarus::crt::CRTTrackProducer::beginJob ( )
override

Definition at line 385 of file icaruscode/icaruscode/CRT/CRTTrackProducer_module.cc.

386  {
387  } // CRTTrackProducer::beginJob()
void icarus::crt::CRTTrackProducer::endJob ( )
override

Definition at line 389 of file icaruscode/icaruscode/CRT/CRTTrackProducer_module.cc.

390  {
391  } // CRTTrackProducer::endJob()
CRTTrackProducer& icarus::crt::CRTTrackProducer::operator= ( CRTTrackProducer const &  )
delete
CRTTrackProducer& icarus::crt::CRTTrackProducer::operator= ( CRTTrackProducer &&  )
delete
void icarus::crt::CRTTrackProducer::produce ( art::Event &  e)
override

Definition at line 133 of file icaruscode/icaruscode/CRT/CRTTrackProducer_module.cc.

134  {
135  // For validation
136  int nTrack = 0;
137  int nCompTrack = 0;
138  int nIncTrack = 0;
139 
140  // CRTTrack collection on this event
141  std::unique_ptr<vector<sbn::crt::CRTTrack> > CRTTrackCol(new vector<sbn::crt::CRTTrack>);
142  std::unique_ptr< art::Assns<sbn::crt::CRTTrack, sbn::crt::CRTHit> > Trackassn( new art::Assns<sbn::crt::CRTTrack, sbn::crt::CRTHit>);
143  art::PtrMaker<sbn::crt::CRTTrack> makeTrackPtr(evt);
144 
145  // Implementation of required member function here.
146  art::Handle< vector<sbn::crt::CRTHit> > rawHandle;
147  evt.getByLabel(fDataLabelHits, rawHandle); //what is the product instance name? no BernZMQ
148 
149  // Check to make sure the data we asked for is valid
150  if(!rawHandle.isValid()){
151  mf::LogWarning("CRTTrackProducer")
152  <<"No CRTHits from producer module "<<fDataLabelHits;
153  return;
154  }
155 
156  // Track method 4 = SBND method with top plane (doesn't use CRTTzero)
157  if(fTrackMethodType == 4){
158 
159  //Get the CRT hits from the event
160  vector<art::Ptr<sbn::crt::CRTHit> > hitlist;
161 
162  if (evt.getByLabel(fDataLabelHits, rawHandle))
163  art::fill_ptr_vector(hitlist, rawHandle);
164 
165  map<art::Ptr<sbn::crt::CRTHit>, int> hitIds;
166 
167  for(size_t i = 0; i<hitlist.size(); i++){
168  hitIds[hitlist[i]] = i;
169  }
170 
171  vector<vector<art::Ptr<sbn::crt::CRTHit>>> CRTTzeroVect = trackAlg.CreateCRTTzeros(hitlist);
172 
173  // Loop over tzeros
174  for(size_t i = 0; i<CRTTzeroVect.size(); i++){
175 
176  //loop over hits for this tzero, sort by tagger
177  //map<string, vector<art::Ptr<sbn::crt::CRTHit>>> hits;
178  map<int, vector<art::Ptr<sbn::crt::CRTHit>>> hits;
179 
180  for (size_t ah = 0; ah< CRTTzeroVect[i].size(); ++ah){
181 
182  //string ip = CRTTzeroVect[i][ah]->tagger;
183  int ip = CRTTzeroVect[i][ah]->plane;
184  hits[ip].push_back(CRTTzeroVect[i][ah]);
185  } // loop over hits
186 
187  //loop over planes and calculate average hits
188  vector<pair<sbn::crt::CRTHit, vector<int>>> allHits;
189 
190  for (auto &keyVal : hits){
191 
192  // string ip = keyVal.first;
193  int ip = keyVal.first;
194  vector<pair<sbn::crt::CRTHit, vector<int>>> ahits = trackAlg.AverageHits(hits[ip], hitIds);
195 
196  allHits.insert(allHits.end(), ahits.begin(), ahits.end());
197 
198  /*
199  if(fUseTopPlane && ip == "volTaggerTopHigh_0"){
200  allHits.insert(allHits.end(), ahits.begin(), ahits.end());
201  }
202 
203  else if(ip != "volTaggerTopHigh_0"){
204  allHits.insert(allHits.end(), ahits.begin(), ahits.end());
205  }
206  */
207  }
208 
209  //Create tracks with hits at the same tzero
210  vector<pair<sbn::crt::CRTTrack, vector<int>>> trackCandidates = trackAlg.CreateTracks(allHits);
211  nTrack += trackCandidates.size();
212 
213  for(size_t j = 0; j < trackCandidates.size(); j++){
214 
215  CRTTrackCol->emplace_back(trackCandidates[j].first);
216  art::Ptr<sbn::crt::CRTTrack> trackPtr = makeTrackPtr(CRTTrackCol->size()-1);
217 
218  for (size_t ah = 0; ah< CRTTzeroVect[i].size(); ++ah){
219  Trackassn->addSingle(trackPtr, CRTTzeroVect[i][ah]);
220  }
221 
222  if(trackCandidates[j].first.complete)
223  nCompTrack++;
224  else
225  nIncTrack++;
226  }
227  }
228 
229  }//end if sbnd option
230 
231  /*
232  //Older track reconstruction methods from MicroBooNE
233  else{
234  //Get list of tzeros
235  // std::vector<crt::CRTHit> const& CRTHitCollection(*rawHandle);
236  art::Handle< vector<sbn::crt::CRTTzero> > rawHandletzero;
237  evt.getByLabel(fDataLabelTZeros, rawHandletzero); //what is the product instance name? no BernZMQ
238 
239  //check to make sure the data we asked for is valid
240  if(!rawHandletzero.isValid()){
241  mf::LogWarning("CRTTrackProducer")
242  <<"No CRTTzeros from producer module "<<fDataLabelTZeros;
243  return;
244  }
245 
246  vector<art::Ptr<sbn::crt::CRTTzero> > tzerolist;
247  if (evt.getByLabel(fDataLabelTZeros,rawHandletzero))
248  art::fill_ptr_vector(tzerolist, rawHandletzero);
249 
250  art::FindManyP<sbn::crt::CRTHit> fmht(rawHandletzero, evt, fDataLabelTZeros);
251 
252  //loop over tzeros
253  for(size_t tzIter = 0; tzIter < tzerolist.size(); ++tzIter){
254 
255  //count planes with hits for this tzero
256  int np =0 ; //int ipflag[7] = {}; // CHANGED FROM 4 TO 7
257  int tothits =0;
258  for (int ip=0;ip<7;++ip) { // CHANGED FROM 4 TO 7
259  if (tzerolist[tzIter]->nhits[ip]>0){
260  np++;
261  //ipflag[ip]=1;
262  tothits+=tzerolist[tzIter]->nhits[ip];
263  }
264  }
265 
266  if (np<2) continue;
267  vector<art::Ptr<sbn::crt::CRTHit> > hitlist=fmht.at(tzIter);
268  //for(size_t hit_i = 0; hit_i < hitlist.size(); hit
269  if (fTrackMethodType==1) {
270  double time_s_A = hitlist[0]->ts0_s;
271 
272  // find pairs of hits in different planes
273  for (size_t ah = 0; ah< hitlist.size()-1; ++ah){
274  sbn::crt::CRTHit temphit=*hitlist[ah];
275  CRTavehit Ahit = copyme(temphit);
276  int planeA = hitlist[ah]->plane;
277 
278  for (size_t bh = ah+1; bh< hitlist.size(); ++bh){
279  int planeB = hitlist[bh]->plane;
280 
281  if (planeB!=planeA && !((planeA==3&&planeB==4)||(planeA==4&&planeB==3))) { // make a track
282  temphit=*hitlist[bh];
283  CRTavehit Bhit = copyme(temphit);
284  sbn::crt::CRTTrack CRTcanTrack=shcut(Ahit,Bhit,time_s_A,0);
285  CRTTrackCol->emplace_back(CRTcanTrack);
286  }
287 
288  }
289 
290  }
291 
292  }
293 
294  else if ((fTrackMethodType==2) || (fTrackMethodType==3 && np==2 && tothits==2)) {
295 
296  //loop over hits and get average x,y,z,pe for each plane CHANGED FROM 4 TO 7
297  vector<float> thittime0[7];
298  vector<float> thittime1[7];
299  vector<float> tx[7];
300  vector<float> ty[7];
301  vector<float> tz[7];
302  vector<float> pe[7];
303 
304  double time_s_A = hitlist[0]->ts0_s;
305  // double time_s_err = hitlist[0]->ts0_s_err;
306  double time_s_err = 0.;
307  double time1_ns_A = hitlist[0]->ts1_ns;
308  double time0_ns_A = hitlist[0]->ts0_ns;
309 
310  //loop over hits for this tzero, sort by plane
311  for (size_t ah = 0; ah< hitlist.size(); ++ah){
312  int ip = hitlist[ah]->plane;
313  thittime0[ip].push_back(hitlist[ah]->ts0_ns-time0_ns_A);
314  thittime1[ip].push_back(hitlist[ah]->ts1_ns-time1_ns_A);
315  tx[ip].push_back(hitlist[ah]->x_pos);
316  ty[ip].push_back(hitlist[ah]->y_pos);
317  tz[ip].push_back(hitlist[ah]->z_pos);
318  pe[ip].push_back(hitlist[ah]->peshit);
319  } // loop over hits
320 
321  CRTavehit aveHits[7];
322  //loop over planes and calculate average hits
323  for (int ip = 0; ip < 7; ip++){
324  if (tx[ip].size()>0){
325  uint32_t at0; int32_t at1; uint16_t rt0,rt1;
326  float totpe=0.0;
327  float avet1=0.0; float rmst1 =0.0;
328  float avet0=0.0; float rmst0 =0.0;
329  float avex=0.0; float rmsx =0.0;
330  float avey=0.0; float rmsy =0.0;
331  float avez=0.0; float rmsz =0.0;
332  vmanip(thittime0[ip],&avet0,&rmst0);
333  vmanip(thittime1[ip],&avet1,&rmst1);
334  at0 = (uint32_t)(avet0+time0_ns_A); rt0 = (uint16_t)rmst0;
335  at1 = (int32_t)(avet1+time1_ns_A); rt1 = (uint16_t)rmst1;
336  vmanip(tx[ip],&avex,&rmsx);
337  vmanip(ty[ip],&avey,&rmsy);
338  vmanip(tz[ip],&avez,&rmsz);
339  totpe=std::accumulate(pe[ip].begin(), pe[ip].end(), 0.0);
340  CRTavehit aveHit = fillme(at0,rt0,at1,rt1,avex,rmsx,avey,rmsy,avez,rmsz,totpe,ip,"");
341  aveHits[ip] = aveHit;
342  }
343  else {
344  CRTavehit aveHit = fillme(0,0,0,0,-99999,-99999,-99999,-99999,-99999,-99999,-99999,ip,"");
345  aveHits[ip] = aveHit;
346  }
347  }
348 
349  // find pairs of hits in different planes
350  for (size_t ah = 0; ah< 6; ++ah){
351  CRTavehit Ahit = aveHits[ah];
352  if( Ahit.x_pos==-99999 ) continue;
353 
354  for (size_t bh = ah+1; bh< 7; ++bh){
355  if ( aveHits[bh].x_pos==-99999 ) continue;
356 
357  if (ah!=bh && !(ah==3&&bh==4)) { // make a track
358  CRTavehit Bhit = aveHits[bh];
359  sbn::crt::CRTTrack CRTcanTrack=shcut(Ahit,Bhit,time_s_A,time_s_err);
360  CRTTrackCol->emplace_back(CRTcanTrack);
361  nTrack++;
362  }
363 
364  }
365 
366  }
367 
368  }
369 
370  }// loop over tzeros
371  }//uBooNE method
372  */
373  //store track collection into event
374  if(fStoreTrack == 1){
375  evt.put(std::move(CRTTrackCol));
376  evt.put(std::move(Trackassn));
377  }
378  mf::LogInfo("CRTTrackProducer")
379  <<"Number of tracks = "<<nTrack<<"\n"
380  <<"Number of complete tracks = "<<nCompTrack<<"\n"
381  <<"Number of incomplete tracks = "<<nIncTrack;
382 
383  } // CRTTrackProducer::produce()
vector< vector< art::Ptr< sbn::crt::CRTHit > > > CreateCRTTzeros(vector< art::Ptr< sbn::crt::CRTHit >>)
vector< pair< sbn::crt::CRTHit, vector< int > > > AverageHits(vector< art::Ptr< sbn::crt::CRTHit >> hits, map< art::Ptr< sbn::crt::CRTHit >, int > hitIds)
vector< pair< sbn::crt::CRTTrack, vector< int > > > CreateTracks(vector< pair< sbn::crt::CRTHit, vector< int >>> hits)
TCEvent evt
Definition: DataStructs.cxx:8

Member Data Documentation

string icarus::crt::CRTTrackProducer::fDataLabelHits
private
int icarus::crt::CRTTrackProducer::fStoreTrack
private
int icarus::crt::CRTTrackProducer::fTrackMethodType
private
bool icarus::crt::CRTTrackProducer::fUseTopPlane
private
CRTTrackRecoAlg icarus::crt::CRTTrackProducer::trackAlg
private

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