e5503f1f34c4a3bd19283e840c18f005272ede68
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemtoUser / AliFemtoModelBPLCMSCorrFctn.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 ///                                                                          ///
3 /// AliFemtoModelBPLCMSCorrFctn - the class for correlation function which   ///
4 /// uses the model framework and weight generation and calculated the 3D     ///
5 /// correlation function in the Bertsh-Pratt LCMS system                     ///
6 /// Authors: Adam Kisiel, kisiel@mps.ohio-state.edu                          ///
7 ///                                                                          ///
8 ////////////////////////////////////////////////////////////////////////////////
9 #include "AliFemtoModelBPLCMSCorrFctn.h"
10 #include "AliFemtoPair.h"
11 #include "AliFemtoModelManager.h"
12 #include <cstdio>
13
14 #ifdef __ROOT__ 
15 ClassImp(AliFemtoModelBPLCMSCorrFctn)
16 #endif
17
18 //____________________________
19 AliFemtoModelBPLCMSCorrFctn::AliFemtoModelBPLCMSCorrFctn(char* title, const int& nbins, const float& QLo, const float& QHi)
20   :
21   AliFemtoModelCorrFctn(title, nbins, QLo, QHi),
22   fNumerator3DTrue(0),
23   fNumerator3DFake(0),
24   fDenominator3D(0),
25   fQinvHisto(0),
26   fPairCut(0)
27 {
28   // set up true numerator
29   char tTitNumT[100] = "Num3DTrue";
30   strcat(tTitNumT,title);
31   fNumerator3DTrue = new TH3D(tTitNumT,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
32   // set up fake numerator
33   char tTitNumF[100] = "Num3DFake";
34   strcat(tTitNumF,title);
35   fNumerator3DFake = new TH3D(tTitNumF,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
36   // set up denominator
37   char tTitDen[100] = "Den3D";
38   strcat(tTitDen,title);
39   fDenominator3D = new TH3D(tTitDen,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
40   // set up ave qInv
41   char tTitQinv[100] = "Qinv";
42   strcat(tTitQinv,title);
43   fQinvHisto = new TH3D(tTitQinv,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
44
45   // to enable error bar calculation...
46   fNumerator3DTrue->Sumw2();
47   fNumerator3DFake->Sumw2();
48   fDenominator3D->Sumw2();
49 }
50
51 AliFemtoModelBPLCMSCorrFctn::AliFemtoModelBPLCMSCorrFctn(const AliFemtoModelBPLCMSCorrFctn& aCorrFctn) :
52   AliFemtoModelCorrFctn(aCorrFctn),
53   fNumerator3DTrue(0),
54   fNumerator3DFake(0),
55   fDenominator3D(0),
56   fQinvHisto(0),
57   fPairCut(0)
58 {
59   // Copy constructor
60   fNumerator3DTrue = new TH3D(*aCorrFctn.fNumerator3DTrue);
61   fNumerator3DFake = new TH3D(*aCorrFctn.fNumerator3DFake);
62   fDenominator3D   = new TH3D(*aCorrFctn.fDenominator3D);
63   fQinvHisto       = new TH3D(*aCorrFctn.fQinvHisto);
64   fPairCut         = aCorrFctn.fPairCut->Clone();
65 }
66 //____________________________
67 AliFemtoModelBPLCMSCorrFctn::~AliFemtoModelBPLCMSCorrFctn()
68 {
69   // destructor
70   if (fNumeratorTrue) delete fNumeratorTrue;
71   if (fNumeratorFake) delete fNumeratorFake;
72   if (fDenominator) delete fDenominator;
73   delete fNumerator3DTrue;
74   delete fNumerator3DFake;
75   delete fDenominator3D;
76   delete fQinvHisto;
77   if (fPairCut) delete fPairCut;
78 }
79 //_________________________
80 AliFemtoModelBPLCMSCorrFctn& AliFemtoModelBPLCMSCorrFctn::operator=(const AliFemtoModelBPLCMSCorrFctn& aCorrFctn)
81 {
82   // Assignment operator
83   if (this == &aCorrFctn)
84     return *this;
85   if (fNumerator3DTrue) delete fNumerator3DTrue;
86   fNumerator3DTrue = new TH3D(*aCorrFctn.fNumerator3DTrue);
87   if (fNumerator3DFake) delete fNumerator3DFake;
88   fNumerator3DFake = new TH3D(*aCorrFctn.fNumerator3DFake);
89   if (fDenominator3D) delete fDenominator3D;
90   fDenominator3D = new TH3D(*aCorrFctn.fDenominator3D);
91   if (fQinvHisto) delete fQinvHisto;
92   fQinvHisto = new TH3D(*aCorrFctn.fQinvHisto);
93   fPairCut = aCorrFctn.fPairCut->Clone();
94
95   return *this;
96 }
97
98 //_________________________
99 void AliFemtoModelBPLCMSCorrFctn::Write(){
100   // Write out data histograms
101   AliFemtoModelCorrFctn::Write();
102   fNumerator3DTrue->Write();
103   fNumerator3DFake->Write();
104   fDenominator3D->Write();
105   fQinvHisto->Write();
106 }
107 //________________________
108 TList* AliFemtoModelBPLCMSCorrFctn::GetOutputList()
109 {
110   // Prepare the list of objects to be written to the output
111   TList *tOutputList = AliFemtoModelCorrFctn::GetOutputList();
112
113   tOutputList->Add(fNumerator3DTrue); 
114   tOutputList->Add(fNumerator3DFake);  
115   tOutputList->Add(fDenominator3D);  
116   tOutputList->Add(fQinvHisto);  
117
118   return tOutputList;
119 }
120
121 //_________________________
122 void AliFemtoModelBPLCMSCorrFctn::Finish(){
123   fQinvHisto->Divide(fDenominator);
124 }
125
126 //____________________________
127 AliFemtoString AliFemtoModelBPLCMSCorrFctn::Report(){
128   // Prepare a report from the execution
129   string stemp = "LCMS Frame Bertsch-Pratt 3D Model Correlation Function Report:\n";
130   char ctemp[100];
131   sprintf(ctemp,"Number of entries in numerator:\t%E\n",fNumeratorTrue->GetEntries());
132   stemp += ctemp;
133   sprintf(ctemp,"Number of entries in denominator:\t%E\n",fDenominator->GetEntries());
134   stemp += ctemp;
135   /*  if (fCorrection)
136       {
137       float radius = fCorrection->GetRadius();
138       sprintf(ctemp,"Coulomb correction used radius of\t%E\n",radius);
139       }
140       else
141       {
142       sprintf(ctemp,"No Coulomb Correction applied to this CorrFctn\n");
143       }
144       stemp += ctemp;
145   */
146
147   //  
148   AliFemtoString returnThis = stemp;
149   return returnThis;
150 }
151 //____________________________
152 void AliFemtoModelBPLCMSCorrFctn::AddRealPair( AliFemtoPair* pair)
153 {
154   // Store a real pair in numerator
155   if (fPairCut){
156     if (!(fPairCut->Pass(pair))) return;
157   }
158   
159   Double_t weight = fManager->GetWeight(pair);
160
161   double qOut = (pair->QOutCMS());
162   double qSide = (pair->QSideCMS());
163   double qLong = (pair->QLongCMS());
164
165   fNumerator3DTrue->Fill(qOut, qSide, qLong, weight);
166   fNumeratorTrue->Fill(pair->QInv(), weight);
167 }
168 //____________________________
169 void AliFemtoModelBPLCMSCorrFctn::AddMixedPair( AliFemtoPair* pair){
170   // store mixed pair in denominator
171   if (fPairCut){
172     if (!(fPairCut->Pass(pair))) return;
173   }
174
175   Double_t weight = fManager->GetWeight(pair);
176
177   double qOut = (pair->QOutCMS());
178   double qSide = (pair->QSideCMS());
179   double qLong = (pair->QLongCMS());
180
181   fNumerator3DFake->Fill(qOut, qSide, qLong, weight);
182   fDenominator3D->Fill(qOut, qSide, qLong, 1.0);
183   fNumeratorFake->Fill(pair->QInv(), weight);
184   fDenominator->Fill(pair->QInv(), 1.0);
185
186 }
187 //_______________________
188 AliFemtoModelCorrFctn* AliFemtoModelBPLCMSCorrFctn::Clone()
189 {
190   // Clone the correlation function
191   AliFemtoModelBPLCMSCorrFctn *tCopy = new AliFemtoModelBPLCMSCorrFctn(*this);
192   
193   return tCopy;
194 }
195
196 void AliFemtoModelBPLCMSCorrFctn::SetSpecificPairCut(AliFemtoPairCut* aCut)
197 {
198   fPairCut = aCut;
199 }