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