24 #include "TGeoMatrix.h"
25 #include "TGToolTip.h"
28 #include "TObjArray.h"
29 #include "TPaveText.h"
30 #include "TPolyLine.h"
38 #include "TPaveStats.h"
40 #include "BashColor.h"
42 #include "TVirtualPad.h"
65 if ( !Watcher::GetFromTrigger(trigger,
"event:data:psa", fFrame) )
79 {
delete fPSAFrame; fPSAFrame = 0x0; }
92 if ( fFrame && fFrame->IsValid() ) {
93 fFrame->GetFrame()->Scan();
94 return fFrame->GetFrame()->GetNbSubFrame();
105 if ( !(which < GetNbFramePSA()) ) {
107 printf(
"EventPSAWatcher::GetDataPSA %d %d \n",which,GetNbFramePSA());
111 if ( !fFrame->GetFrame()->LinkSubFrame(which,fPSAFrame) ) {
113 printf(
"EventPSAWatcher::GetDataPSA cannot LinkSubFrame \n");
117 if( fPSAFrame->Read() == 0 ) {
119 printf(
"EventPSAWatcher::GetDataPSA cannot Read \n");
123 return GetDataPointer<PSAInterface>(fPSAFrame);
135 fSpectraDoppler(180),
139 fCoreCommonDoppler(0x0),
149 if ( fVertexBuilder == 0x0 )
150 std::cout <<
"Should not be NULL " <<
std::endl;
154 if ( gSystem->AccessPathName(
"CrystalPositionLookUpTable") ) {
155 if ( gSystem->AccessPathName(
"CrystalPositionLookUpTable.dat") ) {
156 fLog <<
error <<
" CrystalPositionLookUpTable required " <<
nline;
159 fLog <<
info <<
" Ge positions extracted from CrystalPositionLookUpTable.dat " <<
nline;
164 fLog <<
info <<
" Ge positions extracted from CrystalPositionLookUpTable.dat " <<
nline;
168 for (UInt_t i = 0u; i < gNbCrys; i++ ) {
170 TString
tmp; TH1F *h;
172 tmp = Form(
"Crystal_%d",i);
173 h = MakeTH1<TH1F>(tmp.Data(),
"Core energy of the crystal", 4096,0,4096);
176 tmp = Form(
"Crystal_track_%d",i);
177 h = MakeTH1<TH1F>(tmp.Data(),
"Core energy of the crystal", 4096,0,4096);
181 fCoreCommon = MakeTH1<TH1F>(
"CoreCommon",
"Core common spectrum",8192,0,4096);
182 fSumSpectra = MakeTH1<TH1F>(
"SumSpectra",
"Sum of all spectra",8192,0,4096);
183 fGxG = MakeTH2<TH2F>(
"GxG",
"Gamma Gamma Matrix",4096,0,4096,4096,0,4096);
184 fDistri = MakeTH1<TH1F>(
"CrystalDistri",
"Distribution of the crystal fired",180,0,180);
185 fPosXYZ = MakeTH3<TH3F>(
"PosXYZ",
"Distribution of hits in Space",100,-200,200,100,-200,200,100,-400,0);
189 fPosXYZ_Ta = MakeTH3<TH3F>(
"PosXYZ_Ta",
"Distribution of hits in Space with Target hit",200,-400,400,200,-400,400,200,-400,400);
193 fGxT = MakeTH2<TH2F>(
"GxT",
"Gamma Time Matrix",4096,0,4096,300,0,300);
195 fCoreCommonDoppler = MakeTH1<TH1F>(
"DCoreCommon",
"Core common spectrum with doppler correction",8192,0,4096);
196 fGxGDoppler = MakeTH2<TH2F>(
"DGxG",
"Gamma Gamma Matrix with doppler correction",4096,0,4096,4096,0,4096);
198 fFold = MakeTH1<TH1F>(
"Fold",
"Crystal Fold distributions",10,0,10);
214 Double_t px, py, pz, dx, dy, dz;
220 Double_t x = hit->
GetX() - px;
221 Double_t y = hit->
GetY() - py;
222 Double_t z = hit->
GetZ() - pz;
224 Double_t dd = x*x + y*y + z*z;
226 Double_t cosTheta = (x*dx + y*dy + z*dz)/::sqrt(dd);
227 e = VertexInterface::DopplerCorrection(e,beta,gamma,cosTheta);
240 c->Divide(4,4,0.001,0.001);
246 for(
int i=0 ; i<
fDistri->GetNbinsX() ; i++)
248 if(
fDistri->GetBinContent(i+1))
256 c =
NewCanvas(Form(
"HitSpectra_%d_%d",PadNbr+1,PadNbr+16));
257 c->Divide(4,4,0.001,0.001);
262 TCanvas *OverImposedCore =
NewCanvas(
"OverImposedCore");
263 OverImposedCore->cd();
264 bool FirstHist =
true;
265 for(
int i=0 ; i<
fDistri->GetNbinsX() ; i++)
279 TCanvas *GlobalSpectra =
NewCanvas(
"GlobalSpectra");
280 GlobalSpectra->Divide(1,2,0.001,0.001);
281 GlobalSpectra->cd(1);
284 TPad *pad =
new TPad(
"Crystal fold",
"Pad for Crystal fold distribution",0.7,0.6,1,1);
289 GlobalSpectra->cd(2);
298 Double_t xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal;
TrackedHitImp<EHit,EHit> gamma; Float_t gg[150], ggdc[150];
312 fFold->Fill(nb_frames);
314 double SumEnergy = 0.;
316 for(UInt_t i = 0u; i <nb_frames; i++) {
319 gg[i] = data->
GetE();
322 h->Fill(data->
GetE());
326 SumEnergy += data->
GetE();
333 Double_t max_e = 0.0;
339 for (UShort_t j = 0u; j < nHits; ++j) {
343 pHit->
GetXYZ(xLocal, yLocal, zLocal);
349 fPosXYZ->Fill(xGlobal, yGlobal, zGlobal);
352 if ( pHit->
GetE() > max_e ) {
353 gamma.
SetXYZ(xGlobal, yGlobal, zGlobal);
354 max_e = pHit->
GetE();
365 else ggdc[i] = gg[i];
370 for(UInt_t i = 0u; i <nb_frames; i++) {
371 for(UInt_t j = i+1; j <nb_frames; j++) {
984 if ( fVertexBuilder == 0x0 )
985 std::cout <<
"Should not be NULL " <<
std::endl;
987 if ( gSystem->AccessPathName(
"CrystalPositionLookUpTable") ) {
988 if ( gSystem->AccessPathName(
"CrystalPositionLookUpTable.dat") ) {
989 fLog <<
error <<
" CrystalPositionLookUpTable required " <<
nline;
992 fLog <<
info <<
" Ge positions extracted from CrystalPositionLookUpTable.dat " <<
nline;
997 fLog <<
info <<
" Ge positions extracted from CrystalPositionLookUpTable.dat " <<
nline;
1001 for (UInt_t i = 0u; i < gNbCrys; i++ ) {
1003 TString
tmp; TH1F *h;
1005 tmp = Form(
"Crystal_%d",i);
1006 h = MakeTH1<TH1F>(tmp.Data(),
"Core energy of the crystal", 4096,0,4096);
1009 fCoreCommon = MakeTH1<TH1F>(
"CoreCommon",
"Core common spectrum",8192,0,4096);
1010 fSumSpectra = MakeTH1<TH1F>(
"SumSpectra",
"Sum of all core spectra",8192,0,4096);
1011 fGxG = MakeTH2<TH2F>(
"GxG_HG",
"Gamma Gamma Matrix (High gain)",4096,0,4096,4096,0,4096);
1012 fDistri = MakeTH1<TH1F>(
"CrystalDistri",
"Distribution of the crystal fired",gNbCrys,0,gNbCrys);
1013 fPosXYZ_Ta = MakeTH3<TH3F>(
"PosXYZ_Ta",
"Distribution of hits in Space with Target hit",200,-400,400,200,-400,400,200,-400,400);
1014 fGxT = MakeTH2<TH2F>(
"GxT_LG",
"Gamma Time Matrix (Low gain)",4096,0,4096,300,0,300);
1015 fFold = MakeTH1<TH1F>(
"Fold",
"Crystal Fold distributions",20,0,20);
1033 TString Name = Form(
"EB_CrystSpectra_%d_%d",PadNbr+1,PadNbr+16);
1034 TString Title =
"Crystal of the hited crystals at the event builder level";
1040 c->Divide(4,4,0.001,0.001);
1042 double topmarg = 0.0679612;
1043 double rightmarg = 0.0121951;
1044 double leftmarg = 0.0983588;
1045 double bottommarg = 0.11165;
1048 gPad->SetRightMargin(rightmarg);
1049 gPad->SetTopMargin(topmarg);
1050 gPad->SetLeftMargin(leftmarg);
1051 gPad->SetBottomMargin(bottommarg);
1053 fDistri->SetBit(TH1::kNoTitle);
1055 fDistri->GetXaxis()->SetTitle(
"Crystal ID");
1056 fDistri->GetXaxis()->SetLabelSize(0.05);
1057 fDistri->GetXaxis()->SetTitleSize(0.06);
1058 fDistri->GetXaxis()->SetTitleOffset(0.85);
1060 fDistri->GetYaxis()->SetTitle(
"Counts");
1061 fDistri->GetYaxis()->SetLabelSize(0.05);
1062 fDistri->GetYaxis()->SetTitleSize(0.06);
1063 fDistri->GetYaxis()->SetTitleOffset(0.90);
1072 TPaveStats *st = (TPaveStats*)
fDistri->FindObject(
"stats");
1075 st->SetX2NDC(1-rightmarg);
1076 st->SetY2NDC(1-topmarg);
1077 st->SetX1NDC(0.681013);
1078 st->SetY1NDC(0.663962);
1083 for(
int i=0 ; i<
fDistri->GetNbinsX() ; i++)
1085 if(
fDistri->GetBinContent(i+1))
1089 Name = Form(
"EB_CrystSpectra_%d_%d",PadNbr+1,PadNbr+16);
1093 c->Divide(4,4,0.001,0.001);
1101 gPad->SetRightMargin(rightmarg);
1102 gPad->SetTopMargin(topmarg);
1103 gPad->SetLeftMargin(leftmarg);
1104 gPad->SetBottomMargin(bottommarg);
1106 h->SetBit(TH1::kNoTitle);
1108 h->GetXaxis()->SetTitle(
"Energy (keV)");
1109 h->GetXaxis()->SetLabelSize(0.05);
1110 h->GetXaxis()->SetTitleSize(0.06);
1111 h->GetXaxis()->SetTitleOffset(0.85);
1113 h->GetYaxis()->SetTitle(
"Counts");
1114 h->GetYaxis()->SetLabelSize(0.05);
1115 h->GetYaxis()->SetTitleSize(0.06);
1116 h->GetYaxis()->SetTitleOffset(0.90);
1125 st = (TPaveStats*)h->FindObject(
"stats");
1128 st->SetX2NDC(1-rightmarg);
1129 st->SetY2NDC(1-topmarg);
1130 st->SetX1NDC(0.681013);
1131 st->SetY1NDC(0.663962);
1144 TString Name =
"EB_SuperimposedCores";
1145 TString Title =
"Superposition of the core spectra at the event builder level";
1149 double topmarg = 0.00240964;
1150 double rightmarg = 0.00120919;
1151 double leftmarg = 0.0719468;
1152 double bottommarg = 0.0843373;
1155 gPad->SetRightMargin(rightmarg);
1156 gPad->SetTopMargin(topmarg);
1157 gPad->SetLeftMargin(leftmarg);
1158 gPad->SetBottomMargin(bottommarg);
1160 bool FirstHist =
true;
1166 double deltaYLeg = 0.035;
1169 for(
int i=0 ; i<
fDistri->GetNbinsX() ; i++)
1174 h->SetTitle(Form(
"Crystal %d",i));
1179 h->SetBit(TH1::kNoTitle);
1181 h->GetXaxis()->SetTitle(
"Energy (keV)");
1182 h->GetXaxis()->SetLabelSize(0.04);
1183 h->GetXaxis()->SetTitleSize(0.04);
1184 h->GetXaxis()->SetTitleOffset(1.);
1186 h->GetYaxis()->SetTitle(
"Counts");
1187 h->GetYaxis()->SetLabelSize(0.04);
1188 h->GetYaxis()->SetTitleSize(0.04);
1189 h->GetYaxis()->SetTitleOffset(1.);
1193 leg =
new TLegend(0.874849,1-topmarg-deltaYLeg,1-rightmarg,1-topmarg,
"",
"NDC");
1194 leg->SetMargin(0.4);
1195 leg->AddEntry(h,h->GetTitle(),
"l");
1204 leg->AddEntry(h,h->GetTitle(),
"l");
1218 leg->SetY1NDC(leg->GetY1NDC()-n*deltaYLeg);
1226 TString Name =
"EB_CommonVsSum";
1227 TString Title =
"Core common spectra compared to sum spectra at the event builder level";
1233 c->Divide(1,2,0.001,0.001);
1235 double topmarg = 0.0657599;
1236 double rightmarg = 0.00726832;
1237 double leftmarg = 0.0490612;
1238 double bottommarg = 0.114119;
1242 for(
int i=0 ; i<2 ; i++)
1246 gPad->SetRightMargin(rightmarg);
1247 gPad->SetTopMargin(topmarg);
1248 gPad->SetLeftMargin(leftmarg);
1249 gPad->SetBottomMargin(bottommarg);
1256 htemp->SetStats(
false);
1257 htemp->GetXaxis()->SetTitle(
"Energy (keV)");
1258 htemp->GetXaxis()->SetTitleSize(0.06);
1259 htemp->GetXaxis()->SetLabelSize(0.06);
1260 htemp->GetXaxis()->SetTitleOffset(0.91);
1262 htemp->GetYaxis()->SetTitle(
"Counts");
1263 htemp->GetYaxis()->SetTitleSize(0.06);
1264 htemp->GetYaxis()->SetLabelSize(0.06);
1265 htemp->GetYaxis()->SetTitleOffset(0.45);
1270 TPaveStats *st = (TPaveStats*)htemp->FindObject(
"stats");
1273 st->SetX2NDC(1-rightmarg);
1274 st->SetY2NDC(1-topmarg);
1277 TPaveText *txt = (TPaveText*)gPad->FindObject(
"title");
1280 double width = txt->GetY2NDC()-txt->GetY1NDC();
1281 txt->SetY2NDC(1-topmarg);
1282 txt->SetY1NDC(txt->GetY2NDC()-width);
1287 TPad *pad =
new TPad(
"Crystal fold",
"Crystal fold distribution",0.7,0.6,1-rightmarg-0.0025,1-topmarg-0.005);
1288 pad->SetRightMargin(0.00486268);
1289 pad->SetTopMargin(0.00912681);
1290 pad->SetLeftMargin(0.0736404);
1291 pad->SetBottomMargin(0.195208);
1296 fFold->SetStats(
false);
1297 fFold->GetXaxis()->SetTitle(
"Crystal Fold");
1298 fFold->GetXaxis()->SetTitleSize(0.08);
1299 fFold->GetXaxis()->SetLabelSize(0.08);
1301 fFold->GetYaxis()->SetTitle(
"Counts");
1302 fFold->GetYaxis()->SetTitleSize(0.08);
1303 fFold->GetYaxis()->SetLabelSize(0.08);
1304 fFold->GetYaxis()->SetTitleOffset(0.5);
1311 double topmarg = 0.00240964;
1312 double rightmarg = 0.00120919;
1313 double leftmarg = 0.0719468;
1314 double bottommarg = 0.0843373;
1318 gPad->SetRightMargin(rightmarg);
1319 gPad->SetTopMargin(topmarg);
1320 gPad->SetLeftMargin(leftmarg);
1321 gPad->SetBottomMargin(bottommarg);
1328 fCoreCommon->GetXaxis()->SetTitle(
"Energy (keV)");
1345 TLegend *leg =
new TLegend(0.756348,0.870486,1-rightmarg,1-topmarg,
"Core common VS Sum spectra",
"NDC");
1356 TString Name =
"EB_GammaGamma";
1357 TString Title =
"Gamma Gamma matrix at the event builder level";
1361 double topmarg = 0.0156627;
1362 double rightmarg = 0.00120919;
1363 double leftmarg = 0.0719468;
1364 double bottommarg = 0.0843373;
1366 gPad->SetRightMargin(rightmarg);
1367 gPad->SetTopMargin(topmarg);
1368 gPad->SetLeftMargin(leftmarg);
1369 gPad->SetBottomMargin(bottommarg);
1371 fGxG->SetBit(TH2::kNoTitle);
1372 fGxG->GetXaxis()->SetTitle(
"Energy #gamma_{1} (keV)");
1373 fGxG->GetYaxis()->SetTitle(
"Energy #gamma_{2} (keV)");
1380 TPaveStats *st = (TPaveStats*)
fGxG->FindObject(
"stats");
1383 st->SetX2NDC(1-rightmarg);
1384 st->SetY2NDC(1-topmarg);
1392 TString Name =
"EB_GammaTime";
1393 TString Title =
"Gamma Time matrix at the event builder level";
1397 double topmarg = 0.0156627;
1398 double rightmarg = 0.00120919;
1399 double leftmarg = 0.0719468;
1400 double bottommarg = 0.0843373;
1402 gPad->SetRightMargin(rightmarg);
1403 gPad->SetTopMargin(topmarg);
1404 gPad->SetLeftMargin(leftmarg);
1405 gPad->SetBottomMargin(bottommarg);
1407 fGxT->SetBit(TH2::kNoTitle);
1408 fGxT->GetXaxis()->SetTitle(
"Energy low gain (keV)");
1409 fGxT->GetYaxis()->SetTitle(
"Time low gain (ns)");
1416 TPaveStats *st = (TPaveStats*)
fGxT->FindObject(
"stats");
1419 st->SetX2NDC(1-rightmarg);
1420 st->SetY2NDC(1-topmarg);
1428 TString Name =
"EB_3DHits";
1429 TString Title =
"3D Hits for the whole array with target vertex ";
1445 cout <<
"non valid frame" <<
endl;
1455 fFold->Fill(nb_frames);
1457 double SumEnergy = 0.;
1459 for(UInt_t i = 0u; i <nb_frames; i++) {
1462 gg[i] = data->
GetE();
1465 h->Fill(data->
GetE());
1469 SumEnergy += data->
GetE();
1476 Double_t max_e = 0.0;
1482 for (UShort_t j = 0u; j < nHits; ++j) {
1486 pHit->
GetXYZ(xLocal, yLocal, zLocal);
1490 if ( pHit->
GetE() > max_e ) {
1491 gamma.
SetXYZ(xGlobal, yGlobal, zGlobal);
1492 max_e = pHit->
GetE();
1499 for(UInt_t i = 0u; i <nb_frames; i++) {
1500 for(UInt_t j = i+1; j <nb_frames; j++) {
1502 fGxG->Fill(gg[i],gg[j]);
fGxG->Fill(gg[j],gg[i]);
1518 fTotalHistPos = fTSWindow/fDeltaTS+1;
1519 fGraphPos = fTotalHistPos+1;
1521 if(fTSWindow%fDeltaTS != 0)
1523 cout<<
"Time stamp window is not a entire step TS factor"<<
endl;
1527 fListOfHists =
new TList();
1529 for (Int_t i = 0; i < gNbCrys; i++ )
1531 Int_t Id = GetCrystalId(CrystalNames[i]);
1533 fLastFitResultCore[Id][0] = 100;
1534 fLastFitResultCore[Id][1] = fERef;
1535 fLastFitResultCore[Id][2] = 2;
1540 fTSMax[Id] = (Double_t)fDeltaTS*60;
1544 fSpectra[Id] = MakeTH1<TH1F>(Form(
"Cry%.3d_%s",Id,CrystalNames[i].
Data()),
"Core energy for the crystal", 8000,0,4000);
1548 f_TS_Dist[Id] = BuildArray(Form(
"TS_%.3d_%s",Id,CrystalNames[i].
Data()),15*24*(60/fDeltaTS),0,15*24*3600.,
false);
1550 f_CoreCheck[Id] = BuildArray(Form(
"CoreCheck_%.3d_%s",Id,CrystalNames[i].
Data()),8000,0,4000,
true);
1552 fGausFuncCry[Id] =
new TF1(Form(
"gaus_%.3d_%s",Id,CrystalNames[i].
Data()),
"gaus");
1554 ((TGraph*)f_CoreCheck[Id]->At(fGraphPos))->SetPoint(0,0,fERef);
1556 fCoreLines[Id] =
new TLine;
1557 fCoreLines[Id]->SetLineColor(kRed);
1558 fCoreLines[Id]->SetLineStyle(2);
1559 fCoreLines[Id]->SetLineWidth(2);
1561 fLastFittedHist[Id] = 0x0;
1562 fLastFitFunction[Id] = 0x0;
1566 if(fCrystalListForSegments.Contains(CrystalNames[i]))
1568 for (Int_t j = 0u; j < gNbSeg; j++ )
1570 fLastFitResultSeg[Id][j][0] = 100;
1571 fLastFitResultSeg[Id][j][1] = fERef;
1572 fLastFitResultSeg[Id][j][2] = 2;
1574 f_SegCheck[Id][j] = BuildArray(Form(
"SegCheck_%.3d_%s_Seg_%d",Id,CrystalNames[i].
Data(),j),8000,0,4000,
true);
1575 fGausFuncSeg[Id][j] =
new TF1(Form(
"gaus_%.3d_%s_Seg_%d",Id,CrystalNames[i].
Data(),j),
"gaus");
1581 void TimeCheckBuilder::ReadConfFile()
1583 ifstream ConfFile(
"TimeChecks.conf");
1590 getline(ConfFile,Line);
1593 if(Buffer.BeginsWith(
"#"))
1596 if(Buffer.BeginsWith(
"ERef="))
1598 Buffer.ReplaceAll(
"ERef=",
"").ReplaceAll(
" ",
"");
1599 fERef = Buffer.Atof();
1601 if(Buffer.BeginsWith(
"CrystalList="))
1603 Buffer.ReplaceAll(
"CrystalList=",
"");
1604 fCrystalList = Buffer;
1606 TObjArray *arr = Buffer.Tokenize(
" ");
1607 gNbCrys = arr->GetEntries();
1609 for(
int i=0 ; i<gNbCrys ; i++)
1610 CrystalNames[i] = arr->At(i)->GetName();
1614 if(Buffer.BeginsWith(
"CrystalListForSegments="))
1616 Buffer.ReplaceAll(
"CrystalListForSegments=",
"");
1617 fCrystalListForSegments = Buffer;
1619 if(Buffer.BeginsWith(
"DeltaTS="))
1621 Buffer.ReplaceAll(
"DeltaTS=",
"").ReplaceAll(
" ",
"");
1622 fDeltaTS = Buffer.Atoi();
1624 if(Buffer.BeginsWith(
"TSWindow="))
1626 Buffer.ReplaceAll(
"TSWindow=",
"").ReplaceAll(
" ",
"");
1627 fTSWindow=Buffer.Atoi();
1629 if(Buffer.BeginsWith(
"NToFill="))
1631 Buffer.ReplaceAll(
"NToFill=",
"").ReplaceAll(
" ",
"");
1632 fNToFill=Buffer.Atoi();
1639 cout<<
"Reference gamma energy to follow : "<<fERef<<
"keV"<<
endl;
1640 cout<<
"Crystals wich are followed only at the core level : "<<endl<<fCrystalList<<
endl;
1641 cout<<
"Crystals wich are followed at the segment level : "<<endl<<fCrystalListForSegments<<
endl;
1642 cout<<
"Delta TS in min : "<<fDeltaTS<<
" min"<<
endl;
1643 cout<<
"Total integrated window in min : "<<fTSWindow<<
"min"<<
endl;
1644 cout<<
"Minimum number of DeltaT wich needs to contains data to analyse the total integrated window histogram : "<<fNToFill<<
endl;
1649 TString TimeCheckBuilder::GetCrystalName(Int_t cry)
1651 Int_t Ctemp = cry/3;
1659 Name = Form(
"%.2dA",C);
1661 Name = Form(
"%.2dB",C);
1663 Name = Form(
"%.2dC",C);
1668 Int_t TimeCheckBuilder::GetCrystalId(TString Name)
1674 if(Name.Contains(
"A"))
1676 if(Name.Contains(
"B"))
1678 if(Name.Contains(
"C"))
1681 Name.Remove(Name.Length()-1,1);
1683 Ctemp = Name.Atoi();
1698 cout <<
"non valid frame" <<
endl;
1702 if(fGoodInit==
false)
1708 for(UInt_t i = 0u; i <nb_frames; i++)
1712 Int_t CryId = data->
GetUID();
1714 TString Name = GetCrystalName(CryId);
1718 if(!fCrystalList.Contains(Name))
1721 h = (TH1F *)fSpectra[CryId];
1723 h->Fill(data->
GetE());
1727 if(fLastTS[CryId] == 0)
1729 fFirstTS[CryId] = fTS;
1730 fLastTS[CryId] = fTS;
1734 Double_t TimeInSec = ((Double_t)fTS-(Double_t)fFirstTS[CryId])*1e-8;
1736 if(TimeInSec<fTSMax[CryId])
1738 ((TH1F*)f_TS_Dist[CryId]->At(0))->Fill(TimeInSec);
1739 ((TH1F*)f_CoreCheck[CryId]->At(0))->Fill(data->
GetE());
1741 if(fCrystalListForSegments.Contains(Name))
1745 for(
int ihit=0 ; ihit<NHits ; ihit++)
1748 Int_t SegId = hit->
GetID(0);
1749 Float_t SegE = hit->
GetE();
1751 ((TH1F*)f_SegCheck[CryId][SegId]->At(0))->Fill(SegE);
1757 ReProcessHists(CryId);
1759 Int_t NFill = GetNFill(CryId);
1761 if(NFill >= fNToFill)
1763 AnalyseGraphs(CryId);
1768 fTSMax[CryId] = (Double_t)TimeInSec+fDeltaTS*60;
1772 fTSMax[CryId] += fDeltaTS*60;
1778 void TimeCheckBuilder::AnalyseGraphs(Int_t cry)
1780 TH1F *X_Hist = ((TH1F*)f_TS_Dist[cry]->At(fTotalHistPos));
1782 TString CryName = GetCrystalName(cry);
1784 for(
int i=0 ; i<fListOfHists->GetSize() ; i++)
1786 TObjArray *arr = (TObjArray*)fListOfHists->At(i);
1788 if(arr->GetEntries()==fGraphPos+1)
1790 TGraph *gr = (TGraph*)arr->At(fGraphPos);
1792 TH1F *Y_Hist = ((TH1F*)arr->At(fTotalHistPos));
1793 TString
tmp = Y_Hist->GetName();
1795 if(Y_Hist->GetEntries()<1000 || !tmp.Contains(CryName))
1798 TString BaseName = gr->GetName();
1800 if(BaseName.Contains(
"CoreCheck"))
1802 Y_Hist->GetXaxis()->SetRangeUser(fLastFitResultCore[cry][1]-10,fLastFitResultCore[cry][1]+10);
1804 Double_t Norm = fLastFitResultCore[cry][0];
1805 Float_t Mean = Y_Hist->GetBinCenter(Y_Hist->GetMaximumBin());
1806 Float_t Sigma = fLastFitResultCore[cry][2];
1808 fGausFuncCry[cry]->SetParameters(Norm,Mean,Sigma);
1814 fGausFuncCry[cry]->SetParLimits(0,0,TMath::Max(Y_Hist->GetMaximum(),Norm)*1.2);
1815 fGausFuncCry[cry]->SetParLimits(1,Mean-2,Mean+2);
1816 fGausFuncCry[cry]->SetParLimits(2,0,10);
1818 Y_Hist->Fit(fGausFuncCry[cry],
"Q0",
"",Mean-2,Mean+2);
1820 fLastFitResultCore[cry][0] = fGausFuncCry[cry]->GetParameter(0);
1821 fLastFitResultCore[cry][1] = fGausFuncCry[cry]->GetParameter(1);
1822 fLastFitResultCore[cry][2] = fGausFuncCry[cry]->GetParameter(2);
1824 if(gr->GetN() && gr->GetX()[0]==0)
1827 gr->SetPoint(gr->GetN(), X_Hist->GetMean(), fLastFitResultCore[cry][1]);
1829 fCoreLines[cry]->SetX1(gr->GetX()[0]);
1830 fCoreLines[cry]->SetX2(gr->GetX()[gr->GetN()-1]);
1832 Double_t max = TMath::MaxElement(gr->GetN(),gr->GetY());
1833 Double_t min = TMath::MinElement(gr->GetN(),gr->GetY());
1835 gr->SetMaximum(TMath::Max(max+gr->GetRMS(2),fERef+gr->GetRMS(2)));
1836 gr->SetMinimum(TMath::Min(min-gr->GetRMS(2),fERef-gr->GetRMS(2)));
1839 if(fLastFittedHist[cry] == 0x0)
1841 fLastFittedHist[cry] = (TH1F*)Y_Hist->Clone();
1842 fLastFitFunction[cry] = (TF1*)fGausFuncCry[cry]->Clone();
1846 fLastFittedHist[cry]->Reset();
1847 fLastFittedHist[cry]->Add(Y_Hist);
1849 fLastFittedHist[cry]->GetXaxis()->SetRangeUser(fLastFitResultCore[cry][1]-5*fLastFitResultCore[cry][2],fLastFitResultCore[cry][1]+5*fLastFitResultCore[cry][2]);
1851 fLastFitFunction[cry]->SetParameters(fGausFuncCry[cry]->GetParameters());
1852 fLastFitFunction[cry]->SetRange(Mean-2,Mean+2);
1855 else if(BaseName.Contains(
"SegCheck"))
1857 TObjArray *arr = BaseName.Tokenize(
"_");
1858 Int_t SegId = ((TString)arr->At(5)->GetName()).Atoi();
1861 Y_Hist->GetXaxis()->SetRangeUser(fLastFitResultSeg[cry][SegId][1]-10,fLastFitResultSeg[cry][SegId][1]+10);
1863 Double_t Norm = fLastFitResultSeg[cry][SegId][0];
1864 Float_t Mean = Y_Hist->GetBinCenter(Y_Hist->GetMaximumBin());
1865 Float_t Sigma = fLastFitResultSeg[cry][SegId][2];
1868 fGausFuncCry[cry]->SetParameters(Norm,Mean,Sigma);
1874 fGausFuncCry[cry]->SetParLimits(0,0,TMath::Max(Y_Hist->GetMaximum(),Norm)*1.2);
1875 fGausFuncCry[cry]->SetParLimits(1,Mean-2,Mean+2);
1876 fGausFuncCry[cry]->SetParLimits(2,0,5);
1879 Y_Hist->Fit(fGausFuncCry[cry],
"Q0",
"",Mean-2,Mean+3);
1881 fLastFitResultSeg[cry][SegId][0] = fGausFuncCry[cry]->GetParameter(0);
1882 fLastFitResultSeg[cry][SegId][1] = fGausFuncCry[cry]->GetParameter(1);
1883 fLastFitResultSeg[cry][SegId][2] = fGausFuncCry[cry]->GetParameter(2);
1886 gr->SetPoint(gr->GetN(), X_Hist->GetMean(), fLastFitResultSeg[cry][SegId][1]);
1892 Int_t TimeCheckBuilder::GetNFill(Int_t cry)
1895 for(
int i=1 ; i<fTotalHistPos ; i++)
1897 TH1F *htemp = ((TH1F*)f_TS_Dist[cry]->At(i));
1898 if(htemp->GetEntries()>0) n++;
1904 void TimeCheckBuilder::ReProcessHists(Int_t cry)
1906 TString CryName = GetCrystalName(cry);
1908 for(
int i=0 ; i<fListOfHists->GetSize() ; i++)
1910 TObjArray *arr = (TObjArray*)fListOfHists->At(i);
1912 TString tmp = ((TH1F*)arr->At(fTotalHistPos))->GetName();
1913 if(!tmp.Contains(CryName))
1916 ((TH1F*)arr->At(fTotalHistPos))->Reset();
1918 for(
int i=fTSWindow/fDeltaTS ; i>0 ; i--)
1920 ((TH1F*)arr->At(i))->Reset();
1921 ((TH1F*)arr->At(i))->
Add(((TH1F*)arr->At(i-1)));
1922 ((TH1F*)arr->At(fTotalHistPos))->
Add(((TH1F*)arr->At(i)));
1925 ((TH1F*)arr->At(0))->Reset();
1929 TObjArray *TimeCheckBuilder::BuildArray(
const char * BaseName,Int_t NBins, Double_t Min, Double_t Max, Bool_t MakeGraph)
1931 TObjArray *arr =
new TObjArray(2+fTotalHistPos+MakeGraph);
1933 arr->Add(
new TH1F(Form(
"%s_PreLoad_%dmin",BaseName,fDeltaTS),Form(
"%s_PreLoad_%dmin",BaseName,fDeltaTS),NBins,Min,Max));
1935 for(
int i=1 ; i<=fTSWindow/fDeltaTS ; i++) arr->Add(
new TH1F(Form(
"%s_%d-%dmin",BaseName,(i-1)*fDeltaTS,i*fDeltaTS),Form(
"%s_%d-%dmin",BaseName,(i-1)*fDeltaTS,i*fDeltaTS),NBins,Min,Max));
1937 arr->Add(
new TH1F(Form(
"%s_%dMin",BaseName,fTSWindow),Form(
"%s_%dMin",BaseName,fTSWindow),NBins,Min,Max));
1941 TGraph *gr =
new TGraph();
1942 gr->SetNameTitle(Form(
"Mean_%s_vs_Time",BaseName),Form(
"Mean_%s_vs_Time",BaseName));
1943 gr->SetMarkerStyle(20);
1944 gr->SetMarkerColor(2);
1945 gr->GetXaxis()->SetLabelSize(0.06);
1946 gr->GetYaxis()->SetLabelSize(0.06);
1951 folder->Add((TObject *)gr);
1955 fListOfHists->Add(arr);
1966 TString Name = Form(
"EB_TimeCheckBuilder_%d",PadNbr+1);
1967 TString Title =
"TimeCheckBuilder at the event builder level";
1976 Int_t NPads = Nx*Ny;
1978 c->Divide(Nx,Ny,0.001,0.001);
1980 double topmarg = 0.0679612;
1981 double rightmarg = 0.0121951;
1982 double leftmarg = 0.0983588;
1983 double bottommarg = 0.11165;
1985 for(
int i=0 ; i<gNbCrys ; i++)
1987 Int_t ID = GetCrystalId(CrystalNames[i]);
1993 if(PadNbr%NPads==0 && PadNbr!=0)
1995 Name = Form(
"EB_TimeCheckBuilder_%d",PadNbr+1);
1999 c->Divide(Nx,Ny,0.001,0.001);
2002 c->cd(PadNbr%NPads+1);
2004 gPad->SetRightMargin(rightmarg);
2005 gPad->SetTopMargin(topmarg);
2006 gPad->SetLeftMargin(leftmarg);
2007 gPad->SetBottomMargin(bottommarg);
2009 TGraph *gr = ((TGraph*)f_CoreCheck[ID]->At(fGraphPos));
2015 fCoreLines[ID]->SetX1(gPad->GetFrame()->GetX1());
2016 fCoreLines[ID]->SetX2(gPad->GetFrame()->GetX2());
2017 fCoreLines[ID]->SetY1(fERef);
2018 fCoreLines[ID]->SetY2(fERef);
2019 fCoreLines[ID]->Draw(
"same");
2033 TString Name = Form(
"EB_TimeCheck_LastFit_%d",PadNbr+1);
2034 TString Title =
"last fit of TimeCheckBuilder at the event builder level";
2043 Int_t NPads = Nx*Ny;
2045 c->Divide(Nx,Ny,0.001,0.001);
2047 double topmarg = 0.0679612;
2048 double rightmarg = 0.0121951;
2049 double leftmarg = 0.0983588;
2050 double bottommarg = 0.11165;
2052 for(
int i=0 ; i<gNbCrys ; i++)
2054 Int_t ID = GetCrystalId(CrystalNames[i]);
2056 if(fLastFittedHist[ID] == 0x0)
2062 if(PadNbr%NPads==0 && PadNbr!=0)
2064 Name = Form(
"EB_TimeCheck_LastFit_%d",PadNbr+1);
2068 c->Divide(Nx,Ny,0.001,0.001);
2071 c->cd(PadNbr%NPads+1);
2073 gPad->SetRightMargin(rightmarg);
2074 gPad->SetTopMargin(topmarg);
2075 gPad->SetLeftMargin(leftmarg);
2076 gPad->SetBottomMargin(bottommarg);
2078 fLastFittedHist[ID]->Draw(
"hist");
2079 fLastFitFunction[ID]->Draw(
"same");
2096 TString CrystalName = crystal_name;
2098 if(!fCrystalListForSegments.Contains(crystal_name))
2101 cout<<
"Crystal "<<crystal_name<<
" is not included in the list of crystals to check"<<
endl;
2106 TString Name =
"TimeCheck_PSA_Spectra_" + CrystalName;
2107 TString Title =
"TimeCheck of crystal " + CrystalName +
"at the post psa level";
2109 Int_t CryId = GetCrystalId(CrystalName);
2113 if(c == 0x0)
return;
2117 for(
int i=0 ; i<CrystalInterface::kNbSegments ; i++)
2121 TPad *pad = (TPad*)c->cd(HistPosition.
PadNmbr);
2122 pad->SetFillStyle(0);
2123 pad->SetFrameFillStyle(0);
2125 TGraph *gr = (TGraph*)f_SegCheck[CryId][i]->At(fGraphPos);
2127 TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject(
"InfoPad");
2129 TString NameTitle = ((TString)gr->GetName()) +
"_" + HistPosition.
SegName;
2131 gr->SetNameTitle(NameTitle,NameTitle);
2140 for(
int i=1 ; i<CrystalInterface::kNbCores ; i++)
2144 TPad *pad = (TPad*)c->cd(HistPosition.
PadNmbr);
2145 pad->SetFillStyle(0);
2146 pad->SetFrameFillStyle(0);
2148 TGraph *gr = (TGraph*)f_CoreCheck[CryId]->At(fGraphPos);
2150 TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject(
"InfoPad");
2152 TString NameTitle = ((TString)gr->GetName()) +
"_" + HistPosition.
SegName;
2154 gr->SetNameTitle(NameTitle,NameTitle);
virtual const Key * GetSubKey(UInt_t) const =0
Returns one of the sub-key in case this is a composite frame.
virtual void SetLoupe(bool loupeon=true)
virtual ~EBWatcher()
******************************************************************************************/// ...
virtual Bool_t IsValid() const
true if it is a valid pointer
virtual void GetDirection(Double_t &, Double_t &, Double_t &, Double_t=0.0) const =0
get the direction of the source (last argument is used in case the position depends on time) ...
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
virtual VertexInterface * GetVertex()
Get the vertex data interface.
virtual UShort_t GetNbHits() const =0
To know the number of Hits currently on the stack.
printf("******************************************************************** \n")
virtual void Add(TTask *)
add only Watchers to the list of tasks to avoid problems.
virtual Frame * GetFrame() const
UInt_t GetNbFramePSA()
number of PSA Frames extracted from the current event
virtual Double_t GetY() const
TCanvas * NewCanvas(Option_t *)
It creates a new embedded canvas.
void Show3DHits()
******************************************************************************************/// ...
static MainFrameFactory & theMainFactory()
the main (global) keyfactory
void ShowCrystalSpectra()
LogMessage & error(LogMessage &)
virtual void Exec(Option_t *option="")
watch the current frame
void ShowSuperimposedCores()
******************************************************************************************/// ...
virtual Frame * New(const FactoryItem &key_item, const FactoryItem &frame_item)
just a frame
TH1 * fCoreCommon
Sum of all core spectra (without Doppler correction)
virtual void GetPosition(Double_t &, Double_t &, Double_t &, Double_t=0.0) const =0
get the position of the source (last argument is used in case the position depends on time) ...
TFolder * GetSubFolder(TFolder *topfolder, const Char_t *sub="")
for a new histogram, it returns the folder it belongs to. It creates sub and all intermediates if req...
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
Set the trigger attached to this watcher.
TH1F * fDistri
Crystal fold.
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
EBWatcher(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
void ShowCrystalLastFits()
virtual DFAgent * GetDFAgent()=0
to get the Data Flow Agent in charge of knowing the structure of the DF
TObject * AddToPool(TObject *ob)
facility for other watchers: keep a list of all histograms (objects) for global operations ...
TFolder * fTopFolder
Top folder in which ae stored all spectra.
virtual ~HitsSpectra()
******************************************************************************************/// ...
void ShowGammaTime()
******************************************************************************************/// ...
TCanvas * NewCanvas(TString cname, TString ctitle)
virtual void Exec(Option_t *option="")
watch the current frame
virtual Double_t GetT(UInt_t=0u) const =0
to get the time associated to the core
LogMessage & nline(LogMessage &)
AgataGeometryTransformer * fTrans
TObjArray fSpectra
Core energy for any crystal.
virtual Double_t GetE() const
static ConfAgent * theGlobalAgent(std::string="Agata")
to get the global agent
AgataGeometryTransformer * fTrans
virtual Double_t GetBeta(Double_t=0.0) const =0
get recoil velocity
TObjArray fSpectraDoppler
TH1F * fDistri
Crystal fold.
ClassImp(EventPSAWatcher)
void ShowCoreVsSumSpectra(bool OnSamePad=false)
******************************************************************************************/// ...
TObjArray fSpectra
Core energy for any crystal.
void ShowCrystalSpectra()
******************************************************************************************/// ...
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
TimeCheckBuilder(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
HitsSpectra(const char *name, const char *title, TDirectory *sp_dir=0x0, TDirectory *tag_dir=0x0)
*/
Base class for version numbers.
LoupOnPad, a class to Loupe on a Pad in a Canvas with many pads in it.
header file for AgataKeyFactory.cpp
TCanvas * BuildSegmentedCanvas(TString CanvasName, TString CanvasTitle)
virtual void Exec(Option_t *option="")
watch the current frame
TH1 * fCoreCommon
Sum of all core spectra (without Doppler correction)
void SetItem(const Char_t *whichfactory, const Char_t *whichitem, Version itemversion, Short_t factversion=-1, void *ptr=0x0)
to change an item
virtual void SetXYZ(Double_t x, Double_t y, Double_t z)
virtual void SetE(Double_t e)
void ShowSegments(const char *CrystalName)
It is a hit associated to a list of Hits.
! Show rates (counts) per Crystal *!
virtual Double_t GetX() const
FactoryItem WhichKnownKey(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
header file for DFAgent.cpp
PSAInterface * GetDataPSA(UInt_t which)
To get one by one the PSA Frames in one event (It fills fFramePSA). Read has beed called ! ...
virtual Double_t GetGamma(Double_t=0.0) const
*********************************** HitsSpectra Class **************************************/// ...
virtual Int_t GetID(Int_t which_id=0) const
get crystal/segment id. if which_id > 0, get crystal ID.
virtual Double_t DoDopplerCorrection(const TrackedHit *hit, VertexInterface *vertex)
Do Doppler taking into account additionnal offset of the agata position (see SetAgataOffset) ...
Base class for a trigger on a data flow.
ADF::LogMessage & endl(ADF::LogMessage &log)
TH1 * fCoreCommonDoppler
Sum of all core spectra (with Doppler correction)
virtual Double_t GetZ() const
void ShowGammaGamma()
******************************************************************************************/// ...
SharedFP * fFrame
main frame i.e. event:data:psa
Concrete implementation of a tracked Hit.
*********************************** EventPSAWatcher Class **************************************/// ...
virtual Hit * GetHit(UShort_t)=0
To get back a particular Hit (already on the stack !)
FactoryItem WhichKnownFrame(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
To get the exact definition of a key and a Frame.
virtual void GetXYZ(Double_t &x, Double_t &y, Double_t &z) const
virtual void SetLoupe(bool loupeon=true)
Base class that described an item in a Factory.
static VertexBuilder * theCurrentVertexBuilder()
to get the current VertexWatcher (for other watchers) i.e. the last one registered.