]>
Commit | Line | Data |
---|---|---|
c88234ad | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | //----------------------------------------------------------------- | |
18 | // AliSpectraAODEventCuts class | |
19 | //----------------------------------------------------------------- | |
20 | ||
21 | #include "TChain.h" | |
22 | #include "TTree.h" | |
23 | #include "TLegend.h" | |
24 | #include "TH1F.h" | |
25 | #include "TH2F.h" | |
26 | #include "TCanvas.h" | |
27 | #include "AliAnalysisTask.h" | |
28 | #include "AliAnalysisManager.h" | |
29 | #include "AliAODTrack.h" | |
30 | #include "AliAODMCParticle.h" | |
31 | #include "AliAODEvent.h" | |
32 | #include "AliAODInputHandler.h" | |
33 | #include "AliAnalysisTaskESDfilter.h" | |
34 | #include "AliAnalysisDataContainer.h" | |
35 | #include "AliSpectraAODEventCuts.h" | |
36 | #include "AliSpectraAODHistoManager.h" | |
37 | #include <iostream> | |
38 | ||
39 | using namespace std; | |
40 | ||
41 | ClassImp(AliSpectraAODEventCuts) | |
42 | ||
43 | AliSpectraAODEventCuts::AliSpectraAODEventCuts(const char *name) : TNamed(name, "AOD Event Cuts"), fAOD(0), fIsSelected(0), fCentralityCutMin(0), fCentralityCutMax(0), fHistoCuts(0) | |
44 | { | |
45 | // Constructor | |
46 | fHistoCuts = new TH1I("fEventCuts", "Event Cuts", kNVtxCuts, -0.5, kNVtxCuts - 0.5); | |
47 | fCentralityCutMin = 0.0; // default value of centrality cut minimum, 0 ~ no cut | |
48 | fCentralityCutMax = 10000.0; // default value of centrality cut maximum, ~ no cut | |
49 | ||
50 | } | |
51 | ||
52 | //______________________________________________________ | |
53 | Bool_t AliSpectraAODEventCuts::IsSelected(AliAODEvent * aod) | |
54 | { | |
55 | // Returns true if Event Cuts are selected and applied | |
56 | fAOD = aod; | |
57 | fIsSelected = (CheckVtxRange() && CheckCentralityCut()); | |
58 | if(fIsSelected) fHistoCuts->Fill(kAcceptedEvents); | |
59 | return fIsSelected; | |
60 | } | |
61 | ||
62 | //______________________________________________________ | |
63 | Bool_t AliSpectraAODEventCuts::CheckVtxRange() | |
64 | { | |
65 | // reject events outside of range | |
66 | AliAODVertex * vertex = fAOD->GetPrimaryVertex(); | |
67 | if (!vertex) | |
68 | { | |
69 | fHistoCuts->Fill(kVtxNoEvent); | |
70 | return kFALSE; | |
71 | } | |
72 | if (TMath::Abs(vertex->GetZ()) < 10) | |
73 | { | |
74 | return kTRUE; | |
75 | } | |
76 | fHistoCuts->Fill(kVtxRange); | |
77 | return kFALSE; | |
78 | } | |
79 | ||
80 | //______________________________________________________ | |
81 | Bool_t AliSpectraAODEventCuts::CheckCentralityCut() | |
82 | { | |
83 | // Check centrality cut | |
84 | if ( (fAOD->GetCentrality()->GetCentralityPercentile("V0M") <= fCentralityCutMax) && (fAOD->GetCentrality()->GetCentralityPercentile("V0M") >= fCentralityCutMin) ) return kTRUE; | |
85 | fHistoCuts->Fill(kVtxCentral); | |
86 | return kFALSE; | |
87 | } | |
88 | ||
89 | //______________________________________________________ | |
90 | void AliSpectraAODEventCuts::PrintCuts() | |
91 | { | |
92 | // print info about event cuts | |
93 | cout << "Event Stats" << endl; | |
94 | cout << " > Number of accepted events: " << fHistoCuts->GetBinContent(kAcceptedEvents + 1) << endl; | |
95 | cout << " > Vertex out of range: " << fHistoCuts->GetBinContent(kVtxRange + 1) << endl; | |
96 | cout << " > Events cut by centrality: " << fHistoCuts->GetBinContent(kVtxCentral + 1) << endl; | |
97 | cout << " > Events without vertex: " << fHistoCuts->GetBinContent(kVtxNoEvent + 1) << endl; | |
98 | } | |
99 | //______________________________________________________ | |
100 | ||
101 | Long64_t AliSpectraAODEventCuts::Merge(TCollection* list) | |
102 | { | |
103 | // Merge a list of AliSpectraAODEventCuts objects with this. | |
104 | // Returns the number of merged objects (including this). | |
105 | ||
106 | // AliInfo("Merging"); | |
107 | ||
108 | if (!list) | |
109 | return 0; | |
110 | ||
111 | if (list->IsEmpty()) | |
112 | return 1; | |
113 | ||
114 | TIterator* iter = list->MakeIterator(); | |
115 | TObject* obj; | |
116 | ||
117 | // collections of all histograms | |
118 | TList collections; | |
119 | ||
120 | Int_t count = 0; | |
121 | ||
122 | while ((obj = iter->Next())) { | |
123 | AliSpectraAODEventCuts* entry = dynamic_cast<AliSpectraAODEventCuts*> (obj); | |
124 | if (entry == 0) | |
125 | continue; | |
126 | ||
127 | TH1I * histo = entry->GetHistoCuts(); | |
128 | collections.Add(histo); | |
129 | count++; | |
130 | } | |
131 | ||
132 | fHistoCuts->Merge(&collections); | |
133 | ||
134 | delete iter; | |
135 | ||
136 | return count+1; | |
137 | } | |
138 |