StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ThBPCorrFctn.cxx
1 /***************************************************************************
2  *
3  *
4  *
5  * Author: Laurent Conin, Fabrice Retiere, Subatech, France
6  ***************************************************************************
7  *
8  * Description : Calculate the theoretical QInv correlation function
9  *
10  ***************************************************************************
11  *
12  *
13  *
14  ***************************************************************************/
15 
16 #include "Stsstream.h"
17 #include "StHbtMaker/ThCorrFctn/ThBPCorrFctn.h"
18 
19 #ifdef __ROOT__
20 ClassImp(ThBPCorrFctn)
21 #endif
22 
23 //____________________________
24 void ThBPCorrFctn::AddNum(StHbtThPair* aThPair){
25 
26  double tQinv = 2 * fabs(aThPair->GetMeasPair()->KStar()); // note - qInv() will be negative for identical pairs...
27  if ((tQinv < mQinvNormHi) && (tQinv > mQinvNormLo)) mNumRealsNorm++;
28  double qOut = aThPair->GetMeasPair()->qOutCMS();
29  double qSide = aThPair->GetMeasPair()->qSideCMS();
30  double qLong = fabs(aThPair->GetMeasPair()->qLongCMS());
31 
32  // cout << "Components Num: inv out side long: " << tQinv << " " << qOut << " " << qSide << " " << qLong << endl;
33  mNumerator->Fill(qOut,qSide,qLong,aThPair->GetWeightNum());
34 }
35 void ThBPCorrFctn::AddDen(StHbtThPair* aThPair){
36 
37  double tQinv= 2 * fabs(aThPair->GetMeasPair()->KStar());
38  if ((tQinv < mQinvNormHi) && (tQinv > mQinvNormLo)) mNumMixedNorm++;
39  double qOut = aThPair->GetMeasPair()->qOutCMS();
40  double qSide = aThPair->GetMeasPair()->qSideCMS();
41  double qLong = fabs(aThPair->GetMeasPair()->qLongCMS());
42 
43  if ((addedHistos == 1) && (tQinv < 0.1)) {
44  add2DHistos[0]->Fill(fabs(qOut), -(fabs(qOut) - fabs(aThPair->RealqOutCMS())), 1.0);
45  add2DHistos[1]->Fill(fabs(qSide), -(fabs(qSide) - fabs(aThPair->RealqSideCMS())), 1.0);
46  add2DHistos[2]->Fill(fabs(qLong), -(fabs(qLong) - fabs(aThPair->RealqLongCMS())), 1.0);
47  }
48 
49  // cout << "Components Den: inv out side long: " << tQinv << " " << qOut << " " << qSide << " " << qLong << endl;
50  mDenominator->Fill(qOut,qSide,qLong,aThPair->GetWeightDen());
51  mQinvHisto->Fill(qOut,qSide,qLong,tQinv);
52 }
53 
54 void ThBPCorrFctn::Finish(){
55  // here is where we should normalize, fit, etc...
56  double NumFact,DenFact;
57  if ((mNumRealsNorm !=0) && (mNumMixedNorm !=0)){
58  NumFact = double(mNumRealsNorm);
59  DenFact = double(mNumMixedNorm);
60  }
61  // can happen that the mNumRealsNorm and mNumMixedNorm = 0 if you do non-standard
62  // things like making a new CorrFctn and just setting the Numerator and Denominator
63  // from OTHER CorrFctns which you read in (like when doing parallel processing)
64  else{
65  cout << "Warning! - no normalization constants defined - I do the best I can..." << endl;
66  int nbins = mNumerator->GetNbinsX();
67  int half_way = nbins/2;
68  NumFact = mNumerator->Integral(half_way,nbins,half_way,nbins,half_way,nbins);
69  DenFact = mDenominator->Integral(half_way,nbins,half_way,nbins,half_way,nbins);
70  }
71 
72  mRatio->Divide(mNumerator,mDenominator,DenFact,NumFact);
73  mQinvHisto->Divide(mDenominator);
74 }
75 
76 ThBPCorrFctn::ThBPCorrFctn(char* aTitle, int aNBins,
77  double aHLo, double aHHi, int addHistos)
78 {
79  // set some stuff...
80  mQinvNormLo = 0.15;
81  mQinvNormHi = 0.18;
82  mNumRealsNorm = 0;
83  mNumMixedNorm = 0;
84 
85  // set up numerator
86  char TitNum[100] = "Num";
87  strcat(TitNum,aTitle);
88  mNumerator = new StHbt3DHisto(TitNum,aTitle,aNBins,aHLo,aHHi,aNBins,aHLo,aHHi,aNBins/2,0.0,aHHi);
89  // set up denominator
90  char TitDen[100] = "Den";
91  strcat(TitDen,aTitle);
92  mDenominator = new StHbt3DHisto(TitDen,aTitle,aNBins,aHLo,aHHi,aNBins,aHLo,aHHi,aNBins/2,0.0,aHHi);
93  // set up ratio
94  char TitRat[100] = "Rat";
95  strcat(TitRat,aTitle);
96  mRatio = new StHbt3DHisto(TitRat,aTitle,aNBins,aHLo,aHHi,aNBins,aHLo,aHHi,aNBins/2,0.0,aHHi);
97  // set up ave qInv
98  char TitQinv[100] = "Qinv";
99  strcat(TitQinv,aTitle);
100  mQinvHisto = new StHbt3DHisto(TitQinv,aTitle,aNBins,aHLo,aHHi,aNBins,aHLo,aHHi,aNBins/2,0.0,aHHi);
101 
102  // to enable error bar calculation...
103  mNumerator->Sumw2();
104  mDenominator->Sumw2();
105  mRatio->Sumw2();
106 
107  addedHistos = addHistos;
108  if (addHistos == 1) {
109  Int_t qdepNBins = 10;
110  Int_t qdiffNBins = 50;
111  Float_t qdepMin = 0.0, qdepMax=0.1;
112  Float_t qdiffMin = -0.025, qdiffMax = 0.025;
113  numAdd2DHistos = 3;
114  typedef StHbt2DHisto* StHbt2DHistoP;
115  add2DHistos = new StHbt2DHistoP[3];
116  char Tit1add[100] = "Qout";
117  strcat(Tit1add,aTitle);
118  add2DHistos[0] = new StHbt2DHisto(Tit1add,aTitle,qdepNBins, qdepMin, qdepMax, qdiffNBins, qdiffMin, qdiffMax);
119  char Tit2add[100] = "Qside";
120  strcat(Tit2add,aTitle);
121  add2DHistos[1] = new StHbt2DHisto(Tit2add,aTitle,qdepNBins, qdepMin, qdepMax, qdiffNBins, qdiffMin, qdiffMax);
122  char Tit3add[100] = "Qlong";
123  strcat(Tit3add,aTitle);
124  add2DHistos[2] = new StHbt2DHisto(Tit3add,aTitle,qdepNBins, qdepMin, qdepMax, qdiffNBins, qdiffMin, qdiffMax);
125  }
126 }
127 
128 ThBPCorrFctn::ThBPCorrFctn(const ThBPCorrFctn& ThCf)
129 {
130  mQinvNormLo = ThCf.mQinvNormLo;
131  mQinvNormHi = ThCf.mQinvNormHi;
132  mNumRealsNorm = ThCf.mNumRealsNorm;
133  mNumMixedNorm = ThCf.mNumMixedNorm;
134 
135  mNumerator = new StHbt3DHisto(*ThCf.mNumerator);
136  mDenominator = new StHbt3DHisto(*ThCf.mDenominator);
137  mRatio = new StHbt3DHisto(*ThCf.mRatio);
138  mQinvHisto = new StHbt3DHisto(*ThCf.mQinvHisto);
139 }
140 
141 StHbtString ThBPCorrFctn::Report()
142 {
143  std::ostringstream *out = new std::ostringstream();
144  (*out) << "Report form the ThBPLCMS Correlation function" << endl;
145  return out->str();
146 }
147 
148 ThBPCorrFctn::~ThBPCorrFctn()
149 {
150  delete mNumerator;
151  delete mDenominator;
152  delete mRatio;
153  delete mQinvHisto;
154  if (addedHistos > 0) {
155  for (int i=0; i<numAdd2DHistos; i++)
156  delete add2DHistos[i];
157  delete add2DHistos;
158  }
159 }
160 
161 void ThBPCorrFctn::Write() {
162  mNumerator->Write();mDenominator->Write();mRatio->Write();
163  if (addedHistos > 0) {
164  for (int i=0; i<numAdd2DHistos; i++)
165  add2DHistos[i]->Write();
166  }
167 };
168 
169 inline StHbt3DHisto* ThBPCorrFctn::Numerator() const { return mNumerator;};
170 inline StHbt3DHisto* ThBPCorrFctn::Denominator() const { return mDenominator;};
171 inline StHbt3DHisto* ThBPCorrFctn::Ratio() const { return mRatio;};
172 inline StHbtThCorrFctn* ThBPCorrFctn::ThClone() const {return new ThBPCorrFctn(*this);}