6 #include <St_base/StMessMgr.h>
8 #include "StGenericVertexMaker/StiPPVertex/ScintHitList.h"
12 ScintHitList::ScintHitList(
float Xphi0,
float XdPhi,
int mxPhi,
13 float Xeta0,
float XdEta,
int mxEta,
14 const char* name,
float wm,
float wv) {
25 active=
new int[nBin];
28 memset(h,0,
sizeof(h));
30 gMessMgr->Message(
"",
"I")
31 <<
"ScintHitList for "<<myName
32 <<
", use W_match="<< Wmatch<<
" W_veto="<<Wveto
33 <<
" nEta="<< nEta<<
" nPhi="<< nPhi<<
" nBin="<< nBin
40 ScintHitList::initRun(){
41 memset(active,0,nBin*
sizeof(
int));
44 gMessMgr->Message(
"",
"D")
45 <<
"Clear ScintHitList for "<<myName<<endm;
50 ScintHitList::~ScintHitList(){
60 ScintHitList::clear(){
61 memset(fired,0,nBin*
sizeof(
int));
62 memset(
track,0,nBin*
sizeof(
int));
63 nFired=nTrack=nMatch=0;
69 ScintHitList::iPhiEta2bin(
int iPhi,
int iEta) {
70 int iBin=iPhi+nPhi*iEta;
79 ScintHitList::getActive(
int iBin){
80 if(iBin<0 || iBin>=nBin)
return -1;
87 ScintHitList::getFired(
int iBin){
88 if(iBin<0 || iBin>=nBin)
return -1;
95 ScintHitList::getTrack(
int iBin){
96 if(iBin<0 || iBin>=nBin)
return -1;
103 ScintHitList::isMatched(
int iBin){
104 if(iBin<0 || iBin>=nBin)
return false;
105 if(active[iBin]>0 && fired[iBin]>0 &&
track[iBin]>0 )
return true;
112 ScintHitList::isVetoed(
int iBin){
113 if(iBin<0 || iBin>=nBin)
return false;
114 if(active[iBin]>0 && fired[iBin]==0 &&
track[iBin]>0 )
return true;
121 ScintHitList:: getWeight(
int iBin){
122 const float Wdunno=1;
123 if( getActive(iBin) <=0)
return Wdunno;
124 if(isMatched(iBin))
return Wmatch;
125 if(isVetoed(iBin))
return Wveto;
133 ScintHitList::iBin2iPhiEta(
int iBin,
int &iPhi,
int &iEta) {
143 ScintHitList::setActive(
int iBin){
153 ScintHitList::setFired(
int iBin){
156 if(active[iBin]<=0)
return;
164 ScintHitList::phiBin(
float phi){
166 int iPhi=(int)((phi-phi0)/dPhi);
167 if(iPhi<0) iPhi+=nPhi;
168 if(iPhi>=nPhi) iPhi-=nPhi;
177 ScintHitList:: addTrack(
float eta,
float phi){
180 int iEta=etaBin(eta);
181 int iPhi=phiBin(phi);
182 if(iEta<0 || iPhi<0 || iEta>=nEta || iPhi>=nPhi)
return iBin;
183 iBin=iPhiEta2bin(iPhi,iEta);
190 float eps=eta - (eta0+iEta*dEta);
193 eps=phi - (phi0+iPhi*dPhi);
195 h[7]->Fill(eps/3.1416*180);
205 ScintHitList::print(
int k){
207 LOG_INFO<< Form(
"%sHitList: nActive=%d nFired=%d nTrack=%d nMatch=%d",myName.Data(),nActive, nFired,nTrack,nMatch)<<endm;
208 LOG_DEBUG << Form(
"iBin iEta iPhi active:fired:track (LEFT: phi/deg, eta)")<<endm;
212 if(k==0 && fired[i]==0 &&
track[i]==0)
continue;
215 iBin2iPhiEta(i,iPhi,iEta);
217 if(fired[i] &&
track[i]) mm=
'*';
218 float etaF=bin2EtaLeft(iEta);
219 LOG_DEBUG << Form(
"%3d %3d %3d %d:%d:%d %c (%.1f, %.3f)",i,iEta,iPhi,active[i],fired[i],
track[i],mm,phi0+iPhi*dPhi/3.1416*180., etaF )<<endm;
221 LOG_DEBUG << Form(
"--- %d printed bins",nb)<<endm;
227 ScintHitList::doHisto(){
236 if(fired[i]) h[1]->Fill(i);
238 if(isMatched(i)) h[5]->Fill(i);
245 ScintHitList:: initHisto (TObjArray*HList){
246 const char *core=myName.Data();
247 char *type[3]={(
char *)
"Fired",(
char *)
"Track",(
char *)
"Matched tracks"};
248 char tt1[100],tt2[500];
252 sprintf(tt1,
"n%s%c",core,type[it][0]);
253 sprintf(tt2,
"%s hits n%s / eve",core,type[it]);
256 h[2*it]=
new TH1F(tt1,tt2,nb,-0.5,nb-0.5);
261 sprintf(tt1,
"%s%c",core,type[it][0]);
262 sprintf(tt2,
"%s : frequency of %s / element",core,type[it]);
263 h[2*it+1]=
new TH1F(tt1,tt2,nBin,0.5,nBin+0.5);
264 HList->Add(h[2*it+1]);
267 sprintf(tt1,
"%sDeta",core);
268 sprintf(tt2,
"%s tracks matched to fired cell; delta eta ",core);
269 h[6]=
new TH1F(tt1,tt2,200,-2*dEta,2*dEta);
272 sprintf(tt1,
"%sDphi",core);
273 sprintf(tt2,
"%s tracks matched to fired cell; delta phi/deg ",core);
274 float xx=2*dPhi/3.1416*180;
275 h[7]=
new TH1F(tt1,tt2,200,-xx,xx);