]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoModelCorrFctnDirectYlm.cxx
Fix Coverity
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemtoUser / AliFemtoModelCorrFctnDirectYlm.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 ///                                                                          ///
3 /// AliFemtoModelCorrFctnDirectYlm - 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(AliFemtoModelCorrFctnDirectYlm, 1)
11 #endif
12
13 #include "AliFemtoModelGausLCMSFreezeOutGenerator.h"
14 #include "AliFemtoModelHiddenInfo.h"
15 #include "AliFemtoModelCorrFctnDirectYlm.h"
16     
17 //_______________________
18 AliFemtoModelCorrFctnDirectYlm::AliFemtoModelCorrFctnDirectYlm(): 
19   AliFemtoModelCorrFctn(),
20   fCYlmTrue(0),
21   fCYlmFake(0),
22   fUseLCMS(0)
23 {
24   // default constructor
25
26   fCYlmTrue = new AliFemtoCorrFctnDirectYlm();
27   fCYlmFake = new AliFemtoCorrFctnDirectYlm();
28   fCYlmTrue->SetUseLCMS(fUseLCMS);
29   fCYlmFake->SetUseLCMS(fUseLCMS);
30 }
31 //_______________________
32 AliFemtoModelCorrFctnDirectYlm::AliFemtoModelCorrFctnDirectYlm(const char *title, Int_t aMaxL, Int_t aNbins, Double_t aQinvLo, Double_t aQinvHi, int aUseLCMS=0):
33   AliFemtoModelCorrFctn(title, aNbins, aQinvLo, aQinvHi),
34   fCYlmTrue(0),
35   fCYlmFake(0),
36   fUseLCMS(aUseLCMS)
37 {
38   // basic constructor
39   char fname[1000];
40   snprintf(fname, 1000, "%s%s", title, "True");
41   fCYlmTrue = new AliFemtoCorrFctnDirectYlm(fname, aMaxL, aNbins, aQinvLo, aQinvHi, fUseLCMS);
42   snprintf(fname, 1000, "%s%s", title, "Fake");
43   fCYlmFake = new AliFemtoCorrFctnDirectYlm(fname, aMaxL, aNbins, aQinvLo, aQinvHi, fUseLCMS);
44 }
45 //_______________________
46 AliFemtoModelCorrFctnDirectYlm::AliFemtoModelCorrFctnDirectYlm(const AliFemtoModelCorrFctnDirectYlm& aCorrFctn):
47   AliFemtoModelCorrFctn(aCorrFctn),
48   fCYlmTrue(new AliFemtoCorrFctnDirectYlm(*(aCorrFctn.fCYlmTrue))),
49   fCYlmFake(new AliFemtoCorrFctnDirectYlm(*(aCorrFctn.fCYlmFake))),
50   fUseLCMS(0)
51 {
52   // copy constructor
53   fUseLCMS = aCorrFctn.fUseLCMS;
54 //   fCYlmTrue = dynamic_cast<AliFemtoCorrFctnDirectYlm*>(aCorrFctn.fCYlmTrue->Clone());
55 //   fCYlmFake = dynamic_cast<AliFemtoCorrFctnDirectYlm*>(aCorrFctn.fCYlmFake->Clone());
56 }
57 //_______________________
58 AliFemtoModelCorrFctnDirectYlm::~AliFemtoModelCorrFctnDirectYlm()
59 {
60   // destructor
61   if (fCYlmTrue) delete fCYlmTrue;
62   if (fCYlmFake) delete fCYlmFake;
63   if (fNumeratorTrue) delete fNumeratorTrue;
64   if (fNumeratorFake) delete fNumeratorFake;
65   if (fDenominator) delete fDenominator;
66 }
67
68 //_______________________
69 AliFemtoModelCorrFctnDirectYlm& AliFemtoModelCorrFctnDirectYlm::operator=(const AliFemtoModelCorrFctnDirectYlm& aCorrFctn)
70 {
71   // assignment operator
72   if (this == &aCorrFctn) 
73     return *this;
74
75   fUseLCMS = aCorrFctn.fUseLCMS;
76
77   if (aCorrFctn.fCYlmTrue)
78     fCYlmTrue = dynamic_cast<AliFemtoCorrFctnDirectYlm*>(aCorrFctn.fCYlmTrue->Clone());
79   else fCYlmTrue = 0;
80
81   if (aCorrFctn.fCYlmFake)
82     fCYlmFake = dynamic_cast<AliFemtoCorrFctnDirectYlm*>(aCorrFctn.fCYlmFake->Clone());
83   else fCYlmFake = 0;
84
85   if (aCorrFctn.fNumeratorTrue)
86     fNumeratorTrue = new TH1D(*aCorrFctn.fNumeratorTrue);
87   else
88     fNumeratorTrue = 0;
89
90   if (aCorrFctn.fNumeratorFake)
91     fNumeratorFake = new TH1D(*aCorrFctn.fNumeratorFake);
92   else
93     fNumeratorFake = 0;
94
95   if (aCorrFctn.fDenominator)
96     fDenominator = new TH1D(*aCorrFctn.fDenominator);
97   else
98     fDenominator = 0;
99
100   return *this;
101 }
102 //_______________________
103 AliFemtoString AliFemtoModelCorrFctnDirectYlm::Report()
104 {
105   // construct report
106   AliFemtoString tStr = "AliFemtoModelCorrFctnDirectYlm report";
107
108   return tStr;
109 }
110
111 //_______________________
112 void AliFemtoModelCorrFctnDirectYlm::AddRealPair(AliFemtoPair* aPair)
113 {
114   // add real (effect) pair
115   if (fPairCut)
116     if (!(fPairCut->Pass(aPair))) return;
117
118   Double_t weight = fManager->GetWeight(aPair);
119   
120   if (fUseLCMS)
121     fCYlmTrue->AddRealPair(aPair->QOutCMS(), aPair->QSideCMS(), aPair->QLongCMS(), weight);
122   else
123     fCYlmTrue->AddRealPair(aPair->KOut(), aPair->KSide(), aPair->KLong(), weight);
124 }
125 //_______________________
126 void AliFemtoModelCorrFctnDirectYlm::AddMixedPair(AliFemtoPair* aPair)
127 {
128   // add mixed (background) pair
129   if (fPairCut)
130     if (!(fPairCut->Pass(aPair))) return;
131
132   Double_t weight = fManager->GetWeight(aPair);
133
134   if (fUseLCMS) {
135     fCYlmTrue->AddMixedPair(aPair->QOutCMS(), aPair->QSideCMS(), aPair->QLongCMS(), 1.0);
136     fCYlmFake->AddRealPair(aPair->QOutCMS(), aPair->QSideCMS(), aPair->QLongCMS(), weight);
137     fCYlmFake->AddMixedPair(aPair->QOutCMS(), aPair->QSideCMS(), aPair->QLongCMS(), 1.0);
138   }
139   else {
140     fCYlmTrue->AddMixedPair(aPair->KOut(), aPair->KSide(), aPair->KLong(), 1.0);
141     fCYlmFake->AddRealPair(aPair->KOut(), aPair->KSide(), aPair->KLong(), weight);
142     fCYlmFake->AddMixedPair(aPair->KOut(), aPair->KSide(), aPair->KLong(), 1.0);
143   }
144 }
145 //_______________________
146 void AliFemtoModelCorrFctnDirectYlm::Write()
147 {
148   // write out all the histograms
149   
150   fCYlmTrue->Write();
151   fCYlmFake->Write();
152 }
153 //_______________________
154 TList* AliFemtoModelCorrFctnDirectYlm::GetOutputList()
155 {
156   // Prepare the list of objects to be written to the output
157   TList *tOutputList = AliFemtoModelCorrFctn::GetOutputList();
158   tOutputList->Clear();
159
160   TList *tListCfTrue = fCYlmTrue->GetOutputList();
161     
162   TIter nextListCfTrue(tListCfTrue);
163   while (TObject *obj = nextListCfTrue()) {
164     tOutputList->Add(obj);
165   }
166
167   TList *tListCfFake = fCYlmFake->GetOutputList();
168     
169   TIter nextListCfFake(tListCfFake);
170   while (TObject *obj = nextListCfFake()) {
171     tOutputList->Add(obj);
172   }
173 //   tOutputList->Add(fCYlmTrue->GetOutputList());
174 //   tOutputList->Add(fCYlmFake->GetOutputList());
175
176   return tOutputList;
177 }
178 //_______________________
179 AliFemtoModelCorrFctn* AliFemtoModelCorrFctnDirectYlm::Clone()
180 {
181   // Clone the correlation function
182   AliFemtoModelCorrFctnDirectYlm *tCopy = new AliFemtoModelCorrFctnDirectYlm(*this);
183   
184   return tCopy;
185 }
186 //_______________________
187 void AliFemtoModelCorrFctnDirectYlm::Finish()
188 {
189   fCYlmTrue->Finish();
190   fCYlmFake->Finish();
191 }
192 //_______________________
193 void AliFemtoModelCorrFctnDirectYlm::SetUseLCMS(int aUseLCMS)
194 {
195   fUseLCMS = aUseLCMS;
196   fCYlmTrue->SetUseLCMS(fUseLCMS);
197   fCYlmFake->SetUseLCMS(fUseLCMS);
198 }
199 //_______________________
200 int  AliFemtoModelCorrFctnDirectYlm::GetUseLCMS()
201 {
202   return fUseLCMS;
203 }
204