1 #include "AlidNdEtaEffSelector.h"
7 #include <TParticlePDG.h>
10 #include <../PYTHIA6/AliGenPythiaEventHeader.h>
11 #include <../TPC/AliTPCtrack.h>
12 #include <AliTracker.h>
17 ClassImp(AlidNdEtaEffSelector)
19 AlidNdEtaEffSelector::AlidNdEtaEffSelector(TTree *) :
24 // Constructor. Initialization of pointers
27 AlidNdEtaEffSelector::~AlidNdEtaEffSelector()
29 // Remove all pointers
31 // histograms are in the output list and deleted when the output
32 // list is deleted by the TSelector dtor
35 void AlidNdEtaEffSelector::Begin(TTree * tree)
37 // The Begin() function is called at the start of the query.
38 // When running with PROOF Begin() is only called on the client.
39 // The tree argument is deprecated (on PROOF 0 is passed).
41 AliSelector::Begin(tree);
43 fdNdEtaCorrection = new dNdEtaCorrection();
46 void AlidNdEtaEffSelector::SlaveBegin(TTree * tree)
48 // The SlaveBegin() function is called after the Begin() function.
49 // When running with PROOF SlaveBegin() is called on each slave server.
50 // The tree argument is deprecated (on PROOF 0 is passed).
52 AliSelector::SlaveBegin(tree);
54 fEsdTrackCuts = new ESDtrackQualityCuts();
55 fEsdTrackCuts->DefineHistograms(1);
57 fEsdTrackCuts->SetMinNClustersTPC(50);
58 fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
59 fEsdTrackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
60 fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
62 fEsdTrackCuts->SetMinNsigmaToVertex(3);
63 fEsdTrackCuts->SetAcceptKingDaughters(kFALSE);
65 AliLog::SetClassDebugLevel("ESDtrackQualityCuts",1);
68 Bool_t AlidNdEtaEffSelector::Notify()
70 // The Notify() function is called when a new file is opened. This
71 // can be either for a new TTree in a TChain or when when a new TTree
72 // is started when using PROOF. Typically here the branch pointers
73 // will be retrieved. It is normaly not necessary to make changes
74 // to the generated code, but the routine can be extended by the
77 if (AliSelector::Notify() == kFALSE)
80 // ########################################################
82 AliTracker::SetFieldMap(GetAliRun()->Field(), kTRUE); // kTRUE means uniform magnetic field
87 Bool_t AlidNdEtaEffSelector::IsPrimary(const TParticle* aParticle, Int_t aTotalPrimaries)
89 // if the particle has a daughter primary, we do not want to count it
90 if (aParticle->GetFirstDaughter() != -1 && aParticle->GetFirstDaughter() < aTotalPrimaries)
93 Int_t pdgCode = TMath::Abs(aParticle->GetPdgCode());
95 // skip quarks and gluon
96 if (pdgCode > 10 && pdgCode != 21)
102 Bool_t AlidNdEtaEffSelector::Process(Long64_t entry)
104 // The Process() function is called for each entry in the tree (or possibly
105 // keyed object in the case of PROOF) to be processed. The entry argument
106 // specifies which entry in the currently loaded tree is to be processed.
107 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
108 // to read either all or the required parts of the data. When processing
109 // keyed objects with PROOF, the object is already loaded and is available
110 // via the fObject pointer.
112 // This function should contain the "body" of the analysis. It can contain
113 // simple or elaborate selection criteria, run algorithms on the data
114 // of the event and typically fill histograms.
116 // WARNING when a selector is used with a TChain, you must use
117 // the pointer to the current TTree to call GetEntry(entry).
118 // The entry is always the local entry number in the current tree.
119 // Assuming that fChain is the pointer to the TChain being processed,
120 // use fChain->GetTree()->GetEntry(entry).
122 if (AliSelector::Process(entry) == kFALSE)
125 if (!fESD || !fHeader)
128 // ########################################################
129 // get the EDS vertex
130 const AliESDVertex* vtxESD = fESD->GetVertex();
136 vtx_res[0] = vtxESD->GetXRes();
137 vtx_res[1] = vtxESD->GetYRes();
138 vtx_res[2] = vtxESD->GetZRes();
140 // the vertex should be reconstructed
141 if (strcmp(vtxESD->GetName(),"default")==0)
144 // the resolution should be reasonable???
145 if (vtx_res[2]==0 || vtx_res[2]>0.1)
148 // ########################################################
150 AliGenPythiaEventHeader* genHeader = (AliGenPythiaEventHeader*) fHeader->GenEventHeader();
153 genHeader->PrimaryVertex(vtxMC);
158 // ########################################################
159 // loop over mc particles
160 TTree* particleTree = GetKinematics();
161 TParticle* particle = 0;
162 particleTree->SetBranchAddress("Particles", &particle);
164 Int_t nPrim = fHeader->GetNprimary();
165 Int_t nTotal = fHeader->GetNtrack();
167 for (Int_t i_mc = nTotal - nPrim; i_mc < nTotal; ++i_mc)
169 particleTree->GetEntry(i_mc);
174 if (strcmp(particle->GetName(),"XXX") == 0)
176 printf("WARNING: There is a particle named XXX (%d).\n", i_mc);
180 TParticlePDG* pdgPart = particle->GetPDG();
182 if (strcmp(pdgPart->ParticleClass(),"Unknown") == 0)
184 printf("WARNING: There is a particle with an unknown particle class (%d pdg code %d).\n", i_mc, particle->GetPdgCode());
188 if (IsPrimary(particle, nPrim) == kFALSE)
191 if (pdgPart->Charge() == 0)
194 fdNdEtaCorrection->FillGene(vtx[2], particle->Eta());
196 }// end of mc particle
198 // ########################################################
199 // loop over esd tracks
200 Int_t nTracks = fESD->GetNumberOfTracks();
201 for (Int_t t=0; t<nTracks; t++)
203 AliESDtrack* esdTrack = fESD->GetTrack(t);
205 // cut the esd track?
206 if (!fEsdTrackCuts->AcceptTrack(esdTrack))
209 AliTPCtrack* tpcTrack = new AliTPCtrack(*esdTrack);
210 if (tpcTrack->GetAlpha()==0)
212 cout << " Warning esd track alpha = 0" << endl;
216 //Float_t theta = tpcTrack->Theta();
217 //Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
219 // using the eta of the mc particle
220 Int_t label = TMath::Abs(esdTrack->GetLabel());
223 cout << " cannot find corresponding mc part !!! " << label << endl;
226 particleTree->GetEntry(nTotal - nPrim + label);
228 fdNdEtaCorrection->FillMeas(vtx[2], particle->Eta());
230 } // end of track loop
235 void AlidNdEtaEffSelector::SlaveTerminate()
237 // The SlaveTerminate() function is called after all entries or objects
238 // have been processed. When running with PROOF SlaveTerminate() is called
239 // on each slave server.
241 AliSelector::SlaveTerminate();
243 // Add the histograms to the output on each slave server
246 printf("ERROR: Output list not initialized\n");
251 void AlidNdEtaEffSelector::Terminate()
253 // The Terminate() function is the last function to be called during
254 // a query. It always runs on the client, it can be used to present
255 // the results graphically or save the results to file.
257 AliSelector::Terminate();
259 fdNdEtaCorrection->Finish();
261 TFile* fout = new TFile("correction_map.root","RECREATE");
263 fEsdTrackCuts->SaveHistograms("esd_track_cuts");
264 fdNdEtaCorrection->SaveHistograms();
269 fdNdEtaCorrection->DrawHistograms();