3 class StFgtCosmicMaker;
7 class StFgtCorAdcMaker;
11 StFgtCosmicMaker *cosmicMkr = 0;
12 StFgtCorAdcMaker *adcCorrector = 0;
28 Int_t fgtCosmicQA(
const Char_t *filename =
"testfile.sfs",
29 const Char_t *pedfilename =
"testfile.Ped.txt",
32 const Char_t *runname =
"testrun",
33 const Char_t *quadname =
"010",
36 Bool_t cutShortEvents = 1,
43 Float_t sansPedYmax = 1024;
44 Float_t sansPedYmin = -512;
45 Int_t sansPedYbins = (sansPedYmax-sansPedYmin)/8;
48 Int_t binFactorXc = 8, binFactorXr = 2, binFactorXp = 4, binFactorY = 32;
49 Int_t numChannelsPerCorBin = 1;
52 Int_t canWidth = 850, canHeight = 1100;
54 Short_t timeBinMask = (1<<timeBin);
56 cout <<
"Constructing the ped plotter" << endl;
58 pedPlotter->setReadFromFile( pedfilename );
59 pedPlotter->setTimeBinMask( 1<<timeBin );
60 pedPlotter->setPlotVsStrip(
'c' );
61 pedPlotter->setDisc( disc );
62 pedPlotter->setQuad( quad );
63 pedPlotter->setQuadName( quadname );
64 pedPlotter->setPlotStDev( 1 );
66 cout <<
"making the ped. st. dev. plots" << endl;
67 ierr = pedPlotter->makePlots();
68 cout <<
"\tdone" << endl;
71 cerr <<
"\tError making pedistal st. dev. plot" << endl;
75 const TGraph* gr = pedPlotter->getGraph( timeBin );
77 cerr <<
"\tError making pedistal st. dev. plot" << endl;
81 cout <<
"Constructing the chain" << endl;
82 analysisChain =
new StChain(
"eemcAnalysisChain");
84 cout <<
"Constructing the cosmic maker" << endl;
85 cosmicMkr =
new StFgtCosmicMaker(
"cosmicMaker", filename );
86 cosmicMkr->setNumDiscs( numDiscs );
88 cout <<
"Constructing the QA makers" << endl;
91 adcVsChan->setTimeBin( timeBin );
92 adcVsChan->setFilenameBase(
"" );
93 adcVsChan->setToPlotVsStrip(
'c' );
94 adcVsChan->setToSubtrPeds( 0 );
95 adcVsChan->setBinFactors( binFactorXc, binFactorY );
99 cPlotterC->setTimeBin( timeBin );
100 cPlotterC->setToPlotVsStrip(
'c' );
101 cPlotterC->setBinFactors( numChannelsPerCorBin, 1 );
102 cPlotterC->setComputeCorrelations( 1 );
103 cPlotterC->setPedReaderFile(
"" );
106 cPlotterR1->setTimeBin( timeBin );
107 cPlotterR1->setToPlotVsStrip(
'r' );
108 cPlotterR1->setBinFactors( numChannelsPerCorBin, 1 );
109 cPlotterR1->setComputeCorrelations( 1 );
110 cPlotterR1->setPedReaderFile(
"" );
113 cPlotterR2->setTimeBin( timeBin );
114 cPlotterR2->setToPlotVsStrip(
'R1' );
115 cPlotterR2->setBinFactors( numChannelsPerCorBin, 1 );
116 cPlotterR2->setComputeCorrelations( 1 );
117 cPlotterR2->setPedReaderFile(
"" );
120 cPlotterP->setTimeBin( timeBin );
121 cPlotterP->setToPlotVsStrip(
'P' );
122 cPlotterP->setBinFactors( numChannelsPerCorBin, 1 );
123 cPlotterP->setComputeCorrelations( 1 );
124 cPlotterP->setPedReaderFile(
"" );
127 adcCorrector =
new StFgtCorAdcMaker(
"adcCorrector",
"cosmicMaker" );
128 adcCorrector->setPedReaderFile( pedfilename );
129 adcCorrector->setTimeBinMask( timeBinMask );
130 adcCorrector->setAbsThres( -10000 );
131 adcCorrector->setRelThres( 0 );
132 adcCorrector->doSubtrPeds( 1 );
133 adcCorrector->doRemoveOtherTimeBins( 1 );
135 adcSansPedVsChan =
new StFgtQaAdcVsChannel(
"fgtQaAdc_3",
"cosmicMaker", disc, quad, quadname );
136 adcSansPedVsChan->setTimeBin( timeBin );
137 adcSansPedVsChan->setFilenameBase(
"" );
138 adcSansPedVsChan->setToPlotVsStrip(
'c' );
139 adcSansPedVsChan->setToSubtrPeds( 0 );
140 adcSansPedVsChan->setYbins( sansPedYbins );
141 adcSansPedVsChan->setYrange( sansPedYmin, sansPedYmax );
142 adcSansPedVsChan->setBinFactors( binFactorXc, 1 );
144 adcSansPedVsR1 =
new StFgtQaAdcVsChannel(
"fgtQaAdc_4",
"cosmicMaker", disc, quad, quadname );
145 adcSansPedVsR1->setTimeBin( timeBin );
146 adcSansPedVsR1->setFilenameBase(
"" );
147 adcSansPedVsR1->setToPlotVsStrip(
'r' );
148 adcSansPedVsR1->setToSubtrPeds( 0 );
149 adcSansPedVsR1->setYbins( sansPedYbins );
150 adcSansPedVsR1->setYrange( sansPedYmin, sansPedYmax );
151 adcSansPedVsR1->setBinFactors( binFactorXr, 1 );
153 adcSansPedVsR2 =
new StFgtQaAdcVsChannel(
"fgtQaAdc_5",
"cosmicMaker", disc, quad, quadname );
154 adcSansPedVsR2->setTimeBin( timeBin );
155 adcSansPedVsR2->setFilenameBase(
"" );
156 adcSansPedVsR2->setToPlotVsStrip(
'R' );
157 adcSansPedVsR2->setToSubtrPeds( 0 );
158 adcSansPedVsR2->setYbins( sansPedYbins );
159 adcSansPedVsR2->setYrange( sansPedYmin, sansPedYmax );
160 adcSansPedVsR2->setBinFactors( binFactorXr, 1 );
162 adcSansPedVsPhi =
new StFgtQaAdcVsChannel(
"fgtQaAdc_6",
"cosmicMaker", disc, quad, quadname );
163 adcSansPedVsPhi->setTimeBin( timeBin );
164 adcSansPedVsPhi->setFilenameBase(
"" );
165 adcSansPedVsPhi->setToPlotVsStrip(
'P' );
166 adcSansPedVsPhi->setToSubtrPeds( 0 );
167 adcSansPedVsPhi->setYbins( sansPedYbins );
168 adcSansPedVsPhi->setYrange( sansPedYmin, sansPedYmax );
169 adcSansPedVsPhi->setBinFactors( binFactorXp, 1 );
171 cout <<
"Initializing" << endl;
172 ierr = analysisChain->Init();
173 cout <<
"\t done initializing" << endl;
176 cout <<
"Error initializing" << endl;
183 cout <<
"Looping over events..." << endl;
184 for(
int i=0; i<nevents && !ierr; ++i ){
187 cout <<
"event number " << i << endl;
190 analysisChain->
Clear();
193 ierr = analysisChain->
Make();
200 cout <<
"finish" << endl;
203 cout <<
"Making plots..." << endl;
206 TH2F* hAdcVsChan = adcVsChan->getHist();
207 TH2F* hAdcSansPedVsChan = adcSansPedVsChan->getHist();
208 TH2F* hAdcSansPedVsR1 = adcSansPedVsR1->getHist();
209 TH2F* hAdcSansPedVsR2 = adcSansPedVsR2->getHist();
210 TH2F* hAdcSansPedVsPhi = adcSansPedVsPhi->getHist();
215 gROOT->SetStyle(
"Plain");
216 gStyle->SetOptStat(0);
217 gStyle->SetEndErrorSize(0);
218 gStyle->SetTitleBorderSize(0);
219 gStyle->SetTitleTextColor(kRed);
220 gStyle->SetPalette(1);
223 TH2F *histC =
new TH2F (
"histC",
"", 1, 0, 1280, 1, 0, 200 );
225 gROOT->SetStyle(
"Plain");
226 TCanvas *can1 =
new TCanvas(
"fgtQAcan1",
"fgtQAcan1", canWidth, canHeight );
234 hAdcVsChan->SetMaximum( 200 );
235 hAdcVsChan->Draw(
"COLZ");
239 histC->SetTitle( gr->GetTitle() );
241 gr->SetMarkerColor( kBlue );
242 gr->SetMarkerSize( 0.4 );
243 gr->SetMarkerStyle( 20 );
248 hAdcSansPedVsChan->SetMaximum( 100 );
249 hAdcSansPedVsChan->Draw(
"COLZ");
258 hAdcSansPedVsR1->SetMaximum( 100 );
259 hAdcSansPedVsR1->Draw(
"COLZ");
263 hAdcSansPedVsR2->SetMaximum( 100 );
264 hAdcSansPedVsR2->Draw(
"COLZ");
268 hAdcSansPedVsPhi->SetMaximum( 100 );
269 hAdcSansPedVsPhi->Draw(
"COLZ");
276 TCanvas *can2 =
new TCanvas(
"fgtQAcan2",
"fgtQAcan2", canWidth, canWidth );
277 TH2F* corHist = cPlotterC->getCorrelationHist();
282 corHist->SetMaximum( 1 );
283 corHist->SetMinimum( -1 );
284 corHist->Draw(
"COLZ");
289 TCanvas *can3 =
new TCanvas(
"fgtQAcan3",
"fgtQAcan3", canWidth, canHeight );
292 TH2F* corHistR1 = cPlotterR1->getCorrelationHist();
293 TH2F* corHistR2 = cPlotterR2->getCorrelationHist();
294 TH2F* corHistP = cPlotterP->getCorrelationHist();
297 TVirtualPad *pad = gPad;
305 corHistR1->SetMaximum( 1 );
306 corHistR1->SetMinimum( -1 );
307 corHistR1->Draw(
"COLZ");
315 corHistR2->SetMaximum( 1 );
316 corHistR2->SetMinimum( -1 );
317 corHistR2->Draw(
"COLZ");
325 corHistP->SetMaximum( 1 );
326 corHistP->SetMinimum( -1 );
327 corHistP->Draw(
"COLZ");
332 cout <<
"ready to save" << endl;
334 std::string fileOut1 =
"fgtCosmicQA.page-1.";
335 std::string fileOut2 =
"fgtCosmicQA.page-2.";
336 std::string fileOut3 =
"fgtCosmicQA.page-3.";
338 std::string tail = runname;
344 cout <<
"\tsaving to '" << tail <<
"'" << endl;
345 can1->Print( (fileOut1+tail).
data() );
347 can2->Print( (fileOut2+tail).
data() );
348 can3->Print( (fileOut3+tail).
data() );
351 cout <<
"all done" << endl;
360 gSystem->Load(
"libPhysics");
361 gSystem->Load(
"St_base");
362 gSystem->Load(
"StChain");
363 gSystem->Load(
"StEvent");
364 gSystem->Load(
"StUtilities");
365 cout <<
"loaded StEvent library" << endl;
367 gSystem->Load(
"StFgtUtil");
368 gSystem->Load(
"StFgtRawMaker");
369 gSystem->Load(
"RTS");
370 gSystem->Load(
"StFgtPedMaker");
371 gSystem->Load(
"StFgtQaMakers");
372 gSystem->Load(
"StFgtPedPlotter");
373 gSystem->Load(
"StFgtCorAdcMaker");
virtual void Clear(Option_t *option="")
User defined functions.