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