3 #include "AliMultiplicityESDSelector.h"
13 #include <AliMultiplicity.h>
15 #include "esdTrackCuts/AliESDtrackCuts.h"
16 #include "AliPWG0Helper.h"
17 #include "dNdEta/AliMultiplicityCorrection.h"
19 //#define TPCMEASUREMENT
20 #define ITSMEASUREMENT
22 ClassImp(AliMultiplicityESDSelector)
24 AliMultiplicityESDSelector::AliMultiplicityESDSelector() :
30 // Constructor. Initialization of pointers
34 AliMultiplicityESDSelector::~AliMultiplicityESDSelector()
40 // histograms are in the output list and deleted when the output
41 // list is deleted by the TSelector dtor
44 void AliMultiplicityESDSelector::Begin(TTree* tree)
48 AliSelector::Begin(tree);
50 ReadUserObjects(tree);
53 void AliMultiplicityESDSelector::ReadUserObjects(TTree* tree)
55 // read the user objects, called from slavebegin and begin
57 if (!fEsdTrackCuts && fInput)
58 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
60 if (!fEsdTrackCuts && tree)
61 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
64 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
67 void AliMultiplicityESDSelector::SlaveBegin(TTree* tree)
69 // The SlaveBegin() function is called after the Begin() function.
70 // When running with PROOF SlaveBegin() is called on each slave server.
71 // The tree argument is deprecated (on PROOF 0 is passed).
73 AliSelector::SlaveBegin(tree);
75 ReadUserObjects(tree);
77 fMultiplicity = new AliMultiplicityCorrection("Multiplicity", "Multiplicity");
80 void AliMultiplicityESDSelector::Init(TTree* tree)
82 // read the user objects
84 AliSelector::Init(tree);
86 // enable only the needed branches
89 tree->SetBranchStatus("*", 0);
90 tree->SetBranchStatus("fTriggerMask", 1);
91 tree->SetBranchStatus("fSPDVertex*", 1);
94 tree->SetBranchStatus("fSPDMult*", 1);
98 AliESDtrackCuts::EnableNeededBranches(tree);
103 Bool_t AliMultiplicityESDSelector::Process(Long64_t entry)
105 // The Process() function is called for each entry in the tree (or possibly
106 // keyed object in the case of PROOF) to be processed. The entry argument
107 // specifies which entry in the currently loaded tree is to be processed.
108 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
109 // to read either all or the required parts of the data. When processing
110 // keyed objects with PROOF, the object is already loaded and is available
111 // via the fObject pointer.
113 // This function should contain the "body" of the analysis. It can contain
114 // simple or elaborate selection criteria, run algorithms on the data
115 // of the event and typically fill histograms.
117 // WARNING when a selector is used with a TChain, you must use
118 // the pointer to the current TTree to call GetEntry(entry).
119 // The entry is always the local entry number in the current tree.
120 // Assuming that fTree is the pointer to the TChain being processed,
121 // use fTree->GetTree()->GetEntry(entry).
123 if (AliSelector::Process(entry) == kFALSE)
126 // Check prerequisites
129 AliDebug(AliLog::kError, "ESD branch not available");
133 Bool_t eventTriggered = AliPWG0Helper::IsEventTriggered(fESD);
134 Bool_t eventVertex = AliPWG0Helper::IsVertexReconstructed(fESD);
136 if (!eventTriggered || !eventVertex)
139 // get the ESD vertex
140 const AliESDVertex* vtxESD = fESD->GetVertex();
144 Int_t nESDTracks05 = 0;
145 Int_t nESDTracks10 = 0;
146 Int_t nESDTracks15 = 0;
147 Int_t nESDTracks20 = 0;
149 #ifdef ITSMEASUREMENT
151 const AliMultiplicity* mult = fESD->GetMultiplicity();
154 AliDebug(AliLog::kError, "AliMultiplicity not available");
158 // get multiplicity from ITS tracklets
159 for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i)
161 //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i));
163 // this removes non-tracklets. Very bad solution. SPD guys are working on better solution...
164 if (mult->GetDeltaPhi(i) < -1000)
167 Float_t theta = mult->GetTheta(i);
168 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
170 if (TMath::Abs(eta) < 0.5)
173 if (TMath::Abs(eta) < 1.0)
176 if (TMath::Abs(eta) < 1.5)
179 if (TMath::Abs(eta) < 2.0)
184 #ifdef TPCMEASUREMENT
187 AliDebug(AliLog::kError, "fESDTrackCuts not available");
191 // get multiplicity from ESD tracks
192 TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD);
193 Int_t nGoodTracks = list->GetEntries();
194 // loop over esd tracks
195 for (Int_t i=0; i<nGoodTracks; i++)
197 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(i));
200 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", i));
205 esdTrack->GetConstrainedPxPyPz(p); // ### TODO should be okay because we have a vertex, however GetInnerPxPyPy / GetOuterPxPyPy also exist
208 Float_t theta = vector.Theta();
209 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
210 Float_t pt = vector.Pt();
215 if (TMath::Abs(eta) < 0.5)
218 if (TMath::Abs(eta) < 1.0)
221 if (TMath::Abs(eta) < 1.5)
224 if (TMath::Abs(eta) < 2.0)
229 fMultiplicity->FillMeasured(vtx[2], nESDTracks05, nESDTracks10, nESDTracks15, nESDTracks20);
234 void AliMultiplicityESDSelector::SlaveTerminate()
236 // The SlaveTerminate() function is called after all entries or objects
237 // have been processed. When running with PROOF SlaveTerminate() is called
238 // on each slave server.
240 AliSelector::SlaveTerminate();
242 // Add the histograms to the output on each slave server
245 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
249 fOutput->Add(fMultiplicity);
252 void AliMultiplicityESDSelector::Terminate()
254 // The Terminate() function is the last function to be called during
255 // a query. It always runs on the client, it can be used to present
256 // the results graphically or save the results to file.
258 AliSelector::Terminate();
260 fMultiplicity = dynamic_cast<AliMultiplicityCorrection*> (fOutput->FindObject("Multiplicity"));
264 AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p", (void*) fMultiplicity));
268 TFile* file = TFile::Open("multiplicityESD.root", "RECREATE");
270 fMultiplicity->SaveHistograms();
274 fMultiplicity->DrawHistograms();