22 #include "art/Framework/Core/ModuleMacros.h"
23 #include "canvas/Persistency/Common/FindManyP.h"
24 #include "art/Framework/Principal/Event.h"
25 #include "fhiclcpp/ParameterSet.h"
26 #include "art/Framework/Principal/Handle.h"
27 #include "canvas/Persistency/Common/Ptr.h"
28 #include "canvas/Persistency/Common/PtrVector.h"
31 #include "art_root_io/TFileService.h"
37 #include "nusimdata/SimulationBase/MCTruth.h"
38 #include "nug4/ParticleNavigation/ParticleList.h"
39 #include "nug4/ParticleNavigation/EmEveIdCalculator.h"
57 #include "art/Framework/Core/EDProducer.h"
61 #include "TProfile2D.h"
63 #include <TGraphErrors.h>
64 #include <TGraphAsymmErrors.h>
90 int Nothere(std::vector<int>*
a,
int b);
91 int Notheref(std::vector<float>* a,
float b);
177 , fDigitModuleLabel (pset.
get<
std::
vector<art::InputTag> > (
"RawModuleLabel"))
178 , fValoretaufcl (pset.
get< float > (
"ValoreTauFCL"))
179 , fmaxfcl (pset.
get< float > (
"FracMaxFCL",0.9))
180 , fminfcl (pset.
get< float > (
"FraxMinFCL",0.05))
181 , fdisfcl (pset.
get< float > (
"DisFCL",3.0))
182 , fcryofcl (pset.
get< int > (
"CryostatFCL"))
183 , fquantevoltefcl (pset.
get< int > (
"QuanteFCL",5))
184 , fplanefcl (pset.
get< int > (
"PlaneFCL"))
185 , fthresholdfcl (pset.
get< int > (
"ThresholdFCL"))
186 , fdumphitsfcl (pset.
get< int > (
"DumpHitFCL",0))
187 , fgruppifcl (pset.
get< int > (
"GruppiFCL",8))
188 , fdwclusfcl (pset.
get< int > (
"DeltaWClusFCL",3))
189 , fdsclusfcl (pset.
get< int > (
"DeltaSClusFCL",100))
190 , fPersistPurityInfo (pset.
get<
bool > (
"PersistPurityInfo",
false))
191 , fFillAnaTuple (pset.
get<
bool > (
"FillAnaTuple",
false))
196 produces< std::vector<anab::TPCPurityInfo> >(
"",art::Persistable::Yes);
198 produces< std::vector<anab::TPCPurityInfo> >(
"",art::Persistable::No);
212 art::ServiceHandle<art::TFileService>
tfs;
214 purityvalues = tfs->make<TH1F>(
"purityvalues",
"purityvalues",20000,-10,10);
215 h_basediff = tfs->make<TH1F>(
"h_basediff",
"h_basediff",10000,-20,20);
216 h_basebase = tfs->make<TH1F>(
"h_basebase",
"h_basebase",10000,-20,20);
217 h_base1 = tfs->make<TH1F>(
"h_base1",
"h_base1",10000,-20,20);
218 h_base2 = tfs->make<TH1F>(
"h_base2",
"h_base2",10000,-20,20);
220 h_rms = tfs->make<TH1F>(
"h_rms",
"h_rms",2000,0,20);
223 h_errors = tfs->make<TH1F>(
"h_errors",
"",1000,0,1000);
226 h_hittime = tfs->make<TH1F>(
"h_hittime",
"",2500,-0.5,2499.5);
227 h_hittime_2 = tfs->make<TH1F>(
"h_hittime_2",
"",2500,-0.5,2499.5);
228 h_hittime_3 = tfs->make<TH1F>(
"h_hittime_3",
"",2500,-0.5,2499.5);
230 purityvalues2 = tfs->make<TH1F>(
"purityvalues2",
"purityvalues2",20000,-10,10);
231 puritytpc0 = tfs->make<TH1F>(
"puritytpc0",
"puritytpc0",20000,-10,10);
232 puritytpc1 = tfs->make<TH1F>(
"puritytpc1",
"puritytpc1",20000,-10,10);
233 puritytpc2 = tfs->make<TH1F>(
"puritytpc2",
"puritytpc2",20000,-10,10);
234 puritytpc3 = tfs->make<TH1F>(
"puritytpc3",
"puritytpc3",20000,-10,10);
235 h_hit_height = tfs->make<TH1F>(
"h_hit_height",
"h_hit_height",2000,0.5,2000.5);
236 h_hit_area = tfs->make<TH1F>(
"h_hit_area",
"h_hit_area",10000,0,10000);
237 h_hit_height_area=tfs->make<TH2D>(
"h_hit_height_area",
"", 300,0.5,300.5,2000,0.,2000.);
239 h_ratio = tfs->make<TH1F>(
"h_ratio",
"h_ratio",20000,0,5);
240 h_ratio_after = tfs->make<TH1F>(
"h_ratio_after",
"h_ratio_after",20000,0,5);
242 h_ratio_after_3 = tfs->make<TH2D>(
"h_ratio_after_3",
"",1300,0,2600,2000,0,2);
243 h_ratio_3 = tfs->make<TH2D>(
"h_ratio_3",
"",1300,0,2600,2000,0,2);
247 fpurTree = tfs->make<TTree>(
"puritytree",
"tree for the purity studies");
248 fpurTree->Branch(
"run",&
run_tree,
"run/I");
249 fpurTree->Branch(
"subrun",&
subrun_tree,
"subrun/I");
250 fpurTree->Branch(
"event",&
event_tree,
"event/I");
251 fpurTree->Branch(
"tpc",&
tpc_tree,
"tpc/I");
252 fpurTree->Branch(
"qhits",&
qhits_tree,
"qhits/I");
253 fpurTree->Branch(
"deltawire",&
dwire_tree,
"deltawire/F");
254 fpurTree->Branch(
"deltatime",&
dtime_tree,
"deltatime/F");
255 fpurTree->Branch(
"errarea",&
earea_tree,
"errarea/F");
256 fpurTree->Branch(
"meanarea",&
marea_tree,
"meanarea/F");
257 fpurTree->Branch(
"slope",&
slope_tree,
"slope/F");
258 fpurTree->Branch(
"errorslope",&
errslope_tree,
"errorslope/F");
259 fpurTree->Branch(
"chisquare",&
chi_tree,
"chisquare/F");
263 purityTuple = tfs->make<TNtuple>(
"purityTuple",
"Purity Tuple",
"run:ev:tpc:att");
269 std::ofstream goodpurofinal(
"valore_indicativo.out",std::ios::app);
277 for(
int i=0; i<(int)a->size();i++)
290 for(
int i=0; i<(int)a->size();i++)
306 int punto_taglio=a->size()*(b)+0.5;
308 if(punto_taglio==0)punto_taglio=1;
309 std::vector<float>* usedhere=
new std::vector<float>;
310 for(
int j=0;j<(int)a->size();j++)usedhere->push_back((*a)[j]);
313 std::sort(usedhere->begin(),usedhere->end(), [](
float &c,
float &d){
return c<d; });
315 taglio=(*usedhere)[punto_taglio-1];
323 //if(punto_taglio==0)punto_taglio=1;
324 std::vector<float>* usedhere=new std::vector<float>;
325 for(int jj=0;jj<punto_taglio+1;jj++)
327 //cout << jj << endl;
329 for(int j=0;j<(int)a->size();j++)
331 if((*a)[j]>maximum && Notheref(usedhere,(*a)[j])==3)
336 //cout << maximum << endl;
337 usedhere->push_back(maximum);
339 //cout << (*usedhere)[punto_taglio] << endl;
340 return (*usedhere)[punto_taglio-1];
349 art::ServiceHandle<geo::Geometry> geom;
350 unsigned int fDataSize;
351 std::vector<short> rawadc;
361 art::Handle< std::vector<raw::RawDigit> > digitVecHandle;
362 std::vector<const raw::RawDigit*> rawDigitVec;
365 std::unique_ptr< std::vector<anab::TPCPurityInfo> > outputPtrVector(
new std::vector<anab::TPCPurityInfo>() );
368 purity_info.
Run = evt.run();
369 purity_info.
Subrun = evt.subRun();
370 purity_info.
Event = evt.event();
371 std::ofstream purh(
"dump_purity_hits.out",std::ios::app);
375 evt.getByLabel(digitlabel, digitVecHandle);
376 std::vector<const raw::RawDigit*> rawDigitVec;
378 if (digitVecHandle.isValid())
383 for(
size_t idx = 0; idx < digitVecHandle->size(); idx++)
384 rawDigitVec.push_back(&digitVecHandle->at(idx));
386 std::sort(rawDigitVec.begin(),
392 std::vector<int> *www0=
new std::vector<int>;
393 std::vector<float> *sss0=
new std::vector<float>;
394 std::vector<float> *hhh0=
new std::vector<float>;
395 std::vector<float> *ehh0=
new std::vector<float>;
396 std::vector<int> *www2=
new std::vector<int>;
397 std::vector<float> *sss2=
new std::vector<float>;
398 std::vector<float> *hhh2=
new std::vector<float>;
399 std::vector<float> *ehh2=
new std::vector<float>;
400 std::vector<int> *ccc0=
new std::vector<int>;
401 std::vector<int> *ccc2=
new std::vector<int>;
402 std::vector<float> *aaa0=
new std::vector<float>;
403 std::vector<float> *aaa2=
new std::vector<float>;
406 short int used[4096];
407 for(
const auto& rawDigit : rawDigitVec)
411 std::vector<geo::WireID> wids = geom->ChannelToWire(channel);
420 size_t iWire=wid.
Wire;
422 fDataSize = rawDigit->Samples();
423 rawadc.resize(fDataSize);
425 for(
int ijk=0;ijk<4096;ijk++)used[ijk]=0;
427 int pedestal = (int)rawDigit->GetPedestal();
428 float pedestal2 = rawDigit->GetPedestal();
429 float sigma_pedestal = rawDigit->GetSigma();
430 raw::Uncompress(rawDigit->ADCs(), rawadc, pedestal, rawDigit->Compression());
433 float quale_sample_massimo;
438 quale_sample_massimo=-1;
440 TH1F *h111 =
new TH1F(
"h111",
"delta aree",20000,0,0);
441 for (
unsigned int ijk=0; ijk<(fDataSize); ijk++)
443 if ((rawDigit->ADC(ijk)-pedestal2)>massimo && ijk>150 && ijk<(fDataSize-150) && used[ijk]==0)
445 massimo=(rawDigit->ADC(ijk)-pedestal2);
446 quale_sample_massimo=ijk;
449 float base_massimo_before=0;
450 float base_massimo_after=0;
451 for (
unsigned int ijk=quale_sample_massimo-135; ijk<quale_sample_massimo-35; ijk++)
453 base_massimo_before+=(rawDigit->ADC(ijk)-pedestal2)*0.01;
455 for (
unsigned int ijk=quale_sample_massimo+35; ijk<quale_sample_massimo+135; ijk++)
457 base_massimo_after+=(rawDigit->ADC(ijk)-pedestal2)*0.01;
459 float basebase=(base_massimo_after+base_massimo_before)*0.5;
460 h_basediff->Fill(fabs(base_massimo_after-base_massimo_before));
h_base1->Fill(base_massimo_before);
463 for (
unsigned int ijk=0; ijk<(fDataSize); ijk++)
465 if (ijk>(quale_sample_massimo-30) && ijk<(quale_sample_massimo+30)) {
466 if(fabs(base_massimo_after-base_massimo_before)<=sigma_pedestal)areaarea+=(rawDigit->ADC(ijk)-pedestal2-basebase);
467 if(fabs(base_massimo_after-base_massimo_before)>sigma_pedestal && base_massimo_after<base_massimo_before)areaarea+=(rawDigit->ADC(ijk)-pedestal2-base_massimo_after);
468 if(fabs(base_massimo_after-base_massimo_before)>sigma_pedestal && base_massimo_after>base_massimo_before)areaarea+=(rawDigit->ADC(ijk)-pedestal2-base_massimo_before);
472 if(used[ijk]==0)h111->Fill(rawDigit->ADC(ijk)-pedestal2-basebase);
475 sigma_pedestal=h111->GetRMS();
477 h_rms->Fill(sigma_pedestal);
478 if(
fdumphitsfcl==1)purh<<evt.event()<<
" " <<iWire<<
" "<<tpc<<
" "<<cryostat<<
" "<<basebase<<
" "<<base_massimo_after<<
" " <<base_massimo_before<<
" "<<pedestal2<<
" "<<sigma_pedestal<<
" " << quale_sample_massimo <<
" " << massimo << std::endl;
482 if(
fdumphitsfcl==1)purh<<iWire<<
" "<<tpc<<
" "<<cryostat<<
" CANDIDATE HIT " << quale_sample_massimo <<
" " << massimo << std::endl;
484 if(tpc==0)www0->push_back(iWire+64);
485 if(tpc==0)sss0->push_back(quale_sample_massimo);
486 if(tpc==0)hhh0->push_back(massimo);
487 if(tpc==0)ehh0->push_back(sigma_pedestal);
488 if(tpc==0)ccc0->push_back(-1);
489 if(tpc==1)www0->push_back(iWire+64+2536);
490 if(tpc==1)sss0->push_back(quale_sample_massimo);
491 if(tpc==1)hhh0->push_back(massimo);
492 if(tpc==1)ehh0->push_back(sigma_pedestal);
493 if(tpc==1)ccc0->push_back(-1);
494 if(tpc==2)www2->push_back(iWire+64);
495 if(tpc==2)sss2->push_back(quale_sample_massimo);
496 if(tpc==2)hhh2->push_back(massimo);
497 if(tpc==2)ehh2->push_back(sigma_pedestal);
498 if(tpc==2)ccc2->push_back(-1);
499 if(tpc==3)www2->push_back(iWire+64+2536);
500 if(tpc==3)sss2->push_back(quale_sample_massimo);
501 if(tpc==3)hhh2->push_back(massimo);
502 if(tpc==3)ehh2->push_back(sigma_pedestal);
503 if(tpc==3)ccc2->push_back(-1);
505 if(tpc==0)aaa0->push_back(areaarea);
506 if(tpc==1)aaa0->push_back(areaarea);
507 if(tpc==2)aaa2->push_back(areaarea);
508 if(tpc==3)aaa2->push_back(areaarea);
509 for(
int ijk=0;ijk<330;ijk++)
511 int ent_value=quale_sample_massimo+ijk-165;
520 for (
unsigned int ijk=0; ijk<www0->size(); ijk++)
522 for (
unsigned int ijk2=0; ijk2<www0->size(); ijk2++)
524 if (fabs((*www0)[ijk]-(*www0)[ijk2])<
fdwclusfcl && ijk!=ijk2 && fabs((*sss0)[ijk]-(*sss0)[ijk2])<
fdsclusfcl)
526 if ((*ccc0)[ijk]<0 && (*ccc0)[ijk2]<0)
531 else if ((*ccc0)[ijk]>0 && (*ccc0)[ijk2]<0)
533 (*ccc0)[ijk2]=(*ccc0)[ijk];
535 else if ((*ccc0)[ijk]<0 && (*ccc0)[ijk2]>0)
537 (*ccc0)[ijk]=(*ccc0)[ijk2];
539 else if ((*ccc0)[ijk]>0 && (*ccc0)[ijk2]>0)
541 for (
unsigned int ijk3=0; ijk3<www0->size(); ijk3++)
543 if(((*ccc0)[ijk3])==((*ccc0)[ijk2]))(*ccc0)[ijk3]=(*ccc0)[ijk];
551 for (
unsigned int ijk=0; ijk<www2->size(); ijk++)
554 for (
unsigned int ijk2=0; ijk2<www2->size(); ijk2++)
556 if (fabs((*www2)[ijk]-(*www2)[ijk2])<
fdwclusfcl && ijk!=ijk2 && fabs((*sss2)[ijk]-(*sss2)[ijk2])<
fdsclusfcl)
558 if ((*ccc2)[ijk]<0 && (*ccc2)[ijk2]<0)
563 else if ((*ccc2)[ijk]>0 && (*ccc2)[ijk2]<0)
565 (*ccc2)[ijk2]=(*ccc2)[ijk];
567 else if ((*ccc2)[ijk]<0 && (*ccc2)[ijk2]>0)
569 (*ccc2)[ijk]=(*ccc2)[ijk2];
571 else if ((*ccc2)[ijk]>0 && (*ccc2)[ijk2]>0)
573 for (
unsigned int ijk3=0; ijk3<www2->size(); ijk3++)
575 if(((*ccc2)[ijk3])==((*ccc2)[ijk2]))(*ccc2)[ijk3]=(*ccc2)[ijk];
583 Int_t clusters_creation[4][30000];
585 Int_t clusters_swire[4][30000];
586 Int_t clusters_lwire[4][30000];
587 Int_t clusters_ssample[4][30000];
588 Int_t clusters_lsample[4][30000];
590 Int_t clusters_nn[1000];
591 Int_t clusters_vi[1000];
592 Int_t clusters_qq[1000];
594 Int_t clusters_dw[1000];
595 Int_t clusters_ds[1000];
596 Double_t clusters_mw[1000];
597 Double_t clusters_ms[1000];
598 Double_t clusters_mintime[1000];
601 for (
unsigned int ijk=0; ijk<4; ijk++) {
602 for (
unsigned int ijk2=0; ijk2<30000; ijk2++) {
603 clusters_creation[ijk][ijk2]=0;
604 clusters_swire[ijk][ijk2]=100000;
605 clusters_lwire[ijk][ijk2]=0;
606 clusters_ssample[ijk][ijk2]=100000;
607 clusters_lsample[ijk][ijk2]=0;
608 if (ijk2<1000 && ijk>2) {
609 clusters_nn[ijk2]=-1;
610 clusters_vi[ijk2]=-1;
611 clusters_dw[ijk2]=-1;
612 clusters_ds[ijk2]=-1;
613 clusters_qq[ijk2]=-1;
614 clusters_mw[ijk2]=-1;
615 clusters_ms[ijk2]=-1;
616 clusters_mintime[ijk2]=-1;
621 for (
unsigned int ijk=0; ijk<www0->size(); ijk++)
623 if ((*ccc0)[ijk]>0) {
624 int numero=(*ccc0)[ijk];
625 clusters_creation[0][numero]+=1;
626 if((*www0)[ijk]<clusters_swire[0][numero])clusters_swire[0][numero]=(*www0)[ijk];
627 if((*www0)[ijk]>clusters_lwire[0][numero])clusters_lwire[0][numero]=(*www0)[ijk];
628 if((*sss0)[ijk]<clusters_ssample[0][numero])clusters_ssample[0][numero]=(*sss0)[ijk];
629 if((*sss0)[ijk]>clusters_lsample[0][numero])clusters_lsample[0][numero]=(*sss0)[ijk];
632 for (
unsigned int ijk=0; ijk<www2->size(); ijk++)
634 if ((*ccc2)[ijk]>0) {
635 int numero=(*ccc2)[ijk];
636 clusters_creation[2][numero]+=1;
637 if((*www2)[ijk]<clusters_swire[2][numero])clusters_swire[2][numero]=(*www2)[ijk];
638 if((*www2)[ijk]>clusters_lwire[2][numero])clusters_lwire[2][numero]=(*www2)[ijk];
639 if((*sss2)[ijk]<clusters_ssample[2][numero])clusters_ssample[2][numero]=(*sss2)[ijk];
640 if((*sss2)[ijk]>clusters_lsample[2][numero])clusters_lsample[2][numero]=(*sss2)[ijk];
644 int quanti_clusters=0;
645 for (
unsigned int ijk=0; ijk<4; ijk++) {
646 for (
unsigned int ijk2=0; ijk2<30000; ijk2++) {
647 if(clusters_creation[ijk][ijk2]>50)
650 clusters_qq[quanti_clusters]=clusters_creation[ijk][ijk2];
651 clusters_vi[quanti_clusters]=ijk;
652 clusters_nn[quanti_clusters]=ijk2;
653 clusters_dw[quanti_clusters]=clusters_lwire[ijk][ijk2]-clusters_swire[ijk][ijk2];
654 clusters_ds[quanti_clusters]=clusters_lsample[ijk][ijk2]-clusters_ssample[ijk][ijk2];
655 clusters_mw[quanti_clusters]=(clusters_lwire[ijk][ijk2]+clusters_swire[ijk][ijk2])*0.5;
656 clusters_ms[quanti_clusters]=(clusters_lsample[ijk][ijk2]+clusters_ssample[ijk][ijk2])*0.5;
657 clusters_mintime[quanti_clusters]=(clusters_ssample[ijk][ijk2]);
664 for(
int icl = 0; icl < quanti_clusters; ++icl){
665 if (clusters_qq[icl]>0) {
667 int tpc_number=clusters_vi[icl];
669 if (clusters_ds[icl]>2250 && clusters_dw[icl]>100)
672 std::vector<float> *whc=
new std::vector<float>;
673 std::vector<float> *shc=
new std::vector<float>;
674 std::vector<float> *ahc=
new std::vector<float>;
675 std::vector<float> *fahc=
new std::vector<float>;
677 if (clusters_vi[icl]==0) {
678 for (
unsigned int ijk=0; ijk<www0->size(); ijk++) {
679 if ((*ccc0)[ijk]==clusters_nn[icl]) {
680 whc->push_back((*www0)[ijk]);
681 shc->push_back((*sss0)[ijk]);
683 ahc->push_back((*aaa0)[ijk]);
684 fahc->push_back((*hhh0)[ijk]);
688 if (clusters_vi[icl]==2) {
689 for (
unsigned int ijk=0; ijk<www2->size(); ijk++) {
690 if ((*ccc2)[ijk]==clusters_nn[icl]) {
691 whc->push_back((*www2)[ijk]);
692 shc->push_back((*sss2)[ijk]);
693 ahc->push_back((*aaa2)[ijk]);
695 fahc->push_back((*hhh2)[ijk]);
706 float pendenza=0;
float intercetta=0;
int found_ok=0;
707 std::vector<int> *escluse=
new std::vector<int>;
714 for(
int j=0;j<(int)whc->size();j++)
718 Double_t wires[10000];
719 Double_t samples[10000];
721 Double_t quale[10000];
724 for(
int k=0;
k<(int)whc->size();
k++)
728 wires[quanti]=(*whc)[
k]*3;
729 samples[quanti]=(*shc)[
k]*0.628;
737 TGraphErrors *gr3 =
new TGraphErrors(quanti,wires,samples,ex,ey);
738 gr3->Fit(
"pol1",
"Q");
739 TF1 *fitfunc = gr3->GetFunction(
"pol1");
740 pendenza=fitfunc->GetParameter(1);
741 intercetta=fitfunc->GetParameter(0);
742 float distance_maximal=
fdisfcl;
743 int quella_a_distance_maximal=0;
745 for(
int jj=0;jj<quanti;jj++)
747 if((
abs((pendenza)*(wires[jj])-samples[jj]+intercetta)/sqrt((pendenza)*pendenza+1))>distance_maximal)
750 quella_a_distance_maximal=quale[jj];
751 distance_maximal=(
abs(pendenza*wires[jj]-samples[jj]+intercetta)/sqrt(pendenza*pendenza+1));
754 if(found_max==1)escluse->push_back(quella_a_distance_maximal);
755 if(found_max==0)found_ok=1;
760 std::vector<float> *hittime=
new std::vector<float>;
761 std::vector<float> *hitwire=
new std::vector<float>;
762 std::vector<float> *hitarea=
new std::vector<float>;
763 std::vector<float> *hittimegood=
new std::vector<float>;
764 std::vector<float> *hitareagood=
new std::vector<float>;
765 std::vector<float> *hitwiregood=
new std::vector<float>;
771 for(
int kkk=0;kkk<(int)whc->size();kkk++)
775 float distance=(
abs(pendenza*((*whc)[kkk]*3)-(*shc)[kkk]*0.628+intercetta))/sqrt(pendenza*pendenza+1);
779 hittime->push_back((*shc)[kkk]*0.4);
780 hitwire->push_back((*whc)[kkk]);
781 hitarea->push_back((*ahc)[kkk]);
791 Double_t area[10000];
792 Double_t nologarea[10000];
793 Double_t tempo[10000];
806 if(hitarea->size()>100)
808 h_ratio->Fill(((
float)whc->size())/((
float)clusters_dw[icl]));
809 h_ratio_3->Fill(clusters_ds[icl],((
float)whc->size())/((
float)clusters_dw[icl]));
814 float wire_minimo=100000;
815 float wire_massimo=0;
817 float delta_sample_selected=0;
818 float delta_wire_selected=0;
819 float wire_del_massimo=-1;
820 float wire_del_minimo=-1;
821 float sample_massimo=-1;
822 float sample_minimo=-1;
823 int quante_hit_nel_range_tempo=0;
824 purh<< evt.run() <<
" " << evt.subRun() <<
" " << evt.event() <<
" -1 " <<
" -1 " <<
" -1 " <<
" -1 " << std::endl;
825 for(
int kk=0;kk<(int)hitarea->size();kk++)
827 if(
fdumphitsfcl==1)purh<< evt.run() <<
" SELECTED " << evt.subRun() <<
" " << evt.event() <<
" " << tpc_number <<
" " << (*hitwire)[kk] <<
" " << (*hittime)[kk] <<
" " << (*hitarea)[kk] << std::endl;
829 quante_hit_nel_range_tempo+=1;
830 if((*hittime)[kk]>massimo)
832 massimo=(*hittime)[kk];
833 wire_del_massimo=(*hitwire)[kk];
837 if((*hittime)[kk]<minimo)
839 minimo=(*hittime)[kk];
840 wire_del_minimo=(*hitwire)[kk];
844 if((*hitwire)[kk]>wire_massimo)
846 wire_massimo=(*hitwire)[kk];
850 if((*hitwire)[kk]<wire_minimo)
852 wire_minimo=(*hitwire)[kk];
857 delta_sample_selected=(massimo-minimo)/0.4;
858 delta_wire_selected=wire_del_massimo-wire_del_minimo;
859 sample_massimo=massimo/0.4;
860 sample_minimo=minimo/0.4;
861 h_ratio_after->Fill(((
float)quante_hit_nel_range_tempo)/fabs(delta_wire_selected));
862 h_ratio_after_2->Fill(((
float)quante_hit_nel_range_tempo)/fabs(wire_massimo-wire_minimo+1));
863 h_ratio_after_3->Fill(delta_sample_selected,((
float)quante_hit_nel_range_tempo)/fabs(wire_massimo-wire_minimo+1));
872 float steptime=(massimo-minimo)/(gruppi+1);
879 for(
int stp=0;stp<=gruppi;stp++)
881 std::vector<float>* hitpertaglio=
new std::vector<float>;
884 for(
int kk=0;kk<(int)hitarea->size();kk++)
886 if((*hittime)[kk]>=(minimo+stp*steptime) && (*hittime)[kk]<=(minimo+(stp+1)*(steptime)))
887 hitpertaglio->push_back((*hitarea)[kk]*
exp((*hittime)[kk]/starting_value_tau));
896 for(
int kk=0;kk<(int)hitarea->size();kk++)
899 if((*hittime)[kk]>(minimo+stp*steptime) &&
900 (*hittime)[kk]<(minimo+(stp+1)*steptime) &&
901 (*hitarea)[kk]*
exp((*hittime)[kk]/starting_value_tau)<tagliomax &&
902 (*hitarea)[kk]*
exp((*hittime)[kk]/starting_value_tau)>tagliomin)
905 hitareagood->push_back((*hitarea)[kk]);
906 hittimegood->push_back((*hittime)[kk]);
907 hitwiregood->push_back((*hitwire)[kk]);
912 if(delta_sample_selected>1900)
914 for(
int k=0;
k<(int)whc->size();
k++)
916 h_hittime->Fill((*shc)[
k]-clusters_mintime[icl]);
918 for(
int k=0;
k<(int)hittime->size();
k++)
920 h_hittime_2->Fill((*hittime)[
k]/0.4-clusters_mintime[icl]);
923 for(
int k=0;
k<(int)hittimegood->size();
k++)
925 h_hittime_3->Fill((*hittimegood)[
k]/0.4-clusters_mintime[icl]);
929 for(
int k=0;
k<(int)hitareagood->size();
k++)
931 if(
fdumphitsfcl==1)purh<< evt.run() <<
" AFTER CLEAN " << evt.subRun() <<
" " << evt.event() <<
" " << tpc_number <<
" " << (*hitwiregood)[
k] <<
" " << (*hittimegood)[
k] <<
" " << (*hitareagood)[
k] << std::endl;
933 tempo[
k]=(*hittimegood)[
k];
934 area[
k]=log((*hitareagood)[
k]);
936 nologarea[
k]=((*hitareagood)[
k]);
944 TGraphErrors *gr31 =
new TGraphErrors(hitareagood->size(),tempo,area,ex,ey);
946 gr31->Fit(
"pol1",
"Q");
947 TF1 *fit = gr31->GetFunction(
"pol1");
948 float slope_purity=fit->GetParameter(1);
950 float intercetta_purezza=fit->GetParameter(0);
952 TH1F *h111 =
new TH1F(
"h111",
"delta aree",200,-10,10);
953 float sum_per_rms_test=0;
954 int quanti_in_h111=0;
955 for(
int k=0;
k<(int)hitareagood->size();
k++)
957 h111->Fill(area[
k]-slope_purity*tempo[
k]-intercetta_purezza);
958 sum_per_rms_test+=(area[
k]-slope_purity*tempo[
k]-intercetta_purezza)*(area[
k]-slope_purity*tempo[
k]-intercetta_purezza);
959 if((area[
k]-slope_purity*tempo[
k]-intercetta_purezza)>-10 && (area[
k]-slope_purity*tempo[
k]-intercetta_purezza)<10)quanti_in_h111+=1;
963 if(quanti_in_h111>1){
964 h111->Fit(
"gaus",
"Q");
965 TF1 *fitg = h111->GetFunction(
"gaus");
966 error=fitg->GetParameter(2);
975 TGraphErrors *gr4 =
new TGraphErrors(hitareagood->size(),tempo,nologarea,ex,ey);
976 gr4->Fit(
"expo",
"Q");
977 TF1 *fite = gr4->GetFunction(
"expo");
978 slope_purity=fite->GetParameter(1);
979 intercetta_purezza=fite->GetParameter(0);
980 float mean_hit_area=0;
981 float size_hit_area=hitareagood->size();
982 int quanti_in_h111e=0;
983 TH1F *h111e =
new TH1F(
"h111e",
"delta aree",100,-1000.,1000.);
984 for(
int k=0;
k<(int)hitareagood->size();
k++)
986 h111e->Fill(nologarea[
k]-
exp(slope_purity*tempo[
k]+intercetta_purezza));
987 mean_hit_area+=nologarea[
k]/size_hit_area;
988 if((nologarea[
k]-
exp(slope_purity*tempo[
k]+intercetta_purezza))>-1000. && (nologarea[
k]-
exp(slope_purity*tempo[
k]+intercetta_purezza))<1000)quanti_in_h111e+=1;
992 float error_expo=1000.;
993 if(quanti_in_h111e>1)
995 h111e->Fit(
"gaus",
"Q");
996 TF1 *fitge = h111e->GetFunction(
"gaus");
997 error_expo=fitge->GetParameter(2);
1003 for(
int k=0;
k<(int)hitareagood->size();
k++)
1013 TGraphErrors *gr32 =
new TGraphErrors(hitareagood->size(),tempo,area,ex,ey);
1014 gr32->Fit(
"pol1",
"Q");
1016 TF1 *fit2 = gr32->GetFunction(
"pol1");
1017 float slope_purity_2=fit2->GetParameter(1);
1018 float error_slope_purity_2=fit2->GetParError(1);
1020 float chiquadro=fit2->GetChisquare()/(hitareagood->size()-2);
1021 std::ofstream goodpuro(
"purity_results.out",std::ios::app);
1022 std::ofstream goodpuro2(
"purity_results2.out",std::ios::app);
1027 TGraphAsymmErrors *gr41 =
new TGraphAsymmErrors (hitareagood->size(),tempo,nologarea,ex,ex,ez,ek);
1028 gr41->Fit(
"expo",
"Q");
1029 TF1 *fitexo = gr41->GetFunction(
"expo");
1030 float slope_purity_exo=fitexo->GetParameter(1);
1031 float error_slope_purity_exo=fitexo->GetParError(1);
1040 if(fabs(slope_purity_2)<0.01 || fabs(slope_purity_exo)<0.01)
1042 if(fabs(slope_purity_2)<0.01)
purityvalues->Fill(-slope_purity_2*1000.);
1043 if(fabs(slope_purity_2)<0.01)goodpuro << evt.run() <<
" " << evt.subRun() <<
" " << evt.event() <<
" " << tpc_number <<
" " << slope_purity_2 <<
" " << error_slope_purity_2 <<
" " << chiquadro <<
" " << clusters_dw[icl] <<
" " << clusters_ds[icl] << std::endl;
1045 if(fabs(slope_purity_exo)<0.01)goodpuro2<< evt.run() <<
" " << evt.subRun() <<
" " << evt.event() <<
" " << tpc_number+
fcryofcl*10 <<
" " << slope_purity_exo <<
" " << error_slope_purity_exo <<
" " << fitexo->GetChisquare()/(hitareagood->size()-2) <<
" " << clusters_dw[icl] <<
" " << clusters_ds[icl] <<
" " << clusters_mw[icl] <<
" " << clusters_ms[icl] <<
" " << delta_wire_selected <<
" " << delta_sample_selected <<
" " << sample_minimo <<
" " << sample_massimo <<
" " << wire_del_minimo <<
" " << wire_del_massimo <<
" " << wire_minimo <<
" " << wire_massimo <<
" " << whc->size() <<
" " << hitarea->size() <<
" " << quante_hit_nel_range_tempo <<
" " << error_expo <<
" " << clusters_mintime[icl] <<
" " << mean_hit_area << std::endl;
1048 if(fabs(slope_purity_exo)<0.01)
1056 chi_tree=fitexo->GetChisquare()/(hitareagood->size()-2);
1064 if(fabs(slope_purity_exo)<0.01)
purityvalues2->Fill(-slope_purity_exo*1000.);
1066 if(fabs(slope_purity_exo)<0.01 && tpc_number==0)
puritytpc0->Fill(-slope_purity_exo*1000.);
1067 if(fabs(slope_purity_exo)<0.01 && tpc_number==1)
puritytpc1->Fill(-slope_purity_exo*1000.);
1068 if(fabs(slope_purity_exo)<0.01 && tpc_number==2)
puritytpc2->Fill(-slope_purity_exo*1000.);
1069 if(fabs(slope_purity_exo)<0.01 && tpc_number==3)
puritytpc3->Fill(-slope_purity_exo*1000.);
1072 if(fabs(slope_purity_exo)<0.01)
1077 purity_info.
Run = evt.run();
1078 purity_info.
Subrun = evt.subRun();
1079 purity_info.
Event = evt.event();
1080 purity_info.
TPC = tpc_number;
1081 purity_info.
Wires = delta_wire_selected;
1082 purity_info.
Ticks = delta_sample_selected;
1103 purity_info.
FracError = error_slope_purity_exo / slope_purity_exo;
1114 purity_info.
Print();
1115 outputPtrVector->push_back(purity_info);
1172 evt.put(std::move(outputPtrVector));
1179 DEFINE_ART_MODULE(ICARUSPurityDQM)
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Collection of charge vs time digitized from a single readout channel.
void produce(art::Event &evt)
read access to event
Declaration of signal hit object.
int Nothere(std::vector< int > *a, int b)
unsigned int PlaneID_t
Type for the ID number.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
CryostatID_t Cryostat
Index of cryostat.
Definition of basic raw digits.
WireID_t Wire
Index of the wire within its plane.
int Notheref(std::vector< float > *a, float b)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
virtual ~ICARUSPurityDQM()
Collect all the RawData header files together.
PlaneID_t Plane
Index of the plane within its TPC.
Declaration of cluster object.
Double_t FoundMeanLog(std::vector< float > *a, float b)
Declaration of basic channel signal object.
art::ServiceHandle< art::TFileService > tfs
unsigned int ChannelID_t
Type representing the ID of a readout channel.
TPCID_t TPC
Index of the TPC within its cryostat.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
ICARUSPurityDQM(fhicl::ParameterSet const &pset)
std::vector< art::InputTag > fDigitModuleLabel
art framework interface to geometry description