Port of changes from v4-07-Release and additional rule conformance
[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 {
27
28   // set up true numerator
29   char TitNumT[100] = "Num3DTrue";
30   strcat(TitNumT,title);
31   fNumerator3DTrue = new TH3D(TitNumT,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
32   // set up fake numerator
33   char TitNumF[100] = "Num3DFake";
34   strcat(TitNumF,title);
35   fNumerator3DFake = new TH3D(TitNumF,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
36   // set up denominator
37   char TitDen[100] = "Den3D";
38   strcat(TitDen,title);
39   fDenominator3D = new TH3D(TitDen,title,nbins,QLo,QHi,nbins,QLo,QHi,nbins,QLo,QHi);
40   // set up ave qInv
41   char TitQinv[100] = "Qinv";
42   strcat(TitQinv,title);
43   fQinvHisto = new TH3D(TitQinv,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 {
58   fNumerator3DTrue = new TH3D(*aCorrFctn.fNumerator3DTrue);
59   fNumerator3DFake = new TH3D(*aCorrFctn.fNumerator3DFake);
60   fDenominator3D   = new TH3D(*aCorrFctn.fDenominator3D);
61   fQinvHisto       = new TH3D(*aCorrFctn.fQinvHisto);
62 }
63 //____________________________
64 AliFemtoModelBPLCMSCorrFctn::~AliFemtoModelBPLCMSCorrFctn()
65 {
66   if (fNumeratorTrue) delete fNumeratorTrue;
67   if (fNumeratorFake) delete fNumeratorFake;
68   if (fDenominator) delete fDenominator;
69   delete fNumerator3DTrue;
70   delete fNumerator3DFake;
71   delete fDenominator3D;
72   delete fQinvHisto;
73 }
74 //_________________________
75 AliFemtoModelBPLCMSCorrFctn& AliFemtoModelBPLCMSCorrFctn::operator=(const AliFemtoModelBPLCMSCorrFctn& aCorrFctn)
76 {
77   if (this == &aCorrFctn)
78     return *this;
79   if (fNumerator3DTrue) delete fNumerator3DTrue;
80   fNumerator3DTrue = new TH3D(*aCorrFctn.fNumerator3DTrue);
81   if (fNumerator3DFake) delete fNumerator3DFake;
82   fNumerator3DFake = new TH3D(*aCorrFctn.fNumerator3DFake);
83   if (fDenominator3D) delete fDenominator3D;
84   fDenominator3D = new TH3D(*aCorrFctn.fDenominator3D);
85   if (fQinvHisto) delete fQinvHisto;
86   fQinvHisto = new TH3D(*aCorrFctn.fQinvHisto);
87
88   return *this;
89 }
90
91 //_________________________
92 void AliFemtoModelBPLCMSCorrFctn::Write(){
93   AliFemtoModelCorrFctn::Write();
94   fNumerator3DTrue->Write();
95   fNumerator3DFake->Write();
96   fDenominator3D->Write();
97   fQinvHisto->Write();
98 }
99
100 //_________________________
101 void AliFemtoModelBPLCMSCorrFctn::Finish(){
102   fQinvHisto->Divide(fDenominator);
103 }
104
105 //____________________________
106 AliFemtoString AliFemtoModelBPLCMSCorrFctn::Report(){
107   string stemp = "LCMS Frame Bertsch-Pratt 3D Model Correlation Function Report:\n";
108   char ctemp[100];
109   sprintf(ctemp,"Number of entries in numerator:\t%E\n",fNumeratorTrue->GetEntries());
110   stemp += ctemp;
111   sprintf(ctemp,"Number of entries in denominator:\t%E\n",fDenominator->GetEntries());
112   stemp += ctemp;
113   /*  if (fCorrection)
114       {
115       float radius = fCorrection->GetRadius();
116       sprintf(ctemp,"Coulomb correction used radius of\t%E\n",radius);
117       }
118       else
119       {
120       sprintf(ctemp,"No Coulomb Correction applied to this CorrFctn\n");
121       }
122       stemp += ctemp;
123   */
124
125   //  
126   AliFemtoString returnThis = stemp;
127   return returnThis;
128 }
129 //____________________________
130 void AliFemtoModelBPLCMSCorrFctn::AddRealPair( AliFemtoPair* pair){
131   Double_t weight = fManager->GetWeight(pair);
132
133   double qOut = fabs(pair->QOutCMS());
134   double qSide = fabs(pair->QSideCMS());
135   double qLong = fabs(pair->QLongCMS());
136
137   fNumerator3DTrue->Fill(qOut, qSide, qLong, weight);
138   fNumeratorTrue->Fill(pair->QInv(), weight);
139 }
140 //____________________________
141 void AliFemtoModelBPLCMSCorrFctn::AddMixedPair( AliFemtoPair* pair){
142   Double_t weight = fManager->GetWeight(pair);
143
144   double qOut = fabs(pair->QOutCMS());
145   double qSide = fabs(pair->QSideCMS());
146   double qLong = fabs(pair->QLongCMS());
147
148   fNumerator3DFake->Fill(qOut, qSide, qLong, weight);
149   fDenominator3D->Fill(qOut, qSide, qLong, 1.0);
150   fNumeratorFake->Fill(pair->QInv(), weight);
151   fDenominator->Fill(pair->QInv(), 1.0);
152
153 }
154 //_______________________
155 AliFemtoModelCorrFctn* AliFemtoModelBPLCMSCorrFctn::Clone()
156 {
157   // Clone the correlation function
158   AliFemtoModelBPLCMSCorrFctn *tCopy = new AliFemtoModelBPLCMSCorrFctn(*this);
159   
160   return tCopy;
161 }