1 #include "AliSPDMCTrackDensity.h"
2 #include <AliMCEvent.h>
3 #include <AliTrackReference.h>
14 //____________________________________________________________________
15 AliSPDMCTrackDensity::AliSPDMCTrackDensity()
17 fUseOnlyPrimary(false),
20 fMinZ(-15), // -14.1),
21 fMaxZ(+15), // +14.1),
27 // Default constructor
30 //____________________________________________________________________
31 AliSPDMCTrackDensity::AliSPDMCTrackDensity(const char*)
32 : TNamed("spdMCTrackDensity","spdMCTrackDensity"),
33 fUseOnlyPrimary(false),
43 // Normal constructor constructor
46 //____________________________________________________________________
47 AliSPDMCTrackDensity::AliSPDMCTrackDensity(const AliSPDMCTrackDensity& o)
49 fUseOnlyPrimary(o.fUseOnlyPrimary),
59 // Normal constructor constructor
62 //____________________________________________________________________
64 AliSPDMCTrackDensity::operator=(const AliSPDMCTrackDensity& o)
66 // Assignment operator
68 fUseOnlyPrimary = o.fUseOnlyPrimary;
76 fBinFlow = o.fBinFlow;
80 //____________________________________________________________________
82 AliSPDMCTrackDensity::DefineOutput(TList* l)
84 fRZ = new TH2D("rz", "(r,z) of used track references",
85 30, -15, 15, 50, 0, 5);
86 fRZ->SetXTitle("z [cm]");
87 fRZ->SetYTitle("r [cm]");
91 fXYZ = new TH3D("xyz", "(x,y,z) of used track references",
92 100, -5., 5., 100, -5., 5., 30, -15., 15.);
93 fXYZ->SetXTitle("x [cm]");
94 fXYZ->SetYTitle("y [cm]");
95 fXYZ->SetZTitle("z [cm]");
96 fXYZ->SetDirectory(0);
99 fNRefs = new TH1D("nrefs", "Number of references used per track",
101 fNRefs->SetXTitle("# of references per track");
102 fNRefs->SetDirectory(0);
105 fBinFlow = new TH2D("binFlow", "#eta and #varphi bin flow",
106 120, -3, 3, 40, -180, 180);
107 fBinFlow->SetXTitle("#Delta#eta");
108 fBinFlow->SetYTitle("#Delta#varphi");
109 fBinFlow->SetDirectory(0);
113 //____________________________________________________________________
115 AliSPDMCTrackDensity::StoreParticle(AliMCParticle* particle,
116 const AliMCParticle* mother,
122 if (refNo < 0) return;
124 AliTrackReference* ref = particle->GetTrackReference(refNo);
127 Double_t r = ref->R();
128 Double_t x = ref->X();
129 Double_t y = ref->Y();
130 Double_t z = ref->Z();
133 Double_t th = TMath::ATan2(r,zr);
134 if (th < 0) th += 2*TMath::Pi();
135 Double_t et = -TMath::Log(TMath::Tan(th/2));
136 Double_t ph = TMath::ATan2(y,x);
137 if (ph < 0) ph += 2*TMath::Pi();
140 const AliMCParticle* mp = (mother ? mother : particle);
141 Double_t dEta = mp->Eta() - et;
142 Double_t dPhi = (mp->Phi() - ph) * 180 / TMath::Pi();
143 if (dPhi > 180) dPhi -= 360;
144 if (dPhi < -180) dPhi += 360;
145 fBinFlow->Fill(dEta, dPhi);
149 //____________________________________________________________________
151 AliSPDMCTrackDensity::GetMother(Int_t iTr,
152 const AliMCEvent& event) const
155 // Track down primary mother
159 const AliMCParticle* p = static_cast<AliMCParticle*>(event.GetTrack(i));
160 if (const_cast<AliMCEvent&>(event).Stack()->IsPhysicalPrimary(i)) return p;
168 //____________________________________________________________________
170 AliSPDMCTrackDensity::Calculate(const AliMCEvent& event,
176 // Filter the input kinematics and track references, using
177 // some of the ESD information
180 // input Input ESD event
181 // event Input MC event
182 // vz Vertex position
183 // output Output ESD-like object
184 // primary Per-event histogram of primaries
187 // True on succes, false otherwise
190 AliStack* stack = const_cast<AliMCEvent&>(event).Stack();
191 Int_t nTracks = stack->GetNtrack();
192 Int_t nPrim = stack->GetNtrack();
193 for (Int_t iTr = 0; iTr < nTracks; iTr++) {
194 AliMCParticle* particle =
195 static_cast<AliMCParticle*>(event.GetTrack(iTr));
197 // Check the returned particle
198 if (!particle) continue;
200 // Check if this charged and a primary
201 Bool_t isCharged = particle->Charge() != 0;
202 if (!isCharged) continue;
204 Bool_t isPrimary = stack->IsPhysicalPrimary(iTr);
206 // Fill 'dn/deta' histogram
207 if (isPrimary && iTr < nPrim) {
209 Double_t eta = particle->Eta();
210 Double_t phi = particle->Phi();
211 primary->Fill(eta, phi);
215 // Bail out if we're only processing primaries - perhaps we should
216 // track back to the original primary?
217 if (fUseOnlyPrimary && !isPrimary) continue;
219 Int_t nTrRef = particle->GetNumberOfTrackReferences();
221 for (Int_t iTrRef = 0; iTrRef < nTrRef; iTrRef++) {
222 AliTrackReference* ref = particle->GetTrackReference(iTrRef);
227 // Check that we hit an FMD element
228 if (ref->DetectorId() != AliTrackReference::kITS)
231 // Get radius and z where the track reference was made
232 Double_t r = ref->R();
233 Double_t x = ref->X();
234 Double_t y = ref->Y();
235 Double_t z = ref->Z();
236 if (r > fMaxR || r < fMinR) continue;
237 if (z > fMaxZ || z < fMinZ) continue;
242 // Only fill first reference
244 const AliMCParticle* mother = GetMother(iTr, event);
245 StoreParticle(particle, mother, iTrRef, vz, output);
252 //____________________________________________________________________
254 AliSPDMCTrackDensity::Print(Option_t* /*option*/) const
256 char ind[gROOT->GetDirLevel()+1];
257 for (Int_t i = 0; i < gROOT->GetDirLevel(); i++) ind[i] = ' ';
258 ind[gROOT->GetDirLevel()] = '\0';
259 std::cout << ind << ClassName() << ": " << GetName() << '\n'
261 << ind << " Only primary tracks: " << fUseOnlyPrimary << '\n'
262 << ind << " R range: [" << fMinR << ',' << fMaxR
264 << ind << " Z range: [" << fMinZ << ',' << fMaxZ
265 << "]" << std::noboolalpha << std::endl;
269 //____________________________________________________________________