Fix Coverity 10974-82
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemtoUser / AliFemtoModelCorrFctnSource.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 ///                                                                          ///
3 /// AliFemtoModelCorrFctnSource - the class for correlation function which   ///
4 /// uses the model framework and weight generation and saves the generated   ///
5 /// emission source                                                          ///
6 /// Authors: Adam Kisiel, kisiel@mps.ohio-state.edu                          ///
7 ///                                                                          ///
8 ////////////////////////////////////////////////////////////////////////////////
9 #ifdef __ROOT__
10   ClassImp(AliFemtoModelCorrFctnSource, 1)
11 #endif
12
13 #include "AliFemtoModelGausLCMSFreezeOutGenerator.h"
14 #include "AliFemtoModelHiddenInfo.h"
15 #include "AliFemtoModelCorrFctnSource.h"
16 #include "AliFemtoKTPairCut.h"
17 #include "AliFemtoAnalysisReactionPlane.h"
18     
19 //_______________________
20 AliFemtoModelCorrFctnSource::AliFemtoModelCorrFctnSource(): 
21   AliFemtoModelCorrFctn(),
22   fHistROut(0),
23   fHistRSide(0),
24   fHistRLong(0),
25   fHistRStar(0),
26   fHistdNdR(0),
27   fHistNumWS(0),
28   fHistDenWS(0),
29   fUseRPSelection(0)
30 {
31   // default constructor
32   char buf[100];
33   char title[100] = "CFSource";
34   sprintf(buf, "%sOut", title);
35   fHistROut = new TH1D(buf,buf,100,-50.0,50.0);
36   sprintf(buf, "%sSide", title);
37   fHistRSide = new TH1D(buf,buf,100,-50.0,50.0);
38   sprintf(buf, "%sLong", title);
39   fHistRLong = new TH1D(buf,buf,100,-50.0,50.0);
40   sprintf(buf, "%sInv", title);
41   fHistRStar = new TH1D(buf,buf,100,-50.0,50.0);
42   sprintf(buf, "%sdNdR", title);
43   fHistdNdR = new TH1D(buf,buf,100,-50.0,50.0);
44
45   sprintf(buf, "%sNWS", title);
46   fHistNumWS = new TH2D(buf,buf,50,0.0,0.5,100,0.0,2.0);
47   sprintf(buf, "%sDWS", title);
48   fHistDenWS = new TH2D(buf,buf,50,0.0,0.5,100,0.0,2.0);
49
50   fHistROut->Sumw2();
51   fHistRSide->Sumw2();
52   fHistRLong->Sumw2();
53   fHistRStar->Sumw2();
54   fHistdNdR->Sumw2();
55 }
56 //_______________________
57 AliFemtoModelCorrFctnSource::AliFemtoModelCorrFctnSource(const char *title, Int_t aNbins, Double_t aQinvLo, Double_t aQinvHi):
58   AliFemtoModelCorrFctn(title, aNbins, aQinvLo, aQinvHi),
59   fHistROut(0),
60   fHistRSide(0),
61   fHistRLong(0),
62   fHistRStar(0),
63   fHistdNdR(0),
64   fHistNumWS(0),
65   fHistDenWS(0),
66   fUseRPSelection(0)
67 {
68   // basic constructor
69   char buf[100];
70   sprintf(buf, "%sOut", title);
71   fHistROut = new TH1D(buf,buf,100,-50.0,50.0);
72   sprintf(buf, "%sSide", title);
73   fHistRSide = new TH1D(buf,buf,100,-50.0,50.0);
74   sprintf(buf, "%sLong", title);
75   fHistRLong = new TH1D(buf,buf,100,-50.0,50.0);
76   sprintf(buf, "%sInv", title);
77   fHistRStar = new TH1D(buf,buf,100,-50.0,50.0);
78   sprintf(buf, "%sdNdR", title);
79   fHistdNdR = new TH1D(buf,buf,100,-50.0,50.0);
80
81   sprintf(buf, "%sNWS", title);
82   fHistNumWS = new TH2D(buf,buf,50,0.0,0.5,100,0.0,2.0);
83   sprintf(buf, "%sDWS", title);
84   fHistDenWS = new TH2D(buf,buf,50,0.0,0.5,100,0.0,2.0);
85
86   fHistROut->Sumw2();
87   fHistRSide->Sumw2();
88   fHistRLong->Sumw2();
89   fHistRStar->Sumw2();
90   fHistdNdR->Sumw2();
91 }
92 //_______________________
93 AliFemtoModelCorrFctnSource::AliFemtoModelCorrFctnSource(const AliFemtoModelCorrFctnSource& aCorrFctn):
94   AliFemtoModelCorrFctn(aCorrFctn),
95   fHistROut(0),
96   fHistRSide(0),
97   fHistRLong(0),
98   fHistRStar(0),
99   fHistdNdR(0),
100   fHistNumWS(0),
101   fHistDenWS(0),
102   fUseRPSelection(0)
103 {
104   // copy constructor
105   fHistROut = new TH1D (*aCorrFctn.fHistROut);
106   fHistRSide = new TH1D(*aCorrFctn.fHistRSide);
107   fHistRLong = new TH1D(*aCorrFctn.fHistRLong);
108   fHistRStar = new TH1D(*aCorrFctn.fHistRStar);
109   fHistdNdR = new TH1D(*aCorrFctn.fHistdNdR);
110   fHistNumWS = new TH2D(*aCorrFctn.fHistNumWS);
111   fHistDenWS = new TH2D(*aCorrFctn.fHistDenWS);
112
113   fUseRPSelection = aCorrFctn.fUseRPSelection;
114 }
115 //_______________________
116 AliFemtoModelCorrFctnSource::~AliFemtoModelCorrFctnSource()
117 {
118   // destructor
119   if (fHistROut) delete fHistROut;
120   if (fHistRSide) delete fHistRSide;
121   if (fHistRLong) delete fHistRLong;
122   if (fHistRStar) delete fHistRStar;
123   if (fHistdNdR) delete fHistdNdR;
124   if (fHistNumWS) delete fHistNumWS;
125   if (fHistDenWS) delete fHistDenWS;
126   if (fNumeratorTrue) delete fNumeratorTrue;
127   if (fNumeratorFake) delete fNumeratorFake;
128   if (fDenominator) delete fDenominator;
129 }
130
131 //_______________________
132 AliFemtoModelCorrFctnSource& AliFemtoModelCorrFctnSource::operator=(const AliFemtoModelCorrFctnSource& aCorrFctn)
133 {
134   // assignment operator
135   if (this == &aCorrFctn) 
136     return *this;
137   if (aCorrFctn.fHistROut)
138     fHistROut = new TH1D (*aCorrFctn.fHistROut);
139   else fHistROut = 0;
140   if (aCorrFctn.fHistRSide)
141     fHistRSide = new TH1D(*aCorrFctn.fHistRSide);
142   else fHistRSide = 0;
143   if (aCorrFctn.fHistRLong)
144     fHistRLong = new TH1D(*aCorrFctn.fHistRLong);
145   else fHistRLong = 0;
146   if (aCorrFctn.fHistRStar)
147     fHistRStar = new TH1D(*aCorrFctn.fHistRStar);
148   fHistRStar = 0;
149   if (aCorrFctn.fHistdNdR)
150     fHistdNdR = new TH1D(*aCorrFctn.fHistdNdR);
151   else fHistdNdR = 0;
152   if (aCorrFctn.fHistNumWS)
153     fHistNumWS = new TH2D(*aCorrFctn.fHistNumWS);
154   else fHistNumWS = 0;
155   if (aCorrFctn.fHistDenWS)
156     fHistDenWS = new TH2D(*aCorrFctn.fHistDenWS);
157   else fHistDenWS = 0;
158
159   fUseRPSelection = aCorrFctn.fUseRPSelection;
160
161   return *this;
162 }
163 //_______________________
164 AliFemtoString AliFemtoModelCorrFctnSource::Report()
165 {
166   // construct report
167   AliFemtoString tStr = "AliFemtoModelCorrFctnSource report";
168
169   return tStr;
170 }
171
172 //_______________________
173 void AliFemtoModelCorrFctnSource::AddRealPair(AliFemtoPair* aPair)
174 {
175   // add real (effect) pair
176 //   if (fPairCut){
177 //     if (!(fPairCut->Pass(aPair))) return;
178 //   }
179   if (fPairCut){
180     if (fUseRPSelection) {
181       AliFemtoKTPairCut *ktc = dynamic_cast<AliFemtoKTPairCut *>(fPairCut);
182       if (!ktc) { 
183         cout << "RP aware cut requested, but not connected to the CF" << endl;
184         if (!(fPairCut->Pass(aPair))) return;
185       }
186       else {
187         AliFemtoAnalysisReactionPlane *arp = dynamic_cast<AliFemtoAnalysisReactionPlane *> (HbtAnalysis());
188         if (!arp) {
189           cout << "RP aware cut requested, but not connected to the CF" << endl;
190           if (!(fPairCut->Pass(aPair))) return;
191         }
192         else if (!(ktc->Pass(aPair, arp->GetCurrentReactionPlane()))) return;
193       }
194     }
195     else
196       if (!(fPairCut->Pass(aPair))) return;
197   }
198   
199   AliFemtoModelCorrFctn::AddRealPair(aPair);
200
201 }
202 //_______________________
203 void AliFemtoModelCorrFctnSource::AddMixedPair(AliFemtoPair* aPair)
204 {
205   // add mixed (background) pair
206 //   if (fPairCut){
207 //     if (!(fPairCut->Pass(aPair))) return;
208 //   }
209   if (fPairCut){
210     if (fUseRPSelection) {
211       AliFemtoKTPairCut *ktc = dynamic_cast<AliFemtoKTPairCut *>(fPairCut);
212       if (!ktc) { 
213         cout << "RP aware cut requested, but not connected to the CF" << endl;
214         if (!(fPairCut->Pass(aPair))) return;
215       }
216       else {
217         AliFemtoAnalysisReactionPlane *arp = dynamic_cast<AliFemtoAnalysisReactionPlane *> (HbtAnalysis());
218         if (!arp) {
219           cout << "RP aware cut requested, but not connected to the CF" << endl;
220           if (!(fPairCut->Pass(aPair))) return;
221         }
222         else if (!(ktc->Pass(aPair, arp->GetCurrentReactionPlane()))) return;
223       }
224     }
225     else
226       if (!(fPairCut->Pass(aPair))) return;
227   }
228   
229   AliFemtoModelCorrFctn::AddMixedPair(aPair);
230   // save the generated positions
231   if (aPair->KStar() < 0.2) {
232     fHistROut->Fill (fManager->GetWeightGenerator()->GetRStarOut());
233     fHistRSide->Fill(fManager->GetWeightGenerator()->GetRStarSide());
234     fHistRLong->Fill(fManager->GetWeightGenerator()->GetRStarLong());
235     fHistRStar->Fill(fManager->GetWeightGenerator()->GetRStar());
236     fHistdNdR->Fill (fManager->GetWeightGenerator()->GetRStar(),1.0/(fManager->GetWeightGenerator()->GetRStar()*fManager->GetWeightGenerator()->GetRStar()));
237   }
238
239   fHistDenWS->Fill(aPair->QInv(), 1.0);
240   Double_t weight = fManager->GetWeight(aPair);
241   fHistNumWS->Fill(aPair->QInv(), weight);
242 }
243 //_______________________
244 void AliFemtoModelCorrFctnSource::Write()
245 {
246   // write out all the histograms
247   fHistROut->Write();
248   fHistRSide->Write();
249   fHistRLong->Write();
250   fHistRStar->Write();
251   fHistdNdR->Write();
252   fHistNumWS->Write();
253   fHistDenWS->Write();
254
255   AliFemtoModelCorrFctn::Write();
256 }
257 //________________________
258 TList* AliFemtoModelCorrFctnSource::GetOutputList()
259 {
260   // Prepare the list of objects to be written to the output
261   TList *tOutputList = AliFemtoModelCorrFctn::GetOutputList();
262
263   tOutputList->Add(fHistROut); 
264   tOutputList->Add(fHistRSide);  
265   tOutputList->Add(fHistRLong);  
266   tOutputList->Add(fHistRStar);  
267   tOutputList->Add(fHistdNdR);  
268   tOutputList->Add(fHistDenWS);
269   tOutputList->Add(fHistNumWS);
270
271   return tOutputList;
272 }
273 //_______________________
274 AliFemtoModelCorrFctn* AliFemtoModelCorrFctnSource::Clone()
275 {
276   // Clone the correlation function
277   AliFemtoModelCorrFctnSource *tCopy = new AliFemtoModelCorrFctnSource(*this);
278   
279   return tCopy;
280 }
281
282 void AliFemtoModelCorrFctnSource::SetUseRPSelection(unsigned short aRPSel)
283 {
284   fUseRPSelection = aRPSel;
285 }