30 #include <Riostream.h>
32 #include <TGraphErrors.h>
34 #include <TFileMerger.h>
35 #include <TMultiGraph.h>
40 #include <TGridCollection.h>
42 #include <TGridResult.h>
43 #include <TClonesArray.h>
44 #include <TObjString.h>
59 if (fTrigger==
"EMC") file =
"/scratch/alicehp2/germain/QA/"+period+
"/"+ pass +
"/runlist.txt" ;
60 else file =
"/scratch/alicehp2/germain/QA/"+period+
"/"+ pass +
"/runlistMB.txt" ;
63 pFile = fopen(file.Data(),
"r");
66 cout <<
" fcalo: " << fCalorimeter <<
"; period: " << period <<
"; pass: " << pass <<
" trigger "<<fTrigger<< endl;
67 char outfilename [100] ;
80 ncols = fscanf(pFile,
"%d %d ",&p,&q);
89 const Int_t nRun = nlines ;
108 TDirectoryFile * dir;
116 TH3D * fhNCellsPerCluster ;
121 TH2F * NCellsPerCluster[n];
138 Double_t CellPerClusterMeanSM[n][nRun] ;
139 Double_t CellPerClusterRMSSM[n][nRun] ;
144 TString namefile =
"/scratch/alicehp2/germain/QA/"+period+
"/"+pass+
"/"+ fCalorimeter + period + pass + fTrigger+
"data.txt";
146 fstream QAData(namefile, ios::out);
148 cout <<
" namefile " << namefile << endl;
149 cout <<
" nRun " << nRun <<
" index(nRun) " << index[nRun-1] << endl;
151 for(
Int_t i = 0 ; i < nRun ; i++){
155 TString name =
"/scratch/alicehp2/germain/QA/"+period +
"/"+ pass +
"/";
159 f = TFile::Open(name.Data(),
"read") ;
164 if(fTrigger==
"EMC"){ dir = (TDirectoryFile *)f->Get(
"CaloQA_EMC7");
165 outputList = (
TList*)dir->Get(
"CaloQA_EMC7");
168 dir = (TDirectoryFile *)f->Get(
"CaloQA_default");
169 outputList = (
TList*)dir->Get(
"CaloQA_default");
175 fhNEvents =(TH1F *)outputList->FindObject(
"hNEvents");
176 nEvent[i]=fhNEvents->GetEntries();
177 cout <<
" Run " << RunId[i]<<
" nevent " << nEvent[i]<< endl;
178 if( nEvent[i] == 0) continue ;
179 if( nEvent[i] < 2) continue ;
180 fhE = (TH1F *)outputList->FindObject(fCalorimeter+
"_hE");
184 for(
Int_t ibin = fhE->FindBin(0.3) ; ibin <fhE->FindBin(50.) ; ibin++){
185 energy+=fhE->GetBinCenter(ibin)*fhE->GetBinContent(ibin);
187 EtotalMean[i]=energy/fhE->Integral(fhE->FindBin(0.3), fhE->FindBin(50.)) ;
188 EtotalRMS[i]=fhE->GetMeanError();
193 for(
Int_t ism = 0 ; ism < n ; ism++){
194 TString nameNCell = Form(
"%s_hNCells_Mod%d",fCalorimeter.Data(),ism);
196 TString nameNCluster = Form(
"%s_hNClusters_Mod%d",fCalorimeter.Data(),ism);
197 TString nameNCellPerCluster = Form(
"%s_hNCellsPerCluster_Mod%d",fCalorimeter.Data(),ism);
198 TString nameE = Form(
"%s_hE_Mod%d",fCalorimeter.Data(),ism);
200 NCells[ism] = (TH1F*)outputList->FindObject(nameNCell.Data());
201 NClusters[ism] = (TH1F*)outputList->FindObject(nameNCluster.Data());
202 NCellsPerCluster[ism] = (
TH2F*)outputList->FindObject(nameNCellPerCluster.Data());
203 E[ism] = (TH1F*)outputList->FindObject(nameE.Data());
204 CellMeanSM[ism][i]=NCells[ism]->GetMean();
205 CellRMSSM[ism][i]=NCells[ism]->GetMeanError();
206 ClusterMeanSM[ism][i]=NClusters[ism]->GetMean();
207 ClusterRMSSM[ism][i]=NClusters[ism]->GetMeanError();
208 CellPerClusterMeanSM[ism][i]=NCellsPerCluster[ism]->GetMean(2);
209 CellPerClusterRMSSM[ism][i]=NCellsPerCluster[ism]->GetMeanError(2);
211 ECell1MeanSM[ism][i] =NCellsPerCluster[ism]->ProjectionX(
"",2,300,
"")->Integral(5,100)/(nEvent[i]);
212 ECell1RMSSM[ism][i] =NCellsPerCluster[ism]->ProjectionX(
"",2,300,
"")->GetMeanError();
214 for(
Int_t ibin = E[ism]->FindBin(0.3) ; ibin <E[ism]->FindBin(50.) ; ibin++){
215 energySM+=E[ism]->GetBinCenter(ibin)*(E[ism]->GetBinContent(ibin));
217 EtotalMeanSM[ism][i]=energySM/(E[ism]->Integral(E[ism]->FindBin(0.3),E[ism]->FindBin(50.)));
219 EtotalRMSSM[ism][i]=E[ism]->GetMeanError();
222 fhNCells = (TH1F*)NCells[ism]->Clone(
"NCells");
223 fhNClusters = (TH1F*)NClusters[ism]->Clone(
"NClusters");
226 fhNCells->Add(NCells[ism],1);
227 fhNClusters->Add(NClusters[ism],1);
230 ClusterMean[i]=fhNClusters->GetMean();
231 ClusterRMS[i]=fhNClusters->GetMeanError();
232 CellMean[i]=fhNCells->GetMean();
233 CellRMS[i]=fhNCells->GetMeanError();
234 outputList->Clear() ;
244 QAData <<i+1<<
" "<< RunId[i] <<
" "<< nEvent[i]
265 TString base =
"/scratch/alicehp2/germain/QA/";
272 TString ClusterAverages ; ClusterAverages = base +
"ClusterAverages.gif";
273 TString Entries ; Entries = base +
"Nentries.gif";
274 TString ClusterAveragesEnergy ; ClusterAveragesEnergy = base +
"ClusterAveragesEnergy.gif";
275 TString ClusterAveragesEntries ; ClusterAveragesEntries = base +
"ClusterAveragesEntries.gif";
276 TString ClusterAveragesCells ; ClusterAveragesCells = base +
"ClusterAveragescells.gif";
279 cout <<
"c11 nEvents" << endl;
282 cout <<
" index(0)" << index[nRun-1] <<
" index(20) " << index[20] <<endl;
283 TH1F * dummy =
new TH1F(
"dummy",
"dummy", nRun, 0., nRun+0.5);
285 dummy->SetTitle(
"") ;
286 dummy->SetStats(kFALSE) ;
287 dummy->SetAxisRange(0., nRun,
"X") ;
289 for(
Int_t i = 0 ; i < nRun ; i++){
292 cout <<
" run "<< RunId[i] <<
" label " <<label << endl;
294 dummy->GetXaxis()->SetBinLabel(i+1,label.Data());
295 dummy->GetXaxis()->LabelsOption(
"v");
301 TCanvas * c11 =
new TCanvas(
"nEvents",
"nEvents", 1000, 500);
302 c11->SetFillColor(0);
303 c11->SetBorderSize(0);
304 c11->SetFrameBorderMode(0);
305 gStyle->SetOptStat(0);
309 dummy->GetXaxis()->SetTitleOffset(0.05);
310 dummy->GetYaxis()->SetTitle(
"N_{events}");
311 dummy->SetMinimum(1.) ;
312 dummy->SetMaximum(1.e6) ;
315 nEvents->SetMarkerStyle(20);
316 nEvents->SetMarkerColor(1);
317 nEvents->SetLineColor(2);
318 nEvents->Draw(
"same PL") ;
322 if (fTrigger==
"MB")sprintf(outfilename,
"nEventMB.gif");
323 if (fTrigger==
"EMC")sprintf(outfilename,
"nEventEMC.gif");
326 c11->SaveAs(Entries);
329 cout <<
"c1 Aver NCell" << endl;
331 TCanvas * c1 =
new TCanvas(
"AverNCell",
"AverNCell", 600, 600);
334 c1->SetBorderSize(0);
335 c1->SetFrameBorderMode(0);
336 gStyle->SetOptStat(0);
337 TH1F * h1 = (TH1F*)dummy->Clone(
"");
338 h1->GetXaxis()->SetTitle(
"RUN Index");
339 h1->GetYaxis()->SetTitle(
"<N_{cells}>");
341 h1->SetMaximum(10.) ;
342 if(fCalorimeter==
"EMCAL") h1->SetMaximum(5.) ;
347 AverNcells->SetMarkerColor(1);
348 AverNcells->SetMarkerStyle(20);
349 AverNcells->Draw(
"same P") ;
350 for(
Int_t ism = 0 ; ism < n ; ism++){
351 AverNcellsSM[ism] =
new TGraphErrors(nRun, x, CellMeanSM[ism], xe, CellRMSSM[ism]);
352 AverNcellsSM[ism]->SetMarkerColor(ism+2);
353 AverNcellsSM[ism]->SetMarkerStyle(21+ism);
354 AverNcellsSM[ism]->Draw(
"same P");
359 TLegend * l1 =
new TLegend(0.4, 0.6, 0.75, 0.85);
361 l1->SetBorderSize(0);
362 l1->SetTextSize(0.02);
363 l1->AddEntry(AverNcells,
"<# of cells>",
"") ;
364 l1->AddEntry(AverNcells, Form(
"det = %s",fCalorimeter.Data()),
"") ;
365 l1->AddEntry(AverNcells,
"average",
"p");
366 for(
Int_t ism = 0 ; ism < n ; ism++){
367 TString projname = Form(
"SM_ %d",ism);
368 l1->AddEntry(AverNcellsSM[ism],projname.Data(),
"p");
374 TCanvas * c200 =
new TCanvas(
"ClusterAverages",
"ClusterAverages", 1000, 500);
375 c200->SetFillColor(0);
376 c200->SetBorderSize(0);
377 c200->SetFrameBorderMode(0);
380 gPad->SetLeftMargin(0.08);
381 gPad->SetRightMargin(0.02);
384 TH1F * h2 = (TH1F*)dummy->Clone(
"");
386 h2->GetYaxis()->SetTitle(
"<N_{clusters}>/event");
388 if (fTrigger==
"EMC") h2->SetMaximum(70) ;
389 else h2->SetMaximum(50) ;
394 AverNclusters->SetMarkerStyle(20);
395 AverNclusters->SetMarkerColor(1);
396 AverNclusters->Draw(
"same P") ;
398 for(
Int_t ism = 0 ; ism < n ; ism++){
399 AverNclustersSM[ism] =
new TGraphErrors(nRun, x, ClusterMeanSM[ism], xe, ClusterRMSSM[ism]);
400 AverNclustersSM[ism]->SetMarkerColor(ism+2);
401 AverNclustersSM[ism]->SetMarkerStyle(21+ism);
403 AverNclustersSM[ism]->Draw(
"same P");
407 TLegend * l200 =
new TLegend(0.4, 0.6, 0.75, 0.85);
408 l200->SetFillColor(0);
409 l200->SetBorderSize(0);
410 l200->SetTextSize(0.02);
411 l200->AddEntry(AverNclusters,
"<# of clusters>",
"") ;
412 l200->AddEntry(AverNclusters, Form(
"det = %s",fCalorimeter.Data()),
"") ;
413 l200->AddEntry(AverNclusters,
"average",
"p");
415 for(
Int_t ism = 0 ; ism < n ; ism++){
416 TString projname = Form(
"SM_ %d",ism);
417 l200->AddEntry(AverNclustersSM[ism],projname.Data(),
"p");
422 c200->SaveAs(ClusterAveragesEntries);
424 TCanvas * c201 =
new TCanvas(
"ClusterAveragesEnergy",
"ClusterAveragesEnergy", 1000, 500);
425 c201->SetFillColor(0);
426 c201->SetBorderSize(0);
427 c201->SetFrameBorderMode(0);
431 gPad->SetLeftMargin(0.08);
432 gPad->SetRightMargin(0.02);
436 TH1F * h3 = (TH1F*)dummy->Clone(
"");
438 h3->GetYaxis()->SetTitle(
"<E> (GeV)");
439 h3->SetMinimum(0.2) ;
444 AverE->SetMarkerStyle(20);
445 AverE->SetMarkerColor(1);
446 AverE->Draw(
"same P");
448 for(
Int_t ism = 0 ; ism < n ; ism++){
449 AverESM[ism] =
new TGraphErrors(nRun, x, EtotalMeanSM[ism], xe, EtotalRMSSM[ism]);
450 AverESM[ism]->SetMarkerColor(ism+2);
451 AverESM[ism]->SetMarkerStyle(21+ism);
452 AverESM[ism]->Draw(
"same P");
456 TLegend * l3 =
new TLegend(0.4, 0.6, 0.75, 0.85);
458 l3->SetBorderSize(0);
459 l3->SetTextSize(0.02);
460 l3->AddEntry(AverE,
"<E>",
"") ;
461 l3->AddEntry(AverE, Form(
"det = %s",fCalorimeter.Data()),
"") ;
462 l3->AddEntry(AverE,
"average",
"p");
464 for(
Int_t ism = 0 ; ism < n ; ism++){
465 TString projname = Form(
"SM_ %d",ism);
466 l3->AddEntry(AverESM[ism],projname.Data(),
"p");
471 c201->SaveAs(ClusterAveragesEnergy);
474 TCanvas * c202 =
new TCanvas(
"ClusterAveragesCells",
"ClusterAveragesCells", 1000, 500);
475 c202->SetFillColor(0);
476 c202->SetBorderSize(0);
477 c202->SetFrameBorderMode(0);
480 gPad->SetLeftMargin(0.08);
481 gPad->SetRightMargin(0.02);
486 TH1F * h4 = (TH1F*)dummy->Clone(
"");
488 h4->GetYaxis()->SetTitle(
"<N_{CellsPerCluster}>");
489 h4->SetMinimum(1.5) ;
490 h4->SetMaximum(5.5) ;
495 AverCellPerCluster->SetMarkerStyle(20);
496 AverCellPerCluster->SetMarkerColor(1);
498 for(
Int_t ism = 0 ; ism < n ; ism++){
499 AverNcellsPerClusterSM[ism] =
new TGraphErrors(nRun, x, CellPerClusterMeanSM[ism], xe, CellPerClusterRMSSM[ism]);
500 AverNcellsPerClusterSM[ism]->SetMarkerColor(ism+2);
501 AverNcellsPerClusterSM[ism]->SetMarkerStyle(21+ism);
502 AverNcellsPerClusterSM[ism]->Draw(
"same P");
506 TLegend * l4 =
new TLegend(0.4, 0.6, 0.75, 0.85);
508 l4->SetBorderSize(0);
509 l4->SetTextSize(0.02);
510 l4->AddEntry(AverCellPerCluster,
"<# of cells per cluster>",
"") ;
511 l4->AddEntry(AverCellPerCluster, Form(
"det = %s",fCalorimeter.Data()),
"") ;
512 l4->AddEntry(AverCellPerCluster,
"average",
"p");
514 for(
Int_t ism = 0 ; ism < n ; ism++){
515 TString projname = Form(
"SM_ %d",ism);
516 l4->AddEntry(AverNcellsPerClusterSM[ism],projname.Data(),
"p");
521 c202->SaveAs(ClusterAveragesCells);
void trendingCluster(TString fCalorimeter="EMCAL", TString period="LHC11h", TString pass="pass1_HLT", const Int_t n=10, TString fTrigger="MB")