1 #include "AliFMDMCTrackELoss.h"
3 #include "AliTrackReference.h"
5 #include "AliFMDStripIndex.h"
6 #include "AliFMDEncodedEdx.h"
8 #include "AliMCParticle.h"
14 #include <TLorentzVector.h>
15 #include <TParticle.h>
16 #include <TClonesArray.h>
19 //====================================================================
21 AliFMDMCTrackELoss::State::Clear(Bool_t alsoCount)
34 if (alsoCount) count = 0;
37 //____________________________________________________________________
38 AliFMDMCTrackELoss::State&
39 AliFMDMCTrackELoss::State::operator=(const State& o)
41 if (&o == this) return *this;
43 oldDetector = o.oldDetector;
45 oldSector = o.oldSector;
46 oldStrip = o.oldStrip;
47 startStrip = o.startStrip;
57 //====================================================================
58 AliFMDMCTrackELoss::Hit::Hit()
59 : fGamma(0), fBeta(0), fEta(0), fDe(0), fDx(0), fDetId(0), fPdg(0),
60 fPrimary(true), fDetector(0), fRing('\0'),
61 fSector(0xFFFF), fStrip(0xFFFF)
63 //____________________________________________________________________
65 AliFMDMCTrackELoss::Hit::Decode() const
67 if (fDetector > 0) return;
68 AliFMDStripIndex::Unpack(fDetId, fDetector, fRing, fSector, fStrip);
70 //____________________________________________________________________
72 AliFMDMCTrackELoss::Hit::AbsPdg() const
74 return TMath::Abs(fPdg);
77 //====================================================================
78 AliFMDMCTrackELoss::AliFMDMCTrackELoss()
79 : AliBaseMCTrackDensity(),
82 fMaxConsequtiveStrips(3),
98 // Default constructor
101 //____________________________________________________________________
102 AliFMDMCTrackELoss::AliFMDMCTrackELoss(const char*)
103 : AliBaseMCTrackDensity("fmdMCTrackELoss"),
106 fMaxConsequtiveStrips(3),
122 // Normal constructor constructor
123 SetTitle("mcTrackELoss");
124 fHits = new TClonesArray("AliFMDMCTrackELoss::Hit");
128 //____________________________________________________________________
129 AliFMDMCTrackELoss::AliFMDMCTrackELoss(const AliFMDMCTrackELoss& o)
130 : AliBaseMCTrackDensity(o),
132 fMaxConsequtiveStrips(o.fMaxConsequtiveStrips),
139 // Normal constructor constructor
142 //____________________________________________________________________
144 AliFMDMCTrackELoss::operator=(const AliFMDMCTrackELoss& o)
146 // Assignment operator
147 if (&o == this) return *this;
148 AliBaseMCTrackDensity::operator=(o);
149 fMaxConsequtiveStrips = o.fMaxConsequtiveStrips;
150 fUseTree = o.fUseTree;
158 fTree = static_cast<TTree*>(o.fTree->Clone());
164 //____________________________________________________________________
166 AliFMDMCTrackELoss::CreateOutputObjects(TList* l)
168 AliBaseMCTrackDensity::CreateOutputObjects(l);
169 TList* ll = static_cast<TList*>(l->FindObject(GetTitle()));
172 fNr = new TH1D("clusterRefs", "# track references per cluster",
174 fNr->SetXTitle("# of track references/cluster");
175 fNr->SetFillColor(kRed+1);
176 fNr->SetFillStyle(3001);
177 fNr->SetDirectory(0);
180 fNt = new TH1D("clusterSize", "cluster length in strips", 21, -.5, 20.5);
181 fNt->SetXTitle("Cluster size [strips]");
182 fNt->SetFillColor(kBlue+1);
183 fNt->SetFillStyle(3001);
184 fNt->SetDirectory(0);
187 fNc = new TH1D("nClusters", "# clusters per track", 21, -.5, 20.5);
188 fNc->SetXTitle("# clusters");
189 fNc->SetFillColor(kGreen+1);
190 fNc->SetFillStyle(3001);
191 fNc->SetDirectory(0);
194 fNcr = new TH2D("clusterVsRefs", "# clusters vs. # refs",
195 21, -.5, 20.5, 21, -.5, 20.5);
196 fNcr->SetXTitle("# References");
197 fNcr->SetYTitle("# Clusters");
198 fNcr->SetOption("COLZ");
199 fNcr->SetDirectory(0);
204 TArrayD bgArray(601);
205 AliFMDEncodedEdx::GetdEAxis().FillBinArray(edepArray);
206 AliForwardUtil::MakeLogScale(600, -2, 5, bgArray);
207 for (Int_t i = 0; i < edepArray.GetSize(); i++)
210 fBetaGammadEdx = new TH2D("betaGammadEdx", "Energy loss",
211 bgArray.GetSize()-1, bgArray.GetArray(),
212 edepArray.GetSize()-1, edepArray.GetArray());
213 fBetaGammadEdx->SetDirectory(0);
214 fBetaGammadEdx->SetXTitle("#it{#beta#gamma}");
215 fBetaGammadEdx->SetYTitle("d#it{#Delta}/d#it{x}");
216 fBetaGammadEdx->Sumw2();
217 ll->Add(fBetaGammadEdx);
219 fBetaGammaEta = new TH2D("betaGammaEta", "#beta#gamma",
220 200, -4, 6, bgArray.GetSize()-1, bgArray.GetArray());
221 fBetaGammaEta->SetXTitle("#eta");
222 fBetaGammaEta->SetYTitle("#it{#beta#gamma}");
223 fBetaGammaEta->Sumw2();
224 ll->Add(fBetaGammaEta);
226 fDEdxEta = new TH2D("dEdxEta", "d#it{#Delta}/d#it{x}",
227 200, -4, 6, edepArray.GetSize()-1, edepArray.GetArray());
228 fDEdxEta->SetXTitle("#eta");
229 fDEdxEta->SetYTitle("d#it{#Delta}/d#it{x}");
233 if (!fUseTree) return;
235 fTree = new TTree("tree", "Tree of hits");
236 fTree->Branch("event", &fEvent, "ipZ/D:cent");
237 fTree->Branch("hits", &fHits);
240 //____________________________________________________________________
242 AliFMDMCTrackELoss::Clear(Option_t*)
245 fSecondaries.Reset(0);
247 fEta.Reset(AliESDFMD::kInvalidEta);
251 //____________________________________________________________________
253 AliFMDMCTrackELoss::GetDetectorId() const
255 return AliTrackReference::kFMD;
258 //____________________________________________________________________
260 AliFMDMCTrackELoss::BeginTrackRefs()
265 //____________________________________________________________________
267 AliFMDMCTrackELoss::EndTrackRefs(Int_t nRefs)
269 fNc->Fill(fState.count);
270 fNcr->Fill(nRefs, fState.count);
274 //____________________________________________________________________
276 AliFMDMCTrackELoss::ProcessRef(AliMCParticle* particle,
277 const AliMCParticle* mother,
278 AliTrackReference* ref)
280 // Get the detector coordinates
283 AliFMDStripIndex::Unpack(ref->UserId(), d, r, s, t);
284 Double_t edep, length, dEdep, dLength;
285 AliFMDEncodedEdx::Decode((ref->UserId() >> 19), edep, length, dEdep, dLength);
290 // Calculate distance of previous reference to base of cluster
291 UShort_t nT = TMath::Abs(t - fState.startStrip) + 1;
293 // Now check if we should flush to output
296 // If this is a new detector/ring, then reset the other one
297 // Check if we have a valid old detectorm ring, and sector
298 if (fState.oldDetector > 0 &&
299 fState.oldRing != '\0' &&
300 fState.oldSector != 1024) {
301 // New detector, new ring, or new sector
302 if (d != fState.oldDetector ||
303 r != fState.oldRing ||
304 s != fState.oldSector) {
305 if (fDebug) Info("Process", "New because new sector");
308 else if (nT > fMaxConsequtiveStrips) {
309 if (fDebug) Info("Process", "New because too long: %d (%d,%d,%d)",
310 fState.nStrips, t, fState.oldStrip, fState.startStrip);
316 Info("Process", "I=%p L=%p D=%d (was %d), R=%c (was %c), "
317 "S=%2d (was %2d) t=%3d (was %3d) nT=%3d/%4d",
319 d, fState.oldDetector,
323 fState.nStrips, fMaxConsequtiveStrips);
324 // Int_t nnT = TMath::Abs(fState.oldStrip - fState.startStrip) + 1;
325 StoreParticle(particle, mother, fState.longest);
329 // If base of cluster not set, set it here.
330 if (fState.startStrip == 1024) fState.startStrip = t;
332 // Calculate distance of previous reference to base of cluster
333 fState.nStrips = TMath::Abs(t - fState.startStrip) + 1;
335 // Count number of track refs in this sector
338 fState.oldDetector = d;
340 fState.oldSector = s;
347 if (t == fState.startStrip)
348 Info("Process", "New cluster starting at FMD%d%c[%2d,%3d]",
351 Info("Process", "Adding to cluster starting at FMD%d%c[%2d,%3d], "
352 "length=%3d (now in %3d, previous %3d)",
353 d, r, s, fState.startStrip, fState.nStrips, t, fState.oldStrip);
356 // The longest passage is determined through the angle
357 Double_t ang = GetTrackRefTheta(ref);
358 if (ang > fState.angle) {
359 fState.longest = ref;
363 return fState.longest;
366 //____________________________________________________________________
368 AliFMDMCTrackELoss::StoreParticle(AliMCParticle* particle,
369 const AliMCParticle* mother,
370 AliTrackReference* ref) const
373 AliBaseMCTrackDensity::StoreParticle(particle, mother, ref);
374 if (w <= 0) return w;
376 // Get the detector coordinates
379 AliFMDStripIndex::Unpack(ref->UserId(), d, r, s, t);
381 Double_t de = fState.de;
382 Double_t dx = fState.dx;
383 Bool_t prim = particle == mother;
385 if (prim) fPrimaries(d,r,s,t) += de;
386 else fSecondaries(d,r,s,t) += de;
389 fNr->Fill(fState.nRefs);
390 fNt->Fill(fState.nStrips);
394 if (de <= 0 || dx <= 0) return w;
397 particle->Particle()->Momentum(v);
398 if (v.E() <= 0) return w;
399 if (v.Beta() < 0 || v.Beta() > 1) return w;
401 Double_t eta = fEta(d,r,s,t);
402 Double_t beta = v.Beta();
403 Double_t gamma = v.Gamma();
404 Double_t dEdx = de/dx;
407 fBetaGammadEdx->Fill(beta*gamma, dEdx);
408 fBetaGammaEta->Fill(eta, beta*gamma);
409 fDEdxEta->Fill(eta, dEdx);
411 Int_t nHits = fHits->GetEntries();
412 Hit* hit = new((*fHits)[nHits]) Hit;
413 hit->fPrimary = prim;
417 hit->fDetId = ref->UserId() & AliFMDStripIndex::kIdMask;
420 hit->fPdg = particle->PdgCode();
425 //____________________________________________________________________
427 AliFMDMCTrackELoss::Calculate(const AliESDFMD& input,
428 const AliMCEvent& event,
433 // Filter the input kinematics and track references, using
434 // some of the ESD information
437 // input Input ESD event
438 // event Input MC event
439 // vz Vertex position
440 // output Output ESD-like object
441 // primary Per-event histogram of primaries
444 // True on succes, false otherwise
450 // Copy eta values to output
451 for (UShort_t ed = 1; ed <= 3; ed++) {
452 UShort_t nq = (ed == 1 ? 1 : 2);
453 for (UShort_t eq = 0; eq < nq; eq++) {
454 Char_t er = (eq == 0 ? 'I' : 'O');
455 UShort_t ns = (eq == 0 ? 20 : 40);
456 UShort_t nt = (eq == 0 ? 512 : 256);
457 for (UShort_t es = 0; es < ns; es++)
458 for (UShort_t et = 0; et < nt; et++)
459 fEta(ed, er, es, et) = input.Eta(ed, er, es, et);
463 Bool_t ret = ProcessTracks(event, vz, 0);
465 if (fTree) fTree->Fill();
470 #define PFV(N,VALUE) \
472 AliForwardUtil::PrintName(N); \
473 std::cout << (VALUE) << std::endl; } while(false)
474 //____________________________________________________________________
476 AliFMDMCTrackELoss::Print(Option_t* option) const
478 AliBaseMCTrackDensity::Print(option);
479 gROOT->IncreaseDirLevel();
480 PFV("Max cluster size", fMaxConsequtiveStrips);
481 gROOT->DecreaseDirLevel();
484 //____________________________________________________________________