]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliFMDMCTrackDensity.h
Fixes for pA indenfication of events
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDMCTrackDensity.h
1 #ifndef ALIFMDMCTRACKDENSITY_MC
2 #define ALIFMDMCTRACKDENSITY_MC
3 #include "AliForwardUtil.h"
4 #include "AliBaseMCTrackDensity.h"
5 class TH1D;
6 class AliESDFMD;
7
8 /**
9  * A class to calculate the particle density from track references.
10  * This code is used both in AliForwardMCCorrectionsTask and
11  * AliFMDMCDensity calculator. 
12  * 
13  * @par Input: 
14  *    - AliESDFMD object  - from reconstruction
15  *    - Kinematics
16  *    - Track-References
17  *
18  * @par Output: 
19  *    - AliESDFMD object  - content is # of track references/strip
20  *
21  * @par Corrections used: 
22  *    - None
23  *
24  * @par Histograms: 
25  *    - Incident angle vs number of track references
26  *    - Incident angle vs number of strips/cluster
27  *
28  * @ingroup pwglf_forward_algo
29  * @ingroup pwglf_forward_mc
30  * @ingroup pwglf_forward_aod
31  */
32 class AliFMDMCTrackDensity : public AliBaseMCTrackDensity 
33 {
34 public:
35   /** 
36    * Default constructor.  Do not use - for ROOT I/O system use only 
37    */
38   AliFMDMCTrackDensity();
39   /** 
40    * Normal constructor 
41    * 
42    * @param name Not used
43    */
44   AliFMDMCTrackDensity(const char* name);
45   /** 
46    * Copy constructor 
47    * 
48    * @param o Object to copy from 
49    */
50   AliFMDMCTrackDensity(const AliFMDMCTrackDensity& o);
51   /** 
52    * Assignment operator
53    * 
54    * @param o Object to assign from 
55    * 
56    * @return Reference to this 
57    */
58   AliFMDMCTrackDensity& operator=(const AliFMDMCTrackDensity& o);
59   /** 
60    * Destructor. 
61    */
62   virtual ~AliFMDMCTrackDensity() {}
63
64   /** 
65    * Set maximum number of strips per 'cluster' 
66    * 
67    * @param n  Maximum number of strips per 'cluster' 
68    */
69   void SetMaxConsequtiveStrips(UShort_t n) { fMaxConsequtiveStrips = n; }
70   /** 
71    * Loops over all the particles in the passed event.  If @a primary
72    * is not null, then that histogram is filled with the primary
73    * particle information - irrespective of whether the particle
74    * actually hits the FMD or not.  For each track (primary or
75    * secondary, unless only primary information is requested - see
76    * SetUseOnlyPrimary) loop over all track references to that
77    * particle and check if they come from the FMD.  In that case,
78    * figure out which strip(s) to assign the track to, and fill the @a
79    * hits structure.
80    * 
81    * @param esd      FMD ESD structure 
82    * @param event    MC event 
83    * @param vz       IP z-coordinate
84    * @param output   Output of FMD hits
85    * @param primary  Primary information, if available. 
86    * 
87    * @return true 
88    */
89   Bool_t Calculate(const AliESDFMD&    esd, 
90                    const AliMCEvent&   event, 
91                    Double_t            vz,
92                    AliESDFMD&          output,
93                    TH2D*               primary);
94   /** 
95    * Define ouputs 
96    * 
97    * @param list List to add outputs to
98    */
99   void DefineOutput(TList* list);
100   
101   void Print(Option_t* option="") const;
102 protected:
103   /** 
104    * Must be defined to return the track-reference ID for this detector
105    * 
106    * @return Detector id set on track references
107    */
108   Int_t GetDetectorId() const;
109   /** 
110    * Process a track reference 
111    * 
112    * @param particle Particle 
113    * @param mother   Ultimate mother (if not primary)
114    * @param ref      Reference 
115    * 
116    * @return 0 if no output should be generated for this reference, or
117    * pointer to track-reference to produce output for.
118    */
119   AliTrackReference* ProcessRef(AliMCParticle* particle, 
120                                 const AliMCParticle* mother, 
121                                 AliTrackReference* ref);
122   /** 
123    * Called at before loop over track references
124    * 
125    */
126   void BeginTrackRefs();
127   /** 
128    * Called at before loop over track references
129    * 
130    * @param nRefs Number of references 
131    */
132   void EndTrackRefs(Int_t nRefs);
133   /** 
134    * Store a particle hit in Base<i>dr</i>[<i>s,t</i>] in @a output
135    * 
136    * 
137    * @param particle  Particle to store
138    * @param mother    Ultimate mother of particle 
139    * @param ref       Longest track reference
140    *
141    * @return weight
142    */  
143   Double_t StoreParticle(AliMCParticle*       particle, 
144                          const AliMCParticle* mother,
145                          AliTrackReference*   ref) const;
146   /** 
147    * Structure holding the state of the `tracker' 
148    * 
149    */
150   mutable struct State 
151   {
152     Double_t angle;            // Angle 
153     UShort_t oldDetector;      // Last detector
154     Char_t   oldRing;          // Last ring
155     UShort_t oldSector;        // Last sector
156     UShort_t oldStrip;         // Last strip 
157     UShort_t startStrip;       // First strip 
158     UShort_t nRefs;            // Number of references
159     UShort_t nStrips;          // Number of strips 
160     UShort_t count;            // Count of hit strips 
161     AliTrackReference* longest; //! Longest track through 
162     /** 
163      * Clear this state
164      * 
165      * @param alsoCount If true, also clear count 
166      */
167     void Clear(Bool_t alsoCount=false);
168     /** 
169      * Assignment operator 
170      * 
171      * @param o Object to assign from 
172      * 
173      * @return Reference to this object 
174      */
175     State& operator=(const State& o);
176   } fState; // State 
177   
178     
179   UShort_t   fMaxConsequtiveStrips; // Max 'cluster' size
180   TH1D*      fNr;                   // Number of track-refs per cluster
181   TH1D*      fNt;                   // Size of cluster in strips 
182   TH1D*      fNc;                   // Number of clusters per track
183   TH2D*      fNcr;                  // Number of clusters per track
184   AliESDFMD* fOutput;               //! Output ESD object
185
186   ClassDef(AliFMDMCTrackDensity,3); // Calculate track-ref density
187 };
188
189 #endif
190 // Local Variables:
191 //  mode: C++ 
192 // End: