RecoTrack_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TimeDist
3 // Module Type: analyzer
4 // File: RecoTrack_module.cc
5 //
6 // Under development: aims to calculate electron lifetime
7 //
8 // Celio Moura camj@fnal.gov celio.moura@ufabc.edu.br
9 //
10 ////////////////////////////////////////////////////////////////////////
11 // Run like this:
12 // lar -c RecoTrack.fcl -s /dune/data/users/camj/input/prodcosmics_dune35t_milliblock_0_20150827T232050_merged.root -T recotrack.root -n 4
13 
14 #ifndef RecoTrack_Module
15 #define RecoTrack_Module
16 
17 // LArSoft includes
23 
24 // Framework includes
29 #include "art_root_io/TFileService.h"
31 #include "fhiclcpp/ParameterSet.h"
32 #include "canvas/Persistency/Common/FindManyP.h"
33 
34 // ROOT includes
35 #include "TH1.h"
36 #include "TH2.h"
37 #include "TTree.h"
38 #include "TVector3.h"
39 
40 #include "TF1.h"
41 //#include "TCanvas.h"
42 
43 // C++ Includes
44 #include <vector>
45 #include <string>
46 #include <math.h>
47 #include <algorithm>
48 #include <iostream>
49 #include <fstream>
50 
51 #define PI 3.14159265
52 
53 namespace RecoTrack {
54 
55  class RecoTrack : public art::EDAnalyzer
56  {
57  public:
58 
59  explicit RecoTrack(fhicl::ParameterSet const& parameterSet);
60 
61  virtual void beginJob() override;
62  virtual void reconfigure(fhicl::ParameterSet const& parameterSet) ;
63  virtual void analyze (const art::Event& event) override;
64 
65  private:
66 
68  std::string fHitProducerLabel; ///< The name of the producer that created hits
69  TH1D* fTimeHist; ///< Hit time of all particles
70  TH1D* fTimeHist1; ///< Hit time of all particles
71  TH1D* fTimeHist2; ///< Hit time of all particles
72  TH1D* fTimeHist3; ///< Hit time of all particles
73  TH1D* fTimeHist4; ///< Hit time of all particles
89 
90  TH2D* fChADCvsTM;
105 
106  ////// TProfile* prof;
107  TF1 *f1;
108  TF1 *f2;
109  TF1 *f3;
110  TF1 *f31;
111  TF1 *f32;
112  TF1 *f33;
113  TF1 *f34;
114  TF1 *f35;
115  TF1 *f36;
116  TF1 *f37;
117  TF1 *f38;
118  TF1 *f4;
119 
120  // for c2: remove unused variables
121  //TF1 *g31,*g32,*g33,*g34,*g35,*g36,*g37;
122  TF1 *g31,*g32;
123 
124  TH1D* fXHist;
125  TH1D* fYHist;
126  TH1D* fZHist;
127 
130 
132 
133  double frequency;
134  double hittime;
135  double hittime2;
136  double chargeADC2;
138 
139  double chargeADCmax1,chargeADCmin1;
140  double chargeADCmax2,chargeADCmin2;
141  double chargeADCmax3,chargeADCmin3;
142  double chargeADCmax4,chargeADCmin4;
143  double chargeADCmax5,chargeADCmin5;
144  double chargeADCmax6,chargeADCmin6;
145  double chargeADCmax7,chargeADCmin7;
146 
147  double trackTheta;
148  double trackPhi;
149 
150  double x;
151  double y;
152  double z;
153 
154  std::vector<double> hittest,timetest;
155  std::vector<double> hittest2,timetest2;
156  std::vector<double> hittest3,timetest3;
157  std::vector<double> hittest4,timetest4;
158  std::vector<double> hittest5,timetest5;
159  std::vector<double> hittest6,timetest6;
160  std::vector<double> hittest7,timetest7;
161  std::vector<double> hittest8,timetest8;
162  std::vector<int> wiretest,timevec;
163 
164  // for c2: these variables are not currently used
165  //double hittimemin;
166  //double hittimemax;
167 
168  // for c2: remove unused variables
169  //double min1,min2,min3,min4,min5,min6,min7;
170  //double max1,max2,max3,max4,max5,max6,max7;
171  double min3;
172  double max3;
173 
174  std::ofstream myfile;
175 
176  int wiretmp,wirehit,wirecount;
177 
178  }; // class RecoTrack
179 
181  : EDAnalyzer(parameterSet)
182  {
183  reconfigure(parameterSet);
184  }
185 
186  //-----------------------------------------------------------------------
188  {
190 
191  fTrackLengthHist = tfs->make<TH1D>("trackVecLength", ";particle track length (cm);", 500, -20, 480);
192  fNofTrackWires = tfs->make<TH1D>("wires",";number of wires hit in a track;",500,-20,480);
193  fNofTrackHits = tfs->make<TH1D>("hits",";number of hits in a track;",1000,-10,990);
194  fTimeHist = tfs->make<TH1D>("timehist",";Histogram of Hit Times;",1000, -10, 990);
195  fTimeHist1 = tfs->make<TH1D>("timehist1",";Histogram2 of Hit Times;",500, -1000, 17000);
196  fTimeHist2 = tfs->make<TH1D>("timehist2",";Histogram2 of Hit Times;",500, -1000, 17000);
197  fTimeHist3 = tfs->make<TH1D>("timehist3",";Histogram of Hit Times;",500, -1000, 17000);
198  fTimeHist4 = tfs->make<TH1D>("timehist4",";Histogram of Hit Times;",500, -1000, 17000);
199  fChargeADCHist1 = tfs->make<TH1D>("ch-adc-hist1",";Histogram of Charge;",100, 100, 1100);
200  fChargeADCHist2 = tfs->make<TH1D>("ch-adc-hist2",";Histogram of Charge;",30, 0, 1200);
201  fChargeADCHist3 = tfs->make<TH1D>("ch-adc-hist3",";Histogram of Charge;",40, 0, 1400);
202  fChargeADCHist31 = tfs->make<TH1D>("ch-adc-hist31",";Histogram of Charge;",30, 200, 800);
203  fChargeADCHist32 = tfs->make<TH1D>("ch-adc-hist32",";Histogram of Charge;",30, 200, 800);
204  fChargeADCHist33 = tfs->make<TH1D>("ch-adc-hist33",";Histogram of Charge;",30, 200, 800);
205  fChargeADCHist34 = tfs->make<TH1D>("ch-adc-hist34",";Histogram of Charge;",30, 200, 800);
206  fChargeADCHist35 = tfs->make<TH1D>("ch-adc-hist35",";Histogram of Charge;",30, 200, 800);
207  fChargeADCHist36 = tfs->make<TH1D>("ch-adc-hist36",";Histogram of Charge;",30, 200, 800);
208  fChargeADCHist37 = tfs->make<TH1D>("ch-adc-hist37",";Histogram of Charge;",30, 200, 800);
209  fChargeADCHist38 = tfs->make<TH1D>("ch-adc-hist38",";Histogram of Charge;",30, 200, 800);
210  fChargeADCHist4 = tfs->make<TH1D>("ch-adc-hist4",";Histogram of Charge;",20, 100, 700);
211  fChADCvsTM = tfs->make<TH2D>("chargeADC.vs.time",";ChargeADC vs Time 2D Plot;",7000,-500,6500,2000,0,2000);
212  fLogChADCvsTM = tfs->make<TH2D>("chargeADCLog.vs.time",";Log(ChargeADC) vs Time 2D Plot;",7000,-500,6500,120,3,9);
213  fLogChADCvsTMkZ = tfs->make<TH2D>("chargeADCLogkZ.vs.time",";Log(ChargeADC) vs Time 2D Plot;",7000,-500,6500,120,3,9);
214  fLogChADCvsTM1 = tfs->make<TH2D>("chargeADCLog_1.vs.time",";Log(ChargeADC) vs Time 2D Plot;",300,1500,1800,120,3,9);
215  fLogChADCvsTM2 = tfs->make<TH2D>("chargeADCLog_2.vs.time",";Log(ChargeADC) vs Time 2D Plot;",500,6500,7000,120,3,9);
216  fLogChADCvsTM3 = tfs->make<TH2D>("chargeADCLog_3.vs.time",";Log(ChargeADC) vs Time 2D Plot;",1000,11600,12600,120,3,9);
217  fLogChADCvsTM31 = tfs->make<TH2D>("chargeADCLog_31.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,11650,11850,60,3,9);
218  fLogChADCvsTM32 = tfs->make<TH2D>("chargeADCLog_32.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,11750,11950,60,3,9);
219  fLogChADCvsTM33 = tfs->make<TH2D>("chargeADCLog_33.vs.time",";Log(ChargeADC) vs Time 2D Plot;",7000,-500,1500,120,3,9);
220  fLogChADCvsTM34 = tfs->make<TH2D>("chargeADCLog_34.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,11950,12150,60,3,9);
221  fLogChADCvsTM35 = tfs->make<TH2D>("chargeADCLog_35.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,12050,12250,60,3,9);
222  fLogChADCvsTM36 = tfs->make<TH2D>("chargeADCLog_36.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,12150,12350,60,3,9);
223  fLogChADCvsTM37 = tfs->make<TH2D>("chargeADCLog_37.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,12250,12450,60,3,9);
224  fLogChADCvsTM38 = tfs->make<TH2D>("chargeADCLog_38.vs.time",";Log(ChargeADC) vs Time 2D Plot;",1000,11600,12600,60,3,9);
225  fLogChADCvsTM4 = tfs->make<TH2D>("chargeADCLog_4.vs.time",";Log(ChargeADC) vs Time 2D Plot;",200,12750,12950,120,3,9);
226  f1 = tfs->make<TF1>("f1","[0]+[1]*x",1500,1800);
227  f2 = tfs->make<TF1>("f2","[0]+[1]*x",6500,7000);
228  f3 = tfs->make<TF1>("f3","[0]+[1]*x",11600,12600);
229  f31 = tfs->make<TF1>("f31","[0]+[1]*x",11650,11850);
230  f32 = tfs->make<TF1>("f32","[0]+[1]*x",11750,11950);
231  f33 = tfs->make<TF1>("f33","[0]+[1]*x",11850,12050);
232  f34 = tfs->make<TF1>("f34","[0]+[1]*x",11950,12150);
233  f35 = tfs->make<TF1>("f35","[0]+[1]*x",12050,12250);
234  f36 = tfs->make<TF1>("f36","[0]+[1]*x",12150,12350);
235  f37 = tfs->make<TF1>("f37","[0]+[1]*x",12250,12450);
236  f38 = tfs->make<TF1>("f38","[0]+[1]*x",11600,12600);
237  f4 = tfs->make<TF1>("f4","[0]+[1]*x",12750,12950);
238  g31 = tfs->make<TF1>("g31","[0]/([1]*sqrt(2.0*3.14159265))*exp(-pow(x-[2],2.0)/(2.0*[1]*[1]))",200,800);
239  g32 = tfs->make<TF1>("g32","[0]/([1]*sqrt(2.0*3.14159265))*exp(-pow(x-[2],2.0)/(2.0*[1]*[1]))",200,800);
240 
241  fTrackThetaHist = tfs->make<TH1D>("trackTheta", ";particle track theta angle (deg);", 440, -20, 200);
242  fTrackPhiHist = tfs->make<TH1D>("trackPhi", ";particle track phi angle (deg);", 800, -200, 200);
243 
244  fXHist = tfs->make<TH1D>("x",";projection on x;",20,-1,1);
245  fYHist = tfs->make<TH1D>("y",";projection on y;",20,-1,1);
246  fZHist = tfs->make<TH1D>("z",";projection on z;",20,-1,1);
247 
248  fSimulationNtuple = tfs->make<TTree>("ElectronLifetime", "ElectronLifetime");
249 
250  fSimulationNtuple->Branch("hittest", "vector<double>", &hittest);
251  // fSimulationNtuple->Branch("chargeSummedADC", "vector<double>", &chargeADCtest);
252  }
253 
254  //-----------------------------------------------------------------------
255  void RecoTrack::reconfigure(fhicl::ParameterSet const& parameterSet)
256  {
257  fHitProducerLabel = parameterSet.get< std::string >("HitLabel");
258  fTrackProducerLabel = parameterSet.get< std::string >("TrackLabel");
259  }
260 
261  //-----------------------------------------------------------------------
263  {
264  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event); // to get TPC clock and frequency
265  frequency = clockData.TPCClock().Frequency();
266 
267  // get information about the hits
268  auto hitHandle = event.getHandle< std::vector<recob::Hit> >(fHitProducerLabel);
269 
270  // get track information
271  auto trackHandle = event.getHandle< std::vector<recob::Track> >(fTrackProducerLabel);
272  std::vector<art::Ptr<recob::Track> > trackVec;
273  art::fill_ptr_vector(trackVec,trackHandle);
274 
275  art::FindManyP<recob::Hit> fmtht(trackHandle, event, fTrackProducerLabel); // to associate tracks and hits
276 
277  chargeADCmin1 = 10000.0;
278  chargeADCmax1 = 0.0;
279  chargeADCmin2 = 10000.0;
280  chargeADCmax2 = 0.0;
281  chargeADCmin3 = 10000.0;
282  chargeADCmax3 = 0.0;
283  chargeADCmin4 = 10000.0;
284  chargeADCmax4 = 0.0;
285  chargeADCmin5 = 10000.0;
286  chargeADCmax5 = 0.0;
287  chargeADCmin6 = 10000.0;
288  chargeADCmax6 = 0.0;
289  chargeADCmin7 = 10000.0;
290  chargeADCmax7 = 0.0;
291 
292  for ( size_t itrack=0 ; itrack < trackVec.size() ; ++itrack ) // Starts looping over tracks
293  {
294  /******************/
295  /* Tracks' Angles */
296  /******************/
297  art::Ptr<recob::Track> ptrack(trackHandle, (int)itrack);
298  const recob::Track& track = *ptrack;
299 
300  int ntraj = track.NumberTrajectoryPoints();
301  if(ntraj > 0)
302  {
303  auto dir = track.VertexDirection();
304  trackTheta=dir.Theta()*180.0/PI;
305  fTrackThetaHist->Fill(trackTheta);
306  trackPhi=dir.Phi()*180.0/PI;
307  fTrackPhiHist->Fill(trackPhi);
308  }
309 
310  x = sin(trackTheta)*cos(trackPhi); // horizontal drift axis
311  z = sin(trackTheta)*sin(trackPhi); // horizontal perpendicular to drift axis
312  y = cos(trackTheta); // vertical
313 
314  /******************/
315  /* End tracks' angles */
316  /******************/
317 
318  /**********************/
319  /* Filling Histograms */
320  /**********************/
321  fXHist->Fill(x);
322  fYHist->Fill(y);
323  fZHist->Fill(z);
324  /**************************/
325  /* End filling Histograms */
326  /**************************/
327 
328 
329  std::vector< art::Ptr<recob::Hit> > allHits = fmtht.at(itrack);
330 
331  /**************************************************************************/
332  /* Getting hit times ******************************************************/
333  /* Getting wire numbers, ordering, and counting number of different wires */
334  /**************************************************************************/
335  timevec.clear(); // clean the vector before every time the hits loop starts
336  wiretest.clear(); // clean the vector before every time the hits loop starts
337 
338  // hittimemin = 20000.0;
339  // hittimemax = 0.0;
340 
341  for (size_t hits=0; hits < allHits.size(); ++hits) // Loop over hits in a track
342  {
343  hittime = allHits[hits]->PeakTime()/frequency;
344  timevec.push_back(hittime);
345 
346  // if (hittime > hittimemax) hittimemax = hittime;
347  // if (hititme < hittimemin) hittimemin = hittime;
348 
349 
350  wirehit = allHits[hits]->WireID().Wire;
351  wiretest.push_back(int(wirehit));
352  } // end loop over track hits
353 
354  std::sort (timevec.begin(), timevec.end());
355  double timeLength = timevec[allHits.size()-1]-timevec[0];
356 
357  std::sort (wiretest.begin(), wiretest.end());
358 
359  wirecount = 0;
360  wiretmp = 60000;
361 
362  for (size_t i = 0; i < allHits.size(); ++i) // counting number of different wires
363  {
364  if (wiretest.at(i) != wiretmp)
365  ++wirecount;
366  wiretmp = wiretest.at(i);
367  } // end counting number of different wires
368 
369  /*********************************************************************************/
370  /* End getting hit times *********************************************************/
371  /* Finish getting wire numbers, ordering, and counting number of different wires */
372  /*********************************************************************************/
373 
374  /**********************/
375  /* Filling Histograms */
376  /**********************/
377  fTimeHist->Fill(timeLength); // Track time length
378  fNofTrackWires->Fill(wirecount); // How many different wires in a track
379  fNofTrackHits->Fill( allHits.size() ); // How many hits in a track
380  fTrackLengthHist->Fill( trackVec[itrack]->Length() ); // Track length
381  /**************************/
382  /* End filling Histograms */
383  /**************************/
384 
385 
386  // if ((wirecount < 300) && (timeLength < 600)) // cuts used for prodcosmics_dune35t_milliblock_0_20150827T232050_merged.root
387  // if ((wirecount < 200) && (timeLength < 400))
388  // continue; // If condition is true, skip the rest of the loop in the current iteration
389 
390  hittest.clear();
391  timetest.clear();
392  hittest2.clear();
393  timetest2.clear();
394  hittest3.clear();
395  timetest3.clear();
396  hittest4.clear();
397  timetest4.clear();
398  hittest5.clear();
399  timetest5.clear();
400  hittest6.clear();
401  timetest6.clear();
402  hittest7.clear();
403  timetest7.clear();
404  hittest8.clear();
405  timetest8.clear();
406 
407  hittime2 = 0;
408 
409  for(size_t h=0; h < allHits.size(); ++h)
410  {
411  art::Ptr<recob::Hit> itrack_hit = allHits[h];
412 
413  hittime2 = itrack_hit->PeakTime()/frequency;
414  hittime2 = hittime2 + itrack*2000.0;
415 
416  chargeADC2 = itrack_hit->SummedADC();
417  chargeADC2Log = log(chargeADC2);
418 
419  fChADCvsTM->Fill(hittime2,chargeADC2);
420  fLogChADCvsTM->Fill(hittime2,chargeADC2Log);
421 
422 
423  if (itrack_hit->View() == geo::kZ)
424  {
425 
426  fLogChADCvsTMkZ->Fill(hittime2,chargeADC2Log);
427 
428 
429  // /* SELECTING TRACKS BY TIME 1 */
430  // //if ((hittime2 < 2000) && (hittime2 > 1000))
431  // if (itrack == 0)
432  // {
433  // //chargeADC2 = itrack_hit->SummedADC();
434  // // if (itrack_hit->View() == geo::kZ)
435  // //{
436  // std::cout << "testing0" <<std::endl;
437  // std::cout << "Track " << itrack << "; Hit charge " << h << " = " << chargeADC2 << std::endl;
438  // fTimeHist1->Fill(hittime2);
439  // fChargeADCHist1->Fill(chargeADC2);
440  // if (chargeADC2 < 500) {
441  // fLogChADCvsTM1->Fill(hittime2,chargeADC2Log);
442  // }
443  // //} // end if
444  // } // end itrack == 0 // end if hittime2
445  // /* END SELECTING TRACKS BY TIME 1 */
446 
447  // /* SELECTING TRACKS BY TIME 2 */
448  // if ((hittime2 < 8000) && (hittime2 > 6000))
449  // {
450  // fTimeHist2->Fill(hittime2);
451  // fChargeADCHist2->Fill(chargeADC2);
452 
453  // // std::cout << "Track " << itrack << "; Hit charge " << h << " = " << chargeADC2 << std::endl;
454  // // hittest2.push_back(chargeADC2);
455 
456  // //if ((chargeADC2Log < lcharge_arb*1.5) && (chargeADC2Log > lcharge_arb*0.5)) {
457  // if ((chargeADC2 < 1500) && (chargeADC2 > 500)) {
458  // fLogChADCvsTM2->Fill(hittime2,chargeADC2Log);
459  // }
460 
461  // } // end if hittime2
462  // /* END SELECTING TRACKS BY TIME 2 */
463 
464  // /* SELECTING TRACKS BY TIME 3 */
465  // /*>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<*/
466  // /*>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<*/
467  // /*>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<*/
468 
469 
470 
471  // if ((hittime2 < 11800) && (hittime2 > 11700))
472  // {
473  // // fChargeADCHist31->Fill(chargeADC2);
474  // // fLogChADCvsTM31->Fill(hittime2,chargeADC2Log);
475  // hittest.push_back(chargeADC2);
476  // timetest.push_back(hittime2);
477  // }
478 
479  // if ((hittime2 < 11900) && (hittime2 > 11800))
480  // {
481  // // fChargeADCHist32->Fill(chargeADC2);
482  // // fLogChADCvsTM32->Fill(hittime2,chargeADC2Log);
483  // hittest2.push_back(chargeADC2);
484  // timetest2.push_back(hittime2);
485  // }
486 
487  if (hittime2 < 2000)
488  {
489  fChargeADCHist33->Fill(chargeADC2);
490  fLogChADCvsTM33->Fill(hittime2,chargeADC2Log);
491 
492  if (chargeADC2 > chargeADCmax3) chargeADCmax3 = chargeADC2;
493  if (chargeADC2 < chargeADCmin3) chargeADCmin3 = chargeADC2;
494 
495  hittest3.push_back(chargeADC2);
496  timetest3.push_back(hittime2);
497  }
498 
499  // if ((hittime2 < 12100) && (hittime2 > 12000))
500  // {
501  // // fChargeADCHist34->Fill(chargeADC2);
502  // // fLogChADCvsTM34->Fill(hittime2,chargeADC2Log);
503  // if (chargeADC2 > chargeADCmax4) chargeADCmax4 = chargeADC2;
504  // if (chargeADC2 < chargeADCmin4) chargeADCmin4 = chargeADC2;
505 
506  // hittest4.push_back(chargeADC2);
507  // timetest4.push_back(hittime2);
508  // }
509 
510  // if ((hittime2 < 12200) && (hittime2 > 12100))
511  // {
512  // // fChargeADCHist35->Fill(chargeADC2);
513  // // fLogChADCvsTM35->Fill(hittime2,chargeADC2Log);
514  // if (chargeADC2 > chargeADCmax5) chargeADCmax5 = chargeADC2;
515  // if (chargeADC2 < chargeADCmin5) chargeADCmin5 = chargeADC2;
516 
517  // hittest5.push_back(chargeADC2);
518  // timetest5.push_back(hittime2);
519  // }
520 
521  // if ((hittime2 < 12300) && (hittime2 > 12200))
522  // {
523  // // fChargeADCHist36->Fill(chargeADC2);
524  // // fLogChADCvsTM36->Fill(hittime2,chargeADC2Log);
525  // if (chargeADC2 > chargeADCmax6) chargeADCmax6 = chargeADC2;
526  // if (chargeADC2 < chargeADCmin6) chargeADCmin6 = chargeADC2;
527 
528  // hittest6.push_back(chargeADC2);
529  // timetest6.push_back(hittime2);
530  // }
531 
532  // if ((hittime2 < 12400) && (hittime2 > 12300))
533  // {
534  // // fChargeADCHist37->Fill(chargeADC2);
535  // // fLogChADCvsTM37->Fill(hittime2,chargeADC2Log);
536  // if (chargeADC2 > chargeADCmax7) chargeADCmax7 = chargeADC2;
537  // if (chargeADC2 < chargeADCmin7) chargeADCmin7 = chargeADC2;
538 
539  // hittest7.push_back(chargeADC2);
540  // timetest7.push_back(hittime2);
541  // }
542 
543  // if ((hittime2 < 12600) && (hittime2 > 11600))
544  // {
545  // std::cout << "testing1" <<std::endl;
546  // std::cout << "Track " << itrack << "; Hit charge " << h << " = " << chargeADC2 << std::endl;
547  // //chargeADC2 = itrack_hit->SummedADC();
548  // fTimeHist3->Fill(hittime2);
549  // fChargeADCHist3->Fill(chargeADC2);
550  // //if (chargeADC2 < 700) {
551  // fLogChADCvsTM3->Fill(hittime2,chargeADC2Log);
552  // //}
553 
554  // } // end if hittime2
555 
556 
557  // std::cout << "testing11" <<std::endl;
558 
559 
560 
561 
562  // /*>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<*/
563  // /*>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<*/
564  // /*>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<*/
565  // /* END SELECTING TRACKS BY TIME 3 */
566 
567  // /* SELECTING TRACKS BY TIME 4 */
568  // if ((hittime2 < 13000) && (hittime2 > 12700))
569  // {
570  // std::cout << "testing2" <<std::endl;
571  // std::cout << "Track " << itrack << "; Hit charge " << h << " = " << chargeADC2 << std::endl;
572  // //chargeADC2 = itrack_hit->SummedADC();
573  // //if (itrack_hit->View() == geo::kZ)
574  // //{
575  // fTimeHist4->Fill(hittime2);
576  // fChargeADCHist4->Fill(chargeADC2);
577  // if (chargeADC2 < 500) {
578  // fLogChADCvsTM4->Fill(hittime2,chargeADC2Log);
579  // }
580  // //} // end if
581  // } // end if hittime2
582  // /* END SELECTING TRACKS BY TIME 4 */
583  } // end if geo::kZ
584 
585  } // end h for (all the hits for a track (itrack))
586 
587 
588  max3 = chargeADCmax3;
589  min3 = chargeADCmin3;
590 
591  std::cout<<" max3 = "<< max3 << "; min3 = " << min3 << std::endl;
592 
593 
594  for(size_t j=0; j < hittest3.size(); ++j)
595  {
596  if ((hittest3[j] > ((max3-min3)*0.15+min3)) && (hittest3[j] < (max3-(max3-min3)*0.15)))
597  {
598 
599  fChargeADCHist33->Fill(hittest3[j]);
600  fLogChADCvsTM33->Fill(timetest3[j],log(hittest3[j]));
601 
602  hittest8.push_back(hittest3[j]);
603  timetest8.push_back(timetest3[j]);
604 
605  }
606  }
607 
608 
609 
610  } // end itrack for
611 
612  myfile.open ("/dune/app/users/camj/dunelatest/work/lifetime.txt");
613 
614  // f1->SetParameters(6.,-0.000333);
615  // f1->SetLineColor(kRed);
616  // fLogChADCvsTM1->Fit(f1);
617  // fLogChADCvsTM1->Draw();
618  // f1->Draw("same");
619  // //double p0 = f1->GetParameter(0);
620  // double p01 = f1->GetParameter(0);
621  // double Err01 = f1->GetParError(0);
622  // double p1 = f1->GetParameter(1);
623  // double Err1 = f1->GetParError(1);
624 
625  // // std::cout << "p1+/-Err1 = (" << -0.001/p1 << " +/- " << (1./p1)*(1./p1)*Err1 <<") ms"<< std::endl;
626  // myfile << "p1 = (" << -0.001/p1 << " +/- " << 1.e-6*(1./p1)*(1./p1)*Err1 <<") ms"<< std::endl;
627  // myfile << "Fit = " << p1 << " +/- " << Err1 << "; " << p01 << " +/- " << Err01 << std::endl;
628 
629  // double maxbin = fChargeADCHist31->GetMaximumBin();
630  // double binamp = fChargeADCHist31->GetBinContent(maxbin);
631  // double bincent = fChargeADCHist31->GetBinCenter(maxbin);
632  // g31->SetParameters(binamp,50.0,bincent);
633  // g31->SetLineColor(kRed);
634  // fChargeADCHist31->Fit(g31);
635  // fChargeADCHist31->Draw();
636  // g31->Draw("same");
637  // double pamp1 = g31->GetParameter(0);
638  // double psig1 = g31->GetParameter(1);
639  // double pavr1 = g31->GetParameter(2);
640  // myfile << "Amplitude = " << pamp1 << "; Sigma = " << psig1 << "; Average = " << pavr1 << std::endl;
641  // myfile << "Bin of the max: " << maxbin << "; Amplitude of the max: " << binamp << "; Bin center: " << bincent << std::endl;
642 
643  // g32->SetParameters(4.0,100.0,420.0);
644  // g32->SetLineColor(kRed);
645  // fChargeADCHist32->Fit(g32);
646  // fChargeADCHist32->Draw();
647  // g32->Draw("same");
648  // double pamp2 = g32->GetParameter(0);
649  // double psig2 = g32->GetParameter(1);
650  // double pavr2 = g32->GetParameter(2);
651  // myfile << "Amplitude = " << pamp2 << "; Sigma = " << psig2 << "; Average = " << pavr2 << std::endl;
652 
653  // f2->SetParameters(6.,-0.000333);
654  // f2->SetLineColor(kRed);
655  // fLogChADCvsTM2->Fit(f2);
656  // fLogChADCvsTM2->Draw();
657  // f2->Draw("same");
658  // double p2 = f2->GetParameter(1);
659  // double Err2 = f2->GetParError(1);
660  // double p02 = f2->GetParameter(0);
661  // double Err02 = f2->GetParError(0);
662 
663  // myfile << "p2 = (" << -0.001/p2 << " +/- " << 1.e-6*(1./p2)*(1./p2)*Err2 <<") ms"<< std::endl;
664  // myfile << "Fit = " << p2 << " +/- " << Err2 << "; " << p02 << " +/- " << Err02 << std::endl;
665 
666  // fLogChADCvsTM3->SetMarkerStyle(kCircle);
667  // fLogChADCvsTM3->SetMarkerSize(0.5);
668  // f3->SetParameters(6.,-0.000333);
669  // fLogChADCvsTM3->Fit(f3);
670  // fLogChADCvsTM3->Draw();
671  // f3->SetLineColor(kRed);
672  // f3->SetTitle("Electron Lifetime");
673  // f3->Draw("same");
674  // double p3 = f3->GetParameter(1);
675  // double Err3 = f3->GetParError(1);
676  // double p03 = f3->GetParameter(0);
677  // double Err03 = f3->GetParError(0);
678 
679  // myfile << "p3 = (" << -0.001/p3 << " +/- " << 1.e-6*(1./p3)*(1./p3)*Err3 <<") ms"<< std::endl;
680  // myfile << "Fit = " << p3 << " +/- " << Err3 << "; " << p03 << " +/- " << Err03 << std::endl;
681 
682  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
683  // fLogChADCvsTM31->SetMarkerStyle(kCircle);
684  // fLogChADCvsTM31->SetMarkerSize(0.5);
685  // f31->SetParameters(6.,-0.000333);
686  // fLogChADCvsTM31->Fit(f31);
687  // fLogChADCvsTM31->Draw();
688  // f31->SetLineColor(kRed);
689  // f31->SetTitle("Electron Lifetime");
690  // f31->Draw("same");
691  // double p31 = f31->GetParameter(1);
692  // double Err31 = f31->GetParError(1);
693  // double p031 = f31->GetParameter(0);
694  // double Err031 = f31->GetParError(0);
695 
696  // myfile << "p31 = (" << -0.001/p31 << " +/- " << 1.e-6*(1./p31)*(1./p31)*Err31 <<") ms"<< std::endl;
697  // myfile << "Fit = " << p31 << " +/- " << Err31 << "; " << p031 << " +/- " << Err031 << std::endl;
698  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
699 
700  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
701  // fLogChADCvsTM32->SetMarkerStyle(kCircle);
702  // fLogChADCvsTM32->SetMarkerSize(0.5);
703  // f32->SetParameters(6.,-0.000333);
704  // fLogChADCvsTM32->Fit(f32);
705  // fLogChADCvsTM32->Draw();
706  // f32->SetLineColor(kRed);
707  // f32->SetTitle("Electron Lifetime");
708  // f32->Draw("same");
709  // double p32 = f32->GetParameter(1);
710  // double Err32 = f32->GetParError(1);
711  // double p032 = f32->GetParameter(0);
712  // double Err032 = f32->GetParError(0);
713 
714  // myfile << "p32 = (" << -0.001/p32 << " +/- " << 1.e-6*(1./p32)*(1./p32)*Err32 <<") ms"<< std::endl;
715  // myfile << "Fit = " << p32 << " +/- " << Err32 << "; " << p032 << " +/- " << Err032 << std::endl;
716  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
717 
718  /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
719  fLogChADCvsTM33->SetMarkerStyle(kCircle);
720  fLogChADCvsTM33->SetMarkerSize(0.5);
721  f33->SetParameters(6.,-0.000333);
722  fLogChADCvsTM33->Fit(f33);
723  fLogChADCvsTM33->Draw();
724  f33->SetLineColor(kRed);
725  f33->SetTitle("Electron Lifetime");
726  f33->Draw("same");
727  double p33 = f33->GetParameter(1);
728  double Err33 = f33->GetParError(1);
729  double p033 = f33->GetParameter(0);
730  double Err033 = f33->GetParError(0);
731 
732  myfile << "p33 = (" << -0.001/p33 << " +/- " << 1.e-6*(1./p33)*(1./p33)*Err33 <<") ms"<< std::endl;
733  myfile << "Fit = " << p33 << " +/- " << Err33 << "; " << p033 << " +/- " << Err033 << std::endl;
734  /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
735 
736  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
737  // fLogChADCvsTM34->SetMarkerStyle(kCircle);
738  // fLogChADCvsTM34->SetMarkerSize(0.5);
739  // f34->SetParameters(6.,-0.000333);
740  // fLogChADCvsTM34->Fit(f34);
741  // fLogChADCvsTM34->Draw();
742  // f34->SetLineColor(kRed);
743  // f34->SetTitle("Electron Lifetime");
744  // f34->Draw("same");
745  // double p34 = f34->GetParameter(1);
746  // double Err34 = f34->GetParError(1);
747  // double p034 = f34->GetParameter(0);
748  // double Err034 = f34->GetParError(0);
749 
750  // myfile << "p34 = (" << -0.001/p34 << " +/- " << 1.e-6*(1./p34)*(1./p34)*Err34 <<") ms"<< std::endl;
751  // myfile << "Fit = " << p34 << " +/- " << Err34 << "; " << p034 << " +/- " << Err034 << std::endl;
752  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
753 
754  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
755  // fLogChADCvsTM35->SetMarkerStyle(kCircle);
756  // fLogChADCvsTM35->SetMarkerSize(0.5);
757  // f35->SetParameters(6.,-0.000333);
758  // fLogChADCvsTM35->Fit(f35);
759  // fLogChADCvsTM35->Draw();
760  // f35->SetLineColor(kRed);
761  // f35->SetTitle("Electron Lifetime");
762  // f35->Draw("same");
763  // double p35 = f35->GetParameter(1);
764  // double Err35 = f35->GetParError(1);
765  // double p035 = f35->GetParameter(0);
766  // double Err035 = f35->GetParError(0);
767 
768  // myfile << "p35 = (" << -0.001/p35 << " +/- " << 1.e-6*(1./p35)*(1./p35)*Err35 <<") ms"<< std::endl;
769  // myfile << "Fit = " << p35 << " +/- " << Err35 << "; " << p035 << " +/- " << Err035 << std::endl;
770  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
771 
772  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
773  // fLogChADCvsTM36->SetMarkerStyle(kCircle);
774  // fLogChADCvsTM36->SetMarkerSize(0.5);
775  // f36->SetParameters(6.,-0.000333);
776  // fLogChADCvsTM36->Fit(f36);
777  // fLogChADCvsTM36->Draw();
778  // f36->SetLineColor(kRed);
779  // f36->SetTitle("Electron Lifetime");
780  // f36->Draw("same");
781  // double p36 = f36->GetParameter(1);
782  // double Err36 = f36->GetParError(1);
783  // double p036 = f36->GetParameter(0);
784  // double Err036 = f36->GetParError(0);
785 
786  // myfile << "p36 = (" << -0.001/p36 << " +/- " << 1.e-6*(1./p36)*(1./p36)*Err36 <<") ms"<< std::endl;
787  // myfile << "Fit = " << p36 << " +/- " << Err36 << "; " << p036 << " +/- " << Err036 << std::endl;
788  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
789 
790  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
791  // fLogChADCvsTM37->SetMarkerStyle(kCircle);
792  // fLogChADCvsTM37->SetMarkerSize(0.5);
793  // f37->SetParameters(6.,-0.000333);
794  // fLogChADCvsTM37->Fit(f37);
795  // fLogChADCvsTM37->Draw();
796  // f37->SetLineColor(kRed);
797  // f37->SetTitle("Electron Lifetime");
798  // f37->Draw("same");
799  // double p37 = f37->GetParameter(1);
800  // double Err37 = f37->GetParError(1);
801  // double p037 = f37->GetParameter(0);
802  // double Err037 = f37->GetParError(0);
803 
804  // myfile << "p37 = (" << -0.001/p37 << " +/- " << 1.e-6*(1./p37)*(1./p37)*Err37 <<") ms"<< std::endl;
805  // myfile << "Fit = " << p37 << " +/- " << Err37 << "; " << p037 << " +/- " << Err037 << std::endl;
806  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
807 
808  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
809  // fLogChADCvsTM38->SetMarkerStyle(kCircle);
810  // fLogChADCvsTM38->SetMarkerSize(0.5);
811  // f38->SetParameters(6.,-0.000333);
812  // fLogChADCvsTM38->Fit(f38);
813  // fLogChADCvsTM38->Draw();
814  // f38->SetLineColor(kRed);
815  // f38->SetTitle("Electron Lifetime");
816  // f38->Draw("same");
817  // double p38 = f38->GetParameter(1);
818  // double Err38 = f38->GetParError(1);
819  // double p038 = f38->GetParameter(0);
820  // double Err038 = f38->GetParError(0);
821 
822  // myfile << "p38 = (" << -0.001/p38 << " +/- " << 1.e-6*(1./p38)*(1./p38)*Err38 <<") ms"<< std::endl;
823  // myfile << "Fit = " << p38 << " +/- " << Err38 << "; " << p038 << " +/- " << Err038 << std::endl;
824  // /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
825 
826  // f4->SetParameters(6.,-0.000333);
827  // f4->SetLineColor(kRed);
828  // fLogChADCvsTM4->Fit(f4);
829  // fLogChADCvsTM4->Draw();
830  // f4->Draw("same");
831  // double p4 = f4->GetParameter(1);
832  // double Err4 = f4->GetParError(1);
833  // double p04 = f4->GetParameter(0);
834  // double Err04 = f4->GetParError(0);
835 
836  // myfile << "p4 = (" << -0.001/p4 << " +/- " << 1.e-6*(1./p4)*(1./p4)*Err4 <<") ms"<< std::endl;
837  // myfile << "Fit = " << p4 << " +/- " << Err4 << "; " << p04 << " +/- " << Err04 << std::endl;
838 
839  myfile.close();
840 
841  // TCanvas *c1 = new TCanvas();
842  // f22->Draw("Surf1");
843  // fLogChADCvsTM3->Draw("P0 Same");
844 
845 
846  // std::cout << lengthb << std::endl;
847 
848  // For every Hit:
849  // for ( auto const& hit : (*hitHandle) )
850  // {
851  // frequency = clockData.TPCClock().Frequency();
852  // hittime = hit.PeakTime()/frequency;
853 
854  // hittest.push_back(hittime); // vector with hit times
855 
856  // fTimeHist->Fill(hittime); // filling the historgram with hit times
857 
858 
859  // fChargeADCHist->Fill(chargeADC); // filling the histogram of charge frequency
860 
861  // if ((chargeADC > 10) && (chargeADC < 500))
862  // {
863  // fChADCvsTM->Fill(hittime,chargeADC);
864  // fLogChADCvsTM->Fill(hittime,chargeADCLog);
865  // } // end if for charge integral
866  // } // for each Hit
867 
868  // fSimulationNtuple->Fill();
869 
870  } // RecoTrack::analyze()
871 
873 
874 } // namespace RecoTrack
875 
876 #endif // RecoTrack_Module
877 
878 // chargeInteg = hit.Integral(); // charge per hit
879 // chargeIntegLog = log(chargeInteg); // calculating log of charge
880 // chargeInttest.push_back(chargeInteg); // vector with integrated charge for each hit
881 
882 // fChargeIntegHist->Fill(chargeInteg); // filling the histogram of charge frequency
883 
884 // fCHvsTM->Fill(hittime,chargeInteg);
885 // fLogCHvsTM->Fill(hittime,chargeIntegLog);
886 
887 // trackTheta = trackVec[itrack]->Theta()*180.0/PI;
888 // fTrackThetaHist->Fill(trackTheta);
889 // trackPhi = trackVec[itrack]->Phi()*180.0/PI;
890 // fTrackPhiHist->Fill(trackPhi);
891 
892  // chargeADC = itrack_hit->Integral(); // Charge per hit. Compare with ->Integral()
893  // chargeADCLog = log(chargeADC); // calculating log of charge
894  // chargeADCtest.push_back(chargeADC); // vector with summed ADC charge for each hit
895  // fChargeADCHist->Fill(chargeADCtest[h]); // filling the histogram of charge frequency
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:69
float Length(const PFPStruct &pfp)
Definition: PFPUtils.cxx:3303
std::vector< double > timetest5
std::vector< double > timetest4
#define PI
std::string string
Definition: nybbler.cc:12
std::vector< double > timetest2
TH1D * fTimeHist4
Hit time of all particles.
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:102
Vector_t VertexDirection() const
Definition: Track.h:132
HadronElasticPhysicsFactory f4
TH1D * fTimeHist1
Hit time of all particles.
TH1D * fTimeHist2
Hit time of all particles.
Planes which measure Z direction.
Definition: geo_types.h:132
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
std::string fHitProducerLabel
The name of the producer that created hits.
string dir
std::vector< double > timetest6
TH1D * fTimeHist
Hit time of all particles.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::vector< int > wiretest
void beginJob()
Definition: Breakpoints.cc:14
virtual void reconfigure(fhicl::ParameterSet const &pset)
T get(std::string const &key) const
Definition: ParameterSet.h:271
TH1D * fTimeHist3
Hit time of all particles.
std::vector< double > timetest8
std::string fTrackProducerLabel
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
Declaration of signal hit object.
std::vector< double > timetest3
std::vector< double > timetest7
Provides recob::Track data product.
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
list x
Definition: train.py:276
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
std::vector< double > timetest
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
QTextStream & endl(QTextStream &s)
Event finding and building.