StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StClusterDisplay.cxx
1 #include "StClusterDisplay.h"
2 #include "StEventTypes.h"
3 #include "StEvent.h"
4 #include "StTrack.h"
5 #include <math.h>
6 #include "TFile.h"
7 #include "TROOT.h"
8 #include "StEmcUtil/geometry/StEmcGeom.h"
9 #include "StEmcUtil/others/emcDetectorName.h"
10 
11 ClassImp(StClusterDisplay)
12 
13 //_____________________________________________________________________________
14 StClusterDisplay::StClusterDisplay(const char *name):StMaker(name)
15 {}
16 //_____________________________________________________________________________
17 StClusterDisplay::~StClusterDisplay()
18 {}
19 //_____________________________________________________________________________
20 Int_t StClusterDisplay::Init()
21 {
22  TString name,title;
23  for(Int_t i = 0; i<MAXDETBARREL; i++)
24  {
25  mGeo[i]=StEmcGeom::getEmcGeom(detname[i].Data());
26  mCanvas[i] = 0;
27  mTh[i] = 0.2;
28 
29  name = detname[i];
30  name += "_NClusters";
31  title = "Number of clusters for detector ";
32  title+= detname[i];
33  mHist1D[0][i] = new TH1F(name.Data(),title.Data(),500,0,500);
34 
35  name = detname[i];
36  name += "_NHits";
37  title = "Number of hits/cluster for detector ";
38  title+= detname[i];
39  mHist1D[1][i] = new TH1F(name.Data(),title.Data(),20,0,20);
40 
41  name = detname[i];
42  name += "_Energy";
43  title = "Cluster energy for detector ";
44  title+= detname[i];
45  mHist1D[2][i] = new TH1F(name.Data(),title.Data(),500,0,50);
46 
47  name = detname[i];
48  name += "_RMSEta";
49  title = "Cluster RMS/eta for detector ";
50  title+= detname[i];
51  mHist1D[3][i] = new TH1F(name.Data(),title.Data(),20,0,0.1);
52 
53  name = detname[i];
54  name += "_RMSPhi";
55  title = "Cluster RMS/phi for detector ";
56  title+= detname[i];
57  mHist1D[4][i] = new TH1F(name.Data(),title.Data(),20,0,0.1);
58 
59  name = detname[i];
60  name += "_EtaPhi";
61  title = "Cluster (eta,phi) for detector ";
62  title+= detname[i];
63  mHist2D[0][i] = new TH2F(name.Data(),title.Data(),40,-1,1,120,-3.1415,3.1415);
64 
65 
66  Int_t nEta=mGeo[i]->NEta();
67  Int_t nSub=mGeo[i]->NSub();
68 
69  TArrayF EtaB(nEta+1,mGeo[i]->EtaB());
70  TArrayF PhiB(nSub+1,mGeo[i]->PhiB());
71 
72  TArrayF EtaBins(2*nEta+2);
73  for(Int_t j=0;j<2*nEta+2;j++)
74  {
75  if (j<nEta+1)
76  EtaBins[j]=-EtaB[nEta-j];
77  else
78  EtaBins[j]=EtaB[j-nEta-1];
79  }
80 
81  TArrayF PhiBins1(60*(nSub+1));
82  TArrayF PhiBins(60*(nSub+1));
83  Int_t j=0;
84  for(Int_t m=1;m<=60;m++)
85  for(Int_t s=1;s<=nSub+1;s++)
86  {
87  Float_t center;
88  mGeo[i]->getPhiModule(m,center);
89  PhiBins1[j]=center+PhiB[s-1];
90  j++;
91  }
92 
93  Bool_t again=kTRUE;
94  j=0;
95  do
96  {
97  again=kFALSE;
98  Float_t phitmp=6.4;
99  Int_t ktmp=-1;
100  for(Int_t k=0;k<60*(nSub+1);k++)
101  {
102  if(PhiBins1[k]<phitmp)
103  {
104  phitmp=PhiBins1[k];
105  ktmp=k;
106  }
107  }
108  if(ktmp!=-1)
109  {
110  PhiBins[j]=phitmp;
111  again=kTRUE;
112  PhiBins1[ktmp]=999;
113  j++;
114  }
115  }
116  while(again);
117 
118  name = detname[i];
119  name += "_HitDisplay";
120  title = "Hits distribution for detector ";
121  title+= detname[i];
122  mHist2D[1][i] = new TH2F(name.Data(),title.Data(),2*nEta+2-1,EtaBins.GetArray(),60*(nSub+1)-1,PhiBins.GetArray());
123 
124  name = detname[i];
125  name += "_ClusterDisplay";
126  title = "Cluster distribution for detector ";
127  title+= detname[i];
128  Int_t BF=10;
129  mHist2D[2][i] = new TH2F(name.Data(),title.Data(),BF*2*nEta,-1,1,BF*60*nSub,-3.1415,3.1415);
130  }
131  return StMaker::Init();
132 }
133 //_____________________________________________________________________________
135 {
136  StEvent *ev = (StEvent*)GetInputDS("StEvent");
137  if(!ev)
138  return kStOk;
139 
140  StEmcCollection *emc = ev->emcCollection();
141  if(!emc)
142  return kStOk;
143  for(Int_t i = 0;i<MAXDETBARREL;i++)
144  {
145  mHist2D[1][i]->Reset();
146  mHist2D[2][i]->Reset();
147  StDetectorId id = static_cast<StDetectorId>(i+kBarrelEmcTowerId);
148  StEmcDetector* detector = emc->detector(id);
149  if(detector)
150  {
151  for(UInt_t j=1;j<121;j++)
152  {
153  StEmcModule* module = detector->module(j);
154  if(module)
155  {
156  StSPtrVecEmcRawHit& rawHit=module->hits();
157 
158  for(Int_t k=0;k<(Int_t)rawHit.size();k++)
159  {
160  Float_t eta,phi;
161  Int_t m=rawHit[k]->module();
162  Int_t e=rawHit[k]->eta();
163  Int_t s=abs(rawHit[k]->sub());
164  Float_t energy = rawHit[k]->energy();
165 
166  mGeo[i]->getEta(m,e,eta);
167  mGeo[i]->getPhi(m,s,phi);
168  if(energy>mTh[i])
169  mHist2D[1][i]->Fill(eta,phi,energy);
170  }
171  }
172  }
173  StEmcClusterCollection* coll = detector->cluster();
174  if(coll)
175  {
176  StSPtrVecEmcCluster& clusters = coll->clusters();
177  Int_t n = clusters.size();
178  mHist1D[0][i]->Fill(n);
179  for(Int_t j = 0;j<n;j++)
180  {
181  StEmcCluster *c =clusters[j];
182  if(c)
183  {
184  mHist1D[1][i]->Fill(c->nHits());
185  mHist1D[2][i]->Fill(c->energy());
186  mHist1D[3][i]->Fill(c->sigmaEta());
187  mHist1D[4][i]->Fill(c->sigmaPhi());
188  mHist2D[0][i]->Fill(c->eta(),c->phi());
189  mHist2D[2][i]->Fill(c->eta(),c->phi());
190  }
191  }
192  }
193  }
194  if(mDraw)
195  {
196  TString CN = "Display_";
197  CN+=detname[i];
198  if(!gROOT->FindObject(CN.Data()))
199  mCanvas[i] = 0;
200  if(!mCanvas[i])
201  mCanvas[i] = new TCanvas(CN.Data(),CN.Data(),400,600);
202  mCanvas[i]->cd();
203  mHist2D[1][i]->Draw("colz");
204  mHist2D[1][i]->GetXaxis()->UnZoom();
205  mHist2D[1][i]->GetYaxis()->UnZoom();
206 
207  mHist2D[2][i]->SetMarkerStyle(24);
208  mHist2D[2][i]->SetMarkerColor(2);
209  mHist2D[2][i]->Draw("sameP");
210  }
211  }
212 
213  return StMaker::Make();
214 }
215 //_____________________________________________________________________________
217 {
218  SaveHist();
219  return kStOk;
220 }
221 //_____________________________________________________________________________
222 Int_t StClusterDisplay::SaveHist()
223 {
224  return kStOk;
225 }
virtual Int_t Make()
Definition: StMaker.cxx:898
virtual Int_t Make()
virtual Int_t Finish()
Definition: Stypes.h:41