29 #include "TPaveStats.h"
32 #include "TPaveText.h"
41 return Watcher::GetFromTrigger(trigger,
"data:psa", fFrame);
44 Float_t PSACrystal3D::fgMetric = 10.;
45 Float_t PSACrystal3D::fRadius = 5. ;
46 Float_t PSACrystal3D::fDepht = 10.;
47 Int_t PSACrystal3D::fNBinX = 50;
48 Int_t PSACrystal3D::fNBinZ = 50;
49 Float_t PSACrystal3D::fDefaultECutMin = 0.;
50 Float_t PSACrystal3D::fDefaultECutMax = 100000000.;
64 fCurrentECutMin(fDefaultECutMin),
65 fCurrentECutMax(fDefaultECutMax)
67 fH3DHitPosition = MakeTH3<TH3F>(
"H3DHitPosition",
"Distribution of Hits in the crystal; x (cm); y (cm); z (cm)",
68 fNBinX, -fRadius, fRadius,
69 fNBinX, -fRadius, fRadius,
71 fE0 = MakeTH1<TH1F>(
"ECore0",
"Core energy 0, (high gain)",6000, 0, 6000);
72 fE1 = MakeTH1<TH1F>(
"ECore1",
"Core energy 1, (low gain) ",1000, 0, 10000);
73 fE1->SetLineColor(kRed);
74 fT0 = MakeTH1<TH1F>(
"TCore0",
"Core time 0",300, 0, 100);
75 fT1 = MakeTH1<TH1F>(
"TCore1",
"Core time 1",300, 0, 100);
76 fT1->SetLineColor(kRed);
77 fTE0 = MakeTH2<TH2F>(
"TECore0",
"Time energy 0",600,0,6000,300, 0, 100);
78 fTE1 = MakeTH2<TH2F>(
"TECore1",
"Time energy 1",600, 0,6000,300, 0, 100);
80 fEnergySeg = MakeTH1<TH1F>(
"ESum",
"Sum of segment",6000, 0, 6000);
81 fNbHits = MakeTH1<TH1F>(
"NbHits",
"Nb hits in crystal",20, 0, 20);
93 if ( option ==
"3D" ) {
94 fH3DHitPosition->Draw(o);
123 for( UShort_t i=0u; i < data->
GetNbHits(); i++ ) {
126 fH3DHitPosition->Fill(data->
GetHit(i)->
GetX()/fgMetric,
131 fE0->Fill(data->
GetE(0u));
132 fE1->Fill(data->
GetE(1u));
133 fT0->Fill(data->
GetT(0));
134 fT1->Fill(data->
GetT(1));
135 fTE0->Fill(data->
GetE(0u),data->
GetT(0));
136 fTE1->Fill(data->
GetE(1u),data->
GetT(1));
141 if( EcutMax < EcutMin ) {
142 std::cerr <<
"ERROR: PSACrystal3D::SetEnergyCut( Float_t EcutMin,Float_t EcutMax)"
144 <<
"ECutMin greater than ECutMax, the cut has not been changed : "
145 <<
"ECutMin = " << fCurrentECutMin
146 <<
" EcutMax = " << fCurrentECutMax <<
std::endl;
150 if( EcutMin != fCurrentECutMin && EcutMax != fCurrentECutMax ) {
151 fCurrentECutMin = EcutMin;
152 fCurrentECutMax = EcutMax;
153 fH3DHitPosition->Reset();
154 TString newtitle = Form(
"Distribution of Hits in the crystal E #in [%lf,%lf]; x (cm); y (cm); z (cm)",
157 fH3DHitPosition->SetTitle(newtitle.Data());
163 fCurrentECutMin = EcutMin;
167 fCurrentECutMax = EcutMax;
171 return(fCurrentECutMin);
175 return(fCurrentECutMax);
192 fH3DHitPosition(0x0),
201 fCurrentECutMin(fDefaultECutMin),
202 fCurrentECutMax(fDefaultECutMax),
207 fH3DHitPosition = MakeTH3<TH3F>(
"H3DHitPosition",
"Distribution of Hits in the crystal; x (cm); y (cm); z (cm)",
211 fE0 = MakeTH1<TH1F>(
"ECore_HG",
"Core energy 0, (high gain)",6000, 0, 6000);
212 fE1 = MakeTH1<TH1F>(
"ECore_LG",
"Core energy 1, (low gain) ",6000, 0, 6000);
213 for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
215 TString Name = (TString)
"PSA_" +
"CrystalName" +
"_Seg_" + HistPosition.
SegName +
"_Specta";
216 TH1F *h = MakeTH1<TH1F>(Name.Data(),Name.Data(), 6000,0,6000);
217 h->GetXaxis()->SetTitle(
"Energy (keV)");
218 h->GetYaxis()->SetTitle(
"Counts");
221 fT0 = MakeTH1<TH1F>(
"TCore_HG",
"Core time 0 (high gain)",1000, 0, 100);
222 fT1 = MakeTH1<TH1F>(
"TCore_LG",
"Core time 1 (low gain)",1000, 0, 100);
223 fTE0 = MakeTH2<TH2F>(
"TECore_HG",
"Time energy 0 (high gain)",6000,0,6000,1000, 0, 100);
224 fTE1 = MakeTH2<TH2F>(
"TECore_LG",
"Time ebergy 1 (low gain)",6000, 0,6000,1000, 0, 100);
226 fEnergySeg = MakeTH1<TH1F>(
"ESum",
"Sum energy of segments",6000, 0, 6000);
227 fNbHits = MakeTH1<TH1F>(
"NbHits",
"Nb hits in crystal",20, 0, 20);
229 for(
int i=0 ; i<6 ; i++)
244 return Watcher::GetFromTrigger(trigger,
"data:psa",
fFrame);
257 if(fCrystalID == 0) fCrystalID = data->
GetUID();
259 Double_t SumSeg = 0.;
263 for( UShort_t i=0u; i < data->
GetNbHits(); i++ )
269 ((TH1*)(
fSpectra->At(SegID)))->Fill(ESeg);
292 if( EcutMax < EcutMin ) {
293 std::cerr <<
"ERROR: PSACrystal3D::SetEnergyCut( Float_t EcutMin,Float_t EcutMax)"
295 <<
"ECutMin greater than ECutMax, the cut has not been changed : "
305 TString newtitle = Form(
"Distribution of Hits in the crystal E #in [%lf,%lf]; x (cm); y (cm); z (cm)",
331 TString opt = (TString)option;
339 if(opt ==
"same") c = (TCanvas*)gPad->GetCanvas();
342 TString Name =
"PSA_Spectra_" + CrystalName;
343 TString Title =
"Mapping of the spectra for crystal " + CrystalName +
"at the post psa level";
351 for(
int i=0 ; i<CrystalInterface::kNbSegments ; i++)
355 TPad *pad = (TPad*)c->cd(HistPosition.
PadNmbr);
359 TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject(
"InfoPad");
363 TString NameTitle = (TString)
"Psa_" + CrystalName +
"_Seg_" + HistPosition.
SegName +
"_Specta";
365 h->SetNameTitle(NameTitle,NameTitle);
368 for(
int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
370 if(pad->GetListOfPrimitives()->At(k)->InheritsFrom(
"TH1"))col++;
376 if(col==0) h->GetXaxis()->SetRangeUser(1,h->GetXaxis()->GetXmax());
383 for(
int i=0 ; i<CrystalInterface::kNbCores ; i++)
387 TPad *pad = (TPad*)c->cd(HistPosition.
PadNmbr);
391 TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject(
"InfoPad");
396 TString NameTitle = (TString)
"Psa_" + CrystalName +
"_Seg_" + HistPosition.
SegName +
"_Specta";
398 h->SetNameTitle(NameTitle,NameTitle);
401 for(
int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
403 if(pad->GetListOfPrimitives()->At(k)->InheritsFrom(
"TH1"))col++;
409 if(col==0) h->GetXaxis()->SetRangeUser(1,h->GetXaxis()->GetXmax());
417 if(!opt.Contains(
"same"))
429 TString Name =
"PSA_3DHits" + CrystalName;
430 TString Title =
"PSA 3D Hits for crystal " + CrystalName;
434 gStyle->SetOptTitle(0);
436 canvas->Divide(3,1,0.001,0.001);
437 canvas->cd(1)->Divide(1,3,0.001,0.001);
438 for(
int i=0 ; i<3 ; i++)
440 canvas->cd(1)->cd(3-i);
444 canvas->cd(2)->Divide(1,3,0.001,0.001);
445 for(
int i=3 ; i<6 ; i++)
447 canvas->cd(2)->cd(3-(i-3));
462 TString Name =
"PSA_CoreVsSumSeg" + CrystalName;
463 TString Title =
"PSA Core versus sum segments spectra " + CrystalName;
467 c->Divide(1,2,0.001,0.001);
469 double topmarg = 0.0657599;
470 double rightmarg = 0.00726832;
471 double leftmarg = 0.0490612;
472 double bottommarg = 0.114119;
475 TString titles[2] = {
"Fold",
"Energy (keV)"};
477 for(
int i=0 ; i<2 ; i++)
481 gPad->SetRightMargin(rightmarg);
482 gPad->SetTopMargin(topmarg);
483 gPad->SetLeftMargin(leftmarg);
484 gPad->SetBottomMargin(bottommarg);
491 htemp->GetXaxis()->SetTitle(titles[i]);
492 htemp->GetXaxis()->SetTitleSize(0.06);
493 htemp->GetXaxis()->SetLabelSize(0.06);
494 htemp->GetXaxis()->SetTitleOffset(0.91);
496 htemp->GetYaxis()->SetTitle(
"Counts");
497 htemp->GetYaxis()->SetTitleSize(0.06);
498 htemp->GetYaxis()->SetLabelSize(0.06);
499 htemp->GetYaxis()->SetTitleOffset(0.45);
503 htemp->SetBit(TH1::kNoTitle);
513 TPaveStats *st = (TPaveStats*)htemp->FindObject(
"stats");
516 st->SetX2NDC(1-rightmarg);
517 st->SetY2NDC(1-topmarg);
520 TPaveText *txt = (TPaveText*)gPad->FindObject(
"title");
523 double width = txt->GetY2NDC()-txt->GetY1NDC();
524 txt->SetY2NDC(1-topmarg);
525 txt->SetY1NDC(txt->GetY2NDC()-width);
530 TLegend *leg =
new TLegend(st->GetX1NDC(),st->GetY1NDC()-(st->GetY2NDC()-st->GetY1NDC()),st->GetX2NDC(),st->GetY1NDC(),
"",
"NDC");
532 leg->AddEntry(
fE0,
fE0->GetTitle(),
"l");
533 leg->AddEntry(
fE1,
fE1->GetTitle(),
"l");
544 TString Name =
"PSA_TimeVsE" + CrystalName;
545 TString Title =
"PSA time versus energy of the core" + CrystalName;
549 c->Divide(2,2,0.001,0.001);
551 double topmarg = 0.0560089;
552 double rightmarg = 0.0234869;
553 double leftmarg = 0.0747608;
554 double bottommarg = 0.104442;
558 for(
int i=0 ; i<4 ; i++)
562 gPad->SetRightMargin(rightmarg);
563 gPad->SetTopMargin(topmarg);
564 gPad->SetLeftMargin(leftmarg);
565 gPad->SetBottomMargin(bottommarg);
571 if(i<2)htemp->Draw();
578 if(i<2) htemp->GetXaxis()->SetTitle(
"Time (ns)");
579 else htemp->GetXaxis()->SetTitle(
"Energy (keV)");
580 htemp->GetXaxis()->SetTitleSize(0.05);
581 htemp->GetXaxis()->SetLabelSize(0.05);
584 if(i<2) htemp->GetYaxis()->SetTitle(
"Counts");
585 else htemp->GetYaxis()->SetTitle(
"Time (ns)");
586 htemp->GetYaxis()->SetTitleSize(0.05);
587 htemp->GetYaxis()->SetLabelSize(0.05);
588 htemp->GetYaxis()->SetTitleOffset(0.8);
590 htemp->SetBit(TH1::kNoTitle);
595 TPaveStats *st = (TPaveStats*)htemp->FindObject(
"stats");
598 st->SetX2NDC(1-rightmarg);
599 st->SetY2NDC(1-topmarg);
607 int size = 3 + 3 + ((TString)GetName()).Length() + 5 + ((TString)GetTitle()).Length() + 3 + 3;
608 for(
int i=0; i<
size ; i++) std::cout<<
"*";
610 std::cout<<
"*** "<<GetName()<<
" --- "<<GetTitle()<<
" ***"<<
std::endl;
611 for(
int i=0; i<
size ; i++) std::cout<<
"*";
614 std::cout<<
"Number of treated events : "<<fNevts<<
std::endl;
615 std::cout<<
"Crystal ID : "<<fCrystalID<<
std::endl;
virtual Bool_t IsValid() const
true if it is a valid pointer
virtual UShort_t GetNbHits() const =0
To know the number of Hits currently on the stack.
void SetCurrentECutMin(Float_t EcutMin)
virtual Double_t GetY() const
TString GetCrystalNameFromID(int ID)
Float_t GetCurrentECutMax() const
Float_t GetCurrentECutMax() const
void SetCurrentECutMin(Float_t EcutMin)
vector< PadPos > fHistPositionList
virtual Double_t GetE(UInt_t=0u) const =0
to get the energy associated to the core
virtual Double_t GetE() const
virtual Int_t GetUID() const =0
to get the crystal ID
virtual void Print(const char *option="") const
void SetCurrentECutMax(Float_t EcutMax)
TCanvas * NewCanvas(TString cname, TString ctitle)
virtual Double_t GetT(UInt_t=0u) const =0
to get the time associated to the core
Data produced fro a Crystal.
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
Bool_t SetTrigger(ADF::DFTrigger *trigger)
Set the frame to be watched from the trigger.
To get a 3D map of hits in a particular crystal.
virtual Int_t GetID(Int_t=0) const
void SetLastExecStatus(Short_t s=0)
reset last status. 0 means no error, 0 < means error, > 0 means ok with conditions ...
PSACrystal3D(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
LoupOnPad, a class to Loupe on a Pad in a Canvas with many pads in it.
TCanvas * BuildSegmentedCanvas(TString CanvasName, TString CanvasTitle)
virtual Double_t GetX() const
virtual void Exec(Option_t *option="")
static Float_t fDefaultECutMin
Base class for a trigger on a data flow.
ADF::LogMessage & endl(ADF::LogMessage &log)
void SetCurrentECutMax(Float_t EcutMax)
void SetEnergyCut(Float_t EcutMin, Float_t EcutMax)
to apply cut on the hits
virtual Double_t GetZ() const
Float_t GetCurrentECutMin() const
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
Set the frame to be watched from the trigger.
virtual Hit * GetHit(UShort_t)=0
To get back a particular Hit (already on the stack !)
PSACrystal(const char *name="PSACrystal", const char *title="Display the psa values for one crystal at the producer level", TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
static Float_t fDefaultECutMax
virtual void ShowSpectraMap(const char *option="")
Base Watcher working for any kind of Frame (Frame interface)
static Float_t fgMetric
PSA watcher class.
virtual void SetLoupe(bool loupeon=true)
void SetEnergyCut(Float_t EcutMin, Float_t EcutMax)
to apply cut on the hits
Float_t GetCurrentECutMin() const