StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtEvtGenPair.cxx
1 /***************************************************************************
2  *
3  *
4  *
5  * Author: Laurent Conin, Fabrice Retiere, Subatech, France
6  ***************************************************************************
7  *
8  * Description : Create pair from StHbtEvtGenHiddenInfo
9  *
10  ***************************************************************************
11  *
12  *
13  *
14  ***************************************************************************/
15 
16 #include "StHbtMaker/ThCorrFctn/StHbtEvtGenPair.h"
17 #include "StHbtMaker/ThCorrFctn/StHbtEvtGenHiddenInfo.hh"
18 #include "StHbtMaker/Infrastructure/StHbtParticle.hh"
19 
20 #include "TRandom.h"
21 #include "TMath.h"
22 
23 ClassImp(StHbtEvtGenPair)
24 
25 StHbtEvtGenPair::StHbtEvtGenPair(short aDecoralate) :
26  StHbtThPair(),mDecoralate(aDecoralate) {
27  if(mDecoralate==2){
28  mNStoredPos=100;
29  mPosArray1 = new StHbtLorentzVector[mNStoredPos];
30  mValidPos1 = new short[mNStoredPos];
31  mPosArray2 = new StHbtLorentzVector[mNStoredPos];
32  mValidPos2 = new short[mNStoredPos];
33  for(int ti=0; ti< mNStoredPos; ti++){
34  mValidPos1[ti]=0;
35  mValidPos2[ti]=0;
36  }
37  }
38 }
39 
40 StHbtEvtGenPair::~StHbtEvtGenPair(){
41  if(mDecoralate==2){
42  delete[] mPosArray1;
43  delete[] mValidPos1;
44  delete[] mPosArray2;
45  delete[] mValidPos2;
46  }
47 }
48 
49 void StHbtEvtGenPair::setVariables(const StHbtPair* aPair){
50  double tTimeShift = 3.75;
51  double SpaceShift = -4.21; if(SpaceShift){/*touch*/};
52 
53  StHbtEvtGenHiddenInfo* tEvtGenHiddenInfoV[2];
54  tEvtGenHiddenInfoV[0] =
55  (StHbtEvtGenHiddenInfo*)(aPair->track1()->getHiddenInfo());
56  tEvtGenHiddenInfoV[1] =
57  (StHbtEvtGenHiddenInfo*)(aPair->track2()->getHiddenInfo());
58 
59  mMomentum1=tEvtGenHiddenInfoV[0]->getFreezeOutMomEn();
60  mMomentum2=tEvtGenHiddenInfoV[1]->getFreezeOutMomEn();
61 
62  for(int ti=0; ti<2; ti++){
63  StHbtEvtGenHiddenInfo* tEvtGenHiddenInfo = tEvtGenHiddenInfoV[ti];
64 
65  if(tEvtGenHiddenInfo->posHaveNotBeenModified()){
66  StHbtLorentzVector* tEmPoint=tEvtGenHiddenInfo->getEmPoint();
67 
68  switch(mDecoralate){
69  case 1: // Randomize phi
70  {
71  static TRandom tRand;
72  double tR = tEmPoint->perp();
73  double tPhi = tRand.Rndm()*2.*TMath::Pi();
74  tEmPoint->setX(tR*cos(tPhi));
75  tEmPoint->setY(tR*sin(tPhi));
76  break;
77  }
78  case 2: // Randomize x and p
79  {
80  static TRandom tRand;
81  static StHbtLorentzVector tVect;
82  int tIndex = (int)(tRand.Rndm()*mNStoredPos);
83  StHbtLorentzVector* tPosArray;
84  short* tValidPos;
85  if(ti==0){
86  tPosArray = mPosArray1;
87  tValidPos = mValidPos1;
88  }
89  else{
90  tPosArray = mPosArray2;
91  tValidPos = mValidPos2;
92  }
93  if(tValidPos[tIndex]==0){
94  tPosArray[tIndex]=(*tEmPoint);
95  tValidPos[tIndex]=1;
96  }
97  else{
98  tVect = (*tEmPoint);
99  (*tEmPoint) = tPosArray[tIndex];
100  tPosArray[tIndex] = tVect;
101  }
102  break;
103  }
104  case 3: // set time to zero in particle LCMS
105  {
106  if(ti==1) tEmPoint->setT(tEmPoint->t()+tTimeShift/mMomentum2->e()*
107  mMomentum2->mt());
108  break;
109  }
110  case 4: // both 1 and 3
111  {
112  static TRandom tRand;
113  double tR = tEmPoint->perp();
114  double tPhi = tRand.Rndm()*2.*TMath::Pi();
115  tEmPoint->setX(tR*cos(tPhi));
116  tEmPoint->setY(tR*sin(tPhi));
117  if(ti==1) tEmPoint->setT(tEmPoint->t()+tTimeShift/mMomentum2->e()*
118  mMomentum2->mt());
119  break;
120  }
121  case 5: // Generate a static gaussian in rOut
122  {
123  static TRandom tRand;
124  static double sigma=9.0;
125  static double mu=3.0;
126  double mRandVar[3];
127  if (ti==0)
128  {
129  tEmPoint->setX(0.0);
130  tEmPoint->setY(0.0);
131  tEmPoint->setZ(0.0);
132  tEmPoint->setT(0.0);
133  }
134  else
135  {
136  mRandVar[0] = tRand.Gaus(0.,1.);
137  mRandVar[1] = tRand.Gaus(0.,1.);
138  mRandVar[2] = tRand.Gaus(0.,1.);
139 
140 
141  double tPx = mMomentum1->x()+mMomentum2->x();
142  double tPy = mMomentum1->y()+mMomentum2->y();
143  double tPz = mMomentum1->z()+mMomentum2->z();
144  double tE = mMomentum1->e()+mMomentum2->e();
145  double tPt = tPx*tPx + tPy*tPy;
146  //mCVK = tPz*tPz;
147  double tMt = tE*tE - tPz*tPz;//mCVK;
148  //mCVK += tPt;
149  //mCVK = ::sqrt(mCVK);
150  double tM = ::sqrt(tMt - tPt);
151  tMt = ::sqrt(tMt);
152  tPt = ::sqrt(tPt);
153 
154  double tROut = mRandVar[0]*sigma+mu;
155  double tRSide = mRandVar[1]*sigma;
156  double ttz = mRandVar[2]*sigma;
157  double ttt = tROut;
158  // mX2[2] = mRandVar[2]*sigma;
159  // mX2[3] = tROut; // =0 | Just a computing trick for the boost
160 
161  tROut *= (tMt/tM); // Rout*gammaT
162  ttt *= (tPt/tM); // Rout*betaT*gammaT
163  double ttDTime = ttt;
164  ttt += (tPz/tE*ttz);
165  ttt *= (tE/tMt);
166  ttz += (tPz/tE*ttDTime);
167  ttz *= (tE/tMt);
168 
169  tPx /= tPt;
170  tPy /= tPt;
171 
172  tEmPoint->setX(tROut*tPx-tRSide*tPy);
173  tEmPoint->setY(tROut*tPy+tRSide*tPx);
174  tEmPoint->setZ(ttz);
175  tEmPoint->setT(ttt);
176  }
177  break;
178  }
179  // case 4:
180  //{
181  // if(ti==1) {
182 
183  //tEmPoint->setT(tEmPoint->t()+tTimeShift/mMomentum2->e()*
184  // mMomentum2->mt());
185  //break;
186  //}
187  }
188  tEvtGenHiddenInfo->setPosHaveBeenModified();
189  }
190  }
191  mEmPoint1 = tEvtGenHiddenInfoV[0]->getEmPoint();
192  mEmPoint2 = tEvtGenHiddenInfoV[1]->getEmPoint();
193  mPid1=tEvtGenHiddenInfoV[0]->getPdgPid();
194  mPid2=tEvtGenHiddenInfoV[1]->getPdgPid();
195 
196  mMomParCalculated=0;
197  mPosParCalculated=0;
198 
199  mMeasPair=aPair;
200  mWeightOk=false;
201 }
202