]>
Commit | Line | Data |
---|---|---|
9d173aad | 1 | // AliAnalysisTaskTriggerStudy |
2 | ||
3 | // Author: Michele Floris, CERN | |
4 | // TODO: | |
5 | // - Add chi2/cluster plot for primary, secondaries and fakes | |
6 | ||
7 | ||
8 | #include "AliAnalysisTaskTriggerStudy.h" | |
9 | #include "AliESDInputHandler.h" | |
10 | #include "AliHistoListWrapper.h" | |
11 | #include "AliAnalysisManager.h" | |
12 | #include "AliMCEvent.h" | |
13 | #include "AliStack.h" | |
14 | #include "TH1I.h" | |
15 | #include "TH3D.h" | |
16 | #include "AliMCParticle.h" | |
17 | #include "AliGenEventHeader.h" | |
18 | #include "AliESDCentrality.h" | |
19 | ||
20 | #include <iostream> | |
21 | #include "AliTriggerAnalysis.h" | |
22 | #include "AliMultiplicity.h" | |
23 | #include "TFile.h" | |
24 | #include "AliLog.h" | |
25 | ||
26 | using namespace std; | |
27 | ||
28 | ClassImp(AliAnalysisTaskTriggerStudy) | |
29 | ||
7f5f2e0c | 30 | //const char * AliAnalysisTaskTriggerStudy::kVDNames[] = {"C0SM1","C0SM2","C0VBA","C0VBC","C0OM2"}; |
31 | const char * AliAnalysisTaskTriggerStudy::kVDNames[] = {"C0SM1","C0SM2","C0VBA","C0VBC"};//,"C0OM2"}; | |
52d405b5 | 32 | |
9d173aad | 33 | AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy() |
34 | : AliAnalysisTaskSE("TaskTriggerStudy"), | |
52d405b5 | 35 | fESD(0),fHistoList(0),fIsMC(0),fTriggerAnalysis(0),fHistoSuffix(""),fNTrackletsCut(1000000) |
9d173aad | 36 | { |
37 | // constructor | |
38 | ||
39 | DefineOutput(1, AliHistoListWrapper::Class()); | |
40 | ||
41 | } | |
42 | AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy(const char * name) | |
43 | : AliAnalysisTaskSE(name), | |
52d405b5 | 44 | fESD(0),fHistoList(0),fIsMC(0),fTriggerAnalysis(0),fHistoSuffix(""),fNTrackletsCut(1000000) |
9d173aad | 45 | { |
46 | // | |
47 | // Standard constructur which should be used | |
48 | // | |
49 | ||
50 | DefineOutput(1, AliHistoListWrapper::Class()); | |
51 | ||
52 | } | |
53 | ||
54 | AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy(const AliAnalysisTaskTriggerStudy& obj) : | |
a82dc581 | 55 | AliAnalysisTaskSE(obj) ,fESD (0), fIsMC(0), fTriggerAnalysis(0),fHistoSuffix("") |
9d173aad | 56 | { |
57 | //copy ctor | |
58 | fESD = obj.fESD ; | |
59 | fHistoList = obj.fHistoList; | |
60 | fTriggerAnalysis = obj.fTriggerAnalysis; | |
a82dc581 | 61 | fHistoSuffix = obj.fHistoSuffix; |
9d173aad | 62 | } |
63 | ||
64 | AliAnalysisTaskTriggerStudy::~AliAnalysisTaskTriggerStudy(){ | |
65 | // destructor | |
66 | ||
67 | if(!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { | |
68 | if(fHistoList) { | |
69 | delete fHistoList; | |
70 | fHistoList = 0; | |
71 | } | |
72 | if(fTriggerAnalysis) { | |
73 | delete fTriggerAnalysis; | |
74 | fHistoList = 0; | |
75 | } | |
76 | } | |
77 | // Histo list should not be destroyed: fListWrapper is owner! | |
78 | ||
79 | } | |
80 | void AliAnalysisTaskTriggerStudy::UserCreateOutputObjects() | |
81 | { | |
82 | // Called once | |
83 | fHistoList = new AliHistoListWrapper("histoList","histogram list for trigger studies"); | |
84 | fTriggerAnalysis = new AliTriggerAnalysis(); | |
85 | } | |
86 | ||
87 | ||
88 | void AliAnalysisTaskTriggerStudy::UserExec(Option_t *) | |
89 | { | |
90 | // User code | |
91 | ||
92 | /* PostData(0) is taken care of by AliAnalysisTaskSE */ | |
93 | PostData(1,fHistoList); | |
94 | ||
95 | fESD = dynamic_cast<AliESDEvent*>(fInputEvent); | |
96 | if (strcmp(fESD->ClassName(),"AliESDEvent")) { | |
97 | AliFatal("Not processing ESDs"); | |
98 | } | |
99 | ||
9d173aad | 100 | |
101 | // get the multiplicity object | |
102 | const AliMultiplicity* mult = fESD->GetMultiplicity(); | |
103 | Int_t ntracklets = mult->GetNumberOfTracklets(); | |
104 | ||
52d405b5 | 105 | if(ntracklets > fNTrackletsCut) return; |
106 | ||
a82dc581 | 107 | // Reset histo suffix and fill reference histograms without any suffix |
108 | fHistoSuffix = ""; | |
9d173aad | 109 | GetHistoTracklets("all","All events")->Fill(ntracklets); |
110 | ||
111 | // Fast or in the outer layer | |
112 | Int_t nFastOrOnline = fTriggerAnalysis->SPDFiredChips(fESD, 1, 0, 2); // offline | |
113 | Int_t nFastOrOffline = fTriggerAnalysis->SPDFiredChips(fESD, 0, 0, 2); // online | |
9d173aad | 114 | |
115 | Bool_t c0sm1 = nFastOrOffline >= 1; | |
116 | Bool_t c0sm2 = nFastOrOffline >= 2; | |
117 | Bool_t c0sm3 = nFastOrOffline >= 3; | |
118 | Bool_t c0sm4 = nFastOrOffline >= 4; | |
119 | Bool_t c0sm5 = nFastOrOffline >= 5; | |
120 | ||
121 | // V0 triggers | |
122 | Bool_t c0v0A = fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0A); | |
123 | Bool_t c0v0C = fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0C); | |
124 | Bool_t v0AHW = (fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw trigger | |
a82dc581 | 125 | Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw trigger |
9d173aad | 126 | |
9d173aad | 127 | // TOF triggers |
52d405b5 | 128 | // FIXME: move to triggeranalysis? |
129 | AliESDHeader*h = fESD->GetHeader(); // taken the header from AliESDEvent | |
130 | Bool_t c0OM2 = h->IsTriggerInputFired("0OM2"); // thr >= 2 (input 19) | |
131 | Bool_t c0OM3 = h->IsTriggerInputFired("0OM3"); // thr >= 3 (input 20) | |
9d173aad | 132 | |
5ec1c2f5 | 133 | // ZDC triggers |
134 | Bool_t zdcA = fTriggerAnalysis->ZDCTrigger(fESD, AliTriggerAnalysis::kASide) ; | |
135 | Bool_t zdcC = fTriggerAnalysis->ZDCTrigger(fESD, AliTriggerAnalysis::kCSide) ; | |
136 | Bool_t zdcBar = fTriggerAnalysis->ZDCTrigger(fESD, AliTriggerAnalysis::kCentralBarrel) ; | |
137 | ||
9d173aad | 138 | // Some macros for the online triggers |
139 | Bool_t cMBS2A = c0sm2 && c0v0A; | |
140 | Bool_t cMBS2C = c0sm2 && c0v0C; | |
141 | Bool_t cMBAC = c0v0A && c0v0C; | |
52d405b5 | 142 | |
9d173aad | 143 | |
52d405b5 | 144 | Bool_t vdArray[kNVDEntries]; |
5ec1c2f5 | 145 | vdArray[kVDC0MBS1] = c0sm1; |
52d405b5 | 146 | vdArray[kVDC0MBS2] = c0sm2; |
147 | vdArray[kVDC0VBA] = c0v0A; | |
148 | vdArray[kVDC0VBC] = c0v0C; | |
7f5f2e0c | 149 | //vdArray[kVDC0OM2] = c0OM2; |
52d405b5 | 150 | |
151 | FillTriggerOverlaps("All", "All Events",vdArray); | |
a82dc581 | 152 | |
7f5f2e0c | 153 | // Fill some combination of trigger classes |
154 | Bool_t cmbs1aOnline = fESD->IsTriggerClassFired("CMBS1A-B-NOPF-ALL"); | |
155 | Bool_t cmbs1cOnline = fESD->IsTriggerClassFired("CMBS1C-B-NOPF-ALL"); | |
156 | Bool_t cmbacOnline = fESD->IsTriggerClassFired("CMBAC-B-NOPF-ALL"); | |
157 | ||
158 | if (cmbs1aOnline || cmbs1cOnline ||cmbacOnline) GetHistoTracklets("TwoOutOfThree" ,"Events 2-out-of-3 online" )->Fill(ntracklets); | |
159 | ||
a82dc581 | 160 | |
161 | // loop over trigger classes in the event | |
162 | TObjArray * tokens = 0; | |
163 | if(fIsMC) { | |
164 | // in case of montecarlo I override the trigger class | |
165 | tokens = new TObjArray; | |
166 | tokens->SetOwner(); | |
167 | // tokens->Add(new TObjString("CINT1B-ABCE-NOPF-ALL")); | |
168 | tokens->Add(new TObjString("MC")); | |
169 | } | |
170 | else { | |
171 | TString trgClasses = fESD->GetFiredTriggerClasses(); | |
7f5f2e0c | 172 | tokens = trgClasses.Tokenize(" "); |
a82dc581 | 173 | } |
7f5f2e0c | 174 | TIterator * iter = (TIterator*) tokens->MakeIterator(); |
175 | ||
176 | TString classes = fESD->GetFiredTriggerClasses(); | |
177 | ||
178 | // if (classes.Contains("SMH")) { | |
179 | // tokens->Print(); | |
180 | // cout << classes.Data() << endl; | |
181 | // } | |
182 | // iter->Reset(); | |
183 | Int_t itoken = 0; | |
184 | TObjString * tok=0; | |
185 | while((tok = (TObjString*) iter->Next())){ | |
a82dc581 | 186 | // clean up trigger name |
187 | TString trg = tok->GetString(); | |
188 | trg.Strip(TString::kTrailing, ' '); | |
189 | trg.Strip(TString::kLeading, ' '); | |
190 | ||
191 | fHistoSuffix = "_"; | |
192 | fHistoSuffix += trg; | |
193 | ||
7f5f2e0c | 194 | // cout << itoken++ << " " << trg.Data() << endl; |
195 | // continue; | |
196 | // if (trg.Contains("SMH")) cout << itoken++ << " " << trg.Data() << endl; | |
197 | ||
198 | // Fill tracklets | |
199 | GetHistoTracklets("All" ,"Events no offline trigger" )->Fill(ntracklets); | |
200 | ||
201 | ||
a82dc581 | 202 | // Fill histograms mismatchs |
203 | // TODO: check mismatch trigger class | |
204 | if(nFastOrOffline != nFastOrOnline) { | |
205 | GetHistoTracklets("mismatchingFastOr", "Events where fast or offline differs from fast-or online")->Fill(ntracklets); | |
206 | } | |
207 | ||
208 | if (c0v0A != v0AHW){ | |
209 | GetHistoTracklets("mismatchingV0A", "Events where V0A offline differs from V0A online")->Fill(ntracklets); | |
210 | } | |
211 | ||
212 | if (c0v0C != v0CHW){ | |
213 | GetHistoTracklets("mismatchingV0C", "Events where V0C offline differs from V0C online")->Fill(ntracklets); | |
214 | } | |
215 | ||
216 | // Fill a tracklet histo for each trigger type | |
217 | if(c0sm1) GetHistoTracklets("c0sm1" ,"Events were trigger c0sm1 fired" )->Fill(ntracklets); | |
218 | if(c0sm2) GetHistoTracklets("c0sm2" ,"Events were trigger c0sm2 fired" )->Fill(ntracklets); | |
219 | if(c0sm3) GetHistoTracklets("c0sm3" ,"Events were trigger c0sm3 fired" )->Fill(ntracklets); | |
220 | if(c0sm4) GetHistoTracklets("c0sm4" ,"Events were trigger c0sm4 fired" )->Fill(ntracklets); | |
221 | if(c0sm5) GetHistoTracklets("c0sm5" ,"Events were trigger c0sm5 fired" )->Fill(ntracklets); | |
222 | if(c0OM2) GetHistoTracklets("c0OM2" ,"Events were trigger c0OM2 fired" )->Fill(ntracklets); | |
223 | if(c0OM3) GetHistoTracklets("c0OM3" ,"Events were trigger c0OM3 fired" )->Fill(ntracklets); | |
224 | if(c0v0A) GetHistoTracklets("c0v0A" ,"Events were trigger c0v0A fired" )->Fill(ntracklets); | |
225 | if(c0v0C) GetHistoTracklets("c0v0C" ,"Events were trigger c0v0C fired" )->Fill(ntracklets); | |
226 | if(cMBS2A) GetHistoTracklets("cMBS2A","Events were trigger cMBS2A fired")->Fill(ntracklets); | |
227 | if(cMBS2C) GetHistoTracklets("cMBS2C","Events were trigger cMBS2C fired")->Fill(ntracklets); | |
5ec1c2f5 | 228 | if(cMBAC ) GetHistoTracklets("cMBAC", "Events were trigger cMBAC fired")->Fill(ntracklets); |
229 | if(zdcA ) GetHistoTracklets("cZDCA", "Events were trigger cZDCA fired")->Fill(ntracklets); | |
230 | if(zdcC ) GetHistoTracklets("cZDCC", "Events were trigger cZDCC fired")->Fill(ntracklets); | |
231 | if(zdcBar) GetHistoTracklets("cZDCBar","Events were trigger cZDCB fired")->Fill(ntracklets); | |
a82dc581 | 232 | // if() GetHistoTracklets("","Events were trigger fired"); |
52d405b5 | 233 | |
234 | // Fill trigger overlaps | |
235 | FillTriggerOverlaps("All", "All Events in trigger class",vdArray); | |
236 | ||
a82dc581 | 237 | } |
7f5f2e0c | 238 | delete tokens; |
a82dc581 | 239 | |
240 | // if (fIsMC) { | |
9d173aad | 241 | |
242 | ||
243 | // if (!fMCEvent) { | |
244 | // AliError("No MC info found"); | |
245 | // } else { | |
246 | ||
247 | // //loop on the MC event | |
248 | // // Int_t nMCTracks = fMCEvent->GetNumberOfTracks(); | |
249 | // Int_t offset = fMCEvent->GetPrimaryOffset(); | |
250 | // Int_t nMCTracks = fMCEvent->GetNumberOfPrimaries()+offset; | |
251 | // for (Int_t ipart=offset; ipart<nMCTracks; ipart++) { | |
252 | ||
253 | // AliMCParticle *mcPart = (AliMCParticle*)fMCEvent->GetTrack(ipart); | |
254 | ||
255 | // // We don't care about neutrals and non-physical primaries | |
256 | // if(mcPart->Charge() == 0) continue; | |
257 | ||
e0376287 | 258 | // PHYSICAL PRIMARY |
9d173aad | 259 | // // Get MC vertex |
e0376287 | 260 | // TArrayF vertex; |
9d173aad | 261 | // fMCEvent->GenEventHeader()->PrimaryVertex(vertex); |
262 | // Float_t zv = vertex[2]; | |
263 | // // Float_t zv = vtxESD->GetZ(); | |
264 | // // Fill generated histo | |
265 | // hTracks[AliAnalysisMultPbTrackHistoManager::kHistoGen]->Fill(mcPart->Pt(),mcPart->Eta(),zv); | |
266 | ||
267 | // } | |
268 | // } | |
269 | // } | |
270 | ||
271 | ||
272 | ||
273 | ||
274 | } | |
275 | ||
276 | void AliAnalysisTaskTriggerStudy::Terminate(Option_t *){ | |
277 | // terminate | |
278 | // Save output in a more friendly format | |
279 | fHistoList = dynamic_cast<AliHistoListWrapper*> (GetOutputData(1)); | |
280 | if (!fHistoList){ | |
281 | Printf("ERROR: fHistoList not available"); | |
282 | return; | |
283 | } | |
284 | TFile * f = new TFile("trigger_study.root", "recreate"); | |
285 | fHistoList->GetList()->Write(); | |
286 | f->Close(); | |
287 | ||
288 | } | |
289 | ||
290 | TH1 * AliAnalysisTaskTriggerStudy::GetHistoTracklets(const char * name, const char * title){ | |
a82dc581 | 291 | // Book histo of events vs ntracklets, if needed |
9d173aad | 292 | |
a82dc581 | 293 | TString hname = "hTracklets_"; |
294 | hname+=name; | |
295 | hname+=fHistoSuffix; | |
9d173aad | 296 | TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data()); |
297 | ||
298 | if(!h) { | |
299 | AliInfo(Form("Booking histo %s",hname.Data())); | |
300 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
301 | TH1::AddDirectory(kFALSE); | |
7f5f2e0c | 302 | // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5); |
303 | h = new TH1F (hname.Data(), title, 4000, -0.5, 4000-0.5); | |
9d173aad | 304 | h->Sumw2(); |
305 | h->SetXTitle("ntracklets"); | |
306 | fHistoList->GetList()->Add(h); | |
307 | TH1::AddDirectory(oldStatus); | |
308 | } | |
309 | return h; | |
310 | } | |
311 | ||
52d405b5 | 312 | void AliAnalysisTaskTriggerStudy::FillTriggerOverlaps (const char * name, const char * title, Bool_t * vdArray){ |
a82dc581 | 313 | //Fills a histo with the different trigger statistics in a venn like diagramm. Books it if needed. |
314 | ||
315 | // Get or book histo | |
316 | TString hname = "hTrigStat_"; | |
317 | hname+=name; | |
318 | hname+=fHistoSuffix; | |
319 | TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data()); | |
320 | ||
321 | if(!h) { | |
322 | AliInfo(Form("Booking histo %s",hname.Data())); | |
323 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
324 | TH1::AddDirectory(kFALSE); | |
52d405b5 | 325 | Int_t nbins = 0; |
326 | for(Int_t ientry = 0; ientry < kNVDEntries; ientry++){ | |
327 | nbins = nbins | (1<<ientry); | |
328 | } | |
7f5f2e0c | 329 | // cout << "NBINS " << nbins << endl; |
330 | nbins = nbins+1; | |
52d405b5 | 331 | h = new TH1I (hname, title, nbins, -0.5, nbins-0.5); |
a82dc581 | 332 | fHistoList->GetList()->Add(h); |
333 | TH1::AddDirectory(oldStatus); | |
52d405b5 | 334 | |
335 | // we look at the combinations of n triggers | |
336 | // We set a bit for each trigger to fill the diagram | |
337 | // This is much simpler and faster than any recursive function | |
338 | h->GetXaxis()->SetBinLabel(1,"NONE"); | |
339 | for(Int_t ibin = 1; ibin < nbins; ibin++){ | |
340 | TString binname = ""; | |
341 | Bool_t first = kTRUE; | |
342 | for(Int_t ivdentry = 0; ivdentry < kNVDEntries; ivdentry++){ | |
343 | if (ibin & (1<<ivdentry)) { | |
344 | if(!first) binname += " & "; | |
345 | binname += kVDNames[ivdentry]; | |
346 | first=kFALSE; | |
347 | } | |
348 | } | |
349 | h->GetXaxis()->SetBinLabel(ibin+1,binname.Data()); | |
350 | } | |
351 | ||
a82dc581 | 352 | } |
353 | ||
52d405b5 | 354 | UInt_t mask = 0; |
355 | for(Int_t ivdentry = 0; ivdentry < kNVDEntries; ivdentry++){ | |
356 | if(vdArray[ivdentry]) { | |
357 | mask = mask | (1<<ivdentry); | |
358 | // cout << " 1 " ; | |
359 | } //else cout << " 0 "; | |
360 | } | |
361 | // cout << hex << " = " << mask << endl; | |
a82dc581 | 362 | |
52d405b5 | 363 | h->Fill(mask); |
9d173aad | 364 | |
a82dc581 | 365 | } |