55 #include "StFcsEventDisplay.h"
58 #include "StMessMgr.h"
60 #include "StEventTypes.h"
61 #include "StMuDSTMaker/COMMON/StMuTypes.hh"
63 #include "StThreeVectorF.hh"
64 #include "StFcsDbMaker/StFcsDb.h"
65 #include "StRoot/StEpdUtil/StEpdGeom.h"
68 #include "StStgcDbMaker/StStgcDbMaker.h"
88 StMaker(name),mFilename((
char *)"fcsEventDisplay.pdf"){}
90 StFcsEventDisplay::~StFcsEventDisplay(){}
92 int StFcsEventDisplay::Init(){
93 mFcsDb=
static_cast<StFcsDb*
>(GetDataSet(
"fcsDb"));
95 LOG_ERROR <<
"StFcsEventDisplay::InitRun Failed to get StFcsDb" << endm;
100 mStgcDbMaker=
static_cast<StStgcDbMaker*
>(GetMaker(
"stgcDb"));
102 LOG_WARN <<
"StFcsEventDisplay::InitRun Failed to get StStgcDbMaker" << endm;
108 mCanvas=
new TCanvas(
"FCSEventtDisplay",
"FCSEventtDisplay",10,10,2000,2000);
109 gStyle->SetOptStat(0);
122 void setColor(
int id,
float v,
float alpha=1.0){
123 static const float PI=3.141592654;
124 TColor *color = gROOT->GetColor(
id);
125 if(!color) color=
new TColor(
id,0,0,0);
126 float r=0.0,g=0.0,b=0.0;
130 r=sin((v-0.5)/0.5*PI/2.0);
131 g=cos((v-0.5)/0.5*PI/2.0);
136 color->SetRGB(r,g,b);
137 color->SetAlpha(alpha);
141 void scale(
float x=160.0,
float dx=5.0,
float ymin=-210.0,
float ymax=210.0,
int ny=40){
142 for(
int i=0; i<ny; i++){
143 setColor(5000+i,
float(i+0.5)/
float(ny));
144 float dy=(ymax-ymin)/
float(ny);
145 TBox* b=
new TBox(x,ymin+dy*i,x+dx,ymin+dy*(i+1));
146 b->SetFillColor(5000+i);
153 if(!event) {LOG_ERROR <<
"StFcsEventDisplay::Make did not find StEvent"<<endm;
return kStErr;}
154 mFcsColl =
event->fcsCollection();
155 if(!mFcsColl) {LOG_ERROR <<
"StFcsEventDisplay::Make did not find StEvent->StFcsCollection"<<endm;
return kStErr;}
158 mStgcColl =
event->stgcCollection();
159 if(!mStgcColl) {LOG_ERROR <<
"StFcsEventDisplay::Make did not find StEvent->StStgcCollection"<<endm;}
162 if(mNAccepted < mMaxEvents){
165 mFcsColl->numberOfHits(0)+ mFcsColl->numberOfHits(1)+ mFcsColl->numberOfHits(2)+ mFcsColl->numberOfHits(3)==0)
return kStOK;
170 sprintf(cc,
"FCSEventDisplayEvt=%d",mNEvents);
178 float yoff[kFcsNDet]={100.0,100.0,-100.0,-100.0,100.0,100.0};
179 float xoff[kFcsNDet]={ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
199 frame=
new TH2F(cc,cc,1,xmin,xmax,1,ymin,ymax);
203 scale(xmax,5,ymin,ymax);
204 if(mMaxE==2 && mMinE==-1){
205 TText* t1=
new TText(xmax+5, ymax,
"100GeV"); t1->SetTextSize(0.02); t1->Draw();
206 TText* t2=
new TText(xmax+5, ymin+dy*2/3.0,
"10GeV" ); t2->SetTextSize(0.02); t2->Draw();
207 TText* t3=
new TText(xmax+5, ymin+dy/3.0,
"1GeV" ); t3->SetTextSize(0.02); t3->Draw();
208 TText* t4=
new TText(xmax+5, ymin,
"0.1GeV"); t4->SetTextSize(0.02); t4->Draw();
209 }
else if(mMaxE==1 && mMinE==-3){
210 TText* t1=
new TText(xmax+5, ymax,
"1GeV"); t1->SetTextSize(0.02); t1->Draw();
211 TText* t2=
new TText(xmax+5, ymin+dy*2/3.0,
"100MeV" ); t2->SetTextSize(0.02); t2->Draw();
212 TText* t3=
new TText(xmax+5, ymin+dy/3.0,
"10MeV" ); t3->SetTextSize(0.02); t3->Draw();
213 TText* t4=
new TText(xmax+5, ymin,
"1MeV"); t4->SetTextSize(0.02); t4->Draw();
215 TText* t1=
new TText(xmax+5, ymax, Form(
"1E%2.0f GeV",mMaxE)); t1->SetTextSize(0.02); t1->Draw();
216 TText* t4=
new TText(xmax+5, ymin, Form(
"1E%2.0f GeV",mMinE)); t4->SetTextSize(0.02); t4->Draw();
220 for(
int det=0; det<kFcsNDet; det++){
221 StSPtrVecFcsHit& hits = mFcsColl->hits(det);
222 StSPtrVecFcsCluster& clusters = mFcsColl->clusters(det);
223 StSPtrVecFcsPoint& points = mFcsColl->points(det);
224 int nh=mFcsColl->numberOfHits(det);
225 int nc=mFcsColl->numberOfClusters(det);
226 int np=mFcsColl->numberOfPoints(det);
227 if(mDebug>0) LOG_INFO << Form(
"StFcsEventDisplay Det=%1d nhit=%4d nclu=%3d",det,nh,nc) << endm;
230 if(det<=kFcsHcalSouthDetId){
231 for(
int id=0;
id<mFcsDb->
maxId(det);
id++){
235 TBox* cell=
new TBox(xyz.x()-wx/2.0+xoff[det], xyz.y()+yoff[det]-wy/2.0,
236 xyz.x()+wx/2.0+xoff[det], xyz.y()+yoff[det]+wy/2.0);
237 cell->SetFillStyle(0);
239 cell->SetLineColor(1); cell->SetLineWidth(1);
245 for(
int i=0; i<nh; i++){
247 if(det<=kFcsHcalSouthDetId){
251 TBox* cell=
new TBox(xyz.x()-wx/2.0+xoff[det], xyz.y()+yoff[det]-wy/2.0,
252 xyz.x()+wx/2.0+xoff[det], xyz.y()+yoff[det]+wy/2.0);
253 float e=hit->energy();
256 if(logE>mMaxE) logE=mMaxE;
257 if(logE<mMinE) logE=mMinE;
258 setColor(color,(logE - mMinE)/(mMaxE-mMinE));
259 cell->SetFillColor(color);
262 if(mRun19 || det>=kFcsHcalNorthDetId){
263 TText* tx=
new TText(xyz.x()+xoff[det],xyz.y()+yoff[det]-wy/4.0,Form(
"%4.2f",e));
264 tx->SetTextSize(eTxSize); tx->SetTextAlign(22);
267 }
else if(det==kFcsPresNorthDetId || det==kFcsPresSouthDetId){
269 double zfcs=710.0+13.90+15.0;
274 mEpdgeo->GetCorners(100*pp+tt,&n,x,y);
275 for(
int i=0; i<n; i++){
278 TLine *l=
new TLine(zr*x[i]+xoff[det],zr*y[i]+yoff[det],
279 zr*x[j]+xoff[det],zr*y[j]+yoff[det]);
280 l->SetLineColor(kRed);
285 if(mDebug>0) LOG_INFO << Form(
"StFcsEventDisplay Det=%1d nhit=%4d i=%3d color=%4d",det,nh,i,color) << endm;
289 for(
int i=0; i<nc; i++){
291 float nt=float(clu->nTowers());
292 for(
int j=0; j<nt; j++){
297 TBox* cell=
new TBox(xyz.x()-wx/2.0+xoff[det], xyz.y()+yoff[det]-wy/2.0,
298 xyz.x()+wx/2.0+xoff[det], xyz.y()+yoff[det]+wy/2.0);
299 cell->SetFillStyle(0);
300 cell->SetLineColor(2+i);
301 cell->SetLineWidth(2);
304 if(mRun19 || det>=kFcsHcalNorthDetId){
305 tx=
new TText(xyz.x()+xoff[det],xyz.y()+yoff[det]+wy/4.0,Form(
"%d",i));
307 tx=
new TText(xyz.x()+xoff[det],xyz.y()+yoff[det],Form(
"%d",i));
309 tx->SetTextSize(cTxSize); tx->SetTextAlign(22);
313 TMarker* m=
new TMarker(cxyz.x()+xoff[det],cxyz.y()+yoff[det],26);
314 m->SetMarkerColor(kMagenta);
318 tx=
new TText(cxyz.x()+xoff[det],cxyz.y()+yoff[det],
319 Form(
" %d/%3.1f/%3.1f/%3.0f",
320 clu->nTowers(),clu->sigmaMax(),clu->sigmaMin(),
321 clu->theta()*180/3.141592654));
322 tx->SetTextSize(cTxSize);
323 tx->SetTextColor(kBlue);
325 int nphoton=clu->nPoints();
326 for(
int j=0; j<nphoton; j++){
329 TMarker* m=
new TMarker(xyz.x()+xoff[det],xyz.y()+yoff[det],29);
331 m->SetMarkerColor(kRed);
340 for(
int det=0; det<kStgcNDet; det++){
341 StSPtrVecFtsStgcHit& hits = mStgcColl->hits(det);
342 int ns=mStgcColl->numberOfHits(det);
343 if(mDebug>0) LOG_INFO << Form(
"StFcsEventDisplay STGC det=%1d nhit=%4d",det,ns) << endm;
344 for(
int i=0; i<ns; i++){
345 StFtsStgcHit*
hit=hits[i];
346 unsigned short fee = hit->fee();
347 unsigned short altro= hit->altro();
348 unsigned short ch = hit->ch();
349 unsigned int id = mStgcDbMaker->toId(fee,altro,ch);
350 float x,y,dx,dy,z,dz;
351 mStgcDbMaker->globalPosition(
id,x,y,dx,dy,z,dz);
352 TBox* cell=
new TBox(x-dx/2+stgcOffX, y-dy/2+stgcOffY,
353 x+dx/2+stgcOffX, y+dy/2+stgcOffY);
354 cell->SetFillStyle(0);
355 cell->SetLineColor(kRed);
356 cell->SetLineWidth(1);
365 TString f(mFilename);
366 if(f.Contains(
".pdf")){
367 if(mNAccepted==1) f.Append(
"(");
368 else if(mNAccepted==mMaxEvents) f.Append(
")");
369 LOG_INFO <<
"Saving " << f.Data() << endm;
370 mCanvas->Print(f.Data(),
"pdf");
371 }
else if(f.Contains(
".png")){
372 f.ReplaceAll(
"eventDisplay.png",Form(
"%d.eventDisplay.png",mNEvents));
373 LOG_INFO <<
"Saving " << f.Data() << endm;
374 mCanvas->SaveAs(f.Data());
StThreeVectorD getStarXYZfromColumnRow(int det, float col, float row, float FcsZ=-1.0) const
get the STAR frame cooridnates from other way
float getXWidth(int det) const
get the angle of the detector
StThreeVectorD getStarXYZ(int det, float FcsX, float FcsY, float FcsZ=-1.0, float zVertex=0.0) const
get the STAR frame cooridnates from local XYZ [cm]
void getEPDfromId(int det, int id, int &pp, int &tt)
Get FCS's EPD map foom EPD mapping.
int maxId(int det) const
number of column
float getYWidth(int det) const
get the X width of the cell