7 #include <TClonesArray.h>
13 #include "EEsoloPi0.h"
15 #include "StEEmcUtil/EEfeeRaw/EEfeeRawEvent.h"
16 #include "StEEmcUtil/EEfeeRaw/EEstarTrig.h"
17 #include "StEEmcUtil/EEfeeRaw/EEmcEventHeader.h"
19 #include "StEEmcUtil/EEfeeRaw/EEfeeDataBlock.h"
20 #include "StEEmcUtil/EEfeeRaw/EEname2Index.h"
22 #include "StEEmcUtil/database/EEmcDbItem.h"
26 #include "EEmcDb/EEmcDb.h"
28 #include "StEEmcUtil/database/StEEmcDb.h"
32 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
46 printf(
"EEsoloPi0() constructed\n");
50 float XseedEnergy=0.8;
52 float XmassLo=0.07, XmassHi=0.22;
53 set(XscaleFactor, XseedEnergy,XshapeLimit,XmassLo,XmassHi);
54 memset(hA,0,
sizeof(hA));
55 memset(hR,0,
sizeof(hR));
56 memset(hM,0,
sizeof(hM));
62 EEsoloPi0::~EEsoloPi0() {}
66 void EEsoloPi0::initRun(
int runID){
67 printf(
" EEsoloPi0::initRun(%d)\n",runID);
76 void EEsoloPi0::init(){
81 hA[0]=
new TH1F (
"tE",
"Eneregy (GeV) from any tower",100,0.,Emax);
82 hA[1]=
new TH1F (
"sE",
"Total Eneregy in event (GeV) (sum from all tower)",100,0.,Emax*24);
84 hA[2]=
new TH1F (
"cE",
"cluster Eneregy (GeV) ",200,0.,1.5*Emax);
86 hA[3]=
new TH1F (
"cSh",
"Shape: energy ratio highT/cluster",55,0.,1.1);
87 hA[4]=
new TH1F (
"cN",
"No. of clusters per event",30,-0.5,29.5);
88 hA[5]=
new TH1F (
"tT",
"Transverse Eneregy (GeV) from any tower",100,0.,Emax);
90 hA[7]=
new TH1F (
"ctbSum",
"CTB ADC sum", 240,0,12000);
94 if(hA[i]==0)
continue;
102 hR[1]=
new TH1F (
"invm",
"Invariant mass of 2 gammas (GeV)",80,0.,1.2);
104 hR[2]=(TH1F*)
new TH2F (
"d-E",
"Distance (cm) vs. 2clust energy (GeV)",50,0,1.5*Emax,100,0.,100);
105 hR[3]=(TH1F*)
new TH2F (
"eta12",
"eta1 vs. eta2 (bins)",12,0.5,12.5,12,0.5,12.5);
107 hR[4]=(TH1F*)
new TH2F (
"xyL",
"Y vs. X (cm) of LOW energy cluster",200,-250.,250,200,-250,250);
108 hR[5]=(TH1F*)
new TH2F (
"xyH",
"Y vs. X (cm) of HIGH energy cluster",200,-250.,250,200,-250,250);
109 hR[6]=
new TH1F (
"oAng",
"Opening angle/rad of any pair",30,0.,.3);
113 sprintf(ttt,
"cut invM=[%.2f,%.2f]",mLo,mHi);
114 hR[7]=
new TH1F (
"0ener",
"Energy (GeV), "+C+ttt,50,0.,Emax/2.);
115 hR[8]=
new TH1F (
"0eta",
"Pseudorapidity, "+C+ttt,25,0.,2.5);
116 hR[9]=
new TH1F (
"0phi",
"phi/rad, "+C+ttt,30,-3.14,3.14);
117 hR[10]=
new TH1F (
"0pt",
"pT (GeV/c), "+C+ttt,50,0.,Emax/4.);
118 hR[11]=(TH1F*)
new TH2F (
"0xyL",
"Y vs. X (cm) of LOW energy, "+C+ttt,200,-250.,250,200,-250,250);
119 hR[12]=(TH1F*)
new TH2F (
"0xyH",
"Y vs. X (cm) of HIGH energy, "+C+ttt,200,-250.,250,200,-250,250);
121 hR[13]=
new TH1F (
"ytw",
"Yield of clusters ;X= iphi+(Eta-1)*60, spiral",721,-.5,720.5);
123 hR[14]=
new TH1F (
"0ytw",
"Yield of clusters, "+C+ttt+
";X= iphi+(Eta-1)*60, spiral",721,-.5,720.5);
125 hR[15]=(TH1F*)
new TH2F (
"0d-E",
"Distance (cm) vs. 2clust energy (GeV), "+C+ttt,50,0,Emax,100,0.,100);
128 hR[24]=
new TH1F (
"0Ang",
"Opening angle/rad of pairs "+C+ttt,50,0.,.7);
129 hR[25]=(TH1F*)
new TH2F (
"invH",
"Time (minutes) vs. Invariant mass of 2 gammas (GeV)",75,0.,1.5,50,0,100);
130 hR[26]=
new TH1F (
"0Z",
"Z=|E1-E2|/sum ,"+C+ttt,25,0.,1.0);
134 char t1[100],t2[100];
135 sprintf(t1,
"invm%02d",i+1);
136 sprintf(t2,
"Invariant mass(GeV), ETA=%d",i+1);
137 hR[27+i]=
new TH1F (t1,t2,80,0.,1.2);
143 TH1F *h2=(TH1F *)h1->Clone();
144 TString tt=h2->GetTitle();
145 h2->SetTitle(
"MIX: "+tt);
147 h2->SetName(
"X"+tt);
148 h2->SetLineColor(kGreen);
157 printf(
"\nEEsoloPi0::init(), cuts: scaleFactor=%f ch/GeV, seedEnergy=%f GeV ,shapeLimit=%f, mLo=%.2f GeV, mHi=%.2f GeV\n\n",scaleFactor, seedEnergy,shapeLimit,mLo, mHi);
170 TotN2g=totPi0=totXPi0=0;
176 void EEsoloPi0::clear(){
181 memset(soloMip,0,
sizeof(soloMip));
182 memset(clust,0,
sizeof(clust));
190 void EEsoloPi0::finish(){
196 float ex=sqrt(s1+s2);
197 printf(
"s1=%f s2=%f\n",s1,s2);
200 float es2b=s2b*sqrt(1/s1+1/s2);
202 printf(
"\n EEsoloPi0::finish() TotN2g=%d, totPi0=%d totXPi0=%d \n",TotN2g,totPi0,totXPi0);
203 printf(
" Npi0=%.0f + / - %.0f , s2b=%.2f + / - %.3f for invm=[%.2f, %.2f]\n\n", x,ex,s2b,es2b,mLo,mHi);
211 void EEsoloPi0::print(){
212 printf(
"\n EEsoloPi0::print()\n soloMip dump:\n");
214 for(k0=0;k0<MxTw;k0++) {
215 if(soloMip[k0].e<=0)
continue;
219 printf(
"ieta=%d iphi=%d key=%d e=%f id=%d\n",ieta,iphi,soloMip[k0].key,soloMip[k0].e,soloMip[k0].
id);
222 printf(
"Clusters found:\nid k1 feta fphi eneTot\n");
224 for(ic=0;ic<nClust;ic++) {
225 printf(
"%d %d %.2f %.2f %5g\n",ic+1, clust[ic].k1,clust[ic].feta,clust[ic].fphi,clust[ic].eC);
231 int EEsoloPi0:: findTowerClust() {
232 assert(seedEnergy>0);
236 for(k=0;k<MxTw;k++) {
237 float ene=soloMip[k].e;
243 hA[1]->Fill(totEner);
247 float maxE=seedEnergy;
249 for(k0=0;k0<MxTw;k0++) {
250 if(soloMip[k0].e<maxE)
continue;
251 if(soloMip[k0].key>0)
continue;
258 clust[nClust].eH=soloMip[k1].e;
260 soloMip[k1].id=nClust;
267 Cluster clustG[MxTw];
270 for(ic=0;ic<nClust;ic++) {
271 sumTwClusterEnergy(ic);
272 float rat=clust[ic].eH/clust[ic].eC;
274 if(rat<shapeLimit)
continue;
275 hA[2]->Fill(clust[ic].eC);
277 clustG[nClustG++]=clust[ic];
283 for(ic=0;ic<nClustG;ic++) {
285 clust[ic]=clustG[ic];
298 void EEsoloPi0::findTowerPi0() {
299 if(nClust<2) return ;
303 for(i=0;i<nClust;i++)
304 for(j=i+1;j<nClust;j++) {
306 Cluster *cl1=&clust[i];
307 Cluster *cl2=&clust[j];
309 totPi0+=findInvM(cl1,cl2,hR);
326 float a=cl1->feta - cl2->feta;
327 float b=cl1->fphi - cl2->fphi;
332 if(b>MxTwPhi/2.) b=MxTwPhi-b;
333 if(sqrt(a*a+b*b) <sqrt(2.) )
continue;
335 totXPi0+=findInvM(cl1,cl2,hM);
346 void EEsoloPi0:: tagCluster(
int k0,
int d){
352 float ener=soloMip[ ieta + MxTwEta*iphi ].e;
353 for(i=ieta-d; i<=ieta+d;i++){
355 if( i>=MxTwEta || i<0)
continue;
356 for(j=iphi-d;j<=iphi+d;j++){
358 if( jj<0 ) jj+=MxTwPhi;
359 if( jj>=MxTwPhi ) jj-=MxTwPhi;
360 assert( jj>=0 && jj<MxTwPhi );
361 soloMip[ i + MxTwEta*jj ].key+=(int)(1000*ener);
369 void EEsoloPi0:: sumTwClusterEnergy(
int ic,
int d){
376 float w0=soloMip[ieta + MxTwEta*iphi].key;
377 double sum=0, sumi=0, sumj=0;
378 for(i=ieta-d; i<=ieta+d;i++){
379 if( i>=MxTwEta || i<0)
continue;
380 for(j=iphi-d;j<=iphi+d;j++){
382 if( jj<0 ) jj+=MxTwPhi;
383 if( jj>=MxTwPhi ) jj-=MxTwPhi;
384 assert( jj>=0 && jj<MxTwPhi );
385 int k1=i + MxTwEta*jj;
386 if(soloMip[k1].e<=0)
continue;
388 float w=w0/soloMip[ k1 ].key;
391 float e=w*soloMip[k1 ].e;
401 clust[ic].feta=sumi/sum;
402 clust[ic].fphi=sumj/sum;
409 float EEsoloPi0::sumPatchEnergy(
int k0,
int d,EEsoloMipA *soloMipX,
float *maxVal){
417 for(i=ieta-d; i<=ieta+d;i++){
418 if( i>=MxTwEta || i<0)
continue;
419 for(j=iphi-d;j<=iphi+d;j++){
421 if( jj<0 ) jj+=MxTwPhi;
422 if( jj>=MxTwPhi ) jj-=MxTwPhi;
423 assert( jj>=0 && jj<MxTwPhi );
424 int k1=i + MxTwEta*jj;
425 if(soloMipX[k1].e<=0)
continue;
426 sum+=soloMipX[k1 ].e;
427 if(max<soloMipX[k1 ].e) max=soloMipX[k1 ].e;
431 if(maxVal) *maxVal=max;
433 printf(
"sumPatchEnergy(k0=%d, d=%d)=%f ,max=%f\n",k0, d,sum,max);
441 int EEsoloPi0::findInvM(Cluster *c1, Cluster *c2, TH1F **h){
447 TVector3 r1=geom-> getDirection( c1->feta, c1->fphi);
448 TVector3 r2=geom-> getDirection( c2->feta, c2->fphi);
450 TVector3 p1=e1* r1.Unit();
451 TVector3 p2=e2* r2.Unit();
453 float opAngle=p1.Angle(p2);
460 float invm2= e12*e12-p12*p12;
461 float invm=sqrt(invm2);
463 float d12=sqrt(r12*r12);
466 if(invm>0.1 & invm<0.20)
468 printf(
"\ninvM=%.3f e1=%.2f e2=%.2f ", invm,e1,e2);
472 float mm2=2.0*e1*e2*(1.0-cos(p1.Angle(p2)));
473 printf(
"\ninvM=%f e1=%f e2=%f feta1=%f fphi1=%f feta2=%f fphi2=%f\n d12/cm=%f ang01=%f ang02=%f ang12=%f etot=%f m=%f\n",
474 invm,e1,e2,c1->feta, c1->fphi,c2->feta, c2->fphi,d12,p12.Angle(p1),p12.Angle(p2),p1.Angle(p2),e12, sqrt(mm2));
476 printf(
" x1,y1,z1=%f %f %f\n",r1.x(),r1.y(),r1.z());
477 printf(
" x2,y2,z2=%f %f %f\n",r2.x(),r2.y(),r2.z());
478 printf(
" p1,p1,p1=%f %f %f\n",p1.x(),p1.y(),p1.z());
479 printf(
" p2,p2,p2=%f %f %f\n",p2.x(),p2.y(),p2.z());
486 h[25]->Fill(invm,timeSec/60.);
488 h[(int) (27+c1->feta)] ->Fill(invm);
489 h[(int) (27+c2->feta)] ->Fill(invm);
491 if(c1->eC < c2->eC) {
492 ((TH2F*) h[4])->Fill(r1.x(),r1.y());
493 ((TH2F*) h[5])->Fill(r2.x(),r2.y());
495 ((TH2F*) h[5])->Fill(r1.x(),r1.y());
496 ((TH2F*) h[4])->Fill(r2.x(),r2.y());
499 int bin1=1+c1->k1%12;
500 int bin2=1+c2->k1%12;
501 if (bin2>bin1) {
int kk=bin1; bin1=bin2; bin2=kk;}
503 ((TH2F*) h[3])->Fill(bin1, bin2);
505 ((TH2F*) h[2])->Fill(e12,d12);
508 int kk1=(c1->k1%12)*60+ (c1->k1/12);
509 int kk2=(c2->k1%12)*60+ (c2->k1/12);
513 if(mLo<invm && invm<mHi){
516 h[8]->Fill(p12.Eta());
517 h[9]->Fill(p12.Phi());
518 h[10]->Fill(p12.Pt());
521 ((TH2F*) h[15])->Fill(e12,d12);
522 h[24]->Fill(opAngle);
524 float zE=fabs(c1->eC - c2->eC)/(c1->eC + c2->eC);
527 if(c1->eC < c2->eC) {
528 ((TH2F*) h[11])->Fill(r1.x(),r1.y());
529 ((TH2F*) h[12])->Fill(r2.x(),r2.y());
531 ((TH2F*) h[12])->Fill(r1.x(),r1.y());
532 ((TH2F*) h[11])->Fill(r2.x(),r2.y());
566 float adc2gev[MaxEtaBins]={
567 18.938, 20.769, 22.650, 24.575,
568 26.539, 28.514, 30.493, 32.473,
569 34.438, 36.387, 38.28, 40.146 };
571 if(strstr(x->name,
"01TA05"))
continue;
572 if(strstr(x->name,
"11TD09"))
continue;
573 if(strstr(x->name,
"09TB06"))
continue;
TObjArray * HList
DB access point.