23 #include "StFmsEventDisplay.h"
25 #include "StMessMgr.h"
27 #include "StMuDSTMaker/COMMON/StMuTypes.hh"
29 #include "StThreeVectorF.hh"
30 #include "StFmsDbMaker/StFmsDbMaker.h"
32 #include "StEventTypes.h"
33 #include "StEvent/StEvent.h"
34 #include "StEvent/StFmsCollection.h"
35 #include "StEvent/StFmsHit.h"
36 #include "StEvent/StFmsPoint.h"
37 #include "StEvent/StFmsPointPair.h"
39 #include "TApplication.h"
55 StFmsEventDisplay::StFmsEventDisplay(
const Char_t* name):
56 StMaker(name),mFilename((char *)
"fmsEventDisplay.pdf"){}
58 StFmsEventDisplay::~StFmsEventDisplay(){}
60 Int_t StFmsEventDisplay::Init(){
61 mFmsDbMaker=
static_cast<StFmsDbMaker*
>(GetMaker(
"fmsDb"));
63 LOG_ERROR <<
"StFmsEventDisplay::InitRun Failed to get StFmsDbMaker" << endm;
67 mApplication =
new TApplication(
"EvtDsp",0,0);
68 mCanvas=
new TCanvas(
"FMSEventtDisplay",
"FMSEventtDisplay",10,10,900,900);
69 gStyle->SetOptStat(0);
74 mApplication->Terminate();
78 void setColor(
int id,
float v){
79 TColor *color = gROOT->GetColor(
id);
80 if(!color) color=
new TColor(
id,0,0,0);
81 float r=0.0,g=0.0,b=0.0;
95 void scale(
float x=100.0,
float dx=5.0,
float ymin=-100.0,
float ymax=100.0,
int ny=40){
96 for(
int i=0; i<ny; i++){
97 setColor(2000+i,
float(i+0.5)/
float(ny));
98 float dy=(ymax-ymin)/
float(ny);
99 TBox* b=
new TBox(x,ymin+dy*i,x+dx,ymin+dy*(i+1));
100 b->SetFillColor(2000+i);
109 if(mudst->
event()->triggerData()){
110 bunch = mudst->
event()->triggerData()->bunchId7Bit();
111 LOG_INFO << Form(
"Bunch=%3d from Mudst\n",bunch) << endm;
116 if(!event) {LOG_ERROR <<
"StFmsEventDisplay::Make did not find StEvent"<<endm;
return kStErr;}
117 mFmsColl =
event->fmsCollection();
118 if(!mFmsColl) {LOG_ERROR <<
"StFmsEventDisplay::Make did not find StEvent->FmsCollection"<<endm;
return kStErr;}
120 if(event->triggerData()) {
121 bunch =
event->triggerData()->bunchId7Bit();
122 LOG_INFO << Form(
"Bunch=%3d from StEvent\n",bunch) <<endm;
126 StSPtrVecFmsHit& hits = mFmsColl->hits();
127 StSPtrVecFmsCluster& clusters = mFmsColl->clusters();
131 int nh=mFmsColl->numberOfHits();
132 int nc=mFmsColl->numberOfClusters();
133 int np=mFmsColl->numberOfPoints();
137 if(mNAccepted < mMaxEvents){
139 if(mFilter==1 && np<2) {mNEvents++;
return kStOK;}
140 if(mFilter==2 && (bunch<30 || bunch>=40)) {mNEvents++;
return kStOK;}
143 sprintf(cc,
"FMSEventDisplayEvt=%d",mNEvents);
146 TH2F* frame=
new TH2F(cc,cc,1,-100.0,105.0,1,-100.0,100.0);
149 TText* t1=
new TText(106, 100.0,
"100GeV"); t1->SetTextSize(0.03); t1->Draw();
150 TText* t2=
new TText(106, 33.3,
"10GeV"); t2->SetTextSize(0.03); t2->Draw();
151 TText* t3=
new TText(106,-33.3,
"1GeV"); t3->SetTextSize(0.03); t3->Draw();
152 TText* t4=
new TText(106,-100.0,
"0.1GeV"); t4->SetTextSize(0.03); t4->Draw();
154 for(
int det=kFmsNorthLargeDetId; det<=kFmsSouthSmallDetId; det++){
155 for(
int ch=0; ch<mFmsDbMaker->
maxChannel(det); ch++){
156 if(mFmsDbMaker->getGain(det,ch)>0.0){
160 TBox* cell=
new TBox(xyz.x()-wx/2.0, xyz.y()-wy/2.0, xyz.x()+wx/2.0, xyz.y()+wy/2.0);
161 cell->SetFillColor(0);
162 cell->SetLineColor(1); cell->SetLineWidth(1);
169 for(
int i=0; i<nh; i++){
171 int det=hit->detectorId();
172 if(det>=kFmsNorthLargeDetId && det<=kFmsSouthSmallDetId){
177 TBox* cell=
new TBox(xyz.x()-wx/2.0, xyz.y()-wy/2.0, xyz.x()+wx/2.0, xyz.y()+wy/2.0);
179 float ladc=log10(hit->energy());
180 if(ladc>2.0) ladc=2.0;
181 if(ladc<-1.0) ladc=-1.0;
182 setColor(color,(ladc+1.0)/3.0);
183 cell->SetFillColor(color);
188 for(
int i=0; i<nc; i++){
190 float nt=float(clu->nTowers());
191 for(
int j=0; j<nt; j++){
193 int det=hit->detectorId();
197 TBox* cell=
new TBox(xyz.x()-wx/2.0, xyz.y()-wy/2.0, xyz.x()+wx/2.0, xyz.y()+wy/2.0);
198 cell->SetFillStyle(0);
199 cell->SetLineColor(2+i);
200 cell->SetLineWidth(2);
203 int nphoton=clu->nPhotons();
204 for(
int j=0; j<nphoton; j++){
206 TMarker* m=
new TMarker(point->XYZ().x(),point->XYZ().y(),29);
207 m->SetMarkerColor(1);
214 TString f(mFilename);
215 if(f.Contains(
".pdf")){
216 if(mNEvents==0) f.Append(
"(");
217 else if(mNEvents==mMaxEvents-1) f.Append(
")");
218 LOG_INFO <<
"Saving " << f.Data() << endm;
219 mCanvas->Print(f.Data(),
"pdf");
220 }
else if(f.Contains(
".png")){
221 f.ReplaceAll(
"eventDisplay.png",Form(
"%d.eventDisplay.png",mNEvents));
222 LOG_INFO <<
"Saving " << f.Data() << endm;
223 mCanvas->SaveAs(f.Data());
Float_t getXWidth(Int_t detectorId)
get the offset of the detector
StThreeVectorF getStarXYZ(Int_t detectorId, Float_t FmsX, Float_t FmsY)
get the Y width of the cell
UShort_t maxChannel(Int_t detectorId) const
number of column
Float_t getYWidth(Int_t detectorId)
get the X width of the cell
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)