]>
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"), | |
32 | fESD(0),fHistoList(0),fIsMC(0),fTriggerAnalysis(0) | |
33 | { | |
34 | // constructor | |
35 | ||
36 | DefineOutput(1, AliHistoListWrapper::Class()); | |
37 | ||
38 | } | |
39 | AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy(const char * name) | |
40 | : AliAnalysisTaskSE(name), | |
41 | fESD(0),fHistoList(0),fIsMC(0),fTriggerAnalysis(0) | |
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) : | |
52 | AliAnalysisTaskSE(obj) ,fESD (0), fIsMC(0), fTriggerAnalysis(0) | |
53 | { | |
54 | //copy ctor | |
55 | fESD = obj.fESD ; | |
56 | fHistoList = obj.fHistoList; | |
57 | fTriggerAnalysis = obj.fTriggerAnalysis; | |
58 | } | |
59 | ||
60 | AliAnalysisTaskTriggerStudy::~AliAnalysisTaskTriggerStudy(){ | |
61 | // destructor | |
62 | ||
63 | if(!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { | |
64 | if(fHistoList) { | |
65 | delete fHistoList; | |
66 | fHistoList = 0; | |
67 | } | |
68 | if(fTriggerAnalysis) { | |
69 | delete fTriggerAnalysis; | |
70 | fHistoList = 0; | |
71 | } | |
72 | } | |
73 | // Histo list should not be destroyed: fListWrapper is owner! | |
74 | ||
75 | } | |
76 | void AliAnalysisTaskTriggerStudy::UserCreateOutputObjects() | |
77 | { | |
78 | // Called once | |
79 | fHistoList = new AliHistoListWrapper("histoList","histogram list for trigger studies"); | |
80 | fTriggerAnalysis = new AliTriggerAnalysis(); | |
81 | } | |
82 | ||
83 | ||
84 | void AliAnalysisTaskTriggerStudy::UserExec(Option_t *) | |
85 | { | |
86 | // User code | |
87 | ||
88 | /* PostData(0) is taken care of by AliAnalysisTaskSE */ | |
89 | PostData(1,fHistoList); | |
90 | ||
91 | fESD = dynamic_cast<AliESDEvent*>(fInputEvent); | |
92 | if (strcmp(fESD->ClassName(),"AliESDEvent")) { | |
93 | AliFatal("Not processing ESDs"); | |
94 | } | |
95 | ||
96 | // FIXME: two options here: either we add a loop setting the name of | |
97 | // the histos with the trigger class in them (there may be a global | |
98 | // SetHistoNamePrefix) or I put a cut to select only collision | |
99 | // classes | |
100 | ||
101 | // get the multiplicity object | |
102 | const AliMultiplicity* mult = fESD->GetMultiplicity(); | |
103 | Int_t ntracklets = mult->GetNumberOfTracklets(); | |
104 | ||
105 | GetHistoTracklets("all","All events")->Fill(ntracklets); | |
106 | ||
107 | // Fast or in the outer layer | |
108 | Int_t nFastOrOnline = fTriggerAnalysis->SPDFiredChips(fESD, 1, 0, 2); // offline | |
109 | Int_t nFastOrOffline = fTriggerAnalysis->SPDFiredChips(fESD, 0, 0, 2); // online | |
110 | ||
111 | if(nFastOrOffline != nFastOrOnline) { | |
112 | GetHistoTracklets("mismatchingFastOr", "Events where fast or offline differs from fast-or online")->Fill(ntracklets); | |
113 | } | |
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 | |
125 | Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw tr | |
126 | ||
127 | if (c0v0A != v0AHW){ | |
128 | GetHistoTracklets("mismatchingV0A", "Events where V0A offline differs from V0A online")->Fill(ntracklets); | |
129 | } | |
130 | ||
131 | if (c0v0C != v0CHW){ | |
132 | GetHistoTracklets("mismatchingV0C", "Events where V0C offline differs from V0C online")->Fill(ntracklets); | |
133 | } | |
134 | ||
135 | // TOF triggers | |
136 | // FIXME: implement real triggers | |
137 | Bool_t c0OM2 = kFALSE; | |
138 | Bool_t c0OM3 = kFALSE; | |
139 | ||
140 | // Some macros for the online triggers | |
141 | Bool_t cMBS2A = c0sm2 && c0v0A; | |
142 | Bool_t cMBS2C = c0sm2 && c0v0C; | |
143 | Bool_t cMBAC = c0v0A && c0v0C; | |
144 | ||
145 | // Fill a tracklet histo for each trigger type | |
146 | if(c0sm1) GetHistoTracklets("c0sm1" ,"Events were trigger c0sm1 fired" )->Fill(ntracklets); | |
147 | if(c0sm2) GetHistoTracklets("c0sm2" ,"Events were trigger c0sm2 fired" )->Fill(ntracklets); | |
148 | if(c0sm3) GetHistoTracklets("c0sm3" ,"Events were trigger c0sm3 fired" )->Fill(ntracklets); | |
149 | if(c0sm4) GetHistoTracklets("c0sm4" ,"Events were trigger c0sm4 fired" )->Fill(ntracklets); | |
150 | if(c0sm5) GetHistoTracklets("c0sm5" ,"Events were trigger c0sm5 fired" )->Fill(ntracklets); | |
151 | if(c0OM2) GetHistoTracklets("c0OM2" ,"Events were trigger c0OM2 fired" )->Fill(ntracklets); | |
152 | if(c0OM3) GetHistoTracklets("c0OM3" ,"Events were trigger c0OM3 fired" )->Fill(ntracklets); | |
153 | if(c0v0A) GetHistoTracklets("c0v0A" ,"Events were trigger c0v0A fired" )->Fill(ntracklets); | |
154 | if(c0v0C) GetHistoTracklets("c0v0C" ,"Events were trigger c0v0C fired" )->Fill(ntracklets); | |
155 | if(cMBS2A) GetHistoTracklets("cMBS2A","Events were trigger cMBS2A fired")->Fill(ntracklets); | |
156 | if(cMBS2C) GetHistoTracklets("cMBS2C","Events were trigger cMBS2C fired")->Fill(ntracklets); | |
157 | if(cMBAC ) GetHistoTracklets("cMBAC ","Events were trigger cMBAC fired")->Fill(ntracklets); | |
158 | // if() GetHistoTracklets("","Events were trigger fired"); | |
159 | ||
160 | ||
161 | // if (fIsMC) { | |
162 | ||
163 | ||
164 | // if (!fMCEvent) { | |
165 | // AliError("No MC info found"); | |
166 | // } else { | |
167 | ||
168 | // //loop on the MC event | |
169 | // // Int_t nMCTracks = fMCEvent->GetNumberOfTracks(); | |
170 | // Int_t offset = fMCEvent->GetPrimaryOffset(); | |
171 | // Int_t nMCTracks = fMCEvent->GetNumberOfPrimaries()+offset; | |
172 | // for (Int_t ipart=offset; ipart<nMCTracks; ipart++) { | |
173 | ||
174 | // AliMCParticle *mcPart = (AliMCParticle*)fMCEvent->GetTrack(ipart); | |
175 | ||
176 | // // We don't care about neutrals and non-physical primaries | |
177 | // if(mcPart->Charge() == 0) continue; | |
178 | ||
179 | // // FIXME: add kTransportBit (uncomment below) | |
180 | // if(!fMCEvent->Stack()->IsPhysicalPrimary(ipart)) continue; | |
181 | ||
182 | // //check if current particle is a physical primary | |
183 | // // Bool_t physprim=fMCEvent->IsPhysicalPrimary(label); | |
184 | // // if (!physprim) continue; | |
185 | // // if (!track) return kFALSE; | |
186 | // // Bool_t transported = mcPart->Particle()->TestBit(kTransportBit); | |
187 | // // if(!transported) return kFALSE; | |
188 | ||
189 | // // Get MC vertex | |
190 | // //FIXME: which vertex do I take for MC? | |
191 | // TArrayF vertex; | |
192 | // fMCEvent->GenEventHeader()->PrimaryVertex(vertex); | |
193 | // Float_t zv = vertex[2]; | |
194 | // // Float_t zv = vtxESD->GetZ(); | |
195 | // // Fill generated histo | |
196 | // hTracks[AliAnalysisMultPbTrackHistoManager::kHistoGen]->Fill(mcPart->Pt(),mcPart->Eta(),zv); | |
197 | ||
198 | // } | |
199 | // } | |
200 | // } | |
201 | ||
202 | ||
203 | ||
204 | ||
205 | } | |
206 | ||
207 | void AliAnalysisTaskTriggerStudy::Terminate(Option_t *){ | |
208 | // terminate | |
209 | // Save output in a more friendly format | |
210 | fHistoList = dynamic_cast<AliHistoListWrapper*> (GetOutputData(1)); | |
211 | if (!fHistoList){ | |
212 | Printf("ERROR: fHistoList not available"); | |
213 | return; | |
214 | } | |
215 | TFile * f = new TFile("trigger_study.root", "recreate"); | |
216 | fHistoList->GetList()->Write(); | |
217 | f->Close(); | |
218 | ||
219 | } | |
220 | ||
221 | TH1 * AliAnalysisTaskTriggerStudy::GetHistoTracklets(const char * name, const char * title){ | |
222 | // terminate | |
223 | ||
224 | TString hname = "h"; | |
225 | hname+=name; | |
226 | TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data()); | |
227 | ||
228 | if(!h) { | |
229 | AliInfo(Form("Booking histo %s",hname.Data())); | |
230 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
231 | TH1::AddDirectory(kFALSE); | |
232 | h = new TH1F (hname.Data(), title, 50, 0.5, 200); | |
233 | h->Sumw2(); | |
234 | h->SetXTitle("ntracklets"); | |
235 | fHistoList->GetList()->Add(h); | |
236 | TH1::AddDirectory(oldStatus); | |
237 | } | |
238 | return h; | |
239 | } | |
240 | ||
241 |