]>
Commit | Line | Data |
---|---|---|
ae186c93 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <TError.h> | |
3 | #include <TROOT.h> | |
4 | #include <TKey.h> | |
5 | #include <TH2.h> | |
6 | #include <TF1.h> | |
7 | #include <TH1.h> | |
8 | #include <TFile.h> | |
9 | #include <TCanvas.h> | |
10 | #include <TPad.h> | |
11 | #include <TStyle.h> | |
12 | #include <TGrid.h> | |
13 | #include <TGridResult.h> | |
14 | #include <TEnv.h> | |
15 | #include <TLegend.h> | |
16 | #include <TMath.h> | |
17 | #include <TSpectrum.h> | |
18 | #include <TTree.h> | |
19 | ||
20 | #include "AliCDBManager.h" | |
21 | #include "AliCDBEntry.h" | |
22 | #include "AliGRPObject.h" | |
23 | #include "AliTriggerInput.h" | |
24 | #include "AliTriggerConfiguration.h" | |
25 | #endif | |
26 | ||
27 | ||
28 | Int_t MakeTrendingV0QA(TString qafilename,Int_t runNumber,TString ocdbStorage = "raw://",Bool_t IsOnGrid = kFALSE,Bool_t canvasE = kFALSE) | |
29 | { | |
30 | if (!qafilename) | |
31 | { | |
32 | Printf("Error - Invalid input file"); | |
33 | return 1; | |
34 | } | |
35 | gStyle->SetPalette(1); | |
36 | ||
37 | TString treePostFileName=Form("trending_%i.root",runNumber); | |
38 | if(IsOnGrid) | |
39 | TGrid::Connect("alien://"); | |
40 | TFile*fin=TFile::Open(qafilename,"r"); | |
41 | ||
42 | if(!fin) | |
43 | { | |
44 | Printf("ERROR: QA output not found. Exiting ...\n"); | |
45 | return -1; | |
46 | } | |
47 | else | |
48 | { | |
49 | Printf("INFO: QA output file %s open. \n",fin->GetName()); | |
50 | } | |
51 | AliCDBManager *man = AliCDBManager::Instance(); | |
52 | man->SetDefaultStorage(ocdbStorage); | |
53 | man->SetRun(runNumber); | |
54 | AliCDBEntry *entry2=0; | |
55 | entry2 = man->Get("GRP/GRP/Data"); | |
56 | AliGRPObject* fGRPData=0; | |
57 | if (entry2) | |
58 | { | |
59 | printf("Found an AliGRPObject in GRP/GRP/Data, reading it\n"); | |
60 | fGRPData = dynamic_cast<AliGRPObject*>(entry2->GetObject()); | |
61 | entry2->SetOwner(0); | |
62 | } | |
63 | TString activeDetList(AliDAQ::ListOfTriggeredDetectors(fGRPData->GetDetectorMask())); | |
64 | TString runType(fGRPData->GetRunType()); | |
65 | TString beamType(fGRPData->GetBeamType()); | |
66 | TString machineMode(fGRPData->GetMachineMode()); | |
67 | TString lhcState(fGRPData->GetLHCState()); | |
68 | printf("activeDetList %s\nrunType %s\nbeamType %s\nmachineMode %s\nlhcState %s\n", | |
69 | activeDetList.Data(),runType.Data(),beamType.Data(), | |
70 | machineMode.Data(),lhcState.Data()); | |
71 | ||
72 | time_t duration = fGRPData->GetTimeEnd() - fGRPData->GetTimeStart(); | |
73 | ||
74 | if(!activeDetList.Contains("VZERO")) | |
75 | { | |
76 | printf("RUN WITH VZERO NOT ACTIVE\n"); | |
77 | return 0; | |
78 | } | |
79 | if(!runType.Contains("PHYSICS")) | |
80 | { | |
81 | printf("RUN NO PHYSICS\n"); | |
82 | return 0; | |
83 | } | |
84 | if(duration<120) | |
85 | { | |
86 | printf("RUNS SHORTER THAN 2 MIN\n"); | |
87 | return 0; | |
88 | } | |
89 | Float_t TimesA=-9999.,TimesC=-9999., BB_BG=-9999.,BB_EE=-9999.,AdcA=-9999.; | |
90 | Float_t AdcC=-9999.,MultA=-9999.,MultC=-9999.; | |
91 | Int_t NumberVoieOff=0, numberBadOffset=0; | |
92 | TTree *ttree=new TTree("trending","tree of trending variables"); | |
93 | ||
94 | ttree->Branch("run",&runNumber,"run/I"); | |
95 | ttree->Branch("TimesA",&TimesA,"BB Leading time;;Time (ns)/F"); | |
96 | ttree->Branch("TimesC",&TimesC,"BB Leading time;;Time (ns)/F"); | |
97 | ttree->Branch("BB_BG",&BB_BG,"Trigger ratio/F"); | |
98 | ttree->Branch("BB_EE",&BB_EE,"Trigger ratio/F"); | |
99 | ttree->Branch("AdcA" ,&AdcA ,"Average Charge/F"); | |
100 | ttree->Branch("AdcC" ,&AdcC ,"Average Charge/F"); | |
101 | ttree->Branch("MultA",&MultA,"Average number of Fired cell/F"); | |
102 | ttree->Branch("MultC",&MultC,"Average number of Fired cell/F"); | |
103 | ttree->Branch("NumberVoieOff",&NumberVoieOff,"Number of path off/I"); | |
104 | ttree->Branch("numberBadOffset",&numberBadOffset,"Number of bad offset /I"); | |
105 | ||
106 | char v0QAdirName[20]="VZERO_Performance"; | |
107 | TDirectoryFile * v0QAdir=(TDirectoryFile*)fin->Get(v0QAdirName); | |
108 | if(!v0QAdir) | |
109 | { | |
110 | printf("ERROR: VZERO QA directory not present in input file.\n"); | |
111 | return -1; | |
112 | } | |
113 | TList *list = (TList*)v0QAdir->Get("QAVZEROHists"); | |
114 | if(!list) | |
115 | { | |
116 | cout << "ERROR: No list found" << endl; | |
117 | return -1; | |
118 | } | |
119 | TH2F *hEvents = (TH2F*)list->FindObject("hEvents"); | |
120 | TH1F *hAdcNoTimeA = (TH1F*)list->FindObject("hAdcNoTimeA"); | |
121 | TH1F *hAdcWithTimeA = (TH1F*)list->FindObject("hAdcWithTimeA"); | |
122 | TH1F *hAdcNoTimeC = (TH1F*)list->FindObject("hAdcNoTimeC"); | |
123 | TH1F *hAdcWithTimeC = (TH1F*)list->FindObject("hAdcWithTimeC"); | |
124 | TH2F *hadcpmtwithtime = (TH2F*)list->FindObject("hadcpmtwithtime"); | |
125 | TH1F *htimepmtA = (TH1F*)list->FindObject("htimepmtA"); | |
126 | TH1F *htimepmtC = (TH1F*)list->FindObject("htimepmtC"); | |
127 | TH1F *hwidthA = (TH1F*)list->FindObject("hwidthA"); | |
128 | TH1F *hwidthC = (TH1F*)list->FindObject("hwidthC"); | |
129 | TH1F *hV0ampl = (TH1F*)list->FindObject("hV0ampl"); | |
130 | TH2F *htimepmt = (TH2F*)list->FindObject("htimepmt"); | |
131 | TH2F *hwidthpmt = (TH2F*)list->FindObject("hwidthpmt"); | |
132 | TH2F *hadcwidthA = (TH2F*)list->FindObject("hadcwidthA"); | |
133 | TH2F *hadcwidthC = (TH2F*)list->FindObject("hadcwidthC"); | |
134 | TH2F *hAdcTimeA = (TH2F*)list->FindObject("hAdcTimeA"); | |
135 | TH2F *hAdcTimeC = (TH2F*)list->FindObject("hAdcTimeC"); | |
136 | TH2F *htimecorr = (TH2F*)list->FindObject("htimecorr"); | |
137 | TH1F *hV0A = (TH1F*)list->FindObject("hV0a"); | |
138 | TH1F *hV0C = (TH1F*)list->FindObject("hV0c"); | |
139 | TH1F *hV0multA = (TH1F*)list->FindObject("hV0multA"); | |
140 | TH1F *hV0multC = (TH1F*)list->FindObject("hV0multC"); | |
141 | TH2F* hVtxXYBB =(TH2F*) list->FindObject("fhVtxXYBB"); | |
142 | TH1F* hVtxZBB =(TH1F*) list->FindObject("fhVtxZBB"); | |
143 | TH2F* hVtxXYBGA =(TH2F*) list->FindObject("fhVtxXYBGA"); | |
144 | TH1F* hVtxZBGA =(TH1F*) list->FindObject("fhVtxZBGA"); | |
145 | TH2F* hVtxXYBGC =(TH2F*) list->FindObject("fhVtxXYBGC"); | |
146 | TH1F* hVtxZBGC =(TH1F*) list->FindObject("fhVtxZBGC"); | |
147 | ||
148 | float BB = hEvents->GetBinContent(2,2); | |
149 | float EE = hEvents->GetBinContent(1,1); | |
150 | float BGA = hEvents->GetBinContent(3,2); | |
151 | float BGC = hEvents->GetBinContent(2,3); | |
152 | ||
153 | if(hAdcWithTimeA->GetEntries()==0) | |
154 | return 0; | |
155 | ||
156 | { | |
157 | TSpectrum s; | |
158 | float shiftA = 8.; | |
159 | Int_t nPeaksFound = s.Search(htimepmtA); | |
160 | Float_t *peaks = s.GetPositionY(); | |
161 | Float_t *posiX = s.GetPositionX(); | |
162 | Float_t maxY = 0.; | |
163 | Int_t index = -1; | |
164 | ||
165 | for(int i=0;i<nPeaksFound;i++) | |
166 | { | |
167 | if(peaks[i]>maxY && posiX[i]>0.) | |
168 | { | |
169 | maxY = peaks[i]; | |
170 | index = i; | |
171 | } | |
172 | } | |
173 | Float_t maxX = (index >= 0) ? s.GetPositionX()[index] : -11111; | |
174 | ||
175 | TF1 *fgaus = new TF1("gausbbbb","gaus",maxX-1.,maxX+1.); | |
176 | htimepmtA->Fit(fgaus,"","",maxX-1.,maxX+1.); | |
177 | TimesA=fgaus->GetParameter(1)-shiftA; | |
178 | delete fgaus; | |
179 | } | |
180 | { | |
181 | TSpectrum s; | |
182 | Int_t nPeaksFound = s.Search(htimepmtC); | |
183 | Float_t *peaks = s.GetPositionY(); | |
184 | Float_t maxY = 0.; | |
185 | Int_t index = -1; | |
186 | for(int i=0;i<nPeaksFound;i++) | |
187 | { | |
188 | if(peaks[i]>maxY) | |
189 | { | |
190 | maxY = peaks[i]; | |
191 | index = i; | |
192 | } | |
193 | } | |
194 | Float_t maxX = (index >= 0) ? s.GetPositionX()[index] : -11111; | |
195 | TF1 *fgaus = new TF1("gausffff","gaus",maxX-1.,maxX+1.); | |
196 | htimepmtC->Fit(fgaus,"","",maxX-1.,maxX+1.); | |
197 | TimesC=fgaus->GetParameter(1); | |
198 | delete fgaus; | |
199 | } | |
200 | if(BB) | |
201 | { | |
202 | BB_BG=(BGA+BGC)/BB; | |
203 | BB_EE=EE/BB; | |
204 | }else | |
205 | { | |
206 | BB_BG=0; | |
207 | BB_EE=0; | |
208 | } | |
209 | ||
210 | MultA=hV0A->GetMean(); | |
211 | MultC=hV0C->GetMean(); | |
212 | ||
213 | AdcA=hAdcWithTimeA->GetMean(); | |
214 | AdcC=hAdcWithTimeC->GetMean(); | |
215 | ||
216 | double valBin=0; | |
217 | TH1D*hadcXFull=hadcpmtwithtime->ProjectionX("hadcXFull",1,hadcpmtwithtime->GetYaxis()->GetLast()); | |
218 | TH1D*hadcX=hadcpmtwithtime->ProjectionX("hadcX",10,20); | |
219 | for(Int_t i=0;i<64;i++) | |
220 | { | |
221 | valBin=hadcXFull->GetBinContent(i+1); | |
222 | if(valBin==0) | |
223 | NumberVoieOff++; | |
224 | valBin=hadcX->GetBinContent(i+1); | |
225 | if(valBin==0) | |
226 | numberBadOffset++; | |
227 | } | |
228 | ||
229 | TFile * trendFile = new TFile(treePostFileName.Data(),"recreate"); | |
230 | ttree->Fill(); | |
231 | trendFile->cd(); | |
232 | ttree->Write(); | |
233 | trendFile->Close(); | |
234 | ||
235 | if(canvasE) | |
236 | { | |
237 | ||
238 | TCanvas * cOut = new TCanvas("cOut",Form("Run %d",runNumber)); | |
239 | cOut->Divide(2,2); | |
240 | cOut->cd(1); cOut->GetPad(1)->SetLogy(); | |
241 | hAdcNoTimeA->Draw("l"); | |
242 | hAdcWithTimeA->Draw("same"); hAdcWithTimeA->SetLineColor(2); | |
243 | ||
244 | cOut->cd(2); cOut->GetPad(2)->SetLogy(); | |
245 | hAdcNoTimeC->Draw("l"); | |
246 | hAdcWithTimeC->Draw("same"); hAdcWithTimeC->SetLineColor(2); | |
247 | ||
248 | cOut->cd(3); cOut->GetPad(3)->SetLogz(); | |
249 | hadcpmtwithtime->Draw("colz"); | |
250 | ||
251 | cOut->cd(4); cOut->GetPad(4)->SetLogz(); | |
252 | hEvents->Draw("colz text"); | |
253 | ||
254 | cOut->Print(Form("QA_Run_%d.pdf(",runNumber)); | |
255 | ||
256 | ||
257 | cOut->cd(1); cOut->GetPad(1)->SetLogy(); | |
258 | htimepmtA->GetXaxis()->SetRangeUser(-25.,25.); htimepmtA->Draw(); | |
259 | ||
260 | cOut->cd(2); cOut->GetPad(2)->SetLogy(); | |
261 | htimepmtC->GetXaxis()->SetRangeUser(-25.,25.); htimepmtC->Draw(); | |
262 | ||
263 | cOut->cd(3); cOut->GetPad(3)->SetLogy();cOut->GetPad(3)->SetLogz(0); | |
264 | hwidthA->GetXaxis()->SetRangeUser(0.,50.); hwidthA->Draw(); | |
265 | ||
266 | cOut->cd(4); cOut->GetPad(4)->SetLogy();cOut->GetPad(4)->SetLogz(0); | |
267 | hwidthC->GetXaxis()->SetRangeUser(0.,50.); hwidthC->Draw(); | |
268 | ||
269 | cOut->Print(Form("QA_Run_%d.pdf",runNumber)); | |
270 | ||
271 | ||
272 | cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz(); | |
273 | htimepmt->Draw("colz"); | |
274 | ||
275 | cOut->cd(2); cOut->GetPad(2)->SetLogy(0);cOut->GetPad(2)->SetLogz(); | |
276 | hwidthpmt->GetYaxis()->SetRangeUser(0.,50.); hwidthpmt->Draw("colz"); | |
277 | ||
278 | cOut->cd(3); cOut->GetPad(3)->SetLogy(0);cOut->GetPad(3)->SetLogz(); | |
279 | hadcwidthA->GetYaxis()->SetRangeUser(0.,50.); hadcwidthA->Draw("colz"); | |
280 | ||
281 | cOut->cd(4); cOut->GetPad(4)->SetLogy(0);cOut->GetPad(4)->SetLogz(); | |
282 | hadcwidthC->GetYaxis()->SetRangeUser(0.,50.); hadcwidthC->Draw("colz"); | |
283 | ||
284 | cOut->Print(Form("QA_Run_%d.pdf",runNumber)); | |
285 | ||
286 | ||
287 | cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz(); | |
288 | hAdcTimeA->Draw("colz"); | |
289 | ||
290 | cOut->cd(2); cOut->GetPad(2)->SetLogy(0);cOut->GetPad(2)->SetLogz(); | |
291 | hAdcTimeC->Draw("colz"); | |
292 | ||
293 | cOut->cd(3); cOut->GetPad(3)->SetLogy(); cOut->GetPad(3)->SetLogz(0); | |
294 | hV0ampl->Draw(); | |
295 | ||
296 | cOut->cd(4); cOut->GetPad(4)->SetLogy(0); cOut->GetPad(4)->SetLogz(0); | |
297 | htimecorr->Draw("colz"); | |
298 | ||
299 | cOut->Print(Form("QA_Run_%d.pdf",runNumber)); | |
300 | ||
301 | ||
302 | ||
303 | cOut->cd(1); cOut->GetPad(1)->SetLogy(1);cOut->GetPad(1)->SetLogz(0); | |
304 | hV0A->GetXaxis()->SetRangeUser(0.,33.);hV0A->Draw(); | |
305 | ||
306 | cOut->cd(2); cOut->GetPad(2)->SetLogy(1);cOut->GetPad(2)->SetLogz(0); | |
307 | hV0C->GetXaxis()->SetRangeUser(0.,33.);hV0C->Draw(); | |
308 | ||
309 | cOut->cd(3); cOut->GetPad(3)->SetLogy(); cOut->GetPad(3)->SetLogz(0); | |
310 | hV0multA->Draw(); | |
311 | ||
312 | cOut->cd(4); cOut->GetPad(4)->SetLogy(); cOut->GetPad(3)->SetLogz(0); | |
313 | hV0multC->Draw(); | |
314 | ||
315 | cOut->Print(Form("QA_Run_%d.pdf",runNumber)); | |
316 | ||
317 | ||
318 | cOut->Clear(); | |
319 | cOut->Divide(2,3); | |
320 | ||
321 | cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz(1); | |
322 | hVtxXYBB->Draw("colz"); | |
323 | ||
324 | cOut->cd(2); cOut->GetPad(2)->SetLogy(1);cOut->GetPad(2)->SetLogz(0); | |
325 | hVtxZBB->Draw(); | |
326 | ||
327 | cOut->cd(3); cOut->GetPad(3)->SetLogy(0); cOut->GetPad(3)->SetLogz(1); | |
328 | hVtxXYBGA->Draw("colz"); | |
329 | ||
330 | cOut->cd(4); cOut->GetPad(4)->SetLogy(); cOut->GetPad(3)->SetLogz(0); | |
331 | hVtxZBGA->Draw(); | |
332 | ||
333 | cOut->cd(5); cOut->GetPad(5)->SetLogy(0); cOut->GetPad(5)->SetLogz(1); | |
334 | hVtxXYBGC->Draw("colz"); | |
335 | ||
336 | cOut->cd(6); cOut->GetPad(6)->SetLogy(); cOut->GetPad(6)->SetLogz(0); | |
337 | hVtxZBGC->Draw(); | |
338 | ||
339 | cOut->Print(Form("QA_Run_%d.pdf)",runNumber)); | |
340 | delete cOut; | |
341 | ||
342 | } | |
343 | delete v0QAdir; | |
344 | return 0; | |
345 | } |