14 #include "TSpectrum.h"
17 #include "TVirtualFitter.h"
18 #include "TPavesText.h"
20 #include "TObjString.h"
22 #include "TSQLResult.h"
24 #include "TSystemDirectory.h"
27 #include "BashColor.h"
43 fDefinePersoBackground(false),
48 fCalibResultsTree(0x0),
64 TObjArray *GlobalToken = Opt.Tokenize(
";");
65 TObject *GlobalObj = 0x0;
66 TIter GlobalIter(GlobalToken);
68 TString CrystalFilter = GlobalToken->Last()->GetName();
71 if(!CrystalFilter.Contains(
"all",TString::kIgnoreCase) && !CrystalFilter.Contains(
fCrystalName,TString::kIgnoreCase))
return;
72 if(CrystalFilter.Contains(AntiCrystal,TString::kIgnoreCase))
return;
75 bool SpectraDrawn =
false;
77 while ( (GlobalObj = GlobalIter()) )
79 TString SubOpt = GlobalObj->GetName();
81 if(SubOpt.Contains(
"ShowSpectra",TString::kIgnoreCase))
83 TObjArray *SubToken = SubOpt.Tokenize(
" ");
84 TObject *SubObj = 0x0;
85 TIter SubIter(SubToken);
87 while ( (SubObj = SubIter()) )
89 TString name = SubObj->GetName();
90 if(name.BeginsWith(
"lib=",TString::kIgnoreCase))
102 if(SubOpt.Contains(
"Recal",TString::kIgnoreCase))
104 TObjArray *SubToken = SubOpt.Tokenize(
" ");
105 TObject *SubObj = 0x0;
106 TIter SubIter(SubToken);
108 while ( (SubObj = SubIter()) )
110 TString name = SubObj->GetName();
111 if(name.BeginsWith(
"source=",TString::kIgnoreCase))
113 name.Replace(0,7,
"");
116 if(name.BeginsWith(
"lib=",TString::kIgnoreCase))
118 name.Replace(0,4,
"");
121 if(name.BeginsWith(
"CL=",TString::kIgnoreCase))
123 name.Replace(0,3,
"");
124 TString chlim = name.Copy().Replace(name.Index(
","),name.Length()-name.Index(
","),
"");
125 int ChMin = chlim.Atoi();
126 chlim = name.Copy().Replace(0,name.Index(
",")+1,
"");
127 int ChMax = chlim.Atoi();
130 if(name.BeginsWith(
"PL=",TString::kIgnoreCase))
132 name.Replace(0,3,
"");
133 TString Peaklim = name.Copy().Replace(name.Index(
","),name.Length()-name.Index(
","),
"");
134 double FWHM = Peaklim.Atof();
135 Peaklim = name.Copy().Replace(0,name.Index(
",")+1,
"");
136 double Ampli = Peaklim.Atof();
147 if(SubOpt.Contains(
"Plot",TString::kIgnoreCase))
149 TObjArray *SubToken = SubOpt.Tokenize(
" ");
150 TObject *SubObj = 0x0;
151 TIter SubIter(SubToken);
153 while ( (SubObj = SubIter()) )
155 TString name = SubObj->GetName();
156 if(name.BeginsWith(
"exp=",TString::kIgnoreCase))
158 name.Replace(0,4,
"");
161 if(name.BeginsWith(
"sel=",TString::kIgnoreCase))
163 name.Replace(0,4,
"");
166 if(name.BeginsWith(
"opt=",TString::kIgnoreCase))
168 name.Replace(0,4,
"");
182 cout<<
"Energy calibration parameters for crystal "<<
fCrystalName<<
" with "<<source<<
" source"<<
endl;
183 cout<<
"Seg"<<
"\t\t Area \t Offset Gain \t\t Mean \t E(keV) \t FWHM(KeV) \t FWHM_10(keV) \t TL \t\t TR"<<
endl;
185 TCanvas *CurrentCanvas = gPad->GetCanvas();
188 while(CurrentCanvas->cd(Pad) != CurrentCanvas->cd(Pad+1))
191 CurrentCanvas->cd(Pad);
196 CurrentCanvas->Update();
197 CurrentCanvas->Modified();
199 gSystem->MakeDirectory(
"FitResults");
200 ofstream FileOut(((TString)
"FitResults/" +
fCrystalName +
"_Amplitude.fit"));
201 FileOut<<
"#Seg"<<
"\t"<<
"Area"<<
"\t"<<
" Offset"<<
"\t "<<
" Gain"<<
" \t "<<
"Mean"<<
" \t "<<
"E"<<
" \t "<<
"FWHM"<<
"\t "<<
"FWHM_10"<<
" \t "<<
"LTProp"<<
" \t "<<
"RTProp"<<
endl;
225 if(gPad->GetListOfPrimitives()->GetSize()>0)
228 TObjArray *array = Name.Tokenize(
"_");
229 TObject *LastToken = array->At(array->GetLast());
231 int HistNbr = ((TString)LastToken->GetName()).Atoi();
233 TString SegName = HistPosition.
SegName;
234 int Profondeur = SegName.Remove(0,1).Atoi();
235 TString SourceName = source;
250 cout<<
"Energy calibration parameters for crystal "<<
fCrystalName<<
" with "<<source<<
" source"<<
endl;
251 cout<<
"Seg"<<
"\t\t Area \t Offset Gain \t\t Mean \t E(keV) \t FWHM(KeV) \t FWHM_10(keV) \t TL \t\t TR"<<
endl;
255 TObjArray *array = Name.Tokenize(
"_");
256 TObject *LastToken = array->At(array->GetLast());
258 HistNbr = ((TString)LastToken->GetName()).Atoi();
262 TString SegName = HistPosition.
SegName;
264 int last = FS->
GetArea().size()-1;
266 double area = FS->
GetArea().at(last);
269 double Mean = FS->
GetMean().at(last);
270 double E = FS->
GetECal().at(last);
292 if(SegName.Contains(
"Core"))cout<<
"Seg "<<HistNbr<<
"("<<SegName<<
"): "<<area<<
"\t "<<offset<<
"\t "<<gain<<
" \t "<<Mean<<
" \t "<<E<<
" \t "<<FWHM<<
"\t "<<FWHM_10<<
" \t "<<LTProp<<
" \t "<<RTProp<<
endl;
293 else cout<<
"Seg "<<HistNbr<<
"("<<SegName<<
"): \t "<<area<<
" \t "<<offset<<
"\t "<<gain<<
" \t "<<Mean<<
" \t "<<E<<
" \t "<<FWHM<<
"\t "<<FWHM_10<<
" \t "<<LTProp<<
" \t "<<RTProp<<
endl;
295 else if(gPad->GetListOfPrimitives()->GetSize()>1)
298 TObjArray *array = Name.Tokenize(
"_");
299 TObject *LastToken = array->At(array->GetLast());
301 HistNbr = ((TString)LastToken->GetName()).Atoi();
305 TString SegName = HistPosition.
SegName;
317 cout<<
"Seg "<<HistNbr<<
"("<<SegName<<
"): "<<0<<
"\t "<<0<<
"\t "<<0<<
" \t "<<0<<
" \t "<<0<<
" \t "<<0<<
"\t "<<0<<
" \t "<<0<<
"\t "<<0<<
endl;
340 TList *ListOfPrimitives = (TList*) gPad->GetListOfPrimitives();
343 if(ListOfPrimitives->GetSize())
345 TIter iter(ListOfPrimitives);
348 while( (o = iter()) )
350 if(o->InheritsFrom(
"TH1"))
358 h->SetAxisRange(xmin,xmax);
360 TSpectrum *s =
new TSpectrum(10*NPeaks);
362 s->Search(h,width,
"",threshold);
374 TString opt = (TString)DrawOpt;
377 if(opt.Contains(
"same",TString::kIgnoreCase)) c = (TCanvas*)gPad->GetCanvas();
380 TString Name =
"RawSpec" +
fCrystalName + Form(
"Lib%d",LibraryNumber);
381 TString Title =
"Mapping of the raw spectra for crystal " +
fCrystalName;
385 c->Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
388 "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
396 for(
int i=0 ; i<
fNSg+
fNC ; i++)
400 TPad *pad = (TPad*)c->cd(HistPosition.
PadNmbr);
404 TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject(
"InfoPad");
406 h = ((TH1*)ListOfHists->At(i));
407 h->GetXaxis()->SetLabelSize(0.07);
408 h->GetYaxis()->SetLabelSize(0.07);
411 for(
int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
413 if(pad->GetListOfPrimitives()->At(k)->InheritsFrom(
"TH1"))col++;
423 gPad->SetFrameFillStyle(0);
429 if(!opt.Contains(
"same"))
441 TCanvas *c = gPad->GetCanvas();
442 c->Connect(
"ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
445 "HandleMovement(Int_t, Int_t, Int_t, TObject*)");
452 TCanvas *CurrentCanvas = gPad->GetCanvas();
454 for(
int HistNbr=FirstHist ; HistNbr<FirstHist+NbrOfSpectra*Step ; HistNbr+=Step)
457 CurrentCanvas->cd(MyMadPos.
PadNmbr);
463 CurrentCanvas->Paint();
464 CurrentCanvas->Update();
474 cout<<
"[ERROR] Source not define ==> s + s to define the source "<<
endl;
479 TCanvas *CurrentCanvas = gPad->GetCanvas();
481 CurrentCanvas->Paint();
482 CurrentCanvas->Update();
484 TString DirName =
"FitResults/GWRecal/" +
fRunName;
486 gSystem->mkdir(DirName,
true);
489 for(
int HistNbr=0 ; HistNbr<
fNC+
fNSg ; HistNbr++)
492 CurrentCanvas->cd(MyMadPos.
PadNmbr);
493 TList *ListOfPrimitives = (TList*) gPad->GetListOfPrimitives();
494 if(ListOfPrimitives->GetSize()>0)
496 TIter iter(ListOfPrimitives);
499 while( (o = iter()) )
501 if(o->InheritsFrom(
"TF1"))
delete o;
507 TString FileName = Form(
"%s/%s_Amplitude_Lib%d.fit",DirName.Data(),
fCrystalName.Data(),LibNbr);
510 CurrentCanvas->Paint();
511 CurrentCanvas->Update();
513 for(
int HistNbr=0 ; HistNbr<
fNC+
fNSg ; HistNbr++)
516 CurrentCanvas->cd(MyMadPos.
PadNmbr);
524 cout<<
"Calibration File write in: "<<FileName<<
endl;
527 CurrentCanvas->Paint();
528 CurrentCanvas->Update();
538 cout<<
"[ERROR] Source not define ==> s + s to define the source "<<
endl;
545 TList *ListOfPrimitives = (TList*) gPad->GetListOfPrimitives();
547 if(ListOfPrimitives->GetSize()>0)
549 TIter iter(ListOfPrimitives);
552 while( (o = iter()) )
554 if(o->InheritsFrom(
"TF1"))
delete o;
557 std::stringstream StoredOutput;
559 std::streambuf* NormalOutput = std::cout.rdbuf(StoredOutput.rdbuf());
564 if(HistAndLib==-1)
return;
566 int LibNbr = HistAndLib/1000;
567 int HistNbr = HistAndLib - LibNbr*1000;
584 for(
size_t i=0 ; i<FitResults.size() ; i++)
586 Fitted FitRes = FitResults[i];
588 if(!FitRes.
good)
continue;
594 f->SetParameter(1,FitRes.
BgFrom);
595 f->SetParameter(2,FitRes.
BgTo);
596 f->SetParameter(3,FitRes.
BgdOff);
599 if(xmin == -1) xmin = FitRes.
BgFrom;
606 f->SetParameter(5+j*6+0,FitRes.
ampli);
607 f->SetParameter(5+j*6+1,FitRes.
posi);
608 f->SetParameter(5+j*6+2,FitRes.
fwhm);
609 f->SetParameter(5+j*6+3,FitRes.
Lambda);
610 f->SetParameter(5+j*6+4,FitRes.
Rho);
611 f->SetParameter(5+j*6+5,FitRes.
S);
618 FitRes = FitResults[i];
630 std::cout.rdbuf(NormalOutput);
636 while (std::getline(StoredOutput, line,
'\n'))
640 if(MyLine==
"")
continue;
641 if((MyLine.BeginsWith(
"# ") || MyLine==
"#") && PrintHeader)
643 if(MyLine.BeginsWith(
"# indx"))MyLine.ReplaceAll(
"indx",
" lib");
647 else if(MyLine.BeginsWith(
"#") && !MyLine.BeginsWith(
"# ") && MyLine!=
"#")
651 else if(!MyLine.BeginsWith(
"#"))
653 if(MyLine.Length()>20)
655 MyLine.Replace(5,1,Form(
"%d",LibNbr));
656 if(HistNbr==0) MyLine.Replace(11,2,
" 0");
657 else MyLine.Replace(11,2,Form(
"%2.0d",HistNbr));
672 cout<<
"Global channel range redefined to [ "<<ChFrom<<
";"<<ChTo<<
"]"<<
endl;
681 cout<<
"Channel range of hist n°"<<SpecNbr<<
", library "<<lib<<
" redefined to [ "<<ChFrom<<
";"<<ChTo<<
"]"<<
endl;
690 cout<<
"Global peak limits redefined to FWHM < "<<DefFWHM<<
" ; Ampli > "<<DefAmpli<<
endl;
699 cout<<
"Peak limits for hist n°"<<SpecNbr<<
", library "<<lib<<
" redefined to FWHM < "<<FWHM<<
" ; Ampli > "<<Ampli<<
endl;
707 TList *ListOfPrimitives = (TList*) gPad->GetListOfPrimitives();
709 if(ListOfPrimitives->GetSize()>0)
711 TIter iter(ListOfPrimitives);
715 while( (o = iter()) )
723 if(HistName.Contains(
"Ampli"))
725 TObjArray *loa=HistName.Tokenize(
"_");
726 int LibNbr = ((TString)((TObjString*)loa->At(loa->GetEntries()-2))->GetString()).Atoi();
727 int HistNbr = ((TString)((TObjString*)loa->At(loa->GetEntries()-1))->GetString()).Atoi();
729 HistAndLib = 1000*LibNbr+HistNbr;
737 TString CanvasName = gPad->GetCanvas()->GetName();
738 if(CanvasName.Index(
"Lib")>=0)
740 int LibNbr = CanvasName.Replace(0,CanvasName.Index(
"Lib")+3,
"").Atoi();
741 HistAndLib = -1000*LibNbr;
746 cout<<
"Not able to evaluate the library number. Probably no multipad drawn. Default library (1) taken."<<
endl;
749 HistAndLib = -1000*LibNbr;
763 if(HistAndLib<0)
return;
765 int LibNbr = HistAndLib/1000;
766 int HistNbr = HistAndLib - LibNbr*1000;
777 if(HistAndLib<0)
return;
779 int LibNbr = HistAndLib/1000;
780 int HistNbr = HistAndLib - LibNbr*1000;
799 if( eventType == kKeyPress )
802 if((EKeySym)eventX == kKey_f && (EKeySym)eventY == kKey_f)
804 if((EKeySym)eventX == kKey_f-96 && (EKeySym)eventY == kKey_f)
810 if((EKeySym)eventY == kKey_l && (EKeySym)eventX == kKey_l && (EKeySym)
fLasteventY == kKey_c && (EKeySym)
fLasteventX == kKey_c)
812 if((EKeySym)eventX == kKey_l-96 && (EKeySym)eventY == kKey_l && (EKeySym)
fLasteventX == kKey_c-96 && (EKeySym)
fLasteventY == kKey_c)
816 if((EKeySym)eventY == kKey_l && (EKeySym)eventX == kKey_l && (EKeySym)
fLasteventY == kKey_p && (EKeySym)
fLasteventX == kKey_p )
818 if((EKeySym)eventX == kKey_l-96 && (EKeySym)eventY == kKey_l && (EKeySym)
fLasteventX == kKey_p-96 && (EKeySym)
fLasteventY == kKey_p)
822 if((EKeySym)eventY == kKey_s && (EKeySym)eventX == kKey_s && (EKeySym)
fLasteventY == kKey_s && (EKeySym)
fLasteventX == kKey_s )
824 cout<<
"List of available sources (more than one allowed): 22Na 40K 56Co 57Co 60Co 88Y 133Ba 134Cs 137Cs 152Eu 208Pb 226Ra 241Am"<<
endl;
834 if((EKeySym)eventY == kKey_c && (EKeySym)eventX == kKey_c && (EKeySym)
fLasteventY == kKey_p && (EKeySym)
fLasteventX == kKey_p )
850 TString Opt = SourcesNames;
851 TObjArray *token = Opt.Tokenize(
",");
852 TObject *a_token = 0x0;
856 while ( (a_token = iter()) )
858 TString name = a_token->GetName();
873 gPad->GetCanvas()->cd(1);
875 int LibNbr = abs(HistAndLib/1000);
877 TString CalibFileName = Form(
"FitResults/GWRecal/%s/%s_Amplitude_Lib%d.fit",
fRunName.Data(),
fCrystalName.Data(),LibNbr);
878 ifstream CalibFile(CalibFileName);
879 if(!CalibFile.is_open())
882 cout<<
"File: "<<CalibFileName<<
" not found"<<
endl;
883 cout<<
"Crystal "<<
fCrystalName <<
" has not yet been calibrated... exit"<<
endl;
892 bool TreeInitialized =
false;
895 getline(CalibFile,Line);
898 TObjArray *token = Buffer.Tokenize(
" ");
899 TObject *a_token = 0x0;
902 if(Buffer.Contains(
"==> Reference peak for extended printouts"))
904 ERef = ((TString)((TObject*)token->At(2))->GetName()).Atof();
908 if(Buffer.BeginsWith(
"# lib"))
911 while ( (a_token = iter()) )
913 TString name = a_token->GetName();
914 if(name !=
"" && name !=
"#")
916 name.ReplaceAll(
"%",
"");
917 name.ReplaceAll(
"#",
"");
918 name.ReplaceAll(
"slope*gain",
"slope");
919 fCalibResultsTree->Branch(Form(
"%s",name.Data()), &Values[col],Form(
"%s/D",name.Data()));
921 TreeInitialized =
true;
925 if(!Buffer.BeginsWith(
"#") && Buffer !=
"" && TreeInitialized)
928 while ( (a_token = iter()) )
930 TString name = a_token->GetName();
931 Values[col] = name.Atof();
951 cout<<
" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "<<
endl;
952 cout<<
"|*******************************************************************************************************************************************************************|"<<
endl;
953 cout<<
"|**| |**|"<<
endl;
954 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
955 cout<<
"|**|-------------------------------------------------------- Help on the calibration results plotter --------------------------------------------------------|**|"<<
endl;
956 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
957 cout<<
"|**| |**|"<<
endl;
958 cout<<
"|**| --> Plot is made from a TTree containing all the fit parameters values. |**|"<<
endl;
959 cout<<
"|**| The plot mechanisms are thus the one of a TTree: Draw(\"varexp\", \"selection\", \"option\"). |**|"<<
endl;
960 cout<<
"|**| |**|"<<
endl;
961 cout<<
"|**| --> If varexp is entered as any observable versus the segment ID (ex: varexp = \"FW05:spec\"), a specific TH1 is drawn with the value of the observable |**|"<<
endl;
962 cout<<
"|**| on the Y axis and the Segment ID on the X axis |**|"<<
endl;
963 cout<<
"|**| |**|"<<
endl;
964 cout<<
"|**| --> In all other cases, the plot is drawn using the TTree plot utilities. |**|"<<
endl;
965 cout<<
"|**| |**|"<<
endl;
966 cout<<
"|**| |**|"<<
endl;
967 cout<<
"|**| --> The name of the histogram is the one entered (ex: varexp = \"FW05:spec>>HistName\"), |**|"<<
endl;
968 cout<<
"|**| --> If no name is entered (ex: varexp = \"FW05:spec\"), name is deduced to avoid identical names |**|"<<
endl;
969 cout<<
"|**| |**|"<<
endl;
970 cout<<
"|**| |**|"<<
endl;
971 cout<<
"|**| List of the printables values: |**|"<<
endl;
972 cout<<
"|**| | lib | spec | pks | ok | ERef | rEnergy | FW05 | FW01 | Area | Position | Width | Ampli | WTML | WTMR | slope | rChi2 | |**|"<<
endl;
973 cout<<
"|**| |**|"<<
endl;
974 cout<<
"|*******************************************************************************************************************************************************************|"<<
endl;
975 cout<<
" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ "<<
endl;
1015 while( (index = test.Index(
":")) != -1 )
1017 test.Replace(index,1,
"");
1022 TString HistNameSave;
1025 bool SpecialPlot =
false;
1026 if(
PlotVarExp.Contains(
":spec") && dim==2) SpecialPlot =
true;
1034 HistName.Replace(0,HistName.Index(
">>")+2,
"");
1035 if(HistName.Contains(
"(")) HistName.Replace(HistName.Index(
"("),HistName.Length()-HistName.Index(
"("),
"");
1037 Observable.Replace(Observable.Index(
":spec"),Observable.Length()-Observable.Index(
":spec"),
"");
1041 Observable =
PlotVarExp.Copy().ReplaceAll(
":spec",
"");
1042 HistName =
fCrystalName + Form(
"_Lib%d_",LibNbr) + Observable;
1050 HistName.Replace(0,HistName.Index(
">>")+2,
"");
1051 if(HistName.Contains(
"(")) HistName.Replace(HistName.Index(
"("),HistName.Length()-HistName.Index(
"("),
"");
1052 HistNameSave = HistName;
1057 Observable =
PlotVarExp.Copy().ReplaceAll(
":",
"_vs_");
1058 HistName =
fCrystalName + Form(
"_Lib%d_",LibNbr) + Observable;
1063 HistName.Append(
"_0");
1064 while(gPad->FindObject(HistName) || gROOT->FindObjectAny(HistName))
1066 HistName.ReplaceAll(Form(
"%s_%d",Observable.Data(),n),Form(
"%s_%d",Observable.Data(),n+1));
1069 PlotVarExp.ReplaceAll(HistNameSave,HistName);
1072 TString CanvasName = Form(
"Canvas_%s_%s_Lib%d_%s",
fRunName.Data(),
fCrystalName.Data(),LibNbr,Observable.Data());
1077 CanvasName = Form(
"Canvas_%s_Lib%d_%s",
fRunName.Data(),LibNbr,Observable.Data());
1078 c = (TCanvas*)gROOT->FindObject(CanvasName);
1087 if(!
PlotVarOpt.Contains(
"same",TString::kIgnoreCase))
1089 c = (TCanvas*)gROOT->FindObject(CanvasName);
1091 else c =
new TCanvas(CanvasName,CanvasName);
1095 c = gPad->GetCanvas();
1098 for(
int k=0 ; k<gPad->GetListOfPrimitives()->GetSize() ; k++)
1100 if(gPad->GetListOfPrimitives()->At(k)->InheritsFrom(
"TH1"))col++;
1109 gStyle->SetOptTitle(1);
1110 gStyle->SetOptStat(0);
1112 TH1F *h =
new TH1F(HistName,((TString)Observable +
" distribution, crystal " +
fCrystalName),38,0,38);
1113 h->GetYaxis()->SetTitle(Observable);
1115 for(
int i=0 ; i<38 ; i++)
1119 h->GetXaxis()->SetBinLabel(i+1,p.
SegName);
1123 TSQLRow *Row = Res->Next();
1124 if(Row)h->SetBinContent(i+1,((TString)Row->GetField(0)).Atof());
1127 h->SetLineColor(HistColor);
1136 TH1 *h = (TH1*)gPad->FindObject(HistName);
1137 if(h)h->SetLineColor(HistColor);
1148 cout<<
" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "<<
endl;
1149 cout<<
"|*******************************************************************************************************************************************************************|"<<
endl;
1150 cout<<
"|**| |**|"<<
endl;
1151 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1152 cout<<
"|**| ---------------------------------------------------------------------- Calibration ---------------------------------------------------------------------|**|"<<
endl;
1153 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1154 cout<<
"|**| |**|"<<
endl;
1155 cout<<
"|**| FitAll() ==> Analysis of all spectra drawn in the current Canvas | |**|"<<
endl;
1156 cout<<
"|**| FitSelectedRecal() ==> Analysis of the spectrum drawn in the selected pad | |**|"<<
endl;
1157 cout<<
"|**| SpecificFit(NHist, FirstHist, Step) ==> Analysis of NHist from seg nbr FirstHist with a step of Step | Def val = 38,0,1 |**|"<<
endl;
1158 cout<<
"|**| | |**|"<<
endl;
1159 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1160 cout<<
"|**| --------------------------------------------------------------------- Configuration ---------------------------------------------------------------------|**|"<<
endl;
1161 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1162 cout<<
"|**| |**|"<<
endl;
1163 cout<<
"|**| ----------------------------------------------------------------- Channel configuration ----------------------------------------------------------------|**|"<<
endl;
1164 cout<<
"|**| SetChannelOffset(Off) ==> Channel offset to subtract to the position of the peaks | Def val = 0 |**|"<<
endl;
1165 cout<<
"|**| SetGlobalChannelLimits(ChFrom, ChTo) ==> Limit the search to this range in channels | |**|"<<
endl;
1166 cout<<
"|**| SetHistChannelLimits(SpecNbr, lib, ChFrom, ChTo) ==> Limit the search to this range in channels for spec SpecNbr of lib library | |**|"<<
endl;
1167 cout<<
"|**| | |**|"<<
endl;
1168 cout<<
"|**| ------------------------------------------------------------ Theoretical Peaks configuration -----------------------------------------------------------|**|"<<
endl;
1169 cout<<
"|**| SetSource(fSourceName): List of available sources (more than one allowed; 60Co if nothing given) | |**|"<<
endl;
1170 cout<<
"|**| -−> 22Na 40K 56Co 57Co 60Co 88Y 133Ba 134Cs 137Cs 152Eu 208Pb 226Ra 241Am | |**|"<<
endl;
1171 cout<<
"|**| AddPeak(EPeak) ==> Add this energy to the list of lines (can be given more than once) | |**|"<<
endl;
1172 cout<<
"|**| RemoveClosestPeakTo(EPeak) ==> Remove the line closest to this energy from the list of lines | |**|"<<
endl;
1173 cout<<
"|**| SetRefPeak(EPeak) ==> Energy (keV) of the reference peak for extended printouts | |**|"<<
endl;
1174 cout<<
"|**| | |**|"<<
endl;
1175 cout<<
"|**| --------------------------------------------------------------- Peak search configuration --------------------------------------------------------------|**|"<<
endl;
1176 cout<<
"|**| SetGlobalPeaksLimits(DefFWHM, DefAmpli) ==> Default fwhm and minmum amplitude for the peaksearch | Def val = 15 5 |**|"<<
endl;
1177 cout<<
"|**| SetHistPeaksLimits(SpecNbr, lib, FWHM, Ampli) ==> Fwhm and minmum Amplitude for spec SpecNbr of lib library | |**|"<<
endl;
1178 cout<<
"|**| UseFirstDerivativeSearch() ==> Use the 1st-derivative search (default, always for 2-line sources) | |**|"<<
endl;
1179 cout<<
"|**| UseSecondDerivativeSearch ==> Use the 2nd-derivative search | |**|"<<
endl;
1180 cout<<
"|**| | |**|"<<
endl;
1181 cout<<
"|**| ---------------------------------------------------------------- BackGround configuration ---------------------------------------------------------------|**|"<<
endl;
1182 cout<<
"|**| UseFlatBackGround() ==> Use a flat function background to fit the peaks (default) | |**|"<<
endl;
1183 cout<<
"|**| UseAffineBackGround() ==> Use an affine function background to fit the peaks | |**|"<<
endl;
1184 cout<<
"|**| NoBackGround() ==> No background estimation to fit the peaks | |**|"<<
endl;
1185 cout<<
"|**| | |**|"<<
endl;
1186 cout<<
"|**| ------------------------------------------------------------------- Fit configuration ------------------------------------------------------------------|**|"<<
endl;
1187 cout<<
"|**| UnsetLeftTail() ==> Disable using the Left Tail in peak fit | |**|"<<
endl;
1188 cout<<
"|**| UnsetRightTail() ==> Disable using the Right Tail in peak fit | |**|"<<
endl;
1189 cout<<
"|**| UseLinearCalib() ==> add a fake peak at (0,0) to push calibration through origin | |**|"<<
endl;
1190 cout<<
"|**| UseAffineCalib() ==> affine calibration y = offset + slope*x | |**|"<<
endl;
1191 cout<<
"|**| UseParabolicCalib() ==> parabolic calibration y = offset + slope*x + curv*x*x | |**|"<<
endl;
1192 cout<<
"|**| SetGain(Gain) ==> scaling factor for the slope | Def val = 1 |**|"<<
endl;
1193 cout<<
"|**| | |**|"<<
endl;
1194 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1195 cout<<
"|**| -------------------------------------------------------------------- Verbose options --------------------------------------------------------------------|**|"<<
endl;
1196 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1197 cout<<
"|**| |**|"<<
endl;
1198 cout<<
"|**| PrintResForXTalk(VerboseMod) ==> Print results as when calculating xTalk coefficients mod==36/37/38 | |**|"<<
endl;
1199 cout<<
"|**| SetVerbosityLevel(Verb) ==> Verbosity bit0=fit_details, bit1=calib_details, bit2=more_calib_details | Def val = 0 |**|"<<
endl;
1200 cout<<
"|**| SetFullVerbosity() ==> Set full verbosity | |**|"<<
endl;
1201 cout<<
"|**| |**|"<<
endl;
1202 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1203 cout<<
"|**| -------------------------------------------------------------------- Plot fit results -------------------------------------------------------------------|**|"<<
endl;
1204 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1205 cout<<
"|**| |**|"<<
endl;
1206 cout<<
"|**| PlotCalibResults() ==> Plot the fit results using TTree utilities | |**|"<<
endl;
1207 cout<<
"|**| PrintPlotHelp() ==> Print a manual for the PlotCalibResults method | |**|"<<
endl;
1208 cout<<
"|**| |**|"<<
endl;
1209 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1210 cout<<
"|**| ---------------------------------------------------------------------- Hotkeys ---------------------------------------------------------------------|**|"<<
endl;
1211 cout<<
"|**|-------------------------------------------------------------------------------------------------------------------------------------------------------------|**|"<<
endl;
1212 cout<<
"|**| |**|"<<
endl;
1213 cout<<
"|**| Set source ==> s+s |**|"<<
endl;
1214 cout<<
"|**| Fit selected pad ==> f |**|"<<
endl;
1215 cout<<
"|**| Fit all pads ==> Ctrl pressed and f |**|"<<
endl;
1216 cout<<
"|**| Set channel limits for the selected pad ==> c+l |**|"<<
endl;
1217 cout<<
"|**| Set global channel limits ==> Ctrl pressed and c+l |**|"<<
endl;
1218 cout<<
"|**| Set peak limits for the selected pad ==> p+l |**|"<<
endl;
1219 cout<<
"|**| Set global peak limits ==> Ctrl pressed and p+l |**|"<<
endl;
1220 cout<<
"|**| Print help ==> p+h |**|"<<
endl;
1221 cout<<
"|**| Plot calibration results ==> p+c |**|"<<
endl;
1222 cout<<
"|**| |**|"<<
endl;
1223 cout<<
"|*******************************************************************************************************************************************************************|"<<
endl;
1224 cout<<
" ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ "<<
endl;
1239 TString OutDirGlob = ConfDirectory;
1243 TString Passwd =
"";
1245 if(OutDirGlob.Contains(
":/"))
1247 TObjArray *token = OutDirGlob.Tokenize(
":");
1248 OutDir = token->Last()->GetName();
1249 cout<<
"Enter password to access to "<<token->First()->GetName()<<
endl;
1255 OutDir = OutDirGlob;
1258 if(!gSystem->OpenDirectory(OutDir.Data()))
1261 cout<<OutDir<<
" not found"<<
endl;
1267 TSystemDirectory Dir;
1268 Dir.SetDirectory(OutDir);
1270 TList *ListOfFolders = Dir.GetListOfFiles();
1272 for(
int i=0 ; i<ListOfFolders->GetSize() ; i++)
1274 if(((TString)ListOfFolders->At(i)->GetName()).Length() != 3)
1276 ListOfFolders->RemoveAt(i);
1281 for(
int i= 0 ; i<ListOfFolders->GetSize() ; i++ )
1283 TString CrystalName = ListOfFolders->At(i)->GetName();
1284 TString ConfFilePath = OutDir +
"/" + CrystalName +
"/" +
"PreprocessingFilterPSA.conf";
1285 TString ConfFilePathTot = OutDirGlob +
"/" + CrystalName +
"/" +
"PreprocessingFilterPSA.conf";
1287 if(!gSystem->IsFileInIncludePath(ConfFilePath))
1290 cout<<
"No PreprocessingFilterPSA.conf found for crystal "<<CrystalName<<
endl;
1295 TString GWFile =
"FitResults/GWRecal/" +
fRunName +
"/" + CrystalName +
"_Amplitude_Lib1.fit";
1296 if(!gSystem->IsFileInIncludePath(GWFile))
1299 cout<<GWFile<<
" not found, test with lib 0"<<
endl;
1301 GWFile =
"FitResults/GWRecal/" +
fRunName +
"/" + CrystalName +
"_Amplitude_Lib0.fit";
1302 if(!gSystem->IsFileInIncludePath(GWFile))
1305 cout<<GWFile<<
" not found, crystal ignored"<<
endl;
1311 ifstream finAGATA(ConfFilePath);
1312 ifstream finGW(GWFile);
1314 ofstream fout(
"Calib_tmp");
1317 TString BufferAGATA;
1325 getline(finAGATA,lineAGATA);
1327 BufferAGATA = lineAGATA;
1329 if(BufferAGATA==
"")
break;
1331 TObjArray *token = BufferAGATA.Tokenize(
" ");
1332 TString CalibAGATA = ((TObject*)token->At(4))->GetName();
1338 while(GWSegNr!=segnbr)
1340 getline(finGW,lineGW);
1343 if(BufferGW.BeginsWith(
"#"))
continue;
1345 token = BufferGW.Tokenize(
" ");
1346 TString Seg = ((TObject*)token->At(1))->GetName();
1347 CalibGW = ((TObject*)token->At(13))->GetName();
1348 GWSegNr = Seg.Atoi();
1354 BufferAGATA.ReplaceAll(CalibAGATA,CalibGW);
1355 fout<<BufferAGATA<<
endl;
1361 getline(finAGATA,lineAGATA);
1363 BufferAGATA = lineAGATA;
1365 if(BufferAGATA==
"")
break;
1367 fout<<BufferAGATA<<
endl;
1375 if(Passwd !=
"" && gSystem->Which(gSystem->Getenv(
"PATH"),
"sshpass"))
1377 status=system(Form(
"sshpass -p %s scp Calib_tmp %s",Passwd.Data(),ConfFilePathTot.Data()));
1381 status=system(Form(
"scp Calib_tmp %s",ConfFilePathTot.Data()));
1382 status=system(
"rm Calib_tmp");
1386 cout<<ConfFilePath<<
" updated !"<<
endl;
GWRecal * fGWRecal
Recal Part.
void FitSelectedRecal(bool PrintHeader=true)
B) FitSelected.
std::vector< double > GetRightTailProp()
void SetHistChannelLimits(int SpecNbr, float ChFrom, float ChTo)
******************************************************************************************/// ...
virtual void WriteCalibFiles(const char *ConfDirectory="")
******************************************************************************************/// ...
virtual void ShowHist(int HistNumber, int LibraryNumber=1, bool same=false)
vector< PadPos > fHistPositionList
void SetThreshold(double t)
virtual void Exec(const char *option)
******************************************************************************************/// ...
std::vector< double > GetFWHMCal()
void SetGain(float Gain)
f) UseFlatBackGround
void SetHistPeaksLimits(int SpecNbr, float FWHM, float Ampli)
******************************************************************************************/// ...
void SetSelectedHistChannelLimits(int ChFrom=50, int ChTo=32768)
******************************************************************************************/// ...
std::vector< double > GetFWHM_10Cal()
int InitTree()
******************************************************************************************/// ...
FitFunctions * fFitFunction
std::vector< double > GetMean()
void SetGlobalChannelLimits(int ChFrom=50, int ChTo=32768)
b) SetChannelLimits
TList * fListOfLibrairies
void SetSource(TString SourceName)
void SetSelectedHistPeaksLimits(float FWHM=15, float Ampli=5)
******************************************************************************************/// ...
void FitSelectedRoot(const char *FitType="Dino", const char *source="60Co", bool all=false)
******************************************************************************************/// ...
void SearchPeak(int NPeaks=2, double width=50, double threshold=0.1, double xmin=0., double xmax=30000.)
******************************************************************************************/// ...
void SetGlobalChannelLimits(int ChFrom, int ChTo)
std::vector< double > GetArea()
void PrintPlotHelp()
******************************************************************************************/// ...
std::vector< double > GetLeftTailProp()
virtual void ShowSpectra(int LibraryNumber=1, const char *DrawOpt="")
******************************************************************************************/// ...
LoupOnPad, a class to Loupe on a Pad in a Canvas with many pads in it.
void SetPersoBackground(int NumberIterations=100, int Direction=TSpectrum::kBackDecreasingWindow, int FilterOrder=TSpectrum::kBackOrder8, bool Smoothing=true, int smoothingWindow=TSpectrum::kBackSmoothing3, bool Compton=false)
******************************************************************************************/// ...
static Bool_t OpenContextMenu(const char *method, TObject *obj, const char *alt_method_name="")
virtual void SetLoupe(bool loupeon=true)
void SetPersoBackground(int NumberIterations=100, int Direction=TSpectrum::kBackDecreasingWindow, int FilterOrder=TSpectrum::kBackOrder8, bool Smoothing=true, int smoothingWindow=TSpectrum::kBackSmoothing3, bool Compton=false)
TCanvas * BuildSegmentedCanvas(TString CanvasName, TString CanvasTitle)
std::vector< double > GetECal()
void SetGlobalPeaksLimits(float DefFWHM=15, float DefAmpli=5)
C) PeakSearch.
void GetPlotParams(const char *varexp="FW05:spec", const char *selection="", const char *option="")
******************************************************************************************/// ...
void SetGlobalPeaksLimits(float DefFWHM, float DefAmpli)
bool fDefinePersoBackground
void SetSource(const char *SourcesNames)
B) TheoreticalPeaks.
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject *select)
******************************************************************************************/// ...
Int_t fLasteventType
HandleMovement part.
void GetCurrentHistogram()
void FitAllRoot(const char *FitType="Dino", const char *source="60Co")
******************************************************************************************/// ...
ADF::LogMessage & endl(ADF::LogMessage &log)
int GetCurrentHistAndLib()
******************************************************************************************/// ...
vector< Fitted > GetFitResults()
virtual void ShowHist(int HistNumber, int LibraryNumber=1, bool same=false)
******************************************************************************************/// ...
void SpecificFit(int NbrOfSpectra=38, int FirstHist=0, int Step=1)
C) SpecificFit.
void SetSpectraFolder(TString name)
void PlotCalibResultsAsTreeLaucher()
******************************************************************************************/// ...
void SetHistNumber(int HistNbr)
void PlotCalibResultsAsTree(int LibNbr)
******************************************************************************************/// ...
RawAmpWatcher(const char *name, const char *title)
*/
TF1 * GetDinoFct(TString Name, double min, double max, int Npar)
******************************************************************************************/// ...
void FitAllRecal()
1) Calibration
TTree * fCalibResultsTree
void SetHistPeaksLimits(int SpecNbr=0, int lib=1, float FWHM=15, float Ampli=5)
b) SetHistPeaksLimits
void SetHistChannelLimits(int SpecNbr=0, int lib=1, int ChFrom=50, int ChTo=32768)
c) SetChannelLimits