adding scripts and macros for V0 automatic QA and trending
authormgermain <marie.germain@subatech.in2p3.fr>
Tue, 21 Oct 2014 12:33:11 +0000 (14:33 +0200)
committermgermain <marie.germain@subatech.in2p3.fr>
Tue, 21 Oct 2014 12:33:11 +0000 (14:33 +0200)
PWGPP/QA/detectorQAscripts/V0.sh [new file with mode: 0755]
PWGPP/VZERO/trending/DrawTrendingV0QA.C [new file with mode: 0755]
PWGPP/VZERO/trending/MakeTrendingV0QA.C [new file with mode: 0755]

diff --git a/PWGPP/QA/detectorQAscripts/V0.sh b/PWGPP/QA/detectorQAscripts/V0.sh
new file mode 100755 (executable)
index 0000000..4a76b01
--- /dev/null
@@ -0,0 +1,18 @@
+
+
+runLevelQA()
+{
+       qaFile=$1
+       detectorQAcontainerName="VZERO"
+       cp $ALICE_ROOT/PWGPP/VZERO/trending/MakeTrendingV0QA.C .
+       aliroot -q -b -l .x "MakeTrendingV0QA.C(\"${qaFile}\",${runNumber},\"${ocdbStorage}\",kFALSE,KFALSE)"
+       #first booleen for Grid connection (true == connection in maketrending) and last boolen for print histo
+}
+
+periodLevelQA()
+{
+       trendingFile=$1
+       detectorQAcontainerName="VZERO"
+       cp $ALICE_ROOT/PWGPP/VZERO/trending/DrawTrendingV0QA.C .
+       aliroot -q -b -l .x "DrawTrendingV0QA.C(\"${trendingFile}\")"
+}
diff --git a/PWGPP/VZERO/trending/DrawTrendingV0QA.C b/PWGPP/VZERO/trending/DrawTrendingV0QA.C
new file mode 100755 (executable)
index 0000000..58980f0
--- /dev/null
@@ -0,0 +1,246 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)\r
+#include <TError.h>\r
+#include <TROOT.h>\r
+#include <TKey.h>\r
+#include <TH2.h>\r
+#include <TF1.h>\r
+#include <TH1.h>\r
+#include <TFile.h>\r
+#include <TCanvas.h>\r
+#include <TPad.h>\r
+#include <TStyle.h>\r
+#include <TGrid.h>\r
+#include <TGridResult.h>\r
+#include <TEnv.h>\r
+#include <TLegend.h>\r
+#include <TMath.h>\r
+#include <TSpectrum.h>\r
+#include <TTree.h>\r
+\r
+#include "AliCDBManager.h"\r
+#include "AliCDBEntry.h"\r
+#include "AliGRPObject.h"\r
+#include "AliTriggerInput.h"\r
+#include "AliTriggerConfiguration.h"\r
+#endif\r
+\r
+Int_t DrawTrendingV0QA(TString mergedTrendFile ="trending.root")\r
+{\r
+       if(!mergedTrendFile)\r
+       {\r
+               printf("Cannot open merged trend file with V0 QA");\r
+               return 1;\r
+       }\r
+       char outfilename[200]="ProductionQA.hist.root";\r
+       TString plotDir(".");\r
+       \r
+       Int_t runNumber=0, NumberVoieOff=0, numberBadOffset=0;\r
+       TFile*fin=TFile::Open(mergedTrendFile.Data());\r
+       if(!fin)\r
+       {\r
+               Printf("ERROR: trending file not found. Exiting ...\n");\r
+               return -1;\r
+       }\r
+       TTree*ttree=(TTree*)fin->Get("trending");\r
+       if(!ttree)\r
+       {\r
+               printf("Invalid trending tree");\r
+               return 2;\r
+       }\r
+       Float_t TimesA=0.,TimesC=0., BB_BG=0.,BB_EE=0.,AdcA=0.;\r
+       Float_t AdcC=0.,MultA=0.,MultC=0.;\r
+       \r
+       \r
+       ttree->SetBranchAddress("run",&runNumber);\r
+       ttree->SetBranchAddress("TimesA",&TimesA);\r
+       ttree->SetBranchAddress("TimesC",&TimesC);\r
+       ttree->SetBranchAddress("BB_BG",&BB_BG);\r
+       ttree->SetBranchAddress("BB_EE",&BB_EE);\r
+       ttree->SetBranchAddress("AdcA" ,&AdcA );\r
+       ttree->SetBranchAddress("AdcC" ,&AdcC );\r
+       ttree->SetBranchAddress("MultA",&MultA);\r
+       ttree->SetBranchAddress("MultC",&MultC);\r
+       ttree->SetBranchAddress("NumberVoieOff",&NumberVoieOff);\r
+       ttree->SetBranchAddress("numberBadOffset",&numberBadOffset);\r
+       \r
+       Int_t nRuns=ttree->GetEntries();\r
+       TList list;\r
+       \r
+       TH1F * hTimeA = new TH1F("hTimeA","BB Leading time;;Time (ns)",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hTimeC = new TH1F("hTimeC","BB Leading time;;Time (ns)",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hBB_BG = new TH1F("hBB_BG","Trigger ratio",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hBB_EE = new TH1F("hBB_EE","Trigger ratio",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hAdcA = new TH1F("hAdcA","Average Charge",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hAdcC = new TH1F("hAdcC","Average Charge",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hMultA = new TH1F("hMultA","Average number of Fired cell",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hMultC = new TH1F("hMultC","Average number of Fired cell",nRuns,-0.5,nRuns-0.5);\r
+       TH1F * hNumberVoieOff=new TH1F("hNumberVoieOff","Number of chanel off",nRuns,-0.5,nRuns-0.5);\r
+       hNumberVoieOff->SetMaximum(70);\r
+       TH1F * hNumberBadOffset=new TH1F("hNumberBadOffset","Number of pdestal",nRuns,-0.5,nRuns-0.5);\r
+       hNumberBadOffset->SetMaximum(70);\r
+       \r
+       list.Add(hTimeA);\r
+       list.Add(hTimeC);\r
+       list.Add(hBB_BG);\r
+       list.Add(hBB_EE);\r
+       list.Add(hAdcA );\r
+       list.Add(hAdcC );\r
+       list.Add(hMultA);\r
+       list.Add(hMultC);\r
+       list.Add(hNumberVoieOff);\r
+       list.Add(hNumberBadOffset);\r
+       char runlabel[6];\r
+       \r
+       \r
+       for(Int_t irun=0;irun<nRuns;irun++)\r
+       {\r
+               ttree->GetEntry(irun);\r
+               sprintf(runlabel,"%i",runNumber);\r
+               \r
+               hTimeA->SetBinContent(irun+1,TimesA);\r
+               hTimeA->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hTimeC->SetBinContent(irun+1,TimesC);\r
+               hTimeC->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hBB_BG->SetBinContent(irun+1,BB_BG);\r
+               hBB_BG->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hBB_EE->SetBinContent(irun+1,BB_EE);\r
+               hBB_EE->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hAdcA->SetBinContent(irun+1,AdcA);\r
+               hAdcA ->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hAdcC->SetBinContent(irun+1,AdcC);\r
+               hAdcC ->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hMultA->SetBinContent(irun+1,MultA);\r
+               hMultA->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hMultC->SetBinContent(irun+1,MultC);\r
+               hMultC->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hNumberVoieOff->SetBinContent(irun+1,NumberVoieOff);\r
+               hNumberVoieOff->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+               \r
+               hNumberBadOffset->SetBinContent(irun+1,numberBadOffset);\r
+               hNumberBadOffset->GetXaxis()->SetBinLabel(irun+1,runlabel);\r
+       }\r
+       \r
+       TFile*fout=new TFile(outfilename,"recreate");\r
+       fout->cd();\r
+       list.Write();\r
+       fout->Close();\r
+       int maxRun =runNumber;\r
+       ttree->GetEntry(0);\r
+       int minRun = runNumber;\r
+       \r
+       gStyle->SetOptStat(0);\r
+       hTimeA->SetMarkerStyle(20);\r
+       hTimeA->SetMarkerColor(2);\r
+  \r
+       hTimeC->SetMarkerStyle(20);\r
+       hTimeC->SetMarkerColor(4);\r
+\r
+       \r
+       \r
+       \r
+       TCanvas * c = new TCanvas("c","Leading time versus run number");\r
+       hTimeA->GetYaxis()->SetRange(0,10);\r
+       hTimeA->Draw("P");\r
+       hTimeA->SetMinimum(TMath::Min(hTimeA->GetMinimum(),hTimeC->GetMinimum())-1.);\r
+       hTimeA->SetMaximum(TMath::Max(hTimeA->GetMaximum(),hTimeC->GetMaximum())+1.);\r
+  \r
+       hTimeC->GetYaxis()->SetRange(0,10);\r
+       hTimeC->Draw("Psame");\r
+       TLegend * lg = new TLegend(0.8,0.9,1,1);\r
+       lg->AddEntry(hTimeA,"V0A - 8 ns","p");\r
+       lg->AddEntry(hTimeC,"V0C","p");\r
+       lg->Draw("same");\r
+       float shiftA=8.0;\r
+       TPave * pavA = new TPave(-0.5,TMath::Max(hTimeA->GetMinimum(),1.5-shiftA),nRuns-0.5,TMath::Min(hTimeA->GetMaximum(),33.5-shiftA),0);\r
+       pavA->SetFillStyle(3004);\r
+       pavA->SetFillColor(2);\r
+       TPave * pavC = new TPave(-0.5,TMath::Max(hTimeC->GetMinimum(),0.5),nRuns-0.5,TMath::Min(hTimeC->GetMaximum(),25.5),0);\r
+       pavC->SetFillStyle(3005);\r
+       pavC->SetFillColor(4);\r
+  \r
+       pavA->Draw("same");\r
+       pavC->Draw("same");\r
+\r
+       \r
+       c->Print(Form("%s/QA_Resume_%d_%d.pdf(",plotDir.Data(),minRun,maxRun));\r
+       c->Write();\r
+  \r
+       TCanvas * c2 = new TCanvas("c2","Trigger ratios");\r
+       c2->SetGridy();\r
+  \r
+       hBB_BG->SetMarkerStyle(20);\r
+       hBB_BG->SetMarkerColor(2);\r
+       hBB_EE->SetMarkerStyle(20);\r
+       hBB_EE->SetMarkerColor(4);\r
+       \r
+       hBB_BG->Draw("P");\r
+       hBB_EE->Draw("Psame");\r
+       TLegend * lg2 = new TLegend(0.8,0.9,1,1);\r
+       lg2->AddEntry(hBB_BG,"BG / BB","p");\r
+       lg2->AddEntry(hBB_EE,"EE / BB","p");\r
+       lg2->Draw("same");\r
+       \r
+       c2->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));\r
+       c2->Write();\r
+       \r
+       \r
+       TCanvas * c3 = new TCanvas("c3","Average Charge");\r
+       c3->SetGridy();\r
+       \r
+       hAdcA->SetMarkerStyle(20);\r
+       hAdcA->SetMarkerColor(2);\r
+       hAdcC->SetMarkerStyle(20);\r
+       hAdcC->SetMarkerColor(4);\r
+       hAdcA->SetMinimum(0);\r
+       hAdcA->SetMaximum(100);\r
+       \r
+       hAdcA->Draw("P");\r
+       hAdcC->Draw("Psame");\r
+       TLegend * lg3 = new TLegend(0.8,0.9,1,1);\r
+       lg3->AddEntry(hAdcA,"V0A","p");\r
+       lg3->AddEntry(hAdcC,"V0C","p");\r
+       lg3->Draw("same");\r
+       \r
+       c3->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));\r
+       c3->Write();\r
+       \r
+  \r
+       TCanvas * c4 = new TCanvas("c4","Average number of cell");\r
+       c4->SetGridy();\r
+       \r
+       hMultA->SetMarkerStyle(20);\r
+       hMultA->SetMarkerColor(2);\r
+       hMultC->SetMarkerStyle(20);\r
+       hMultC->SetMarkerColor(4);\r
+       hMultA->SetMinimum(0);\r
+       hMultA->SetMaximum(32);\r
+       \r
+       hMultA->Draw("P");\r
+       hMultC->Draw("Psame");\r
+       TLegend * lg4 = new TLegend(0.8,0.9,1,1);\r
+       lg4->AddEntry(hMultA,"V0A","p");\r
+       lg4->AddEntry(hMultC,"V0C","p");\r
+       lg4->Draw("same");\r
+       \r
+       c4->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));\r
+       c4->Write();\r
+\r
+       TCanvas * c5 = new TCanvas("c5","");\r
+       c5->cd();\r
+       hNumberVoieOff->Draw();\r
+       TCanvas * c6 = new TCanvas("c6","");\r
+       c6->cd();\r
+       hNumberBadOffset->Draw();\r
+       c5->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));\r
+       c6->Print(Form("%s/QA_Resume_%d_%d.pdf)",plotDir.Data(),minRun,maxRun));\r
+       c5->Write();\r
+       return 0;\r
+}\r
diff --git a/PWGPP/VZERO/trending/MakeTrendingV0QA.C b/PWGPP/VZERO/trending/MakeTrendingV0QA.C
new file mode 100755 (executable)
index 0000000..4bb0818
--- /dev/null
@@ -0,0 +1,345 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)\r
+#include <TError.h>\r
+#include <TROOT.h>\r
+#include <TKey.h>\r
+#include <TH2.h>\r
+#include <TF1.h>\r
+#include <TH1.h>\r
+#include <TFile.h>\r
+#include <TCanvas.h>\r
+#include <TPad.h>\r
+#include <TStyle.h>\r
+#include <TGrid.h>\r
+#include <TGridResult.h>\r
+#include <TEnv.h>\r
+#include <TLegend.h>\r
+#include <TMath.h>\r
+#include <TSpectrum.h>\r
+#include <TTree.h>\r
+\r
+#include "AliCDBManager.h"\r
+#include "AliCDBEntry.h"\r
+#include "AliGRPObject.h"\r
+#include "AliTriggerInput.h"\r
+#include "AliTriggerConfiguration.h"\r
+#endif\r
+\r
+\r
+Int_t MakeTrendingV0QA(TString qafilename,Int_t runNumber,TString ocdbStorage = "raw://",Bool_t IsOnGrid = kFALSE,Bool_t canvasE = kFALSE)\r
+{\r
+       if (!qafilename) \r
+       {\r
+               Printf("Error - Invalid input file");\r
+               return 1;\r
+       }\r
+       gStyle->SetPalette(1);\r
+       \r
+       TString treePostFileName=Form("trending_%i.root",runNumber);\r
+       if(IsOnGrid)\r
+               TGrid::Connect("alien://");\r
+       TFile*fin=TFile::Open(qafilename,"r");\r
+\r
+       if(!fin)\r
+       {\r
+               Printf("ERROR: QA output not found. Exiting ...\n");\r
+               return -1;\r
+       }\r
+       else\r
+       {\r
+               Printf("INFO: QA output file %s open. \n",fin->GetName());\r
+       }\r
+       AliCDBManager *man = AliCDBManager::Instance();\r
+       man->SetDefaultStorage(ocdbStorage);\r
+       man->SetRun(runNumber);\r
+       AliCDBEntry *entry2=0;\r
+       entry2 = man->Get("GRP/GRP/Data");\r
+       AliGRPObject* fGRPData=0;\r
+       if (entry2) \r
+       {\r
+               printf("Found an AliGRPObject in GRP/GRP/Data, reading it\n");\r
+               fGRPData = dynamic_cast<AliGRPObject*>(entry2->GetObject()); \r
+               entry2->SetOwner(0);\r
+       }\r
+       TString activeDetList(AliDAQ::ListOfTriggeredDetectors(fGRPData->GetDetectorMask()));\r
+       TString runType(fGRPData->GetRunType());\r
+       TString beamType(fGRPData->GetBeamType());\r
+       TString machineMode(fGRPData->GetMachineMode());\r
+       TString lhcState(fGRPData->GetLHCState());\r
+       printf("activeDetList %s\nrunType %s\nbeamType %s\nmachineMode %s\nlhcState %s\n",\r
+               activeDetList.Data(),runType.Data(),beamType.Data(),\r
+               machineMode.Data(),lhcState.Data());\r
+    \r
+       time_t duration = fGRPData->GetTimeEnd() - fGRPData->GetTimeStart();\r
+    \r
+       if(!activeDetList.Contains("VZERO"))\r
+       { \r
+                       printf("RUN WITH VZERO NOT ACTIVE\n");\r
+               return 0;\r
+       }\r
+       if(!runType.Contains("PHYSICS"))\r
+       { \r
+               printf("RUN NO PHYSICS\n");\r
+               return 0;\r
+       }\r
+       if(duration<120)\r
+       { \r
+               printf("RUNS SHORTER THAN 2 MIN\n");\r
+               return 0;\r
+       }\r
+       Float_t TimesA=-9999.,TimesC=-9999., BB_BG=-9999.,BB_EE=-9999.,AdcA=-9999.;\r
+       Float_t AdcC=-9999.,MultA=-9999.,MultC=-9999.;\r
+       Int_t NumberVoieOff=0, numberBadOffset=0;\r
+       TTree *ttree=new TTree("trending","tree of trending variables");\r
+\r
+       ttree->Branch("run",&runNumber,"run/I");\r
+       ttree->Branch("TimesA",&TimesA,"BB Leading time;;Time (ns)/F");\r
+       ttree->Branch("TimesC",&TimesC,"BB Leading time;;Time (ns)/F");\r
+       ttree->Branch("BB_BG",&BB_BG,"Trigger ratio/F");\r
+       ttree->Branch("BB_EE",&BB_EE,"Trigger ratio/F");\r
+       ttree->Branch("AdcA" ,&AdcA ,"Average Charge/F");\r
+       ttree->Branch("AdcC" ,&AdcC ,"Average Charge/F");\r
+       ttree->Branch("MultA",&MultA,"Average number of Fired cell/F");\r
+       ttree->Branch("MultC",&MultC,"Average number of Fired cell/F");\r
+       ttree->Branch("NumberVoieOff",&NumberVoieOff,"Number of path off/I");\r
+       ttree->Branch("numberBadOffset",&numberBadOffset,"Number of bad offset /I");\r
+       \r
+       char v0QAdirName[20]="VZERO_Performance";\r
+       TDirectoryFile * v0QAdir=(TDirectoryFile*)fin->Get(v0QAdirName);\r
+       if(!v0QAdir)\r
+       {\r
+               printf("ERROR: VZERO QA directory not present in input file.\n");\r
+               return -1;\r
+       }\r
+       TList *list = (TList*)v0QAdir->Get("QAVZEROHists");\r
+       if(!list) \r
+       {\r
+               cout << "ERROR: No list found" << endl;\r
+               return -1;\r
+       }\r
+       TH2F *hEvents = (TH2F*)list->FindObject("hEvents");\r
+       TH1F *hAdcNoTimeA = (TH1F*)list->FindObject("hAdcNoTimeA");\r
+       TH1F *hAdcWithTimeA = (TH1F*)list->FindObject("hAdcWithTimeA");\r
+       TH1F *hAdcNoTimeC = (TH1F*)list->FindObject("hAdcNoTimeC");\r
+       TH1F *hAdcWithTimeC = (TH1F*)list->FindObject("hAdcWithTimeC");\r
+       TH2F *hadcpmtwithtime = (TH2F*)list->FindObject("hadcpmtwithtime");     \r
+       TH1F *htimepmtA = (TH1F*)list->FindObject("htimepmtA");\r
+       TH1F *htimepmtC = (TH1F*)list->FindObject("htimepmtC");\r
+       TH1F *hwidthA = (TH1F*)list->FindObject("hwidthA");\r
+       TH1F *hwidthC = (TH1F*)list->FindObject("hwidthC");\r
+       TH1F *hV0ampl = (TH1F*)list->FindObject("hV0ampl");\r
+       TH2F *htimepmt = (TH2F*)list->FindObject("htimepmt");   \r
+       TH2F *hwidthpmt = (TH2F*)list->FindObject("hwidthpmt"); \r
+       TH2F *hadcwidthA = (TH2F*)list->FindObject("hadcwidthA");       \r
+       TH2F *hadcwidthC = (TH2F*)list->FindObject("hadcwidthC");       \r
+       TH2F *hAdcTimeA = (TH2F*)list->FindObject("hAdcTimeA"); \r
+       TH2F *hAdcTimeC = (TH2F*)list->FindObject("hAdcTimeC"); \r
+       TH2F *htimecorr = (TH2F*)list->FindObject("htimecorr"); \r
+       TH1F *hV0A = (TH1F*)list->FindObject("hV0a");\r
+       TH1F *hV0C = (TH1F*)list->FindObject("hV0c");\r
+       TH1F *hV0multA = (TH1F*)list->FindObject("hV0multA");\r
+       TH1F *hV0multC = (TH1F*)list->FindObject("hV0multC");\r
+       TH2F* hVtxXYBB  =(TH2F*) list->FindObject("fhVtxXYBB");\r
+       TH1F* hVtxZBB   =(TH1F*) list->FindObject("fhVtxZBB");\r
+       TH2F* hVtxXYBGA =(TH2F*) list->FindObject("fhVtxXYBGA");\r
+       TH1F* hVtxZBGA  =(TH1F*) list->FindObject("fhVtxZBGA");\r
+       TH2F* hVtxXYBGC =(TH2F*) list->FindObject("fhVtxXYBGC");\r
+       TH1F* hVtxZBGC  =(TH1F*) list->FindObject("fhVtxZBGC");\r
+       \r
+       float BB = hEvents->GetBinContent(2,2);\r
+       float EE = hEvents->GetBinContent(1,1);\r
+       float BGA = hEvents->GetBinContent(3,2);\r
+       float BGC = hEvents->GetBinContent(2,3);\r
+       \r
+       if(hAdcWithTimeA->GetEntries()==0)\r
+               return 0;\r
+       \r
+       {\r
+               TSpectrum s;\r
+               float shiftA = 8.;\r
+               Int_t nPeaksFound = s.Search(htimepmtA);\r
+               Float_t *peaks = s.GetPositionY();\r
+               Float_t *posiX = s.GetPositionX();\r
+               Float_t maxY = 0.;\r
+               Int_t index = -1;\r
+       \r
+               for(int i=0;i<nPeaksFound;i++) \r
+               {\r
+                       if(peaks[i]>maxY && posiX[i]>0.) \r
+                       {\r
+                               maxY = peaks[i];\r
+                               index = i;\r
+                       }       \r
+               }\r
+               Float_t maxX = (index >= 0) ? s.GetPositionX()[index] : -11111; \r
+               \r
+               TF1 *fgaus = new TF1("gausbbbb","gaus",maxX-1.,maxX+1.);\r
+               htimepmtA->Fit(fgaus,"","",maxX-1.,maxX+1.);\r
+               TimesA=fgaus->GetParameter(1)-shiftA;\r
+               delete fgaus;\r
+       }\r
+       {\r
+               TSpectrum s;\r
+               Int_t nPeaksFound = s.Search(htimepmtC);\r
+               Float_t *peaks = s.GetPositionY();\r
+               Float_t maxY = 0.;\r
+               Int_t index = -1;\r
+               for(int i=0;i<nPeaksFound;i++) \r
+               {\r
+                       if(peaks[i]>maxY) \r
+                       {\r
+                       maxY = peaks[i];\r
+                       index = i;\r
+                       }\r
+               }       \r
+               Float_t maxX = (index >= 0) ? s.GetPositionX()[index] : -11111; \r
+               TF1 *fgaus = new TF1("gausffff","gaus",maxX-1.,maxX+1.);\r
+               htimepmtC->Fit(fgaus,"","",maxX-1.,maxX+1.);\r
+               TimesC=fgaus->GetParameter(1);\r
+               delete fgaus;\r
+       }\r
+       if(BB) \r
+       {\r
+               BB_BG=(BGA+BGC)/BB;\r
+               BB_EE=EE/BB;\r
+       }else\r
+       {\r
+               BB_BG=0;\r
+               BB_EE=0;\r
+       }\r
+       \r
+       MultA=hV0A->GetMean();\r
+       MultC=hV0C->GetMean();\r
+    \r
+       AdcA=hAdcWithTimeA->GetMean();\r
+       AdcC=hAdcWithTimeC->GetMean();\r
+       \r
+       double valBin=0;\r
+       TH1D*hadcXFull=hadcpmtwithtime->ProjectionX("hadcXFull",1,hadcpmtwithtime->GetYaxis()->GetLast());\r
+       TH1D*hadcX=hadcpmtwithtime->ProjectionX("hadcX",10,20);\r
+       for(Int_t i=0;i<64;i++)\r
+       {\r
+               valBin=hadcXFull->GetBinContent(i+1);\r
+               if(valBin==0)\r
+                       NumberVoieOff++;\r
+               valBin=hadcX->GetBinContent(i+1);\r
+               if(valBin==0)\r
+                       numberBadOffset++;\r
+       }\r
+               \r
+       TFile * trendFile = new TFile(treePostFileName.Data(),"recreate");\r
+       ttree->Fill();\r
+       trendFile->cd();\r
+       ttree->Write();\r
+       trendFile->Close();\r
+       \r
+       if(canvasE)\r
+       {\r
+       \r
+               TCanvas * cOut = new TCanvas("cOut",Form("Run %d",runNumber));\r
+               cOut->Divide(2,2);\r
+               cOut->cd(1); cOut->GetPad(1)->SetLogy();\r
+               hAdcNoTimeA->Draw("l");\r
+               hAdcWithTimeA->Draw("same"); hAdcWithTimeA->SetLineColor(2);\r
+    \r
+               cOut->cd(2); cOut->GetPad(2)->SetLogy();\r
+               hAdcNoTimeC->Draw("l");\r
+               hAdcWithTimeC->Draw("same"); hAdcWithTimeC->SetLineColor(2);\r
+       \r
+                       cOut->cd(3); cOut->GetPad(3)->SetLogz();\r
+               hadcpmtwithtime->Draw("colz");\r
+       \r
+               cOut->cd(4); cOut->GetPad(4)->SetLogz();\r
+               hEvents->Draw("colz text");\r
+       \r
+               cOut->Print(Form("QA_Run_%d.pdf(",runNumber));\r
+       \r
+       \r
+               cOut->cd(1); cOut->GetPad(1)->SetLogy();\r
+               htimepmtA->GetXaxis()->SetRangeUser(-25.,25.); htimepmtA->Draw();\r
+       \r
+               cOut->cd(2); cOut->GetPad(2)->SetLogy();\r
+               htimepmtC->GetXaxis()->SetRangeUser(-25.,25.); htimepmtC->Draw();\r
+       \r
+                       cOut->cd(3); cOut->GetPad(3)->SetLogy();cOut->GetPad(3)->SetLogz(0);\r
+               hwidthA->GetXaxis()->SetRangeUser(0.,50.); hwidthA->Draw();\r
+       \r
+               cOut->cd(4); cOut->GetPad(4)->SetLogy();cOut->GetPad(4)->SetLogz(0);\r
+               hwidthC->GetXaxis()->SetRangeUser(0.,50.); hwidthC->Draw();\r
+       \r
+               cOut->Print(Form("QA_Run_%d.pdf",runNumber));\r
+               \r
+       \r
+               cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz();\r
+               htimepmt->Draw("colz");\r
+       \r
+               cOut->cd(2); cOut->GetPad(2)->SetLogy(0);cOut->GetPad(2)->SetLogz();\r
+               hwidthpmt->GetYaxis()->SetRangeUser(0.,50.); hwidthpmt->Draw("colz");\r
+               \r
+               cOut->cd(3); cOut->GetPad(3)->SetLogy(0);cOut->GetPad(3)->SetLogz();\r
+               hadcwidthA->GetYaxis()->SetRangeUser(0.,50.); hadcwidthA->Draw("colz");\r
+       \r
+               cOut->cd(4); cOut->GetPad(4)->SetLogy(0);cOut->GetPad(4)->SetLogz();\r
+               hadcwidthC->GetYaxis()->SetRangeUser(0.,50.); hadcwidthC->Draw("colz");\r
+       \r
+               cOut->Print(Form("QA_Run_%d.pdf",runNumber));\r
+               \r
+       \r
+               cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz();\r
+               hAdcTimeA->Draw("colz");\r
+       \r
+               cOut->cd(2); cOut->GetPad(2)->SetLogy(0);cOut->GetPad(2)->SetLogz();\r
+               hAdcTimeC->Draw("colz");\r
+       \r
+               cOut->cd(3); cOut->GetPad(3)->SetLogy(); cOut->GetPad(3)->SetLogz(0);\r
+               hV0ampl->Draw();\r
+       \r
+               cOut->cd(4); cOut->GetPad(4)->SetLogy(0); cOut->GetPad(4)->SetLogz(0);\r
+               htimecorr->Draw("colz");\r
+       \r
+               cOut->Print(Form("QA_Run_%d.pdf",runNumber));\r
+       \r
+               \r
+       \r
+               cOut->cd(1);  cOut->GetPad(1)->SetLogy(1);cOut->GetPad(1)->SetLogz(0);\r
+               hV0A->GetXaxis()->SetRangeUser(0.,33.);hV0A->Draw();\r
+       \r
+               cOut->cd(2); cOut->GetPad(2)->SetLogy(1);cOut->GetPad(2)->SetLogz(0);\r
+               hV0C->GetXaxis()->SetRangeUser(0.,33.);hV0C->Draw();\r
+       \r
+               cOut->cd(3); cOut->GetPad(3)->SetLogy(); cOut->GetPad(3)->SetLogz(0);\r
+               hV0multA->Draw();\r
+               \r
+               cOut->cd(4); cOut->GetPad(4)->SetLogy(); cOut->GetPad(3)->SetLogz(0);\r
+               hV0multC->Draw();\r
+       \r
+               cOut->Print(Form("QA_Run_%d.pdf",runNumber));\r
+       \r
+               \r
+               cOut->Clear();\r
+               cOut->Divide(2,3);\r
+       \r
+               cOut->cd(1);  cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz(1);\r
+               hVtxXYBB->Draw("colz");\r
+       \r
+               cOut->cd(2); cOut->GetPad(2)->SetLogy(1);cOut->GetPad(2)->SetLogz(0);\r
+               hVtxZBB->Draw();\r
+       \r
+               cOut->cd(3); cOut->GetPad(3)->SetLogy(0); cOut->GetPad(3)->SetLogz(1);\r
+               hVtxXYBGA->Draw("colz");\r
+       \r
+               cOut->cd(4); cOut->GetPad(4)->SetLogy(); cOut->GetPad(3)->SetLogz(0);\r
+               hVtxZBGA->Draw();\r
+       \r
+               cOut->cd(5); cOut->GetPad(5)->SetLogy(0); cOut->GetPad(5)->SetLogz(1);\r
+               hVtxXYBGC->Draw("colz");\r
+       \r
+               cOut->cd(6); cOut->GetPad(6)->SetLogy(); cOut->GetPad(6)->SetLogz(0);\r
+               hVtxZBGC->Draw();\r
+               \r
+               cOut->Print(Form("QA_Run_%d.pdf)",runNumber));\r
+               delete cOut;\r
+                                       \r
+       }\r
+       delete v0QAdir;\r
+       return 0;\r
+}\r