8 #include "ScintHitList.h"
13 ScintHitList::ScintHitList(
float Xphi0,
float XdPhi,
int mxPhi,
14 float Xeta0,
float XdEta,
int mxEta,
15 const char * name,
float wm,
float wv)
27 active=
new int[nBin];
30 memset(h,0,
sizeof(h));
32 gMessMgr->Message(
"",
"I")
33 <<
"ScintHitList for "<<myName
34 <<
", use W_match="<< Wmatch<<
" W_veto="<<Wveto
35 <<
" nEta="<< nEta<<
" nPhi="<< nPhi<<
" nBin="<< nBin
42 ScintHitList::initRun(){
43 memset(active,0,nBin*
sizeof(
int));
46 gMessMgr->Message(
"",
"D")
47 <<
"Clear ScintHitList for "<<myName<<endm;
52 ScintHitList::~ScintHitList(){
62 ScintHitList::clear(){
63 memset(fired,0,nBin*
sizeof(
int));
64 memset(
track,0,nBin*
sizeof(
int));
65 nFired=nTrack=nMatch=0;
71 ScintHitList::iPhiEta2bin(
int iPhi,
int iEta) {
72 int iBin=iPhi+nPhi*iEta;
81 ScintHitList::getActive(
int iBin){
82 if(iBin<0 || iBin>=nBin)
return -1;
89 ScintHitList::getFired(
int iBin){
90 if(iBin<0 || iBin>=nBin)
return -1;
97 ScintHitList::getTrack(
int iBin){
98 if(iBin<0 || iBin>=nBin)
return -1;
105 ScintHitList::isMatched(
int iBin){
106 if(iBin<0 || iBin>=nBin)
return false;
107 if(active[iBin]>0 && fired[iBin]>0 &&
track[iBin]>0 )
return true;
114 ScintHitList::isVetoed(
int iBin){
115 if(iBin<0 || iBin>=nBin)
return false;
116 if(active[iBin]>0 && fired[iBin]==0 &&
track[iBin]>0 )
return true;
123 ScintHitList:: getWeight(
int iBin){
124 const float Wdunno=1;
125 if( getActive(iBin) <=0)
return Wdunno;
126 if(isMatched(iBin))
return Wmatch;
127 if(isVetoed(iBin))
return Wveto;
135 ScintHitList::iBin2iPhiEta(
int iBin,
int &iPhi,
int &iEta) {
145 ScintHitList::setActive(
int iBin){
155 ScintHitList::setFired(
int iBin){
158 if(active[iBin]<=0)
return;
166 ScintHitList::phiBin(
float phi){
168 int iPhi=(int)((phi-phi0)/dPhi);
169 if(iPhi<0) iPhi+=nPhi;
170 if(iPhi>=nPhi) iPhi-=nPhi;
179 ScintHitList:: addTrack(
float eta,
float phi){
182 int iEta=etaBin(eta);
183 int iPhi=phiBin(phi);
184 if(iEta<0 || iPhi<0 || iEta>=nEta || iPhi>=nPhi)
return iBin;
185 iBin=iPhiEta2bin(iPhi,iEta);
192 float eps=eta - (eta0+iEta*dEta);
195 eps=phi - (phi0+iPhi*dPhi);
197 h[7]->Fill(eps/3.1416*180);
207 ScintHitList::print(
int k){
209 LOG_INFO<< Form(
"%sHitList: nActive=%d nFired=%d nTrack=%d nMatch=%d",myName.Data(),nActive, nFired,nTrack,nMatch)<<endm;
210 LOG_DEBUG << Form(
"iBin iEta iPhi active:fired:track (LEFT: phi/deg, eta)")<<endm;
214 if(k==0 && fired[i]==0 &&
track[i]==0)
continue;
217 iBin2iPhiEta(i,iPhi,iEta);
219 if(fired[i] &&
track[i]) mm=
'*';
220 float etaF=bin2EtaLeft(iEta);
221 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;
223 LOG_DEBUG << Form(
"--- %d printed bins",nb)<<endm;
229 ScintHitList::doHisto(){
238 if(fired[i]) h[1]->Fill(i);
240 if(isMatched(i)) h[5]->Fill(i);
247 ScintHitList:: initHisto (TObjArray*HList){
248 const char *core=myName.Data();
249 char *type[3]={(
char *)
"Fired",(
char *)
"Track",(
char *)
"Matched tracks"};
250 char tt1[100],tt2[500];
254 sprintf(tt1,
"n%s%c",core,type[it][0]);
255 sprintf(tt2,
"%s hits n%s / eve",core,type[it]);
258 h[2*it]=
new TH1F(tt1,tt2,nb,-0.5,nb-0.5);
263 sprintf(tt1,
"%s%c",core,type[it][0]);
264 sprintf(tt2,
"%s : frequency of %s / element",core,type[it]);
265 h[2*it+1]=
new TH1F(tt1,tt2,nBin,0.5,nBin+0.5);
266 HList->Add(h[2*it+1]);
269 sprintf(tt1,
"%sDeta",core);
270 sprintf(tt2,
"%s tracks matched to fired cell; delta eta ",core);
271 h[6]=
new TH1F(tt1,tt2,200,-2*dEta,2*dEta);
274 sprintf(tt1,
"%sDphi",core);
275 sprintf(tt2,
"%s tracks matched to fired cell; delta phi/deg ",core);
276 float xx=2*dPhi/3.1416*180;
277 h[7]=
new TH1F(tt1,tt2,200,-xx,xx);