00001
00002
00003
00004
00005
00006
00008
00009
00010
00012
00013 #include <Stiostream.h>
00014 #include <stdlib.h>
00015 #include <math.h>
00016 #include "StMaker.h"
00017 #include "StPidAmpMaker.h"
00018 #include "StFlowMaker/StFlowMaker.h"
00019 #include "StFlowMaker/StFlowEvent.h"
00020 #include "StFlowMaker/StFlowConstants.h"
00021 #include "StFlowMaker/StFlowSelection.h"
00022 #include "StFlowMaker/StFlowCutTrack.h"
00023 #include "StEnumerations.h"
00024 #include "PhysicalConstants.h"
00025 #include "SystemOfUnits.h"
00026 #include "TVector2.h"
00027 #include "TFile.h"
00028 #include "TString.h"
00029 #include "TH1.h"
00030 #include "TH2.h"
00031 #include "TH3.h"
00032 #include "TF1.h"
00033 #include "StMessMgr.h"
00034 #include "TMath.h"
00035 #define PR(x) cout << "##### PidAmp " << (#x) << " = " << (x) << endl;
00036
00037 ClassImp(StPidAmpMaker)
00038
00039
00040
00041 StPidAmpMaker::StPidAmpMaker(const Char_t* name):
00042 StMaker(name),
00043 mSingleMultiplicityBin(1),
00044 MakerName(name) {
00045
00046 }
00047
00048
00049
00050 StPidAmpMaker::~StPidAmpMaker() {
00051 }
00052
00053
00054
00055 Int_t StPidAmpMaker::Make() {
00056
00057
00058
00059
00060 StFlowMaker* pFlowMaker = NULL;
00061 pFlowMaker = (StFlowMaker*)GetMaker("Flow");
00062 if (pFlowMaker) pFlowEvent = pFlowMaker->FlowEventPointer();
00063 if (pFlowEvent && pFlowSelect->Select(pFlowEvent)) {
00064
00065 if (pFlowEvent) FillParticleHistograms();
00066
00067 if (Debug()) StMaker::PrintInfo();
00068
00069 }
00070
00071 return kStOK;
00072 }
00073
00074
00075
00076 Int_t StPidAmpMaker::Init() {
00077
00078
00079
00080 TH1F dummyHisto("dummy","dummy",mNDedxBins,mDedxStart,mDedxEnd);
00081
00082 pidHisto
00083 =new TH1F*[mSingleMultiplicityBin*mNDcaBins*mNChargeBins*mNPBins*mNEtaBins*mNNHitsBins];
00084
00085 for(int m=0;m<mSingleMultiplicityBin;m++)
00086 for(int d=0; d<mNDcaBins;d++)
00087 for(int e=0; e<mNChargeBins;e++)
00088 for(int i=0; i<mNPBins;i++)
00089 for(int j=0; j<mNEtaBins;j++)
00090 for(int k=0; k<mNNHitsBins; k++){
00091 char *theName = new char[80];
00092
00093 if (i<10){
00094 sprintf(theName,"%d%d%d0%d%d%d",theMultBin,d,e,i,j,k);
00095 }else {
00096 sprintf(theName,"%d%d%d%d%d%d",theMultBin,d,e,i,j,k);
00097 }
00098
00099 pidHisto[GetPositionInArray(m,d,e,i,j,k)]=
00100 new TH1F(dummyHisto);
00101 pidHisto[GetPositionInArray(m,d,e,i,j,k)]->SetName(theName);
00102 pidHisto[GetPositionInArray(m,d,e,i,j,k)]->SetTitle(theName);
00103
00104 cout<<"booking histo, mult. # "<<theMultBin<<", dca # "<<d<<", charge # "<<e<<", p # "<<i<<", eta # "<<j<<", ndedx # "<<k<<endl;
00105 }
00106
00107
00108 gMessMgr->SetLimit("##### StPidAmp", 2);
00109 gMessMgr->Info("##### StPidAmp: $Id: StPidAmpMaker.cxx,v 1.12 2003/09/02 17:58:46 perev Exp $");
00110
00111 return StMaker::Init();
00112 }
00113
00114
00115
00116
00117
00118
00119 void StPidAmpMaker::FillParticleHistograms() {
00120
00121
00122 int multBin=0;
00123
00124
00125 StFlowTrackCollection* pFlowTracks = pFlowEvent->TrackCollection();
00126 StFlowTrackIterator itr;
00127
00128 for (itr = pFlowTracks->begin(); itr != pFlowTracks->end(); itr++) {
00129 StFlowTrack* pFlowTrack = *itr;
00130
00131 float eta = pFlowTrack->Eta();
00132 int charge = pFlowTrack->Charge();
00133
00134
00135 int fitPts = pFlowTrack->FitPts();
00136 float mtm = pFlowTrack->P();
00137 float dedx = pFlowTrack->Dedx();
00138 float NDedxUsed = (fitPts-1.39589)/1.41276;
00139
00140 int dcaBin=0;
00141 int chargeBin=0;
00142 int pBin=0;
00143 int etaBin=0;
00144 int nhitsBin=0;
00145
00146 dcaBin=0;
00147
00148 chargeBin= (charge>0) ? 1 : 0;
00149
00150 pBin=int(mtm/((mPEnd-mPStart)/mNPBins));
00151 if (pBin>(mNPBins-1)) continue;
00152
00153 etaBin=int(fabs(eta)/((mEtaEnd-mEtaStart)/mNEtaBins));
00154 if (etaBin>(mNEtaBins-1)) continue;
00155
00156 nhitsBin=
00157 int(float(NDedxUsed)/(float(mNNHitsEnd-mNNHitsStart)/mNNHitsBins));
00158 nhitsBin=(nhitsBin>(mNNHitsBins-1)) ? (mNNHitsBins-1) : nhitsBin;
00159 nhitsBin=(nhitsBin<0) ? 0 : nhitsBin;
00160
00161 if (dedx>mDedxStart && dedx<mDedxEnd)
00162 pidHisto[GetPositionInArray(multBin,dcaBin,chargeBin,pBin,etaBin,nhitsBin)]->Fill(dedx);
00163
00164 }
00165
00166
00167 }
00168
00169
00170
00171 Int_t StPidAmpMaker::GetPositionInArray(Int_t theMultBin, Int_t theDcaBin, Int_t theChargeBin, Int_t thePBin, Int_t theEtaBin, Int_t theNHitsBin){
00172
00173 int totalEntry
00174 = mSingleMultiplicityBin*mNDcaBins*mNChargeBins*mNPBins*mNEtaBins*mNNHitsBins;
00175
00176 int positionPointer=0;
00177
00178 totalEntry=totalEntry/mSingleMultiplicityBin;
00179 positionPointer=positionPointer+totalEntry*theMultBin;
00180
00181 totalEntry=totalEntry/mNDcaBins;
00182 positionPointer=positionPointer+totalEntry*theDcaBin;
00183
00184 totalEntry=totalEntry/mNChargeBins;
00185 positionPointer=positionPointer+totalEntry*theChargeBin;
00186
00187 totalEntry=totalEntry/mNPBins;
00188 positionPointer=positionPointer+totalEntry*thePBin;
00189
00190 totalEntry=totalEntry/mNEtaBins;
00191 positionPointer=positionPointer+totalEntry*theEtaBin;
00192
00193 totalEntry=totalEntry/mNNHitsBins;
00194 positionPointer=positionPointer+totalEntry*theNHitsBin;
00195
00196 return positionPointer;
00197 }
00198
00199
00200
00201
00202
00203
00204 Int_t StPidAmpMaker::Finish() {
00205
00206
00207 for(int m=0;m<mSingleMultiplicityBin;m++)
00208 for(int d=0; d<mNDcaBins;d++)
00209 for(int e=0; e<mNChargeBins;e++) {
00210
00211 char *theHistoFileName = new char[200];
00212 sprintf(theHistoFileName,"./PidHisto_%d%d%d.root",theMultBin,d,e);
00213
00214 TFile histoFile(theHistoFileName,"RECREATE");
00215 cout<<" writting histogram file "<<theHistoFileName<<endl;
00216
00217 histoFile.cd();
00218
00219
00221
00222
00223
00224
00225 char* multName=new char[80];
00226 sprintf(multName,"%d",theMultBin);
00227
00228 TString tempString;
00229 tempString.Append(multName);
00230
00231 if (d==0) tempString.Append("P");
00232 else tempString.Append("N");
00233
00234 if (e==0) tempString.Append("-");
00235 else tempString.Append("+");
00236
00237
00238 TNamed fileNameTag(tempString,tempString);
00239
00240 fileNameTag.Write();
00241
00242
00243 TH1F* tempHisto=0;
00244
00245 for (int i =0; i<mNPBins; i++)
00246 for (int j=0; j<mNEtaBins;j++)
00247 for (int k=0; k<mNNHitsBins;k++) {
00248
00249
00250 char *theName = new char[80];
00251 if (i<10)
00252 sprintf(theName,"h0%d%d%d",i,j,k);
00253 else sprintf(theName,"h%d%d%d",i,j,k);
00254
00255 histoFile.cd();
00256 tempHisto=new TH1F(*(pidHisto[GetPositionInArray(m,d,e,i,j,k)]));
00257 tempHisto->SetName(theName);
00258 tempHisto->SetTitle(theName);
00259 tempHisto->Write();
00260 delete tempHisto;
00261
00262 }
00263
00264 histoFile.Write();
00265
00266 histoFile.Close();
00267
00268 }
00269
00270
00271
00272
00273
00274 delete pFlowSelect;
00275
00276 cout << endl;
00277 gMessMgr->Summary(3);
00278 cout << endl;
00279
00280 return StMaker::Finish();
00281 }
00282
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298