ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ssen/Analyzers/src/ZDCAnalyzer.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Thu Dec 10 20:05:05 2009 UTC (15 years, 4 months ago) by tyetkin
Content type: text/plain
Branch: INITIAL, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Error occurred while calculating annotation data.
Log Message:
with flags

File Contents

# Content
1 // -*- C++ -*-
2 //
3 // Package: ZDCAnalyzer
4 // Class: ZDCAnalyzer
5 //
6 /**\class ZDCAnalyzer ZDCAnalyzer.cc Analyzers/ZDCAnalyzer/src/ZDCAnalyzer.cc
7
8 Description: <one line class summary>
9
10 Implementation:
11 <Notes on implementation>
12 */
13 //
14 // Original Author: Taylan Yetkin
15 // Created: Sat Nov 7 23:04:14 CET 2009
16 // $Id: ZDCAnalyzer.cc,v 1.4 2009/11/08 00:38:40 tyetkin Exp $
17 //
18 //
19
20
21 //trigger
22 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
23 #include "DataFormats/Common/interface/TriggerResults.h"
24 #include "FWCore/Framework/interface/TriggerNames.h"
25
26 // system include files
27 #include <memory>
28 #include <iostream>
29 #include <fstream>
30 #include <algorithm>
31 #include <vector>
32 #include <string>
33 #include <sys/time.h>
34
35 // user include files
36 #include "FWCore/Framework/interface/Frameworkfwd.h"
37 #include "FWCore/Framework/interface/EDAnalyzer.h"
38
39 #include "FWCore/Framework/interface/Event.h"
40 #include "FWCore/Framework/interface/MakerMacros.h"
41
42 #include "FWCore/ParameterSet/interface/ParameterSet.h"
43
44 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
45 // #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
46 // #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
47 // #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
48 #include "DataFormats/DetId/interface/DetId.h"
49 #include "Analyzers/ZDCAnalyzer/interface/ZDCAnalyzer.h"
50 #include "TH1F.h"
51 #include "TH2F.h"
52 #include "TStyle.h"
53 #include "TCanvas.h"
54
55 static const float HFQIEConst = 2.6;
56 static const float EMGain = 0.025514;
57 static const float HADGain = 0.782828;
58
59 using namespace edm;
60 using namespace std;
61
62 ZDCAnalyzer::ZDCAnalyzer(const edm::ParameterSet& iConfig){
63 Runno = iConfig.getUntrackedParameter < int >("RunNo", 1);
64 htmlPrint = iConfig.getUntrackedParameter < bool > ("printHTML", false);
65 doZDCHTML = iConfig.getUntrackedParameter < bool > ("printZDCHTML", false);
66
67 // base Html output directory
68 baseHtmlDir_ = iConfig.getUntrackedParameter < string > ("baseHtmlDir", "");
69 if (baseHtmlDir_.size() != 0)
70 cout << "-->HTML output will go to baseHtmlDir = '" << baseHtmlDir_ << "'" << endl;
71 else
72 cout << "-->HTML output is disabled" << endl;
73
74 runBegin = -1;
75 evtNo = 0;
76 lumibegin = 0;
77 lumiend = 0;
78 startTime = "Not Avaliable";
79 // root style
80 gStyle->Reset("Default");
81 gStyle->SetOptFit(1);
82 gStyle->SetCanvasColor(0);
83 gStyle->SetPadColor(0);
84 gStyle->SetFillColor(0);
85 gStyle->SetTitleFillColor(10);
86 // gStyle->SetOptStat(0);
87 gStyle->SetOptStat("ouemr");
88 gStyle->SetPalette(1);
89 //gStyle->SetPaintTextFormat("g");
90 }
91
92
93 ZDCAnalyzer::~ZDCAnalyzer(){
94 }
95
96
97 void ZDCAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
98 {
99 ++evtNo;
100 time_t a = (iEvent.time().value()) >> 32;
101 event = iEvent.id().event();
102 run = iEvent.id().run();
103 bxnumber = iEvent.bunchCrossing();
104 //if (run != Runno) return;
105
106 if (iEvent.bunchCrossing() != 51 && iEvent.bunchCrossing() != 2724 ){
107 cout << "bunc crossing failed " << bxnumber << endl;
108 return;
109 }
110 //std::cout << "~~~~~~~~~~event number " << event << std::endl;
111 lumi = iEvent.luminosityBlock();
112
113 //if (lumi < 105 ) return;
114 if (runBegin < 0) { // parameters for the first event
115 startTime = ctime(&a);
116 lumibegin = lumiend = lumi;
117 runBegin = iEvent.id().run();
118 }
119 run = iEvent.id().run();//needed in the tree
120
121 if (lumi < lumibegin)lumibegin = lumi;
122 if (lumi > lumiend)lumiend = lumi;
123
124 h_lumiBlock->Fill(iEvent.luminosityBlock());
125 h_bunchXing->Fill(iEvent.bunchCrossing());
126
127
128
129 // L1 global trigger
130 Handle < L1GlobalTriggerReadoutRecord > gtRecord_h;
131 iEvent.getByType(gtRecord_h); // assume only one L1 trigger record here
132 const L1GlobalTriggerReadoutRecord *gtRecord = gtRecord_h.failedToGet()? 0 : &*gtRecord_h;
133
134 // L1 Global trigger (algo)
135 bool collisionTrigger = false;
136 if (gtRecord) { // object is available
137 //for (int l1bit = 0; l1bit < 128; ++l1bit) {
138 // if (gtRecord->decisionWord()[l1bit]){
139 // h_l1_algoBit->Fill(l1bit);
140 // h_l1_algoBit_vs_bunchXing->Fill(l1bit,iEvent.bunchCrossing());
141 // }
142 //}
143 for (int l1bit = 0; l1bit < 64; ++l1bit) {
144 if (gtRecord->technicalTriggerWord()[l1bit]){
145 if (l1bit == 40 || l1bit ==41 ) {
146 collisionTrigger = true;
147 h_l1_techBit->Fill(l1bit);
148 cout << "Tech. Bit = " << l1bit << endl;
149 }
150 }
151 }
152 }else{
153 cout << "L1 Global Trigger does not exist" << endl;
154 }
155 if(!collisionTrigger){
156 cout << " Rejecting " << endl;
157 return;
158 }else{
159 cout << " ACCEPT " << endl;
160 }
161
162
163
164 // hf rechits
165 Handle < HFRecHitCollection > hf_recHits_h;
166 iEvent.getByLabel("hfreco", hf_recHits_h);
167 const HFRecHitCollection *hf_recHits = hf_recHits_h.failedToGet()? 0 : &*hf_recHits_h;
168 float hf_time_difference = -999.;
169 double PlusTiming = -999.;
170 double MinusTiming = -999.;
171 if (hf_recHits) { // object is available
172 std::cout << "HF RECHITS here" << iEvent.id() << std::endl;
173 float sumE_HFP = 0.;
174 float sumE_HFM = 0.;
175 float timeWeightedEnergy_HFP = 0.;
176 float timeWeightedEnergy_HFM = 0.;
177 int rechitCounter = 0;
178 for (HFRecHitCollection::const_iterator hhit = hf_recHits->begin(); hhit != hf_recHits->end(); hhit++) {
179 if (hhit->energy() > 2.0){ //GeV Cut
180 if((hhit->id()).ieta()>0.){ //HFP
181 if(hhit->id().depth() == 1){ //only Long Fibers
182 sumE_HFP += hhit->energy();
183 timeWeightedEnergy_HFP += (hhit->energy()*hhit->time());
184 //std::cout << "Plus Side " << rechitCounter << ". " << " Rechit time " << hhit->time() << std::endl;
185 }
186 }else{ //HFM
187 if(hhit->id().depth() == 1){ //only Long Fibers
188 sumE_HFM += hhit->energy();
189 timeWeightedEnergy_HFM += (hhit->energy()*hhit->time());
190 //std::cout << "Minus Side " << rechitCounter << ". " << " Rechit time " << hhit->time() << std::endl;
191 }
192 }
193 }
194
195 ++rechitCounter;
196 }
197
198 PlusTiming = (sumE_HFP > 0.) ? (timeWeightedEnergy_HFP/sumE_HFP):0;
199 MinusTiming = (sumE_HFM > 0.) ? (timeWeightedEnergy_HFM/sumE_HFM):0;
200 double HFPTime = (sumE_HFP > 0.) ? (timeWeightedEnergy_HFP/sumE_HFP):0;
201 double HFMTime = (sumE_HFM > 0.) ? (timeWeightedEnergy_HFM/sumE_HFM):0;
202
203 hf_time_difference = (PlusTiming - MinusTiming);
204 //hf_time_difference = (timeWeightedEnergy_HFP/sumE_HFP - timeWeightedEnergy_HFM/sumE_HFM);
205 h_hf_time_difference ->Fill(hf_time_difference);
206 h_recHitSum_HFP_Long->Fill(sumE_HFP);
207 h_recHitSum_HFM_Long->Fill(sumE_HFM);
208 int flag1 = 0;
209 int flag2 = 0;
210 int flag3 = 0;
211 int flag4 = 0;
212 int flag5 = 0;
213 int flag6 = 0;
214 int flag7 = 0;
215 if( (HFPTime > 15. && HFPTime < 30.) && (HFMTime > 15. && HFMTime < 30.))flag1 = 1; // intime events
216 if( (HFPTime < -50. && HFPTime > -90.) && (HFMTime > 15. && HFMTime < 30.))flag2 = 1; //beam1 halo
217 if( (HFPTime > 15. && HFPTime < 30.) && (HFMTime > -50. && HFMTime < -20.))flag3 = 1; // beam2 scr
218 if( (HFPTime > 15. && HFPTime < 30.) && (HFMTime < -50. && HFMTime > -90.))flag4 = 1;
219 if( (HFPTime > 15. && HFPTime < 30.) && (HFMTime > 40. && HFMTime < 60.))flag5 = 1;
220 if( (HFPTime > 15. && HFPTime < 30.) && (HFMTime > 60. && HFMTime < 80.))flag6 = 1;
221 if( (HFPTime > 40.) && (HFMTime > 15. && HFMTime < 30.))flag7 = 1;
222 //if( (HFPTime > 15. && HFPTime < 30.) && (HFMTime > 15. && HFMTime < 30.))flag7 = 1; // intime events
223 int bin = histFlag1->GetXaxis()->FindBin(lumi);
224 if(flag1==1)histFlag1->Fill(bin,1);
225 int bin1 = histFlag1->GetXaxis()->FindBin(lumi);
226 if(flag2==1)histFlag2->Fill(bin1,1);
227 int bin2 = histFlag2->GetXaxis()->FindBin(lumi);
228 if(flag3==1)histFlag3->Fill(bin2,1);
229 int bin3 = histFlag3->GetXaxis()->FindBin(lumi);
230 if(flag4==1)histFlag4->Fill(bin3,1);
231 int bin4 = histFlag4->GetXaxis()->FindBin(lumi);
232 if(flag5==1)histFlag5->Fill(bin4,1);
233 int bin5 = histFlag5->GetXaxis()->FindBin(lumi);
234 if(flag6==1)histFlag6->Fill(bin5,1);
235 int bin6 = histFlag6->GetXaxis()->FindBin(lumi);
236 if(flag7==1)histFlag7->Fill(bin6,1);
237
238 //std::cout << " PlusTiming " << PlusTiming << std::endl;
239 //std::cout << " MinusTiming " << MinusTiming << std::endl;
240
241 } //end of HFrechits
242
243 if(hf_time_difference == -999){
244 cout << "WARNING! RECHITS WERE NOT FOUND. NO TIMING INFORMATION" << endl;
245 }
246
247 // We have three conditions need to be flagged.
248
249 //intime condition1
250 //if ( PlusTiming < 15. || PlusTiming > 30.) return;
251 //if ( MinusTiming < 15. || MinusTiming > 30.) return;
252
253 // //beam2scr
254 //if ( PlusTiming < 15. || PlusTiming > 30.) return;
255 //if ( MinusTiming < -50. || MinusTiming > 0.) return;
256
257 //beam2halo condition4
258 //if ( PlusTiming < 15. || PlusTiming > 30.) return;
259 //if ( MinusTiming < -90. || MinusTiming > -70.) return;
260
261 // //beam1scr condition3
262 //if ( PlusTiming < -50. || PlusTiming > 0.) return;
263 //if ( MinusTiming < 15. || MinusTiming > 30.) return;
264
265 //beam1halo condition5
266 //if ( PlusTiming < -90. || PlusTiming > -70.) return;
267 //if ( MinusTiming < 15. || MinusTiming > 30.) return;
268
269 //cout << " ~~~~THIS EVENT HAS ALREADY BEEN ACCEPTED ! WHAT DO YOU THINK~~~~ ?" << endl;
270
271 //if (fabs(hf_time_difference) > 20) return;
272 //if (hf_time_difference < 30) return;
273 //if (fabs(hf_time_difference) > 300) return;
274 //if (hf_time_difference > 40 || hf_time_difference < 10) return;
275
276 //if (timeWeightedEnergy_HFP/sumE_HFP > 15. && timeWeightedEnergy_HFP/sumE_HFP < 30. )
277
278 //std::cout << " timeWeightedEnergy_HFP/sumE_HFP " << timeWeightedEnergy_HFP/sumE_HFP << std::endl;
279 //std::cout << " timeWeightedEnergy_HFM/sumE_HFM " << timeWeightedEnergy_HFM/sumE_HFM << std::endl;
280
281
282 h_BX_after_return->Fill(iEvent.bunchCrossing());
283 //if (hf_time_difference < 60) return; //only Plus(or minus) outtime events
284
285 edm::Handle<ZDCDigiCollection> zdc_digi_h;
286 iEvent.getByType(zdc_digi_h);
287 const ZDCDigiCollection *zdc_digi = zdc_digi_h.failedToGet()? 0 : &*zdc_digi_h;
288
289 if(zdc_digi){
290 double QEM = 0.;
291 double QEMR = 0.;
292 double QHAD = 0.;
293 double QHAD1 = 0.;
294 double QHAD2 = 0.;
295 double QHADR = 0.;
296 for (ZDCDigiCollection::const_iterator j=zdc_digi->begin();j!=zdc_digi->end(); ++j) {
297 const ZDCDataFrame digi = (const ZDCDataFrame)(*j);
298 int iSide = digi.id().zside();
299 int iSection = digi.id().section();
300 int iChannel = digi.id().channel();
301 //std::cout << "Side= " << iSide << " Section= " << iSection << " Channel= " << iChannel << std::endl;
302 double fSum = 0.;
303 double fData[10] = {-999.};
304 double adcfData[10] = {-999.};
305 int fTS = digi.size();
306 for (int i = 0; i < fTS; ++i) {
307 fData[i] = HFQIEConst*digi[i].nominal_fC();
308 //fData[i] = digi[i].adc();
309 //fData[i] = digi[i].capid();
310 //std::cout << "capsRotation ";
311 // std::cout << fData[i] << std::endl;
312 //std::cout << fData[i] << std::endl;
313 histodeneme->Fill(fData[i],1);
314 }
315
316 if(!isGood(fData, 30, 0.001))continue;
317 double fTSMean = getTime(fData, fSum);
318
319 if(iSection==1){
320
321 if (iSide == -1) h_channel_side_charge->Fill(iSide+2,iChannel-1,fSum);
322 if (iSide == 1) h_channel_side_charge->Fill(iSide-1,iChannel-1,fSum);
323 //h_channel_side_timing->Fill(iSide,iChannel,fTSmean);
324
325 if (iSide ==1 ){
326 for(int i = 0; i < fTS; ++i){
327 h_ZDCP_EM_Pulse[iChannel-1]->Fill(i,fData[i]);
328 }
329 h_ZDCP_EM_Charge[iChannel-1]->Fill(fSum);
330 h_ZDCP_EM_TSMean[iChannel-1]->Fill(fTSMean);
331 //h_channel_side_timing->Fill(iSide+1,iChannel,fTSmean);
332 h_ZDCP_EM_RecHitEnergy[iChannel-1]->Fill(fSum*EMGain);
333
334 QEM += fSum;
335 QEMR += fSum*EMGain;
336 }
337 if (iSide == -1 ){
338 for(int i = 0; i < fTS; ++i){
339 h_ZDCM_EM_Pulse[iChannel-1]->Fill(i,fData[i]);
340 }
341 h_ZDCM_EM_Charge[iChannel-1]->Fill(fSum);
342 h_ZDCM_EM_TSMean[iChannel-1]->Fill(fTSMean);
343 //h_channel_side_timing->Fill(iSide,iChannel,fTSmean);
344 h_ZDCM_EM_RecHitEnergy[iChannel-1]->Fill(fSum*EMGain);
345 //if (iChannel==1) std::cout << iEvent.id() << << ". TS" << i << "\t" << "Charge " << fData[i] << std::endl;
346 }
347 }
348 if(iSection==2){
349
350 if (iSide == -1) h_channel_side_charge->Fill(iSide+2,iChannel+4,fSum);
351 if (iSide == 1) h_channel_side_charge->Fill(iSide-1,iChannel+4,fSum);
352 //h_channel_side_timing->Fill(iSide,iChannel+5,fTSmean);
353
354 if (iSide == 1 ){
355 for(int i = 0; i < fTS; ++i){
356 h_ZDCP_HAD_Pulse[iChannel-1]->Fill(i,fData[i]);}
357 h_ZDCP_HAD_Charge[iChannel-1]->Fill(fSum);
358 h_ZDCP_HAD_TSMean[iChannel-1]->Fill(fTSMean);
359 //h_channel_side_timing->Fill(iSide+1,iChannel+5,fTSmean);
360 h_ZDCP_HAD_RecHitEnergy[iChannel-1]->Fill(fSum*HADGain);
361 QHAD += fSum;
362 if (iChannel == 1 || iChannel ==2) QHAD1 += fSum;
363 if (iChannel == 3 || iChannel ==4) QHAD2 += fSum;
364 QHADR += fSum*HADGain;
365 if (QHAD > 10000) std::cout << "~~~~~~~~~~~~~~~"
366 << "###############"
367 << " Event Number " << event << " lumi = " << lumi << " BX = " << iEvent.bunchCrossing() << std::endl;
368 }
369 if (iSide == -1 ){
370 for(int i = 0; i < fTS; ++i){
371 h_ZDCM_HAD_Pulse[iChannel-1]->Fill(i,fData[i]);}
372 h_ZDCM_HAD_Charge[iChannel-1]->Fill(fSum);
373 h_ZDCM_HAD_TSMean[iChannel-1]->Fill(fTSMean);
374 //h_channel_side_timing->Fill(iSide,iChannel+5,fTSmean);
375 h_ZDCM_HAD_RecHitEnergy[iChannel-1]->Fill(fSum*HADGain);
376 }
377 }
378 }
379 h_ZDCP_Charge_Correlation->Fill(QEM, QHAD);
380 h_ZDCP_Charge_CorrelationHAD->Fill(QHAD1, QHAD2);
381 //h_ZDCP_Charge_Correlation2->Fill(QEM/5, QHAD/4);
382 //h_ZDCP_RecHit_Correlation->Fill(QEMR, QHADR);
383 }
384 }
385
386 void ZDCAnalyzer::beginJob(const edm::EventSetup& iSetup){
387 // iSetup.get<HcalDbRecord>().get(conditions);
388 TFileDirectory ZDCDir = mFileServer->mkdir("ZDC");
389 histFlag1 = book1DHistogram(ZDCDir,"histFlag1", "histFlag1", 1000, 0., 1000.);
390 histFlag2 = book1DHistogram(ZDCDir,"histFlag2", "histFlag2", 1000, 0., 1000.);
391 histFlag3 = book1DHistogram(ZDCDir,"histFlag3", "histFlag3", 1000, 0., 1000.);
392 histFlag4 = book1DHistogram(ZDCDir,"histFlag4", "histFlag4", 1000, 0., 1000.);
393 histFlag5 = book1DHistogram(ZDCDir,"histFlag5", "histFlag5", 1000, 0., 1000.);
394 histFlag6 = book1DHistogram(ZDCDir,"histFlag6", "histFlag6", 1000, 0., 1000.);
395 histFlag7 = book1DHistogram(ZDCDir,"histFlag7", "histFlag7", 1000, 0., 1000.);
396 char title[128];
397 char name[128];
398 for(int i = 0; i < 4;++i){
399 // pulse Plus Side
400 sprintf(title,"h_ZDCP_HADChan_%i_Pulse",i+1);
401 sprintf(name,"ZDC Plus HAD Section Pulse for channel %i",i+1);
402 h_ZDCP_HAD_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
403 h_ZDCP_HAD_Pulse[i]->SetFillColor(kBlue);
404 //integrated charge over 10 time samples
405 sprintf(title,"h_ZDCP_HADChan_%i_Charge",i+1);
406 sprintf(name,"ZDC Plus HAD Section Charge for channel %i",i+1);
407 h_ZDCP_HAD_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
408 h_ZDCP_HAD_Charge[i]->SetFillColor(kBlue);
409 //charge weighted time slice
410 sprintf(title,"h_ZDCP_HADChan_%i_TSMean",i+1);
411 sprintf(name,"ZDC Plus HAD Section TSMean for channel %i",i+1);
412 h_ZDCP_HAD_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
413 h_ZDCP_HAD_TSMean[i]->SetFillColor(kBlue);
414 //RecHit for HAD sections
415 sprintf(title,"h_ZDCP_HADChan_%i_RecHit_Energy",i+1);
416 sprintf(name,"ZDC Plus HAD Section Rechit Energy for channel %i",i+1);
417 h_ZDCP_HAD_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
418 h_ZDCP_HAD_RecHitEnergy[i]->SetFillColor(kRed);
419
420 // pulse Minus Side
421 sprintf(title,"h_ZDCM_HADChan_%i_Pulse",i+1);
422 sprintf(name,"ZDC Minus HAD Section Pulse for channel %i",i+1);
423 h_ZDCM_HAD_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
424 h_ZDCM_HAD_Pulse[i]->SetFillColor(7);
425 //integrated charge over 10 time samples
426 sprintf(title,"h_ZDCM_HADChan_%i_Charge",i+1);
427 sprintf(name,"ZDC Minus HAD Section Charge for channel %i",i+1);
428 h_ZDCM_HAD_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
429 h_ZDCM_HAD_Charge[i]->SetFillColor(7);
430 //charge weighted time slice
431 sprintf(title,"h_ZDCM_HADChan_%i_TSMean",i+1);
432 sprintf(name,"ZDC Minus HAD Section TSMean for channel %i",i+1);
433 h_ZDCM_HAD_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
434 h_ZDCM_HAD_TSMean[i]->SetFillColor(7);
435 //RecHit for HAD sections
436 sprintf(title,"h_ZDCM_HADChan_%i_RecHit_Energy",i+1);
437 sprintf(name,"ZDC Minus HAD Section Rechit Energy for channel %i",i+1);
438 h_ZDCM_HAD_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10.,30000.);
439 h_ZDCM_HAD_RecHitEnergy[i]->SetFillColor(kRed);
440 }
441 for(int i = 0; i < 5;++i){
442 // pulse Plus Side
443 sprintf(title,"h_ZDCP_EMChan_%i_Pulse",i+1);
444 sprintf(name,"ZDC Plus EM Section Pulse for channel %i",i+1);
445 h_ZDCP_EM_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
446 h_ZDCP_EM_Pulse[i]->SetFillColor(kBlue);
447 //integrated charge over 10 time samples
448 sprintf(title,"h_ZDCP_EMChan_%i_Charge",i+1);
449 sprintf(name,"ZDC Plus EM Section Charge for channel %i",i+1);
450 h_ZDCP_EM_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
451 h_ZDCP_EM_Charge[i]->SetFillColor(kBlue);
452 //charge weighted time slice
453 sprintf(title,"h_ZDCP_EMChan_%i_TSMean",i+1);
454 sprintf(name,"ZDC Plus EM Section TSMean for channel %i",i+1);
455 h_ZDCP_EM_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
456 h_ZDCP_EM_TSMean[i]->SetFillColor(kBlue);
457 //RecHit for EM sections
458 sprintf(title,"h_ZDCP_EMChan_%i_RecHit_Energy",i+1);
459 sprintf(name,"ZDC Plus EM Section Rechit Energy for channel %i",i+1);
460 h_ZDCP_EM_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
461 h_ZDCP_EM_RecHitEnergy[i]->SetFillColor(kRed);
462
463 // pulse Minus Side
464 sprintf(title,"h_ZDCM_EMChan_%i_Pulse",i+1);
465 sprintf(name,"ZDC Minus EM Section Pulse for channel %i",i+1);
466 h_ZDCM_EM_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
467 h_ZDCM_EM_Pulse[i]->SetFillColor(7);
468 //integrated charge over 10 time samples
469 sprintf(title,"h_ZDCM_EMChan_%i_Charge",i+1);
470 sprintf(name,"ZDC Minus EM Section Charge for channel %i",i+1);
471 h_ZDCM_EM_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
472 h_ZDCM_EM_Charge[i]->SetFillColor(7);
473 //charge weighted time slice
474 sprintf(title,"h_ZDCM_EMChan_%i_TSMean",i+1);
475 sprintf(name,"ZDC Minus EM Section TSMean for channel %i",i+1);
476 h_ZDCM_EM_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
477 h_ZDCM_EM_TSMean[i]->SetFillColor(7);
478 //RecHit for EM sections
479 sprintf(title,"h_ZDCM_EMChan_%i_RecHit_Energy",i+1);
480 sprintf(name,"ZDC Minus EM Section Rechit Energy for channel %i",i+1);
481 h_ZDCM_EM_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
482 h_ZDCM_EM_RecHitEnergy[i]->SetFillColor(kRed);
483 }
484
485 h_l1_techBit = book1DHistogram(ZDCDir,"h_l1_techBit", "L1 Global Technical Trigger Bits", 128, -0.5, 127.5);
486
487 h_recHitSum_HFP_Long = book1DHistogram(ZDCDir,"h_recHitSum_HFP", "HFP RecHit Sum", 100, -10., 1000.);
488 h_recHitSum_HFM_Long = book1DHistogram(ZDCDir,"h_recHitSum_HFM", "HFM RecHit Sum", 100, -10., 1000.);
489 h_hf_time_difference = book1DHistogram(ZDCDir,"HF_time_difference", "HFP_L sum(E*Time)/sumE - HFM_L sum(E*Time)/sumE", 100, -100., 100.);
490
491 h_channel_side_charge = book2DHistogram(ZDCDir,"charge", "Occup. charge", 2,0,2,9,0,9);
492 h_channel_side_timing = book2DHistogram(ZDCDir,"timing", "Occup. timing", 2,0,2,9,0,9);
493
494 h_channel_side_charge->GetXaxis()->SetBinLabel(1,"ZDC+");
495 h_channel_side_charge->GetXaxis()->SetBinLabel(2,"ZDC-");
496 h_channel_side_timing->GetXaxis()->SetBinLabel(1,"ZDC+");
497 h_channel_side_timing->GetXaxis()->SetBinLabel(2,"ZDC-");
498
499 h_channel_side_charge->GetYaxis()->SetBinLabel(1,"EM1");
500 h_channel_side_charge->GetYaxis()->SetBinLabel(2,"EM2");
501 h_channel_side_charge->GetYaxis()->SetBinLabel(3,"EM3");
502 h_channel_side_charge->GetYaxis()->SetBinLabel(4,"EM4");
503 h_channel_side_charge->GetYaxis()->SetBinLabel(5,"EM5");
504 h_channel_side_charge->GetYaxis()->SetBinLabel(6,"HAD1");
505 h_channel_side_charge->GetYaxis()->SetBinLabel(7,"HAD2");
506 h_channel_side_charge->GetYaxis()->SetBinLabel(8,"HAD3");
507 h_channel_side_charge->GetYaxis()->SetBinLabel(9,"HAD4");
508
509 h_channel_side_timing->GetYaxis()->SetBinLabel(1,"EM1");
510 h_channel_side_timing->GetYaxis()->SetBinLabel(2,"EM2");
511 h_channel_side_timing->GetYaxis()->SetBinLabel(3,"EM3");
512 h_channel_side_timing->GetYaxis()->SetBinLabel(4,"EM4");
513 h_channel_side_timing->GetYaxis()->SetBinLabel(5,"EM5");
514 h_channel_side_timing->GetYaxis()->SetBinLabel(6,"HAD1");
515 h_channel_side_timing->GetYaxis()->SetBinLabel(7,"HAD2");
516 h_channel_side_timing->GetYaxis()->SetBinLabel(8,"HAD3");
517 h_channel_side_timing->GetYaxis()->SetBinLabel(9,"HAD4");
518
519
520 h_channel_side_charge_Ave = book2DHistogram(ZDCDir,"charge_Ave", "Occup. charge_Ave", 2,0,2,9,0,9);
521
522 //h_channel_side_charge_Ave->Draw("TEXT");
523
524 h_channel_side_charge_Ave->GetXaxis()->SetBinLabel(1,"ZDC+");
525 h_channel_side_charge_Ave->GetXaxis()->SetBinLabel(2,"ZDC-");
526
527 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(1,"EM1");
528 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(2,"EM2");
529 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(3,"EM3");
530 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(4,"EM4");
531 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(5,"EM5");
532 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(6,"HAD1");
533 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(7,"HAD2");
534 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(8,"HAD3");
535 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(9,"HAD4");
536
537 h_channel_side_TSMean_Ave = book2DHistogram(ZDCDir,"TSMean_Ave", "Occup. TSMean_Ave", 2,0,2,9,0,9);
538
539 h_channel_side_TSMean_Ave->GetXaxis()->SetBinLabel(1,"ZDC+");
540 h_channel_side_TSMean_Ave->GetXaxis()->SetBinLabel(2,"ZDC-");
541
542 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(1,"EM1");
543 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(2,"EM2");
544 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(3,"EM3");
545 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(4,"EM4");
546 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(5,"EM5");
547 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(6,"HAD1");
548 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(7,"HAD2");
549 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(8,"HAD3");
550 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(9,"HAD4");
551
552 h_bunchXing = book1DHistogram(ZDCDir,"h_bunchXing", "BX distribution", 3565, -0.5, 3563.5);
553 h_lumiBlock = book1DHistogram(ZDCDir,"h_lumiBlock", "Lumi Blocks", 300, -0.5, 295.5);
554 histodeneme = book1DHistogram(ZDCDir,"histodeneme", "QIE Bins", 128, -0.5, 127.5);
555 h_bunchXing->SetFillColor(kBlue);
556 h_lumiBlock->SetFillColor(kBlue);
557 histodeneme->SetFillColor(kBlue);
558 h_BX_before_return = book1DHistogram(ZDCDir,"h_BX_before", "BX distribution", 3565, -0.5, 3563.5);
559 h_BX_after_return = book1DHistogram(ZDCDir,"h_BX_after", "BX distribution for nonIP5 Events", 3565, -0.5, 3563.5);
560
561 h_ZDCP_EM_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCP_EM_RecHitEnergyAve", "ZDC Plus EM Section RecHitEnergyAve", 5, -0.5, 4.5);
562 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"+EM1");
563 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"+EM2");
564 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"+EM3");
565 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"+EM4");
566 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(5,"+EM5");
567 h_ZDCP_HAD_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCP_HAD_RecHitEnergyAve", "ZDC Plus HAD Section RecHitEnergyAve", 4, -0.5, 3.5);
568 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"+HAD1");
569 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"+HAD2");
570 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"+HAD3");
571 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"+HAD4");
572
573 h_ZDCP_EMHAD_ChargeAve = book1DHistogram(ZDCDir,"h_ZDCP_EMHAD_ChargeAve", "ZDC Plus ChargeAve", 9, -0.5, 8.5);
574 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(1,"+EM1");
575 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(2,"+EM2");
576 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(3,"+EM3");
577 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(4,"+EM4");
578 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(5,"+EM5");
579 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(6,"+HAD1");
580 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(7,"+HAD2");
581 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(8,"+HAD3");
582 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(9,"+HAD4");
583
584 //setZDClabels(h_ZDCP_EMHAD_TSMeanAve);
585 h_ZDCP_EMHAD_TSMeanAve = book1DHistogram(ZDCDir,"h_ZDCP_EMHAD_TSMeanAve", "ZDC Plus Timing", 9, -0.5, 8.5);
586 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(1,"+EM1");
587 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(2,"+EM2");
588 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(3,"+EM3");
589 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(4,"+EM4");
590 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(5,"+EM5");
591 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(6,"+HAD1");
592 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(7,"+HAD2");
593 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(8,"+HAD3");
594 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(9,"+HAD4");
595
596 h_ZDCP_Charge_Correlation = book2DHistogram(ZDCDir,"h_ZDCP_Charge_Correlation","ZDC Plus Charge Correlation",120,0.,1200.,120,0.,1200.);
597 //h_ZDCP_Charge_Correlation2 = book2DHistogram(ZDCDir,"h_ZDCP_Charge_Correlation2","ZDCP Charge Correlation2",100,-10.,1000.,100,-10.,1000.);
598 //h_ZDCP_RecHit_Correlation = book2DHistogram(ZDCDir,"h_ZDCP_RecHit_Correlation","ZDCP RecHit Correlation",,0.,1000.,1000,0.,20000.);
599 h_ZDCP_Charge_CorrelationHAD = book2DHistogram(ZDCDir,"h_ZDCP_Charge_CorrelationHAD","ZDC Plus Charge CorrelationHAD",100,0.,600.,100,0.,600.);
600
601 h_ZDCP_EM_RecHitEnergyAve->Sumw2();
602 h_ZDCP_HAD_RecHitEnergyAve->Sumw2();
603 h_ZDCP_EMHAD_ChargeAve->Sumw2();
604 h_ZDCP_EMHAD_TSMeanAve->Sumw2();
605
606 h_ZDCP_EM_RecHitEnergyAve->SetFillColor(kRed);
607 h_ZDCP_HAD_RecHitEnergyAve->SetFillColor(kRed);
608 h_ZDCP_EMHAD_TSMeanAve->SetFillColor(kRed);
609 h_ZDCP_Charge_Correlation->SetMarkerColor(kBlue);
610 h_ZDCP_Charge_Correlation->SetMarkerStyle(kFullTriangleUp);
611 //h_ZDCP_Charge_Correlation2->SetMarkerColor(kRed);
612 //h_ZDCP_Charge_Correlation2->SetMarkerStyle(kFullTriangleUp);
613 //h_ZDCP_RecHit_Correlation->SetMarkerColor(kRed);
614 //h_ZDCP_RecHit_Correlation->SetMarkerStyle(kFullTriangleDown);
615 h_ZDCP_Charge_CorrelationHAD->SetMarkerColor(kRed);
616 h_ZDCP_Charge_CorrelationHAD->SetMarkerStyle(kFullTriangleUp);
617
618 // Minus Side Histograms
619
620 h_ZDCM_EM_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCM_EM_RecHitEnergyAve", "ZDC Minus EM Section RecHitEnergyAve", 5, -0.5, 4.5);
621 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"-EM1");
622 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"-EM2");
623 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"-EM3");
624 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"-EM4");
625 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(5,"-EM5");
626 h_ZDCM_HAD_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCM_HAD_RecHitEnergyAve", "ZDC Minus HAD Section RecHitEnergyAve", 4, -0.5, 3.5);
627 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"-HAD1");
628 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"-HAD2");
629 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"-HAD3");
630 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"-HAD4");
631
632 h_ZDCM_EMHAD_ChargeAve = book1DHistogram(ZDCDir,"h_ZDCM_EMHAD_ChargeAve", "ZDC Minus ChargeAve", 9, -0.5, 8.5);
633 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(1,"-EM1");
634 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(2,"-EM2");
635 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(3,"-EM3");
636 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(4,"-EM4");
637 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(5,"-EM5");
638 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(6,"-HAD1");
639 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(7,"-HAD2");
640 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(8,"-HAD3");
641 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(9,"-HAD4");
642
643 h_ZDCM_EMHAD_TSMeanAve = book1DHistogram(ZDCDir,"h_ZDCM_EMHAD_TSMeanAve", "ZDC Minus Timing", 9, -0.5, 8.5);
644 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(1,"-EM1");
645 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(2,"-EM2");
646 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(3,"-EM3");
647 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(4,"-EM4");
648 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(5,"-EM5");
649 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(6,"-HAD1");
650 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(7,"-HAD2");
651 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(8,"-HAD3");
652 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(9,"-HAD4");
653
654 h_ZDCM_EM_RecHitEnergyAve->Sumw2();
655 h_ZDCM_HAD_RecHitEnergyAve->Sumw2();
656 h_ZDCM_EMHAD_ChargeAve->Sumw2();
657 h_ZDCM_EMHAD_TSMeanAve->Sumw2();
658 h_ZDCM_EM_RecHitEnergyAve->SetFillColor(kRed);
659 h_ZDCM_HAD_RecHitEnergyAve->SetFillColor(kRed);
660 h_ZDCM_EMHAD_TSMeanAve->SetFillColor(kRed);
661 }
662
663 //exact copy from http://cmslxr.fnal.gov/lxr/source/DQM/HcalMonitorModule/src/HcalTimingMonitorModule.cc#100
664 bool ZDCAnalyzer::isGood(double fData[10], double fCut, double fPercentage){
665 bool dec = false;
666 int n = 10;
667 int ts_max=-1; double max=-100;
668 ts_max = getTSMax(fData,10);
669 if(ts_max==0 || ts_max==(n-1)) return false;
670 float sum = fData[ts_max-1] + fData[ts_max+1];
671 //cout << "tsMax " << ts_max << " data[tsmax] " << mData[ts_max] << " sum " << sum << endl;
672 if(fData[ts_max] > fCut && sum > (fData[ts_max]*fPercentage)) dec = true;
673 return dec;
674 }
675
676
677 int ZDCAnalyzer::getTSMax(double fData[10], int fTS)
678 {
679 int ts_max = -100;
680 double max = -9999.;
681 for(int j = 0; j < fTS; ++j){
682 if(max < fData[j]){
683 max = fData[j];
684 ts_max = j;
685 }
686 }
687 return ts_max;
688 }
689 double ZDCAnalyzer::getTime(double fData[10], double& fSum){
690 int n = 10;
691 int ts_max = getTSMax(fData,10);
692 double Time=0,SumT=0; //,MaxT=-10;
693 if (ts_max>=0){
694 Time = ts_max*fData[ts_max];
695 SumT = fData[ts_max];
696 if(ts_max>0){
697 Time += (ts_max-1)*fData[ts_max-1];
698 SumT += fData[ts_max-1];
699 }
700 if(ts_max<(n-1)){
701 Time += (ts_max+1)*fData[ts_max+1];
702 SumT += fData[ts_max+1];
703 }
704 Time=Time/SumT;
705 }
706 if (SumT > 0.) fSum = SumT;
707
708 return Time;
709 }
710 TH1F *ZDCAnalyzer::book1DHistogram(TFileDirectory & fDir, const std::string & fName, const std::string & fTitle,
711 int fNbins, double fXmin, double fXmax) const {
712 char title[1024];
713 sprintf(title, "%s [RUN:%i]", fTitle.c_str(), Runno);
714 return fDir.make < TH1F > (fName.c_str(), title, fNbins, fXmin, fXmax);
715 }
716 TH2F *ZDCAnalyzer::book2DHistogram(TFileDirectory & fDir, const std::string & fName, const std::string & fTitle,
717 int fNbinsX, double fXmin, double fXmax, int fNbinsY, double fYmin, double fYmax) const {
718 char title[1024];
719 sprintf(title, "%s [RUN:%i]", fTitle.c_str(), Runno);
720 return fDir.make < TH2F > (fName.c_str(), title, fNbinsX, fXmin, fXmax, fNbinsY, fYmin, fYmax);
721 }
722
723 void ZDCAnalyzer::endJob() {
724 for(int i = 0; i < 5;++i){
725 h_ZDCP_EMHAD_TSMeanAve->SetBinContent(i+1,h_ZDCP_EM_TSMean[i]->GetMean());
726 h_ZDCP_EMHAD_TSMeanAve->SetBinError(i+1,h_ZDCP_EM_TSMean[i]->GetMeanError());
727 h_ZDCP_EMHAD_ChargeAve->SetBinContent(i+1,h_ZDCP_EM_Charge[i]->GetMean());
728 h_ZDCP_EMHAD_ChargeAve->SetBinError(i+1,h_ZDCP_EM_Charge[i]->GetMeanError());
729 h_ZDCP_EM_RecHitEnergyAve->SetBinContent(i+1,h_ZDCP_EM_RecHitEnergy[i]->GetMean());
730 h_ZDCP_EM_RecHitEnergyAve->SetBinError(i+1,h_ZDCP_EM_RecHitEnergy[i]->GetMeanError());
731 h_ZDCP_EM_Pulse[i]->Scale(10./h_ZDCP_EM_Pulse[i]->GetEntries());
732
733 h_channel_side_charge_Ave->SetBinContent(1,i+1,h_ZDCP_EM_Charge[i]->GetMean());
734 //h_channel_side_charge_Ave->Draw("TEXT");
735 h_channel_side_TSMean_Ave->SetBinContent(1,i+1,h_ZDCP_EM_TSMean[i]->GetMean());
736 //h_channel_side_TSMean_Ave->Draw("TEXT");
737
738 h_ZDCM_EMHAD_TSMeanAve->SetBinContent(i+1,h_ZDCM_EM_TSMean[i]->GetMean());
739 h_ZDCM_EMHAD_TSMeanAve->SetBinError(i+1,h_ZDCM_EM_TSMean[i]->GetMeanError());
740 h_ZDCM_EMHAD_ChargeAve->SetBinContent(i+1,h_ZDCM_EM_Charge[i]->GetMean());
741 h_ZDCM_EMHAD_ChargeAve->SetBinError(i+1,h_ZDCM_EM_Charge[i]->GetMeanError());
742 h_ZDCM_EM_RecHitEnergyAve->SetBinContent(i+1,h_ZDCM_EM_RecHitEnergy[i]->GetMean());
743 h_ZDCM_EM_RecHitEnergyAve->SetBinError(i+1,h_ZDCM_EM_RecHitEnergy[i]->GetMeanError());
744 h_ZDCM_EM_Pulse[i]->Scale(10./h_ZDCM_EM_Pulse[i]->GetEntries());
745
746 h_channel_side_charge_Ave->SetBinContent(2,i+1,h_ZDCM_EM_Charge[i]->GetMean());
747 h_channel_side_TSMean_Ave->SetBinContent(2,i+1,h_ZDCM_EM_TSMean[i]->GetMean());
748 }
749 for(int i = 0; i < 4;++i){
750 h_ZDCP_EMHAD_TSMeanAve->SetBinContent(i+6,h_ZDCP_HAD_TSMean[i]->GetMean());
751 h_ZDCP_EMHAD_TSMeanAve->SetBinError(i+6,h_ZDCP_HAD_TSMean[i]->GetMeanError());
752 h_ZDCP_EMHAD_ChargeAve->SetBinContent(i+6,h_ZDCP_HAD_Charge[i]->GetMean());
753 h_ZDCP_EMHAD_ChargeAve->SetBinError(i+6,h_ZDCP_HAD_Charge[i]->GetMeanError());
754 h_ZDCP_HAD_RecHitEnergyAve->SetBinContent(i+1,h_ZDCP_HAD_RecHitEnergy[i]->GetMean());
755 h_ZDCP_HAD_RecHitEnergyAve->SetBinError(i+1,h_ZDCP_HAD_RecHitEnergy[i]->GetMeanError());
756 h_ZDCP_HAD_Pulse[i]->Scale(10./h_ZDCP_HAD_Pulse[i]->GetEntries());
757
758 h_channel_side_charge_Ave->SetBinContent(1,i+6,h_ZDCP_HAD_Charge[i]->GetMean());
759 h_channel_side_TSMean_Ave->SetBinContent(1,i+6,h_ZDCP_HAD_TSMean[i]->GetMean());
760
761 h_ZDCM_EMHAD_TSMeanAve->SetBinContent(i+6,h_ZDCM_HAD_TSMean[i]->GetMean());
762 h_ZDCM_EMHAD_TSMeanAve->SetBinError(i+6,h_ZDCM_HAD_TSMean[i]->GetMeanError());
763 h_ZDCM_EMHAD_ChargeAve->SetBinContent(i+6,h_ZDCM_HAD_Charge[i]->GetMean());
764 h_ZDCM_EMHAD_ChargeAve->SetBinError(i+6,h_ZDCM_HAD_Charge[i]->GetMeanError());
765 h_ZDCM_HAD_RecHitEnergyAve->SetBinContent(i+1,h_ZDCM_HAD_RecHitEnergy[i]->GetMean());
766 h_ZDCM_HAD_RecHitEnergyAve->SetBinError(i+1,h_ZDCM_HAD_RecHitEnergy[i]->GetMeanError());
767 h_ZDCM_HAD_Pulse[i]->Scale(10./h_ZDCM_HAD_Pulse[i]->GetEntries());
768
769 h_channel_side_charge_Ave->SetBinContent(2,i+6,h_ZDCM_HAD_Charge[i]->GetMean());
770 h_channel_side_TSMean_Ave->SetBinContent(2,i+6,h_ZDCM_HAD_TSMean[i]->GetMean());
771 }
772
773 //h_channel_side_charge_Ave->Draw("TEXT");
774 //h_channel_side_TSMean_Ave->Draw("TEXT");
775
776 if (htmlPrint) htmlOutput();
777
778 }
779
780 void ZDCAnalyzer::htmlOutput(void)
781 {
782
783
784 cout << "Preparing html output ..." << endl;
785
786 char tmp[10];
787
788 if (runBegin != -1)
789 sprintf(tmp, "ZDCBeamSplash_R%09ld_L%ld_%ld", runBegin,lumibegin,lumiend);
790 else
791 sprintf(tmp, "ZDCBeamSplash_R%09d", 0);
792 string htmlDir = baseHtmlDir_ + "/" + tmp + "/";
793
794 system(("/bin/mkdir -p " + htmlDir).c_str());
795
796 std::ofstream htmlFile;
797
798 htmlFile.open((htmlDir + "index.html").c_str());
799
800 // html page header
801 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
802 htmlFile << "<html> " << endl;
803 htmlFile << "<head> " << endl;
804 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
805 htmlFile << " http-equiv=\"content-type\"> " << endl;
806 htmlFile << " <title>ZDC Beam Splash Analysis Output</title> " << endl;
807 htmlFile << "</head> " << endl;
808 htmlFile << "<body> " << endl;
809 htmlFile << "<br> " << endl;
810 htmlFile << "<center><h1>ZDC Beam Splash Analysis Outputs</h1></center>" << endl;
811 htmlFile << "<h2>Authors:&nbsp;(U.&nbsp;of&nbsp;Iowa)&nbsp;S.&nbsp;Sen,&nbsp;T.&nbsp;Yetkin</h2>" << endl;
812 htmlFile << "<h2>Run Number:&nbsp;&nbsp;" << endl;
813 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << runBegin << "</span>" << endl;
814
815 htmlFile << "&nbsp;&nbsp;LS:&nbsp;" << endl;
816 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumibegin << "</span>" << endl;
817
818 htmlFile << "-" << endl;
819 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumiend << "</span>" << endl;
820
821 htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;Time:&nbsp;<span style=\"color: rgb(0, 0, 153);\">" <<
822 startTime << "</span></h2> " << endl;
823 htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;" << endl;
824 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << evtNo << "</span></h2> " << endl;
825 htmlFile << "<hr>" << endl;
826 htmlFile << "<ul>" << endl;
827
828 string htmlName;
829
830 if (doZDCHTML) {
831 htmlName = "ZDC.html";
832 ZDCHTMLOutput(startTime, htmlDir, htmlName);
833 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
834 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">ZDC</a></td>" << endl;
835
836 }
837 htmlFile << "</tr></table>" << endl;
838 htmlFile << "</ul>" << endl;
839
840 // html page footer
841 htmlFile << "</body> " << endl;
842 htmlFile << "</html> " << endl;
843
844 htmlFile.close();
845 cout << "html output done..." << endl;
846 return;
847 }
848
849 void ZDCAnalyzer::ZDCHTMLOutput(string startTime, string htmlDir, string htmlName) {
850 cout << "Preparing html output for " << htmlName << endl;
851
852 ofstream htmlFile;
853
854 htmlFile.open((htmlDir + htmlName).c_str());
855
856 // html page header
857 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
858 htmlFile << "<html> " << endl;
859 htmlFile << "<head> " << endl;
860 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
861 htmlFile << " http-equiv=\"content-type\"> " << endl;
862 htmlFile << " <title>ZDC Plots</title> " << endl;
863 htmlFile << "</head> " << endl;
864 htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << endl;
865 htmlFile << "<body> " << endl;
866 htmlFile << "<br> " << endl;
867 htmlFile << "<h2>Run Number:&nbsp;&nbsp;&nbsp;" << endl;
868 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << runBegin << "</span>" << endl;
869
870 htmlFile << "&nbsp;&nbsp;LS:&nbsp;" << endl;
871 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumibegin << "</span>" << endl;
872
873 htmlFile << "-" << endl;
874 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumiend << "</span>" << endl;
875
876 htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;Time:&nbsp;<span style=\"color: rgb(0, 0, 153);\">" <<
877 startTime << "</span></h2> " << endl;
878 htmlFile << "<h2>Plots from :&nbsp;&nbsp;&nbsp;&nbsp; <span " << endl;
879 htmlFile << " style=\"color: rgb(0, 0, 153);\">ZDC</span></h2> " << endl;
880 htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << endl;
881 htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span " << endl;
882 htmlFile << " style=\"color: rgb(0, 0, 153);\">" << evtNo << "</span></h2>" << endl;
883 // begin table for histograms
884 htmlFile << "<table width=100% border=1><tr>" << endl;
885 htmlFile << "</tr></table>" << endl;
886 htmlFile << "<hr>" << endl;
887
888 htmlFile << "<h2><strong>ZDC&nbsp;Histograms</strong></h2>" << endl;
889 htmlFile << "<h3>" << endl;
890 htmlFile << "<a href=\"#ZDC_Plots\">ZDC Plots </a></br>" << endl;
891 htmlFile << "</h3>" << endl;
892 htmlFile << "<hr>" << endl;
893
894
895 string type = "ZDC";
896 htmlFile << "<tr align=\"left\">" << endl;
897 htmlFile << "<td>&nbsp;&nbsp;&nbsp;<a name=\"" << type << "_Plots\"><h3>" << type << " Histograms</h3></td></tr>" << endl;
898
899 htmlFile << "<tr align=\"left\">" << endl;
900 histoHTML2(h_channel_side_charge_Ave, "", "", 92, htmlFile, htmlDir,true);
901 histoHTML2(h_channel_side_TSMean_Ave, "", "", 92, htmlFile, htmlDir,true);
902 histoHTML(h_bunchXing, "Bunch Xing", "Events", 92, htmlFile, htmlDir);
903 histoHTML(h_BX_after_return, "Bunch Xing", "Events", 92, htmlFile, htmlDir);
904 histoHTML(h_lumiBlock, "Lumi Block", "Events", 92, htmlFile, htmlDir);
905 histoHTML(h_l1_techBit, "L1 Technical Bits", "Events", 92, htmlFile, htmlDir);
906 histoHTML(h_hf_time_difference, "Time (ns)", "Events", 92, htmlFile, htmlDir);
907 //histoHTML(histodeneme, "QIE bins", "bins", 92, htmlFile, htmlDir,false);
908 histoHTML(h_ZDCP_EMHAD_ChargeAve, "ZDCP Channel id", "Ave. Charge (fC)", 92, htmlFile, htmlDir,false);
909 histoHTML(h_ZDCP_EMHAD_TSMeanAve, "ZDCP Channel id", "TS_Mean", 92, htmlFile, htmlDir,false);
910 histoHTML(h_ZDCP_EM_RecHitEnergyAve, "ZDCP EM Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
911 histoHTML(h_ZDCP_HAD_RecHitEnergyAve, "ZDCP HAD Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
912 histoHTML(h_ZDCM_EMHAD_ChargeAve, "ZDCM Channel id", "Ave. Charge (fC)", 92, htmlFile, htmlDir,false);
913 histoHTML(h_ZDCM_EMHAD_TSMeanAve, "ZDCM Channel id", "TS_Mean", 92, htmlFile, htmlDir,false);
914 histoHTML(h_ZDCM_EM_RecHitEnergyAve, "ZDCM EM Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
915 histoHTML(h_ZDCM_HAD_RecHitEnergyAve, "ZDCM HAD Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
916 histoHTML2(h_ZDCP_Charge_Correlation,"Total EM Charge {fC}","Total HAD Charge {fC}",92, htmlFile, htmlDir, false);
917 histoHTML2(h_ZDCP_Charge_CorrelationHAD,"HAD1+HAD2 Charge {fC}","HAD3+HAD4 Charge {fC}",92, htmlFile, htmlDir, false);
918 //histoHTML2(h_ZDCP_Charge_Correlation2,"(Total EM Charge {fC})/5","(Total HAD Charge {fC})/4",92, htmlFile,htmlDir,false);
919 //histoHTML2(h_ZDCP_RecHit_Correlation,"(Total EM RecHit {GeV})/5","(Total HAD RecHit {GeV})/4",92, htmlFile,htmlDir,false);
920 histoHTML(h_ZDCP_EM_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
921 histoHTML(h_ZDCP_EM_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
922 histoHTML(h_ZDCP_EM_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
923 histoHTML(h_ZDCP_EM_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
924 histoHTML(h_ZDCP_EM_Pulse[4], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
925 histoHTML(h_ZDCP_HAD_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
926 histoHTML(h_ZDCP_HAD_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
927 histoHTML(h_ZDCP_HAD_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
928 histoHTML(h_ZDCP_HAD_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
929 histoHTML(h_ZDCP_EM_Charge[0], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
930 histoHTML(h_ZDCP_EM_Charge[1], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
931 histoHTML(h_ZDCP_EM_Charge[2], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
932 histoHTML(h_ZDCP_EM_Charge[3], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
933 histoHTML(h_ZDCP_EM_Charge[4], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
934 histoHTML(h_ZDCP_HAD_Charge[0], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
935 histoHTML(h_ZDCP_HAD_Charge[1], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
936 histoHTML(h_ZDCP_HAD_Charge[2], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
937 histoHTML(h_ZDCP_HAD_Charge[3], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
938 histoHTML(h_ZDCP_EM_RecHitEnergy[0], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
939 histoHTML(h_ZDCP_EM_RecHitEnergy[1], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
940 histoHTML(h_ZDCP_EM_RecHitEnergy[2], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
941 histoHTML(h_ZDCP_EM_RecHitEnergy[3], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
942 histoHTML(h_ZDCP_EM_RecHitEnergy[4], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
943 histoHTML(h_ZDCP_HAD_RecHitEnergy[0], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
944 histoHTML(h_ZDCP_HAD_RecHitEnergy[1], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
945 histoHTML(h_ZDCP_HAD_RecHitEnergy[2], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
946 histoHTML(h_ZDCP_HAD_RecHitEnergy[3], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
947 histoHTML(h_ZDCP_EM_TSMean[0], "ZDCP EM Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
948 histoHTML(h_ZDCP_EM_TSMean[1], "ZDCP EM Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
949 histoHTML(h_ZDCP_EM_TSMean[2], "ZDCP EM Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
950 histoHTML(h_ZDCP_EM_TSMean[3], "ZDCP EM Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
951 histoHTML(h_ZDCP_EM_TSMean[4], "ZDCP EM Channel5 TS Mean", "Events", 92, htmlFile, htmlDir,false);
952 histoHTML(h_ZDCP_HAD_TSMean[0], "ZDCP HAD Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
953 histoHTML(h_ZDCP_HAD_TSMean[1], "ZDCP HAD Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
954 histoHTML(h_ZDCP_HAD_TSMean[2], "ZDCP HAD Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
955 histoHTML(h_ZDCP_HAD_TSMean[3], "ZDCP HAD Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
956
957 histoHTML(h_ZDCM_EM_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
958 histoHTML(h_ZDCM_EM_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
959 histoHTML(h_ZDCM_EM_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
960 histoHTML(h_ZDCM_EM_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
961 histoHTML(h_ZDCM_EM_Pulse[4], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
962 histoHTML(h_ZDCM_HAD_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
963 histoHTML(h_ZDCM_HAD_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
964 histoHTML(h_ZDCM_HAD_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
965 histoHTML(h_ZDCM_HAD_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
966 histoHTML(h_ZDCM_EM_Charge[0], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
967 histoHTML(h_ZDCM_EM_Charge[1], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
968 histoHTML(h_ZDCM_EM_Charge[2], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
969 histoHTML(h_ZDCM_EM_Charge[3], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
970 histoHTML(h_ZDCM_EM_Charge[4], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
971 histoHTML(h_ZDCM_HAD_Charge[0], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
972 histoHTML(h_ZDCM_HAD_Charge[1], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
973 histoHTML(h_ZDCM_HAD_Charge[2], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
974 histoHTML(h_ZDCM_HAD_Charge[3], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
975 histoHTML(h_ZDCM_EM_RecHitEnergy[0], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
976 histoHTML(h_ZDCM_EM_RecHitEnergy[1], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
977 histoHTML(h_ZDCM_EM_RecHitEnergy[2], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
978 histoHTML(h_ZDCM_EM_RecHitEnergy[3], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
979 histoHTML(h_ZDCM_EM_RecHitEnergy[4], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
980 histoHTML(h_ZDCM_HAD_RecHitEnergy[0], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
981 histoHTML(h_ZDCM_HAD_RecHitEnergy[1], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
982 histoHTML(h_ZDCM_HAD_RecHitEnergy[2], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
983 histoHTML(h_ZDCM_HAD_RecHitEnergy[3], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
984 histoHTML(h_ZDCM_EM_TSMean[0], "ZDCM EM Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
985 histoHTML(h_ZDCM_EM_TSMean[1], "ZDCM EM Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
986 histoHTML(h_ZDCM_EM_TSMean[2], "ZDCM EM Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
987 histoHTML(h_ZDCM_EM_TSMean[3], "ZDCM EM Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
988 histoHTML(h_ZDCM_EM_TSMean[4], "ZDCM EM Channel5 TS Mean", "Events", 92, htmlFile, htmlDir,false);
989 histoHTML(h_ZDCM_HAD_TSMean[0], "ZDCM HAD Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
990 histoHTML(h_ZDCM_HAD_TSMean[1], "ZDCM HAD Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
991 histoHTML(h_ZDCM_HAD_TSMean[2], "ZDCM HAD Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
992 histoHTML(h_ZDCM_HAD_TSMean[3], "ZDCM HAD Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
993 htmlFile << "</tr>" << endl;
994 htmlFile << "</table>" << endl;
995 // end table
996 htmlFile << "<br>" << endl;
997
998 // html page footer
999 htmlFile << "</body> " << endl;
1000 htmlFile << "</html> " << endl;
1001 htmlFile.close();
1002 }
1003 void ZDCAnalyzer::histoHTML(TH1F * hist, const char *xlab, const char *ylab, int width, ofstream & htmlFile,
1004 string htmlDir, bool log) {
1005
1006 if (hist != NULL) {
1007 string imgNameTMB = "";
1008
1009 imgNameTMB = getIMG(hist, 1, htmlDir, xlab, ylab,log);
1010 string imgName = "";
1011
1012 imgName = getIMG(hist, 2, htmlDir, xlab, ylab, log);
1013
1014 if (imgName.size() != 0)
1015 htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << endl;
1016 else
1017 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
1018 } else
1019 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
1020 return;
1021 }
1022
1023 void ZDCAnalyzer::histoHTML2(TH2F * hist, const char *xlab, const char *ylab, int width,
1024 ofstream & htmlFile, string htmlDir, bool color, bool log) {
1025 if (hist != NULL) {
1026 string imgNameTMB = "";
1027
1028 imgNameTMB = getIMG2(hist, 1, htmlDir, xlab, ylab, color,log);
1029 string imgName = "";
1030
1031 imgName = getIMG2(hist, 2, htmlDir, xlab, ylab, color,log);
1032 if (imgName.size() != 0)
1033 htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << endl;
1034 else
1035 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
1036 } else
1037 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
1038 return;
1039 }
1040
1041
1042
1043 string ZDCAnalyzer::getIMG(TH1F * hist, int size, string htmlDir, const char *xlab, const char *ylab, bool log) {
1044
1045 if (hist == NULL) {
1046 printf("getIMG: This histo is NULL, %s, %s\n", xlab, ylab);
1047 return "";
1048 }
1049
1050 string name = hist->GetName();
1051
1052 cleanString(name);
1053 char dest[512];
1054
1055 if (runBegin > -1)
1056 sprintf(dest, "%s - Run %ld LS %ld-%ld", name.c_str(), runBegin, lumibegin, lumiend);
1057 else
1058 sprintf(dest, "%s", name.c_str());
1059 // set run generically hist->SetTitle(dest);
1060 string title = dest;
1061
1062 int xwid = 900;
1063 int ywid = 540;
1064
1065 if (size == 1) {
1066 title = title + "_tmb";
1067 xwid = 600;
1068 ywid = 360;
1069 }
1070 TCanvas *can = new TCanvas(dest, dest, xwid, ywid);
1071 if(log){
1072 can->SetLogy();
1073 }
1074
1075 parseString(title);
1076 string outName = title + ".gif";
1077 string saveName = htmlDir + outName;
1078
1079 hist->SetXTitle(xlab);
1080 hist->SetYTitle(ylab);
1081 // if(name.find("h_max",0)!=string::npos){
1082 // hist->Fit("landau");
1083 // }
1084 hist->Draw();
1085
1086 can->SaveAs(saveName.c_str());
1087 delete can;
1088
1089 return outName;
1090 }
1091
1092 string ZDCAnalyzer::getIMG2(TH2F * hist, int size, string htmlDir, const char *xlab, const char *ylab,
1093 bool color, bool log) {
1094
1095 if (hist == NULL) {
1096 printf("getIMG2: This histo is NULL, %s, %s\n", xlab, ylab);
1097 return "";
1098 }
1099
1100 string name = hist->GetName();
1101
1102 cleanString(name);
1103 char dest[512];
1104
1105 if (runBegin > -1)
1106 sprintf(dest, "%s - Run %ld LS %ld-%ld", name.c_str(), runBegin, lumibegin, lumiend);
1107 else
1108 sprintf(dest, "%s", name.c_str());
1109 // set run generically hist->SetTitle(dest);
1110 string title = dest;
1111
1112 int xwid = 900;
1113 int ywid = 540;
1114
1115 if (size == 1) {
1116 title = title + "_tmb";
1117 xwid = 600;
1118 ywid = 360;
1119 }
1120 TCanvas *can = new TCanvas(dest, dest, xwid, ywid);
1121
1122 parseString(title);
1123 string outName = title + ".gif";
1124 string saveName = htmlDir + outName;
1125
1126 hist->SetXTitle(xlab);
1127 hist->SetYTitle(ylab);
1128 if (!color)
1129 hist->Draw();
1130 else {
1131 hist->SetStats(false);
1132 hist->Draw("COLZ");
1133 }
1134 can->SaveAs(saveName.c_str());
1135 delete can;
1136
1137 return outName;
1138 }
1139 void ZDCAnalyzer::cleanString(string & title) {
1140
1141 for (unsigned int i = 0; i < title.size(); i++) {
1142 if (title.substr(i, 6) == " - Run") {
1143 title.replace(i, title.size() - i, "");
1144 }
1145 if (title.substr(i, 4) == "_Run") {
1146 title.replace(i, title.size() - i, "");
1147 }
1148 if (title.substr(i, 5) == "__Run") {
1149 title.replace(i, title.size() - i, "");
1150 }
1151 }
1152 }
1153
1154 void ZDCAnalyzer::parseString(string & title) {
1155
1156 for (unsigned int i = 0; i < title.size(); i++) {
1157 if (title.substr(i, 1) == " ") {
1158 title.replace(i, 1, "_");
1159 }
1160 if (title.substr(i, 1) == "#") {
1161 title.replace(i, 1, "N");
1162 }
1163 if (title.substr(i, 1) == "-") {
1164 title.replace(i, 1, "_");
1165 }
1166 if (title.substr(i, 1) == "&") {
1167 title.replace(i, 1, "_and_");
1168 }
1169 if (title.substr(i, 1) == "(" || title.substr(i, 1) == ")") {
1170 title.replace(i, 1, "_");
1171 }
1172 }
1173
1174 return;
1175 }
1176