]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/multPbPb/AliAnalysisTaskTriggerStudy.cxx
Fixed install target
[u/mrichter/AliRoot.git] / PWG0 / multPbPb / AliAnalysisTaskTriggerStudy.cxx
CommitLineData
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"
eef42d18 25#include "AliESDtrackCuts.h"
bcc49144 26#include "AliESDVZERO.h"
27#include "TH2F.h"
abd808b9 28#include "AliESDUtils.h"
9d173aad 29
30using namespace std;
31
32ClassImp(AliAnalysisTaskTriggerStudy)
33
7f5f2e0c 34//const char * AliAnalysisTaskTriggerStudy::kVDNames[] = {"C0SM1","C0SM2","C0VBA","C0VBC","C0OM2"};
35const char * AliAnalysisTaskTriggerStudy::kVDNames[] = {"C0SM1","C0SM2","C0VBA","C0VBC"};//,"C0OM2"};
52d405b5 36
9d173aad 37AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy()
38: AliAnalysisTaskSE("TaskTriggerStudy"),
eef42d18 39 fESD(0),fHistoList(0),fIsMC(0),fTriggerAnalysis(0),fHistoSuffix(""),fNTrackletsCut(1000000),fNTrackletsCutKine(100),fRejectBGWithV0(0)
9d173aad 40{
41 // constructor
42
43 DefineOutput(1, AliHistoListWrapper::Class());
44
45}
46AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy(const char * name)
47 : AliAnalysisTaskSE(name),
eef42d18 48 fESD(0),fHistoList(0),fIsMC(0),fTriggerAnalysis(0),fHistoSuffix(""),fNTrackletsCut(1000000),fNTrackletsCutKine(100),fRejectBGWithV0(0)
9d173aad 49{
50 //
51 // Standard constructur which should be used
52 //
53
54 DefineOutput(1, AliHistoListWrapper::Class());
55
56}
57
58AliAnalysisTaskTriggerStudy::AliAnalysisTaskTriggerStudy(const AliAnalysisTaskTriggerStudy& obj) :
eef42d18 59 AliAnalysisTaskSE(obj) ,fESD (0), fIsMC(0), fTriggerAnalysis(0),fHistoSuffix(""),fNTrackletsCut(1000000),fNTrackletsCutKine(100),fRejectBGWithV0(0)
9d173aad 60{
61 //copy ctor
62 fESD = obj.fESD ;
63 fHistoList = obj.fHistoList;
64 fTriggerAnalysis = obj.fTriggerAnalysis;
a82dc581 65 fHistoSuffix = obj.fHistoSuffix;
eef42d18 66 fNTrackletsCut = obj.fNTrackletsCut;
67 fNTrackletsCutKine = obj.fNTrackletsCutKine;
68 fRejectBGWithV0 = obj.fRejectBGWithV0;
9d173aad 69}
70
71AliAnalysisTaskTriggerStudy::~AliAnalysisTaskTriggerStudy(){
72 // destructor
73
74 if(!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
75 if(fHistoList) {
76 delete fHistoList;
77 fHistoList = 0;
78 }
79 if(fTriggerAnalysis) {
80 delete fTriggerAnalysis;
81 fHistoList = 0;
82 }
83 }
84 // Histo list should not be destroyed: fListWrapper is owner!
85
86}
87void AliAnalysisTaskTriggerStudy::UserCreateOutputObjects()
88{
89 // Called once
90 fHistoList = new AliHistoListWrapper("histoList","histogram list for trigger studies");
91 fTriggerAnalysis = new AliTriggerAnalysis();
abd808b9 92 if (fIsMC) fTriggerAnalysis->SetAnalyzeMC(1);
9d173aad 93}
94
95
96void AliAnalysisTaskTriggerStudy::UserExec(Option_t *)
97{
98 // User code
99
bcc49144 100 // FIXME: make sure you have the right cuts here
101
9d173aad 102 /* PostData(0) is taken care of by AliAnalysisTaskSE */
103 PostData(1,fHistoList);
104
105 fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
106 if (strcmp(fESD->ClassName(),"AliESDEvent")) {
107 AliFatal("Not processing ESDs");
108 }
109
9d173aad 110 // get the multiplicity object
111 const AliMultiplicity* mult = fESD->GetMultiplicity();
112 Int_t ntracklets = mult->GetNumberOfTracklets();
bcc49144 113 // Get Number of tracks
114 Int_t ntracks = AliESDtrackCuts::GetReferenceMultiplicity(fESD,kTRUE); // tpc only
115
116 // Get V0 Multiplicity
117 AliESDVZERO* esdV0 = fESD->GetVZEROData();
118 Float_t multV0A=esdV0->GetMTotV0A();
119 Float_t multV0C=esdV0->GetMTotV0C();
abd808b9 120 Float_t dummy = 0;
121 Float_t multV0 = AliESDUtils::GetCorrV0(fESD, dummy);
bcc49144 122
123 // Get number of clusters in layer 1
124 Float_t outerLayerSPD = mult->GetNumberOfITSClusters(1);
125 Float_t innerLayerSPD = mult->GetNumberOfITSClusters(0);
126 Float_t totalClusSPD = outerLayerSPD+innerLayerSPD;
127
abd808b9 128 if ( !fIsMC &&(!(fESD->IsTriggerClassFired("CMBS2A-B-NOPF-ALL")|| fESD->IsTriggerClassFired("CMBS2C-B-NOPF-ALL") || fESD->IsTriggerClassFired("CMBAC-B-NOPF-ALL")) )) return;
bcc49144 129 GetHistoSPD1 ("All", "All events before any selection")->Fill(outerLayerSPD);
abd808b9 130 GetHistoV0M ("All", "All events before any selection")->Fill(multV0);
bcc49144 131
132
133 // Physics selection
134 Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
135 if(!isSelected) return;
bcc49144 136
abd808b9 137
138 GetHistoSPD1 ("AllPSNoPrino", "All events after physsel (no ZDC time)")->Fill(outerLayerSPD);
139 GetHistoV0M ("AllPSNoPrino", "All events after physsel (no ZDC time)")->Fill(multV0);
bcc49144 140
141
142 // Francesco's cuts
abd808b9 143 // const AliESDVertex * vtxESDTPC= fESD->GetPrimaryVertexTPC();
144 // if(vtxESDTPC->GetNContributors()<1) return;
145 // if (vtxESDTPC->GetNContributors()<(-10.+0.25*fESD->GetMultiplicity()->GetNumberOfITSClusters(0))) return;
146 // const AliESDVertex * vtxESDSPD= fESD->GetPrimaryVertexSPD();
147 // Float_t tpcContr=vtxESDTPC->GetNContributors();
bcc49144 148
149
150
151 // GetT0 Stuff
152 const Double32_t *meanT0 = fESD->GetT0TOF();
153 const Double32_t meanT0A = 0.001* meanT0[1];
154 const Double32_t meanT0C = 0.001* meanT0[2];
155 const Double32_t meanT0AC = 0.001* meanT0[0];
156 Double32_t T0Vertex = fESD->GetT0zVertex();
157 // Double32_t *ampT0 =Esdevent ->GetT0amplitude();
158
159// cut1yesF = ( (meanC < 95. && meanA < 95.) && (meanC < -2.) ) && francescoscut
160// cut1notF = ( (meanC < 95. && meanA < 95.) && (meanC < -2.) ) && ! francescoscut
161// cut2 = ( (meanC < 95. && meanA < 95.) && ( (meanC-meanA) <=-0.7) && meanC > -2) )
162// cut3 = ( (meanC < 95. && meanA < 95.) && ( (meanC-meanA) < 0.7 && (meanC-meanA) > -0.7 ) )
163// cut4 = ( (meanC < 95. && meanA < 95.) && (meanA < -2.)
164
165 Bool_t cut1T0 = ( (meanT0C < 95. && meanT0A < 95.) && (meanT0C < -2.) );
166 Bool_t cut2T0 = ( (meanT0C < 95. && meanT0A < 95.) && ( (meanT0C-meanT0A) <=-0.7) && meanT0C > -2) ;
9d173aad 167
52d405b5 168 if(ntracklets > fNTrackletsCut) return;
169
a82dc581 170 // Reset histo suffix and fill reference histograms without any suffix
171 fHistoSuffix = "";
9d173aad 172
173 // Fast or in the outer layer
174 Int_t nFastOrOnline = fTriggerAnalysis->SPDFiredChips(fESD, 1, 0, 2); // offline
175 Int_t nFastOrOffline = fTriggerAnalysis->SPDFiredChips(fESD, 0, 0, 2); // online
9d173aad 176
177 Bool_t c0sm1 = nFastOrOffline >= 1;
178 Bool_t c0sm2 = nFastOrOffline >= 2;
179 Bool_t c0sm3 = nFastOrOffline >= 3;
180 Bool_t c0sm4 = nFastOrOffline >= 4;
181 Bool_t c0sm5 = nFastOrOffline >= 5;
182
183 // V0 triggers
184 Bool_t c0v0A = fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0A);
185 Bool_t c0v0C = fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0C);
186 Bool_t v0AHW = (fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw trigger
a82dc581 187 Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(fESD, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);// should replay hw trigger
9d173aad 188
eef42d18 189 Bool_t v0ABG = fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0ABG);
190 Bool_t v0CBG = fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0CBG);
191 Bool_t v0BG = v0ABG || v0CBG;
192
193
9d173aad 194 // TOF triggers
52d405b5 195 // FIXME: move to triggeranalysis?
196 AliESDHeader*h = fESD->GetHeader(); // taken the header from AliESDEvent
197 Bool_t c0OM2 = h->IsTriggerInputFired("0OM2"); // thr >= 2 (input 19)
198 Bool_t c0OM3 = h->IsTriggerInputFired("0OM3"); // thr >= 3 (input 20)
9d173aad 199
5ec1c2f5 200 // ZDC triggers
abd808b9 201 Bool_t zdcA = kFALSE;
202 Bool_t zdcC = kFALSE;
203 Bool_t zdcBar = kFALSE;
204 Bool_t zdcTime = fTriggerAnalysis->ZDCTimeTrigger(fESD);
bcc49144 205
206 if (!fIsMC) {
207 // If it's data, we use the TDCs
208 zdcA = fTriggerAnalysis->ZDCTDCTrigger(fESD, AliTriggerAnalysis::kASide, kTRUE, kFALSE) ;
209 zdcC = fTriggerAnalysis->ZDCTDCTrigger(fESD, AliTriggerAnalysis::kCSide, kTRUE, kFALSE) ;
210 zdcBar = fTriggerAnalysis->ZDCTDCTrigger(fESD, AliTriggerAnalysis::kCentralBarrel) ;
211 } else {
212 // If it's MC, we use the energy
213 Double_t minEnergy = 0;
214 AliESDZDC *esdZDC = fESD->GetESDZDC();
215 Double_t zNCEnergy = esdZDC->GetZDCN1Energy();
216 Double_t zPCEnergy = esdZDC->GetZDCP1Energy();
217 Double_t zNAEnergy = esdZDC->GetZDCN2Energy();
218 Double_t zPAEnergy = esdZDC->GetZDCP2Energy();
bcf2601a 219 // zdcA = (zNAEnergy>minEnergy || zPAEnergy>minEnergy);
220 // zdcC = (zNCEnergy>minEnergy || zPCEnergy>minEnergy);
221 zdcA = (zNAEnergy>minEnergy);
222 zdcC = (zNCEnergy>minEnergy);
bcc49144 223 }
224
5ec1c2f5 225
9d173aad 226 // Some macros for the online triggers
227 Bool_t cMBS2A = c0sm2 && c0v0A;
228 Bool_t cMBS2C = c0sm2 && c0v0C;
229 Bool_t cMBAC = c0v0A && c0v0C;
52d405b5 230
9d173aad 231
52d405b5 232 Bool_t vdArray[kNVDEntries];
5ec1c2f5 233 vdArray[kVDC0MBS1] = c0sm1;
52d405b5 234 vdArray[kVDC0MBS2] = c0sm2;
235 vdArray[kVDC0VBA] = c0v0A;
236 vdArray[kVDC0VBC] = c0v0C;
7f5f2e0c 237 //vdArray[kVDC0OM2] = c0OM2;
52d405b5 238
abd808b9 239 // Plots requested by Jurgen on 18/11/2010 + later updates (including plots for the note)
bcc49144 240 // FIXME: will skip everything else
241
abd808b9 242
243 if(zdcTime) {
244 GetHistoSPD1 ("ZDCTIME", "ZDC Time Cut")->Fill(outerLayerSPD);
245 GetHistoTracks("ZDCTIME", "ZDC Time Cut")->Fill(ntracks);
246 GetHistoV0M ("ZDCTIME", "ZDC Time Cut")->Fill(multV0);
247 }
248
249 if(zdcTime && ntracks > 1) {
250 GetHistoSPD1 ("ZDCTIME1TRACK", "ZDC Time Cut & 1 Track")->Fill(outerLayerSPD);
251 GetHistoTracks("ZDCTIME1TRACK", "ZDC Time Cut & 1 Track")->Fill(ntracks);
252 GetHistoV0M ("ZDCTIME1TRACK", "ZDC Time Cut & 1 Track")->Fill(multV0);
253 }
254
255 // GetHistoSPD1 ("PhysSel", "All events after physics selection and Francesco's cut")->Fill(outerLayerSPD);
256 // GetHistoTracks("PhysSel", "All events after physics selection and Francesco's cut")->Fill(ntracks);
257 // GetHistoV0M ("PhysSel", "All events after physics selection and Francesco's cut")->Fill(multV0);
bcc49144 258 if(c0v0A && c0v0C) {
259 GetHistoSPD1 ("V0AND", "V0A & V0C")->Fill(outerLayerSPD);
260 GetHistoTracks("V0AND", "V0A & V0C")->Fill(ntracks);
261 GetHistoV0M ("V0AND", "V0A & V0C")->Fill(multV0);
262 }
bfae2924 263 if((c0v0A && !c0v0C) || (!c0v0A && c0v0C)) {
264 GetHistoSPD1 ("V0ONLYONE", "(V0A & !V0C) || (!V0A & V0C)")->Fill(outerLayerSPD);
265 GetHistoTracks("V0ONLYONE", "(V0A & !V0C) || (!V0A & V0C)")->Fill(ntracks);
266 GetHistoV0M ("V0ONLYONE", "(V0A & !V0C) || (!V0A & V0C)")->Fill(multV0);
267 }
bcc49144 268 if(zdcA && zdcC) {
269 GetHistoSPD1 ("ZDCAND", "ZDCA & ZDCC")->Fill(outerLayerSPD);
270 GetHistoTracks("ZDCAND", "ZDCA & ZDCC")->Fill(ntracks);
271 GetHistoV0M ("ZDCAND", "ZDCA & ZDCC")->Fill(multV0);
272 }
273 if((c0v0A && c0v0C) && !(zdcA && zdcC)) {
274 GetHistoSPD1 ("V0ANDNOTZDCAND", "(V0A & V0C) & !(ZDCA & ZDCC)")->Fill(outerLayerSPD);
275 GetHistoTracks("V0ANDNOTZDCAND", "(V0A & V0C) & !(ZDCA & ZDCC)")->Fill(ntracks);
276 GetHistoV0M ("V0ANDNOTZDCAND", "(V0A & V0C) & !(ZDCA & ZDCC)")->Fill(multV0);
277 }
278 if((c0v0A && c0v0C) && !zdcA && !zdcC) {
279 GetHistoSPD1 ("V0ANDNOTZDC", "(V0A & V0C) & !ZDCA & !ZDCC)")->Fill(outerLayerSPD);
280 GetHistoTracks("V0ANDNOTZDC", "(V0A & V0C) & !ZDCA & !ZDCC)")->Fill(ntracks);
281 GetHistoV0M ("V0ANDNOTZDC", "(V0A & V0C) & !ZDCA & !ZDCC)")->Fill(multV0);
282}
283 if((c0v0A && c0v0C) && ((!zdcA && zdcC) || (zdcA && !zdcC))) {
284 GetHistoSPD1 ("V0ANDONEZDC", "(V0A & V0C) & ((!ZDCA && ZDCC) || (ZDCA && !ZDCC)))")->Fill(outerLayerSPD);
285 GetHistoTracks("V0ANDONEZDC", "(V0A & V0C) & ((!ZDCA && ZDCC) || (ZDCA && !ZDCC)))")->Fill(ntracks);
286 GetHistoV0M ("V0ANDONEZDC", "(V0A & V0C) & ((!ZDCA && ZDCC) || (ZDCA && !ZDCC)))")->Fill(multV0);
287 }
288
289 if(((c0v0A && !c0v0C) || (!c0v0A && c0v0C)) && (zdcA && zdcC)) {
290 GetHistoSPD1 ("V0ONEZDCBOTH", "((V0A && !V0C) || (!V0A && V0C)) && (ZDCA && ZDCC)")->Fill(outerLayerSPD);
291 GetHistoTracks("V0ONEZDCBOTH", "((V0A && !V0C) || (!V0A && V0C)) && (ZDCA && ZDCC)")->Fill(ntracks);
292 GetHistoV0M ("V0ONEZDCBOTH", "((V0A && !V0C) || (!V0A && V0C)) && (ZDCA && ZDCC)")->Fill(multV0);
293 }
294
295 if((c0v0A && c0v0C) && (zdcA && zdcC)) {
296 GetHistoSPD1 ("V0ANDZDCAND", "(V0A & V0C) & (ZDCA & ZDCC)")->Fill(outerLayerSPD);
297 GetHistoTracks("V0ANDZDCAND", "(V0A & V0C) & (ZDCA & ZDCC)")->Fill(ntracks);
298 GetHistoV0M ("V0ANDZDCAND", "(V0A & V0C) & (ZDCA & ZDCC)")->Fill(multV0);
299 }
300
301 if((c0v0A && zdcA && !zdcC && !c0v0C) || (c0v0C && zdcC && !zdcA && !c0v0A)) {
302 GetHistoSPD1 ("OneSided", "(V0A & ZDCA & !ZDCC & !V0C) || (V0C & ZDCC & !ZDCA & !V0A)")->Fill(outerLayerSPD);
303 GetHistoTracks("OneSided", "(V0A & ZDCA & !ZDCC & !V0C) || (V0C & ZDCC & !ZDCA & !V0A)")->Fill(ntracks);
304 GetHistoV0M ("OneSided", "(V0A & ZDCA & !ZDCC & !V0C) || (V0C & ZDCC & !ZDCA & !V0A)")->Fill(multV0);
305 }
306
307 // GetHistoCorrelationSPDTPCVz("All", "After physics selection and Francesco's cut")->Fill(vtxESDSPD->GetZ(),vtxESDTPC->GetZ());
308 // if(cut1T0) GetHistoCorrelationSPDTPCVz("Cut1T0", "T0 Cut 1")->Fill(vtxESDSPD->GetZ(),vtxESDTPC->GetZ());
309 // if(cut2T0) GetHistoCorrelationSPDTPCVz("Cut2T0", "T0 Cut 2")->Fill(vtxESDSPD->GetZ(),vtxESDTPC->GetZ());
310
311 // GetHistoCorrelationContrTPCSPDCls("All", "After physics selection and Francesco's cut")->Fill(totalClusSPD,tpcContr);
312 // if(cut1T0) GetHistoCorrelationContrTPCSPDCls("Cut1T0", "T0 Cut 1")->Fill(totalClusSPD,tpcContr);
313 // if(cut2T0) GetHistoCorrelationContrTPCSPDCls("Cut2T0", "T0 Cut 2")->Fill(totalClusSPD,tpcContr);
314
315 // GetHistoCorrelationTrackletsSPDCls("All", "After physics selection and Francesco's cut")->Fill(totalClusSPD,ntracklets);
316 // if(cut1T0) GetHistoCorrelationTrackletsSPDCls("Cut1T0", "T0 Cut 1")->Fill(totalClusSPD,ntracklets);
317 // if(cut2T0) GetHistoCorrelationTrackletsSPDCls("Cut2T0", "T0 Cut 2")->Fill(totalClusSPD,ntracklets);
318
319
320 return; // FIXME
321
322
eef42d18 323 // Reject background
324 if (v0BG && fRejectBGWithV0) {
325 cout << "Rejection BG" << endl;
326
327 return;
328 }
329 // Fill global histos
330 GetHistoTracklets("all","All events")->Fill(ntracklets);
52d405b5 331 FillTriggerOverlaps("All", "All Events",vdArray);
a82dc581 332
7f5f2e0c 333 // Fill some combination of trigger classes
334 Bool_t cmbs1aOnline = fESD->IsTriggerClassFired("CMBS1A-B-NOPF-ALL");
335 Bool_t cmbs1cOnline = fESD->IsTriggerClassFired("CMBS1C-B-NOPF-ALL");
336 Bool_t cmbacOnline = fESD->IsTriggerClassFired("CMBAC-B-NOPF-ALL");
337
eef42d18 338 Bool_t twoOutOfThree = kFALSE;
339 if (cmbs1aOnline || cmbs1cOnline ||cmbacOnline) twoOutOfThree = kTRUE;
340 if (twoOutOfThree) GetHistoTracklets("All_TwoOutOfThree" ,"Events 2-out-of-3 online" )->Fill(ntracklets);
7f5f2e0c 341
a82dc581 342
343 // loop over trigger classes in the event
344 TObjArray * tokens = 0;
345 if(fIsMC) {
346 // in case of montecarlo I override the trigger class
347 tokens = new TObjArray;
348 tokens->SetOwner();
349 // tokens->Add(new TObjString("CINT1B-ABCE-NOPF-ALL"));
350 tokens->Add(new TObjString("MC"));
351 }
352 else {
353 TString trgClasses = fESD->GetFiredTriggerClasses();
7f5f2e0c 354 tokens = trgClasses.Tokenize(" ");
a82dc581 355 }
7f5f2e0c 356 TIterator * iter = (TIterator*) tokens->MakeIterator();
357
358 TString classes = fESD->GetFiredTriggerClasses();
359
360 // if (classes.Contains("SMH")) {
361 // tokens->Print();
362 // cout << classes.Data() << endl;
363 // }
364 // iter->Reset();
4d0aa70f 365 //Int_t itoken = 0;
7f5f2e0c 366 TObjString * tok=0;
367 while((tok = (TObjString*) iter->Next())){
a82dc581 368 // clean up trigger name
369 TString trg = tok->GetString();
370 trg.Strip(TString::kTrailing, ' ');
371 trg.Strip(TString::kLeading, ' ');
372
373 fHistoSuffix = "_";
374 fHistoSuffix += trg;
375
7f5f2e0c 376 // cout << itoken++ << " " << trg.Data() << endl;
377 // continue;
378 // if (trg.Contains("SMH")) cout << itoken++ << " " << trg.Data() << endl;
379
380 // Fill tracklets
eef42d18 381 GetHistoTracklets("All" ,"Events no offline trigger" )->Fill(ntracklets);
7f5f2e0c 382
383
a82dc581 384 // Fill histograms mismatchs
385 // TODO: check mismatch trigger class
386 if(nFastOrOffline != nFastOrOnline) {
387 GetHistoTracklets("mismatchingFastOr", "Events where fast or offline differs from fast-or online")->Fill(ntracklets);
388 }
389
390 if (c0v0A != v0AHW){
391 GetHistoTracklets("mismatchingV0A", "Events where V0A offline differs from V0A online")->Fill(ntracklets);
392 }
393
394 if (c0v0C != v0CHW){
395 GetHistoTracklets("mismatchingV0C", "Events where V0C offline differs from V0C online")->Fill(ntracklets);
396 }
397
398 // Fill a tracklet histo for each trigger type
399 if(c0sm1) GetHistoTracklets("c0sm1" ,"Events were trigger c0sm1 fired" )->Fill(ntracklets);
400 if(c0sm2) GetHistoTracklets("c0sm2" ,"Events were trigger c0sm2 fired" )->Fill(ntracklets);
401 if(c0sm3) GetHistoTracklets("c0sm3" ,"Events were trigger c0sm3 fired" )->Fill(ntracklets);
402 if(c0sm4) GetHistoTracklets("c0sm4" ,"Events were trigger c0sm4 fired" )->Fill(ntracklets);
403 if(c0sm5) GetHistoTracklets("c0sm5" ,"Events were trigger c0sm5 fired" )->Fill(ntracklets);
404 if(c0OM2) GetHistoTracklets("c0OM2" ,"Events were trigger c0OM2 fired" )->Fill(ntracklets);
405 if(c0OM3) GetHistoTracklets("c0OM3" ,"Events were trigger c0OM3 fired" )->Fill(ntracklets);
406 if(c0v0A) GetHistoTracklets("c0v0A" ,"Events were trigger c0v0A fired" )->Fill(ntracklets);
407 if(c0v0C) GetHistoTracklets("c0v0C" ,"Events were trigger c0v0C fired" )->Fill(ntracklets);
408 if(cMBS2A) GetHistoTracklets("cMBS2A","Events were trigger cMBS2A fired")->Fill(ntracklets);
409 if(cMBS2C) GetHistoTracklets("cMBS2C","Events were trigger cMBS2C fired")->Fill(ntracklets);
5ec1c2f5 410 if(cMBAC ) GetHistoTracklets("cMBAC", "Events were trigger cMBAC fired")->Fill(ntracklets);
411 if(zdcA ) GetHistoTracklets("cZDCA", "Events were trigger cZDCA fired")->Fill(ntracklets);
eef42d18 412 if(zdcC ) GetHistoTracklets("cZDCC", "Events were trigger cZDCC fired")->Fill(ntracklets);
413 if(!zdcA && !zdcC ) GetHistoTracklets("NoZDC", "Events were zdc trigger don't fired")->Fill(ntracklets);
414 if( (zdcA && !zdcC) || (!zdcA && zdcC) ) GetHistoTracklets("OneSideZDC", "Events were only 1 ZDC fired")->Fill(ntracklets);
415 if( (zdcA && zdcC) ) GetHistoTracklets("TwoSideZDC", "Events were both ZDC fired")->Fill(ntracklets);
416
417 if(twoOutOfThree) {
418 if(!zdcA && !zdcC ) GetHistoTracklets("NoZDC_TwoOutOfThree", "Events were zdc trigger don't fired")->Fill(ntracklets);
419 if( (zdcA && !zdcC) || (!zdcA && zdcC) ) GetHistoTracklets("OneSideZDC_TwoOutOfThree", "Events were only 1 ZDC fired")->Fill(ntracklets);
420 if( (zdcA && zdcC) ) GetHistoTracklets("TwoSideZDC_TwoOutOfThree", "Events were both ZDC fired")->Fill(ntracklets);
421 }
5ec1c2f5 422 if(zdcBar) GetHistoTracklets("cZDCBar","Events were trigger cZDCB fired")->Fill(ntracklets);
a82dc581 423 // if() GetHistoTracklets("","Events were trigger fired");
52d405b5 424
425 // Fill trigger overlaps
426 FillTriggerOverlaps("All", "All Events in trigger class",vdArray);
427
eef42d18 428
429 // Fill kinematic variables for peripheral events
430 static AliESDtrackCuts * cuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); // FIXME: change this ?
431 if (ntracklets < fNTrackletsCutKine) {
432 // 1. Loop on tracklets
433 for(Int_t itracklet = 0; itracklet < ntracklets; itracklet++){
434 GetHistoEta("All", Form("Tracklet #eta distribution, ntracklets < %d",fNTrackletsCutKine))->Fill(mult->GetEta(itracklet));
435 }
436 // 2. loop on tracks
437 TObjArray * goodTracks = cuts->GetAcceptedTracks(fESD);
438 TIterator * iterTracks = goodTracks->MakeIterator();
439 AliESDtrack * esdTrack = 0;
440 while ((esdTrack = (AliESDtrack*) iterTracks->Next())) {
441 GetHistoPt("All", Form("Tracklet p_{T} distribution, ntracklets < %d",fNTrackletsCutKine))->Fill(esdTrack->Pt());
442 }
443 delete goodTracks;
444 }
445
446
a82dc581 447 }
7f5f2e0c 448 delete tokens;
a82dc581 449
450 // if (fIsMC) {
9d173aad 451
452
453 // if (!fMCEvent) {
454 // AliError("No MC info found");
455 // } else {
456
457 // //loop on the MC event
458 // // Int_t nMCTracks = fMCEvent->GetNumberOfTracks();
459 // Int_t offset = fMCEvent->GetPrimaryOffset();
460 // Int_t nMCTracks = fMCEvent->GetNumberOfPrimaries()+offset;
461 // for (Int_t ipart=offset; ipart<nMCTracks; ipart++) {
462
463 // AliMCParticle *mcPart = (AliMCParticle*)fMCEvent->GetTrack(ipart);
464
465 // // We don't care about neutrals and non-physical primaries
466 // if(mcPart->Charge() == 0) continue;
467
e0376287 468 // PHYSICAL PRIMARY
9d173aad 469 // // Get MC vertex
e0376287 470 // TArrayF vertex;
9d173aad 471 // fMCEvent->GenEventHeader()->PrimaryVertex(vertex);
472 // Float_t zv = vertex[2];
473 // // Float_t zv = vtxESD->GetZ();
474 // // Fill generated histo
475 // hTracks[AliAnalysisMultPbTrackHistoManager::kHistoGen]->Fill(mcPart->Pt(),mcPart->Eta(),zv);
476
477 // }
478 // }
479 // }
480
481
482
483
484}
485
486void AliAnalysisTaskTriggerStudy::Terminate(Option_t *){
487 // terminate
488 // Save output in a more friendly format
489 fHistoList = dynamic_cast<AliHistoListWrapper*> (GetOutputData(1));
490 if (!fHistoList){
491 Printf("ERROR: fHistoList not available");
492 return;
493 }
494 TFile * f = new TFile("trigger_study.root", "recreate");
495 fHistoList->GetList()->Write();
496 f->Close();
497
498}
499
500TH1 * AliAnalysisTaskTriggerStudy::GetHistoTracklets(const char * name, const char * title){
a82dc581 501 // Book histo of events vs ntracklets, if needed
9d173aad 502
a82dc581 503 TString hname = "hTracklets_";
504 hname+=name;
505 hname+=fHistoSuffix;
9d173aad 506 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
507
508 if(!h) {
509 AliInfo(Form("Booking histo %s",hname.Data()));
510 Bool_t oldStatus = TH1::AddDirectoryStatus();
511 TH1::AddDirectory(kFALSE);
7f5f2e0c 512 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
513 h = new TH1F (hname.Data(), title, 4000, -0.5, 4000-0.5);
9d173aad 514 h->Sumw2();
515 h->SetXTitle("ntracklets");
516 fHistoList->GetList()->Add(h);
517 TH1::AddDirectory(oldStatus);
518 }
519 return h;
520}
521
bcc49144 522
523TH1 * AliAnalysisTaskTriggerStudy::GetHistoSPD1(const char * name, const char * title){
524 // Book histo of events vs ntracklets, if needed
525
526 TString hname = "hSPD1_";
527 hname+=name;
528 hname+=fHistoSuffix;
529 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
530
531 // const Int_t nbin = 118;
532 // Float_t bins[nbin] = {0};
533 // bins[0] = 0;
534 // for(Int_t ibin = 1; ibin <= nbin; ibin++){
535 // if (ibin < 100)
536 // bins[ibin] = bins [ibin-1]+1;
537 // else if (ibin < 1000)
538 // bins[ibin] = bins [ibin-1]+100;
539 // else if (ibin < 10000)
540 // bins[ibin] = bins [ibin-1]+1000;
541 // }
542
543
544 if(!h) {
545 AliInfo(Form("Booking histo %s",hname.Data()));
546 Bool_t oldStatus = TH1::AddDirectoryStatus();
547 TH1::AddDirectory(kFALSE);
548 // h = new TH1F (hname.Data(), title, nbin, bins);
549 //h = new TH1F (hname.Data(), title, 100, -0.5, 100-0.5);
550 h = new TH1F (hname.Data(), title, 10000, -0.5, 10000-0.5);
551 h->Sumw2();
552 h->SetXTitle("SPD1");
553 fHistoList->GetList()->Add(h);
554 TH1::AddDirectory(oldStatus);
555 }
556 return h;
557}
558
559TH1 * AliAnalysisTaskTriggerStudy::GetHistoV0M(const char * name, const char * title){
560 // Book histo of events vs ntracklets, if needed
561
562 TString hname = "hV0M_";
563 hname+=name;
564 hname+=fHistoSuffix;
565 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
566
567 if(!h) {
568 AliInfo(Form("Booking histo %s",hname.Data()));
569 Bool_t oldStatus = TH1::AddDirectoryStatus();
570 TH1::AddDirectory(kFALSE);
571 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
abd808b9 572 h = new TH1F (hname.Data(), title, 500, -0.5, 500-0.5);
bcc49144 573 h->Sumw2();
574 h->SetXTitle("V0M");
575 fHistoList->GetList()->Add(h);
576 TH1::AddDirectory(oldStatus);
577 }
578 return h;
579}
580
581
582TH1 * AliAnalysisTaskTriggerStudy::GetHistoTracks(const char * name, const char * title){
583 // Book histo of events vs ntracklets, if needed
584
585 TString hname = "hTPCTracks_";
586 hname+=name;
587 hname+=fHistoSuffix;
588 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
589
590 if(!h) {
591 AliInfo(Form("Booking histo %s",hname.Data()));
592 Bool_t oldStatus = TH1::AddDirectoryStatus();
593 TH1::AddDirectory(kFALSE);
594 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
595 h = new TH1F (hname.Data(), title, 50, -0.5, 50-0.5);
596 h->Sumw2();
597 h->SetXTitle("ntracks");
598 fHistoList->GetList()->Add(h);
599 TH1::AddDirectory(oldStatus);
600 }
601 return h;
602}
603
604
eef42d18 605TH1 * AliAnalysisTaskTriggerStudy::GetHistoEta(const char * name, const char * title){
606 // Book histo of events vs ntracklets, if needed
607
608 TString hname = "hEta_";
609 hname+=name;
610 hname+=fHistoSuffix;
611 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
612
613 if(!h) {
614 AliInfo(Form("Booking histo %s",hname.Data()));
615 Bool_t oldStatus = TH1::AddDirectoryStatus();
616 TH1::AddDirectory(kFALSE);
617 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
618 h = new TH1F (hname.Data(), title, 20, -2, 2);
619 h->Sumw2();
620 h->SetXTitle("#eta");
621 fHistoList->GetList()->Add(h);
622 TH1::AddDirectory(oldStatus);
623 }
624 return h;
625}
626
627TH1 * AliAnalysisTaskTriggerStudy::GetHistoPt(const char * name, const char * title){
628 // Book histo of pt distribution, if needed
629
630 TString hname = "hPt_";
631 hname+=name;
632 hname+=fHistoSuffix;
633 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
634
635 if(!h) {
636 AliInfo(Form("Booking histo %s",hname.Data()));
637 Bool_t oldStatus = TH1::AddDirectoryStatus();
638 TH1::AddDirectory(kFALSE);
639 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
640 h = new TH1F (hname.Data(), title, 100, -0.5, 1-0.5);
641 h->Sumw2();
642 h->SetXTitle("p_{T}");
643 fHistoList->GetList()->Add(h);
644 TH1::AddDirectory(oldStatus);
645 }
646 return h;
647}
648
bcc49144 649TH1 * AliAnalysisTaskTriggerStudy::GetHistoCorrelationSPDTPCVz(const char * name, const char * title){
650 // Book histo of events vs ntracklets, if needed
651
652 TString hname = "hTPCvsSPD_";
653 hname+=name;
654 hname+=fHistoSuffix;
655 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
656
657 if(!h) {
658 AliInfo(Form("Booking histo %s",hname.Data()));
659 Bool_t oldStatus = TH1::AddDirectoryStatus();
660 TH1::AddDirectory(kFALSE);
661 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
662 h = new TH2F (hname.Data(), title, 80, -20, 20, 80, -20, 20);
663 h->Sumw2();
664 h->SetXTitle("SPD Vz");
665 h->SetYTitle("TPC Vz");
666 fHistoList->GetList()->Add(h);
667 TH1::AddDirectory(oldStatus);
668 }
669 return h;
670}
671
672TH1 * AliAnalysisTaskTriggerStudy::GetHistoCorrelationContrTPCSPDCls(const char * name, const char * title){
673 // Book histo of events vs ntracklets, if needed
674
675 TString hname = "hContrTPCvsSPDCls_";
676 hname+=name;
677 hname+=fHistoSuffix;
678 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
679
680 if(!h) {
681 AliInfo(Form("Booking histo %s",hname.Data()));
682 Bool_t oldStatus = TH1::AddDirectoryStatus();
683 TH1::AddDirectory(kFALSE);
684 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
685 h = new TH2F (hname.Data(), title, 1000, 0, 9000, 1000, 0, 5000);
686 h->Sumw2();
687 h->SetXTitle("SPD Clusters");
688 h->SetYTitle("TPC V Contributors");
689 fHistoList->GetList()->Add(h);
690 TH1::AddDirectory(oldStatus);
691 }
692 return h;
693}
694TH1 * AliAnalysisTaskTriggerStudy::GetHistoCorrelationTrackletsSPDCls(const char * name, const char * title){
695 // Book histo of events vs ntracklets, if needed
696
697 TString hname = "hTrackletsvsSPDCls_";
698 hname+=name;
699 hname+=fHistoSuffix;
700 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
701
702 if(!h) {
703 AliInfo(Form("Booking histo %s",hname.Data()));
704 Bool_t oldStatus = TH1::AddDirectoryStatus();
705 TH1::AddDirectory(kFALSE);
706 // h = new TH1F (hname.Data(), title, 1000, -0.5, 10000-0.5);
707 h = new TH2F (hname.Data(), title, 1000, 0, 9000, 1000, 0, 5000);
708 h->Sumw2();
709 h->SetXTitle("SPD Clusters");
710 h->SetYTitle("N tracklets");
711 fHistoList->GetList()->Add(h);
712 TH1::AddDirectory(oldStatus);
713 }
714 return h;
715}
716
717
52d405b5 718void AliAnalysisTaskTriggerStudy::FillTriggerOverlaps (const char * name, const char * title, Bool_t * vdArray){
a82dc581 719 //Fills a histo with the different trigger statistics in a venn like diagramm. Books it if needed.
720
721 // Get or book histo
722 TString hname = "hTrigStat_";
723 hname+=name;
724 hname+=fHistoSuffix;
725 TH1 * h = (TH1*) fHistoList->GetList()->FindObject(hname.Data());
726
727 if(!h) {
728 AliInfo(Form("Booking histo %s",hname.Data()));
729 Bool_t oldStatus = TH1::AddDirectoryStatus();
730 TH1::AddDirectory(kFALSE);
52d405b5 731 Int_t nbins = 0;
732 for(Int_t ientry = 0; ientry < kNVDEntries; ientry++){
733 nbins = nbins | (1<<ientry);
734 }
7f5f2e0c 735 // cout << "NBINS " << nbins << endl;
736 nbins = nbins+1;
52d405b5 737 h = new TH1I (hname, title, nbins, -0.5, nbins-0.5);
a82dc581 738 fHistoList->GetList()->Add(h);
739 TH1::AddDirectory(oldStatus);
52d405b5 740
741 // we look at the combinations of n triggers
742 // We set a bit for each trigger to fill the diagram
743 // This is much simpler and faster than any recursive function
744 h->GetXaxis()->SetBinLabel(1,"NONE");
745 for(Int_t ibin = 1; ibin < nbins; ibin++){
746 TString binname = "";
747 Bool_t first = kTRUE;
748 for(Int_t ivdentry = 0; ivdentry < kNVDEntries; ivdentry++){
749 if (ibin & (1<<ivdentry)) {
750 if(!first) binname += " & ";
751 binname += kVDNames[ivdentry];
752 first=kFALSE;
753 }
754 }
755 h->GetXaxis()->SetBinLabel(ibin+1,binname.Data());
756 }
757
a82dc581 758 }
759
52d405b5 760 UInt_t mask = 0;
761 for(Int_t ivdentry = 0; ivdentry < kNVDEntries; ivdentry++){
762 if(vdArray[ivdentry]) {
763 mask = mask | (1<<ivdentry);
764 // cout << " 1 " ;
765 } //else cout << " 0 ";
766 }
767 // cout << hex << " = " << mask << endl;
a82dc581 768
52d405b5 769 h->Fill(mask);
9d173aad 770
a82dc581 771}