1 /*************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 // Example analysis for diffractive studies
19 // Felix Reidt <Felix.Reidt@cern.ch>
27 #include "AliAODInputHandler.h"
28 #include "AliAODHandler.h"
29 #include "AliESDInputHandler.h"
30 #include "AliPIDResponse.h"
31 #include "AliPhysicsSelection.h"
33 #include "AliCDMesonBaseStripped.h"
34 #include "AliCDMesonUtilsStripped.h"
35 #include "AliCDMesonTracks.h"
36 #include "AliAnalysisTaskCDex.h"
39 //------------------------------------------------------------------------------
40 AliAnalysisTaskCDex::AliAnalysisTaskCDex(const char* name):
41 AliAnalysisTaskSE(name)
43 , fMaxVtxDst(0.5) // value to be checked with the vertex study histograms
48 , fTracks(new AliCDMesonTracks())
52 , fResidualTracklets(0)
57 , fCurrentGapCondition(0)
64 , fv0fmdspdtpcntrk(0x0)
69 // standard constructor
71 // slot in TaskSE must start from 1
72 DefineOutput(1, TList::Class());
74 // initialize gap information
75 for (Int_t iGap = 0; iGap < kMax; ++iGap) {
76 fGapInformation[iGap] = 0;
81 //------------------------------------------------------------------------------
82 AliAnalysisTaskCDex::~AliAnalysisTaskCDex()
101 //------------------------------------------------------------------------------
102 void AliAnalysisTaskCDex::UserCreateOutputObjects()
105 // createOutputObjects
108 //= TList for Histograms =====================================================
110 fHist->SetOwner(); // ensures that the histograms are all deleted on exit!
112 //= MULTIPLICITY PER GAP CONDITION =
113 fv0ntrk = new TH2D("b00_v0ntrk", ";number of tracks;gap condition",
114 80, 0., 80., 4, 1., 5.);
118 fv0fmdntrk = new TH2D("b01_v0fmdntrk", ";number of tracks;gap condition",
119 80, 0., 80., 4, 1., 5.);
121 fHist->Add(fv0fmdntrk);
124 new TH2D("b02_v0fmdspdntrk", ";number of tracks;gap condition",
125 80, 0., 80., 4, 1., 5.);
126 //x: ntrk; y: V0FMDSPD
127 fHist->Add(fv0fmdspdntrk);
130 new TH2D("b03_v0fmdspdtpcntrk", ";number of tracks;gap condition",
131 80, 0., 80., 4, 1., 5.);
132 //x: ntrk; y: V0FMDSPDTPC
133 fHist->Add(fv0fmdspdtpcntrk);
136 //= STATISTICS FLOW =
137 fhStatsFlow = AliCDMesonBaseStripped::GetHistStatsFlow();
138 fHist->Add(fhStatsFlow);
142 //------------------------------------------------------------------------------
143 void AliAnalysisTaskCDex::UserExec(Option_t *)
146 // executed for every event which passed the physics selection
148 // in order to select only correct minimum bias events,
149 // SetCollisionCandidates(AliVEvent::kMB) should be used
151 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinTotalInput); // stats flow
153 //= INPUT DATA SANITY TESTS ==================================================
159 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinGoodInput); // stats flow
161 //= EVENT SELECTION ==========================================================
162 Bool_t eventIsValid = (fDoAOD) ?
163 AliCDMesonUtilsStripped::CutEvent(fAODEvent) :
164 AliCDMesonUtilsStripped::CutEvent(fESDEvent);
170 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinEventsAfterCuts); // stats flow
172 //= PILE UP ==================================================================
173 const Bool_t isPileup = (fDoAOD) ?
174 fAODEvent->IsPileupFromSPD(2, 0.8, 3., 2., 5.) :
175 fESDEvent->IsPileupFromSPD(2, 0.8, 3., 2., 5.);
176 // using only 2 instead of three contributors
183 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinEventsWithOutPileUp);
185 //= GAP ======================================================================
186 // determine the complete gap configuration (for all gap-tagging detectors)
187 if (!DetermineGap()) {
192 //= VERTEX COINCIDENCE AND POSITION ==========================================
194 if (!(abs(fVtxZ) < 4.)) { // vertex from tracks within +/-4cm
199 //= TRACK CUTS ===============================================================
200 fTracks->ProcessEvent(fAODEvent, fESDEvent, kTRUE);
201 // apply cuts (including soft)
202 DoMultiplicityStudy(); // fill corresponding histograms
204 // is multiplicity within the desired range of 2 to 3?
205 Int_t nch = fTracks->GetTracks();
206 Int_t ncombined = fTracks->GetCombinedTracks();
208 //============================================================================
209 //=== USER ANALYSIS CODE =====================================================
210 //============================================================================
211 for (Int_t iTrack = 0; iTrack < ncombined; ++iTrack) { // including soft
212 AliVTrack* trk = fTracks->GetTrack(iTrack);
213 trk->GetID(); // prevent warning...
215 for (Int_t iTrack = 0; iTrack < nch; ++iTrack) { // excluding soft tracks
216 AliVTrack* trk = fTracks->GetTrack(iTrack);
217 trk->GetID(); // prevent warning...
220 if (fGapInformation[kV0FMDSPDTPC] == AliCDMesonBaseStripped::kBinDG) {
221 // event is a full double gap event
224 //============================================================================
229 //------------------------------------------------------------------------------
230 void AliAnalysisTaskCDex::PostOutputs()
235 // this function is main of use with multiple output containers
241 //------------------------------------------------------------------------------
242 Bool_t AliAnalysisTaskCDex::CheckInput()
245 // general protection of the task against malicious input data
247 if (const AliESDInputHandler *esdH =
248 dynamic_cast<AliESDInputHandler*>(fInputHandler)){
249 fESDEvent = esdH->GetEvent();
251 else if (const AliAODInputHandler *aodH =
252 dynamic_cast<AliAODInputHandler*>(fInputHandler)){
253 fAODEvent = aodH->GetEvent();
256 fPIDResponse = (AliPIDResponse*)fInputHandler->GetPIDResponse();
258 if(!fESDEvent && !fAODEvent){
259 printf("AliAnalysisTaskex - No valid event\n");
264 printf("AliAnalysisTaskex - No PIDd\n");
265 // PID is fixed to unknown
269 if(fDoAOD && fabs(fAODEvent->GetMagneticField())<1){
270 printf("AliAnalysisTaskex - strange Bfield! %f\n",
271 fAODEvent->GetMagneticField());
274 else if((!fDoAOD) && fabs(fESDEvent->GetMagneticField())<1){
275 printf("AliAnalysisTaskex - strange Bfield! %f\n",
276 fESDEvent->GetMagneticField());
282 tmprun = fAODEvent->GetRunNumber();
285 tmprun = fESDEvent->GetRunNumber();
290 AliCDMesonUtilsStripped::SPDLoadGeom(fRun);
297 //------------------------------------------------------------------------------
298 Bool_t AliAnalysisTaskCDex::DetermineGap()
300 // determines the gap configuration for all gap tagging detectors based on the
301 // data set which is available
305 AliAODHandler* aodHandler =
306 (AliAODHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
307 TTree *aodTree = aodHandler->GetTree();
308 aodTree->SetBranchAddress("gapCondition", &fCurrentGapCondition);
309 aodTree->GetEvent(Entry()); // seems to be needed! (loads current event)
310 if (!fCurrentGapCondition) {
311 fCurrentGapCondition = 0xfffe;
312 puts("freidtlog - error while gap condition determination using AODs\n");
317 // gap determination from detector information
318 fCurrentGapCondition = AliCDMesonUtilsStripped::GetGapConfig(fESDEvent);
320 // gap determination from preprocessed detector information
322 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
323 TTree* esdTree = am->GetInputEventHandler()->GetTree(); // get ESD tree
325 esdTree->SetBranchAddress("gapCondition", &fCurrentGapCondition);
326 esdTree->GetEvent(Entry()); // seems to be needed! (loads current event)
330 if (!fCurrentGapCondition) {
331 fCurrentGapCondition = 0xfffe;
332 puts("freidtlog - error while gap condition determination using ESDs\n");
337 // disentagle the contributions to the gap conditions of different "tightness"
338 fGapInformation[kV0] =
339 AliCDMesonBaseStripped::GetGapBin("V0", fCurrentGapCondition);
340 fGapInformation[kV0FMD] =
341 AliCDMesonBaseStripped::GetGapBin("V0FMD", fCurrentGapCondition);
342 fGapInformation[kV0FMDSPD] =
343 AliCDMesonBaseStripped::GetGapBin("V0FMDSPD", fCurrentGapCondition);
344 fGapInformation[kV0FMDSPDTPC] =
345 AliCDMesonBaseStripped::GetGapBin("V0FMDSPDTPC", fCurrentGapCondition);
346 fGapInformation[kFMD] =
347 AliCDMesonBaseStripped::GetGapBin("FMD",fCurrentGapCondition);
348 fGapInformation[kSPD] =
349 AliCDMesonBaseStripped::GetGapBin("SPD",fCurrentGapCondition);
350 fGapInformation[kTPC] =
351 AliCDMesonBaseStripped::GetGapBin("TPC",fCurrentGapCondition);
357 //------------------------------------------------------------------------------
358 void AliAnalysisTaskCDex::DoMultiplicityStudy()
360 // stores the multiplicity distributions for different gap conditions and
361 // adds some information to the statsFlow histogram
364 // retrieve values from the track object
365 Int_t ntrk0 = fTracks->GetTracksBeforeCuts(); // number of tracks before cuts
366 //Int_t nch = fTracks->GetTracks(); // number of good ITS-TPC primaries
367 Int_t ncombined = fTracks->GetCombinedTracks(); // number ITSTPC and ITS only
368 Int_t nITSpureSA = fTracks->GetITSpureSACount(); // number ITS standalone
370 // determine the residual tracks / tracklets
371 fResidualTracks = ntrk0 - ncombined - nITSpureSA;
372 fResidualTracklets = fTracks->GetRemainingTrackletsCentralBarrel();
374 // multiplicity distributions for different gaps
375 fv0ntrk->Fill(ncombined, fGapInformation[kV0]);
376 fv0fmdntrk->Fill(ncombined, fGapInformation[kV0FMD]);
377 fv0fmdspdntrk->Fill(ncombined, fGapInformation[kV0FMDSPD]);
378 fv0fmdspdtpcntrk->Fill(ncombined, fGapInformation[kV0FMDSPDTPC]);
380 if (fGapInformation[kV0] == AliCDMesonBaseStripped::kBinDG) {
381 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0Gap);
383 if (fGapInformation[kV0FMD] == AliCDMesonBaseStripped::kBinDG) {
384 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0fmdGap);
386 if (fGapInformation[kV0FMDSPD] == AliCDMesonBaseStripped::kBinDG) {
387 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0fmdspdGap);
389 if (fGapInformation[kV0FMDSPDTPC] == AliCDMesonBaseStripped::kBinDG) {
390 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinv0fmdspdtpcGap);
394 if (fResidualTracks == 0) {
395 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinResidualTracks);
397 if (fResidualTracklets == 0) {
398 fhStatsFlow->Fill(AliCDMesonBaseStripped::kBinResidualTracklets);
403 //--------------------------------------------------------------------------
404 void AliAnalysisTaskCDex::AnalyzeVtx()
406 // calculates the distance between the vertex obtain from tracks and the
407 // vertex obtain from spd tracklets
408 // stores the z position of the primary vertex from tracks
410 fVtxDst = 0.; // reset distance
412 // retrieve the pointers of the current primary vertices
413 AliVVertex* trackVtx = (fDoAOD) ?
414 (AliVVertex*)fAODEvent->GetPrimaryVertex() :
415 (AliVVertex*)fESDEvent->GetPrimaryVertexTracks();
416 AliVVertex* spdVtx = (fDoAOD) ?
417 (AliVVertex*)fAODEvent->GetPrimaryVertexSPD() :
418 (AliVVertex*)fESDEvent->GetPrimaryVertexSPD();
420 fVtxZ = trackVtx->GetZ(); // store the vertex z position
422 if (fDoAOD && (trackVtx == spdVtx)) { // no primary track vertex in the AOD
423 fVtxDst = -5; // set arbitrary distance (counted in underflow bin!)
425 else { // do proper calculation of the geometrical distance
426 fVtxDst += (trackVtx->GetX()-spdVtx->GetX())
427 * (trackVtx->GetX()-spdVtx->GetX());
428 fVtxDst += (trackVtx->GetY()-spdVtx->GetY())
429 * (trackVtx->GetY()-spdVtx->GetY());
430 fVtxDst += (trackVtx->GetZ()-spdVtx->GetZ())
431 * (trackVtx->GetZ()-spdVtx->GetZ());
432 fVtxDst = TMath::Sqrt(fVtxDst);