1 #include "StEEmcDisplay.h"
3 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
10 #include "TPaveText.h"
13 #include "StMessMgr.h"
17 StEEmcDisplay::StEEmcDisplay(
const Char_t *name,
const Char_t *title ) : TNamed(name,title)
19 memset( mTowerEnergy, 0,
sizeof(mTowerEnergy) );
20 memset( mTowerStat, 0,
sizeof(mTowerStat) );
21 memset( mTowerFail, 0,
sizeof(mTowerFail) );
22 memset( mStripEnergy, 0,
sizeof(mStripEnergy) );
23 memset( mStripStat, 0,
sizeof(mStripStat) );
24 memset( mStripFail, 0,
sizeof(mStripFail) );
36 mEnergy2Mip=1000.0/1.3;
50 memset( mTowerEnergy, 0,
sizeof(mTowerEnergy) );
51 memset( mTowerStat, 0,
sizeof(mTowerStat) );
52 memset( mTowerFail, 0,
sizeof(mTowerFail) );
53 memset( mStripEnergy, 0,
sizeof(mStripEnergy) );
54 memset( mStripStat, 0,
sizeof(mStripStat) );
55 memset( mStripFail, 0,
sizeof(mStripFail) );
62 mClusterEnergy.clear();
64 mClusterSigma.clear();
65 mClusterSector.clear();
66 mClusterPlane.clear();
67 for ( UInt_t ii=0;ii<mClusterStrips.size();ii++) mClusterStrips[ii].
clear();
68 mClusterStrips.clear();
69 mClusterHisto.clear();
70 mClusterStats.clear();
71 mClusterColor.clear();
73 mClusterSplit.clear();
85 if (hTowers )
delete hTowers;
88 if ( hPre1 )
delete hPre1;
91 if ( hPre2 )
delete hPre2;
94 if ( hPost)
delete hPost;
97 for ( Int_t sec=0;sec<12;sec++ )
98 for ( Int_t plane=0;plane<2;plane++ ){
99 if ( hSmds[sec][plane] )
delete hSmds[sec][plane];
102 if (eemc)
delete eemc; eemc=0;
103 if (smdu)
delete smdu; smdu=0;
104 if (smdv)
delete smdv; smdv=0;
106 if (pre1)
delete pre1; pre1=0;
107 if (pre2)
delete pre2; pre2=0;
108 if (post)
delete post; post=0;
120 Int_t sec = tower.
sector();
122 Int_t eta = tower.
etabin();
123 Int_t layer=tower.
layer();
125 mTowerEnergy[sec][sub][eta]=tower.
energy();
126 mTowerStat[sec][sub][eta]=tower.
stat();
127 mTowerFail[sec][sub][eta]=tower.
fail();
130 mPrepostEnergy[sec][sub][eta][layer-1]=tower.
energy();
131 mPrepostStat[sec][sub][eta][layer-1]=tower.
stat();
132 mPrepostFail[sec][sub][eta][layer-1]=tower.
fail();
147 Int_t sec = strip.
sector();
148 Int_t plane = strip.
plane();
149 Int_t index=strip.
index();
150 mStripEnergy[sec][plane][index]=strip.
energy();
151 mStripStat[sec][plane][index]=strip.
stat();
152 mStripFail[sec][plane][index]=strip.
fail();
157 mClusterKey.push_back( cluster.
key() );
158 mClusterSector.push_back( cluster.sector() );
159 mClusterEnergy.push_back( cluster.energy() );
160 mClusterPlane.push_back( cluster.plane() );
161 std::vector< Int_t > strips;
162 for ( Int_t ii=0;ii<cluster.size();ii++ )
163 strips.push_back( cluster.
strip(ii).
index() );
164 mClusterStrips.push_back( strips );
165 mClusterColor.push_back( color );
166 mClusterFill.push_back( fill );
167 mClusterMean.push_back( cluster.mean() );
168 mClusterSigma.push_back( cluster.sigma() );
169 mClusterSplit.push_back( cluster.split() );
170 if ( cluster.plane()==0 ) nClustersU++;
171 if ( cluster.plane()==1 ) nClustersV++;
176 mPointKey.push_back( point.key() );
177 mPointEnergy.push_back( point.
energy() );
179 mPointX.push_back( position.X() );
180 mPointY.push_back( position.Y() );
181 mPointColor.push_back( color );
182 mPointStyle.push_back( style );
183 mPointUkey.push_back( point.
cluster(0).key() );
184 mPointVkey.push_back( point.
cluster(1).key() );
195 eemc=
new TCanvas(TString(
"eemc-")+GetName(),GetTitle(),600,400);
200 hTowers -> Draw(opts);
205 hTowers =
new TH2F(TString(
"hTowers-")+GetName(),GetTitle(),62,-1.,61.,12,0.,12.);
208 for ( Int_t sec=0;sec<kEEmcNumSectors;sec++ )
209 for ( Int_t sub=0;sub<kEEmcNumSubSectors;sub++ )
210 for ( Int_t eta=0;eta<kEEmcNumEtas;eta++ )
213 Float_t x = 5*sec+sub; x+=0.5;
214 Float_t y = eta; y+=0.5;
215 Int_t bin = hTowers->FindBin ( x, y );
217 if ( !mTowerFail[sec][sub][eta] )
218 hTowers->SetBinContent( bin, mTowerEnergy[sec][sub][eta] );
220 failTower(sec,sub,eta, hTowers);
225 if ( sec==11 && sub==4 )
228 bin = hTowers->FindBin ( x, y );
230 if ( !mTowerFail[sec][sub][eta] )
231 hTowers->SetBinContent( bin, mTowerEnergy[sec][sub][eta] );
233 failTower(0,-1,eta,hTowers);
238 if ( sec==0 && sub==0 )
241 bin = hTowers->FindBin ( x, y );
242 if ( !mTowerFail[sec][sub][eta] )
243 hTowers->SetBinContent( bin, mTowerEnergy[sec][sub][eta] );
245 failTower(12,5,eta,hTowers);
251 for ( Float_t x=0.0; x<=60.0; x+=5.0 ) {
252 hTowers->GetListOfFunctions()->Add(
new TLine( x, 0., x, 12.0 ) );
254 hTowers->GetXaxis()->SetRangeUser(0.,59.9);
272 LOG_WARN<<
" Invalid layer passed to DrawLayer(...)"<<endm;
276 TCanvas *mycanvas = 0;
285 const Char_t *cnames[]={
"eemc",
"pre1",
"pre2",
"post"};
286 TH2F *his[]={hTowers,hPre1,hPre2,hPost};
287 TH2F *myhist=his[layer];
288 const Char_t *hnames[]={
"hTowers",
"hPre1",
"hPre2",
"hPost"};
292 mycanvas=
new TCanvas(TString(cnames[layer])+GetName(),GetTitle(),600,400);
294 if ( layer==1 )pre1=mycanvas;
295 if ( layer==2 )pre2=mycanvas;
296 if ( layer==3 )post=mycanvas;
302 myhist -> Draw(opts);
307 const Char_t *titles[]={
"Towers: ",
"Preshower 1: ",
"Preshower 2: ",
"Postshower: "};
310 myhist =
new TH2F(TString(hnames[layer])+GetName(),TString(titles[layer])+GetTitle(),62,-1.,61.,12,0.,12.);
314 for ( Int_t sec=0;sec<kEEmcNumSectors;sec++ )
315 for ( Int_t sub=0;sub<kEEmcNumSubSectors;sub++ )
316 for ( Int_t eta=0;eta<kEEmcNumEtas;eta++ )
319 Float_t x = 5*sec+sub; x+=0.5;
320 Float_t y = eta; y+=0.5;
321 Int_t bin = myhist->FindBin ( x, y );
323 if ( !mPrepostFail[sec][sub][eta][layer-1] )
324 myhist->SetBinContent( bin,1000.* mPrepostEnergy[sec][sub][eta][layer-1] );
326 failTower(sec,sub,eta, myhist);
331 if ( sec==11 && sub==4 )
334 bin = myhist->FindBin ( x, y );
336 if ( !mPrepostFail[sec][sub][eta][layer-1] )
337 myhist->SetBinContent( bin, 1000.* mPrepostEnergy[sec][sub][eta][layer-1] );
339 failTower(0,-1,eta,myhist);
344 if ( sec==0 && sub==0 )
347 bin = myhist->FindBin ( x, y );
348 if ( !mPrepostFail[sec][sub][eta][layer-1] )
349 myhist->SetBinContent( bin, 1000.*mPrepostEnergy[sec][sub][eta][layer-1] );
351 failTower(12,5,eta,myhist);
357 for ( Float_t x=0.0; x<=60.0; x+=5.0 ) {
358 myhist->GetListOfFunctions()->Add(
new TLine( x, 0., x, 12.0 ) );
360 myhist->GetXaxis()->SetRangeUser(0.,59.9);
377 if ( !mPointMarker.size() )
378 for ( UInt_t ii=0;ii<mPointKey.size();ii++ )
381 Float_t x=mPointX[ii];
382 Float_t y=mPointY[ii];
383 TVector3 position(x,y,kEEmcZSMD);
387 if ( !geom->
getTower( position, sec, sub, eta, dphi, deta ) ){
392 Float_t myphi = 0.5 + 5*sec + ((Float_t)sub) + 0.5*dphi;
393 Float_t myeta = 0.5 + ((Float_t)eta) + 0.5*deta;
395 TMarker *m=
new TMarker( myphi, myeta, mPointStyle[ii] );
396 m->SetMarkerColor( mPointColor[ii] );
397 mPointMarker.push_back(m);
399 TLatex *tex=
new TLatex( myphi+0.05, myeta, Form(
"uid=%i vid=%i",mPointUkey[ii],mPointVkey[ii]) );
400 tex->SetTextColor( mPointColor[ii] );
401 towers->GetListOfFunctions()->Add(tex);
405 for ( UInt_t ii=0;ii<mPointMarker.size();ii++ )
407 mPointMarker[ii]->Draw();
421 const Char_t *name_planes[]={
"smdu",
"smdv"};
422 const Char_t *name_uv[]={
"U",
"V"};
425 TCanvas *mycanvas = (plane==0)? smdu : smdv;
428 mycanvas =
new TCanvas(TString(name_planes[plane])+
"-"+GetName(),GetTitle(),600,400);
429 if ( plane==0 ) smdu=mycanvas;
else smdv=mycanvas;
435 if ( hSmds[sector][plane] )
437 hSmds[sector][plane]->Draw(opts);
438 return hSmds[sector][plane];
444 if ( sector+1<10 ) hname+=
"0";
446 hname+=name_uv[plane];
449 TH1F *histo=
new TH1F(hname,TString(GetTitle())+
";index;Nmips",288,0.,288.);
450 hSmds[sector][plane]=histo;
452 for ( Int_t strip=0;strip<kEEmcNumStrips;strip++ )
454 Float_t energy = mStripEnergy[sector][plane][strip];
455 if ( !mStripFail[sector][plane][strip] )
456 histo->SetBinContent( strip+1, energy*mEnergy2Mip );
460 hSmds[sector][plane]->Draw(opts);
462 return hSmds[sector][plane];
471 Bool_t draw_stats =
false;
473 if ( myopts.Contains(
"stats") )
475 myopts.ReplaceAll(
"stats",
"");
480 TH1F *hsmd =
DrawSmd(sector, plane, opts );
482 for ( UInt_t ii=0;ii<mClusterKey.size();ii++ )
484 if ( sector == mClusterSector[ii] &&
485 plane == mClusterPlane[ii] )
493 for ( UInt_t ii=0;ii<mClusterKey.size();ii++ )
495 if ( sector == mClusterSector[ii] &&
496 plane == mClusterPlane[ii] )
499 Int_t key = mClusterKey[ii];
500 Float_t energy = mClusterEnergy[ii];
501 Float_t nmips = energy * mEnergy2Mip;
502 Float_t mean = mClusterMean[ii];
503 Float_t sigma = mClusterSigma[ii];
504 Int_t sector = mClusterSector[ii];
505 Int_t plane = mClusterPlane[ii];
506 Int_t color = mClusterColor[ii];
507 Int_t fill = mClusterFill[ii];
508 TCanvas *c = (plane==0)? smdu : smdv;
511 Int_t imean=(Int_t)mean;
512 Float_t Iright = hSmds[sector][plane]->Integral( imean+6,imean+10 );
513 Float_t Ileft = hSmds[sector][plane]->Integral( imean-10, imean-6);
515 Float_t xpave = mean + 6.0;
516 Float_t ypave = hSmds[sector][plane]->GetBinContent(imean+1);
517 if ( Iright > 0.4 * nmips && Ileft < 0.4 * nmips )
522 TPaveText *text=
new TPaveText( xpave, ypave*0.7, xpave+20, ypave );
523 text->SetFillColor( color );
524 text->SetFillStyle( fill );
525 text->AddText(Form(
"cluster id = %i",key));
526 text->AddText(Form(
"energy = %5.2f MeV",energy*1000.0));
527 text->AddText(Form(
"mean = %5.1f", mean));
528 text->AddText(Form(
"sigma = %5.3f", sigma));
529 if ( mClusterSplit[ii] )
530 text->AddText(Form(
"split cluster"));
533 hsmd->GetListOfFunctions()->Add( text );
551 Int_t plane = mClusterPlane [ icluster ];
553 assert( (plane==0)?smdu:smdv );
555 if ( plane==0 ) smdu->cd();
556 if ( plane==1 ) smdv->cd();
560 if ( mClusterHisto.size() )
562 mClusterHisto[ icluster ]->Draw(opts);
563 return mClusterHisto[icluster];
567 const Char_t *name_uv[]={
"U",
"V"};
568 for ( UInt_t ii=0;ii<mClusterKey.size();ii++ )
571 Int_t sector = mClusterSector[ ii ];
572 Int_t plane = mClusterPlane[ ii ];
573 TString UV=name_uv[plane];
575 LOG_INFO <<
"+ cluster "
576 << ( (sector<9)?
"0":
"" )
579 <<
" key=" << mClusterKey[ii]
580 <<
" col=" << mClusterColor[ii]
581 <<
" fill="<< mClusterFill[ii]
585 if ( sector+1<10 ) hname+=
"0";
587 hname+=name_uv[plane];
589 hname+=mClusterKey[ii];
594 TH1F *histo =
new TH1F(hname,GetTitle(),kEEmcNumStrips,0.,(Float_t)kEEmcNumStrips);
596 for ( UInt_t jj=0;jj<mClusterStrips[ii].size();jj++ )
598 Int_t index=mClusterStrips[ii][jj];
599 Float_t energy = mStripEnergy[ sector ][ plane ][ index ];
600 histo->SetBinContent( index+1, energy*mEnergy2Mip );
603 histo->SetFillColor( mClusterColor[ii] );
604 histo->SetFillStyle( mClusterFill[ii] );
606 mClusterHisto.push_back( histo );
611 mClusterHisto[icluster]->Draw(opts);
613 return mClusterHisto[icluster];
619 void StEEmcDisplay::failTower( Int_t sec, Int_t sub, Int_t eta, TH2F *histo )
621 Float_t x1=5*sec+sub;
625 TLine *l1=
new TLine(x1,y1,x2,y2);l1->SetLineColor(2);
626 TLine *l2=
new TLine(x2,y1,x1,y2);l2->SetLineColor(2);
627 histo->GetListOfFunctions()->Add(l1);
628 histo->GetListOfFunctions()->Add(l2);
636 LOG_WARN<<
" sumEnergy not yet implemented for SMD'ss"<<endm;
641 for ( Int_t sec=0;sec<12;sec++ )
642 for ( Int_t sub=0;sub<5;sub++ )
643 for ( Int_t eta=0;eta<12;eta++ )
646 sum += mTowerEnergy[sec][sub][eta];
649 sum += mPrepostEnergy[sec][sub][eta][layer-1];
653 if ( layer > 0 ) sum *= 1000.0;
662 LOG_WARN<<
" sumEnergy not yet implemented for SMD'ss"<<endm;
667 for ( Int_t sec=0;sec<12;sec++ )
668 for ( Int_t sub=0;sub<5;sub++ )
669 for ( Int_t eta=0;eta<12;eta++ )
672 if ( mTowerEnergy[sec][sub][eta] > threshold ) sum++;
675 if ( mPrepostEnergy[sec][sub][eta][layer-1] *1000.0 > threshold ) sum++;
void clear()
clears all storage arrays, deletes all canvases and histograms
void cluster(const StEEmcSmdCluster &c, Int_t plane)
Add an smd cluster to this point.
TH1F * DrawClusters(Int_t sector, Int_t plane, Option_t *opts="")
Base class for representing EEMC points.
void stat(unsigned s)
Set a status bit for this element.
void layer(Int_t l)
Sets the layer, [0-4]=[TPQR].
void energy(Float_t e, Int_t layer=0)
Set the energy of this point.
TH2F * DrawPoints(Option_t *opts="box")
Float_t sumEnergy(Int_t layer)
Int_t etabin() const
Returns the etabin of this tower, pre- or postshower element.
void fail(unsigned f)
Set a fail bit for this element.
Int_t subsector() const
Returns subsector of this tower, pre- or postshower element.
void index(Int_t i)
Sets the index for this SMD strip, 0..287.
Base class for representing tower, preshower and postshower elements.
void add(StEEmcTower tower)
Add a tower to the display.
Int_t sector() const
Returns sector of this tower, pre- or postshower element.
TH2F * DrawTowers(Option_t *opts="box,text")
Int_t key()
Return a unique key assigned by the cluster maker.
TH2F * DrawLayer(Int_t layer, Option_t *opts="box,text")
A base class for representing clusters of EEMC smd strips.
TH1F * DrawCluster(Int_t cluster, Option_t *opts="")
Int_t phibin() const
Returns the phibin of this tower.
TH1F * DrawSmd(Int_t sector, Int_t plane, Option_t *opts="")
void position(const TVector3 &p)
Set the position of this point at the SMD plane.
void plane(Int_t p)
Sets the plane for this SMD strip, 0=U, 1=V.
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
void sector(Int_t s)
Sets the sector for this SMD strip.
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
StEEmcStrip & strip(Int_t s)
Returns the specified smd strip w/in the cluster.
Base class for describing an endcap SMD strip.
Int_t hitMultiplicity(Int_t layer, Float_t threshold=0.0)
Returns the number of hit elements in the spcified layer above threshold.