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