CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DQM/HcalMonitorTasks/src/HcalZDCMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalZDCMonitor.h"
00002 
00003 // constructor
00004 HcalZDCMonitor::HcalZDCMonitor(const edm::ParameterSet & ps) {
00005   Online_                = ps.getUntrackedParameter<bool>("online",false);
00006   mergeRuns_             = ps.getUntrackedParameter<bool>("mergeRuns",false);
00007   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00008   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00009   prefixME_=ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00010   if (prefixME_.substr(prefixME_.size()-1, prefixME_.size())!="/")
00011     prefixME_.append("/");
00012   subdir_=ps.getUntrackedParameter<std::string>("TaskFolder","ZDCMonitor_Hcal/");
00013   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00014     subdir_.append("/");
00015   subdir_=prefixME_+subdir_;
00016 
00017   rechitLabel_=ps.getParameter<edm::InputTag>("rechitLabel");
00018   digiLabel_=ps.getParameter<edm::InputTag>("digiLabel");
00019   AllowedCalibTypes_     = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00020   skipOutOfOrderLS_      = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
00021   NLumiBlocks_           = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00022   makeDiagnostics_       = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00023   OnlineColdThreshold_   = ps.getUntrackedParameter<int>("ZDC_OnlineColdThreshold");
00024   OnlineDeadThreshold_   = ps.getUntrackedParameter<int>("ZDC_OnlineDeadThreshold");
00025   OfflineColdThreshold_  = ps.getUntrackedParameter<int>("ZDC_OfflineColdThreshold");
00026   OfflineDeadThreshold_  = ps.getUntrackedParameter<int>("ZDC_OfflineDeadThreshold");
00027   ColdADCThreshold_      = ps.getUntrackedParameter<int>("ZDC_ColdADCThreshold");
00028   ChannelWeighting_      = ps.getUntrackedParameter<std::vector<double>> ("ZDC_ChannelWeighting");
00029   MaxErrorRates_         = ps.getUntrackedParameter<std::vector<double>> ("ZDC_AcceptableChannelErrorRates");
00030 }
00031 
00032 //destructor
00033 HcalZDCMonitor::~HcalZDCMonitor() {
00034 }
00035 
00036 void HcalZDCMonitor::reset() {
00037 }
00038 
00039 
00040 void HcalZDCMonitor::setup() {
00041   debug_=0;
00042 
00043   HcalBaseDQMonitor::setup(); 
00044 
00045 
00046     // Set initial event # to 0
00047     ievt_ = 0;
00048 
00049      //Histograms
00050     if (dbe_) {
00051          dbe_->setCurrentFolder(subdir_);
00052          meEVT_ = dbe_->bookInt("ZDC Event Number");
00053          meEVT_->Fill(ievt_);
00054          char name[128];
00055          char title[128];
00056  
00057          // Add histograms of your choice
00058 
00059 
00063          dbe_->setCurrentFolder(subdir_);
00064          PZDC_QualityIndexVsLB_ = dbe_->book1D("PZDC_QualityIndexVSLB","Quality Index for the ZDC+ vs LS; LS; Quality Index", NLumiBlocks_,0,NLumiBlocks_);
00065          NZDC_QualityIndexVsLB_ = dbe_->book1D("NZDC_QualityIndexVSLB","Quality Index for the ZDC- vs  LS; LS; Quality Index", NLumiBlocks_,0,NLumiBlocks_);
00066          EventsVsLS             = dbe_->book1D("EventsVsLS", "Total Number of Events per LS; LS; # of Events", NLumiBlocks_,0,NLumiBlocks_);
00067         
00068 
00069 
00075 
00076         dbe_->setCurrentFolder(subdir_ + "Errors/Digis");
00077         ZDC_Digi_Errors = dbe_->book2D("ZDC_Digi_Errors", "Raw Number of Digi Errors Per ZDC Channel", 2, 0, 2, 9, 0, 9);
00078         ZDC_Digi_Errors->setBinLabel(1,"ZDC+",1);
00079         ZDC_Digi_Errors->setBinLabel(2,"ZDC-",1);
00080         ZDC_Digi_Errors->setBinLabel(1,"EM1",2);
00081         ZDC_Digi_Errors->setBinLabel(2,"EM2",2);
00082         ZDC_Digi_Errors->setBinLabel(3,"EM3",2);
00083         ZDC_Digi_Errors->setBinLabel(4,"EM4",2);
00084         ZDC_Digi_Errors->setBinLabel(5,"EM5",2);
00085         ZDC_Digi_Errors->setBinLabel(6,"HAD1",2);
00086         ZDC_Digi_Errors->setBinLabel(7,"HAD2",2);
00087         ZDC_Digi_Errors->setBinLabel(8,"HAD3",2);
00088         ZDC_Digi_Errors->setBinLabel(9,"HAD4",2);
00089         ZDC_Digi_Errors->getTH2F()->SetOption("coltext");
00090 
00091 
00092         ZDC_DigiErrorsVsLS=dbe_->book1D("ZDC_DigiErrorsVsLS","Total Number of (Digi) Errors found in the ZDCs vs. Lumi Section;LS;# errors",NLumiBlocks_,0,NLumiBlocks_);
00093 
00094    
00095 
00096 
00097         dbe_->setCurrentFolder(subdir_+"Errors/Digis/DigiErrorCauses");
00098         ZDC_DigiErrors_DVER = dbe_->book2D("ZDC_DigiErrors_DVER","Raw Number of Digi Errors Caused by Finding .dv()=0 or .er()=1",2,0,2,9,0,9);
00099         ZDC_DigiErrors_DVER->setBinLabel(1,"ZDC+",1);
00100         ZDC_DigiErrors_DVER->setBinLabel(2,"ZDC-",1);
00101         ZDC_DigiErrors_DVER->setBinLabel(1,"EM1",2);
00102         ZDC_DigiErrors_DVER->setBinLabel(2,"EM2",2);
00103         ZDC_DigiErrors_DVER->setBinLabel(3,"EM3",2);
00104         ZDC_DigiErrors_DVER->setBinLabel(4,"EM4",2);
00105         ZDC_DigiErrors_DVER->setBinLabel(5,"EM5",2);
00106         ZDC_DigiErrors_DVER->setBinLabel(6,"HAD1",2);
00107         ZDC_DigiErrors_DVER->setBinLabel(7,"HAD2",2);
00108         ZDC_DigiErrors_DVER->setBinLabel(8,"HAD3",2);
00109         ZDC_DigiErrors_DVER->setBinLabel(9,"HAD4",2);
00110         ZDC_DigiErrors_DVER->getTH2F()->SetOption("coltext");
00111 
00112 
00113         ZDC_DigiErrors_CAPID = dbe_->book2D("ZDC_DigiErrors_CAPID","Raw Number of Digi Errors Caused by the Caps not Alternating",2,0,2,9,0,9);
00114         ZDC_DigiErrors_CAPID->setBinLabel(1,"ZDC+",1);
00115         ZDC_DigiErrors_CAPID->setBinLabel(2,"ZDC-",1);
00116         ZDC_DigiErrors_CAPID->setBinLabel(1,"EM1",2);
00117         ZDC_DigiErrors_CAPID->setBinLabel(2,"EM2",2);
00118         ZDC_DigiErrors_CAPID->setBinLabel(3,"EM3",2);
00119         ZDC_DigiErrors_CAPID->setBinLabel(4,"EM4",2);
00120         ZDC_DigiErrors_CAPID->setBinLabel(5,"EM5",2);
00121         ZDC_DigiErrors_CAPID->setBinLabel(6,"HAD1",2);
00122         ZDC_DigiErrors_CAPID->setBinLabel(7,"HAD2",2);
00123         ZDC_DigiErrors_CAPID->setBinLabel(8,"HAD3",2);
00124         ZDC_DigiErrors_CAPID->setBinLabel(9,"HAD4",2);
00125         ZDC_DigiErrors_CAPID->getTH2F()->SetOption("coltext");
00126 
00132 
00133      
00134         dbe_->setCurrentFolder(subdir_ + "Errors/HotChannel");
00135         ZDC_Hot_Channel_Errors = dbe_->book2D("ZDC_Hot_Channel_Errors", "Raw Number of Times Each Channel Appeared Hot", 2, 0, 2, 9, 0, 9);
00136         ZDC_Hot_Channel_Errors->setBinLabel(1,"ZDC+",1);
00137         ZDC_Hot_Channel_Errors->setBinLabel(2,"ZDC-",1);
00138         ZDC_Hot_Channel_Errors->setBinLabel(1,"EM1",2);
00139         ZDC_Hot_Channel_Errors->setBinLabel(2,"EM2",2);
00140         ZDC_Hot_Channel_Errors->setBinLabel(3,"EM3",2);
00141         ZDC_Hot_Channel_Errors->setBinLabel(4,"EM4",2);
00142         ZDC_Hot_Channel_Errors->setBinLabel(5,"EM5",2);
00143         ZDC_Hot_Channel_Errors->setBinLabel(6,"HAD1",2);
00144         ZDC_Hot_Channel_Errors->setBinLabel(7,"HAD2",2);
00145         ZDC_Hot_Channel_Errors->setBinLabel(8,"HAD3",2);
00146         ZDC_Hot_Channel_Errors->setBinLabel(9,"HAD4",2);    
00147         ZDC_Hot_Channel_Errors->getTH2F()->SetOption("coltext");
00148 
00149 
00150          ZDC_HotChannelErrorsVsLS=dbe_->book1D("ZDC_HotChannelErrorsVsLS","Total Number of Hot Channel Errors in the ZDCs vs. Lumi Section; LS; # Hot channels", NLumiBlocks_,0,NLumiBlocks_);
00151 
00152 
00153 
00159 
00160         dbe_->setCurrentFolder(subdir_ + "Errors/DeadChannel");
00161         ZDC_Dead_Channel_Errors = dbe_->book2D("ZDC_Dead_Channel_Errors", "Raw Number of Times Each Channel Appeared Dead", 2, 0, 2, 9, 0, 9);
00162         ZDC_Dead_Channel_Errors->setBinLabel(1,"ZDC+",1);
00163         ZDC_Dead_Channel_Errors->setBinLabel(2,"ZDC-",1);
00164         ZDC_Dead_Channel_Errors->setBinLabel(1,"EM1",2);
00165         ZDC_Dead_Channel_Errors->setBinLabel(2,"EM2",2);
00166         ZDC_Dead_Channel_Errors->setBinLabel(3,"EM3",2);
00167         ZDC_Dead_Channel_Errors->setBinLabel(4,"EM4",2);
00168         ZDC_Dead_Channel_Errors->setBinLabel(5,"EM5",2);
00169         ZDC_Dead_Channel_Errors->setBinLabel(6,"HAD1",2);
00170         ZDC_Dead_Channel_Errors->setBinLabel(7,"HAD2",2);
00171         ZDC_Dead_Channel_Errors->setBinLabel(8,"HAD3",2);
00172         ZDC_Dead_Channel_Errors->setBinLabel(9,"HAD4",2);    
00173         ZDC_Dead_Channel_Errors->getTH2F()->SetOption("coltext");
00174         
00175         ZDC_DeadChannelErrorsVsLS=dbe_->book1D("ZDC_DeadChannelErrorsVsLS","Total Number of Dead Channel Errors in the ZDC vs. Lumi Section; LS; # of Dead Chanels", NLumiBlocks_, 0, NLumiBlocks_);  
00176 
00177 
00183 
00184         dbe_->setCurrentFolder(subdir_ + "Errors/ColdChannel");
00185         ZDC_Cold_Channel_Errors = dbe_->book2D("ZDC_Cold_Channel_Errors", "Raw Number of Times Each Channel Appeared Cold", 2, 0, 2, 9, 0, 9);
00186         ZDC_Cold_Channel_Errors->setBinLabel(1,"ZDC+",1);
00187         ZDC_Cold_Channel_Errors->setBinLabel(2,"ZDC-",1);
00188         ZDC_Cold_Channel_Errors->setBinLabel(1,"EM1",2);
00189         ZDC_Cold_Channel_Errors->setBinLabel(2,"EM2",2);
00190         ZDC_Cold_Channel_Errors->setBinLabel(3,"EM3",2);
00191         ZDC_Cold_Channel_Errors->setBinLabel(4,"EM4",2);
00192         ZDC_Cold_Channel_Errors->setBinLabel(5,"EM5",2);
00193         ZDC_Cold_Channel_Errors->setBinLabel(6,"HAD1",2);
00194         ZDC_Cold_Channel_Errors->setBinLabel(7,"HAD2",2);
00195         ZDC_Cold_Channel_Errors->setBinLabel(8,"HAD3",2);
00196         ZDC_Cold_Channel_Errors->setBinLabel(9,"HAD4",2);    
00197         ZDC_Cold_Channel_Errors->getTH2F()->SetOption("coltext");
00198         
00199         ZDC_ColdChannelErrorsVsLS=dbe_->book1D("ZDC_ColdChannelErrorsVsLS","Total Number of Cold Channels in the ZDC vs. Lumi Section; LS; # of Cold Chanels", NLumiBlocks_, 0, NLumiBlocks_);  
00200 
00201 
00202 
00203 
00209 
00210 
00211         dbe_->setCurrentFolder(subdir_ + "Errors");
00212         ZDC_TotalChannelErrors = dbe_->book2D("ZDC_TotalChannelErrors","Total Number of Errors(Digi Error, Hot Cell or Dead Cell) Per Channel in the ZDC" ,2,0,2,9,0,9);
00213         ZDC_TotalChannelErrors->setBinLabel(1,"ZDC+",1);
00214         ZDC_TotalChannelErrors->setBinLabel(2,"ZDC-",1);
00215         ZDC_TotalChannelErrors->setBinLabel(1,"EM1",2);
00216         ZDC_TotalChannelErrors->setBinLabel(2,"EM2",2);
00217         ZDC_TotalChannelErrors->setBinLabel(3,"EM3",2);
00218         ZDC_TotalChannelErrors->setBinLabel(4,"EM4",2);
00219         ZDC_TotalChannelErrors->setBinLabel(5,"EM5",2);
00220         ZDC_TotalChannelErrors->setBinLabel(6,"HAD1",2);
00221         ZDC_TotalChannelErrors->setBinLabel(7,"HAD2",2);
00222         ZDC_TotalChannelErrors->setBinLabel(8,"HAD3",2);
00223         ZDC_TotalChannelErrors->setBinLabel(9,"HAD4",2);
00224         ZDC_TotalChannelErrors->getTH2F()->SetOption("coltext");
00225         
00231 
00232          dbe_->setCurrentFolder(subdir_);
00233          h_2D_charge = dbe_->book2D("2D_DigiCharge", "Digi Charge (fC)", 2, 0, 2, 9, 0, 9);
00234          h_2D_charge->setBinLabel(1,"ZDC+",1);
00235          h_2D_charge->setBinLabel(2,"ZDC-",1);
00236          h_2D_charge->setBinLabel(1,"EM1",2);
00237          h_2D_charge->setBinLabel(2,"EM2",2);
00238          h_2D_charge->setBinLabel(3,"EM3",2);
00239          h_2D_charge->setBinLabel(4,"EM4",2);
00240          h_2D_charge->setBinLabel(5,"EM5",2);
00241          h_2D_charge->setBinLabel(6,"HAD1",2);
00242          h_2D_charge->setBinLabel(7,"HAD2",2);
00243          h_2D_charge->setBinLabel(8,"HAD3",2);
00244          h_2D_charge->setBinLabel(9,"HAD4",2);
00245          
00246          h_2D_TSMean = dbe_->book2D("2D_DigiTiming", "Digi Timing", 2, 0, 2, 9, 0, 9);
00247          h_2D_TSMean->setBinLabel(1,"ZDC+",1);
00248          h_2D_TSMean->setBinLabel(2,"ZDC-",1);
00249          h_2D_TSMean->setBinLabel(1,"EM1",2);
00250          h_2D_TSMean->setBinLabel(2,"EM2",2);
00251          h_2D_TSMean->setBinLabel(3,"EM3",2);
00252          h_2D_TSMean->setBinLabel(4,"EM4",2);
00253          h_2D_TSMean->setBinLabel(5,"EM5",2);
00254          h_2D_TSMean->setBinLabel(6,"HAD1",2);
00255          h_2D_TSMean->setBinLabel(7,"HAD2",2);
00256          h_2D_TSMean->setBinLabel(8,"HAD3",2);
00257          h_2D_TSMean->setBinLabel(9,"HAD4",2);
00258          
00259          h_2D_RecHitEnergy = dbe_->book2D("2D_RecHitEnergy", "Rechit Energy", 2, 0, 2, 9, 0, 9);
00260          h_2D_RecHitEnergy->setBinLabel(1,"ZDC+",1);
00261          h_2D_RecHitEnergy->setBinLabel(2,"ZDC-",1);
00262          h_2D_RecHitEnergy->setBinLabel(1,"EM1",2);
00263          h_2D_RecHitEnergy->setBinLabel(2,"EM2",2);
00264          h_2D_RecHitEnergy->setBinLabel(3,"EM3",2);
00265          h_2D_RecHitEnergy->setBinLabel(4,"EM4",2);
00266          h_2D_RecHitEnergy->setBinLabel(5,"EM5",2);
00267          h_2D_RecHitEnergy->setBinLabel(6,"HAD1",2);
00268          h_2D_RecHitEnergy->setBinLabel(7,"HAD2",2);
00269          h_2D_RecHitEnergy->setBinLabel(8,"HAD3",2);
00270          h_2D_RecHitEnergy->setBinLabel(9,"HAD4",2);
00271          
00272          h_2D_RecHitTime = dbe_->book2D("2D_RecHitTime", "Rechit Timing", 2, 0, 2, 9, 0, 9);
00273          h_2D_RecHitTime->setBinLabel(1,"ZDC+",1);
00274          h_2D_RecHitTime->setBinLabel(2,"ZDC-",1);
00275          h_2D_RecHitTime->setBinLabel(1,"EM1",2);
00276          h_2D_RecHitTime->setBinLabel(2,"EM2",2);
00277          h_2D_RecHitTime->setBinLabel(3,"EM3",2);
00278          h_2D_RecHitTime->setBinLabel(4,"EM4",2);
00279          h_2D_RecHitTime->setBinLabel(5,"EM5",2);
00280          h_2D_RecHitTime->setBinLabel(6,"HAD1",2);
00281          h_2D_RecHitTime->setBinLabel(7,"HAD2",2);
00282          h_2D_RecHitTime->setBinLabel(8,"HAD3",2);
00283          h_2D_RecHitTime->setBinLabel(9,"HAD4",2);
00284          
00285          h_2D_saturation = dbe_->book2D("h_2D_QIE", "Saturation Check", 2, 0, 2, 9, 0, 9);
00286          h_2D_saturation->setBinLabel(1,"ZDC+",1);
00287          h_2D_saturation->setBinLabel(2,"ZDC-",1);
00288          h_2D_saturation->setBinLabel(1,"EM1",2);
00289          h_2D_saturation->setBinLabel(2,"EM2",2);
00290          h_2D_saturation->setBinLabel(3,"EM3",2);
00291          h_2D_saturation->setBinLabel(4,"EM4",2);
00292          h_2D_saturation->setBinLabel(5,"EM5",2);
00293          h_2D_saturation->setBinLabel(6,"HAD1",2);
00294          h_2D_saturation->setBinLabel(7,"HAD2",2);
00295          h_2D_saturation->setBinLabel(8,"HAD3",2);
00296          h_2D_saturation->setBinLabel(9,"HAD4",2);
00297          
00298          dbe_->setCurrentFolder(subdir_ + "Digis");
00299 
00300         for (int i = 0; i < 5; ++i) {
00301             // pulse Plus Side 
00302             sprintf(title, "h_ZDCP_EMChan_%i_Pulse", i + 1);
00303             sprintf(name, "ZDC Plus EM Section Pulse for channel %i", i + 1);
00304             h_ZDCP_EM_Pulse[i]= dbe_->book1D(title, name, 10, -0.5, 9.5);
00305             h_ZDCP_EM_Pulse[i]->setAxisTitle("Time Slice id",1);
00306             h_ZDCP_EM_Pulse[i]->setAxisTitle("Pulse Height",2);
00307             // pulse Minus Side
00308             sprintf(title, "h_ZDCM_EMChan_%i_Pulse", i + 1);
00309             sprintf(name, "ZDC Minus EM Section Pulse for channel %i", i + 1);
00310             h_ZDCM_EM_Pulse[i] = dbe_->book1D(title, name, 10, -0.5, 9.5);
00311             h_ZDCM_EM_Pulse[i]->setAxisTitle("Time Slice id",1);
00312             h_ZDCM_EM_Pulse[i]->setAxisTitle("Pulse Height",2);
00313             // integrated charge over 10 time samples
00314             sprintf(title, "h_ZDCP_EMChan_%i_Charge", i + 1);
00315             sprintf(name, "ZDC Plus EM Section Charge for channel %i", i + 1);
00316             h_ZDCP_EM_Charge[i] = dbe_->book1D(title, name, 1000, 0., 30000.);
00317             h_ZDCP_EM_Charge[i]->setAxisTitle("Charge (fC)",1);
00318             h_ZDCP_EM_Charge[i]->setAxisTitle("Events",2);
00319             // integrated charge over 10 time samples
00320             sprintf(title, "h_ZDCM_EMChan_%i_Charge", i + 1);
00321             sprintf(name, "ZDC Minus EM Section Charge for channel %i", i + 1);
00322             h_ZDCM_EM_Charge[i] = dbe_->book1D(title, name, 1000, 0., 30000.);
00323             h_ZDCM_EM_Charge[i]->setAxisTitle("Charge (fC)",1);
00324             h_ZDCM_EM_Charge[i]->setAxisTitle("Events",2);
00325             // charge weighted time slice
00326             sprintf(title, "h_ZDCP_EMChan_%i_TSMean", i + 1);
00327             sprintf(name, "ZDC Plus EM Section TSMean for channel %i", i + 1);
00328             h_ZDCP_EM_TSMean[i] = dbe_->book1D(title, name, 100, -0.5, 9.5);
00329             h_ZDCP_EM_TSMean[i]->setAxisTitle("Timing",1);
00330             h_ZDCP_EM_TSMean[i]->setAxisTitle("Events",2);
00331             // charge weighted time slice
00332             sprintf(title, "h_ZDCM_EMChan_%i_TSMean", i + 1);
00333             sprintf(name, "ZDC Minus EM Section TSMean for channel %i", i + 1);
00334             h_ZDCM_EM_TSMean[i] = dbe_->book1D(title, name, 100, -0.5, 9.5);
00335             h_ZDCM_EM_TSMean[i]->setAxisTitle("Timing",1);
00336             h_ZDCM_EM_TSMean[i]->setAxisTitle("Events",2);
00337         }
00338 
00339         for (int i = 0; i < 4; ++i) {
00340             // pulse Plus Side 
00341             sprintf(title, "h_ZDCP_HADChan_%i_Pulse", i + 1);
00342             sprintf(name, "ZDC Plus HAD Section Pulse for channel %i", i + 1);
00343             h_ZDCP_HAD_Pulse[i] = dbe_->book1D(title, name, 10, -0.5, 9.5);
00344             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Time Slice id",1);
00345             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Pulse Height",2);
00346             // pulse Minus Side 
00347             sprintf(title, "h_ZDCM_HADChan_%i_Pulse", i + 1);
00348             sprintf(name, "ZDC Minus HAD Section Pulse for channel %i", i + 1);
00349             h_ZDCM_HAD_Pulse[i] = dbe_->book1D(title, name, 10, -0.5, 9.5);
00350             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Time Slice id",1);
00351             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Pulse Height",2);
00352             // integrated charge over 10 time samples 
00353             sprintf(title, "h_ZDCP_HADChan_%i_Charge", i + 1);
00354             sprintf(name, "ZDC Plus HAD Section Charge for channel %i", i + 1);
00355             h_ZDCP_HAD_Charge[i] = dbe_->book1D(title, name, 1000, 0., 30000.);
00356             h_ZDCP_HAD_Charge[i]->setAxisTitle("Charge (fC)",1);
00357             h_ZDCP_HAD_Charge[i]->setAxisTitle("Events",2);
00358             // integrated charge over 10 time samples 
00359             sprintf(title, "h_ZDCM_HADChan_%i_Charge", i + 1);
00360             sprintf(name, "ZDC Minus HAD Section Charge for channel %i", i + 1);
00361             h_ZDCM_HAD_Charge[i] = dbe_->book1D(title, name, 1000, 0., 30000.);
00362             h_ZDCM_HAD_Charge[i]->setAxisTitle("Charge (fC)",1);
00363             h_ZDCM_HAD_Charge[i]->setAxisTitle("Events",2);
00364             // charge weighted time slice 
00365             sprintf(title, "h_ZDCP_HADChan_%i_TSMean", i + 1);
00366             sprintf(name, "ZDC Plus HAD Section TSMean for channel %i", i + 1);
00367             h_ZDCP_HAD_TSMean[i] = dbe_->book1D(title, name, 100, -0.5, 9.5);
00368             h_ZDCP_HAD_TSMean[i]->setAxisTitle("Timing",1);
00369             h_ZDCP_HAD_TSMean[i]->setAxisTitle("Events",2);
00370             // charge weighted time slice 
00371             sprintf(title, "h_ZDCM_HADChan_%i_TSMean", i + 1);
00372             sprintf(name, "ZDC Minus HAD Section TSMean for channel %i", i + 1);
00373             h_ZDCM_HAD_TSMean[i] = dbe_->book1D(title, name, 100, -0.5, 9.5);
00374             h_ZDCM_HAD_TSMean[i]->setAxisTitle("Timing",1);
00375             h_ZDCM_HAD_TSMean[i]->setAxisTitle("Events",2);
00376         }
00377 
00378         dbe_->setCurrentFolder(subdir_ + "RecHits");
00379         for (int i = 0; i < 5; ++i) {
00380             //RecHitEnergy Plus Side
00381             sprintf(title,"h_ZDCP_EMChan_%i_RecHit_Energy",i+1);
00382             sprintf(name,"ZDC EM Section Rechit Energy for channel %i",i+1);
00383             h_ZDCP_EM_RecHitEnergy[i] = dbe_->book1D(title, name, 1010, -100., 10000.);
00384             h_ZDCP_EM_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00385             h_ZDCP_EM_RecHitEnergy[i]->setAxisTitle("Events",2);
00386             //RecHitEnergy Minus Side
00387             sprintf(title,"h_ZDCM_EMChan_%i_RecHit_Energy",i+1);
00388             sprintf(name,"ZDC EM Section Rechit Energy for channel %i",i+1);
00389             h_ZDCM_EM_RecHitEnergy[i] = dbe_->book1D(title, name, 1010, -100., 10000.);
00390             h_ZDCM_EM_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00391             h_ZDCM_EM_RecHitEnergy[i]->setAxisTitle("Events",2);
00392             //RecHit Timing Plus Side 
00393             sprintf(title,"h_ZDCP_EMChan_%i_RecHit_Timing",i+1);
00394             sprintf(name,"ZDC EM Section Rechit Timing for channel %i",i+1);
00395             h_ZDCP_EM_RecHitTiming[i] = dbe_->book1D(title, name, 100, -100., 100.);
00396             h_ZDCP_EM_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00397             h_ZDCP_EM_RecHitTiming[i]->setAxisTitle("Events",2);
00398             //RecHit Timing Minus Side 
00399             sprintf(title,"h_ZDCM_EMChan_%i_RecHit_Timing",i+1);
00400             sprintf(name,"ZDC EM Section Rechit Timing for channel %i",i+1);
00401             h_ZDCM_EM_RecHitTiming[i] = dbe_->book1D(title, name, 100, -100., 100.);    
00402             h_ZDCM_EM_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00403             h_ZDCM_EM_RecHitTiming[i]->setAxisTitle("Events",2);
00404         }
00405 
00406         for (int i = 0; i < 4; ++i) {
00407             //RecHitEnergy Plus Side
00408             sprintf(title,"h_ZDCP_HADChan_%i_RecHit_Energy",i+1);
00409             sprintf(name,"ZDC HAD Section Rechit Energy for channel %i",i+1);
00410             h_ZDCP_HAD_RecHitEnergy[i] = dbe_->book1D(title, name, 1010, -100., 10000.);
00411             h_ZDCP_HAD_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00412             h_ZDCP_HAD_RecHitEnergy[i]->setAxisTitle("Events",2);
00413             //RecHitEnergy Minus Side
00414             sprintf(title,"h_ZDCM_HADChan_%i_RecHit_Energy",i+1);
00415             sprintf(name,"ZDC HAD Section Rechit Energy for channel %i",i+1);
00416             h_ZDCM_HAD_RecHitEnergy[i] = dbe_->book1D(title, name, 1010, -100., 10000.);
00417             h_ZDCM_HAD_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00418             h_ZDCM_HAD_RecHitEnergy[i]->setAxisTitle("Events",2);
00419             //RecHit Timing Plus Side 
00420             sprintf(title,"h_ZDCP_HADChan_%i_RecHit_Timing",i+1);
00421             sprintf(name,"ZDC HAD Section Rechit Timing for channel %i",i+1);
00422             h_ZDCP_HAD_RecHitTiming[i] = dbe_->book1D(title, name, 100, -100., 100.);   
00423             h_ZDCP_HAD_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00424             h_ZDCP_HAD_RecHitTiming[i]->setAxisTitle("Events",2);
00425             //RecHit Timing Minus Side 
00426             sprintf(title,"h_ZDCM_HADChan_%i_RecHit_Timing",i+1);
00427             sprintf(name,"ZDC HAD Section Rechit Timing for channel %i",i+1);
00428             h_ZDCM_HAD_RecHitTiming[i] = dbe_->book1D(title, name, 100, -100., 100.);   
00429             h_ZDCM_HAD_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00430             h_ZDCM_HAD_RecHitTiming[i]->setAxisTitle("Events",2);
00431         }
00432     } // if (dbe_)
00433     return;
00434 }
00435 
00436 
00437 void HcalZDCMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00438 {
00439   HcalBaseDQMonitor::beginRun(run, c);
00440   if (tevt_==0) this->setup();  // call basic setup of histograms
00441 
00442   for (int i=0;i<18;++i)
00443     {
00444       ColdChannelCounter[i]=0;
00445       DeadChannelCounter[i]=0;
00446     }
00447   
00448   EventCounter=0;
00449 
00450 }
00451 
00452 void HcalZDCMonitor::endRun(const edm::Run& run, const edm::EventSetup& c)
00453 {
00454   for(int i=0;i<18;++i)
00455     {
00456       ZDC_Cold_Channel_Errors->Fill(i/9,i%9,ColdChannelCounter[i]);
00457       ZDC_Dead_Channel_Errors->Fill(i/9,i%9,DeadChannelCounter[i]);
00458       ZDC_TotalChannelErrors->Fill(i/9,i%9,ColdChannelCounter[i]);
00459       ZDC_TotalChannelErrors->Fill(i/9,i%9,DeadChannelCounter[i]);
00460     }
00461   HcalBaseDQMonitor::endRun(run, c);
00462 }
00463 
00464 void HcalZDCMonitor::analyze(const edm::Event& e, const edm::EventSetup& c)
00465 {
00466   if (!IsAllowedCalibType()) return;
00467   if (LumiInOrder(e.luminosityBlock())==false) return;
00468   HcalBaseDQMonitor::analyze(e,c);
00469 
00470   edm::Handle<ZDCDigiCollection> zdcdigis;
00471   e.getByLabel(digiLabel_,zdcdigis);
00472   edm::Handle<ZDCRecHitCollection> zdcrechits;
00473   e.getByLabel(rechitLabel_,zdcrechits);
00474   edm::Handle<HcalUnpackerReport> report;
00475   e.getByLabel(digiLabel_,report);
00476   processEvent(*zdcdigis, *zdcrechits, *report); // run the histogramming/analysis specific to this code
00477 }
00478 
00479 void HcalZDCMonitor::beginLuminosityBlock(const edm::LuminosityBlock& e, const edm::EventSetup& c)
00480 {
00481   HcalBaseDQMonitor::beginLuminosityBlock(e,c);
00482   // ZDC_Dead_Channel_Errors->Fill(-1,-1,1);
00483   //  ZDC_Cold_Channel_Errors->Fill(-1,-1,1); READ COMMENT!!!!
00484   // The above line should be uncommented IF, in the fill (down in endlumiblock) we used a value of 1 to say that a specific ZDC channel had 1 Cold Error after >50 times that the cold error occured. Currently, I have it set so that if a ZDC channel goes over the threshold, the RAW number of times that the channel appeared cold shows up. For example: the cold threshold is at 50, EM 1 has a cold Error 51 times...currently, the number 51 will show up in the ZDC_Cold_Channel_Errors plot...however the other way....it would say 1. 
00485   //This is only a problem when you get to the client level since this line fills the underflow bin. The underflow bin is read in by the client as the divisor. If you try to divide a number of ColdEvents by a number of Lumis...most likely your rate will be greater than one. For now I am moving this line back to processEvent.  
00486   EventCounter=0;
00487   for (int i=0;i<18;++i)
00488     {
00489       ChannelRatio[i]=0.;
00490       TotalChannelErrors[i]=0;
00491     }
00492   
00493 }
00494 
00495 
00496 
00497 void HcalZDCMonitor::processEvent(const ZDCDigiCollection& digi, const ZDCRecHitCollection& rechit, const HcalUnpackerReport& report) {
00498 
00499     meEVT_->Fill(ievt_);
00500 
00501     //--------------------------------------
00502     // ZDC Digi part 
00503     //--------------------------------------
00504     double fSum = 0.;
00505     std::vector<double> fData;
00506     double digiThresh = 99.5; //corresponds to 40 ADC counts
00507     //int digiThreshADC = 40;
00508     int digiSaturation = 127;
00509     //double ZDCQIEConst = 2.6; 
00510 
00511 
00512     if (digi.size()>0)
00513         {
00514           ZDC_Digi_Errors->Fill(-1,-1,1);
00515           ZDC_Hot_Channel_Errors->Fill(-1,-1,1);
00516           ZDC_TotalChannelErrors->Fill(-1,-1,1);
00517           ZDC_Cold_Channel_Errors->Fill(-1,-1,1);
00518           ZDC_Dead_Channel_Errors->Fill(-1,-1,1);
00519           EventCounter+=1;
00520         }
00521     for (int i=0;i<18;++i)
00522       {
00523         ChannelHasDigiError[i]=false;
00524         DigiErrorDVER[i]=false;
00525         DigiErrorCAPID[i]=false;
00526         HotChannelError[i]=false;
00527         DeadChannelError[i]=true;
00528       }
00529     
00530     
00531     typedef std::vector<DetId> DetIdVector;
00532     
00533     for (DetIdVector::const_iterator baddigi_iter=report.bad_quality_begin();
00534          baddigi_iter != report.bad_quality_end();
00535          ++baddigi_iter)
00536       {
00537         DetId id(baddigi_iter->rawId());
00538         if (id.det()==DetId::Calo && id.subdetId()==HcalZDCDetId::SubdetectorId)
00539         //HcalDetId id(baddigi_iter->rawId());
00540         //if (id.subdet()==HcalZDCDetId::SubdetectorId)
00541           {
00542             // const ZDCDataFrame digi = (const ZDCDataFrame) (*baddigi_iter);
00543             HcalZDCDetId id(baddigi_iter->rawId());
00544             int iSide = id.zside();
00545             int iSection = id.section();
00546             int iChannel = id.channel();
00547             if(iSection==1 || iSection==2){
00548             ChannelHasDigiError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=true;
00549             DeadChannelError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=false;
00550             //do stuff
00551             }//end of if i(Section==1 || iSection==2) 
00552           }
00553         else continue;
00554 
00555       }//end unpacker section
00556 
00557 
00558 
00559     // ChannelHasError[18]:  [0-8] are iSide=1, [9-17] are iSide=2                                                                                      
00560     //  First 5 bins ([0-4],[9-13]) are EM bins                                                                                                         
00561     //  Last 4 bins are HAD bins   
00562 
00563 
00564     for (ZDCDigiCollection::const_iterator digi_iter = digi.begin(); 
00565          digi_iter != digi.end(); ++digi_iter) 
00566       {
00567         const ZDCDataFrame digi = (const ZDCDataFrame) (*digi_iter);
00568         //HcalZDCDetId id(digi_iter->id());
00569         int iSide = digi_iter->id().zside();
00570         int iSection = digi_iter->id().section();
00571         int iChannel = digi_iter->id().channel();
00572  
00573         unsigned int fTS = digi_iter->size();
00574         while (fData.size()<fTS)
00575           fData.push_back(-999);
00576         while (fData.size()>fTS)
00577           fData.pop_back(); // delete last elements 
00578 
00579         if (iSection==1 || iSection==2)
00580           {
00581      
00583 
00586         DeadChannelError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=false;
00588 
00589         int iCapID=27;
00590         int iCapIDPrevious=27;
00591         int HotCounter=0;
00592         int ColdCounter=0;
00593 
00594         for (int iTS=0; iTS<digi.size(); ++iTS) //looping over all ten timeslices
00595           {
00597             if (digi[iTS].adc()==127) HotCounter+=1;
00598             else HotCounter=0;//require 3 consecutive saturated Time Slices in a single channel in a single event
00599             if (HotCounter >= 3) HotChannelError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=true; 
00601             
00602 
00604             if (digi[iTS].adc()<=10) ColdCounter+=1;
00605             if (ColdCounter==10) 
00606               {
00607                 ColdChannelCounter[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]+=1;
00608               }
00610 
00611               
00614             if ((ChannelHasDigiError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=false))
00615               {
00616               iCapID=digi.sample(iTS).capid();
00617               if (iTS>0) iCapIDPrevious=digi.sample(iTS-1).capid();
00618                           
00619               if (digi.sample(iTS).dv()==0 || digi.sample(iTS).er()==1)
00620                 {
00621                   ChannelHasDigiError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=true;
00622                   DigiErrorDVER[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=true;
00623                   break;
00624                 }
00625               else
00626                 {
00627                   if (iTS==0) continue;
00628                   else
00629                     {
00630                       if ((iCapID-iCapIDPrevious+4)%4!=1)
00631                         {
00632                           ChannelHasDigiError[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=true;
00633                           DigiErrorCAPID[(9*((1-iSide)/2))+(iChannel-1)+(5*((iSection-1)%2))]=true;
00634                           break;
00635                         }//end of capid rotation check
00636                     }//checking if TS!=0
00637                 } // end of the check for dv/er
00638               }//END of unpacker double check
00639           } // end of TS loop
00640 
00642 
00643 
00644 
00645 
00646         fSum = 0.;
00647         bool saturated = false;
00648         for (unsigned int i = 0; i < fTS; ++i) 
00649           {
00650              //fData[i]=digi[i].nominal_fC() * ZDCQIEConst;
00651              fData[i]=digi[i].nominal_fC();
00652              if (digi[i].adc()==digiSaturation){
00653                  saturated=true;
00654              }
00655           }
00656       
00657         double fTSMean = 0;
00658         if (fData.size()>6)
00659     fTSMean = getTime(fData, 4, 6, fSum); // tsmin = 4, tsmax = 6.
00660         //std::cout << "Side= " << iSide << " Section= " << iSection << " Channel= " << iChannel << "\tCharge\t" << fSum <<std::endl; 
00661           if (saturated==true){
00662              h_2D_saturation->Fill(iSide==1?0:1,iSection==1?iChannel-1:iChannel+4,1);
00663           }
00664       
00665         if (iSection == 1) 
00666           {    // EM
00667             if (iSide == 1) {   // Plus
00668               for (unsigned int i = 0; i < fTS; ++i) {
00669                 if (fData[i] > digiThresh) h_ZDCP_EM_Pulse[iChannel - 1]->Fill(i, fData[i]);
00670               }
00671               if (fSum > digiThresh) {
00672                 h_ZDCP_EM_Charge[iChannel - 1]->Fill(fSum);
00673                 h_ZDCP_EM_TSMean[iChannel - 1]->Fill(fTSMean);
00674                 //std::cout<< "fSum " << fSum << " fTSMean " << fTSMean <<std::endl;
00675               }
00676             } // Plus
00677             if (iSide == -1) {  // Minus
00678               for (unsigned int i = 0; i < fTS; ++i) {
00679                 if (fData[i] > digiThresh) h_ZDCM_EM_Pulse[iChannel - 1]->Fill(i, fData[i]);
00680               }
00681               if (fSum > digiThresh) {
00682                 h_ZDCM_EM_Charge[iChannel - 1]->Fill(fSum);
00683                 h_ZDCM_EM_TSMean[iChannel - 1]->Fill(fTSMean);
00684               }
00685             } // Minus
00686           }// EM
00687       
00688         else if (iSection == 2) 
00689           {    // HAD
00690             if (iSide == 1) {   // Plus 
00691               for (unsigned int i = 0; i < fTS; ++i) {
00692                 if (fData[i] > digiThresh) h_ZDCP_HAD_Pulse[iChannel - 1]->Fill(i, fData[i]);
00693               }
00694               if (fSum > digiThresh) {
00695                 h_ZDCP_HAD_Charge[iChannel - 1]->Fill(fSum);
00696                 h_ZDCP_HAD_TSMean[iChannel - 1]->Fill(fTSMean);
00697               }
00698             } // Plus
00699             if (iSide == -1) {  // Minus
00700               for (unsigned int i = 0; i < fTS; ++i) {
00701                 if (fData[i] > digiThresh) h_ZDCM_HAD_Pulse[iChannel - 1]->Fill(i, fData[i]);
00702               } 
00703               if (fSum > digiThresh) {
00704                 h_ZDCM_HAD_Charge[iChannel - 1]->Fill(fSum);
00705                 h_ZDCM_HAD_TSMean[iChannel - 1]->Fill(fTSMean);
00706               }
00707             }// Minus
00708           } // HAD 
00709           }//end of if (iSection==1 || iSection==2)
00710       } // loop on zdc digi collection
00711                     
00712                     
00713                     
00715     // Fill Fall 2012 histograms
00717     int numdigierrors=0;
00718     int numhoterrors=0;
00719 
00720     for (int i = 0; i<18; i++){
00721       if (ChannelHasDigiError[i]==true)
00722         {
00723           ++numdigierrors;
00724           ZDC_Digi_Errors->Fill(i/9,i%9,1);
00725         }
00726       if (DigiErrorDVER[i]==true)
00727         {
00728           ZDC_DigiErrors_DVER->Fill(i/9,i%9,1);
00729         }
00730       if (DigiErrorCAPID[i]==true)
00731         {
00732           ZDC_DigiErrors_CAPID->Fill(i/9,i%9,1);
00733         }
00734       if(HotChannelError[i]==true)
00735         {
00736           ++numhoterrors;
00737           ZDC_Hot_Channel_Errors->Fill(i/9,(i%9),1);
00738         }
00739       if(DeadChannelError[i]==true)
00740         {
00741           DeadChannelCounter[i]+=1;
00742         }
00743       // If any of the above is true, fill the total channel errors
00744       if (ChannelHasDigiError[i] || HotChannelError[i])
00745         {
00746           ZDC_TotalChannelErrors->Fill(i/9,i%9,1);
00747           TotalChannelErrors[i]+=1;
00748         }
00749     }//end the for i<18 loop
00750  
00751 
00752     if (numdigierrors>0)
00753       ZDC_DigiErrorsVsLS->Fill(currentLS,numdigierrors); //could make this ->Fill(currentLS,1) if I want to count each event as only having one error even if multiple channels are in error
00754     if (numhoterrors>0)
00755       ZDC_HotChannelErrorsVsLS->Fill(currentLS,numhoterrors);
00757     //End of  filling Fall 2012  histograms
00759 
00760     //--------------------------------------
00761     // ZDC RecHit part 
00762     //--------------------------------------
00763     for (ZDCRecHitCollection::const_iterator rechit_iter = rechit.begin(); 
00764          rechit_iter != rechit.end(); ++rechit_iter)
00765       {         
00766         HcalZDCDetId id(rechit_iter->id());
00767         int Side      = (rechit_iter->id()).zside();
00768         int Section   = (rechit_iter->id()).section();
00769         int Channel   = (rechit_iter->id()).channel();
00770         //std::cout << "RecHitEnergy  " << zhit->energy() << "  RecHitTime  " << zhit->time() << std::endl;
00771         
00772         if(Section==1)
00773           { //EM
00774             if (Side ==1 ){ // Plus
00775               h_ZDCP_EM_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00776               h_ZDCP_EM_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00777             }
00778             if (Side == -1 ){ //Minus
00779               h_ZDCM_EM_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00780               h_ZDCM_EM_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00781             }
00782           } //EM
00783         else if(Section==2)
00784           { //HAD
00785             if (Side ==1 ){ //Plus
00786               h_ZDCP_HAD_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00787               h_ZDCP_HAD_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00788             }
00789             if (Side == -1 ){ //Minus
00790               h_ZDCM_HAD_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00791               h_ZDCM_HAD_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00792             }
00793           } // HAD
00794       } // loop on rechits
00795     
00796 } // end of event processing 
00797 /*
00798 ------------------------------------------------------------------------------------
00799 // This is what we did to find the good signal. After we've started to use only time slice 4,5,6.
00800 bool HcalZDCMonitor::isGood(std::vector<double>fData, double fCut, double fPercentage) {
00801   bool dec = false;
00802   int ts_max = -1;
00803   
00804   ts_max = getTSMax(fData);
00805   if (ts_max == 0 || ts_max == (int)(fData.size() - 1))
00806     return false;
00807   float sum = fData[ts_max - 1] + fData[ts_max + 1];
00808   
00809   // cout << "tsMax " << ts_max << " data[tsmax] " << mData[ts_max] << " sum " << sum << endl;
00810   if (fData[ts_max] > fCut && sum > (fData[ts_max] * fPercentage))
00811     dec = true;
00812   return dec;
00813 } // bool HcalZDCMonitor::isGood
00814 
00815 int HcalZDCMonitor::getTSMax(std::vector<double>fData) 
00816 {
00817   int ts_max = -100;
00818   double max = -999.;
00819   
00820   for (unsigned int j = 0; j < fData.size(); ++j) {
00821     if (max < fData[j]) {
00822       max = fData[j];
00823       ts_max = j;
00824     }
00825   }
00826   return ts_max;
00827 } // int HcalZDCMonitor::getTSMax()
00828 ------------------------------------------------------------------------------------
00829 */
00830 double HcalZDCMonitor::getTime(std::vector<double>fData, unsigned int ts_min, unsigned int ts_max, double &fSum) {
00831   double weightedTime = 0.;
00832   double SumT = 0.; 
00833   double Time = -999.;
00834   double digiThreshf = 99.5;
00835  
00836   for (unsigned int ts=ts_min; ts<=ts_max; ++ts) {
00837     if (fData[ts] > digiThreshf){ 
00838     weightedTime += ts * fData[ts];
00839     SumT += fData[ts];
00840     }
00841   }
00842 
00843   if (SumT > 0.) {
00844     Time = weightedTime / SumT;
00845   }
00846 
00847   fSum = SumT;
00848 
00849   return Time;
00850 
00851 } //double HcalZDCMonitor::getTime()
00852 
00853 
00854 void HcalZDCMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c) 
00855 {
00856 
00857   bool HadLumiError[18]={false};
00858 
00859   EventsVsLS->Fill(currentLS,EventCounter);
00860 
00861   if(Online_ == false)
00862     {//checks if DQM is in OFFLINE MODE
00863       for (int i=0;i<18;++i)
00864         {
00865           ChannelRatio[i]=(TotalChannelErrors[i])*1./EventCounter;
00866           if (ChannelRatio[i] <= MaxErrorRates_[i])
00867             {
00868               if (i<9)
00869                 {
00870                   PZDC_QualityIndexVsLB_->Fill(currentLS,ChannelWeighting_[i]);
00871                 }
00872               else
00873                 {
00874                   NZDC_QualityIndexVsLB_->Fill(currentLS,ChannelWeighting_[i]);
00875                 }
00876               if (ColdChannelCounter[i] >= OfflineColdThreshold_)//Begin Cold Error Plots
00877                 {
00878                   ZDC_Cold_Channel_Errors->Fill(i/9,i%9,ColdChannelCounter[i]);
00879                   ZDC_ColdChannelErrorsVsLS->Fill(currentLS,1);
00880                   ZDC_TotalChannelErrors->Fill(i/9,i%9,ColdChannelCounter[i]);//Can change this between 1, or the amount of errors (Currently the latter)
00881                   ColdChannelCounter[i]=0;
00882                   HadLumiError[i]=true;
00883                 }//END OF Cold Error Plot
00884               if (DeadChannelCounter[i] >= OfflineDeadThreshold_)
00885                 {//Begin Dead Error Plots
00886                   ZDC_Dead_Channel_Errors->Fill(i/9,i%9,DeadChannelCounter[i]);
00887                   ZDC_DeadChannelErrorsVsLS->Fill(currentLS,1);
00888                   ZDC_TotalChannelErrors->Fill(i/9,i%9,DeadChannelCounter[i]); //Could fill this with 1 or total dead errors (which is currently done)
00889                   DeadChannelCounter[i]=0;
00890                   HadLumiError[i]=true;
00891                 }//END OF Dead Channel Plots
00892               if (HadLumiError[i]==true)
00893                 {//Removing the QI for Dead of Cold Channels
00894                   if (i<9)
00895                     {
00896                       PZDC_QualityIndexVsLB_->Fill(currentLS,(-1*ChannelWeighting_[i]));
00897                     }
00898                   else 
00899                     {
00900                       NZDC_QualityIndexVsLB_->Fill(currentLS,(-1*ChannelWeighting_[i]));
00901                     }
00902                 }//END OF QI Removal
00903             }//END OF ChannelRatio[i]<=MaxErrorRates_[i]
00904           else
00905             {//This part only happens if ChannelRatio[i] > MaxErrorRates_[i]...Above you notice the QI plots become 'un-filled'. If the plot was never filled to begin with, then we do not want to remove from the plot  causing there to be a negative QI
00906               if (ColdChannelCounter[i] > OfflineColdThreshold_)
00907                 {//Begin Cold Error Plots
00908                   ZDC_Cold_Channel_Errors->Fill(i/9,i%9,ColdChannelCounter[i]);
00909                   ZDC_ColdChannelErrorsVsLS->Fill(currentLS,1);
00910                   ZDC_TotalChannelErrors->Fill(i/9,i%9,ColdChannelCounter[i]);
00911                   ColdChannelCounter[i]=0;
00912                 }//END OF Cold Error Plot
00913               if (DeadChannelCounter[i] > OfflineDeadThreshold_)
00914                 {//Begin Dead Error plots
00915                   ZDC_Dead_Channel_Errors->Fill(i/9,i%9,DeadChannelCounter[i]);
00916                   ZDC_DeadChannelErrorsVsLS->Fill(currentLS,1);
00917                   ZDC_TotalChannelErrors->Fill(i/9,i%9,DeadChannelCounter[i]);
00918                   DeadChannelCounter[i]=0;
00919                 }//END OF Dead Error Plots
00920             }
00921         }//END OF FOR LOOP
00922     }//END OF DQM OFFLINE PART
00923 
00924   if(Online_ == true)
00925     {//checks if DQM is in ONLINE MODE
00926       for (int i=0;i<18;++i)
00927         {
00928           ChannelRatio[i]=(TotalChannelErrors[i])*1./EventCounter;
00929           if (ChannelRatio[i] <= MaxErrorRates_[i])
00930             {
00931               if (i<9)
00932                 {
00933                   PZDC_QualityIndexVsLB_->Fill(currentLS,ChannelWeighting_[i]);
00934                 }
00935               else
00936                 {
00937                   NZDC_QualityIndexVsLB_->Fill(currentLS,ChannelWeighting_[i]);
00938                 }
00939               if (ColdChannelCounter[i] >= OnlineColdThreshold_)//Begin Cold Error Plots
00940                 {
00941                   ZDC_Cold_Channel_Errors->Fill(i/9,i%9,ColdChannelCounter[i]);
00942                   ZDC_ColdChannelErrorsVsLS->Fill(currentLS,1);
00943                   ZDC_TotalChannelErrors->Fill(i/9,i%9,ColdChannelCounter[i]);//Can change this between 1, or the amount of errors (Currently the latter)
00944                   ColdChannelCounter[i]=0;
00945                   HadLumiError[i]=true;
00946                 }//END OF Cold Error Plot
00947               if (DeadChannelCounter[i] >= OnlineDeadThreshold_)
00948                 {//Begin Dead Error Plots
00949                   ZDC_Dead_Channel_Errors->Fill(i/9,i%9,DeadChannelCounter[i]);
00950                   ZDC_DeadChannelErrorsVsLS->Fill(currentLS,1);
00951                   ZDC_TotalChannelErrors->Fill(i/9,i%9,DeadChannelCounter[i]); //Could fill this with 1 or total dead errors (which is currently done)
00952                   DeadChannelCounter[i]=0;
00953                   HadLumiError[i]=true;
00954                 }//END OF Dead Channel Plots
00955               if (HadLumiError[i]==true)
00956                 {//Removing the QI for Dead of Cold Channels
00957                   if (i<9)
00958                     {
00959                       PZDC_QualityIndexVsLB_->Fill(currentLS,(-1*ChannelWeighting_[i]));
00960                     }
00961                   else 
00962                     {
00963                       NZDC_QualityIndexVsLB_->Fill(currentLS,(-1*ChannelWeighting_[i]));
00964                     }
00965                 }//END OF QI Removal
00966             }//END OF ChannelRatio[i]<=MaxErrorRates_[i]
00967           else
00968             {//This part only happens if ChannelRatio[i] > MaxErrorRates_[i]...Above you notice the QI plots become 'un-filled'. If the plot was never filled to begin with, then we do not want to remove from the plot  causing there to be a negative QI
00969               if (ColdChannelCounter[i] > OnlineColdThreshold_)
00970                 {//Begin Cold Error Plots
00971                   ZDC_Cold_Channel_Errors->Fill(i/9,i%9,ColdChannelCounter[i]);
00972                   ZDC_ColdChannelErrorsVsLS->Fill(currentLS,1);
00973                   ZDC_TotalChannelErrors->Fill(i/9,i%9,ColdChannelCounter[i]);
00974                   ColdChannelCounter[i]=0;
00975                 }//END OF Cold Error Plot
00976               if (DeadChannelCounter[i] > OnlineDeadThreshold_)
00977                 {//Begin Dead Error plots
00978                   ZDC_Dead_Channel_Errors->Fill(i/9,i%9,DeadChannelCounter[i]);
00979                   ZDC_DeadChannelErrorsVsLS->Fill(currentLS,1);
00980                   ZDC_TotalChannelErrors->Fill(i/9,i%9,DeadChannelCounter[i]);
00981                   DeadChannelCounter[i]=0;
00982                 }//END OF Dead Error Plots
00983             }//end of ChannelRatio[i] > MaxErrorRates_[i] part
00984         }//END OF FOR LOOP
00985     }//END OF DQM ONLINE PART
00986 
00987 
00988 
00989   //if (LumiInOrder(lumiSeg.luminosityBlock())==false) return; // WHY DOESN'T THIS WORK?
00990   if (dbe_==0)
00991     {
00992       return;
00993     }
00994   HcalBaseDQMonitor::endLuminosityBlock(lumiSeg, c);
00995 
00996   for (int i = 0; i < 5; ++i) {   // EM Channels 
00997     // ZDC Plus 
00998     h_2D_charge->setBinContent(1, i + 1, h_ZDCP_EM_Charge[i]->getMean());
00999     h_2D_TSMean->setBinContent(1, i + 1, h_ZDCP_EM_TSMean[i]->getMean());
01000     h_2D_RecHitEnergy->setBinContent(1, i + 1, h_ZDCP_EM_RecHitEnergy[i]->getMean());
01001     h_2D_RecHitTime->setBinContent(1, i + 1, h_ZDCP_EM_RecHitTiming[i]->getMean());
01002     // ZDC Minus
01003     h_2D_charge->setBinContent(2, i + 1, h_ZDCM_EM_Charge[i]->getMean());
01004     h_2D_TSMean->setBinContent(2, i + 1, h_ZDCM_EM_TSMean[i]->getMean());
01005     h_2D_RecHitEnergy->setBinContent(2, i + 1, h_ZDCM_EM_RecHitEnergy[i]->getMean());
01006     h_2D_RecHitTime->setBinContent(2, i + 1, h_ZDCM_EM_RecHitTiming[i]->getMean());
01007   }
01008   for (int i = 0; i < 4; ++i) {   // HAD channels 
01009     // ZDC Plus 
01010     h_2D_charge->setBinContent(1, i + 6, h_ZDCP_HAD_Charge[i]->getMean());
01011     h_2D_TSMean->setBinContent(1, i + 6, h_ZDCP_HAD_TSMean[i]->getMean());
01012     h_2D_RecHitEnergy->setBinContent(1, i + 6, h_ZDCP_HAD_RecHitEnergy[i]->getMean());
01013     h_2D_RecHitTime->setBinContent(1, i + 6, h_ZDCP_HAD_RecHitTiming[i]->getMean());
01014     // ZDC Minus
01015     //h_ZDCM_HAD_Pulse[i]->Scale(10. / h_ZDCM_HAD_Pulse[i]->getEntries());
01016     h_2D_charge->setBinContent(2, i + 6, h_ZDCM_HAD_Charge[i]->getMean());
01017     h_2D_TSMean->setBinContent(2, i + 6, h_ZDCM_HAD_TSMean[i]->getMean());
01018     h_2D_RecHitEnergy->setBinContent(2, i + 6, h_ZDCM_HAD_RecHitEnergy[i]->getMean());
01019     h_2D_RecHitTime->setBinContent(2, i + 6, h_ZDCM_HAD_RecHitTiming[i]->getMean());
01020 
01021     // use ZDCProblemsCurrentLB_ for stuff
01022   }
01023 }// void HcalZDCMonitor::endLuminosityBlock()
01024 
01025 
01026 DEFINE_FWK_MODULE(HcalZDCMonitor);