1 #include "eemcTimingScanPlot.h"
11 #include "TGraphErrors.h"
12 #include "TMultiGraph.h"
26 #include "StEEmcUtil/EEfeeRaw/EEdims.h"
31 eemcTimingScanPlot::eemcTimingScanPlot() {
35 mNormalizePreshower=
false;
45 TGraph *graphs[MaxMapmtCrates][12];
46 TString tmpstr,runnumberstring,tmpstr2;
47 const Int_t MxMapmtFeeCh= (MaxMapmtCrates* MaxMapmtCrateCh / 16) + 1;
50 Int_t myCrateIds[MaxMapmtCrates][12];
51 Int_t myChannelIds[MaxMapmtCrates][12];
54 Float_t channelIntegrals[MxMapmtFeeCh];
55 Float_t channelErrors[MxMapmtFeeCh];
56 Int_t channelIds[MxMapmtFeeCh];
57 Int_t crateIds[MxMapmtFeeCh];
65 std::vector<std::vector<std::vector<Float_t> > > allRunsVector;
66 std::vector<std::vector<Float_t> > channelIntegralVector;
67 std::vector<Float_t> tmpvector;
68 std::vector<Float_t> timingDelay;
70 std::vector<std::vector<std::vector<Int_t> > > allRunsCrateIds;
71 std::vector<std::vector<std::vector<Int_t> > > allRunsChannelIds;
72 std::vector<std::vector<Int_t> > crateIdsVector;
73 std::vector<std::vector<Int_t> > channelIdsVector;
74 std::vector<Int_t> tmpCrateIds;
75 std::vector<Int_t> tmpChannelIds;
79 if (!directory)
return 0;
84 if ((dir = gSystem->OpenDirectory(directory.Data())) != NULL) {
91 const Char_t *dirEntryc;
92 while ((dirEntryc = gSystem->GetDirEntry(dir)) != NULL) {
95 channelIntegralVector.clear();
96 crateIdsVector.clear();
97 channelIdsVector.clear();
101 if(!dirEntry.Contains(
".root"))
continue;
102 tmpstr2 = directory +
"/" + dirEntry;
105 TFile *tf =
new TFile(tmpstr2.Data());
108 if (tf && tf->IsOpen()) {
111 flavor = dirEntry(4,5);
115 TTree* ttree =
dynamic_cast<TTree*
>(tf->Get(
"ints"));
116 ttree->SetBranchAddress(
"chanint",channelIntegrals);
117 ttree->SetBranchAddress(
"chanerr",channelErrors);
118 ttree->SetBranchAddress(
"delay",&tmpfloat);
119 ttree->SetBranchAddress(
"crateIds",crateIds);
120 ttree->SetBranchAddress(
"channelIds",channelIds);
126 for(
int i=0; i<MaxMapmtCrates; i++) {
131 tmpChannelIds.clear();
136 for(
int j=0; j<12; j++) {
137 tmpvector.push_back(channelIntegrals[i*12 + j]);
138 tmpCrateIds.push_back(crateIds[i*12 + j]);
139 tmpChannelIds.push_back(channelIds[i*12 + j]);
141 channelIntegralVector.push_back(tmpvector);
142 crateIdsVector.push_back(tmpCrateIds);
143 channelIdsVector.push_back(tmpChannelIds);
147 timingDelay.push_back(tmpfloat);
155 allRunsVector.push_back(channelIntegralVector);
156 allRunsCrateIds.push_back(crateIdsVector);
157 allRunsChannelIds.push_back(channelIdsVector);
166 Int_t tmpint, sector;
167 for(
int icr=0;icr<MaxMapmtCrates;icr++) {
190 if ( flavor.Contains(
"tower") ) {
196 sector=icr/4-1;
if ( sector==-1 ) sector = 11;
199 if ( tmpint<4 ) { tit+=
"S"; tit += tmpint; }
208 for(
int ich=0;ich<12;ich++) {
209 TGraph* gr=
new TGraph(timingDelay.size());
210 gr->SetMarkerStyle(20+ich%7);
212 gr->SetMarkerColor(icol);
213 gr->SetLineColor(icol);
214 if(ich==0)gr->SetName(tit);
215 if(ich==0)gr->SetTitle(tit+
"; delay(ns)");
216 graphs[icr][ich]=(TGraph*)gr;
224 Int_t numberofPoints = timingDelay.size();
225 Float_t maxima[MaxMapmtCrates];
226 Float_t maxCrateChan[MaxMapmtCrates][12];
227 for(
int icr=0;icr<MaxMapmtCrates;icr++) {
229 for ( Int_t jch=0; jch<12; jch++ ) maxCrateChan[icr][jch]=0.;
234 for(Int_t i=0; i<numberofPoints; i++) {
236 for(
int icr=0;icr<MaxMapmtCrates;icr++) {
238 for(
int ich=0; ich<12; ich++) {
241 if (allRunsVector[i][icr][ich] > maxima[icr]) {
242 maxima[icr] = allRunsVector[i][icr][ich];
244 if (allRunsVector[i][icr][ich] > maxCrateChan[icr][ich] ){
245 maxCrateChan[icr][ich] = allRunsVector[i][icr][ich];
256 for(Int_t i=0; i<numberofPoints; i++) {
258 for(
int icr=0;icr<MaxMapmtCrates;icr++) {
260 for(
int ich=0; ich<12; ich++) {
264 if ( mNormalize && maxCrateChan[icr][ich] != 0. ) scale = maxima[icr]/maxCrateChan[icr][ich];
265 TString myName=graphs[icr][ich]->GetName();
266 if ( myName.Contains(
"P") && !mNormalizePreshower ) scale = 1.;
267 if ( allRunsVector[i][icr][ich] > 0. || !mSuppressZeros )
268 graphs[icr][ich]->SetPoint(i,timingDelay[i],scale*allRunsVector[i][icr][ich]);
269 myCrateIds[icr][ich] = allRunsCrateIds[i][icr][ich];
270 myChannelIds[icr][ich] = allRunsChannelIds[i][icr][ich]; }
277 for ( Int_t i = 0; i < MaxMapmtCrates; i++ ) {
278 for ( Int_t j = 0; j < 12; j++ ) {
279 graphs[i][j]->Sort();
293 Int_t maxpg= (flavor.Contains(
"tower"))?1:4;
294 Int_t maxch= (flavor.Contains(
"tower"))?8:12;
300 for(
int i=0; i<maxpg; i++) {
306 TString cname=
"canvas"; cname += i;
307 TCanvas* c =
new TCanvas(cname,
"Crate channel plots",0,0,800,600);
309 for(
int pp=0; pp<4; pp++) {
310 for(
int qq=0; qq<3; qq++) {
314 smallpad[pp*3+qq] =
new TPad(tmpstr.Data(),tmpstr.Data(), 0.33*qq, 0.25*pp, 0.33*(qq+1), 0.25*(pp+1));
315 smallpad[pp*3+qq]->Draw();
323 for(
int icpp=0; icpp<12 ; icpp++) {
325 smallpad[icpp]->cd();
326 smallpad[icpp]->Clear();
330 TMultiGraph* tmg =
new TMultiGraph(graphs[i*12 + icpp][0]->GetName(),graphs[i*12 + icpp][0]->GetTitle());
332 for(
int pcc=0; pcc<maxch ; pcc++) {
333 tmg->Add(graphs[i*12 + icpp][pcc]);
336 tmg->SetMaximum(maxima[i*12 + icpp] * 1.1);
337 tmg->SetMinimum(0.0);
339 Float_t minX=mAxisMin;
340 Float_t maxX=(mLegend)?mAxisMax*1.25:mAxisMax;
342 Float_t maxY=1.1*maxima[i*12 + icpp];
345 TH1F *htmp =
new TH1F(graphs[i*12 + icpp][0]->GetName(),graphs[i*12 + icpp][0]->GetTitle(),110,minX,maxX);
346 htmp->SetMaximum(maxY);
347 htmp->SetMinimum(minY);
353 if ( !mLegend )
continue;
354 TString bxstr =
"crate "; bxstr += myCrateIds[i*12 + icpp][1];
355 TLegend *legend=
new TLegend( 0.77 * maxX, 0.10 * maxY, 0.98 * maxX, 0.98 * maxY, bxstr,
"br" );
356 legend->SetFillColor(33);
357 for(
int pcc=0; pcc<maxch ; pcc++) {
358 TString chstr = bxstr;
360 chstr += myChannelIds[i*12 + icpp][pcc];
361 legend->AddEntry(graphs[i*12 + icpp][pcc],chstr,
"P");
367 tmpstr=
"CrateTimingScanPage";
373 tmpstr.ReplaceAll(
"gif",
"ps");
Int_t scan(TString directory)