CalibAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: CalibAna
3 // Plugin Type: analyzer (art v2_12_01)
4 // File: CalibAna_module.cc
5 //
6 // Generated at Sat Apr 27 09:35:48 2019 by Tyler Alion using cetskelgen
7 // from cetlib version v3_06_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
21 
22 #include "TTree.h"
23 
25 #include "RecoBase/Track.h"
26 #include "RecoBase/CellHit.h"
27 //#include "MCCheater/BackTracker.h"
28 #include "Calibrator/Calibrator.h"
29 
30 //#include "Geometry/Geometry.h"
33 
34 namespace calib {
36  {
37  template<class T> using Atom = fhicl::Atom<T>;
38  template<class T> using Table = fhicl::Table<T>;
40  using Name = fhicl::Name;
42  Name("TrackLabel"),
43  Comment("Label of track reconstruction module (all tracks or stopping seleciton)")
44  };
46  Name("PCHitsLabel"),
47  Comment("Label of PCHitsList module (pclist or pcliststop)")
48  };
50  Name("WhichHitTrees"),
51  Comment("Which Hit Trees to make. All: \"tricell, trajectory, cellhit\"")
52  };
53  };
54 }
55 
56 namespace caldp {
57  class PCHit;
58 }
59 
60 namespace calib {
61  class CalibAna;
62 }
63 
65 public:
67 
68  explicit CalibAna(const Parameters& params);
69  // The compiler-generated destructor is fine for non-base
70  // classes without bare pointers or other resource use.
71 
72  // Plugins should not be copied or assigned.
73  CalibAna(CalibAna const &) = delete;
74  CalibAna(CalibAna &&) = delete;
75  CalibAna & operator = (CalibAna const &) = delete;
76  CalibAna & operator = (CalibAna &&) = delete;
77 
78  // Required functions.
79  void analyze(art::Event const & e) override;
80 
81  // Selected optional functions.
82  void beginJob() override;
83  void endJob() override;
84 
85 private:
87 
88  void AddEventBranches(TTree * t);
89  void ResetEventBranches();
90  TTree * fEventTree;
92  int et_run, et_subrun, et_event;
93  uint32_t et_evttime;
98 
99  void AddTrackBranches(TTree * t);
100  void ResetTrackBranches();
101  TTree * fTrackTree;
102  float tt_dcosz, tt_dcosy, tt_dcosx;
105  int tt_pdg;
111  TVector3 tt_startpos;
112  TVector3 tt_endpos;
113 
114  void AddHitBranches(TTree * t, std::string type);
115  void ResetHitBranches();
116  std::map< std::string, TTree * > fHitTree;
118  bool ht_istraj;
119  bool ht_isavg;
120  bool ht_isz;
122  int ht_dcm;
123  int ht_apd;
124  int ht_pixel;
125  int ht_plane;
126  int ht_cell;
127  int ht_view;
128  float ht_w;
129  float ht_readdist;
130  float ht_xapprox, ht_yapprox, ht_zapprox;
131  float ht_pe;
132  float ht_pecorr;
134  float ht_recoMeV;
135  float ht_path;
138  float ht_tns;
139  float ht_truepath;
140  float ht_truepe;
141  float ht_truew;
142  float ht_trueMeV;
145  int ht_tdc; // In CellHits,
146  int ht_adc; // but not PCHits.
147  void FillWithPCHit( caldp::PCHit const &pchit,
148  bool is_trajectory, bool is_tricell,
149  bool is_avg, bool is_z,
150  float trk_len );
151  void FillWithCellHit( art::Ptr< rb::CellHit > cellhit,
152  bool is_trajectory, bool is_tricell,
153  bool is_avg, bool is_z,
154  float trk_len ); // less info than PCHits
155 
156  // Use W from PCHit to get PECorr from calibrator
157  float GetPECorrToMeV( caldp::PCHit const &pchit );
158  float GetPECorr( caldp::PCHit const &pchit);
159 
160  void PrintHit ( caldp::PCHit const &hit );
161  bool HitInList( caldp::PCHit const &hit,
162  std::vector<art::Ptr<caldp::PCHit> > list );
163  bool HitInList( art::Ptr< rb::CellHit > hit,
164  std::vector<art::Ptr<caldp::PCHit> > list );
165  bool MatchHits( caldp::PCHit const &h1,
166  caldp::PCHit const &h2 );
167  bool MatchHits( art::Ptr< rb::CellHit > h1,
168  caldp::PCHit const &h2 );
169  void ApproximateHitPos( caldp::PCHit const &hit,
170  float & x, float & y, float & z );
171  void ApproximateHitPos( art::Ptr< rb::CellHit > cellhit,
172  float & x, float & y, float & z );
173 };
174 
175 
177  :
178  EDAnalyzer(params),
179  fParams(params())
180 {}
181 
182 
183 
184 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
186 {
187  fIsRealData = e.isRealData();
189  et_run = (int)(e.run());
190  et_subrun = (int)(e.subRun());
191  et_event = (int)(e.id().event());
192  et_evttime = e.time().timeHigh();
193 
195  e.getByLabel(fParams.TrackLabel(), tracks);
196  et_ntracks = tracks->size();
197 
198 
199  // Annoyingly need all since (XY + Z + Avg) = all hits in track
200  // FindTricellHits gets the main hits to be put in tree
201  art::FindManyP<caldp::PCHit> FindTricellHits(tracks, e,
203  "pathQualXY"));
204  art::FindManyP<caldp::PCHit> FindTrajHits(tracks, e,
206  "pathQualTraj"));
207  art::FindManyP<caldp::PCHit> FindAvgHits( tracks, e,
209  "pathQualAvg"));
210  art::FindManyP<caldp::PCHit> FindZHits( tracks, e,
212  "pathQualZ"));
213  if( !FindTricellHits.isValid() ){
214  mf::LogInfo("CalibAna") << "No pathQualXY hits."; return; }
215  if( !FindTrajHits.isValid() ){
216  mf::LogInfo("CalibAna") << "No pathQualTraj hits."; return; }
217  if( !FindAvgHits.isValid() ){
218  mf::LogInfo("CalibAna") << "No pathQualAvg hits."; return; }
219  if( !FindZHits.isValid() ){
220  mf::LogInfo("CalibAna") << "No pathQualZ hits."; return; }
221 
222 
223  for( unsigned int i=0; i<tracks->size(); ++i ){
225  rb::Track trk = (*tracks)[i];
226  tt_dcosx = trk.Dir().X()/trk.Dir().Mag();
227  tt_dcosy = trk.Dir().Y()/trk.Dir().Mag();
228  tt_dcosz = trk.Dir().Z()/trk.Dir().Mag();
229 
230  tt_startpos = trk.Start();
231  tt_endpos = trk.Stop();
232  tt_totdisplace = (tt_endpos-tt_startpos).Mag(); // displacement
233  tt_totlength = trk.TotalLength(); // vs. distance
234 
235  // xy and z conditions are mutually exclusive,
236  // avg hits are just the rest in the track
237  // so xy + z + avg is all the hits in the track
238  std::vector<art::Ptr<caldp::PCHit> > trihits = FindTricellHits.at(i);
239  std::vector<art::Ptr<caldp::PCHit> > trajhits = FindTrajHits.at(i);
240  std::vector<art::Ptr<caldp::PCHit> > avghits = FindAvgHits.at(i);
241  std::vector<art::Ptr<caldp::PCHit> > zhits = FindZHits.at(i);
242  //int npchits = trihits.size() + avghits.size() + zhits.size();
243  tt_ncellhits = trk.NCell();
244  //if(tt_ncellhits != npchits)
245  //mf::LogInfo("CalibAna") << tt_ncellhits << " CellHits, but " << npchits << " PCHits";
246  tt_npchits_tricell = trihits.size();
247  tt_npchits_avg = avghits.size();
248  tt_npchits_z = zhits.size();
249  tt_npchits_traj = trajhits.size();
250  //if(tt_ncellhits != tt_npchits_traj)
251  //mf::LogInfo("CalibAna") << tt_ncellhits << " CellHits, but " << tt_npchits_traj << " Trajectory PCHits";
255 
256  /*
257  std::cout << npchits << " PCHits ("
258  << tt_npchits_tricell << " Tricell, "
259  << tt_npchits_avg << " Avg, "
260  << zhits.size() << " Z), "
261  << tt_npchits_traj << " Trajectory. "
262  << trk.NCell() << " Cell Hits." << std::endl;
263  */
264 
265 
266  //daqchannelmap::DAQChannelMap* cmap = daqchannelmap::DAQChannelMap::getInstance(fDS->DetId());
267 
268  if(fHitTree.count("cellhit")==1){
269  for(size_t c = 0; c < trk.NCell(); ++c){
270  art::Ptr< rb::CellHit > cellhit = trk.Cell(c);
271 
272  // Check what hit qualities this cellhit has
273  bool is_avg = HitInList( cellhit, avghits );
274  bool is_z = HitInList( cellhit, zhits );
275  bool is_traj = HitInList( cellhit, trajhits );
276  bool is_tri = HitInList( cellhit, trihits );
277 
278  FillWithCellHit(cellhit,
279  is_traj, is_tri,
280  is_avg, is_z,
281  tt_totdisplace);
282  fHitTree["cellhit"]->Fill();
283  }
284  }
285 
286 
287  if(fHitTree.count("tricell")==1){
288  for(size_t h = 0; h < trihits.size(); ++h){
289  caldp::PCHit const & trihit = *trihits[h];
290 
291  // Check what other hit qualities this trajectory hit has
292  bool is_avg = HitInList( trihit, avghits );
293  bool is_z = HitInList( trihit, zhits );
294  bool is_traj = HitInList( trihit, trajhits );
295 
296  FillWithPCHit( trihit,
297  is_traj, true,
298  is_avg, is_z,
299  tt_totdisplace);
300  fHitTree["tricell"]->Fill();
301  }
302  }
303 
304  if(fHitTree.count("trajectory")==1){
305  size_t ntricell=0;
306  for(size_t h = 0; h < trajhits.size(); ++h){
307  caldp::PCHit const & trajhit = *trajhits[h];
308 
309  // Check what other hit qualities this trajectory hit has
310  bool is_avg = HitInList( trajhit, avghits );
311  bool is_z = HitInList( trajhit, zhits );
312  bool is_tri = HitInList( trajhit, trihits );
313  if( is_tri ) ntricell++;
314 
315  FillWithPCHit( trajhit,
316  true, is_tri,
317  is_avg, is_z,
318  tt_totdisplace);
319  fHitTree["trajectory"]->Fill();
320  }
321 
322  if(tt_dcosz > 0.95 && ntricell!=0 ){
323  std::cout << "^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^\n\n" << std::endl;
324  std::cout << " Forward Track with " << ntricell << " tricell hits.\n\n" << std::endl;
325  for(size_t h = 0; h < trajhits.size(); ++h){
326  caldp::PCHit const & thit = *trajhits[h];
327  if( HitInList( thit, trihits ) ) std::cout << "Tricell: " << std::endl;
328  PrintHit(thit);
329  }
330  }
331 
332  }
333 
334 
335  fTrackTree->Fill();
336  }
337 
338  fEventTree->Fill();
339 }
340 
341 
342 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
344  std::cout << std::right << std::setw(6) << std::setfill(' ')
345  << "P:" << hit.Plane() << std::right << std::setw(6) << std::setfill(' ')
346  << "C:" << hit.Cell() << std::right << std::setw(6) << std::setfill(' ')
347  << "W:" << hit.W() << std::right << std::setw(6) << std::setfill(' ')
348  << "T:" << hit.TNS() << std::right << std::setw(6) << std::setfill(' ')
349  << std::endl;
350 }
351 
352 
353 
354 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
356  std::vector<art::Ptr<caldp::PCHit> > list)
357 {
358  for(size_t i = 0; i < list.size(); ++i)
359  if( MatchHits( hit, *list[i] ) )
360  return true;
361  return false;
362 }
364  std::vector<art::Ptr<caldp::PCHit> > list)
365 {
366  for(size_t i = 0; i < list.size(); ++i)
367  if( MatchHits( cellhit, *list[i] ) )
368  return true;
369  return false;
370 }
372  caldp::PCHit const &h2)
373 {
374  return (h1.Cell() == h2.Cell() &&
375  h1.Plane() == h2.Plane() &&
376  h1.TNS() == h2.TNS());
377 }
379  caldp::PCHit const &h2)
380 {
381  return (h1->Cell() == h2.Cell() &&
382  h1->Plane() == h2.Plane() &&
383  h1->TNS() == h2.TNS());
384 }
385 
386 
387 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
389 {
391  fEventTree = tfs->make<TTree>("event_tree","tree of variables per art event");
393 
394  fTrackTree = tfs->make<TTree>("track_tree","tree of variables per track");
397 
398  std::vector< std::string > types = {"tricell","trajectory","cellhit"};
399  for(auto& type: types){
400  if(fParams.WhichHitTrees().find(type)==std::string::npos) continue;
401 
402  fHitTree[type] = tfs->make<TTree>((type+"_tree").c_str(),
403  ("tree of variables per "+type+" hit").c_str());
405  AddTrackBranches(fHitTree[type]);
406  AddHitBranches(fHitTree[type],type);
407  }
408 
409 }
410 
411 
412 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
414  bool is_trajectory, bool is_tricell,
415  bool is_avg, bool is_z,
416  float trk_length)
417 {
419  // straight from the hit
420  ht_diblock = pc.Diblock();
421  ht_dcm = pc.DCM();
422  ht_apd = pc.APD();
423  ht_pixel = pc.Pixel();
424  ht_plane = pc.Plane();
425  ht_cell = pc.Cell();
426  ht_view = pc.View();
427  ht_w = pc.W();
428  ht_readdist = pc.ReadDist();
429  ht_pe = pc.PE();
430  ht_path = pc.Path();
431  ht_tns = pc.TNS();
432  ht_truepath = pc.TruePath();
433  ht_truepe = pc.TruePE();
434  ht_truew = pc.TrueW();
435  ht_trueMeV = pc.TrueMeV();
436  ht_flightLen = pc.FlightLen(); // comes from trk->DistanceFromStart( world coordinate );
437  ht_cmFromEnd = trk_length - pc.FlightLen();
439  // use calibrator service
440  ht_pecorr = GetPECorr(pc);
445 
446  size_t ntypes = 0;
447  if( is_tricell ) ntypes++;
448  if( is_avg ) ntypes++;
449  if( is_z ) ntypes++;
450  if( ntypes > 1 )
451  mf::LogError("CalibAna")
452  << "Tricell, Avg, and Z selections should be mutually exclusive, "
453  << "but this hit is: "
454  << (is_tricell ? "Tricell, " : "")
455  << (is_avg ? "Avg, " : "")
456  << (is_z ? "Z. " : ".");
457 
458  ht_istraj = is_trajectory;
459  ht_istricell = is_tricell;
460  ht_isavg = is_avg;
461  ht_isz = is_z;
462 
464 }
465 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
467  bool is_trajectory, bool is_tricell,
468  bool is_avg, bool is_z,
469  float trk_length)
470 {
472  // straight from the hit
473 
474  ht_plane = ch->Plane();
475  ht_cell = ch->Cell();
476  /*
477  uint32_t lchan = cmap->encodeLChan(fGeom->DetId(), chit->Plane(), chit->Cell());
478  uint32_t dchan = cmap->encodeDChan(lchan);
479  uint32_t pixel = cmap->getPixel(dchan);
480  uint32_t apd = cmap->getFEB(dchan);
481  uint32_t dcm = cmap->getDCM(dchan);
482  uint32_t diblock = cmap->getDiBlock(dchan);
483  */
484  //ht_diblock = ch->Diblock();
485  //ht_dcm = ch->DCM();
486  //ht_apd = ch->APD();
487  //ht_pixel = ch->Pixel();
488 
489  ht_view = ch->View();
490  //ht_w = ch->W();
491  ht_pe = ch->PE();
492  //ht_path = ch->Path();
493  ht_tns = ch->TNS();
494  //ht_truepath = ch->TruePath();
495  //ht_truepe = ch->TruePE();
496  //ht_truew = ch->TrueW();
497  //ht_trueMeV = ch->TrueMeV();
498  //ht_x = trk_length - ch->FlightLen();
499  ht_tdc = ch->TDC();
500  ht_adc = ch->ADC();
501  // use calibrator service
502  //ht_pecorr = GetPECorr(ch); // need W from PCHits
503  //ht_pecorrtomev = GetPECorrToMeV(ch);
504  //ht_recoMeV = ht_pecorr * ht_pecorrtomev;
507 
508  ht_istraj = is_trajectory;
509  ht_istricell = is_tricell;
510  ht_isavg = is_avg;
511  ht_isz = is_z;
512 
514 }
515 
516 
517 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
519  //Make mock cellhit
520  rb::CellHit cellhit;
521  cellhit.SetPlane(pchit.Plane());
522  cellhit.SetCell(pchit.Cell());
523  cellhit.SetView(pchit.View());
524  cellhit.SetTNS(pchit.TNS(),pchit.GoodTime());
525  if(!fIsRealData) cellhit.SetMC();
526  cellhit.SetPE(pchit.PE());
528  return calibrator->GetPECorr(cellhit, pchit.W());
529 }
531  rb::CellHit cellhit;
532  if(!fIsRealData) cellhit.SetMC();
534  return 1000.*calibrator->GetPECorrToGeVScale(cellhit);
535 }
536 
537 
538 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
540  float & x, float & y, float & z ){
542  const geo::PlaneGeo* planeg = geo->Plane(hit.Plane());
543  const geo::CellGeo* cellg = planeg->Cell(hit.Cell());
544  double cell_center[3];
545  cellg->GetCenter(cell_center);
546 
547  z = cell_center[2];
548  if( hit.View()==geo::kX ){
549  x = cell_center[0];
550  y = hit.W();
551  }
552  else if( hit.View()==geo::kY ){
553  x = hit.W();
554  y = cell_center[1];
555  }
556  else{
557  mf::LogWarning("CalibAna") << "Bad hit.View()";
558  }
559 }
561  float & x, float & y, float & z ){
563  const geo::CellGeo* cellg = geo->Plane(cellhit->Plane())->Cell(cellhit->Cell());
564  double cell_center[3];
565  cellg->GetCenter(cell_center);
566 
567  z = cell_center[2];
568  if( cellhit->View()==geo::kX ){
569  x = cell_center[0];
570  y = -999.; // estimate W?
571  }
572  else if( cellhit->View()==geo::kY ){
573  x = -999.; // estimate W?
574  y = cell_center[1];
575  }
576  else{
577  mf::LogWarning("CalibAna") << "Bad hit.View()";
578  }
579 }
580 
581 
582 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
584 {
586  CalibratorParams cal_par = calibrator->GetCalibratorParams();
587 
588  std::string baserel = getenv("SRT_PUBLIC_CONTEXT");
589  std::string testrel = getenv("SRT_PRIVATE_CONTEXT");
590  std::string csvpath_atten = calibrator->GetAttenCSVPath();
591  std::string csvpath_abs = calibrator->GetAbsConstsCSVPath();
592  std::string csvpath_timing = calibrator->GetTimingConstsCSVPath();
593  std::string csvpath_drift = calibrator->GetDriftConstsCSVPath();
594  std::string calibtag = cal_par.Tag();
595  bool UseAbsEpochs = cal_par.UseAbsEpochs();
596  std::string AbsEpochTag = cal_par.AbsEpochTag();
597  std::string TimingTag = cal_par.TimingTag();
598  bool UseTimingEpochs = cal_par.UseTimingEpochs();
599  std::string TimingEpochTag = cal_par.TimingEpochTag();
600  std::string DriftCSV = cal_par.DriftCSV();
601  bool UseDriftEpochs = cal_par.UseDriftEpochs();
602  std::string DriftEpochTag = cal_par.DriftEpochTag();
603 
605  TTree* FileTree = tfs->make<TTree>("file_tree","tree of info per file");
606  FileTree->Branch( "baserel", &baserel ); // $SRT_PUBLIC_CONTEXT
607  FileTree->Branch( "testrel", &testrel ); // $SRT_PRIVATE_CONTEXT
608  FileTree->Branch( "csvpath_atten", &csvpath_atten ); // $CALIBCSVS_CSV_PATH or fcl provided
609  FileTree->Branch( "csvpath_abs", &csvpath_abs );
610  FileTree->Branch( "csvpath_timing", &csvpath_timing );
611  FileTree->Branch( "csvpath_drift", &csvpath_drift );
612  FileTree->Branch( "calibtag", &calibtag );
613 
614  // Other potentially important configurations
615  // TODO: Loop through parameter table and use key
616  // as branch name to do a full config dump.
617  FileTree->Branch( "UseAbsEpochs", &UseAbsEpochs );
618  FileTree->Branch( "AbsEpochTag", &AbsEpochTag );
619  FileTree->Branch( "TimingTag", &TimingTag );
620  FileTree->Branch( "UseTimingEpochs", &UseTimingEpochs );
621  FileTree->Branch( "TimingEpochTag", &TimingEpochTag );
622  FileTree->Branch( "DriftCSV", &DriftCSV );
623  FileTree->Branch( "UseDriftEpochs", &UseDriftEpochs );
624  FileTree->Branch( "DriftEpochTag", &DriftEpochTag );
625  //FileTree->Branch("brightnessmodel",&brightnessmodel); //
626 
627 
628  FileTree->Fill();
629 }
630 
631 
632 
633 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
635 {
636  t->Branch("run",&et_run);
637  t->Branch("subrun",&et_subrun);
638  t->Branch("event",&et_event);
639  t->Branch("evt_ntracks",&et_ntracks);
640  t->Branch("evt_ncellhits",&et_ncellhits);
641  t->Branch("evt_nhits_tricell",&et_npchits_tricell);
642  t->Branch("evt_nhits_traj",&et_npchits_traj);
643  t->Branch("evt_time",&et_evttime);
644 }
646 {
647  et_run=-5; et_subrun=-5; et_event=-5;
648  et_ntracks=-5; et_ncellhits=-5;
650  et_evttime=-5;
651 }
652 
653 
654 
655 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
657 {
658  t->Branch("trk_nhits_tricell",&tt_npchits_tricell);
659  t->Branch("trk_nhits_avg",&tt_npchits_avg);
660  t->Branch("trk_nhits_z",&tt_npchits_z);
661  t->Branch("trk_nhits_traj",&tt_npchits_traj);
662  t->Branch("trk_ncellhits",&tt_ncellhits);
663  //t->Branch("npts",&tt_npts);
664  t->Branch("trk_dcosx",&tt_dcosx);
665  t->Branch("trk_dcosy",&tt_dcosy);
666  t->Branch("trk_dcosz",&tt_dcosz);
667  t->Branch("trk_totlength",&tt_totlength);
668  t->Branch("trk_totdisplace",&tt_totlength);
669  t->Branch("trk_startpos",&tt_startpos);
670  t->Branch("trk_endpos",&tt_endpos);
671  t->Branch("trk_pdg",&tt_pdg);
672 }
674 {
676  tt_npchits_avg=0;
677  tt_npchits_z=0;
678  tt_npchits_traj=0;
679  tt_ncellhits=0;
680  //tt_npts=0;
681  tt_pdg=0;
682  tt_dcosx=-5; tt_dcosy=-5; tt_dcosz=-5;
684  tt_startpos.SetXYZ(0.,0.,0.);
685  tt_endpos.SetXYZ(0.,0.,0.);
686 }
687 
688 
689 // ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
692 {
693  // Hit vars
694  t->Branch("istricell",&ht_istricell);
695  t->Branch("istraj",&ht_istraj);
696  t->Branch("isavg",&ht_isavg);
697  t->Branch("isz",&ht_isz);
698  t->Branch("diblock",&ht_diblock);
699  t->Branch("dcm",&ht_dcm);
700  t->Branch("apd",&ht_apd);
701  t->Branch("pixel",&ht_pixel);
702  t->Branch("plane",&ht_plane);
703  t->Branch("cell",&ht_cell);
704  t->Branch("w",&ht_w);
705  t->Branch("readdist",&ht_readdist);
706  t->Branch("xapprox",&ht_xapprox);
707  t->Branch("yapprox",&ht_yapprox);
708  t->Branch("zapprox",&ht_zapprox);
709  t->Branch("pe",&ht_pe);
710  t->Branch("pecorr",&ht_pecorr);
711  t->Branch("pecorrtomev",&ht_pecorrtomev);
712  t->Branch("recoMeV",&ht_recoMeV);
713  t->Branch("path",&ht_path);
714  t->Branch("cmFromStart",&ht_flightLen); // cm from track start
715  t->Branch("cmFromEnd",&ht_cmFromEnd); // cm from track endpt
716  t->Branch("view",&ht_view);
717  t->Branch("tns",&ht_tns);
718  t->Branch("truepath",&ht_truepath);
719  t->Branch("truepe",&ht_truepe);
720  t->Branch("truew",&ht_truew);
721  t->Branch("trueMeV",&ht_trueMeV);
722  t->Branch("poissonLambda",&ht_poissonlambda);
723  t->Branch("brightbin",&ht_brightbin);
724  //if(type=="cellhit"){
725  t->Branch("tdc",&ht_tdc); // time of last baseline sample
726  t->Branch("adc",&ht_adc); // best estimate of hit charge
727  //}
728 }
730 {
731  ht_istricell=false; ht_isz=false;
732  ht_istraj=false; ht_isavg=false;
733  ht_diblock=-5; ht_dcm=-5; ht_apd=-5;
734  ht_pixel=-5; ht_plane=-5; ht_cell=-5;
735  ht_w=-999; ht_pe=-5; ht_pecorr=-5;
736  ht_xapprox=-999; ht_yapprox=-999; ht_zapprox=-999;
738  ht_cmFromEnd=-5; ht_flightLen=-5;
739  ht_view=-5; ht_tns=-5;
740  ht_truepath=-5; ht_truepe=-5; ht_truew=-5;
741  ht_trueMeV=-5; ht_brightbin=-5;
743  ht_tdc=-5; ht_adc=-5;
744 }
745 
746 
int Pixel() const
Return pixel value.
Definition: PCHit.h:34
void FillWithPCHit(caldp::PCHit const &pchit, bool is_trajectory, bool is_tricell, bool is_avg, bool is_z, float trk_len)
float TNS() const
Definition: CellHit.h:46
float TrueMeV() const
Return True energy (MeV) value.
Definition: PCHit.h:44
Atom< bool > UseTimingEpochs
Definition: Calibrator.h:117
float TNS() const
Return uncorrected hit time.
Definition: PCHit.h:52
SubRunNumber_t subRun() const
Definition: Event.h:72
float FlightLen() const
Return path from start of track to current cell.
Definition: PCHit.h:56
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
void GetCenter(double *xyz, double localz=0.0) const
Definition: CellGeo.cxx:159
void AddHitBranches(TTree *t, std::string type)
double GetPECorrToGeVScale(rb::CellHit const &cellhit)
void SetTNS(float tns, bool good)
Definition: CellHit.h:56
Atom< std::string > DriftEpochTag
Definition: Calibrator.h:149
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
float TruePath() const
Return True Pathlength value.
Definition: PCHit.h:48
void analyze(art::Event const &e) override
int APD() const
Return apd value.
Definition: PCHit.h:32
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned short Plane() const
Definition: CellHit.h:39
Atom< std::string > Tag
Definition: Calibrator.h:81
geo::View_t View() const
Definition: CellHit.h:41
const CellGeo * Cell(int icell) const
Definition: PlaneGeo.h:48
bool GoodTime() const
Return quality of timing fit for cell.
Definition: PCHit.h:54
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:35
Vertical planes which measure X.
Definition: PlaneGeo.h:28
int Cell() const
Return cell value.
Definition: PCHit.h:26
void AddEventBranches(TTree *t)
Atom< std::string > TimingTag
Definition: Calibrator.h:125
A rb::Prong with full reconstructed trajectory.
Definition: Track.h:20
const PlaneGeo * Plane(unsigned int i) const
Atom< std::string > AbsEpochTag
Definition: Calibrator.h:109
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isRealData() const
Definition: Event.h:83
DEFINE_ART_MODULE(TestTMapFile)
virtual TVector3 Start() const
Definition: Prong.h:73
fhicl::Comment Comment
CalibAna(const Parameters &params)
float GetPECorr(caldp::PCHit const &pchit)
float TrueW() const
Return True W value.
Definition: PCHit.h:50
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
"Pre-calibration hit". Common input to calibration procedures
Definition: PCHit.h:16
float Path() const
Return Path value.
Definition: PCHit.h:40
void SetView(geo::View_t view)
Definition: CellHit.h:54
void SetPlane(unsigned short plane)
Definition: CellHit.h:53
float W() const
Return W value.
Definition: PCHit.h:42
virtual double TotalLength() const
Length (cm) of all the track segments.
Definition: Track.cxx:213
CalibAnaParams fParams
unsigned int getBrightnessIndex(unsigned int plane, unsigned int cell) const
void beginJob() override
unsigned short Cell() const
Definition: CellHit.h:40
Track finder for cosmic rays.
float PoissonLambda() const
Return number of simulated photons at readout before fluctuations.
Definition: PCHit.h:60
void SetCell(unsigned short cell)
Definition: CellHit.h:52
void FillWithCellHit(art::Ptr< rb::CellHit > cellhit, bool is_trajectory, bool is_tricell, bool is_avg, bool is_z, float trk_len)
CDPStorage service.
void SetPE(float pe)
Definition: CellHit.h:55
float PE() const
Return PE value.
Definition: PCHit.h:38
void beginJob()
void endJob() override
float TruePE() const
Return True PE value.
Definition: PCHit.h:46
float GetPECorrToMeV(caldp::PCHit const &pchit)
std::string getenv(std::string const &name)
Atom< std::string > PCHitsLabel
virtual TVector3 Dir() const
Unit vector describing prong direction.
Definition: Prong.h:77
Geometry information for a single readout plane.
Definition: PlaneGeo.h:36
float PE() const
Definition: CellHit.h:42
void AddTrackBranches(TTree *t)
std::string GetDriftConstsCSVPath()
Definition: Calibrator.h:388
void ApproximateHitPos(caldp::PCHit const &hit, float &x, float &y, float &z)
std::string GetTimingConstsCSVPath()
Definition: Calibrator.h:387
int Plane() const
Return plane value.
Definition: PCHit.h:24
geo::View_t View() const
Return view.
Definition: PCHit.h:36
int Diblock() const
Return diblock value.
Definition: PCHit.h:28
z
Definition: test.py:28
std::string GetAbsConstsCSVPath()
Definition: Calibrator.h:386
void PrintHit(caldp::PCHit const &hit)
OStream cout
Definition: OStream.cxx:6
TH1F * h2
Definition: plot.C:45
Atom< bool > UseAbsEpochs
Definition: Calibrator.h:101
Atom< std::string > WhichHitTrees
void SetMC(bool isMC=true)
Definition: RawDigit.h:106
Histograms used by attenuation calibration.
EventNumber_t event() const
Definition: EventID.h:116
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
TH1F * h1
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
T * make(ARGS...args) const
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
float ReadDist() const
Return distance to readout, with pigtail.
Definition: PCHit.h:58
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Atom< std::string > TimingEpochTag
Definition: Calibrator.h:121
float Mag() const
std::map< std::string, TTree * > fHitTree
Atom< std::string > DriftCSV
Definition: Calibrator.h:141
std::string GetAttenCSVPath()
Definition: Calibrator.h:385
Timestamp time() const
Definition: Event.h:61
double GetPECorr(rb::CellHit const &cellhit, double w)
int DCM() const
Return dcm value.
Definition: PCHit.h:30
TVector3 Stop() const
Position of the final trajectory point.
Definition: Track.cxx:186
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.h:77
Encapsulate the cell geometry.
Definition: CellGeo.h:25
Helper for AttenCurve.
Definition: Path.h:10
CalibratorParams GetCalibratorParams()
Definition: Calibrator.h:389
bool HitInList(caldp::PCHit const &hit, std::vector< art::Ptr< caldp::PCHit > > list)
Atom< std::string > TrackLabel
EventID id() const
Definition: Event.h:56
Atom< bool > UseDriftEpochs
Definition: Calibrator.h:145
bool MatchHits(caldp::PCHit const &h1, caldp::PCHit const &h2)
enum BeamMode string