dEdxcalibration_module.cc
Go to the documentation of this file.
5 #include "art_root_io/TFileService.h"
6 #include "art_root_io/TFileDirectory.h"
8 #include "canvas/Persistency/Common/FindManyP.h"
11 #include "fhiclcpp/ParameterSet.h"
13 
23 #include "lardataobj/RawData/raw.h"
44 
45 #include "TFile.h"
46 #include "TTree.h"
47 #include "TDirectory.h"
48 #include "TH1.h"
49 #include "TH2.h"
50 #include "TF1.h"
51 #include "TProfile.h"
52 #include "TROOT.h"
53 #include "TStyle.h"
54 #include "TMath.h"
55 #include "TGraphErrors.h"
56 #include "TMinuit.h"
57 #include "TString.h"
58 #include "TTimeStamp.h"
59 #include "TVectorD.h"
60 #include "TCanvas.h"
61 #include "TFrame.h"
62 #include "TLine.h"
63 #include "TAxis.h"
64 #include "TTimeStamp.h"
65 
66 #include <vector>
67 #include <fstream>
68 #include "TPaveStats.h"
69 #include <iostream>
70 #include <string>
71 #include "math.h"
72 #include "stdio.h"
73 #include <iterator>
74 
75 const int kMaxTracks = 200;
76 
77 using namespace std;
78 
79 namespace dune{
80 
82  public:
83 
84  explicit dEdxcalibration(fhicl::ParameterSet const& pset);
85  virtual ~dEdxcalibration();
86 
87  void beginJob();
88  void endJob();
89  void beginRun(const art::Run& run);
90  void analyze(const art::Event& evt);
91  void reset();
92 
93  private:
94  TTree* fEventTree;
95  Int_t run;
96  Int_t subrun;
97  Int_t event;
98  Double_t Total_energy[kMaxTracks];
99  Double_t EndE[kMaxTracks];
100  Int_t pdg[kMaxTracks];
101  Double_t evttime;
104  Int_t cross_trks;
109  Int_t all_trks;
110  Float_t xprojectedlen[kMaxTracks];
111  Float_t trackthetaxz[kMaxTracks];
112  Float_t trackthetayz[kMaxTracks];
113  Float_t trkstartx[kMaxTracks];
114  Float_t trkstarty[kMaxTracks];
115  Float_t trkstartz[kMaxTracks];
116  Float_t trkendx[kMaxTracks];
117  Float_t trkendy[kMaxTracks];
118  Float_t trkendz[kMaxTracks];
119  Float_t trklen[kMaxTracks];
120  Int_t TrkID[kMaxTracks];
121  Int_t TrackId_geant[kMaxTracks];
123  Float_t EndPointx[kMaxTracks];
124  Float_t EndPointy[kMaxTracks];
125  Float_t EndPointz[kMaxTracks];
126  Float_t EndPointx_corrected[kMaxTracks];
127  Float_t EndPointy_corrected[kMaxTracks];
128  Float_t EndPointz_corrected[kMaxTracks];
129  Float_t StartPointx[kMaxTracks];
130  Float_t StartPointy[kMaxTracks];
131  Float_t StartPointz[kMaxTracks];
132  Float_t trkstartcosxyz[kMaxTracks][3];
133  Float_t trkendcosxyz[kMaxTracks][3];
134  Int_t ntrkhits[kMaxTracks][3];
135  Float_t trkdqdx[kMaxTracks][3][3000];
136  Float_t trkdedx[kMaxTracks][3][3000];
137  Float_t trkresrange[kMaxTracks][3][3000];
138  Float_t trkhitx[kMaxTracks][3][3000];
139  Float_t trkhity[kMaxTracks][3][3000];
140  Float_t trkhitz[kMaxTracks][3][3000];
141  Float_t trkpitch[kMaxTracks][3][3000];
142  Float_t peakT_max[kMaxTracks];
143  Float_t peakT_min[kMaxTracks];
144  Int_t daughter_electrons[kMaxTracks];
145  Int_t daughter_positrons[kMaxTracks];
151  };
152 
153  //========================================================================
154  dEdxcalibration::dEdxcalibration(fhicl::ParameterSet const& pset) :
155  EDAnalyzer(pset),
156  fHitsModuleLabel (pset.get< std::string >("HitsModuleLabel","") ),
157  fTrackModuleLabel (pset.get< std::string >("TrackModuleLabel","") ),
158  fCalorimetryModuleLabel (pset.get< std::string >("CalorimetryModuleLabel","") ),
159  fSaveCaloInfo (pset.get< bool>("SaveCaloInfo",false)),
160  fSaveTrackInfo (pset.get< bool>("SaveTrackInfo",false))
161  {
162  if (fSaveTrackInfo == false) fSaveCaloInfo = false;
163  }
164 
165  //========================================================================
167  }
168  //========================================================================
169 
170  //========================================================================
172  std::cout<<"job begin..."<<std::endl;
174  fEventTree = tfs->make<TTree>("Event", "Event Tree from Reco");
175  fEventTree->Branch("event", &event,"event/I");
176  fEventTree->Branch("evttime",&evttime,"evttime/D");
177  fEventTree->Branch("run", &run,"run/I");
178  fEventTree->Branch("subrun", &subrun,"surbrun/I");
179  fEventTree->Branch("year_month_date", &year_month_date,"year_month_date/I");
180  fEventTree->Branch("hour_min_sec", &hour_min_sec,"hour_min_sec/I");
181  fEventTree->Branch("cross_trks",&cross_trks,"cross_trks/I");
182  fEventTree->Branch("mc_stopping20",&mc_stopping20,"mc_stopping20/I");
183  fEventTree->Branch("mc_stopping50",&mc_stopping50,"mc_stopping50/I");
184  fEventTree->Branch("true_stopping_muons",&true_stopping_muons,"true_stopping_muons/I");
185  fEventTree->Branch("stopping_trks",&stopping_trks,"stopping_trks/I");
186  fEventTree->Branch("all_trks",&all_trks,"all_trks/I");
187  fEventTree->Branch("xprojectedlen",xprojectedlen,"xprojectedlen[all_trks]/F");
188  fEventTree->Branch("trackthetaxz",trackthetaxz,"trackthetaxz[cross_trks]/F");
189  fEventTree->Branch("trackthetayz",trackthetayz,"trackthetayz[cross_trks]/F");
190  fEventTree->Branch("trkstartx",trkstartx,"trkstartx[cross_trks]/F");
191  fEventTree->Branch("trkstarty",trkstarty,"trkstarty[cross_trks]/F");
192  fEventTree->Branch("trkstartz",trkstartz,"trkstartz[cross_trks]/F");
193  fEventTree->Branch("trkendx",trkendx,"trkendx[cross_trks]/F");
194  fEventTree->Branch("trkendy",trkendy,"trkendy[cross_trks]/F");
195  fEventTree->Branch("trkendz",trkendz,"trkendz[cross_trks]/F");
196  fEventTree->Branch("trklen",trklen,"trklen[cross_trks]/F");
197  fEventTree->Branch("Total_energy",Total_energy,"Total_energy[cross_trks]/D");
198  fEventTree->Branch("EndE",EndE,"EndE[cross_trks]/D");
199  fEventTree->Branch("peakT_max",peakT_max,"peakT_max[cross_trks]/F");
200  fEventTree->Branch("peakT_min",peakT_min,"peakT_min[cross_trks]/F");
201  fEventTree->Branch("pdg",pdg,"pdg[cross_trks]/I");
202  fEventTree->Branch("origin",origin,"origin[cross_trks]/I");
203  fEventTree->Branch("TrkID",TrkID,"TrkID[cross_trks]/I");
204  fEventTree->Branch("TrackId_geant",TrackId_geant,"TrackId_geant[cross_trks]/I");
205  fEventTree->Branch("daughter_electrons",daughter_electrons,"daughter_electrons[cross_trks]/I");
206  fEventTree->Branch("daughter_positrons",daughter_positrons,"daughter_positrons[cross_trks]/I");
207  fEventTree->Branch("EndPointx",EndPointx,"EndPointx[cross_trks]/F");
208  fEventTree->Branch("EndPointy",EndPointy,"EndPointy[cross_trks]/F");
209  fEventTree->Branch("EndPointz",EndPointz,"EndPointz[cross_trks]/F");
210  fEventTree->Branch("EndPointx_corrected",EndPointx_corrected,"EndPointx_corrected[cross_trks]/F");
211  fEventTree->Branch("EndPointy_corrected",EndPointy_corrected,"EndPointy_corrected[cross_trks]/F");
212  fEventTree->Branch("EndPointz_corrected",EndPointz_corrected,"EndPointz_corrected[cross_trks]/F");
213  fEventTree->Branch("StartPointx",StartPointx,"StartPointx[cross_trks]/F");
214  fEventTree->Branch("StartPointy",StartPointy,"StartPointy[cross_trks]/F");
215  fEventTree->Branch("StartPointz",StartPointz,"StartPointz[cross_trks]/F");
216  fEventTree->Branch("trkstartcosxyz",trkstartcosxyz,"trkstartcosxyz[cross_trks][3]/F");
217  fEventTree->Branch("trkendcosxyz",trkendcosxyz,"trkendcosxyz[cross_trks][3]/F");
218  fEventTree->Branch("ntrkhits",ntrkhits,"ntrkhits[cross_trks][3]/I");
219  fEventTree->Branch("trkdqdx",trkdqdx,"trkdqdx[cross_trks][3][3000]/F");
220  fEventTree->Branch("trkdedx",trkdedx,"trkdedx[cross_trks][3][3000]/F");
221  fEventTree->Branch("trkresrange",trkresrange,"trkresrange[cross_trks][3][3000]/F");
222  fEventTree->Branch("trkhitx",trkhitx,"trkhitx[cross_trks][3][3000]/F");
223  fEventTree->Branch("trkhity",trkhity,"trkhity[cross_trks][3][3000]/F");
224  fEventTree->Branch("trkhitz",trkhitz,"trkhitz[cross_trks][3][3000]/F");
225  fEventTree->Branch("trkpitch",trkpitch,"trkpitch[cross_trks][3][3000]/F");
226  }
227 
228  //========================================================================
230 
231  }
232 
233  //========================================================================
235  mf::LogInfo("dEdxcalibration")<<"begin run..."<<std::endl;
236  }
237  //========================================================================
238 
239  //========================================================================
240 
241  //========================================================================
242 
244  reset();
247 
248  std::vector<art::Ptr<recob::Track> > tracklist;
249  auto trackListHandle = evt.getHandle< std::vector<recob::Track> >(fTrackModuleLabel);
250  if (trackListHandle) art::fill_ptr_vector(tracklist, trackListHandle);
251 
252  std::vector<art::Ptr<recob::PFParticle> > pfplist;
253  auto PFPListHandle = evt.getHandle< std::vector<recob::PFParticle> >("pandora");
254  if (PFPListHandle) art::fill_ptr_vector(pfplist, PFPListHandle);
255 
256  /******new lines*************************/
257  std::vector<art::Ptr<recob::Hit>> hitlist;
258  auto hitListHandle = evt.getHandle< std::vector<recob::Hit> >(fHitsModuleLabel); // to get information about the hits
259  if (hitListHandle)
260  art::fill_ptr_vector(hitlist, hitListHandle);
261 
262  art::FindManyP<recob::Hit> fmtht(trackListHandle, evt, fTrackModuleLabel); // to associate tracks and hits
263 
264 
265  art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, evt, fCalorimetryModuleLabel);
266  art::FindManyP<anab::T0> trk_t0_assn_v(PFPListHandle, evt ,"pandora");
267  art::FindManyP<recob::PFParticle> pfp_trk_assn(trackListHandle,evt,"pandoraTrack");
268  art::FindManyP<anab::T0> fmT0(trackListHandle, evt ,"pmtrack");
269 
270 
271  run = evt.run();
272  subrun = evt.subRun();
273  event = evt.id().event();
274  art::Timestamp ts = evt.time();
275  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
276  evttime=tts.AsDouble();
277 
278  UInt_t year=0;
279  UInt_t month=0;
280  UInt_t day=0;
281 
282  year_month_date=tts.GetDate(kTRUE,0,&year,&month,&day);
283 
284  UInt_t hour=0;
285  UInt_t min=0;
286  UInt_t sec=0;
287 
288  hour_min_sec=tts.GetTime(kTRUE,0,&hour,&min,&sec);
289 
290  cross_trks=0;
291  stopping_trks=0;
292  all_trks=0;
294  mc_stopping20=0;
295  mc_stopping50=0;
296 
297  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
298 
299  size_t NTracks = tracklist.size();
300  for(size_t i=0; i<NTracks;++i){
301  art::Ptr<recob::Track> ptrack(trackListHandle, i);
302  if(fTrackModuleLabel=="pandoraTrack"){
303  std::vector<art::Ptr<recob::PFParticle>> pfps=pfp_trk_assn.at(i);
304  if(!pfps.size()) continue;
305  std::vector<art::Ptr<anab::T0>> t0s=trk_t0_assn_v.at(pfps[0].key());
306  if(!t0s.size()) continue;
307  //auto t0 = t0s.at(0);
308  // double t_zero=t0->Time();
309  }
310 
311 
312 
313 
314  if(fTrackModuleLabel=="pmtrack"){
315  std::vector<art::Ptr<anab::T0>> T0s=fmT0.at(i);
316  if(T0s.size()==0)
317  continue;
318  }
319  all_trks++;
320  std::vector<art::Ptr<anab::Calorimetry>> calos=fmcal.at(i);
321  const recob::Track& track = *ptrack;
322  auto pos = track.Vertex<TVector3>();
323  auto dir_start = track.VertexDirection<TVector3>();
324  auto dir_end = track.EndDirection<TVector3>();
325  auto end = track.End();
326  double theta_xz = std::atan2(dir_start.X(), dir_start.Z());
327  double theta_yz = std::atan2(dir_start.Y(), dir_start.Z());
328  float starty=pos.Y();
329  float startz=pos.Z();
330  float endy=end.Y();
331  float endz=end.Z();
332  float startcosx=dir_start.X();
333  float startcosy=dir_start.Y();
334  float startcosz=dir_start.Z();
335  float endcosx=dir_end.X();
336  float endcosy=dir_end.Y();
337  float endcosz=dir_end.Z();
338  float tracklength=track.Length();
339  size_t count = 0;
340  /********************************************************************************************************/
341  /*********************storing hits for each tracks*******************************/
342 
343 
344  std::vector<art::Ptr<recob::Hit>> allHits=fmtht.at(i); //storing hits for ith track
345  int trackid=-1;
348  std::map<int,double> trkide;
349  std::vector<float> hitpeakT;
350  //selection based on hitpeakT
351  for(size_t h1=0;h1<allHits.size();h1++){
352  hitpeakT.push_back(allHits[h1]->PeakTime());
353  }
354  float max=-999999;
355  float min=-999999;
356  min=*min_element(hitpeakT.begin(),hitpeakT.end());
357  max=*max_element(hitpeakT.begin(),hitpeakT.end());
358  hitpeakT.clear();
359  // if(min<250) continue;
360  for(size_t h=0; h<allHits.size();h++){
361  art::Ptr<recob::Hit> hit=allHits[h];
362  std::vector<sim::TrackIDE> eveIDs = bt_serv->HitToTrackIDEs(clockData, hit);
363  for(size_t e=0;e<eveIDs.size(); ++e){
364  trkide[eveIDs[e].trackID] += eveIDs[e].energy;
365  }
366  }
367  double maxe = -1;
368  double tote = 0;
369  for(std::map<int,double>::iterator ii = trkide.begin(); ii!=trkide.end(); ++ii){
370  tote += ii->second;
371  if((ii->second)>maxe){
372  maxe = ii->second;
373  trackid = ii->first;
374 
375  }
376  }
377  float EndE1=-99999;
378  int pdg1=-99999;
379  int mc_endx=-99999;
380  int mc_endy=-99999;
381  int mc_endz=-99999;
382  const art::Ptr<simb::MCTruth> mc=pi_serv->TrackIdToMCTruth_P(trackid);
383  const simb::MCParticle *particle = pi_serv->TrackIdToParticle_P(trackid);
384  if(particle){
385  EndE1 = particle->EndE();
386  pdg1=particle->PdgCode();
387  mc_endx=particle->EndPosition()[0];
388  mc_endy=particle->EndPosition()[1];
389  mc_endz=particle->EndPosition()[2];
390  };
391  if(std::abs(pdg1)==13 && std::abs(mc_endx)<310 && mc_endy>50 && mc_endy<550 && mc_endz>50 && mc_endz<645) mc_stopping50++;
392  if(std::abs(pdg1)==13 && std::abs(mc_endx)<340 && mc_endy>20 && mc_endy<580 && mc_endz>20 && mc_endz<675) mc_stopping20++;
393  if(std::abs(pdg1)==13 && EndE1<0.106) true_stopping_muons++;
394  if(!particle) continue;
395 
396 
397 
398 
399 
400 
401  if(!(((std::abs(pos.X())>340 || pos.Y()<20 || pos.Y()>580 || pos.Z()<20 || pos.Z()>675) && !(std::abs(end.X())>310 || end.Y()<50 || end.Y()>550 || end.Z()<50 || end.Z()>645))||(!(std::abs(pos.X())>310 || pos.Y()<50 || pos.Y()>550 || pos.Z()<50 || pos.Z()>645) && (std::abs(end.X())>340 || end.Y()<20 || end.Y()>580 || end.Z()<20 || end.Z()>675)))) continue;
402  // if(!(((std::abs(pos.X())>340 || pos.Y()<20 || pos.Y()>580 || pos.Z()<20 || pos.Z()>675) && !(std::abs(end.X())>320 || end.Y()<40 || end.Y()>560 || end.Z()<40 || end.Z()>655))||(!(std::abs(pos.X())>320 || pos.Y()<40 || pos.Y()>560 || pos.Z()<40 || pos.Z()>655) && (std::abs(end.X())>340 || end.Y()<20 || end.Y()>580 || end.Z()<20 || end.Z()>675)))) continue;
403  stopping_trks++;
404 
405  /**********************************broken tracks removal**************************************************************************************/
406  for(size_t k=0;k<NTracks;++k){
407  art::Ptr<recob::Track> ptrack_k(trackListHandle, k);
408  const recob::Track& track_k = *ptrack_k;
409  auto pos_k = track_k.Vertex();
410  auto dir_pos_k= track_k.VertexDirection();
411  auto dir_end_k = track_k.EndDirection();
412  auto end_k = track_k.End();
413  if(k==i) continue;
414  if((std::abs(((end_k.Y()-pos_k.Y())/(end_k.Z()-pos_k.Z()))*(endz-pos_k.Z())+pos_k.Y()-endy)<30||std::abs(((end_k.Y()-pos_k.Y())/(end_k.Z()-pos_k.Z()))*(startz-pos_k.Z())+pos_k.Y()-starty)<30)&&(std::abs(endcosx*dir_pos_k.X()+endcosy*dir_pos_k.Y()+endcosz*dir_pos_k.Z())>0.97||std::abs(startcosx*dir_pos_k.X()+startcosy*dir_pos_k.Y()+startcosz*dir_pos_k.Z())>0.97||std::abs(endcosx*dir_end_k.X()+endcosy*dir_end_k.Y()+endcosz*dir_end_k.Z())>0.97||std::abs(startcosx*dir_end_k.X()+startcosy*dir_end_k.Y()+startcosz*dir_end_k.Z())>0.97)) break;
415  if((std::abs(((end_k.Y()-pos_k.Y())/(end_k.Z()-pos_k.Z()))*(endz-pos_k.Z())+pos_k.Y()-endy)<50||std::abs(((end_k.Y()-pos_k.Y())/(end_k.Z()-pos_k.Z()))*(startz-pos_k.Z())+pos_k.Y()-starty)<50)&&(std::abs(endcosx*dir_pos_k.X()+endcosy*dir_pos_k.Y()+endcosz*dir_pos_k.Z())>0.998||std::abs(startcosx*dir_pos_k.X()+startcosy*dir_pos_k.Y()+startcosz*dir_pos_k.Z())>0.998||std::abs(endcosx*dir_end_k.X()+endcosy*dir_end_k.Y()+endcosz*dir_end_k.Z())>0.998||std::abs(startcosx*dir_end_k.X()+startcosy*dir_end_k.Y()+startcosz*dir_end_k.Z())>0.998)) break;
416  count++;
417 
418  }
419  if(!(count==NTracks-1)|| tracklength<100) continue;
420  int geant_trkID=particle->TrackId();
421  int n_daughters_electron=0;
422  int n_daughters_positron=0;
423  if(abs(pdg1)==13){
424  const sim::ParticleList& plist = pi_serv->ParticleList();
425  sim::ParticleList::const_iterator itPart=plist.begin(),pend=plist.end();
426  for(size_t iPart = 0;(iPart<plist.size()) && (itPart!=pend); ++iPart){
427  const simb::MCParticle* pPart = (itPart++)->second;
428  int pdgcode = pPart->PdgCode();
429  // if(abs(pdgcode)==11) std::cout<<pdgcode<<" "<<pPart->Process()<<" "<<pPart->Mother()<<" "<<geant_trkID<<std::endl;
430  if(pPart->Mother()==geant_trkID && pdgcode==11) n_daughters_electron++;
431  if(pPart->Mother()==geant_trkID && pdgcode==-11) n_daughters_positron++;
432  }
433  }
434  /*************************************filling the values****************************/
435  cross_trks++;
436 
437  auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
438  EndPointx_corrected[cross_trks-1]=particle->EndPosition()[0]-SCE->GetPosOffsets(geo::Point_t(particle->EndPosition()[0],particle->EndPosition()[1],particle->EndPosition()[2])).X();
439  EndPointy_corrected[cross_trks-1]=particle->EndPosition()[1]+SCE->GetPosOffsets(geo::Point_t(particle->EndPosition()[0],particle->EndPosition()[1],particle->EndPosition()[2])).Y();
440  EndPointz_corrected[cross_trks-1]=particle->EndPosition()[2]+SCE->GetPosOffsets(geo::Point_t(particle->EndPosition()[0],particle->EndPosition()[1],particle->EndPosition()[2])).Z();
441  origin[cross_trks-1]=mc->Origin();
442  daughter_electrons[cross_trks-1]=n_daughters_electron++;
443  daughter_positrons[cross_trks-1]=n_daughters_positron++;
444  EndE[cross_trks-1]=particle->EndE();
445  pdg[cross_trks-1]=particle->PdgCode();
446  TrackId_geant[cross_trks-1]=particle->TrackId();
447  EndPointx[cross_trks-1]=particle->EndPosition()[0];
448  EndPointy[cross_trks-1]=particle->EndPosition()[1];
449  EndPointz[cross_trks-1]=particle->EndPosition()[2];
450  StartPointx[cross_trks-1]=particle->Vx();
451  StartPointy[cross_trks-1]=particle->Vy();
452  StartPointz[cross_trks-1]=particle->Vz();
453  Total_energy[cross_trks-1]=tote;
454  trackthetaxz[cross_trks-1]=theta_xz;
455  trackthetayz[cross_trks-1]=theta_yz;
456  trkstartx[cross_trks-1]=pos.X();
457  trkstarty[cross_trks-1]=pos.Y();
458  trkstartz[cross_trks-1]=pos.Z();
459  trkendx[cross_trks-1]=end.X();
460  trkendy[cross_trks-1]=end.Y();
461  trkendz[cross_trks-1]=end.Z();
462  trklen[cross_trks-1]=track.Length();
463  TrkID[cross_trks-1]=track.ID();
466  trkstartcosxyz[cross_trks-1][0]=dir_start.X();
467  trkstartcosxyz[cross_trks-1][1]=dir_start.Y();
468  trkstartcosxyz[cross_trks-1][2]=dir_start.Z();
469  trkendcosxyz[cross_trks-1][0]=dir_end.X();
470  trkendcosxyz[cross_trks-1][1]=dir_end.Y();
471  trkendcosxyz[cross_trks-1][2]=dir_end.Z();
472  for(size_t ical = 0; ical<calos.size(); ++ical){
473  if(!calos[ical]) continue;
474  if(!calos[ical]->PlaneID().isValid) continue;
475  int planenum = calos[ical]->PlaneID().Plane;
476  if(planenum<0||planenum>2) continue;
477  const size_t NHits = calos[ical] -> dEdx().size();
478  ntrkhits[cross_trks-1][planenum]=int(NHits);
479  for(size_t iHit = 0; iHit < NHits; ++iHit){
480  const auto& TrkPos = (calos[ical] -> XYZ())[iHit];
481  trkdqdx[cross_trks-1][planenum][iHit]=(calos[ical] -> dQdx())[iHit];
482  trkdedx[cross_trks-1][planenum][iHit]=(calos[ical] -> dEdx())[iHit];
483  trkresrange[cross_trks-1][planenum][iHit]=(calos[ical]->ResidualRange())[iHit];
484  trkhitx[cross_trks-1][planenum][iHit]=TrkPos.X();
485  trkhity[cross_trks-1][planenum][iHit]=TrkPos.Y();
486  trkhitz[cross_trks-1][planenum][iHit]=TrkPos.Z();
487  trkpitch[cross_trks-1][planenum][iHit]=(calos[ical]->TrkPitchVec())[iHit];
488  } // loop over iHit..
489  } // loop over ical 2nd time...
490  } // loop over trks...
491  // stopping_muons->Fill(stopping_trks);
492  fEventTree->Fill();
493  } // end of analyze function
494 
495  /////////////////// Defintion of reset function ///////////
497  run = -99999;
498  subrun = -99999;
499  event = -99999;
500  evttime = -99999;
501  cross_trks = -99999;
502  true_stopping_muons=-99999;
503  mc_stopping20=-99999;
504  mc_stopping50=-99999;
505  all_trks = -99999;
506  year_month_date=-99999;
507  hour_min_sec=-99999;
508  for(int i=0; i<kMaxTracks; i++){
509  trackthetaxz[i]=-99999;
510  trackthetayz[i]=-99999;
511  trkstartx[i]=-99999;
512  trkstarty[i]=-99999;
513  trkstartz[i]=-99999;
514  trkendx[i]=-99999;
515  trkendy[i]=-99999;
516  trkendz[i]=-99999;
517  trklen[i]=-99999;
518  TrkID[i]=-99999;
519  TrackId_geant[i]=-99999;
520  origin[i]=-99999;
521  EndE[i]=-99999;
522  pdg[i]=-99999;
523  Total_energy[i]=-999999;
524  daughter_electrons[i]=-99999;
525  daughter_positrons[i]=-99999;
526  EndPointx[i]=-99999;
527  EndPointy[i]=-99999;
528  EndPointz[i]=-99999;
529  EndPointx_corrected[i]=-99999;
530  EndPointy_corrected[i]=-99999;
531  EndPointz_corrected[i]=-99999;
532  StartPointx[i]=-99999;
533  StartPointy[i]=-99999;
534  StartPointz[i]=-99999;
535  pdg[i]=-99999;
536  EndE[i]=-99999;
537  peakT_max[i]=-99999;
538  peakT_min[i]=-99999;
539  xprojectedlen[i]=-99999;
540  trkstartcosxyz[i][0]=-99999;
541  trkstartcosxyz[i][1]=-99999;
542  trkstartcosxyz[i][2]=-99999;
543  trkendcosxyz[i][0]=-99999;
544  trkendcosxyz[i][1]=-99999;
545  trkendcosxyz[i][2]=-99999;
546  ntrkhits[i][0] = -99999;
547  ntrkhits[i][1] = -99999;
548  ntrkhits[i][2] = -99999;
549  for(int j=0; j<3; j++){
550  for(int k=0; k<3000; k++){
551  trkdqdx[i][j][k]=-99999;
552  trkdedx[i][j][k]=-99999;
553  trkresrange[i][j][k]=-99999;
554  trkhitx[i][j][k]=-99999;
555  trkhity[i][j][k]=-99999;
556  trkhitz[i][j][k]=-99999;
557  trkpitch[i][j][k]=-99999;
558  }
559  }
560  }
561  }
562  //////////////////////// End of definition ///////////////
563 
565 }
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Float_t trkstartcosxyz[kMaxTracks][3]
intermediate_table::iterator iterator
int PdgCode() const
Definition: MCParticle.h:212
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
Float_t EndPointx[kMaxTracks]
Float_t StartPointz[kMaxTracks]
double EndE() const
Definition: MCParticle.h:244
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:225
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
Int_t daughter_positrons[kMaxTracks]
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
const simb::MCParticle * TrackIdToParticle_P(int id) const
int Mother() const
Definition: MCParticle.h:213
Float_t StartPointx[kMaxTracks]
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
simb::Origin_t Origin() const
Definition: MCTruth.h:74
Vector_t VertexDirection() const
Definition: Track.h:132
STL namespace.
Float_t trackthetayz[kMaxTracks]
Float_t peakT_max[kMaxTracks]
intermediate_table::const_iterator const_iterator
Float_t trkstarty[kMaxTracks]
Particle class.
Float_t trkhitz[kMaxTracks][3][3000]
object containing MC flux information
art framework interface to geometry description
Float_t trkhitx[kMaxTracks][3][3000]
Definition: Run.h:17
int TrackId() const
Definition: MCParticle.h:210
Float_t EndPointy_corrected[kMaxTracks]
Float_t trkstartx[kMaxTracks]
Float_t EndPointx_corrected[kMaxTracks]
T abs(T value)
Float_t EndPointz[kMaxTracks]
QTextStream & reset(QTextStream &s)
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
Double_t EndE[kMaxTracks]
const double e
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:167
Timestamp time() const
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void beginJob()
Definition: Breakpoints.cc:14
def key(type, name=None)
Definition: graph.py:13
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
Float_t trackthetaxz[kMaxTracks]
const int kMaxTracks
Point_t const & Vertex() const
Definition: Track.h:124
Double_t Total_energy[kMaxTracks]
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
Float_t StartPointy[kMaxTracks]
RunNumber_t run() const
Definition: DataViewImpl.cc:71
static int max(int a, int b)
Definition of data types for geometry description.
void analyze(const art::Event &evt)
Detector simulation of raw signals on wires.
Float_t trkhity[kMaxTracks][3][3000]
const sim::ParticleList & ParticleList() const
Float_t EndPointy[kMaxTracks]
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
double Vx(const int i=0) const
Definition: MCParticle.h:221
int ID() const
Definition: Track.h:198
Float_t xprojectedlen[kMaxTracks]
Declaration of signal hit object.
Float_t trkendcosxyz[kMaxTracks][3]
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
Vector_t EndDirection() const
Definition: Track.h:133
Provides recob::Track data product.
Float_t trkresrange[kMaxTracks][3][3000]
double Vz(const int i=0) const
Definition: MCParticle.h:223
Float_t trkdedx[kMaxTracks][3][3000]
EventNumber_t event() const
Definition: EventID.h:116
Point_t const & End() const
Definition: Track.h:125
Float_t peakT_min[kMaxTracks]
Declaration of basic channel signal object.
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
void beginRun(const art::Run &run)
Float_t trkpitch[kMaxTracks][3][3000]
Int_t ntrkhits[kMaxTracks][3]
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
Float_t trkdqdx[kMaxTracks][3][3000]
Float_t EndPointz_corrected[kMaxTracks]
Float_t trkstartz[kMaxTracks]
int bool
Definition: qglobal.h:345
Int_t daughter_electrons[kMaxTracks]
EventID id() const
Definition: Event.cc:34
double Vy(const int i=0) const
Definition: MCParticle.h:222
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
QTextStream & endl(QTextStream &s)
Event finding and building.