More code clean up.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDMCDensityCalculator.cxx
1 #include "AliFMDMCDensityCalculator.h"
2 #include <TMath.h>
3 #include "AliForwardCorrectionManager.h"
4 #include "AliFMDStripIndex.h"
5 #include "AliMCEvent.h"
6 // #include "AliFMDAnaParameters.h"
7 #include "AliLog.h"
8 #include <TH2D.h>
9
10 ClassImp(AliFMDMCDensityCalculator)
11 #if 0
12 ; // For Emacs
13 #endif 
14
15
16 //____________________________________________________________________
17 AliFMDMCDensityCalculator&
18 AliFMDMCDensityCalculator::operator=(const AliFMDMCDensityCalculator& o)
19 {
20   AliFMDDensityCalculator::operator=(o);
21   return *this;
22 }
23
24     
25 //____________________________________________________________________
26 Bool_t
27 AliFMDMCDensityCalculator::CalculateMC(const AliMCEvent&       event,
28                                        AliForwardUtil::Histos& hists,
29                                        Double_t                vz,
30                                        UShort_t                vtxbin)
31 {
32   Int_t nTracks = event.GetNumberOfTracks();
33   for (Int_t iTr = 0; iTr < nTracks; iTr++) { 
34     AliMCParticle* particle = 
35       static_cast<AliMCParticle*>(event.GetTrack(iTr));
36     
37     // Check the returned particle 
38     if (!particle) continue;
39     
40     // Check if this charged and a primary 
41     Bool_t isCharged = particle->Charge() != 0;
42     if (!isCharged) continue;
43
44     Int_t nTrRef = particle->GetNumberOfTrackReferences();
45     for (Int_t iTrRef = 0; iTrRef < nTrRef; iTrRef++) { 
46       AliTrackReference* ref = particle->GetTrackReference(iTrRef);
47       
48       // Check existence 
49       if (!ref) continue;
50
51       // Check that we hit an FMD element 
52       if (ref->DetectorId() != AliTrackReference::kFMD) 
53         continue;
54
55       // Get the detector coordinates 
56       UShort_t d, s, t;
57       Char_t r;
58       AliFMDStripIndex::Unpack(ref->UserId(), d, r, s, t);
59
60       Double_t x    = ref->X();
61       Double_t y    = ref->Y();
62       Double_t z    = ref->Z()-vz;
63       Double_t rr   = TMath::Sqrt(x*x+y*y);
64       Double_t phi  = TMath::ATan2(y,x);
65       Double_t theta= TMath::ATan2(rr,z);
66       Double_t eta  = -TMath::Log(TMath::Tan(theta/2));
67
68       Float_t  c    = Correction(d,r,s,t,vtxbin,eta,false);
69       fCorrections->Fill(c);
70       
71       TH2D*    h    = hists.Get(d,r);
72       h->Fill(eta,phi, 1 * c);
73     }
74   }
75   return kTRUE;
76 }
77
78 //____________________________________________________________________
79 Bool_t
80 AliFMDMCDensityCalculator::Calculate(const AliESDFMD&,
81                                      AliForwardUtil::Histos&,
82                                      UShort_t,
83                                      Bool_t)
84 {
85   AliWarning("Method Calculate disabled for this class. If you need this, "
86              "make an AliFMDDensityCalculator object instead");
87   return kFALSE;
88 }
89
90 //____________________________________________________________________
91 //
92 // EOF
93 //
94           
95
96