]>
Commit | Line | Data |
---|---|---|
61899827 | 1 | /* $Id: AliPhysicsSelection.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */ |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Author: The ALICE Off-line Project. * | |
7 | * Contributors are mentioned in the code where appropriate. * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // Implementation of Class AliPhysicsSelection | |
528640ed | 20 | // This class selects collision candidates from data runs, applying selection cuts on triggers |
21 | // and background rejection based on the content of the ESD | |
22 | // | |
23 | // Usage: | |
24 | // | |
a2ce3799 | 25 | // Create the object: |
528640ed | 26 | // fPhysicsSelection = new AliPhysicsSelection; |
a2ce3799 | 27 | // |
28 | // For MC data, call | |
29 | // fPhysicsSelection->SetAnalyzeMC() | |
528640ed | 30 | // |
31 | // To check if an event is a collision candidate, use: | |
32 | // fPhysicsSelection->IsCollisionCandidate(fESD) | |
33 | // | |
34 | // After processing save the resulting histograms to a file with (a folder physics_selection | |
35 | // will be created that contains the histograms): | |
36 | // fPhysicsSelection->SaveHistograms("physics_selection") | |
37 | // | |
38 | // To print statistics after processing use: | |
39 | // fPhysicsSelection->Print(); | |
40 | // | |
85c71ba7 | 41 | // To seleect the BX ids corresponding to real bunches crossings p2 use: |
42 | // fPhysicsSelection->SetUseBXNumbers(); | |
43 | // you cannot process runs with different filling schemes if you require this option. | |
44 | // | |
45 | // To compute the Background automatically using the control triggers | |
46 | // use: | |
47 | // fPhysicsSelection->SetComputeBG(); | |
48 | // this will show the value of the Beam Gas, accidentals and good | |
49 | // events as additional rows in the statistic tables, but it will NOT | |
50 | // subtract the background automatically. | |
51 | // This option will only work for runs taken with the CINT1 | |
52 | // suite. This options enables automatically also the usage of BX | |
53 | // numbers. You can only process one run at a time if you require this | |
54 | // options, because it uses the bunch intensity estimated run by run. | |
55 | // | |
56 | // The BG will usually be more important in the so-called "bin 0": the | |
57 | // class can also compute the statistics table for events in this | |
58 | // bin. Since the definition of bin 0 may in general change from | |
59 | // analysis to analysis, the user needs to provide a callback | |
60 | // implementing the definition of bin zero. The callback should be | |
61 | // implemented as a method in the analysis task and should override | |
62 | // the IsEventInBinZero method of AliAnalysisTaskSE, and should thus | |
63 | // have the the following prototype: | |
64 | // Bool_t IsEventInBinZero(); | |
65 | // It should return true if the event is in the bin 0 and it is set by | |
66 | // passing to the physics selection the NAME of the task where the | |
67 | // callback is implemented: | |
68 | // fPhysicsSelection->SetBin0Callback("MyTask"). | |
69 | // | |
70 | // | |
decf6fd4 | 71 | // Usually the class selects the trigger scheme by itself depending on the run number. |
72 | // Nevertheless, you can do that manually by calling AddCollisionTriggerClass() and AddBGTriggerClass() | |
73 | // Example: | |
74 | // To define the class CINT1B-ABCE-NOPF-ALL as collision trigger (those will be accepted as | |
75 | // collision candidates when they pass the selection): | |
76 | // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL #769 #3119"); | |
77 | // To select on bunch crossing IDs in addition, use: | |
78 | // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL #769 #3119"); | |
79 | // To define the class CINT1A-ABCE-NOPF-ALL as a background trigger (those will only be counted | |
80 | // for the control histograms): | |
81 | // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); | |
82 | // You can also specify more than one trigger class in a string or you can require that some are *not* | |
83 | // present. The following line would require CSMBA-ABCE-NOPF-ALL, but CSMBB-ABCE-NOPF-ALL is not allowed | |
84 | // to be present: | |
85 | // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); | |
86 | // | |
85c71ba7 | 87 | // Origin: Jan Fiete Grosse-Oetringhaus, CERN |
88 | // Michele Floris, CERN | |
61899827 | 89 | //------------------------------------------------------------------------- |
90 | ||
91 | #include <Riostream.h> | |
92 | #include <TH1F.h> | |
93 | #include <TH2F.h> | |
94 | #include <TList.h> | |
95 | #include <TIterator.h> | |
96 | #include <TDirectory.h> | |
296dd262 | 97 | #include <TObjArray.h> |
61899827 | 98 | |
99 | #include <AliPhysicsSelection.h> | |
100 | ||
101 | #include <AliTriggerAnalysis.h> | |
102 | #include <AliLog.h> | |
103 | ||
104 | #include <AliESDEvent.h> | |
85c71ba7 | 105 | #include <AliAnalysisTaskSE.h> |
106 | #include "AliAnalysisManager.h" | |
61899827 | 107 | |
108 | ClassImp(AliPhysicsSelection) | |
109 | ||
110 | AliPhysicsSelection::AliPhysicsSelection() : | |
296dd262 | 111 | AliAnalysisCuts("AliPhysicsSelection", "AliPhysicsSelection"), |
112 | fCurrentRun(-1), | |
a2ce3799 | 113 | fMC(kFALSE), |
296dd262 | 114 | fCollTrigClasses(), |
115 | fBGTrigClasses(), | |
116 | fTriggerAnalysis(), | |
117 | fBackgroundIdentification(0), | |
91bea6e7 | 118 | fHistBunchCrossing(0), |
119 | fSkipTriggerClassSelection(0), | |
85c71ba7 | 120 | fUsingCustomClasses(0), |
121 | fSkipV0(0), | |
122 | fBIFactorA(1), | |
123 | fBIFactorC(1), | |
124 | fRatioBEEE(2), | |
125 | fComputeBG(0), | |
126 | fUseBXNumbers(0), | |
127 | fFillingScheme(""), | |
ff097e3f | 128 | fBin0CallBack(""), |
129 | fBin0CallBackPointer(0) | |
61899827 | 130 | { |
131 | // constructor | |
132 | ||
296dd262 | 133 | fCollTrigClasses.SetOwner(1); |
134 | fBGTrigClasses.SetOwner(1); | |
135 | fTriggerAnalysis.SetOwner(1); | |
85c71ba7 | 136 | fHistStatistics[0] = 0; |
137 | fHistStatistics[1] = 0; | |
296dd262 | 138 | |
61899827 | 139 | AliLog::SetClassDebugLevel("AliPhysicsSelection", AliLog::kWarning); |
140 | } | |
141 | ||
142 | AliPhysicsSelection::~AliPhysicsSelection() | |
143 | { | |
144 | // destructor | |
85c71ba7 | 145 | |
296dd262 | 146 | fCollTrigClasses.Delete(); |
147 | fBGTrigClasses.Delete(); | |
148 | fTriggerAnalysis.Delete(); | |
61899827 | 149 | |
85c71ba7 | 150 | if (fHistStatistics[0]) |
151 | { | |
152 | delete fHistStatistics[0]; | |
153 | fHistStatistics[0] = 0; | |
154 | } | |
155 | if (fHistStatistics[1]) | |
61899827 | 156 | { |
85c71ba7 | 157 | delete fHistStatistics[1]; |
158 | fHistStatistics[1] = 0; | |
61899827 | 159 | } |
160 | ||
161 | if (fHistBunchCrossing) | |
162 | { | |
163 | delete fHistBunchCrossing; | |
164 | fHistBunchCrossing = 0; | |
165 | } | |
85c71ba7 | 166 | |
61899827 | 167 | } |
296dd262 | 168 | |
169 | Bool_t AliPhysicsSelection::CheckTriggerClass(const AliESDEvent* aEsd, const char* trigger) const | |
170 | { | |
171 | // checks if the given trigger class(es) are found for the current event | |
172 | // format of trigger: +TRIGGER1 -TRIGGER2 | |
173 | // requires TRIGGER1 and rejects TRIGGER2 | |
174 | ||
decf6fd4 | 175 | Bool_t foundBCRequirement = kFALSE; |
176 | Bool_t foundCorrectBC = kFALSE; | |
177 | ||
296dd262 | 178 | TString str(trigger); |
179 | TObjArray* tokens = str.Tokenize(" "); | |
180 | ||
181 | for (Int_t i=0; i < tokens->GetEntries(); i++) | |
182 | { | |
183 | TString str2(((TObjString*) tokens->At(i))->String()); | |
184 | ||
decf6fd4 | 185 | if (str2[0] == '+' || str2[0] == '-') |
296dd262 | 186 | { |
decf6fd4 | 187 | Bool_t flag = (str2[0] == '+'); |
188 | ||
189 | str2.Remove(0, 1); | |
190 | ||
191 | if (flag && !aEsd->IsTriggerClassFired(str2)) | |
192 | { | |
193 | AliDebug(AliLog::kDebug, Form("Rejecting event because trigger class %s is not present", str2.Data())); | |
194 | delete tokens; | |
195 | return kFALSE; | |
196 | } | |
197 | if (!flag && aEsd->IsTriggerClassFired(str2)) | |
198 | { | |
199 | AliDebug(AliLog::kDebug, Form("Rejecting event because trigger class %s is present", str2.Data())); | |
200 | delete tokens; | |
201 | return kFALSE; | |
202 | } | |
296dd262 | 203 | } |
decf6fd4 | 204 | else if (str2[0] == '#') |
296dd262 | 205 | { |
decf6fd4 | 206 | foundBCRequirement = kTRUE; |
207 | ||
208 | str2.Remove(0, 1); | |
209 | ||
210 | Int_t bcNumber = str2.Atoi(); | |
211 | AliDebug(AliLog::kDebug, Form("Checking for bunch crossing number %d", bcNumber)); | |
212 | ||
213 | if (aEsd->GetBunchCrossNumber() == bcNumber) | |
214 | { | |
215 | foundCorrectBC = kTRUE; | |
216 | AliDebug(AliLog::kDebug, Form("Found correct bunch crossing %d", bcNumber)); | |
217 | } | |
296dd262 | 218 | } |
decf6fd4 | 219 | else |
220 | AliFatal(Form("Invalid trigger syntax: %s", trigger)); | |
296dd262 | 221 | } |
222 | ||
223 | delete tokens; | |
decf6fd4 | 224 | |
225 | if (foundBCRequirement && !foundCorrectBC) | |
226 | return kFALSE; | |
227 | ||
296dd262 | 228 | return kTRUE; |
229 | } | |
61899827 | 230 | |
231 | Bool_t AliPhysicsSelection::IsCollisionCandidate(const AliESDEvent* aEsd) | |
232 | { | |
233 | // checks if the given event is a collision candidate | |
234 | ||
95e6f4ec | 235 | if (fCurrentRun != aEsd->GetRunNumber()) |
236 | if (!Initialize(aEsd->GetRunNumber())) | |
237 | AliFatal(Form("Could not initialize for run %d", aEsd->GetRunNumber())); | |
238 | ||
61899827 | 239 | const AliESDHeader* esdHeader = aEsd->GetHeader(); |
240 | if (!esdHeader) | |
241 | { | |
242 | AliError("ESD Header could not be retrieved"); | |
243 | return kFALSE; | |
244 | } | |
245 | ||
a2ce3799 | 246 | // check event type; should be PHYSICS = 7 for data and 0 for MC |
247 | if (!fMC) | |
248 | { | |
249 | if (esdHeader->GetEventType() != 7) | |
250 | return kFALSE; | |
251 | } | |
252 | else | |
253 | { | |
254 | if (esdHeader->GetEventType() != 0) | |
255 | AliFatal(Form("Invalid event type for MC: %d", esdHeader->GetEventType())); | |
256 | } | |
758941d4 | 257 | |
296dd262 | 258 | Bool_t accept = kFALSE; |
259 | ||
260 | Int_t count = fCollTrigClasses.GetEntries() + fBGTrigClasses.GetEntries(); | |
261 | for (Int_t i=0; i < count; i++) | |
61899827 | 262 | { |
296dd262 | 263 | const char* triggerClass = 0; |
264 | if (i < fCollTrigClasses.GetEntries()) | |
265 | triggerClass = ((TObjString*) fCollTrigClasses.At(i))->String(); | |
266 | else | |
267 | triggerClass = ((TObjString*) fBGTrigClasses.At(i - fCollTrigClasses.GetEntries()))->String(); | |
61899827 | 268 | |
296dd262 | 269 | AliDebug(AliLog::kDebug, Form("Processing trigger class %s", triggerClass)); |
61899827 | 270 | |
296dd262 | 271 | AliTriggerAnalysis* triggerAnalysis = static_cast<AliTriggerAnalysis*> (fTriggerAnalysis.At(i)); |
61899827 | 272 | |
296dd262 | 273 | triggerAnalysis->FillTriggerClasses(aEsd); |
61899827 | 274 | |
296dd262 | 275 | if (CheckTriggerClass(aEsd, triggerClass)) |
276 | { | |
277 | triggerAnalysis->FillHistograms(aEsd); | |
278 | ||
85c71ba7 | 279 | Bool_t isBin0 = kFALSE; |
280 | if (fBin0CallBack != "") { | |
281 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
282 | if (!mgr) { | |
283 | AliError("Cannot get the analysis manager"); | |
284 | } | |
285 | else { | |
286 | isBin0 = ((AliAnalysisTaskSE*)mgr->GetTask(fBin0CallBack.Data()))->IsEventInBinZero(); | |
287 | } | |
ff097e3f | 288 | } else if (fBin0CallBackPointer) { |
289 | isBin0 = (*fBin0CallBackPointer)(aEsd); | |
290 | ||
85c71ba7 | 291 | } |
ff097e3f | 292 | |
85c71ba7 | 293 | |
cc9d9320 | 294 | |
295 | // hardware trigger (should only remove events for MC) | |
296 | // replay CINT1B hardware trigger | |
297 | // TODO this has to depend on the actual hardware trigger (and that depends on the run...) | |
298 | Int_t fastORHW = triggerAnalysis->SPDFiredChips(aEsd, 1); // SPD number of chips from trigger bits (!) | |
85c71ba7 | 299 | Bool_t v0A = fSkipV0 ? 0 :triggerAnalysis->IsOfflineTriggerFired(aEsd, AliTriggerAnalysis::kV0A); |
300 | Bool_t v0C = fSkipV0 ? 0 :triggerAnalysis->IsOfflineTriggerFired(aEsd, AliTriggerAnalysis::kV0C); | |
301 | Bool_t v0AHW = fSkipV0 ? 0 :(triggerAnalysis->V0Trigger(aEsd, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw trigger | |
302 | Bool_t v0CHW = fSkipV0 ? 0 :(triggerAnalysis->V0Trigger(aEsd, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw trigger | |
cc9d9320 | 303 | // offline trigger |
304 | Int_t fastOROffline = triggerAnalysis->SPDFiredChips(aEsd, 0); // SPD number of chips from clusters (!) | |
85c71ba7 | 305 | Bool_t v0ABG = fSkipV0 ? 0 :triggerAnalysis->IsOfflineTriggerFired(aEsd, AliTriggerAnalysis::kV0ABG); |
306 | Bool_t v0CBG = fSkipV0 ? 0 :triggerAnalysis->IsOfflineTriggerFired(aEsd, AliTriggerAnalysis::kV0CBG); | |
f4ca8f20 | 307 | Bool_t v0BG = v0ABG || v0CBG; |
85c71ba7 | 308 | |
309 | // fmd | |
310 | Bool_t fmdA = triggerAnalysis->IsOfflineTriggerFired(aEsd, AliTriggerAnalysis::kFMDA); | |
311 | Bool_t fmdC = triggerAnalysis->IsOfflineTriggerFired(aEsd, AliTriggerAnalysis::kFMDC); | |
312 | Bool_t fmd = fmdA || fmdC; | |
61899827 | 313 | |
85c71ba7 | 314 | // SSD |
315 | Int_t ssdClusters = triggerAnalysis->SSDClusters(aEsd); | |
316 | ||
317 | // Some "macros" | |
318 | Bool_t mb1 = (fastOROffline > 0 || v0A || v0C) && (!v0BG); | |
319 | Bool_t mb1prime = (fastOROffline > 1 || (fastOROffline > 0 && (v0A || v0C)) || (v0A && v0C) ) && (!v0BG); | |
320 | ||
321 | // Background rejection | |
322 | Bool_t bgID = ! fBackgroundIdentification->IsSelected(const_cast<AliESDEvent*> (aEsd)); | |
323 | ||
324 | Int_t ntrig = fastOROffline; // any 2 hits | |
325 | if(v0A) ntrig += 1; | |
326 | if(v0C) ntrig += 1; //v0C alone is enough | |
327 | if(fmd) ntrig += 1; | |
328 | if(ssdClusters>1) ntrig += 1; | |
329 | ||
330 | ||
331 | Bool_t hwTrig = fastORHW > 0 || v0AHW || v0CHW; | |
332 | ||
333 | // fill statistics and return decision | |
334 | const Int_t nHistStat = 2; | |
335 | for(Int_t iHistStat = 0; iHistStat < nHistStat; iHistStat++){ | |
336 | if (iHistStat == kStatIdxBin0 && !isBin0) continue; // skip the filling of bin0 stats if the event is not in the bin0 | |
337 | ||
338 | fHistStatistics[iHistStat]->Fill(kStatTriggerClass, i); | |
339 | ||
340 | ||
341 | ||
342 | // We fill the rest only if hw trigger is ok | |
343 | if (!hwTrig) | |
344 | { | |
345 | AliDebug(AliLog::kDebug, "Rejecting event because hardware trigger is not fired"); | |
346 | continue; | |
347 | } else { | |
348 | fHistStatistics[iHistStat]->Fill(kStatHWTrig, i); | |
349 | } | |
733f0542 | 350 | |
85c71ba7 | 351 | |
352 | // v0 BG stats | |
353 | if (v0ABG) | |
354 | fHistStatistics[iHistStat]->Fill(kStatV0ABG, i); | |
355 | if (v0CBG) | |
356 | fHistStatistics[iHistStat]->Fill(kStatV0CBG, i); | |
357 | ||
358 | // We fill the rest only if mb1 && ! v0BG | |
359 | if (mb1) | |
360 | fHistStatistics[iHistStat]->Fill(kStatMB1, i); | |
361 | else continue; | |
362 | ||
363 | if (mb1prime) | |
364 | fHistStatistics[iHistStat]->Fill(kStatMB1Prime, i); | |
365 | ||
366 | if (fmd) | |
367 | fHistStatistics[iHistStat]->Fill(kStatFMD, i); | |
368 | ||
369 | if(ssdClusters>1) | |
370 | fHistStatistics[iHistStat]->Fill(kStatSSD1, i); | |
371 | ||
372 | if(ntrig >= 2 && !v0BG) | |
373 | fHistStatistics[iHistStat]->Fill(kStatAny2Hits, i); | |
374 | ||
375 | if (fastOROffline > 0) | |
376 | fHistStatistics[iHistStat]->Fill(kStatFO1, i); | |
377 | if (fastOROffline > 1) | |
378 | fHistStatistics[iHistStat]->Fill(kStatFO2, i); | |
cc9d9320 | 379 | |
85c71ba7 | 380 | if (v0A) |
381 | fHistStatistics[iHistStat]->Fill(kStatV0A, i); | |
382 | if (v0C) | |
383 | fHistStatistics[iHistStat]->Fill(kStatV0C, i); | |
384 | ||
385 | // if (fastOROffline > 1 && !v0BG) | |
386 | // fHistStatistics[iHistStat]->Fill(kStatFO2NoBG, i); | |
387 | ||
388 | if (fastOROffline > 0 && (v0A || v0C) && !v0BG) | |
389 | fHistStatistics[iHistStat]->Fill(kStatFO1AndV0, i); | |
296dd262 | 390 | |
85c71ba7 | 391 | if (v0A && v0C && !v0BG && !bgID) |
392 | fHistStatistics[iHistStat]->Fill(kStatV0, i); | |
393 | ||
394 | ||
395 | if ( mb1 ) | |
396 | ||
397 | { | |
398 | if (!v0BG || fSkipV0) | |
399 | { | |
400 | if (!v0BG) fHistStatistics[iHistStat]->Fill(kStatOffline, i); | |
61899827 | 401 | |
85c71ba7 | 402 | if (fBackgroundIdentification && bgID) |
403 | { | |
404 | AliDebug(AliLog::kDebug, "Rejecting event because of background identification"); | |
405 | fHistStatistics[iHistStat]->Fill(kStatBG, i); | |
406 | } | |
407 | else | |
408 | { | |
409 | AliDebug(AliLog::kDebug, "Accepted event for histograms"); | |
296dd262 | 410 | |
85c71ba7 | 411 | fHistStatistics[iHistStat]->Fill(kStatAccepted, i); |
412 | if(iHistStat == kStatIdxAll) fHistBunchCrossing->Fill(aEsd->GetBunchCrossNumber(), i); // Fill only for all (avoid double counting) | |
413 | if((i < fCollTrigClasses.GetEntries() || fSkipTriggerClassSelection) && (iHistStat==kStatIdxAll)) | |
414 | accept = kTRUE; // only set for "all" (should not really matter) | |
415 | } | |
416 | } | |
417 | else | |
418 | AliDebug(AliLog::kDebug, "Rejecting event because of V0 BG flag"); | |
419 | } | |
420 | else | |
421 | AliDebug(AliLog::kDebug, "Rejecting event because trigger condition is not fulfilled"); | |
296dd262 | 422 | } |
296dd262 | 423 | } |
424 | } | |
425 | ||
426 | if (accept) | |
427 | AliDebug(AliLog::kDebug, "Accepted event as collision candidate"); | |
61899827 | 428 | |
296dd262 | 429 | return accept; |
61899827 | 430 | } |
a2ce3799 | 431 | |
85c71ba7 | 432 | Int_t AliPhysicsSelection::GetTriggerScheme(UInt_t runNumber) const |
a2ce3799 | 433 | { |
434 | // returns the current trigger scheme (classes that are accepted/rejected) | |
435 | ||
436 | if (fMC) | |
437 | return 0; | |
438 | ||
439 | // TODO dependent on run number | |
4b7e8f3b | 440 | |
441 | switch (runNumber) | |
442 | { | |
443 | // CSMBB triggers | |
444 | case 104044: | |
445 | case 105054: | |
446 | case 105057: | |
447 | return 2; | |
448 | } | |
449 | ||
450 | // default: CINT1 suite | |
a2ce3799 | 451 | return 1; |
452 | } | |
85c71ba7 | 453 | |
454 | const char * AliPhysicsSelection::GetFillingScheme(UInt_t runNumber) { | |
455 | ||
456 | if(fMC) return "MC"; | |
457 | ||
458 | if (runNumber >= 104065 && runNumber <= 104160) { | |
459 | return "4x4a"; | |
460 | } | |
461 | else if (runNumber >= 104315 && runNumber <= 104321) { | |
462 | return "4x4a*"; | |
463 | } | |
464 | else if (runNumber >= 104792 && runNumber <= 104803) { | |
465 | return "4x4b"; | |
466 | } | |
467 | else if (runNumber >= 104824 && runNumber <= 104892) { | |
468 | return "4x4c"; | |
469 | } | |
470 | else if (runNumber == 105143 || runNumber == 105160) { | |
471 | return "16x16a"; | |
472 | } | |
473 | else if (runNumber >= 105256 && runNumber <= 105268) { | |
474 | return "4x4c"; | |
ca234d7a | 475 | } else if (runNumber == 114786 || runNumber == 114798 || runNumber == 114783 ) { |
476 | return "Single_2b_1_1_1"; | |
85c71ba7 | 477 | } |
478 | else { | |
479 | AliError(Form("Unknown filling scheme (run %d)", runNumber)); | |
480 | } | |
481 | ||
482 | return "Unknown"; | |
483 | } | |
484 | ||
485 | Int_t AliPhysicsSelection::GetRatioBBBE(Int_t runNumber) { | |
486 | ||
487 | ||
488 | if(fMC) return 1; | |
489 | ||
490 | if (runNumber == 105143 || runNumber == 105160) { | |
491 | return 8; | |
ca234d7a | 492 | }else if (runNumber == 114786 || runNumber == 114798 || runNumber == 114783 ) { |
493 | return 1; | |
85c71ba7 | 494 | } |
495 | else if (fComputeBG && | |
496 | !(runNumber >= 105256 && runNumber <= 105268) && | |
497 | !(runNumber >= 104065 && runNumber <= 104160) && | |
498 | !(runNumber >= 104315 && runNumber <= 104321) && | |
499 | !(runNumber >= 104792 && runNumber <= 104803) && | |
500 | !(runNumber >= 104824 && runNumber <= 104892) | |
501 | ){ | |
502 | ||
503 | AliError(Form("Unknown run %d, assuming ratio BE/EE = 2",runNumber)); | |
504 | ||
505 | } | |
506 | ||
507 | return 2; | |
508 | } | |
509 | ||
510 | ||
511 | const char * AliPhysicsSelection::GetBXIDs(UInt_t runNumber, const char * trigger) { | |
512 | ||
513 | if (!fUseBXNumbers || fMC) return ""; | |
514 | ||
515 | if (runNumber >= 104065 && runNumber <= 104160) { | |
516 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #2128 #3019"; | |
517 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #346 #3465"; | |
518 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #1234 #1680"; | |
519 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #790"; | |
520 | else AliError(Form("Unknown trigger: %s", trigger)); | |
521 | } | |
522 | else if (runNumber >= 104315 && runNumber <= 104321) { | |
523 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #2000 #2891"; | |
524 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #218 #3337"; | |
525 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #1106 #1552"; | |
526 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #790"; | |
527 | else AliError(Form("Unknown trigger: %s", trigger)); | |
528 | } | |
529 | else if (runNumber >= 104792 && runNumber <= 104803) { | |
530 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #2228 #3119"; | |
531 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #2554 #446"; | |
532 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #1334 #769"; | |
533 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #790"; | |
534 | else AliError(Form("Unknown trigger: %s", trigger)); | |
535 | } | |
536 | else if (runNumber >= 104824 && runNumber <= 104892) { | |
537 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #3119 #769"; | |
538 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #2554 #446"; | |
539 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #1334 #2228"; | |
540 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #790"; | |
541 | else AliError(Form("Unknown trigger: %s", trigger)); | |
542 | } | |
543 | else if (runNumber == 105143 || runNumber == 105160) { | |
544 | fRatioBEEE = 8; | |
545 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #1337 #1418 #2228 #2309 #3119 #3200 #446 #527"; | |
546 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #1580 #1742 #1904 #2066 #2630 #2792 #2954 #3362"; | |
547 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #845 #1007 #1169 #1577 #3359 #3521 #119 #281 "; | |
548 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #790"; | |
549 | else AliError(Form("Unknown trigger: %s", trigger)); | |
550 | } | |
551 | else if (runNumber >= 105256 && runNumber <= 105268) { | |
552 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #3019 #669"; | |
553 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #2454 #346"; | |
554 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #1234 #2128"; | |
555 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #790"; | |
556 | else AliError(Form("Unknown trigger: %s", trigger)); | |
ca234d7a | 557 | } if (runNumber == 114786 || runNumber == 114798 || runNumber == 114783 ) { |
558 | if (!strcmp("CINT1B-ABCE-NOPF-ALL",trigger)) return " #346"; | |
559 | else if(!strcmp("CINT1A-ABCE-NOPF-ALL",trigger)) return " #2131"; | |
560 | else if(!strcmp("CINT1C-ABCE-NOPF-ALL",trigger)) return " #3019"; | |
561 | else if(!strcmp("CINT1-E-NOPF-ALL",trigger)) return " #1238"; | |
562 | else AliError(Form("Unknown trigger: %s", trigger)); | |
85c71ba7 | 563 | } |
564 | else { | |
565 | AliError(Form("Unknown run %d, using all BXs!",runNumber)); | |
566 | } | |
567 | ||
568 | return ""; | |
569 | } | |
61899827 | 570 | |
85c71ba7 | 571 | Bool_t AliPhysicsSelection::Initialize(Int_t runNumber) |
61899827 | 572 | { |
573 | // initializes the object for the given run | |
574 | // TODO having the run number here and parameters hardcoded is clearly temporary, a way needs to be found to have a CDB-like configuration also for analysis | |
575 | ||
29e8486e | 576 | Bool_t oldStatus = TH1::AddDirectoryStatus(); |
577 | TH1::AddDirectory(kFALSE); | |
578 | ||
85c71ba7 | 579 | if(!fBin0CallBack) |
580 | AliError("Bin0 Callback not set: will not fill the statistics for the bin 0"); | |
581 | ||
582 | if (fMC) { | |
583 | // ovverride BX and bg options in case of MC | |
584 | fComputeBG = kFALSE; | |
585 | fUseBXNumbers = kFALSE; | |
586 | } | |
587 | ||
a2ce3799 | 588 | Int_t triggerScheme = GetTriggerScheme(runNumber); |
91bea6e7 | 589 | if (!fUsingCustomClasses && fCurrentRun != -1 && triggerScheme != GetTriggerScheme(fCurrentRun)) |
a2ce3799 | 590 | AliFatal("Processing several runs with different trigger schemes is not supported"); |
296dd262 | 591 | |
85c71ba7 | 592 | if(fComputeBG && fCurrentRun != -1 && fCurrentRun != runNumber) |
593 | AliFatal("Cannot process several runs because BG computation is requested"); | |
594 | ||
595 | if(fComputeBG && !fUseBXNumbers) | |
596 | AliFatal("Cannot compute BG id BX numbers are not used"); | |
597 | ||
598 | if(fUseBXNumbers && fFillingScheme != "" && fFillingScheme != GetFillingScheme(runNumber)) | |
599 | AliFatal("Cannot process runs with different filling scheme if usage of BX numbers is requested"); | |
600 | ||
601 | fRatioBEEE = GetRatioBBBE(runNumber); | |
602 | fFillingScheme = GetFillingScheme(runNumber); | |
603 | ||
604 | if(fComputeBG) SetBIFactors(runNumber); | |
605 | ||
61899827 | 606 | AliInfo(Form("Initializing for run %d", runNumber)); |
607 | ||
758941d4 | 608 | // initialize first time? |
a2ce3799 | 609 | if (fCurrentRun == -1) |
a2ce3799 | 610 | { |
91bea6e7 | 611 | if (fUsingCustomClasses) { |
612 | AliInfo("Using user-provided trigger classes"); | |
613 | } else { | |
614 | switch (triggerScheme) | |
615 | { | |
a2ce3799 | 616 | case 0: |
617 | fCollTrigClasses.Add(new TObjString("")); | |
618 | break; | |
91bea6e7 | 619 | |
a2ce3799 | 620 | case 1: |
85c71ba7 | 621 | { // need a new scope to avoid cross-initialization errors |
622 | TObjString * cint1b = new TObjString(Form("%s%s","+CINT1B-ABCE-NOPF-ALL", GetBXIDs(runNumber,"CINT1B-ABCE-NOPF-ALL"))); | |
623 | TObjString * cint1a = new TObjString(Form("%s%s","+CINT1A-ABCE-NOPF-ALL", GetBXIDs(runNumber,"CINT1A-ABCE-NOPF-ALL"))); | |
624 | TObjString * cint1c = new TObjString(Form("%s%s","+CINT1C-ABCE-NOPF-ALL", GetBXIDs(runNumber,"CINT1C-ABCE-NOPF-ALL"))); | |
625 | TObjString * cint1e = new TObjString(Form("%s%s","+CINT1-E-NOPF-ALL", GetBXIDs(runNumber,"CINT1-E-NOPF-ALL")) ); | |
626 | // | |
627 | fCollTrigClasses.Add(cint1b); | |
628 | fBGTrigClasses.Add(cint1a); | |
629 | fBGTrigClasses.Add(cint1c); | |
630 | fBGTrigClasses.Add(cint1e); | |
631 | } | |
a2ce3799 | 632 | break; |
633 | ||
4b7e8f3b | 634 | case 2: |
635 | fCollTrigClasses.Add(new TObjString("+CSMBB-ABCE-NOPF-ALL")); | |
636 | fBGTrigClasses.Add(new TObjString("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL")); | |
637 | fBGTrigClasses.Add(new TObjString("+CSMBC-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL")); | |
638 | break; | |
91bea6e7 | 639 | |
a2ce3799 | 640 | default: |
641 | AliFatal(Form("Unsupported trigger scheme %d", triggerScheme)); | |
91bea6e7 | 642 | } |
a2ce3799 | 643 | } |
91bea6e7 | 644 | |
a2ce3799 | 645 | Int_t count = fCollTrigClasses.GetEntries() + fBGTrigClasses.GetEntries(); |
646 | ||
647 | for (Int_t i=0; i<count; i++) | |
648 | { | |
649 | AliTriggerAnalysis* triggerAnalysis = new AliTriggerAnalysis; | |
650 | triggerAnalysis->SetAnalyzeMC(fMC); | |
651 | triggerAnalysis->EnableHistograms(); | |
652 | triggerAnalysis->SetSPDGFOThreshhold(1); | |
653 | fTriggerAnalysis.Add(triggerAnalysis); | |
654 | } | |
655 | ||
85c71ba7 | 656 | // TODO: shall I really delete this? |
657 | if (fHistStatistics[0]) | |
658 | delete fHistStatistics[0]; | |
659 | if (fHistStatistics[1]) | |
660 | delete fHistStatistics[1]; | |
296dd262 | 661 | |
85c71ba7 | 662 | fHistStatistics[kStatIdxBin0] = BookHistStatistics("_Bin0"); |
663 | fHistStatistics[kStatIdxAll] = BookHistStatistics(""); | |
a2ce3799 | 664 | |
665 | if (fHistBunchCrossing) | |
666 | delete fHistBunchCrossing; | |
667 | ||
668 | fHistBunchCrossing = new TH2F("fHistBunchCrossing", "fHistBunchCrossing;bunch crossing number;", 4000, -0.5, 3999.5, count, -0.5, -0.5 + count); | |
669 | ||
85c71ba7 | 670 | Int_t n = 1; |
a2ce3799 | 671 | for (Int_t i=0; i < fCollTrigClasses.GetEntries(); i++) |
672 | { | |
a2ce3799 | 673 | fHistBunchCrossing->GetYaxis()->SetBinLabel(n, ((TObjString*) fCollTrigClasses.At(i))->String()); |
674 | n++; | |
675 | } | |
676 | for (Int_t i=0; i < fBGTrigClasses.GetEntries(); i++) | |
677 | { | |
a2ce3799 | 678 | fHistBunchCrossing->GetYaxis()->SetBinLabel(n, ((TObjString*) fBGTrigClasses.At(i))->String()); |
679 | n++; | |
680 | } | |
85c71ba7 | 681 | |
682 | ||
683 | ||
a2ce3799 | 684 | } |
685 | ||
686 | Int_t count = fCollTrigClasses.GetEntries() + fBGTrigClasses.GetEntries(); | |
296dd262 | 687 | for (Int_t i=0; i<count; i++) |
61899827 | 688 | { |
a2ce3799 | 689 | AliTriggerAnalysis* triggerAnalysis = static_cast<AliTriggerAnalysis*> (fTriggerAnalysis.At(i)); |
690 | ||
296dd262 | 691 | switch (runNumber) |
692 | { | |
a2ce3799 | 693 | case 104315: |
296dd262 | 694 | case 104316: |
695 | case 104320: | |
a2ce3799 | 696 | case 104321: |
296dd262 | 697 | case 104439: |
698 | triggerAnalysis->SetV0TimeOffset(7.5); | |
699 | break; | |
a2ce3799 | 700 | default: |
701 | triggerAnalysis->SetV0TimeOffset(0); | |
296dd262 | 702 | } |
f4ca8f20 | 703 | } |
704 | ||
758941d4 | 705 | fCurrentRun = runNumber; |
706 | ||
29e8486e | 707 | TH1::AddDirectory(oldStatus); |
708 | ||
61899827 | 709 | return kTRUE; |
710 | } | |
711 | ||
85c71ba7 | 712 | TH2F * AliPhysicsSelection::BookHistStatistics(const char * tag) { |
713 | ||
714 | // add 6 rows to count for the estimate of good, accidentals and | |
715 | // BG and the ratio of BG and accidentals to total +ratio goot to | |
716 | // first col + 2 for error on good. | |
717 | ||
718 | Int_t count = fCollTrigClasses.GetEntries() + fBGTrigClasses.GetEntries(); | |
719 | #ifdef VERBOSE_STAT | |
720 | Int_t extrarows = fComputeBG ? 8 : 0; | |
721 | #else | |
722 | Int_t extrarows = fComputeBG ? 3 : 0; | |
723 | #endif | |
724 | TH2F * h = new TH2F(Form("fHistStatistics%s",tag), Form("fHistStatistics - %s ;;",tag), kStatAccepted, 0.5, kStatAccepted+0.5, count+extrarows, -0.5, -0.5 + count+extrarows); | |
725 | ||
726 | h->GetXaxis()->SetBinLabel(kStatTriggerClass, "Trigger class"); | |
727 | h->GetXaxis()->SetBinLabel(kStatHWTrig, "Hardware trigger"); | |
728 | h->GetXaxis()->SetBinLabel(kStatFO1, "FO >= 1"); | |
729 | h->GetXaxis()->SetBinLabel(kStatFO2, "FO >= 2"); | |
730 | h->GetXaxis()->SetBinLabel(kStatV0A, "V0A"); | |
731 | h->GetXaxis()->SetBinLabel(kStatV0C, "V0C"); | |
732 | h->GetXaxis()->SetBinLabel(kStatFMD, "FMD"); | |
733 | h->GetXaxis()->SetBinLabel(kStatSSD1, "SSD >= 2"); | |
734 | h->GetXaxis()->SetBinLabel(kStatV0ABG, "V0A BG"); | |
735 | h->GetXaxis()->SetBinLabel(kStatV0CBG, "V0C BG"); | |
736 | h->GetXaxis()->SetBinLabel(kStatMB1, "(FO >= 1 | V0A | V0C) & !V0 BG"); | |
737 | h->GetXaxis()->SetBinLabel(kStatMB1Prime, "(FO >= 2 | (FO >= 1 & (V0A | V0C)) | (V0A &v0C) ) & !V0 BG"); | |
738 | h->GetXaxis()->SetBinLabel(kStatFO1AndV0, "FO >= 1 & (V0A | V0C) & !V0 BG"); | |
739 | h->GetXaxis()->SetBinLabel(kStatV0, "V0A & V0C & !V0 BG & !BG ID"); | |
740 | h->GetXaxis()->SetBinLabel(kStatOffline, "Offline Trigger"); | |
741 | h->GetXaxis()->SetBinLabel(kStatAny2Hits, "2 Hits & !V0 BG"); | |
742 | h->GetXaxis()->SetBinLabel(kStatBG, "Background identification"); | |
743 | h->GetXaxis()->SetBinLabel(kStatAccepted, "Accepted"); | |
744 | ||
745 | Int_t n = 1; | |
746 | for (Int_t i=0; i < fCollTrigClasses.GetEntries(); i++) | |
747 | { | |
748 | h->GetYaxis()->SetBinLabel(n, ((TObjString*) fCollTrigClasses.At(i))->String()); | |
749 | n++; | |
750 | } | |
751 | for (Int_t i=0; i < fBGTrigClasses.GetEntries(); i++) | |
752 | { | |
753 | h->GetYaxis()->SetBinLabel(n, ((TObjString*) fBGTrigClasses.At(i))->String()); | |
754 | n++; | |
755 | } | |
756 | ||
757 | if(fComputeBG) { | |
758 | h->GetYaxis()->SetBinLabel(n++, "BG (A+C)"); | |
759 | h->GetYaxis()->SetBinLabel(n++, "ACC"); | |
760 | #ifdef VERBOSE_STAT | |
761 | h->GetYaxis()->SetBinLabel(n++, "BG (A+C) % (rel. to CINT1B)"); | |
762 | h->GetYaxis()->SetBinLabel(n++, "ACC % (rel. to CINT1B)"); | |
763 | h->GetYaxis()->SetBinLabel(n++, "ERR GOOD %"); | |
764 | h->GetYaxis()->SetBinLabel(n++, "GOOD % (rel. to 1st col)"); | |
765 | h->GetYaxis()->SetBinLabel(n++, "ERR GOOD"); | |
766 | #endif | |
767 | h->GetYaxis()->SetBinLabel(n++, "GOOD"); | |
768 | } | |
769 | ||
770 | return h; | |
771 | } | |
772 | ||
61899827 | 773 | void AliPhysicsSelection::Print(Option_t* /* option */) const |
774 | { | |
775 | // print the configuration | |
776 | ||
a2ce3799 | 777 | Printf("Configuration initialized for run %d (MC: %d):", fCurrentRun, fMC); |
61899827 | 778 | |
296dd262 | 779 | Printf("Collision trigger classes:"); |
780 | for (Int_t i=0; i < fCollTrigClasses.GetEntries(); i++) | |
781 | Printf("%s", ((TObjString*) fCollTrigClasses.At(i))->String().Data()); | |
61899827 | 782 | |
296dd262 | 783 | Printf("Background trigger classes:"); |
784 | for (Int_t i=0; i < fBGTrigClasses.GetEntries(); i++) | |
785 | Printf("%s", ((TObjString*) fBGTrigClasses.At(i))->String().Data()); | |
786 | ||
787 | AliTriggerAnalysis* triggerAnalysis = dynamic_cast<AliTriggerAnalysis*> (fTriggerAnalysis.At(0)); | |
61899827 | 788 | |
296dd262 | 789 | if (triggerAnalysis) |
790 | { | |
791 | if (triggerAnalysis->GetV0TimeOffset() > 0) | |
792 | Printf("V0 time offset active: %.2f ns", triggerAnalysis->GetV0TimeOffset()); | |
61899827 | 793 | |
296dd262 | 794 | Printf("\nTotal available events:"); |
528640ed | 795 | |
296dd262 | 796 | triggerAnalysis->PrintTriggerClasses(); |
797 | } | |
528640ed | 798 | |
85c71ba7 | 799 | if (fHistStatistics[kStatIdxAll] && fCollTrigClasses.GetEntries() > 0) |
b43e01ed | 800 | { |
cc9d9320 | 801 | Printf("\nSelection statistics for first collision trigger (%s):", ((TObjString*) fCollTrigClasses.First())->String().Data()); |
b43e01ed | 802 | |
85c71ba7 | 803 | Printf("Total events with correct trigger class: %d", (Int_t) fHistStatistics[kStatIdxAll]->GetBinContent(1, 1)); |
804 | Printf("Selected collision candidates: %d", (Int_t) fHistStatistics[kStatIdxAll]->GetBinContent(fHistStatistics[kStatIdxAll]->GetXaxis()->FindBin("Accepted"), 1)); | |
17ba346c | 805 | } |
806 | ||
807 | if (fHistBunchCrossing) | |
808 | { | |
809 | Printf("\nBunch crossing statistics:"); | |
810 | ||
811 | for (Int_t i=1; i<=fHistBunchCrossing->GetNbinsY(); i++) | |
812 | { | |
813 | TString str; | |
814 | str.Form("Trigger %s has accepted events in the bunch crossings: ", fHistBunchCrossing->GetYaxis()->GetBinLabel(i)); | |
815 | ||
816 | for (Int_t j=1; j<=fHistBunchCrossing->GetNbinsX(); j++) | |
817 | if (fHistBunchCrossing->GetBinContent(j, i) > 0) | |
818 | str += Form("%d, ", (Int_t) fHistBunchCrossing->GetXaxis()->GetBinCenter(j)); | |
819 | ||
820 | Printf("%s", str.Data()); | |
821 | } | |
822 | ||
823 | for (Int_t j=1; j<=fHistBunchCrossing->GetNbinsX(); j++) | |
824 | { | |
825 | Int_t count = 0; | |
826 | for (Int_t i=1; i<=fHistBunchCrossing->GetNbinsY(); i++) | |
827 | { | |
828 | if (fHistBunchCrossing->GetBinContent(j, i) > 0) | |
829 | count++; | |
830 | } | |
831 | if (count > 1) | |
832 | Printf("WARNING: Bunch crossing %d has more than one trigger class active. Check BPTX functioning for this run!", (Int_t) fHistBunchCrossing->GetXaxis()->GetBinCenter(j)); | |
833 | } | |
b43e01ed | 834 | } |
91bea6e7 | 835 | |
836 | if (fUsingCustomClasses) | |
837 | Printf("WARNING: Using custom trigger classes!"); | |
838 | if (fSkipTriggerClassSelection) | |
839 | Printf("WARNING: Skipping trigger class selection!"); | |
85c71ba7 | 840 | if (fSkipV0) |
841 | Printf("WARNING: Ignoring V0 information in selection"); | |
842 | if(!fBin0CallBack) | |
843 | Printf("WARNING: Callback not set: will not fill the statistics for the bin 0"); | |
844 | ||
61899827 | 845 | } |
846 | ||
847 | Long64_t AliPhysicsSelection::Merge(TCollection* list) | |
848 | { | |
849 | // Merge a list of AliMultiplicityCorrection objects with this (needed for | |
850 | // PROOF). | |
851 | // Returns the number of merged objects (including this). | |
852 | ||
853 | if (!list) | |
854 | return 0; | |
855 | ||
856 | if (list->IsEmpty()) | |
857 | return 1; | |
858 | ||
859 | TIterator* iter = list->MakeIterator(); | |
860 | TObject* obj; | |
17ba346c | 861 | |
61899827 | 862 | // collections of all histograms |
863 | const Int_t nHists = 9; | |
864 | TList collections[nHists]; | |
865 | ||
866 | Int_t count = 0; | |
867 | while ((obj = iter->Next())) { | |
868 | ||
869 | AliPhysicsSelection* entry = dynamic_cast<AliPhysicsSelection*> (obj); | |
870 | if (entry == 0) | |
871 | continue; | |
17ba346c | 872 | |
873 | collections[0].Add(&(entry->fTriggerAnalysis)); | |
85c71ba7 | 874 | if (entry->fHistStatistics[0]) |
875 | collections[1].Add(entry->fHistStatistics[0]); | |
876 | if (entry->fHistStatistics[1]) | |
877 | collections[2].Add(entry->fHistStatistics[1]); | |
17ba346c | 878 | if (entry->fHistBunchCrossing) |
85c71ba7 | 879 | collections[3].Add(entry->fHistBunchCrossing); |
296dd262 | 880 | if (entry->fBackgroundIdentification) |
85c71ba7 | 881 | collections[4].Add(entry->fBackgroundIdentification); |
61899827 | 882 | |
883 | count++; | |
884 | } | |
885 | ||
17ba346c | 886 | fTriggerAnalysis.Merge(&collections[0]); |
85c71ba7 | 887 | if (fHistStatistics[0]) |
888 | fHistStatistics[0]->Merge(&collections[1]); | |
889 | if (fHistStatistics[1]) | |
890 | fHistStatistics[1]->Merge(&collections[2]); | |
17ba346c | 891 | if (fHistBunchCrossing) |
85c71ba7 | 892 | fHistBunchCrossing->Merge(&collections[3]); |
296dd262 | 893 | if (fBackgroundIdentification) |
85c71ba7 | 894 | fBackgroundIdentification->Merge(&collections[4]); |
61899827 | 895 | |
896 | delete iter; | |
897 | ||
898 | return count+1; | |
899 | } | |
900 | ||
901 | void AliPhysicsSelection::SaveHistograms(const char* folder) const | |
902 | { | |
903 | // write histograms to current directory | |
904 | ||
85c71ba7 | 905 | if (!fHistStatistics[0] || !fHistStatistics[1]) |
61899827 | 906 | return; |
907 | ||
908 | if (folder) | |
909 | { | |
910 | gDirectory->mkdir(folder); | |
911 | gDirectory->cd(folder); | |
912 | } | |
913 | ||
85c71ba7 | 914 | |
915 | // Fill the last rows of fHistStatistics before saving | |
916 | if (fComputeBG) { | |
917 | Int_t triggerScheme = GetTriggerScheme(UInt_t(fCurrentRun)); | |
918 | if(triggerScheme != 1){ | |
919 | AliWarning("BG estimate only supported for trigger scheme \"1\" (CINT1 suite)"); | |
920 | } else { | |
921 | Int_t nHistStat = 2; | |
922 | // TODO: get number of rows in a more flexible way | |
923 | // 1. loop over all cols | |
924 | ||
925 | for(Int_t iHistStat = 0; iHistStat < nHistStat; iHistStat++){ | |
926 | ||
927 | Int_t ncol = fHistStatistics[iHistStat]->GetNbinsX(); | |
928 | Float_t good1 = 0; | |
929 | for(Int_t icol = 1; icol <= ncol; icol++) { | |
930 | Int_t cint1B = (Int_t) fHistStatistics[iHistStat]->GetBinContent(icol,1); | |
931 | Int_t cint1A = (Int_t) fHistStatistics[iHistStat]->GetBinContent(icol,2); | |
932 | Int_t cint1C = (Int_t) fHistStatistics[iHistStat]->GetBinContent(icol,3); | |
933 | Int_t cint1E = (Int_t) fHistStatistics[iHistStat]->GetBinContent(icol,4); | |
934 | ||
935 | if (cint1B>0) { | |
936 | Int_t acc = fRatioBEEE*cint1E; | |
ca234d7a | 937 | Double_t acc_err = TMath::Sqrt(fRatioBEEE*fRatioBEEE*cint1E); |
85c71ba7 | 938 | // Int_t bg = cint1A + cint1C - 2*acc; |
939 | Float_t bg = fBIFactorA*(cint1A-acc) + fBIFactorC*(cint1C-acc) ; | |
940 | Float_t good = Float_t(cint1B) - bg - acc; | |
941 | if (icol ==1) good1 = good; | |
942 | // Float_t errGood = TMath::Sqrt(2*(cint1A+cint1C+cint1E));// Error on the number of goods assuming only bg fluctuates | |
943 | // DeltaG^2 = B + FA^2 A + FC^2 C + Ratio^2 (FA+FC-1)^2 E. | |
944 | Float_t errGood = TMath::Sqrt( cint1B + | |
945 | fBIFactorA*fBIFactorA*cint1A + | |
946 | fBIFactorC*fBIFactorC*cint1C + | |
947 | fRatioBEEE * fRatioBEEE * | |
948 | (fBIFactorA + fBIFactorC - 1)*(fBIFactorA + fBIFactorC - 1)*cint1E); | |
949 | Float_t errBG = TMath::Sqrt(fBIFactorA*fBIFactorA*cint1A+ | |
950 | fBIFactorC*fBIFactorC*cint1C+ | |
951 | fRatioBEEE*fRatioBEEE*(fBIFactorA+fBIFactorC)*(fBIFactorA+fBIFactorC)*cint1E); | |
952 | ||
953 | ||
954 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowBG,bg); | |
955 | fHistStatistics[iHistStat]->SetBinError (icol,kStatRowBG,errBG); | |
956 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowAcc,acc); | |
ca234d7a | 957 | fHistStatistics[iHistStat]->SetBinError (icol,kStatRowAcc,acc_err); |
85c71ba7 | 958 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowGood,good); |
959 | fHistStatistics[iHistStat]->SetBinError (icol,kStatRowGood,errGood); | |
960 | ||
961 | #ifdef VERBOSE_STAT | |
ca234d7a | 962 | //kStatRowBG=5,kStatRowAcc,kStatRowBGFrac,kStatRowAccFrac,kStatRowErrGoodFrac,kStatRowGoodFrac,kStatRowGood,kStatRowErrGood |
85c71ba7 | 963 | Float_t accFrac = Float_t(acc) / cint1B *100; |
ca234d7a | 964 | Float_t errAccFrac= Float_t(acc_err) / cint1B *100; |
85c71ba7 | 965 | Float_t bgFrac = Float_t(bg) / cint1B *100; |
966 | Float_t goodFrac = Float_t(good) / good1 *100; | |
967 | Float_t errGoodFrac = errGood/good1 * 100; | |
968 | Float_t errFracBG = bg > 0 ? TMath::Sqrt(errBG/bg + 1/TMath::Sqrt(cint1B))*bgFrac : 0; | |
969 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowBGFrac,bgFrac); | |
970 | fHistStatistics[iHistStat]->SetBinError (icol,kStatRowBGFrac,errFracBG); | |
971 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowAccFrac,accFrac); | |
ca234d7a | 972 | fHistStatistics[iHistStat]->SetBinError (icol,kStatRowAccFrac,errAccFrac); |
85c71ba7 | 973 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowGoodFrac,goodFrac); |
ca234d7a | 974 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowErrGoodFrac,errGoodFrac); |
85c71ba7 | 975 | fHistStatistics[iHistStat]->SetBinContent(icol,kStatRowErrGood,errGood); |
976 | #endif | |
977 | } | |
978 | } | |
979 | } | |
980 | } | |
981 | } | |
982 | ||
983 | fHistStatistics[0]->Write(); | |
984 | fHistStatistics[1]->Write(); | |
61899827 | 985 | fHistBunchCrossing->Write(); |
986 | ||
296dd262 | 987 | Int_t count = fCollTrigClasses.GetEntries() + fBGTrigClasses.GetEntries(); |
988 | for (Int_t i=0; i < count; i++) | |
989 | { | |
990 | TString triggerClass = "trigger_histograms_"; | |
991 | if (i < fCollTrigClasses.GetEntries()) | |
992 | triggerClass += ((TObjString*) fCollTrigClasses.At(i))->String(); | |
993 | else | |
994 | triggerClass += ((TObjString*) fBGTrigClasses.At(i - fCollTrigClasses.GetEntries()))->String(); | |
61899827 | 995 | |
296dd262 | 996 | gDirectory->mkdir(triggerClass); |
997 | gDirectory->cd(triggerClass); | |
61899827 | 998 | |
296dd262 | 999 | static_cast<AliTriggerAnalysis*> (fTriggerAnalysis.At(i))->SaveHistograms(); |
1000 | ||
1001 | gDirectory->cd(".."); | |
1002 | } | |
1003 | ||
1004 | if (fBackgroundIdentification) | |
1005 | { | |
1006 | gDirectory->mkdir("background_identification"); | |
1007 | gDirectory->cd("background_identification"); | |
1008 | ||
1009 | fBackgroundIdentification->GetOutput()->Write(); | |
1010 | ||
1011 | gDirectory->cd(".."); | |
1012 | } | |
61899827 | 1013 | |
1014 | if (folder) | |
1015 | gDirectory->cd(".."); | |
1016 | } | |
85c71ba7 | 1017 | |
1018 | void AliPhysicsSelection::SetBIFactors(Int_t run) { | |
1019 | ||
1020 | switch(run) { | |
1021 | case 104155: | |
1022 | fBIFactorA = 0.961912722908; | |
1023 | fBIFactorC = 1.04992336081; | |
1024 | break; | |
1025 | case 104157: | |
1026 | fBIFactorA = 0.947312854998; | |
1027 | fBIFactorC = 1.01599706417; | |
1028 | break; | |
1029 | case 104159: | |
1030 | fBIFactorA = 0.93659320151; | |
1031 | fBIFactorC = 0.98580804207; | |
1032 | break; | |
1033 | case 104160: | |
1034 | fBIFactorA = 0.929664189926; | |
1035 | fBIFactorC = 0.963467679851; | |
1036 | break; | |
1037 | case 104315: | |
1038 | fBIFactorA = 1.08939104979; | |
1039 | fBIFactorC = 0.931113921925; | |
1040 | break; | |
1041 | case 104316: | |
1042 | fBIFactorA = 1.08351880974; | |
1043 | fBIFactorC = 0.916068345845; | |
1044 | break; | |
1045 | case 104320: | |
1046 | fBIFactorA = 1.07669281245; | |
1047 | fBIFactorC = 0.876818744763; | |
1048 | break; | |
1049 | case 104321: | |
1050 | fBIFactorA = 1.00971079602; | |
1051 | fBIFactorC = 0.773781299076; | |
1052 | break; | |
1053 | case 104792: | |
1054 | fBIFactorA = 0.787215863962; | |
1055 | fBIFactorC = 0.778253173071; | |
1056 | break; | |
1057 | case 104793: | |
1058 | fBIFactorA = 0.692211363661; | |
1059 | fBIFactorC = 0.733152456667; | |
1060 | break; | |
1061 | case 104799: | |
1062 | fBIFactorA = 1.04027825161; | |
1063 | fBIFactorC = 1.00530825942; | |
1064 | break; | |
1065 | case 104800: | |
1066 | fBIFactorA = 1.05309910671; | |
1067 | fBIFactorC = 1.00376801855; | |
1068 | break; | |
1069 | case 104801: | |
1070 | fBIFactorA = 1.0531231922; | |
1071 | fBIFactorC = 0.992439666758; | |
1072 | break; | |
1073 | case 104802: | |
1074 | fBIFactorA = 1.04191478134; | |
1075 | fBIFactorC = 0.979368585208; | |
1076 | break; | |
1077 | case 104803: | |
1078 | fBIFactorA = 1.03121314094; | |
1079 | fBIFactorC = 0.973379962609; | |
1080 | break; | |
1081 | case 104824: | |
1082 | fBIFactorA = 0.969945926722; | |
1083 | fBIFactorC = 0.39549745806; | |
1084 | break; | |
1085 | case 104825: | |
1086 | fBIFactorA = 0.968627213937; | |
1087 | fBIFactorC = 0.310100412205; | |
1088 | break; | |
1089 | case 104841: | |
1090 | fBIFactorA = 0.991601393212; | |
1091 | fBIFactorC = 0.83762204722; | |
1092 | break; | |
1093 | case 104845: | |
1094 | fBIFactorA = 0.98040863886; | |
1095 | fBIFactorC = 0.694824205793; | |
1096 | break; | |
1097 | case 104867: | |
1098 | fBIFactorA = 1.10646173412; | |
1099 | fBIFactorC = 0.841407246916; | |
1100 | break; | |
1101 | case 104876: | |
1102 | fBIFactorA = 1.12063452421; | |
1103 | fBIFactorC = 0.78726542895; | |
1104 | break; | |
1105 | case 104890: | |
1106 | fBIFactorA = 1.02346137453; | |
1107 | fBIFactorC = 1.03355663595; | |
1108 | break; | |
1109 | case 104892: | |
1110 | fBIFactorA = 1.05406025913; | |
1111 | fBIFactorC = 1.00029166135; | |
1112 | break; | |
1113 | case 105143: | |
1114 | fBIFactorA = 0.947343384349; | |
1115 | fBIFactorC = 0.972637444408; | |
1116 | break; | |
1117 | case 105160: | |
1118 | fBIFactorA = 0.908854622177; | |
1119 | fBIFactorC = 0.958851103977; | |
1120 | break; | |
1121 | case 105256: | |
1122 | fBIFactorA = 0.810076150206; | |
1123 | fBIFactorC = 0.884663561883; | |
1124 | break; | |
1125 | case 105257: | |
1126 | fBIFactorA = 0.80974912303; | |
1127 | fBIFactorC = 0.878859123479; | |
1128 | break; | |
1129 | case 105268: | |
1130 | fBIFactorA = 0.809052110679; | |
1131 | fBIFactorC = 0.87233890989; | |
1132 | break; | |
1133 | default: | |
1134 | fBIFactorA = 1; | |
1135 | fBIFactorC = 1; | |
1136 | } | |
1137 | ||
1138 | ||
1139 | } |