ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/ssen/Analyzers/src/ZDCAnalyzer.cc1
Revision: 1.1.1.1 (vendor branch)
Committed: Thu Dec 10 20:05:05 2009 UTC (15 years, 5 months ago) by tyetkin
Branch: INITIAL, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
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
201 hf_time_difference = (PlusTiming - MinusTiming);
202 //hf_time_difference = (timeWeightedEnergy_HFP/sumE_HFP - timeWeightedEnergy_HFM/sumE_HFM);
203 h_hf_time_difference ->Fill(hf_time_difference);
204 h_recHitSum_HFP_Long->Fill(sumE_HFP);
205 h_recHitSum_HFM_Long->Fill(sumE_HFM);
206
207 std::cout << " PlusTiming " << PlusTiming << std::endl;
208 std::cout << " MinusTiming " << MinusTiming << std::endl;
209
210 } //end of HFrechits
211
212 if(hf_time_difference == -999){
213 cout << "WARNING! RECHITS WERE NOT FOUND. NO TIMING INFORMATION" << endl;
214 }
215
216 // We have three conditions need to be flagged.
217
218
219 if (lumi != lumi) luminew = lumi;
220 if (luminew = luminew ) counter1 = 0;
221
222 bool condition1 false;
223 //intime condition1
224 if ( PlusTiming < 15. || PlusTiming > 30.) return;
225 if ( MinusTiming < 15. || MinusTiming > 30.) return;
226
227 if ( PlusTiming > 15. && PlusTiming < 30.) && ( MinusTiming > 15. && MinusTiming < 30. ) {
228 ++counter1;
229 condition = true;
230 }
231
232 // //beam2scr
233 //if ( PlusTiming < 15. || PlusTiming > 30.) return;
234 //if ( MinusTiming < -50. || MinusTiming > 0.) return;
235
236 //beam2halo condition4
237 //if ( PlusTiming < 15. || PlusTiming > 30.) return;
238 //if ( MinusTiming < -90. || MinusTiming > -70.) return;
239
240 // //beam1scr condition3
241 //if ( PlusTiming < -50. || PlusTiming > 0.) return;
242 //if ( MinusTiming < 15. || MinusTiming > 30.) return;
243
244 //beam1halo condition5
245 //if ( PlusTiming < -90. || PlusTiming > -70.) return;
246 //if ( MinusTiming < 15. || MinusTiming > 30.) return;
247
248 cout << " ~~~~THIS EVENT HAS ALREADY BEEN ACCEPTED ! WHAT DO YOU THINK~~~~ ?" << endl;
249
250 //if (fabs(hf_time_difference) > 20) return;
251 //if (hf_time_difference < 30) return;
252 //if (fabs(hf_time_difference) > 300) return;
253 //if (hf_time_difference > 40 || hf_time_difference < 10) return;
254
255 //if (timeWeightedEnergy_HFP/sumE_HFP > 15. && timeWeightedEnergy_HFP/sumE_HFP < 30. )
256
257 //std::cout << " timeWeightedEnergy_HFP/sumE_HFP " << timeWeightedEnergy_HFP/sumE_HFP << std::endl;
258 //std::cout << " timeWeightedEnergy_HFM/sumE_HFM " << timeWeightedEnergy_HFM/sumE_HFM << std::endl;
259
260
261 h_BX_after_return->Fill(iEvent.bunchCrossing());
262 //if (hf_time_difference < 60) return; //only Plus(or minus) outtime events
263
264 edm::Handle<ZDCDigiCollection> zdc_digi_h;
265 iEvent.getByType(zdc_digi_h);
266 const ZDCDigiCollection *zdc_digi = zdc_digi_h.failedToGet()? 0 : &*zdc_digi_h;
267
268 if(zdc_digi){
269 double QEM = 0.;
270 double QEMR = 0.;
271 double QHAD = 0.;
272 double QHAD1 = 0.;
273 double QHAD2 = 0.;
274 double QHADR = 0.;
275 for (ZDCDigiCollection::const_iterator j=zdc_digi->begin();j!=zdc_digi->end(); ++j) {
276 const ZDCDataFrame digi = (const ZDCDataFrame)(*j);
277 int iSide = digi.id().zside();
278 int iSection = digi.id().section();
279 int iChannel = digi.id().channel();
280 //std::cout << "Side= " << iSide << " Section= " << iSection << " Channel= " << iChannel << std::endl;
281 double fSum = 0.;
282 double fData[10] = {-999.};
283 double adcfData[10] = {-999.};
284 int fTS = digi.size();
285 for (int i = 0; i < fTS; ++i) {
286 fData[i] = HFQIEConst*digi[i].nominal_fC();
287 //fData[i] = digi[i].adc();
288 //fData[i] = digi[i].capid();
289 //std::cout << "capsRotation ";
290 // std::cout << fData[i] << std::endl;
291 //std::cout << fData[i] << std::endl;
292 histodeneme->Fill(fData[i],1);
293 }
294
295 if(!isGood(fData, 30, 0.001))continue;
296 double fTSMean = getTime(fData, fSum);
297
298 if(iSection==1){
299
300 if (iSide == -1) h_channel_side_charge->Fill(iSide+2,iChannel-1,fSum);
301 if (iSide == 1) h_channel_side_charge->Fill(iSide-1,iChannel-1,fSum);
302 //h_channel_side_timing->Fill(iSide,iChannel,fTSmean);
303
304 if (iSide ==1 ){
305 for(int i = 0; i < fTS; ++i){
306 h_ZDCP_EM_Pulse[iChannel-1]->Fill(i,fData[i]);
307 }
308 h_ZDCP_EM_Charge[iChannel-1]->Fill(fSum);
309 h_ZDCP_EM_TSMean[iChannel-1]->Fill(fTSMean);
310 //h_channel_side_timing->Fill(iSide+1,iChannel,fTSmean);
311 h_ZDCP_EM_RecHitEnergy[iChannel-1]->Fill(fSum*EMGain);
312
313 QEM += fSum;
314 QEMR += fSum*EMGain;
315 }
316 if (iSide == -1 ){
317 for(int i = 0; i < fTS; ++i){
318 h_ZDCM_EM_Pulse[iChannel-1]->Fill(i,fData[i]);
319 }
320 h_ZDCM_EM_Charge[iChannel-1]->Fill(fSum);
321 h_ZDCM_EM_TSMean[iChannel-1]->Fill(fTSMean);
322 //h_channel_side_timing->Fill(iSide,iChannel,fTSmean);
323 h_ZDCM_EM_RecHitEnergy[iChannel-1]->Fill(fSum*EMGain);
324 //if (iChannel==1) std::cout << iEvent.id() << << ". TS" << i << "\t" << "Charge " << fData[i] << std::endl;
325 }
326 }
327 if(iSection==2){
328
329 if (iSide == -1) h_channel_side_charge->Fill(iSide+2,iChannel+4,fSum);
330 if (iSide == 1) h_channel_side_charge->Fill(iSide-1,iChannel+4,fSum);
331 //h_channel_side_timing->Fill(iSide,iChannel+5,fTSmean);
332
333 if (iSide == 1 ){
334 for(int i = 0; i < fTS; ++i){
335 h_ZDCP_HAD_Pulse[iChannel-1]->Fill(i,fData[i]);}
336 h_ZDCP_HAD_Charge[iChannel-1]->Fill(fSum);
337 h_ZDCP_HAD_TSMean[iChannel-1]->Fill(fTSMean);
338 //h_channel_side_timing->Fill(iSide+1,iChannel+5,fTSmean);
339 h_ZDCP_HAD_RecHitEnergy[iChannel-1]->Fill(fSum*HADGain);
340 QHAD += fSum;
341 if (iChannel == 1 || iChannel ==2) QHAD1 += fSum;
342 if (iChannel == 3 || iChannel ==4) QHAD2 += fSum;
343 QHADR += fSum*HADGain;
344 if (QHAD > 10000) std::cout << "~~~~~~~~~~~~~~~"
345 << "###############"
346 << " Event Number " << event << " lumi = " << lumi << " BX = " << iEvent.bunchCrossing() << std::endl;
347 }
348 if (iSide == -1 ){
349 for(int i = 0; i < fTS; ++i){
350 h_ZDCM_HAD_Pulse[iChannel-1]->Fill(i,fData[i]);}
351 h_ZDCM_HAD_Charge[iChannel-1]->Fill(fSum);
352 h_ZDCM_HAD_TSMean[iChannel-1]->Fill(fTSMean);
353 //h_channel_side_timing->Fill(iSide,iChannel+5,fTSmean);
354 h_ZDCM_HAD_RecHitEnergy[iChannel-1]->Fill(fSum*HADGain);
355 }
356 }
357 }
358 h_ZDCP_Charge_Correlation->Fill(QEM, QHAD);
359 h_ZDCP_Charge_CorrelationHAD->Fill(QHAD1, QHAD2);
360 //h_ZDCP_Charge_Correlation2->Fill(QEM/5, QHAD/4);
361 //h_ZDCP_RecHit_Correlation->Fill(QEMR, QHADR);
362 }
363 }
364
365 void ZDCAnalyzer::beginJob(const edm::EventSetup& iSetup){
366 // iSetup.get<HcalDbRecord>().get(conditions);
367 TFileDirectory ZDCDir = mFileServer->mkdir("ZDC");
368 char title[128];
369 char name[128];
370 for(int i = 0; i < 4;++i){
371 // pulse Plus Side
372 sprintf(title,"h_ZDCP_HADChan_%i_Pulse",i+1);
373 sprintf(name,"ZDC Plus HAD Section Pulse for channel %i",i+1);
374 h_ZDCP_HAD_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
375 h_ZDCP_HAD_Pulse[i]->SetFillColor(kBlue);
376 //integrated charge over 10 time samples
377 sprintf(title,"h_ZDCP_HADChan_%i_Charge",i+1);
378 sprintf(name,"ZDC Plus HAD Section Charge for channel %i",i+1);
379 h_ZDCP_HAD_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
380 h_ZDCP_HAD_Charge[i]->SetFillColor(kBlue);
381 //charge weighted time slice
382 sprintf(title,"h_ZDCP_HADChan_%i_TSMean",i+1);
383 sprintf(name,"ZDC Plus HAD Section TSMean for channel %i",i+1);
384 h_ZDCP_HAD_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
385 h_ZDCP_HAD_TSMean[i]->SetFillColor(kBlue);
386 //RecHit for HAD sections
387 sprintf(title,"h_ZDCP_HADChan_%i_RecHit_Energy",i+1);
388 sprintf(name,"ZDC Plus HAD Section Rechit Energy for channel %i",i+1);
389 h_ZDCP_HAD_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
390 h_ZDCP_HAD_RecHitEnergy[i]->SetFillColor(kRed);
391
392 // pulse Minus Side
393 sprintf(title,"h_ZDCM_HADChan_%i_Pulse",i+1);
394 sprintf(name,"ZDC Minus HAD Section Pulse for channel %i",i+1);
395 h_ZDCM_HAD_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
396 h_ZDCM_HAD_Pulse[i]->SetFillColor(7);
397 //integrated charge over 10 time samples
398 sprintf(title,"h_ZDCM_HADChan_%i_Charge",i+1);
399 sprintf(name,"ZDC Minus HAD Section Charge for channel %i",i+1);
400 h_ZDCM_HAD_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
401 h_ZDCM_HAD_Charge[i]->SetFillColor(7);
402 //charge weighted time slice
403 sprintf(title,"h_ZDCM_HADChan_%i_TSMean",i+1);
404 sprintf(name,"ZDC Minus HAD Section TSMean for channel %i",i+1);
405 h_ZDCM_HAD_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
406 h_ZDCM_HAD_TSMean[i]->SetFillColor(7);
407 //RecHit for HAD sections
408 sprintf(title,"h_ZDCM_HADChan_%i_RecHit_Energy",i+1);
409 sprintf(name,"ZDC Minus HAD Section Rechit Energy for channel %i",i+1);
410 h_ZDCM_HAD_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10.,30000.);
411 h_ZDCM_HAD_RecHitEnergy[i]->SetFillColor(kRed);
412 }
413 for(int i = 0; i < 5;++i){
414 // pulse Plus Side
415 sprintf(title,"h_ZDCP_EMChan_%i_Pulse",i+1);
416 sprintf(name,"ZDC Plus EM Section Pulse for channel %i",i+1);
417 h_ZDCP_EM_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
418 h_ZDCP_EM_Pulse[i]->SetFillColor(kBlue);
419 //integrated charge over 10 time samples
420 sprintf(title,"h_ZDCP_EMChan_%i_Charge",i+1);
421 sprintf(name,"ZDC Plus EM Section Charge for channel %i",i+1);
422 h_ZDCP_EM_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
423 h_ZDCP_EM_Charge[i]->SetFillColor(kBlue);
424 //charge weighted time slice
425 sprintf(title,"h_ZDCP_EMChan_%i_TSMean",i+1);
426 sprintf(name,"ZDC Plus EM Section TSMean for channel %i",i+1);
427 h_ZDCP_EM_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
428 h_ZDCP_EM_TSMean[i]->SetFillColor(kBlue);
429 //RecHit for EM sections
430 sprintf(title,"h_ZDCP_EMChan_%i_RecHit_Energy",i+1);
431 sprintf(name,"ZDC Plus EM Section Rechit Energy for channel %i",i+1);
432 h_ZDCP_EM_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
433 h_ZDCP_EM_RecHitEnergy[i]->SetFillColor(kRed);
434
435 // pulse Minus Side
436 sprintf(title,"h_ZDCM_EMChan_%i_Pulse",i+1);
437 sprintf(name,"ZDC Minus EM Section Pulse for channel %i",i+1);
438 h_ZDCM_EM_Pulse[i] = book1DHistogram(ZDCDir,title, name, 10, -0.5, 9.5);
439 h_ZDCM_EM_Pulse[i]->SetFillColor(7);
440 //integrated charge over 10 time samples
441 sprintf(title,"h_ZDCM_EMChan_%i_Charge",i+1);
442 sprintf(name,"ZDC Minus EM Section Charge for channel %i",i+1);
443 h_ZDCM_EM_Charge[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
444 h_ZDCM_EM_Charge[i]->SetFillColor(7);
445 //charge weighted time slice
446 sprintf(title,"h_ZDCM_EMChan_%i_TSMean",i+1);
447 sprintf(name,"ZDC Minus EM Section TSMean for channel %i",i+1);
448 h_ZDCM_EM_TSMean[i] = book1DHistogram(ZDCDir,title, name, 100, -0.5, 9.5);
449 h_ZDCM_EM_TSMean[i]->SetFillColor(7);
450 //RecHit for EM sections
451 sprintf(title,"h_ZDCM_EMChan_%i_RecHit_Energy",i+1);
452 sprintf(name,"ZDC Minus EM Section Rechit Energy for channel %i",i+1);
453 h_ZDCM_EM_RecHitEnergy[i] = book1DHistogram(ZDCDir,title, name, 1000, -10., 30000.);
454 h_ZDCM_EM_RecHitEnergy[i]->SetFillColor(kRed);
455 }
456
457 h_l1_techBit = book1DHistogram(ZDCDir,"h_l1_techBit", "L1 Global Technical Trigger Bits", 128, -0.5, 127.5);
458
459 h_recHitSum_HFP_Long = book1DHistogram(ZDCDir,"h_recHitSum_HFP", "HFP RecHit Sum", 100, -10., 1000.);
460 h_recHitSum_HFM_Long = book1DHistogram(ZDCDir,"h_recHitSum_HFM", "HFM RecHit Sum", 100, -10., 1000.);
461 h_hf_time_difference = book1DHistogram(ZDCDir,"HF_time_difference", "HFP_L sum(E*Time)/sumE - HFM_L sum(E*Time)/sumE", 100, -100., 100.);
462
463 h_channel_side_charge = book2DHistogram(ZDCDir,"charge", "Occup. charge", 2,0,2,9,0,9);
464 h_channel_side_timing = book2DHistogram(ZDCDir,"timing", "Occup. timing", 2,0,2,9,0,9);
465
466 h_channel_side_charge->GetXaxis()->SetBinLabel(1,"ZDC+");
467 h_channel_side_charge->GetXaxis()->SetBinLabel(2,"ZDC-");
468 h_channel_side_timing->GetXaxis()->SetBinLabel(1,"ZDC+");
469 h_channel_side_timing->GetXaxis()->SetBinLabel(2,"ZDC-");
470
471 h_channel_side_charge->GetYaxis()->SetBinLabel(1,"EM1");
472 h_channel_side_charge->GetYaxis()->SetBinLabel(2,"EM2");
473 h_channel_side_charge->GetYaxis()->SetBinLabel(3,"EM3");
474 h_channel_side_charge->GetYaxis()->SetBinLabel(4,"EM4");
475 h_channel_side_charge->GetYaxis()->SetBinLabel(5,"EM5");
476 h_channel_side_charge->GetYaxis()->SetBinLabel(6,"HAD1");
477 h_channel_side_charge->GetYaxis()->SetBinLabel(7,"HAD2");
478 h_channel_side_charge->GetYaxis()->SetBinLabel(8,"HAD3");
479 h_channel_side_charge->GetYaxis()->SetBinLabel(9,"HAD4");
480
481 h_channel_side_timing->GetYaxis()->SetBinLabel(1,"EM1");
482 h_channel_side_timing->GetYaxis()->SetBinLabel(2,"EM2");
483 h_channel_side_timing->GetYaxis()->SetBinLabel(3,"EM3");
484 h_channel_side_timing->GetYaxis()->SetBinLabel(4,"EM4");
485 h_channel_side_timing->GetYaxis()->SetBinLabel(5,"EM5");
486 h_channel_side_timing->GetYaxis()->SetBinLabel(6,"HAD1");
487 h_channel_side_timing->GetYaxis()->SetBinLabel(7,"HAD2");
488 h_channel_side_timing->GetYaxis()->SetBinLabel(8,"HAD3");
489 h_channel_side_timing->GetYaxis()->SetBinLabel(9,"HAD4");
490
491
492 h_channel_side_charge_Ave = book2DHistogram(ZDCDir,"charge_Ave", "Occup. charge_Ave", 2,0,2,9,0,9);
493
494 //h_channel_side_charge_Ave->Draw("TEXT");
495
496 h_channel_side_charge_Ave->GetXaxis()->SetBinLabel(1,"ZDC+");
497 h_channel_side_charge_Ave->GetXaxis()->SetBinLabel(2,"ZDC-");
498
499 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(1,"EM1");
500 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(2,"EM2");
501 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(3,"EM3");
502 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(4,"EM4");
503 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(5,"EM5");
504 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(6,"HAD1");
505 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(7,"HAD2");
506 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(8,"HAD3");
507 h_channel_side_charge_Ave->GetYaxis()->SetBinLabel(9,"HAD4");
508
509 h_channel_side_TSMean_Ave = book2DHistogram(ZDCDir,"TSMean_Ave", "Occup. TSMean_Ave", 2,0,2,9,0,9);
510
511 h_channel_side_TSMean_Ave->GetXaxis()->SetBinLabel(1,"ZDC+");
512 h_channel_side_TSMean_Ave->GetXaxis()->SetBinLabel(2,"ZDC-");
513
514 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(1,"EM1");
515 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(2,"EM2");
516 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(3,"EM3");
517 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(4,"EM4");
518 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(5,"EM5");
519 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(6,"HAD1");
520 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(7,"HAD2");
521 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(8,"HAD3");
522 h_channel_side_TSMean_Ave->GetYaxis()->SetBinLabel(9,"HAD4");
523
524 h_bunchXing = book1DHistogram(ZDCDir,"h_bunchXing", "BX distribution", 3565, -0.5, 3563.5);
525 h_lumiBlock = book1DHistogram(ZDCDir,"h_lumiBlock", "Lumi Blocks", 300, -0.5, 295.5);
526 histodeneme = book1DHistogram(ZDCDir,"histodeneme", "QIE Bins", 128, -0.5, 127.5);
527 h_bunchXing->SetFillColor(kBlue);
528 h_lumiBlock->SetFillColor(kBlue);
529 histodeneme->SetFillColor(kBlue);
530 h_BX_before_return = book1DHistogram(ZDCDir,"h_BX_before", "BX distribution", 3565, -0.5, 3563.5);
531 h_BX_after_return = book1DHistogram(ZDCDir,"h_BX_after", "BX distribution for nonIP5 Events", 3565, -0.5, 3563.5);
532
533 h_ZDCP_EM_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCP_EM_RecHitEnergyAve", "ZDC Plus EM Section RecHitEnergyAve", 5, -0.5, 4.5);
534 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"+EM1");
535 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"+EM2");
536 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"+EM3");
537 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"+EM4");
538 h_ZDCP_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(5,"+EM5");
539 h_ZDCP_HAD_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCP_HAD_RecHitEnergyAve", "ZDC Plus HAD Section RecHitEnergyAve", 4, -0.5, 3.5);
540 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"+HAD1");
541 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"+HAD2");
542 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"+HAD3");
543 h_ZDCP_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"+HAD4");
544
545 h_ZDCP_EMHAD_ChargeAve = book1DHistogram(ZDCDir,"h_ZDCP_EMHAD_ChargeAve", "ZDC Plus ChargeAve", 9, -0.5, 8.5);
546 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(1,"+EM1");
547 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(2,"+EM2");
548 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(3,"+EM3");
549 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(4,"+EM4");
550 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(5,"+EM5");
551 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(6,"+HAD1");
552 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(7,"+HAD2");
553 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(8,"+HAD3");
554 h_ZDCP_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(9,"+HAD4");
555
556 //setZDClabels(h_ZDCP_EMHAD_TSMeanAve);
557 h_ZDCP_EMHAD_TSMeanAve = book1DHistogram(ZDCDir,"h_ZDCP_EMHAD_TSMeanAve", "ZDC Plus Timing", 9, -0.5, 8.5);
558 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(1,"+EM1");
559 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(2,"+EM2");
560 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(3,"+EM3");
561 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(4,"+EM4");
562 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(5,"+EM5");
563 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(6,"+HAD1");
564 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(7,"+HAD2");
565 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(8,"+HAD3");
566 h_ZDCP_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(9,"+HAD4");
567
568 h_ZDCP_Charge_Correlation = book2DHistogram(ZDCDir,"h_ZDCP_Charge_Correlation","ZDC Plus Charge Correlation",120,0.,1200.,120,0.,1200.);
569 //h_ZDCP_Charge_Correlation2 = book2DHistogram(ZDCDir,"h_ZDCP_Charge_Correlation2","ZDCP Charge Correlation2",100,-10.,1000.,100,-10.,1000.);
570 //h_ZDCP_RecHit_Correlation = book2DHistogram(ZDCDir,"h_ZDCP_RecHit_Correlation","ZDCP RecHit Correlation",,0.,1000.,1000,0.,20000.);
571 h_ZDCP_Charge_CorrelationHAD = book2DHistogram(ZDCDir,"h_ZDCP_Charge_CorrelationHAD","ZDC Plus Charge CorrelationHAD",100,0.,600.,100,0.,600.);
572
573 h_ZDCP_EM_RecHitEnergyAve->Sumw2();
574 h_ZDCP_HAD_RecHitEnergyAve->Sumw2();
575 h_ZDCP_EMHAD_ChargeAve->Sumw2();
576 h_ZDCP_EMHAD_TSMeanAve->Sumw2();
577
578 h_ZDCP_EM_RecHitEnergyAve->SetFillColor(kRed);
579 h_ZDCP_HAD_RecHitEnergyAve->SetFillColor(kRed);
580 h_ZDCP_EMHAD_TSMeanAve->SetFillColor(kRed);
581 h_ZDCP_Charge_Correlation->SetMarkerColor(kBlue);
582 h_ZDCP_Charge_Correlation->SetMarkerStyle(kFullTriangleUp);
583 //h_ZDCP_Charge_Correlation2->SetMarkerColor(kRed);
584 //h_ZDCP_Charge_Correlation2->SetMarkerStyle(kFullTriangleUp);
585 //h_ZDCP_RecHit_Correlation->SetMarkerColor(kRed);
586 //h_ZDCP_RecHit_Correlation->SetMarkerStyle(kFullTriangleDown);
587 h_ZDCP_Charge_CorrelationHAD->SetMarkerColor(kRed);
588 h_ZDCP_Charge_CorrelationHAD->SetMarkerStyle(kFullTriangleUp);
589
590 // Minus Side Histograms
591
592 h_ZDCM_EM_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCM_EM_RecHitEnergyAve", "ZDC Minus EM Section RecHitEnergyAve", 5, -0.5, 4.5);
593 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"-EM1");
594 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"-EM2");
595 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"-EM3");
596 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"-EM4");
597 h_ZDCM_EM_RecHitEnergyAve->GetXaxis()->SetBinLabel(5,"-EM5");
598 h_ZDCM_HAD_RecHitEnergyAve = book1DHistogram(ZDCDir,"h_ZDCM_HAD_RecHitEnergyAve", "ZDC Minus HAD Section RecHitEnergyAve", 4, -0.5, 3.5);
599 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(1,"-HAD1");
600 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(2,"-HAD2");
601 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(3,"-HAD3");
602 h_ZDCM_HAD_RecHitEnergyAve->GetXaxis()->SetBinLabel(4,"-HAD4");
603
604 h_ZDCM_EMHAD_ChargeAve = book1DHistogram(ZDCDir,"h_ZDCM_EMHAD_ChargeAve", "ZDC Minus ChargeAve", 9, -0.5, 8.5);
605 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(1,"-EM1");
606 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(2,"-EM2");
607 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(3,"-EM3");
608 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(4,"-EM4");
609 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(5,"-EM5");
610 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(6,"-HAD1");
611 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(7,"-HAD2");
612 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(8,"-HAD3");
613 h_ZDCM_EMHAD_ChargeAve->GetXaxis()->SetBinLabel(9,"-HAD4");
614
615 h_ZDCM_EMHAD_TSMeanAve = book1DHistogram(ZDCDir,"h_ZDCM_EMHAD_TSMeanAve", "ZDC Minus Timing", 9, -0.5, 8.5);
616 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(1,"-EM1");
617 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(2,"-EM2");
618 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(3,"-EM3");
619 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(4,"-EM4");
620 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(5,"-EM5");
621 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(6,"-HAD1");
622 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(7,"-HAD2");
623 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(8,"-HAD3");
624 h_ZDCM_EMHAD_TSMeanAve->GetXaxis()->SetBinLabel(9,"-HAD4");
625
626 h_ZDCM_EM_RecHitEnergyAve->Sumw2();
627 h_ZDCM_HAD_RecHitEnergyAve->Sumw2();
628 h_ZDCM_EMHAD_ChargeAve->Sumw2();
629 h_ZDCM_EMHAD_TSMeanAve->Sumw2();
630 h_ZDCM_EM_RecHitEnergyAve->SetFillColor(kRed);
631 h_ZDCM_HAD_RecHitEnergyAve->SetFillColor(kRed);
632 h_ZDCM_EMHAD_TSMeanAve->SetFillColor(kRed);
633 }
634
635 //exact copy from http://cmslxr.fnal.gov/lxr/source/DQM/HcalMonitorModule/src/HcalTimingMonitorModule.cc#100
636 bool ZDCAnalyzer::isGood(double fData[10], double fCut, double fPercentage){
637 bool dec = false;
638 int n = 10;
639 int ts_max=-1; double max=-100;
640 ts_max = getTSMax(fData,10);
641 if(ts_max==0 || ts_max==(n-1)) return false;
642 float sum = fData[ts_max-1] + fData[ts_max+1];
643 //cout << "tsMax " << ts_max << " data[tsmax] " << mData[ts_max] << " sum " << sum << endl;
644 if(fData[ts_max] > fCut && sum > (fData[ts_max]*fPercentage)) dec = true;
645 return dec;
646 }
647
648
649 int ZDCAnalyzer::getTSMax(double fData[10], int fTS)
650 {
651 int ts_max = -100;
652 double max = -9999.;
653 for(int j = 0; j < fTS; ++j){
654 if(max < fData[j]){
655 max = fData[j];
656 ts_max = j;
657 }
658 }
659 return ts_max;
660 }
661 double ZDCAnalyzer::getTime(double fData[10], double& fSum){
662 int n = 10;
663 int ts_max = getTSMax(fData,10);
664 double Time=0,SumT=0; //,MaxT=-10;
665 if (ts_max>=0){
666 Time = ts_max*fData[ts_max];
667 SumT = fData[ts_max];
668 if(ts_max>0){
669 Time += (ts_max-1)*fData[ts_max-1];
670 SumT += fData[ts_max-1];
671 }
672 if(ts_max<(n-1)){
673 Time += (ts_max+1)*fData[ts_max+1];
674 SumT += fData[ts_max+1];
675 }
676 Time=Time/SumT;
677 }
678 if (SumT > 0.) fSum = SumT;
679
680 return Time;
681 }
682 TH1F *ZDCAnalyzer::book1DHistogram(TFileDirectory & fDir, const std::string & fName, const std::string & fTitle,
683 int fNbins, double fXmin, double fXmax) const {
684 char title[1024];
685 sprintf(title, "%s [RUN:%i]", fTitle.c_str(), Runno);
686 return fDir.make < TH1F > (fName.c_str(), title, fNbins, fXmin, fXmax);
687 }
688 TH2F *ZDCAnalyzer::book2DHistogram(TFileDirectory & fDir, const std::string & fName, const std::string & fTitle,
689 int fNbinsX, double fXmin, double fXmax, int fNbinsY, double fYmin, double fYmax) const {
690 char title[1024];
691 sprintf(title, "%s [RUN:%i]", fTitle.c_str(), Runno);
692 return fDir.make < TH2F > (fName.c_str(), title, fNbinsX, fXmin, fXmax, fNbinsY, fYmin, fYmax);
693 }
694
695 void ZDCAnalyzer::endJob() {
696 for(int i = 0; i < 5;++i){
697 h_ZDCP_EMHAD_TSMeanAve->SetBinContent(i+1,h_ZDCP_EM_TSMean[i]->GetMean());
698 h_ZDCP_EMHAD_TSMeanAve->SetBinError(i+1,h_ZDCP_EM_TSMean[i]->GetMeanError());
699 h_ZDCP_EMHAD_ChargeAve->SetBinContent(i+1,h_ZDCP_EM_Charge[i]->GetMean());
700 h_ZDCP_EMHAD_ChargeAve->SetBinError(i+1,h_ZDCP_EM_Charge[i]->GetMeanError());
701 h_ZDCP_EM_RecHitEnergyAve->SetBinContent(i+1,h_ZDCP_EM_RecHitEnergy[i]->GetMean());
702 h_ZDCP_EM_RecHitEnergyAve->SetBinError(i+1,h_ZDCP_EM_RecHitEnergy[i]->GetMeanError());
703 h_ZDCP_EM_Pulse[i]->Scale(10./h_ZDCP_EM_Pulse[i]->GetEntries());
704
705 h_channel_side_charge_Ave->SetBinContent(1,i+1,h_ZDCP_EM_Charge[i]->GetMean());
706 //h_channel_side_charge_Ave->Draw("TEXT");
707 h_channel_side_TSMean_Ave->SetBinContent(1,i+1,h_ZDCP_EM_TSMean[i]->GetMean());
708 //h_channel_side_TSMean_Ave->Draw("TEXT");
709
710 h_ZDCM_EMHAD_TSMeanAve->SetBinContent(i+1,h_ZDCM_EM_TSMean[i]->GetMean());
711 h_ZDCM_EMHAD_TSMeanAve->SetBinError(i+1,h_ZDCM_EM_TSMean[i]->GetMeanError());
712 h_ZDCM_EMHAD_ChargeAve->SetBinContent(i+1,h_ZDCM_EM_Charge[i]->GetMean());
713 h_ZDCM_EMHAD_ChargeAve->SetBinError(i+1,h_ZDCM_EM_Charge[i]->GetMeanError());
714 h_ZDCM_EM_RecHitEnergyAve->SetBinContent(i+1,h_ZDCM_EM_RecHitEnergy[i]->GetMean());
715 h_ZDCM_EM_RecHitEnergyAve->SetBinError(i+1,h_ZDCM_EM_RecHitEnergy[i]->GetMeanError());
716 h_ZDCM_EM_Pulse[i]->Scale(10./h_ZDCM_EM_Pulse[i]->GetEntries());
717
718 h_channel_side_charge_Ave->SetBinContent(2,i+1,h_ZDCM_EM_Charge[i]->GetMean());
719 h_channel_side_TSMean_Ave->SetBinContent(2,i+1,h_ZDCM_EM_TSMean[i]->GetMean());
720 }
721 for(int i = 0; i < 4;++i){
722 h_ZDCP_EMHAD_TSMeanAve->SetBinContent(i+6,h_ZDCP_HAD_TSMean[i]->GetMean());
723 h_ZDCP_EMHAD_TSMeanAve->SetBinError(i+6,h_ZDCP_HAD_TSMean[i]->GetMeanError());
724 h_ZDCP_EMHAD_ChargeAve->SetBinContent(i+6,h_ZDCP_HAD_Charge[i]->GetMean());
725 h_ZDCP_EMHAD_ChargeAve->SetBinError(i+6,h_ZDCP_HAD_Charge[i]->GetMeanError());
726 h_ZDCP_HAD_RecHitEnergyAve->SetBinContent(i+1,h_ZDCP_HAD_RecHitEnergy[i]->GetMean());
727 h_ZDCP_HAD_RecHitEnergyAve->SetBinError(i+1,h_ZDCP_HAD_RecHitEnergy[i]->GetMeanError());
728 h_ZDCP_HAD_Pulse[i]->Scale(10./h_ZDCP_HAD_Pulse[i]->GetEntries());
729
730 h_channel_side_charge_Ave->SetBinContent(1,i+6,h_ZDCP_HAD_Charge[i]->GetMean());
731 h_channel_side_TSMean_Ave->SetBinContent(1,i+6,h_ZDCP_HAD_TSMean[i]->GetMean());
732
733 h_ZDCM_EMHAD_TSMeanAve->SetBinContent(i+6,h_ZDCM_HAD_TSMean[i]->GetMean());
734 h_ZDCM_EMHAD_TSMeanAve->SetBinError(i+6,h_ZDCM_HAD_TSMean[i]->GetMeanError());
735 h_ZDCM_EMHAD_ChargeAve->SetBinContent(i+6,h_ZDCM_HAD_Charge[i]->GetMean());
736 h_ZDCM_EMHAD_ChargeAve->SetBinError(i+6,h_ZDCM_HAD_Charge[i]->GetMeanError());
737 h_ZDCM_HAD_RecHitEnergyAve->SetBinContent(i+1,h_ZDCM_HAD_RecHitEnergy[i]->GetMean());
738 h_ZDCM_HAD_RecHitEnergyAve->SetBinError(i+1,h_ZDCM_HAD_RecHitEnergy[i]->GetMeanError());
739 h_ZDCM_HAD_Pulse[i]->Scale(10./h_ZDCM_HAD_Pulse[i]->GetEntries());
740
741 h_channel_side_charge_Ave->SetBinContent(2,i+6,h_ZDCM_HAD_Charge[i]->GetMean());
742 h_channel_side_TSMean_Ave->SetBinContent(2,i+6,h_ZDCM_HAD_TSMean[i]->GetMean());
743 }
744
745 //h_channel_side_charge_Ave->Draw("TEXT");
746 //h_channel_side_TSMean_Ave->Draw("TEXT");
747
748 if (htmlPrint) htmlOutput();
749
750 }
751
752 void ZDCAnalyzer::htmlOutput(void)
753 {
754
755
756 cout << "Preparing html output ..." << endl;
757
758 char tmp[10];
759
760 if (runBegin != -1)
761 sprintf(tmp, "ZDCBeamSplash_R%09ld_L%ld_%ld", runBegin,lumibegin,lumiend);
762 else
763 sprintf(tmp, "ZDCBeamSplash_R%09d", 0);
764 string htmlDir = baseHtmlDir_ + "/" + tmp + "/";
765
766 system(("/bin/mkdir -p " + htmlDir).c_str());
767
768 std::ofstream htmlFile;
769
770 htmlFile.open((htmlDir + "index.html").c_str());
771
772 // html page header
773 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
774 htmlFile << "<html> " << endl;
775 htmlFile << "<head> " << endl;
776 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
777 htmlFile << " http-equiv=\"content-type\"> " << endl;
778 htmlFile << " <title>ZDC Beam Splash Analysis Output</title> " << endl;
779 htmlFile << "</head> " << endl;
780 htmlFile << "<body> " << endl;
781 htmlFile << "<br> " << endl;
782 htmlFile << "<center><h1>ZDC Beam Splash Analysis Outputs</h1></center>" << endl;
783 htmlFile << "<h2>Authors:&nbsp;(U.&nbsp;of&nbsp;Iowa)&nbsp;S.&nbsp;Sen,&nbsp;T.&nbsp;Yetkin</h2>" << endl;
784 htmlFile << "<h2>Run Number:&nbsp;&nbsp;" << endl;
785 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << runBegin << "</span>" << endl;
786
787 htmlFile << "&nbsp;&nbsp;LS:&nbsp;" << endl;
788 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumibegin << "</span>" << endl;
789
790 htmlFile << "-" << endl;
791 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumiend << "</span>" << endl;
792
793 htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;Time:&nbsp;<span style=\"color: rgb(0, 0, 153);\">" <<
794 startTime << "</span></h2> " << endl;
795 htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;" << endl;
796 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << evtNo << "</span></h2> " << endl;
797 htmlFile << "<hr>" << endl;
798 htmlFile << "<ul>" << endl;
799
800 string htmlName;
801
802 if (doZDCHTML) {
803 htmlName = "ZDC.html";
804 ZDCHTMLOutput(startTime, htmlDir, htmlName);
805 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
806 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">ZDC</a></td>" << endl;
807
808 }
809 htmlFile << "</tr></table>" << endl;
810 htmlFile << "</ul>" << endl;
811
812 // html page footer
813 htmlFile << "</body> " << endl;
814 htmlFile << "</html> " << endl;
815
816 htmlFile.close();
817 cout << "html output done..." << endl;
818 return;
819 }
820
821 void ZDCAnalyzer::ZDCHTMLOutput(string startTime, string htmlDir, string htmlName) {
822 cout << "Preparing html output for " << htmlName << endl;
823
824 ofstream htmlFile;
825
826 htmlFile.open((htmlDir + htmlName).c_str());
827
828 // html page header
829 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
830 htmlFile << "<html> " << endl;
831 htmlFile << "<head> " << endl;
832 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
833 htmlFile << " http-equiv=\"content-type\"> " << endl;
834 htmlFile << " <title>ZDC Plots</title> " << endl;
835 htmlFile << "</head> " << endl;
836 htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << endl;
837 htmlFile << "<body> " << endl;
838 htmlFile << "<br> " << endl;
839 htmlFile << "<h2>Run Number:&nbsp;&nbsp;&nbsp;" << endl;
840 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << runBegin << "</span>" << endl;
841
842 htmlFile << "&nbsp;&nbsp;LS:&nbsp;" << endl;
843 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumibegin << "</span>" << endl;
844
845 htmlFile << "-" << endl;
846 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << lumiend << "</span>" << endl;
847
848 htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;Time:&nbsp;<span style=\"color: rgb(0, 0, 153);\">" <<
849 startTime << "</span></h2> " << endl;
850 htmlFile << "<h2>Plots from :&nbsp;&nbsp;&nbsp;&nbsp; <span " << endl;
851 htmlFile << " style=\"color: rgb(0, 0, 153);\">ZDC</span></h2> " << endl;
852 htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << endl;
853 htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span " << endl;
854 htmlFile << " style=\"color: rgb(0, 0, 153);\">" << evtNo << "</span></h2>" << endl;
855 // begin table for histograms
856 htmlFile << "<table width=100% border=1><tr>" << endl;
857 htmlFile << "</tr></table>" << endl;
858 htmlFile << "<hr>" << endl;
859
860 htmlFile << "<h2><strong>ZDC&nbsp;Histograms</strong></h2>" << endl;
861 htmlFile << "<h3>" << endl;
862 htmlFile << "<a href=\"#ZDC_Plots\">ZDC Plots </a></br>" << endl;
863 htmlFile << "</h3>" << endl;
864 htmlFile << "<hr>" << endl;
865
866
867 string type = "ZDC";
868 htmlFile << "<tr align=\"left\">" << endl;
869 htmlFile << "<td>&nbsp;&nbsp;&nbsp;<a name=\"" << type << "_Plots\"><h3>" << type << " Histograms</h3></td></tr>" << endl;
870
871 htmlFile << "<tr align=\"left\">" << endl;
872 histoHTML2(h_channel_side_charge_Ave, "", "", 92, htmlFile, htmlDir,true);
873 histoHTML2(h_channel_side_TSMean_Ave, "", "", 92, htmlFile, htmlDir,true);
874 histoHTML(h_bunchXing, "Bunch Xing", "Events", 92, htmlFile, htmlDir);
875 histoHTML(h_BX_after_return, "Bunch Xing", "Events", 92, htmlFile, htmlDir);
876 histoHTML(h_lumiBlock, "Lumi Block", "Events", 92, htmlFile, htmlDir);
877 histoHTML(h_l1_techBit, "L1 Technical Bits", "Events", 92, htmlFile, htmlDir);
878 histoHTML(h_hf_time_difference, "Time (ns)", "Events", 92, htmlFile, htmlDir);
879 //histoHTML(histodeneme, "QIE bins", "bins", 92, htmlFile, htmlDir,false);
880 histoHTML(h_ZDCP_EMHAD_ChargeAve, "ZDCP Channel id", "Ave. Charge (fC)", 92, htmlFile, htmlDir,false);
881 histoHTML(h_ZDCP_EMHAD_TSMeanAve, "ZDCP Channel id", "TS_Mean", 92, htmlFile, htmlDir,false);
882 histoHTML(h_ZDCP_EM_RecHitEnergyAve, "ZDCP EM Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
883 histoHTML(h_ZDCP_HAD_RecHitEnergyAve, "ZDCP HAD Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
884 histoHTML(h_ZDCM_EMHAD_ChargeAve, "ZDCM Channel id", "Ave. Charge (fC)", 92, htmlFile, htmlDir,false);
885 histoHTML(h_ZDCM_EMHAD_TSMeanAve, "ZDCM Channel id", "TS_Mean", 92, htmlFile, htmlDir,false);
886 histoHTML(h_ZDCM_EM_RecHitEnergyAve, "ZDCM EM Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
887 histoHTML(h_ZDCM_HAD_RecHitEnergyAve, "ZDCM HAD Channel id", "Ave. Rechit Energy (GeV)", 92, htmlFile, htmlDir,false);
888 histoHTML2(h_ZDCP_Charge_Correlation,"Total EM Charge {fC}","Total HAD Charge {fC}",92, htmlFile, htmlDir, false);
889 histoHTML2(h_ZDCP_Charge_CorrelationHAD,"HAD1+HAD2 Charge {fC}","HAD3+HAD4 Charge {fC}",92, htmlFile, htmlDir, false);
890 //histoHTML2(h_ZDCP_Charge_Correlation2,"(Total EM Charge {fC})/5","(Total HAD Charge {fC})/4",92, htmlFile,htmlDir,false);
891 //histoHTML2(h_ZDCP_RecHit_Correlation,"(Total EM RecHit {GeV})/5","(Total HAD RecHit {GeV})/4",92, htmlFile,htmlDir,false);
892 histoHTML(h_ZDCP_EM_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
893 histoHTML(h_ZDCP_EM_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
894 histoHTML(h_ZDCP_EM_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
895 histoHTML(h_ZDCP_EM_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
896 histoHTML(h_ZDCP_EM_Pulse[4], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
897 histoHTML(h_ZDCP_HAD_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
898 histoHTML(h_ZDCP_HAD_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
899 histoHTML(h_ZDCP_HAD_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
900 histoHTML(h_ZDCP_HAD_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
901 histoHTML(h_ZDCP_EM_Charge[0], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
902 histoHTML(h_ZDCP_EM_Charge[1], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
903 histoHTML(h_ZDCP_EM_Charge[2], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
904 histoHTML(h_ZDCP_EM_Charge[3], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
905 histoHTML(h_ZDCP_EM_Charge[4], "ZDCP EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
906 histoHTML(h_ZDCP_HAD_Charge[0], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
907 histoHTML(h_ZDCP_HAD_Charge[1], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
908 histoHTML(h_ZDCP_HAD_Charge[2], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
909 histoHTML(h_ZDCP_HAD_Charge[3], "ZDCP HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
910 histoHTML(h_ZDCP_EM_RecHitEnergy[0], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
911 histoHTML(h_ZDCP_EM_RecHitEnergy[1], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
912 histoHTML(h_ZDCP_EM_RecHitEnergy[2], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
913 histoHTML(h_ZDCP_EM_RecHitEnergy[3], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
914 histoHTML(h_ZDCP_EM_RecHitEnergy[4], "ZDCP EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
915 histoHTML(h_ZDCP_HAD_RecHitEnergy[0], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
916 histoHTML(h_ZDCP_HAD_RecHitEnergy[1], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
917 histoHTML(h_ZDCP_HAD_RecHitEnergy[2], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
918 histoHTML(h_ZDCP_HAD_RecHitEnergy[3], "ZDCP HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
919 histoHTML(h_ZDCP_EM_TSMean[0], "ZDCP EM Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
920 histoHTML(h_ZDCP_EM_TSMean[1], "ZDCP EM Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
921 histoHTML(h_ZDCP_EM_TSMean[2], "ZDCP EM Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
922 histoHTML(h_ZDCP_EM_TSMean[3], "ZDCP EM Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
923 histoHTML(h_ZDCP_EM_TSMean[4], "ZDCP EM Channel5 TS Mean", "Events", 92, htmlFile, htmlDir,false);
924 histoHTML(h_ZDCP_HAD_TSMean[0], "ZDCP HAD Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
925 histoHTML(h_ZDCP_HAD_TSMean[1], "ZDCP HAD Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
926 histoHTML(h_ZDCP_HAD_TSMean[2], "ZDCP HAD Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
927 histoHTML(h_ZDCP_HAD_TSMean[3], "ZDCP HAD Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
928
929 histoHTML(h_ZDCM_EM_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
930 histoHTML(h_ZDCM_EM_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
931 histoHTML(h_ZDCM_EM_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
932 histoHTML(h_ZDCM_EM_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
933 histoHTML(h_ZDCM_EM_Pulse[4], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
934 histoHTML(h_ZDCM_HAD_Pulse[0], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
935 histoHTML(h_ZDCM_HAD_Pulse[1], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
936 histoHTML(h_ZDCM_HAD_Pulse[2], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
937 histoHTML(h_ZDCM_HAD_Pulse[3], "Time Slice id", "Ave. Pulse Height", 92, htmlFile, htmlDir,false);
938 histoHTML(h_ZDCM_EM_Charge[0], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
939 histoHTML(h_ZDCM_EM_Charge[1], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
940 histoHTML(h_ZDCM_EM_Charge[2], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
941 histoHTML(h_ZDCM_EM_Charge[3], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
942 histoHTML(h_ZDCM_EM_Charge[4], "ZDCM EM Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
943 histoHTML(h_ZDCM_HAD_Charge[0], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
944 histoHTML(h_ZDCM_HAD_Charge[1], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
945 histoHTML(h_ZDCM_HAD_Charge[2], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
946 histoHTML(h_ZDCM_HAD_Charge[3], "ZDCM HAD Channel1 Charge (fC)", "Events", 92, htmlFile, htmlDir,false);
947 histoHTML(h_ZDCM_EM_RecHitEnergy[0], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
948 histoHTML(h_ZDCM_EM_RecHitEnergy[1], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
949 histoHTML(h_ZDCM_EM_RecHitEnergy[2], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
950 histoHTML(h_ZDCM_EM_RecHitEnergy[3], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
951 histoHTML(h_ZDCM_EM_RecHitEnergy[4], "ZDCM EM Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
952 histoHTML(h_ZDCM_HAD_RecHitEnergy[0], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
953 histoHTML(h_ZDCM_HAD_RecHitEnergy[1], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
954 histoHTML(h_ZDCM_HAD_RecHitEnergy[2], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
955 histoHTML(h_ZDCM_HAD_RecHitEnergy[3], "ZDCM HAD Channel1 RecHitEnergy (GeV)", "Events", 92, htmlFile, htmlDir,false);
956 histoHTML(h_ZDCM_EM_TSMean[0], "ZDCM EM Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
957 histoHTML(h_ZDCM_EM_TSMean[1], "ZDCM EM Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
958 histoHTML(h_ZDCM_EM_TSMean[2], "ZDCM EM Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
959 histoHTML(h_ZDCM_EM_TSMean[3], "ZDCM EM Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
960 histoHTML(h_ZDCM_EM_TSMean[4], "ZDCM EM Channel5 TS Mean", "Events", 92, htmlFile, htmlDir,false);
961 histoHTML(h_ZDCM_HAD_TSMean[0], "ZDCM HAD Channel1 TS Mean", "Events", 92, htmlFile, htmlDir,false);
962 histoHTML(h_ZDCM_HAD_TSMean[1], "ZDCM HAD Channel2 TS Mean", "Events", 92, htmlFile, htmlDir,false);
963 histoHTML(h_ZDCM_HAD_TSMean[2], "ZDCM HAD Channel3 TS Mean", "Events", 92, htmlFile, htmlDir,false);
964 histoHTML(h_ZDCM_HAD_TSMean[3], "ZDCM HAD Channel4 TS Mean", "Events", 92, htmlFile, htmlDir,false);
965 htmlFile << "</tr>" << endl;
966 htmlFile << "</table>" << endl;
967 // end table
968 htmlFile << "<br>" << endl;
969
970 // html page footer
971 htmlFile << "</body> " << endl;
972 htmlFile << "</html> " << endl;
973 htmlFile.close();
974 }
975 void ZDCAnalyzer::histoHTML(TH1F * hist, const char *xlab, const char *ylab, int width, ofstream & htmlFile,
976 string htmlDir, bool log) {
977
978 if (hist != NULL) {
979 string imgNameTMB = "";
980
981 imgNameTMB = getIMG(hist, 1, htmlDir, xlab, ylab,log);
982 string imgName = "";
983
984 imgName = getIMG(hist, 2, htmlDir, xlab, ylab, log);
985
986 if (imgName.size() != 0)
987 htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << endl;
988 else
989 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
990 } else
991 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
992 return;
993 }
994
995 void ZDCAnalyzer::histoHTML2(TH2F * hist, const char *xlab, const char *ylab, int width,
996 ofstream & htmlFile, string htmlDir, bool color, bool log) {
997 if (hist != NULL) {
998 string imgNameTMB = "";
999
1000 imgNameTMB = getIMG2(hist, 1, htmlDir, xlab, ylab, color,log);
1001 string imgName = "";
1002
1003 imgName = getIMG2(hist, 2, htmlDir, xlab, ylab, color,log);
1004 if (imgName.size() != 0)
1005 htmlFile << "<td><a href=\"" << imgName << "\"><img src=\"" << imgNameTMB << "\"></a></td>" << endl;
1006 else
1007 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
1008 } else
1009 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
1010 return;
1011 }
1012
1013
1014
1015 string ZDCAnalyzer::getIMG(TH1F * hist, int size, string htmlDir, const char *xlab, const char *ylab, bool log) {
1016
1017 if (hist == NULL) {
1018 printf("getIMG: This histo is NULL, %s, %s\n", xlab, ylab);
1019 return "";
1020 }
1021
1022 string name = hist->GetName();
1023
1024 cleanString(name);
1025 char dest[512];
1026
1027 if (runBegin > -1)
1028 sprintf(dest, "%s - Run %ld LS %ld-%ld", name.c_str(), runBegin, lumibegin, lumiend);
1029 else
1030 sprintf(dest, "%s", name.c_str());
1031 // set run generically hist->SetTitle(dest);
1032 string title = dest;
1033
1034 int xwid = 900;
1035 int ywid = 540;
1036
1037 if (size == 1) {
1038 title = title + "_tmb";
1039 xwid = 600;
1040 ywid = 360;
1041 }
1042 TCanvas *can = new TCanvas(dest, dest, xwid, ywid);
1043 if(log){
1044 can->SetLogy();
1045 }
1046
1047 parseString(title);
1048 string outName = title + ".gif";
1049 string saveName = htmlDir + outName;
1050
1051 hist->SetXTitle(xlab);
1052 hist->SetYTitle(ylab);
1053 // if(name.find("h_max",0)!=string::npos){
1054 // hist->Fit("landau");
1055 // }
1056 hist->Draw();
1057
1058 can->SaveAs(saveName.c_str());
1059 delete can;
1060
1061 return outName;
1062 }
1063
1064 string ZDCAnalyzer::getIMG2(TH2F * hist, int size, string htmlDir, const char *xlab, const char *ylab,
1065 bool color, bool log) {
1066
1067 if (hist == NULL) {
1068 printf("getIMG2: This histo is NULL, %s, %s\n", xlab, ylab);
1069 return "";
1070 }
1071
1072 string name = hist->GetName();
1073
1074 cleanString(name);
1075 char dest[512];
1076
1077 if (runBegin > -1)
1078 sprintf(dest, "%s - Run %ld LS %ld-%ld", name.c_str(), runBegin, lumibegin, lumiend);
1079 else
1080 sprintf(dest, "%s", name.c_str());
1081 // set run generically hist->SetTitle(dest);
1082 string title = dest;
1083
1084 int xwid = 900;
1085 int ywid = 540;
1086
1087 if (size == 1) {
1088 title = title + "_tmb";
1089 xwid = 600;
1090 ywid = 360;
1091 }
1092 TCanvas *can = new TCanvas(dest, dest, xwid, ywid);
1093
1094 parseString(title);
1095 string outName = title + ".gif";
1096 string saveName = htmlDir + outName;
1097
1098 hist->SetXTitle(xlab);
1099 hist->SetYTitle(ylab);
1100 if (!color)
1101 hist->Draw();
1102 else {
1103 hist->SetStats(false);
1104 hist->Draw("COLZ");
1105 }
1106 can->SaveAs(saveName.c_str());
1107 delete can;
1108
1109 return outName;
1110 }
1111 void ZDCAnalyzer::cleanString(string & title) {
1112
1113 for (unsigned int i = 0; i < title.size(); i++) {
1114 if (title.substr(i, 6) == " - Run") {
1115 title.replace(i, title.size() - i, "");
1116 }
1117 if (title.substr(i, 4) == "_Run") {
1118 title.replace(i, title.size() - i, "");
1119 }
1120 if (title.substr(i, 5) == "__Run") {
1121 title.replace(i, title.size() - i, "");
1122 }
1123 }
1124 }
1125
1126 void ZDCAnalyzer::parseString(string & title) {
1127
1128 for (unsigned int i = 0; i < title.size(); i++) {
1129 if (title.substr(i, 1) == " ") {
1130 title.replace(i, 1, "_");
1131 }
1132 if (title.substr(i, 1) == "#") {
1133 title.replace(i, 1, "N");
1134 }
1135 if (title.substr(i, 1) == "-") {
1136 title.replace(i, 1, "_");
1137 }
1138 if (title.substr(i, 1) == "&") {
1139 title.replace(i, 1, "_and_");
1140 }
1141 if (title.substr(i, 1) == "(" || title.substr(i, 1) == ")") {
1142 title.replace(i, 1, "_");
1143 }
1144 }
1145
1146 return;
1147 }
1148