17 #include "StPidAmpMaker.h"
18 #include "StFlowMaker/StFlowMaker.h"
19 #include "StFlowMaker/StFlowEvent.h"
20 #include "StFlowMaker/StFlowConstants.h"
21 #include "StFlowMaker/StFlowSelection.h"
22 #include "StFlowMaker/StFlowCutTrack.h"
24 #include "PhysicalConstants.h"
25 #include "SystemOfUnits.h"
33 #include "StMessMgr.h"
35 #define PR(x) cout << "##### PidAmp " << (#x) << " = " << (x) << endl;
43 mSingleMultiplicityBin(1),
50 StPidAmpMaker::~StPidAmpMaker() {
62 if (pFlowMaker) pFlowEvent = pFlowMaker->FlowEventPointer();
63 if (pFlowEvent && pFlowSelect->Select(pFlowEvent)) {
65 if (pFlowEvent) FillParticleHistograms();
67 if (Debug()) StMaker::PrintInfo();
76 Int_t StPidAmpMaker::Init() {
80 TH1F dummyHisto(
"dummy",
"dummy",mNDedxBins,mDedxStart,mDedxEnd);
83 =
new TH1F*[mSingleMultiplicityBin*mNDcaBins*mNChargeBins*mNPBins*mNEtaBins*mNNHitsBins];
85 for(
int m=0;m<mSingleMultiplicityBin;m++)
86 for(
int d=0; d<mNDcaBins;d++)
87 for(
int e=0; e<mNChargeBins;e++)
88 for(
int i=0; i<mNPBins;i++)
89 for(
int j=0; j<mNEtaBins;j++)
90 for(
int k=0; k<mNNHitsBins; k++){
91 char *theName =
new char[80];
94 sprintf(theName,
"%d%d%d0%d%d%d",theMultBin,d,e,i,j,k);
96 sprintf(theName,
"%d%d%d%d%d%d",theMultBin,d,e,i,j,k);
99 pidHisto[GetPositionInArray(m,d,e,i,j,k)]=
100 new TH1F(dummyHisto);
101 pidHisto[GetPositionInArray(m,d,e,i,j,k)]->SetName(theName);
102 pidHisto[GetPositionInArray(m,d,e,i,j,k)]->SetTitle(theName);
104 cout<<
"booking histo, mult. # "<<theMultBin<<
", dca # "<<d<<
", charge # "<<e<<
", p # "<<i<<
", eta # "<<j<<
", ndedx # "<<k<<endl;
108 gMessMgr->SetLimit(
"##### StPidAmp", 2);
109 gMessMgr->Info(
"##### StPidAmp: $Id: StPidAmpMaker.cxx,v 1.12 2003/09/02 17:58:46 perev Exp $");
111 return StMaker::Init();
119 void StPidAmpMaker::FillParticleHistograms() {
125 StFlowTrackCollection* pFlowTracks = pFlowEvent->TrackCollection();
126 StFlowTrackIterator itr;
128 for (itr = pFlowTracks->begin(); itr != pFlowTracks->end(); itr++) {
131 float eta = pFlowTrack->Eta();
132 int charge = pFlowTrack->Charge();
135 int fitPts = pFlowTrack->FitPts();
136 float mtm = pFlowTrack->P();
137 float dedx = pFlowTrack->Dedx();
138 float NDedxUsed = (fitPts-1.39589)/1.41276;
148 chargeBin= (charge>0) ? 1 : 0;
150 pBin=int(mtm/((mPEnd-mPStart)/mNPBins));
151 if (pBin>(mNPBins-1))
continue;
153 etaBin=int(fabs(eta)/((mEtaEnd-mEtaStart)/mNEtaBins));
154 if (etaBin>(mNEtaBins-1))
continue;
157 int(
float(NDedxUsed)/(
float(mNNHitsEnd-mNNHitsStart)/mNNHitsBins));
158 nhitsBin=(nhitsBin>(mNNHitsBins-1)) ? (mNNHitsBins-1) : nhitsBin;
159 nhitsBin=(nhitsBin<0) ? 0 : nhitsBin;
161 if (dedx>mDedxStart && dedx<mDedxEnd)
162 pidHisto[GetPositionInArray(multBin,dcaBin,chargeBin,pBin,etaBin,nhitsBin)]->Fill(dedx);
171 Int_t StPidAmpMaker::GetPositionInArray(Int_t theMultBin, Int_t theDcaBin, Int_t theChargeBin, Int_t thePBin, Int_t theEtaBin, Int_t theNHitsBin){
174 = mSingleMultiplicityBin*mNDcaBins*mNChargeBins*mNPBins*mNEtaBins*mNNHitsBins;
176 int positionPointer=0;
178 totalEntry=totalEntry/mSingleMultiplicityBin;
179 positionPointer=positionPointer+totalEntry*theMultBin;
181 totalEntry=totalEntry/mNDcaBins;
182 positionPointer=positionPointer+totalEntry*theDcaBin;
184 totalEntry=totalEntry/mNChargeBins;
185 positionPointer=positionPointer+totalEntry*theChargeBin;
187 totalEntry=totalEntry/mNPBins;
188 positionPointer=positionPointer+totalEntry*thePBin;
190 totalEntry=totalEntry/mNEtaBins;
191 positionPointer=positionPointer+totalEntry*theEtaBin;
193 totalEntry=totalEntry/mNNHitsBins;
194 positionPointer=positionPointer+totalEntry*theNHitsBin;
196 return positionPointer;
207 for(
int m=0;m<mSingleMultiplicityBin;m++)
208 for(
int d=0; d<mNDcaBins;d++)
209 for(
int e=0; e<mNChargeBins;e++) {
211 char *theHistoFileName =
new char[200];
212 sprintf(theHistoFileName,
"./PidHisto_%d%d%d.root",theMultBin,d,e);
214 TFile histoFile(theHistoFileName,
"RECREATE");
215 cout<<
" writting histogram file "<<theHistoFileName<<endl;
225 char* multName=
new char[80];
226 sprintf(multName,
"%d",theMultBin);
229 tempString.Append(multName);
231 if (d==0) tempString.Append(
"P");
232 else tempString.Append(
"N");
234 if (e==0) tempString.Append(
"-");
235 else tempString.Append(
"+");
238 TNamed fileNameTag(tempString,tempString);
245 for (
int i =0; i<mNPBins; i++)
246 for (
int j=0; j<mNEtaBins;j++)
247 for (
int k=0; k<mNNHitsBins;k++) {
250 char *theName =
new char[80];
252 sprintf(theName,
"h0%d%d%d",i,j,k);
253 else sprintf(theName,
"h%d%d%d",i,j,k);
256 tempHisto=
new TH1F(*(pidHisto[GetPositionInArray(m,d,e,i,j,k)]));
257 tempHisto->SetName(theName);
258 tempHisto->SetTitle(theName);
277 gMessMgr->Summary(3);