14 #ifndef RecoTrack_Module 15 #define RecoTrack_Module 29 #include "art_root_io/TFileService.h" 32 #include "canvas/Persistency/Common/FindManyP.h" 181 : EDAnalyzer(parameterSet)
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);
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);
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);
248 fSimulationNtuple = tfs->make<TTree>(
"ElectronLifetime",
"ElectronLifetime");
250 fSimulationNtuple->Branch(
"hittest",
"vector<double>", &hittest);
258 fTrackProducerLabel = parameterSet.
get<
std::string >(
"TrackLabel");
265 frequency = clockData.TPCClock().Frequency();
268 auto hitHandle =
event.getHandle< std::vector<recob::Hit> >(fHitProducerLabel);
271 auto trackHandle =
event.getHandle< std::vector<recob::Track> >(fTrackProducerLabel);
272 std::vector<art::Ptr<recob::Track> > trackVec;
275 art::FindManyP<recob::Hit> fmtht(trackHandle, event, fTrackProducerLabel);
277 chargeADCmin1 = 10000.0;
279 chargeADCmin2 = 10000.0;
281 chargeADCmin3 = 10000.0;
283 chargeADCmin4 = 10000.0;
285 chargeADCmin5 = 10000.0;
287 chargeADCmin6 = 10000.0;
289 chargeADCmin7 = 10000.0;
292 for (
size_t itrack=0 ; itrack < trackVec.size() ; ++itrack )
304 trackTheta=
dir.Theta()*180.0/
PI;
305 fTrackThetaHist->Fill(trackTheta);
306 trackPhi=
dir.Phi()*180.0/
PI;
307 fTrackPhiHist->Fill(trackPhi);
310 x = sin(trackTheta)*cos(trackPhi);
311 z = sin(trackTheta)*sin(trackPhi);
329 std::vector< art::Ptr<recob::Hit> > allHits = fmtht.at(itrack);
341 for (
size_t hits=0; hits < allHits.size(); ++hits)
343 hittime = allHits[hits]->PeakTime()/frequency;
344 timevec.push_back(hittime);
350 wirehit = allHits[hits]->WireID().Wire;
351 wiretest.push_back(
int(wirehit));
354 std::sort (timevec.begin(), timevec.end());
355 double timeLength = timevec[allHits.size()-1]-timevec[0];
357 std::sort (wiretest.begin(), wiretest.end());
362 for (
size_t i = 0; i < allHits.size(); ++i)
364 if (wiretest.at(i) != wiretmp)
366 wiretmp = wiretest.at(i);
377 fTimeHist->Fill(timeLength);
378 fNofTrackWires->Fill(wirecount);
379 fNofTrackHits->Fill( allHits.size() );
380 fTrackLengthHist->Fill( trackVec[itrack]->
Length() );
409 for(
size_t h=0;
h < allHits.size(); ++
h)
413 hittime2 = itrack_hit->
PeakTime()/frequency;
414 hittime2 = hittime2 + itrack*2000.0;
417 chargeADC2Log = log(chargeADC2);
419 fChADCvsTM->Fill(hittime2,chargeADC2);
420 fLogChADCvsTM->Fill(hittime2,chargeADC2Log);
426 fLogChADCvsTMkZ->Fill(hittime2,chargeADC2Log);
489 fChargeADCHist33->Fill(chargeADC2);
490 fLogChADCvsTM33->Fill(hittime2,chargeADC2Log);
492 if (chargeADC2 > chargeADCmax3) chargeADCmax3 = chargeADC2;
493 if (chargeADC2 < chargeADCmin3) chargeADCmin3 = chargeADC2;
495 hittest3.push_back(chargeADC2);
496 timetest3.push_back(hittime2);
588 max3 = chargeADCmax3;
589 min3 = chargeADCmin3;
591 std::cout<<
" max3 = "<< max3 <<
"; min3 = " << min3 <<
std::endl;
594 for(
size_t j=0; j < hittest3.size(); ++j)
596 if ((hittest3[j] > ((max3-min3)*0.15+min3)) && (hittest3[j] < (max3-(max3-min3)*0.15)))
599 fChargeADCHist33->Fill(hittest3[j]);
600 fLogChADCvsTM33->Fill(timetest3[j],log(hittest3[j]));
602 hittest8.push_back(hittest3[j]);
603 timetest8.push_back(timetest3[j]);
612 myfile.open (
"/dune/app/users/camj/dunelatest/work/lifetime.txt");
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");
727 double p33 = f33->GetParameter(1);
728 double Err33 = f33->GetParError(1);
729 double p033 = f33->GetParameter(0);
730 double Err033 = f33->GetParError(0);
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;
876 #endif // RecoTrack_Module def analyze(root, level, gtrees, gbranches, doprint)
float Length(const PFPStruct &pfp)
std::vector< double > timetest5
std::vector< double > timetest4
TTree * fSimulationNtuple
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.
Vector_t VertexDirection() const
HadronElasticPhysicsFactory f4
TH1D * fTimeHist1
Hit time of all particles.
TH1D * fTimeHist2
Hit time of all particles.
Planes which measure Z direction.
geo::View_t View() const
View for the plane of the hit.
std::string fHitProducerLabel
The name of the producer that created hits.
std::vector< double > timetest6
TH1D * fTimeHist
Hit time of all particles.
#define DEFINE_ART_MODULE(klass)
std::vector< int > wiretest
virtual void reconfigure(fhicl::ParameterSet const &pset)
T get(std::string const &key) const
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.
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)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
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:
QTextStream & endl(QTextStream &s)
Event finding and building.