]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliFMDMCSharingFilter.cxx
Refactored Ali{SPD,FMD}MCTrackDensity into a common base class.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDMCSharingFilter.cxx
1 //
2 // Class to do the sharing correction for MC data.
3 //
4 // Input: 
5 //    - AliESDFMD object  - from reconstruction
6 //    - Kinematics
7 //    - Track-References
8 //
9 // Output: 
10 //    - AliESDFMD object  - copy of input, but with signals merged 
11 //
12 // Corrections used: 
13 //    - ELoss fits
14 //
15 // Histograms: 
16 //    - For each ring (FMD1i, FMD2i, FMD2o, FMD3i, FMD3o) the distribution of 
17 //      signals before and after the filter.  
18 //    - For each ring (see above), an array of distributions of number of 
19 //      hit strips for each vertex bin (if enabled - see Init method)
20 // 
21 #include "AliFMDMCSharingFilter.h"
22 #include <AliESDFMD.h>
23 #include <AliMCEvent.h>
24 #include <AliTrackReference.h>
25 #include <AliStack.h>
26 #include <TAxis.h>
27 #include <TList.h>
28 #include <TH1.h>
29 #include <TMath.h>
30 #include "AliFMDStripIndex.h"
31 #include "AliFMDFloatMap.h"
32 #include <AliLog.h>
33 #include <TROOT.h>
34 #include <iostream>
35 #include <iomanip>
36
37 ClassImp(AliFMDMCSharingFilter)
38 #if 0
39 ; // This is for Emacs
40 #endif 
41
42 //____________________________________________________________________
43 AliFMDMCSharingFilter::AliFMDMCSharingFilter(const char* title)
44   : AliFMDSharingFilter(title), 
45     fTrackDensity(title),
46     fFMD1i(0),
47     fFMD2i(0),
48     fFMD2o(0),
49     fFMD3i(0),
50     fFMD3o(0),
51     fOperComp(0)
52 {
53   // 
54   // Constructor 
55   // 
56   // Parameters:
57   //    title Title of object  - not significant 
58   //
59   fFMD1i = new TH2D("FMD1i_corr", "Merged vs MC", 21, -.5, 20.5, 300, 0, 15);
60   fFMD2i = new TH2D("FMD2i_corr", "Merged vs MC", 21, -.5, 20.5, 300, 0, 15);
61   fFMD2o = new TH2D("FMD2o_corr", "Merged vs MC", 21, -.5, 20.5, 300, 0, 15);
62   fFMD3i = new TH2D("FMD3i_corr", "Merged vs MC", 21, -.5, 20.5, 300, 0, 15);
63   fFMD3o = new TH2D("FMD3o_corr", "Merged vs MC", 21, -.5, 20.5, 300, 0, 15);
64   fFMD1i->SetYTitle("#Delta E/#Delta_{mip} (ESD)");
65   fFMD1i->SetXTitle("Hits (MC)");
66   fFMD2i->SetYTitle("#Delta E/#Delta_{mip} (ESD)");
67   fFMD2i->SetXTitle("Hits (MC)");
68   fFMD2o->SetYTitle("#Delta E/#Delta_{mip} (ESD)");
69   fFMD2o->SetXTitle("Hits (MC)");
70   fFMD3i->SetYTitle("#Delta E/#Delta_{mip} (ESD)");
71   fFMD3i->SetXTitle("Hits (MC)");
72   fFMD3o->SetYTitle("#Delta E/#Delta_{mip} (ESD)");
73   fFMD3o->SetXTitle("Hits (MC)");
74   fFMD1i->SetDirectory(0);
75   fFMD2i->SetDirectory(0);
76   fFMD2o->SetDirectory(0);
77   fFMD3i->SetDirectory(0);
78   fFMD3o->SetDirectory(0);
79
80   fOper     = new AliFMDFloatMap(0,0,0,0);
81   fOperComp = new TH2I("operComp", "Operation vs # track refs", 
82                        kMergedInto, kNone-.5, kMergedInto+.5, 
83                        20, -.5, 19.5);
84   fOperComp->SetXTitle("Operation");
85   fOperComp->SetYTitle("# of track refs in sector");
86   fOperComp->SetZTitle("Observations");
87   fOperComp->GetXaxis()->SetBinLabel(kNone,            "None");
88   fOperComp->GetXaxis()->SetBinLabel(kCandidate,       "Candidate");
89   fOperComp->GetXaxis()->SetBinLabel(kMergedWithOther, "Merged w/other");
90   fOperComp->GetXaxis()->SetBinLabel(kMergedInto,      "Merged into");
91   fOperComp->SetDirectory(0);
92 }
93
94 //____________________________________________________________________
95 AliFMDMCSharingFilter::AliFMDMCSharingFilter(const AliFMDMCSharingFilter& o)
96   : AliFMDSharingFilter(o), 
97     fTrackDensity(o.fTrackDensity),
98     fFMD1i(o.fFMD1i),
99     fFMD2i(o.fFMD2i),
100     fFMD2o(o.fFMD2o),
101     fFMD3i(o.fFMD3i),
102     fFMD3o(o.fFMD3o),
103     fOperComp(o.fOperComp)
104 {
105   // 
106   // Copy constructor 
107   // 
108   // Parameters:
109   //    o Object to copy from 
110   //
111 }
112
113 //____________________________________________________________________
114 AliFMDMCSharingFilter::~AliFMDMCSharingFilter()
115 {
116   // 
117   // Destructor
118   //
119 }
120
121 //____________________________________________________________________
122 AliFMDMCSharingFilter&
123 AliFMDMCSharingFilter::operator=(const AliFMDMCSharingFilter& o)
124 {
125   // 
126   // Assignment operator 
127   // 
128   // Parameters:
129   //    o Object to assign from 
130   // 
131   // Return:
132   //    Reference to this 
133   //
134   AliFMDSharingFilter::operator=(o);
135   fTrackDensity = o.fTrackDensity;
136   return *this;
137 }
138
139
140 //____________________________________________________________________
141 Bool_t
142 AliFMDMCSharingFilter::FilterMC(const AliESDFMD&  input, 
143                                 const AliMCEvent& event,
144                                 Double_t          vz,
145                                 AliESDFMD&        output, 
146                                 TH2D*             primary)
147 {
148   // 
149   // Filter the input kinematics and track references, using 
150   // some of the ESD information
151   // 
152   // Parameters:
153   //    input   Input ESD event
154   //    event   Input MC event
155   //    vz      Vertex position 
156   //    output  Output ESD-like object
157   //    primary Per-event histogram of primaries 
158   //
159   // Return:
160   //    True on succes, false otherwise 
161   //
162   output.Clear();
163
164
165   fTrackDensity.Calculate(input, event, vz, output, primary);
166
167   return kTRUE;
168 }
169
170 //____________________________________________________________________
171 void
172 AliFMDMCSharingFilter::CompareResults(const AliESDFMD&  esd, 
173                                       const AliESDFMD&  mc)
174 {
175   // 
176   // Compare the result of merging to the monte-carlo truth.  This
177   // fills the correlation histograms
178   // 
179   // Parameters:
180   //    esd  ESD after sharing correction
181   //    mc   MC ESD 
182   //
183
184   // Copy eta values to output 
185   for (UShort_t d = 1; d <= 3; d++) { 
186     UShort_t nq = (d == 1 ? 1 : 2);
187     for (UShort_t q = 0; q < nq; q++) {
188       Char_t   r  = (q == 0 ? 'I' : 'O');
189       UShort_t ns = (q == 0 ?  20 :  40);
190       UShort_t nt = (q == 0 ? 512 : 256);
191       TH2*     co = 0;
192       switch (d) { 
193       case 1: co = fFMD1i; break;
194       case 2: co = (q == 0 ? fFMD2i : fFMD2o); break;
195       case 3: co = (q == 0 ? fFMD3i : fFMD3o); break;
196       }
197
198       for (UShort_t s = 0; s < ns; s++) {
199         for (UShort_t t = 0; t < nt; t++) { 
200           Float_t mEsd = esd.Multiplicity(d, r, s, t);
201           Float_t mMc  = mc.Multiplicity(d, r, s, t);
202
203           co->Fill(mMc, mEsd);
204         } 
205       }
206     }
207   }
208 }
209   
210 //____________________________________________________________________
211 void
212 AliFMDMCSharingFilter::DefineOutput(TList* dir)
213 {
214   // 
215   // Define the output histograms.  These are put in a sub list of the
216   // passed list.   The histograms are merged before the parent task calls 
217   // AliAnalysisTaskSE::Terminate 
218   // 
219   // Parameters:
220   //    dir Directory to add to 
221   //
222   AliFMDSharingFilter::DefineOutput(dir);
223   TList* d = static_cast<TList*>(dir->FindObject(GetName()));
224   TList* cd = new TList;
225   cd->SetOwner();
226   cd->SetName("esd_mc_comparion");
227   d->Add(cd);
228   cd->Add(fFMD1i);
229   cd->Add(fFMD2i);
230   cd->Add(fFMD2o);
231   cd->Add(fFMD3i);
232   cd->Add(fFMD3o);
233   cd->Add(fOperComp);
234   fTrackDensity.DefineOutput(d);
235 }
236
237 //____________________________________________________________________
238 void
239 AliFMDMCSharingFilter::ScaleHistograms(const TList* dir, Int_t nEvents)
240 {
241   // 
242   // Scale the histograms to the total number of events 
243   // 
244   // Parameters:
245   //    dir     Where the output is 
246   //    nEvents Number of events 
247   //
248   AliFMDSharingFilter::ScaleHistograms(dir, nEvents);
249 }
250
251 //____________________________________________________________________
252 void
253 AliFMDMCSharingFilter::SetDebug(Int_t dbg)
254 {
255   AliFMDSharingFilter::SetDebug(dbg);
256   fTrackDensity.SetDebug(dbg > 2);
257 }
258
259 //____________________________________________________________________
260 void
261 AliFMDMCSharingFilter::Print(Option_t* option) const
262 {
263   // 
264   // Print information
265   // 
266   // Parameters:
267   //    option Not used 
268   //
269   AliFMDSharingFilter::Print(option);
270   gROOT->IncreaseDirLevel();
271   fTrackDensity.Print(option);
272   gROOT->DecreaseDirLevel();
273
274 }
275
276 //____________________________________________________________________
277 //
278 // EOF
279 //