CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/HcalMonitorTasks/src/HcalRecHitMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalRecHitMonitor.h"
00002 #include "FWCore/Framework/interface/LuminosityBlock.h"
00003 #include "FWCore/Common/interface/TriggerNames.h" 
00004 #include "CondFormats/HcalObjects/interface/HcalChannelStatus.h"
00005 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00006 
00007 #include "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
00008 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00009 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalCaloFlagLabels.h"
00010 #include "DataFormats/Common/interface/TriggerResults.h"
00011 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00012 #include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h" // for eta bounds
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 #include <cmath>
00015 
00016 HcalRecHitMonitor::HcalRecHitMonitor(const edm::ParameterSet& ps)
00017 {
00018   // Common Base Class parameters
00019   Online_                = ps.getUntrackedParameter<bool>("online",false);
00020   mergeRuns_             = ps.getUntrackedParameter<bool>("mergeRuns",false);
00021   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00022   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00023   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00024   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00025     prefixME_.append("/");
00026   subdir_                = ps.getUntrackedParameter<std::string>("TaskFolder","RecHitMonitor_Hcal/"); 
00027   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00028     subdir_.append("/");
00029   subdir_=prefixME_+subdir_;
00030   AllowedCalibTypes_     = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00031   skipOutOfOrderLS_      = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
00032   NLumiBlocks_           = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00033   makeDiagnostics_       = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00034 
00035   hbheRechitLabel_       = ps.getUntrackedParameter<edm::InputTag>("hbheRechitLabel");
00036   hoRechitLabel_         = ps.getUntrackedParameter<edm::InputTag>("hoRechitLabel");
00037   hfRechitLabel_         = ps.getUntrackedParameter<edm::InputTag>("hfRechitLabel");
00038   l1gtLabel_             = ps.getUntrackedParameter<edm::InputTag>("L1GTLabel"); // should be l1GtUnpack
00039 
00040   hltresultsLabel_       = ps.getUntrackedParameter<edm::InputTag>("HLTResultsLabel");
00041   HcalHLTBits_           = ps.getUntrackedParameter<std::vector<std::string> >("HcalHLTBits");
00042   MinBiasHLTBits_        = ps.getUntrackedParameter<std::vector<std::string> >("MinBiasHLTBits");
00043 
00044   // energy/ET threshold plots also require that at least one MinBias trigger bit fires
00045   energyThreshold_       = ps.getUntrackedParameter<double>("energyThreshold",2);
00046   HBenergyThreshold_     = ps.getUntrackedParameter<double>("HB_energyThreshold",energyThreshold_);
00047   HEenergyThreshold_     = ps.getUntrackedParameter<double>("HE_energyThreshold",energyThreshold_);
00048   HOenergyThreshold_     = ps.getUntrackedParameter<double>("HO_energyThreshold",energyThreshold_);
00049   HFenergyThreshold_     = ps.getUntrackedParameter<double>("HF_energyThreshold",energyThreshold_);
00050   
00051   ETThreshold_       = ps.getUntrackedParameter<double>("ETThreshold",0);
00052   HBETThreshold_     = ps.getUntrackedParameter<double>("HB_ETThreshold",ETThreshold_);
00053   HEETThreshold_     = ps.getUntrackedParameter<double>("HE_ETThreshold",ETThreshold_);
00054   HOETThreshold_     = ps.getUntrackedParameter<double>("HO_ETThreshold",ETThreshold_);
00055   HFETThreshold_     = ps.getUntrackedParameter<double>("HF_ETThreshold",ETThreshold_);
00056 
00057   timediffThresh_    = ps.getUntrackedParameter<double>("collisiontimediffThresh",10.);
00058 
00059 } //constructor
00060 
00061 HcalRecHitMonitor::~HcalRecHitMonitor()
00062 {
00063 } //destructor
00064 
00065 
00066 /* ------------------------------------ */ 
00067 
00068 
00069 void HcalRecHitMonitor::setup()
00070 {
00071   HcalBaseDQMonitor::setup();
00072 
00073 
00074   if (debug_>0)
00075     std::cout <<"<HcalRecHitMonitor::setup>  Setting up histograms"<<std::endl;
00076 
00077   // Can we include this just in the setup, or do we need to get a new logical map with every run?
00078   HcalLogicalMapGenerator gen;
00079   logicalMap=new HcalLogicalMap(gen.createMap());
00080 
00081   // RecHit Monitor - specific cfg variables
00082 
00083   if (debug_>1)
00084     std::cout <<"<HcalRecHitMonitor::setup>  Creating Histograms"<<std::endl;
00085 
00086   dbe_->setCurrentFolder(subdir_);
00087   h_TriggeredEvents=dbe_->book1D("EventTriggers","EventTriggers",3,-0.5,2.5);
00088   h_TriggeredEvents->setBinLabel(1,"AllEvents");
00089   h_TriggeredEvents->setBinLabel(2,"HLT_Minbias");
00090   h_TriggeredEvents->setBinLabel(3,"HLT_Hcal");
00091 
00092   dbe_->setCurrentFolder(subdir_+"rechit_parameters");
00093   MonitorElement* THR;
00094   dbe_->setCurrentFolder(subdir_+"rechit_parameters/thresholds");
00095   THR=dbe_->bookFloat("HB_Rechit_Energy_Threshold");
00096   THR->Fill(HBenergyThreshold_);
00097   THR=dbe_->bookFloat("HE_Rechit_Energy_Threshold");
00098   THR->Fill(HEenergyThreshold_);
00099   THR=dbe_->bookFloat("HO_Rechit_Energy_Threshold");
00100   THR->Fill(HOenergyThreshold_);
00101   THR=dbe_->bookFloat("HF_Rechit_Energy_Threshold");
00102   THR->Fill(HFenergyThreshold_);
00103   THR=dbe_->bookFloat("HB_Rechit_ET_Threshold");
00104   THR->Fill(HBETThreshold_);
00105   THR=dbe_->bookFloat("HE_Rechit_ET_Threshold");
00106   THR->Fill(HEETThreshold_);
00107   THR=dbe_->bookFloat("HO_Rechit_ET_Threshold");
00108   THR->Fill(HOETThreshold_);
00109   THR=dbe_->bookFloat("HF_Rechit_ET_Threshold");
00110   THR->Fill(HFETThreshold_);
00111   THR=dbe_->bookFloat("Maximum_HFM_HFP_time_difference_for_luminosityplots");
00112   THR->Fill(timediffThresh_);
00113 
00114   
00115   // Set up histograms that are filled by all rechits
00116   dbe_->setCurrentFolder(subdir_+"Distributions_AllRecHits");
00117   SetupEtaPhiHists(OccupancyByDepth,"RecHit Occupancy","");
00118   h_rechitieta = dbe_->book1D("HcalRecHitIeta",
00119                               "Hcal RecHit ieta",
00120                               83,-41.5,41.5);
00121   h_rechitiphi = dbe_->book1D("HcalRecHitIphi",
00122                               "Hcal RecHit iphi",
00123                               72,0.5,72.5);
00124 
00125   h_rechitieta_05 = dbe_->book1D("HcalRecHitIeta05",
00126                                  "Hcal RecHit ieta E>0.5 GeV",
00127                                  83,-41.5,41.5);
00128   h_rechitiphi_05 = dbe_->book1D("HcalRecHitIphi05",
00129                                  "Hcal RecHit iphi E>0.5 GeV",
00130                                  72,0.5,72.5);
00131   h_rechitieta_10 = dbe_->book1D("HcalRecHitIeta10",
00132                                  "Hcal RecHit ieta E>1.0 GeV",
00133                                  83,-41.5,41.5);
00134   h_rechitiphi_10 = dbe_->book1D("HcalRecHitIphi10",
00135                                  "Hcal RecHit iphi E>1.0 GeV",
00136                                  72,0.5,72.5);
00137   h_rechitieta_25 = dbe_->book1D("HcalRecHitIeta25",
00138                                  "Hcal RecHit ieta E>2.5 GeV",
00139                                  83,-41.5,41.5);
00140   h_rechitiphi_25 = dbe_->book1D("HcalRecHitIphi25",
00141                                  "Hcal RecHit iphi E>2.5 GeV",
00142                                  72,0.5,72.5);
00143   h_rechitieta_100 = dbe_->book1D("HcalRecHitIeta100",
00144                                   "Hcal RecHit ieta E>10.0 GeV",
00145                                   83,-41.5,41.5);
00146   h_rechitiphi_100 = dbe_->book1D("HcalRecHitIphi100",
00147                                   "Hcal RecHit iphi E>10.0 GeV",
00148                                   72,0.5,72.5);
00149 
00150 
00151 
00152   h_LumiPlot_LS_allevents = dbe_->book1D("AllEventsPerLS",
00153                                          "LS # of all events",
00154                                          NLumiBlocks_,0.5,NLumiBlocks_+0.5);
00155   h_LumiPlot_BX_allevents = dbe_->book1D("BX_allevents",
00156                                          "BX # of all events",
00157                                          3600,0,3600);
00158   h_LumiPlot_MinTime_vs_MinHT = dbe_->book2D("MinTime_vs_MinSumET",
00159                                              "Energy-Weighted Time vs Min (HF+,HF-) Scalar Sum ET;min Sum ET(GeV);time(ns)",
00160                                              100,0,10,80,-40,40);
00161 
00162   h_LumiPlot_timeHT_HFM = dbe_->book2D("HFM_Time_vs_SumET",
00163                                        "Energy-Weighted Time vs HFMinus Scalar Sum ET;Sum ET(GeV);time(ns)",
00164                                        100,0,10,80,-40,40);
00165   
00166   h_LumiPlot_timeHT_HFP = dbe_->book2D("HFP_Time_vs_SumET",
00167                                        "Energy-Weighted Time vs HFPlus Scalar Sum ET;Sum ET(GeV);time(ns)",
00168                                        100,0,10,80,-40,40);
00169 
00170 
00171   dbe_->setCurrentFolder(subdir_+"Distributions_AllRecHits/sumplots");
00172   SetupEtaPhiHists(SumEnergyByDepth,"RecHit Summed Energy","GeV");
00173   SetupEtaPhiHists(SqrtSumEnergy2ByDepth,"RecHit Sqrt Summed Energy2","GeV");
00174   SetupEtaPhiHists(SumTimeByDepth,"RecHit Summed Time","nS");
00175 
00176   // Histograms for events that passed MinBias triggers
00177   dbe_->setCurrentFolder(subdir_+"Distributions_PassedMinBias");
00178 
00179   h_HBP_weightedTime = dbe_->book1D("WeightedTime_HBP","Weighted Time for HBP",
00180                                     300,-150,150);
00181   h_HBM_weightedTime = dbe_->book1D("WeightedTime_HBM","Weighted Time for HBM",
00182                                     300,-150,150);
00183   h_HEP_weightedTime = dbe_->book1D("WeightedTime_HEP","Weighted Time for HEP",
00184                                     300,-150,150);
00185   h_HEM_weightedTime = dbe_->book1D("WeightedTime_HEM","Weighted Time for HEM",
00186                                     300,-150,150);
00187   h_HFP_weightedTime = dbe_->book1D("WeightedTime_HFP","Weighted Time for HFP",
00188                                     300,-150,150);
00189   h_HFM_weightedTime = dbe_->book1D("WeightedTime_HFM","Weighted Time for HFM",
00190                                     300,-150,150);
00191 
00192   h_HFtimedifference = dbe_->book1D("HFweightedtimeDifference",
00193                                     "Energy-Weighted time difference between HF+ and HF- passing MinBias (no HT cut)",
00194                                     251,-250.5,250.5);
00195   h_HEtimedifference = dbe_->book1D("HEweightedtimeDifference",
00196                                     "Energy-Weighted time difference between HE+ and HE- passing MinBias (no HT cut)",
00197                                     251,-250.5,250.5);
00198   
00199   HFP_HFM_Energy = dbe_->book2D("HFP_HFM_Energy",
00200                                 "HFP VS HFM Energy; Total Energy in HFMinus (TeV); Total Energy in HFPlus (TeV)",
00201                                 100,0,100, 100,0,100);
00202   
00203   // Would these work better as 2D plots?
00204   h_HFenergydifference = dbe_->book1D("HFenergyDifference",
00205                                       "Sum(E_HFPlus - E_HFMinus)/Sum(E_HFPlus + E_HFMinus)",
00206                                       200,-1,1);
00207   h_HEenergydifference = dbe_->book1D("HEenergyDifference",
00208                                       "Sum(E_HEPlus - E_HEMinus)/Sum(E_HEPlus + E_HEMinus)",
00209                                       200,-1,1);
00210 
00211   h_LumiPlot_LS_MinBiasEvents=dbe_->book1D("MinBiasEventsPerLS",
00212                                            "Number of MinBias Events vs LS (HT cut and HFM-HFP time cut)",
00213                                            NLumiBlocks_/10,0.5,NLumiBlocks_+0.5); 
00214   h_LumiPlot_LS_MinBiasEvents_notimecut=dbe_->book1D("MinBiasEventsPerLS_notimecut",
00215                                                      "Number of Events with MinBias vs LS (HFM,HFP HT>1,no time cut)",
00216                                                      NLumiBlocks_/10,0.5,NLumiBlocks_+0.5); 
00217 
00218   h_LumiPlot_SumHT_HFPlus_vs_HFMinus = dbe_->book2D("SumHT_plus_minus",
00219                                                     "HF+ Sum HT vs HF- Sum HT",60,0,30,60,0,30);
00220   h_LumiPlot_SumEnergy_HFPlus_vs_HFMinus = dbe_->book2D("SumEnergy_plus_minus",
00221                                                         "HF+ Sum Energy  vs HF- Sum Energy",
00222                                                         60,0,150,60,0,150);
00223   h_LumiPlot_timeHFPlus_vs_timeHFMinus = dbe_->book2D("timeHFplus_vs_timeHFminus",
00224                                                       "Energy-weighted time average of HF+ vs HF-",
00225                                                       60,-60,60,60,-60,60);
00226   h_LumiPlot_BX_MinBiasEvents = dbe_->book1D("BX_MinBias_Events_TimeCut",
00227                                           "BX # of MinBias events (HFM & HFP HT>1 & HFM-HFP time cut)",
00228                                           3600,0,3600);
00229   h_LumiPlot_BX_MinBiasEvents_notimecut = dbe_->book1D("BX_MinBias_Events_notimecut",
00230                                                        "BX # of MinBias events (HFM,HFP HT>1, no time cut)",
00231                                                        3600,0,3600);
00232   // threshold plots must pass MinBias Trigger
00233   SetupEtaPhiHists(OccupancyThreshByDepth,"Above Threshold RecHit Occupancy","");
00234   h_rechitieta_thresh = dbe_->book1D("HcalRecHitIeta_thresh",
00235                               "Hcal RecHit ieta above energy and ET threshold",
00236                               83,-41.5,41.5);
00237   h_rechitiphi_thresh = dbe_->book1D("HcalRecHitIphi_thresh",
00238                               "Hcal RecHit iphi above energy and ET threshold",
00239                               72,0.5,72.5);
00240 
00241   dbe_->setCurrentFolder(subdir_+"Distributions_PassedMinBias/sumplots");
00242   SetupEtaPhiHists(SumEnergyThreshByDepth,"Above Threshold RecHit Summed Energy","GeV");
00243   SetupEtaPhiHists(SumTimeThreshByDepth,"Above Threshold RecHit Summed Time","nS");
00244   SetupEtaPhiHists(SqrtSumEnergy2ThreshByDepth,"Above Threshold RecHit Sqrt Summed Energy2","GeV");
00245 
00246   dbe_->setCurrentFolder(subdir_+"Distributions_PassedMinBias/rechit_1D_plots");
00247   h_HBThreshTime=dbe_->book1D("HB_time_thresh", 
00248                               "HB RecHit Time Above Threshold",
00249                               int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00250   h_HBThreshOccupancy=dbe_->book1D("HB_occupancy_thresh",
00251                                    "HB RecHit Occupancy Above Threshold",260,-0.5,2599.5);
00252   h_HEThreshTime=dbe_->book1D("HE_time_thresh", 
00253                               "HE RecHit Time Above Threshold",
00254                               int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00255   h_HEThreshOccupancy=dbe_->book1D("HE_occupancy_thresh",
00256                                    "HE RecHit Occupancy Above Threshold",260,-0.5,2599.5);
00257   h_HOThreshTime=dbe_->book1D("HO_time_thresh", 
00258                               "HO RecHit Time Above Threshold",
00259                               int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00260   h_HOThreshOccupancy=dbe_->book1D("HO_occupancy_thresh",
00261                                    "HO RecHit Occupancy Above Threshold",217,-0.5,2169.5);
00262   h_HFThreshTime=dbe_->book1D("HF_time_thresh", 
00263                               "HF RecHit Time Above Threshold",
00264                               int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00265   h_HFThreshOccupancy=dbe_->book1D("HF_occupancy_thresh",
00266                                    "HF RecHit Occupancy Above Threshold",
00267                                    173,-0.5,1729.5);
00268 
00269   // Histograms for events that did passed Hcal-specfied HLT triggers
00270   dbe_->setCurrentFolder(subdir_+"Distributions_PassedHcalHLTriggers");
00271   
00272   h_LumiPlot_BX_HcalHLTEvents = dbe_->book1D("BX_HcalHLT_Events_TimeCut",
00273                                           "BX # of HcalHLT events (HFM & HFP HT>1 & HFM-HFP time cut)",
00274                                           3600,0,3600);
00275   h_LumiPlot_BX_HcalHLTEvents_notimecut = dbe_->book1D("BX_HcalHLT_Events_notimecut",
00276                                                        "BX # of HcalHLT events (HFM,HFP HT>1, no time cut)",
00277                                                        3600,0,3600);
00278   h_LumiPlot_LS_HcalHLTEvents=dbe_->book1D("HcalHLTEventsPerLS",
00279                                            "Number of HcalHLT Events vs LS (HT cut and HFM-HFP time cut)",
00280                                            NLumiBlocks_/10,0.5,NLumiBlocks_+0.5); 
00281   h_LumiPlot_LS_HcalHLTEvents_notimecut=dbe_->book1D("HcalHLTEventsPerLS_notimecut",
00282                                                      "Number of Events with HcalHLT vs LS (HFM,HFP HT>1,no time cut)",
00283                                                      NLumiBlocks_/10,0.5,NLumiBlocks_+0.5); 
00284   
00285 
00286   dbe_->setCurrentFolder(subdir_+"Distributions_PassedHcalHLTriggers/");
00287   h_HF_HcalHLT_weightedtimedifference = dbe_->book1D("HF_HcalHLT_weightedtimeDifference",
00288                                              "Energy-Weighted time difference between HF+ and HF- Hcal HLT",
00289                                              251,-250.5,250.5);
00290   h_HE_HcalHLT_weightedtimedifference = dbe_->book1D("HE_HcalHLT_weightedtimeDifference",
00291                                              "Energy-Weighted time difference between HE+ and HE- Hcal HLT",
00292                                              251,-250.5,250.5);
00293   h_HF_HcalHLT_energydifference = dbe_->book1D("HF_HcalHLT_energyDifference",
00294                                              "Sum(E_HFPlus - E_HFMinus)/Sum(E_HFPlus + E_HFMinus)",
00295                                              200,-1,1);
00296   h_HE_HcalHLT_energydifference = dbe_->book1D("HE_HcalHLT_energyDifference",
00297                                              "Sum(E_HEPlus - E_HEMinus)/Sum(E_HEPlus + E_HEMinus)",
00298                                              200,-1,1);
00299 
00300   // Do we want separate directories for Minbias, other flags at some point?
00301   dbe_->setCurrentFolder(subdir_+"AnomalousCellFlags");// HB Flag Histograms
00302 
00303 
00304   h_HFLongShort_vs_LS=dbe_->book1D("HFLongShort_vs_LS",
00305                                    "HFLongShort Flags vs Lumi Section",
00306                                    NLumiBlocks_/10,0.5,0.5+NLumiBlocks_);
00307   h_HFDigiTime_vs_LS=dbe_->book1D("HFDigiTime_vs_LS",
00308                                   "HFDigiTime Flags vs Lumi Section",
00309                                   NLumiBlocks_/10,0.5,0.5+NLumiBlocks_);
00310   h_HBHEHPDMult_vs_LS=dbe_->book1D("HBHEHPDMult_vs_LS",
00311                                    "HBHEHPDMult Flags vs Lumi Section",
00312                                    NLumiBlocks_/10,0.5,0.5+NLumiBlocks_);
00313   h_HBHEPulseShape_vs_LS=dbe_->book1D("HBHEPulseShape_vs_LS",
00314                                       "HBHEPulseShape Flags vs Lumi Section",
00315                                       NLumiBlocks_/10,0.5,0.5+NLumiBlocks_);
00316 
00317   h_HF_FlagCorr=dbe_->book2D("HF_FlagCorrelation",
00318                              "HF LongShort vs. DigiTime flags; DigiTime; LongShort", 
00319                              2,-0.5,1.5,2,-0.5,1.5);
00320   h_HF_FlagCorr->setBinLabel(1,"OFF",1);
00321   h_HF_FlagCorr->setBinLabel(2,"ON",1);
00322   h_HF_FlagCorr->setBinLabel(1,"OFF",2);
00323   h_HF_FlagCorr->setBinLabel(2,"ON",2);
00324 
00325   h_HBHE_FlagCorr=dbe_->book2D("HBHE_FlagCorrelation",
00326                                "HBHE HpdHitMultiplicity vs. PulseShape flags; PulseShape; HpdHitMultiplicity", 
00327                                2,-0.5,1.5,2,-0.5,1.5);
00328   h_HBHE_FlagCorr->setBinLabel(1,"OFF",1);
00329   h_HBHE_FlagCorr->setBinLabel(2,"ON",1);
00330   h_HBHE_FlagCorr->setBinLabel(1,"OFF",2);
00331   h_HBHE_FlagCorr->setBinLabel(2,"ON",2);
00332 
00333   h_FlagMap_HPDMULT=dbe_->book2D("FlagMap_HPDMULT",
00334                                  "RBX Map of HBHEHpdHitMultiplicity Flags;RBX;RM",
00335                                   72,-0.5,71.5,4,0.5,4.5);
00336   h_FlagMap_PULSESHAPE=dbe_->book2D("FlagMap_PULSESHAPE",
00337                                     "RBX Map of HBHEPulseShape Flags;RBX;RM",
00338                                   72,-0.5,71.5,4,0.5,4.5);
00339   h_FlagMap_DIGITIME=dbe_->book2D("FlagMap_DIGITIME",
00340                                   "RBX Map of HFDigiTime Flags;RBX;RM",
00341                                   24,131.5,155.5,4,0.5,4.5);
00342   h_FlagMap_LONGSHORT=dbe_->book2D("FlagMap_LONGSHORT",
00343                                    "RBX Map of HFLongShort Flags;RBX;RM",
00344                                    24,131.5,155.5,4,0.5,4.5);
00345 
00346   h_FlagMap_TIMEADD=dbe_->book2D("FlagMap_TIMEADD",
00347                                  "RBX Map of Timing Added Flags;RBX;RM",
00348                                    156,-0.5,155.5,4,0.5,4.5);
00349   h_FlagMap_TIMESUBTRACT=dbe_->book2D("FlagMap_TIMESUBTRACT",
00350                                       "RBX Map of Timing Subtracted Flags;RBX;RM",
00351                                    156,-0.5,155.5,4,0.5,4.5);
00352   h_FlagMap_TIMEERROR=dbe_->book2D("FlagMap_TIMEERROR",
00353                                    "RBX Map of Timing Error Flags;RBX;RM",
00354                                    156,-0.5,155.5,4,0.5,4.5);
00355 
00356   h_HBflagcounter=dbe_->book1D("HBflags","HB flags",32,-0.5,31.5);
00357   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHEHpdHitMultiplicity, "HpdHitMult",1);
00358   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHEPulseShape, "PulseShape",1);
00359   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_R1R2, "HSCP R1R2",1);
00360   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_FracLeader, "HSCP FracLeader",1);
00361   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_OuterEnergy, "HSCP OuterEnergy",1);
00362   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_ExpFit, "HSCP ExpFit",1);
00363   // 2-bit timing counter
00364   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHETimingTrustBits,"TimingTrust1",1);
00365   h_HBflagcounter->setBinLabel(2+HcalCaloFlagLabels::HBHETimingTrustBits,"TimingTrust2",1);
00366   //3-bit timing shape cut
00367   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHETimingShapedCutsBits,"TimingShape1",1);
00368   h_HBflagcounter->setBinLabel(2+HcalCaloFlagLabels::HBHETimingShapedCutsBits,"TimingShape2",1);
00369   h_HBflagcounter->setBinLabel(3+HcalCaloFlagLabels::HBHETimingShapedCutsBits,"TimingShape3",1);
00370 
00371   // common flags
00372   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingSubtractedBit, "Subtracted",1);
00373   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingAddedBit, "Added",1);
00374   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingErrorBit, "TimingError",1);
00375   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::ADCSaturationBit, "Saturation",1);
00376   h_HBflagcounter->setBinLabel(1+HcalCaloFlagLabels::Fraction2TS,"Frac2TS",1);
00377 
00378   // HE Flag Histograms
00379   h_HEflagcounter=dbe_->book1D("HEflags","HE flags",32,-0.5,31.5);
00380   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHEHpdHitMultiplicity, "HpdHitMult",1);
00381   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHEPulseShape, "PulseShape",1);
00382   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_R1R2, "HSCP R1R2",1);
00383   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_FracLeader, "HSCP FracLeader",1);
00384   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_OuterEnergy, "HSCP OuterEnergy",1);
00385   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HSCP_ExpFit, "HSCP ExpFit",1);
00386   // 2-bit timing counter
00387   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHETimingTrustBits,"TimingTrust1",1);
00388   h_HEflagcounter->setBinLabel(2+HcalCaloFlagLabels::HBHETimingTrustBits,"TimingTrust2",1);
00389   //3-bit timing shape cut
00390   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::HBHETimingShapedCutsBits,"TimingShape1",1);
00391   h_HEflagcounter->setBinLabel(2+HcalCaloFlagLabels::HBHETimingShapedCutsBits,"TimingShape2",1);
00392   h_HEflagcounter->setBinLabel(3+HcalCaloFlagLabels::HBHETimingShapedCutsBits,"TimingShape3",1);
00393   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingSubtractedBit, "Subtracted",1);
00394   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingAddedBit, "Added",1);
00395   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingErrorBit, "TimingError",1);
00396   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::ADCSaturationBit, "Saturation",1);
00397   h_HEflagcounter->setBinLabel(1+HcalCaloFlagLabels::Fraction2TS,"Frac2TS",1);
00398 
00399   // HO Flag Histograms
00400   h_HOflagcounter=dbe_->book1D("HOflags","HO flags",32,-0.5,31.5);
00401   h_HOflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingSubtractedBit, "Subtracted",1);
00402   h_HOflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingAddedBit, "Added",1);
00403   h_HOflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingErrorBit, "TimingError",1);
00404   h_HOflagcounter->setBinLabel(1+HcalCaloFlagLabels::ADCSaturationBit, "Saturation",1);
00405   h_HOflagcounter->setBinLabel(1+HcalCaloFlagLabels::Fraction2TS,"Frac2TS",1);
00406 
00407   // HF Flag Histograms
00408   h_HFflagcounter=dbe_->book1D("HFflags","HF flags",32,-0.5,31.5);
00409   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::HFLongShort, "LongShort",1);
00410   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::HFDigiTime, "DigiTime",1);
00411   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::HFTimingTrustBits,"TimingTrust1",1);
00412   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingSubtractedBit, "Subtracted",1);
00413   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingAddedBit, "Added",1);
00414   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::TimingErrorBit, "TimingError",1);
00415   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::ADCSaturationBit, "Saturation",1);
00416   h_HFflagcounter->setBinLabel(1+HcalCaloFlagLabels::Fraction2TS,"Frac2TS",1);
00417 
00418   h_HBflagcounter->getTH1F()->LabelsOption("v");
00419   h_HEflagcounter->getTH1F()->LabelsOption("v");
00420   h_HOflagcounter->getTH1F()->LabelsOption("v");
00421   h_HFflagcounter->getTH1F()->LabelsOption("v");
00422 
00423 
00424   // Diagnostic plots are currently filled for all rechits (no trigger/threshold requirement)
00425   // hb
00426   dbe_->setCurrentFolder(subdir_+"diagnostics/hb");
00427   
00428   h_HBTimeVsEnergy=dbe_->book2D("HBTimeVsEnergy","HB Time Vs Energy (All RecHits);Energy (GeV); time(nS)",100,0,500,40,-100,100);
00429 
00430   h_HBsizeVsLS=dbe_->bookProfile("HBRecHitsVsLB","HB RecHits vs Luminosity Block",
00431                                  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
00432                                  100,0,10000);
00433 
00434   h_HBTime=dbe_->book1D("HB_time","HB RecHit Time",
00435                         int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00436   h_HBOccupancy=dbe_->book1D("HB_occupancy",
00437                              "HB RecHit Occupancy",260,-0.5,2599.5);
00438   
00439   //he
00440   dbe_->setCurrentFolder(subdir_+"diagnostics/he");
00441 
00442   h_HETimeVsEnergy=dbe_->book2D("HETimeVsEnergy","HE Time Vs Energy (All RecHits);Energy (GeV); time(nS)",100,0,500,40,-100,100);
00443 
00444   h_HEsizeVsLS=dbe_->bookProfile("HERecHitsVsLB","HE RecHits vs Luminosity Block",
00445                                  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
00446                                  100,0,10000);
00447         
00448   h_HETime=dbe_->book1D("HE_time","HE RecHit Time",
00449                         int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00450   h_HEOccupancy=dbe_->book1D("HE_occupancy","HE RecHit Occupancy",260,-0.5,2599.5);
00451    
00452   // ho
00453   dbe_->setCurrentFolder(subdir_+"diagnostics/ho");     
00454 
00455   h_HOTimeVsEnergy=dbe_->book2D("HOTimeVsEnergy","HO Time Vs Energy (All RecHits);Energy (GeV); time(nS)",100,0,500,40,-100,100);
00456 
00457   h_HOsizeVsLS=dbe_->bookProfile("HORecHitsVsLB","HO RecHits vs Luminosity Block",
00458                                  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
00459                                  100,0,10000);
00460   h_HOTime=dbe_->book1D("HO_time",
00461                         "HO RecHit Time",
00462                         int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00463   h_HOOccupancy=dbe_->book1D("HO_occupancy",
00464                              "HO RecHit Occupancy",217,-0.5,2169.5);
00465   
00466   // hf
00467   dbe_->setCurrentFolder(subdir_+"diagnostics/hf");
00468 
00469   h_HFTimeVsEnergy=dbe_->book2D("HFTimeVsEnergy","HF Time Vs Energy (All RecHits);Energy (GeV); time(nS)",100,0,500,40,-100,100);
00470 
00471   h_HFsizeVsLS=dbe_->bookProfile("HFRecHitsVsLB",
00472                                  "HF RecHits vs Luminosity Block",
00473                                  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
00474                                  100, 0,10000); 
00475   h_HFTime=dbe_->book1D("HF_time","HF RecHit Time",
00476                         int(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN),RECHITMON_TIME_MIN,RECHITMON_TIME_MAX);
00477   h_HFOccupancy=dbe_->book1D("HF_occupancy","HF RecHit Occupancy",173,-0.5,1729.5);
00478 
00479   // clear all counters, reset histograms
00480   this->zeroCounters();
00481   this->reset();
00482 
00483   return;
00484 } //void HcalRecHitMonitor::setup(...)
00485 
00486 void HcalRecHitMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00487 {
00488 
00489   if (debug_>0) std::cout <<"HcalRecHitMonitor::beginRun():  task =  '"<<subdir_<<"'"<<std::endl;
00490   HcalBaseDQMonitor::beginRun(run, c);
00491   if (tevt_==0) // create histograms, if they haven't been created already
00492     this->setup();
00493   // Clear histograms at the start of each run if not merging runs
00494   if (mergeRuns_==false)
00495     this->reset();
00496 
00497   if (tevt_!=0) return;
00498   // create histograms displaying trigger parameters?  Specify names?
00499   dbe_->setCurrentFolder(subdir_+"rechit_parameters");
00500   MonitorElement* trig;
00501   std::string tnames="";
00502   if (HcalHLTBits_.size()>0)
00503     tnames=HcalHLTBits_[0];
00504   for (unsigned int i=1;i<HcalHLTBits_.size();++i)
00505     tnames=tnames + " OR " + HcalHLTBits_[i];
00506   trig=dbe_->bookString("HcalHLTriggerRequirements",tnames);
00507   tnames="";
00508   if (MinBiasHLTBits_.size()>0)
00509     tnames=MinBiasHLTBits_[0];
00510   for (unsigned int i=1;i<MinBiasHLTBits_.size();++i)
00511     tnames=tnames + " OR " + MinBiasHLTBits_[i];
00512   trig=dbe_->bookString("MinBiasHLTriggerRequirements",tnames);
00513   return;
00514   
00515 } //void HcalRecHitMonitor::beginRun(...)
00516 
00517 
00518 void HcalRecHitMonitor::endRun(const edm::Run& run, const edm::EventSetup& c)
00519 {
00520   if (debug_>0) std::cout <<"HcalRecHitMonitor::endRun():  task =  '"<<subdir_<<"'"<<std::endl;
00521 
00522   //Any special fill calls needed?  Shouldn't be necessary; last endLuminosityBlock should do necessary fills
00523 } // void HcalRecHitMonitor::endrun(...)
00524 
00525 
00526 /* --------------------------- */
00527 
00528 void HcalRecHitMonitor::reset()
00529 {
00530   std::vector<MonitorElement*> hists = dbe_->getAllContents(subdir_);
00531   for (unsigned int i=0;i<hists.size();++i)
00532     {
00533       if (hists[i]->kind()==MonitorElement::DQM_KIND_TH1F ||
00534           hists[i]->kind()==MonitorElement::DQM_KIND_TH2F ||
00535           hists[i]->kind()==MonitorElement::DQM_KIND_TPROFILE)
00536         hists[i]->Reset();
00537     }
00538 }  
00539 
00540 void HcalRecHitMonitor::endJob()
00541 {
00542   if (!enableCleanup_) return;
00543   HcalBaseDQMonitor::cleanup();
00544   this->cleanup();
00545 }
00546 
00547 
00548 /* --------------------------------- */
00549 
00550 void HcalRecHitMonitor::cleanup()
00551 {
00552   //Add code to clean out subdirectories
00553   if (!enableCleanup_) return;
00554   if (dbe_)
00555     {
00556       dbe_->setCurrentFolder(subdir_); dbe_->removeContents();
00557       dbe_->setCurrentFolder(subdir_+"rechit_parameters"); dbe_->removeContents();
00558       dbe_->setCurrentFolder(subdir_+"rechit_parameters/thresholds"); dbe_->removeContents();
00559       dbe_->setCurrentFolder(subdir_+"Distributions_AllRecHits"); dbe_->removeContents();
00560       dbe_->setCurrentFolder(subdir_+"Distributions_AllRecHits/sumplots"); dbe_->removeContents();
00561       dbe_->setCurrentFolder(subdir_+"Distributions_PassedMinBias"); dbe_->removeContents();
00562       dbe_->setCurrentFolder(subdir_+"Distributions_PassedMinBias/sumplots"); dbe_->removeContents();
00563       dbe_->setCurrentFolder(subdir_+"Distributions_PassedHcalHLTriggers"); dbe_->removeContents();
00564       dbe_->setCurrentFolder(subdir_+"Distributions_PassedHcalHLTriggers/passedTechTriggers/"); dbe_->removeContents();
00565 
00566       dbe_->setCurrentFolder(subdir_+"AnomalousCellFlags"); dbe_->removeContents();
00567       dbe_->setCurrentFolder(subdir_+"diagnostics/hb"); dbe_->removeContents();
00568       dbe_->setCurrentFolder(subdir_+"diagnostics/he"); dbe_->removeContents();
00569       dbe_->setCurrentFolder(subdir_+"diagnostics/ho"); dbe_->removeContents();
00570       dbe_->setCurrentFolder(subdir_+"diagnostics/hf"); dbe_->removeContents();
00571     }
00572   return;
00573 } // void HcalRecHitMonitor::cleanup()
00574 
00575 /* -------------------------------- */
00576 
00577 void HcalRecHitMonitor::analyze(edm::Event const&e, edm::EventSetup const&s)
00578 {
00579   if (debug_>0)  std::cout <<"HcalRecHitMonitor::analyze; debug = "<<debug_<<std::endl;
00580 
00581   if (!IsAllowedCalibType()) return;
00582   if (LumiInOrder(e.luminosityBlock())==false) return;
00583 
00584   // Get objects
00585   edm::Handle<HBHERecHitCollection> hbhe_rechit;
00586   edm::Handle<HORecHitCollection> ho_rechit;
00587   edm::Handle<HFRecHitCollection> hf_rechit;
00588 
00589   if (!(e.getByLabel(hbheRechitLabel_,hbhe_rechit)))
00590     {
00591       edm::LogWarning("HcalHotCellMonitor")<< hbheRechitLabel_<<" hbhe_rechit not available";
00592       return;
00593     }
00594 
00595   if (!(e.getByLabel(hfRechitLabel_,hf_rechit)))
00596     {
00597       edm::LogWarning("HcalHotCellMonitor")<< hfRechitLabel_<<" hf_rechit not available";
00598       return;
00599     }
00600   
00601   if (!(e.getByLabel(hoRechitLabel_,ho_rechit)))
00602     {
00603       edm::LogWarning("HcalHotCellMonitor")<< hoRechitLabel_<<" ho_rechit not available";
00604       return;
00605     }
00606 
00607 
00608   h_LumiPlot_LS_allevents->Fill(currentLS);
00609   h_LumiPlot_BX_allevents->Fill(e.bunchCrossing());
00610   processEvent(*hbhe_rechit, *ho_rechit, *hf_rechit, e.bunchCrossing(), e);
00611 
00612   HcalBaseDQMonitor::analyze(e,s);
00613 } // void HcalRecHitMonitor::analyze()
00614 
00615 
00616 void HcalRecHitMonitor::processEvent(const HBHERecHitCollection& hbHits,
00617                                      const HORecHitCollection& hoHits,
00618                                      const HFRecHitCollection& hfHits,
00619                                      int BCN,
00620                                      const edm::Event & iEvent
00621                                      )
00622 {
00623 
00624   
00625   if (debug_>1) std::cout <<"<HcalRecHitMonitor::processEvent> Processing event..."<<std::endl;
00626 
00627 
00628   bool passedHcalHLT=false;
00629   bool passedMinBiasHLT=false;
00630 
00631   edm::Handle<edm::TriggerResults> hltRes;
00632   if (!(iEvent.getByLabel(hltresultsLabel_,hltRes)))
00633     {
00634       if (debug_>0) edm::LogWarning("HcalRecHitMonitor")<<" Could not get HLT results with tag "<<hltresultsLabel_<<std::endl;
00635     }
00636   else
00637     {
00638       const edm::TriggerNames & triggerNames = iEvent.triggerNames(*hltRes);
00639       const unsigned int nTrig(triggerNames.size());
00640       for (unsigned int i=0;i<nTrig;++i)
00641         {
00642           // trigger decision is based on 'OR' of any specified trigger names
00643           for (unsigned int k=0;k<HcalHLTBits_.size();++k)
00644             {
00645               // if (triggerNames.triggerName(i)==HcalHLTBits_[k] && hltRes->accept(i))
00646               if (triggerNames.triggerName(i).find(HcalHLTBits_[k])!=std::string::npos && hltRes->accept(i))
00647                 { 
00648                   passedHcalHLT=true;
00649                   break;
00650                 }
00651             }
00652           // repeat for minbias triggers
00653           for (unsigned int k=0;k<MinBiasHLTBits_.size();++k)
00654             {
00655               // if (triggerNames.triggerName(i)==MinBiasHLTBits_[k] && hltRes->accept(i))              
00656               if (triggerNames.triggerName(i).find(MinBiasHLTBits_[k])!=std::string::npos && hltRes->accept(i))
00657                 { 
00658                   passedMinBiasHLT=true;
00659                   break;
00660                 }
00661             }
00662         }
00663     } //else
00664 
00665   if (debug_>2 && passedHcalHLT)  std::cout <<"\t<HcalRecHitMonitor::processEvent>  Passed Hcal HLT trigger  "<<std::endl;
00666   if (debug_>2 && passedMinBiasHLT)  std::cout <<"\t<HcalRecHitMonitor::processEvent>  Passed MinBias HLT trigger  "<<std::endl;
00667   
00668   h_TriggeredEvents->Fill(0); // all events
00669   if (passedMinBiasHLT) h_TriggeredEvents->Fill(1); // Minbias;
00670   if (passedHcalHLT)    h_TriggeredEvents->Fill(2); // hcal HLT
00671   processEvent_rechit(hbHits, hoHits, hfHits,passedHcalHLT,passedMinBiasHLT,BCN);
00672 
00673   return;
00674 } // void HcalRecHitMonitor::processEvent(...)
00675 
00676 
00677 /* --------------------------------------- */
00678 
00679 
00680 void HcalRecHitMonitor::processEvent_rechit( const HBHERecHitCollection& hbheHits,
00681                                              const HORecHitCollection& hoHits,
00682                                              const HFRecHitCollection& hfHits,
00683                                              bool passedHcalHLT,
00684                                              bool passedMinBiasHLT,
00685                                              int BCN)
00686 {
00687   // Gather rechit info
00688   
00689   //const float area[]={0.111,0.175,0.175,0.175,0.175,0.175,0.174,0.178,0.172,0.175,0.178,0.346,0.604};
00690 
00691   if (debug_>1) std::cout <<"<HcalRecHitMonitor::processEvent_rechitenergy> Processing rechits..."<<std::endl;
00692   
00693   // loop over HBHE
00694   
00695   int     hbocc=0;
00696   int     heocc=0;
00697   int     hboccthresh=0;
00698   int     heoccthresh=0;
00699 
00700   double HtPlus =0, HtMinus=0;
00701   double HFePlus=0, HFeMinus=0;
00702   double HBePlus=0, HBeMinus=0;
00703   double HEePlus=0, HEeMinus=0;
00704   double HFtPlus=0, HFtMinus=0;
00705   double HBtPlus=0, HBtMinus=0;
00706   double HEtPlus=0, HEtMinus=0;
00707 
00708   int hbpocc=0, hbmocc=0, hepocc=0, hemocc=0, hfpocc=0, hfmocc=0;
00709 
00710   for (unsigned int i=0;i<4;++i)
00711     {
00712       OccupancyByDepth.depth[i]->update();
00713       OccupancyThreshByDepth.depth[i]->update();
00714       SumEnergyByDepth.depth[i]->update();
00715       SqrtSumEnergy2ByDepth.depth[i]->update();
00716       SumTimeByDepth.depth[i]->update();
00717     }
00718     
00719   h_HBflagcounter->update();
00720   h_HEflagcounter->update();
00721   h_HFflagcounter->update();
00722   h_HOflagcounter->update();
00723   
00724   
00725   for (HBHERecHitCollection::const_iterator HBHEiter=hbheHits.begin(); HBHEiter!=hbheHits.end(); ++HBHEiter) 
00726     { // loop over all hits
00727       float en = HBHEiter->energy();
00728       float ti = HBHEiter->time();
00729       HcalDetId id(HBHEiter->detid().rawId());
00730       int ieta = id.ieta();
00731       int iphi = id.iphi();
00732       int depth = id.depth();
00733 
00734       if (en>0.5)
00735         {
00736           h_rechitieta_05->Fill(ieta);
00737           h_rechitiphi_05->Fill(iphi);
00738           if (en>1.)
00739             {
00740               h_rechitieta_10->Fill(ieta);
00741               h_rechitiphi_10->Fill(iphi);
00742               if (en>2.5)
00743                 {
00744                   h_rechitieta_25->Fill(ieta);
00745                   h_rechitiphi_25->Fill(iphi);
00746                   if (en>10.)
00747                     {
00748                       h_rechitieta_100->Fill(ieta);
00749                       h_rechitiphi_100->Fill(iphi);
00750                     }
00751                 }
00752             }
00753         }
00754 
00755 
00756 
00757       HcalSubdetector subdet = id.subdet();
00758       double fEta=fabs(0.5*(theHBHEEtaBounds[abs(ieta)-1]+theHBHEEtaBounds[abs(ieta)]));
00759 
00760       int calcEta = CalcEtaBin(subdet,ieta,depth);
00761       int rbxindex=logicalMap->getHcalFrontEndId(HBHEiter->detid()).rbxIndex();
00762       int rm= logicalMap->getHcalFrontEndId(HBHEiter->detid()).rm();
00763 
00764       // Fill HBHE flag plots
00765       h_HBHE_FlagCorr->Fill(HBHEiter->flagField(HcalCaloFlagLabels::HBHEPulseShape),
00766                             HBHEiter->flagField(HcalCaloFlagLabels::HBHEHpdHitMultiplicity)); 
00767 
00768       if (HBHEiter->flagField(HcalCaloFlagLabels::HBHEHpdHitMultiplicity))
00769         {
00770           h_FlagMap_HPDMULT->Fill(rbxindex,rm);
00771           h_HBHEHPDMult_vs_LS->Fill(currentLS,1);
00772         }
00773       if (HBHEiter->flagField(HcalCaloFlagLabels::HBHEPulseShape))
00774         {
00775           h_FlagMap_PULSESHAPE->Fill(rbxindex,rm);
00776           h_HBHEPulseShape_vs_LS->Fill(currentLS,1);
00777         }
00778       if (HBHEiter->flagField(HcalCaloFlagLabels::TimingSubtractedBit))
00779         h_FlagMap_TIMESUBTRACT->Fill(rbxindex,rm);
00780       else if (HBHEiter->flagField(HcalCaloFlagLabels::TimingAddedBit))
00781         h_FlagMap_TIMEADD->Fill(rbxindex,rm);
00782       else if (HBHEiter->flagField(HcalCaloFlagLabels::TimingErrorBit))
00783         h_FlagMap_TIMEERROR->Fill(rbxindex,rm);
00784 
00785       if (subdet==HcalBarrel)
00786         {
00787           if (en>HBenergyThreshold_)
00788             h_HBTimeVsEnergy->Fill(en,ti);
00789           //Looping over HB searching for flags --- cris
00790           for (int f=0;f<32;f++)
00791             {
00792               // Let's display HSCP just to see if these bits are set
00793               /*
00794                if (f == HcalCaloFlagLabels::HSCP_R1R2)         continue;
00795                if (f == HcalCaloFlagLabels::HSCP_FracLeader)   continue;
00796                if (f == HcalCaloFlagLabels::HSCP_OuterEnergy)  continue;
00797                if (f == HcalCaloFlagLabels::HSCP_ExpFit)       continue;
00798               */
00799               if (HBHEiter->flagField(f))
00800                 ++HBflagcounter_[f];
00801             }
00802           ++occupancy_[calcEta][iphi-1][depth-1];
00803           energy_[calcEta][iphi-1][depth-1]+=en;
00804           energy2_[calcEta][iphi-1][depth-1]+=pow(en,2);
00805           time_[calcEta][iphi-1][depth-1]+=ti;
00806           if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
00807             h_HBTime->Fill(ti);
00808           else
00809             ++HBtime_[int(ti-RECHITMON_TIME_MIN)];
00810           ++hbocc; 
00811 
00812           // Threshold plots;  require E> threshold and minbias trigger
00813           if (
00814               en>=HBenergyThreshold_ && 
00815               en/cosh(fEta)>=HBETThreshold_ 
00816               ) 
00817             {
00818               if (passedMinBiasHLT==true)
00819                 {
00820                   ++occupancy_thresh_[calcEta][iphi-1][depth-1];
00821                   energy_thresh_[calcEta][iphi-1][depth-1]+=en;
00822                   energy2_thresh_[calcEta][iphi-1][depth-1]+=pow(en,2);
00823                   time_thresh_[calcEta][iphi-1][depth-1]+=ti;
00824                   
00825                   ++hboccthresh;
00826                   if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
00827                     h_HBThreshTime->Fill(ti);
00828                   else
00829                     ++HBtime_thresh_[int(ti-RECHITMON_TIME_MIN)];
00830                 }
00831 
00832               if (ieta>0)
00833                 {
00834                   HBePlus+=en;
00835                   HBtPlus+=ti*en;
00836                   hbpocc++;
00837                 }
00838               else
00839                 {
00840                   HBeMinus+=en;
00841                   HBtMinus+=ti*en;
00842                   hbmocc++;
00843                 }
00844             } // if (HB  en>thresh, ET>thresh)
00845         } // if (id.subdet()==HcalBarrel)
00846 
00847       else if (subdet==HcalEndcap)
00848         {
00849           if (en>HEenergyThreshold_)
00850             h_HETimeVsEnergy->Fill(en,ti);
00851           //Looping over HE searching for flags --- cris
00852           for (int f=0;f<32;f++)
00853             {
00854               if (HBHEiter->flagField(f))
00855                 ++HEflagcounter_[f];
00856             }
00857 
00858           ++occupancy_[calcEta][iphi-1][depth-1];
00859           energy_[calcEta][iphi-1][depth-1]+=en;
00860           energy2_[calcEta][iphi-1][depth-1]+=pow(en,2);
00861           time_[calcEta][iphi-1][depth-1]+=ti;
00862 
00863           ++heocc;
00864           if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
00865             h_HETime->Fill(ti);
00866           else
00867             ++HEtime_[int(ti-RECHITMON_TIME_MIN)];
00868 
00869           // Threshold plots require e>E_thresh, ET>ET_thresh
00870           if (en>=HEenergyThreshold_
00871               && en/cosh(fEta)>=HEETThreshold_
00872               )
00873             {
00874               // occupancy plots also require passedMinBiasHLT
00875               if (passedMinBiasHLT==true)
00876                 {
00877                   ++occupancy_thresh_[calcEta][iphi-1][depth-1];
00878                   energy_thresh_[calcEta][iphi-1][depth-1]+=en;
00879                   energy2_thresh_[calcEta][iphi-1][depth-1]+=pow(en,2);
00880                   time_thresh_[calcEta][iphi-1][depth-1]+=ti;
00881                   ++heoccthresh;
00882                   if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
00883                       h_HEThreshTime->Fill(ti);
00884                   else
00885                     ++HEtime_thresh_[int(ti-RECHITMON_TIME_MIN)];
00886                 }
00887               // ePlus, tPlus calculated regardless of trigger
00888               if (ieta>0)
00889                 {
00890                   HEePlus+=en;
00891                   HEtPlus+=ti*en;
00892                   hepocc++;
00893                 }
00894               else
00895                 {
00896                   HEeMinus+=en;
00897                   HEtMinus+=ti*en;
00898                   hemocc++;
00899                 }
00900             } // if (en>=HEenergyThreshold_ && ET>threshold)
00901 
00902         } // else if (id.subdet()==HcalEndcap)
00903      
00904     } //for (HBHERecHitCollection::const_iterator HBHEiter=...)
00905   
00906   // Calculate normalized time
00907   HEePlus>0  ?  HEtPlus/=HEePlus   :  HEtPlus=10000;
00908   HEeMinus>0 ?  HEtMinus/=HEeMinus :  HEtMinus=-10000;
00909   HBePlus>0  ?  HBtPlus/=HBePlus   :  HBtPlus=10000;
00910   HBeMinus>0 ?  HBtMinus/=HBeMinus :  HBtMinus=-10000;
00911   
00912   ++HB_occupancy_[hbocc/10];
00913   ++HE_occupancy_[heocc/10];
00914   ++HB_occupancy_thresh_[hboccthresh/10];
00915   ++HE_occupancy_thresh_[heoccthresh/10];
00916   h_HBsizeVsLS->Fill(currentLS,hbocc);
00917   h_HEsizeVsLS->Fill(currentLS,heocc);
00918 
00919   // loop over HO
00920 
00921   h_HOsizeVsLS->Fill(currentLS,hoHits.size());
00922   int hoocc=0;
00923   int hooccthresh=0;
00924   for (HORecHitCollection::const_iterator HOiter=hoHits.begin(); HOiter!=hoHits.end(); ++HOiter) 
00925     { // loop over all hits
00926       float en = HOiter->energy();
00927       float ti = HOiter->time();
00928       if (en>HOenergyThreshold_)
00929         h_HOTimeVsEnergy->Fill(en,ti);
00930 
00931       HcalDetId id(HOiter->detid().rawId());
00932       int ieta = id.ieta();
00933       int iphi = id.iphi();
00934       int depth = id.depth();
00935 
00936       if (en>0.5)
00937         {
00938           h_rechitieta_05->Fill(ieta);
00939           h_rechitiphi_05->Fill(iphi);
00940           if (en>1.)
00941             {
00942               h_rechitieta_10->Fill(ieta);
00943               h_rechitiphi_10->Fill(iphi);
00944               if (en>2.5)
00945                 {
00946                   h_rechitieta_25->Fill(ieta);
00947                   h_rechitiphi_25->Fill(iphi);
00948                   if (en>10.)
00949                     {
00950                       h_rechitieta_100->Fill(ieta);
00951                       h_rechitiphi_100->Fill(iphi);
00952                     }
00953                 }
00954             }
00955         }
00956 
00957 
00958 
00959       int calcEta = CalcEtaBin(HcalOuter,ieta,depth);
00960       double fEta=fabs(0.5*(theHBHEEtaBounds[abs(ieta)-1]+theHBHEEtaBounds[abs(ieta)]));
00961       
00962       int rbxindex=logicalMap->getHcalFrontEndId(HOiter->detid()).rbxIndex();
00963       int rm= logicalMap->getHcalFrontEndId(HOiter->detid()).rm();
00964       
00965       if (HOiter->flagField(HcalCaloFlagLabels::TimingSubtractedBit))
00966         h_FlagMap_TIMESUBTRACT->Fill(rbxindex,rm);
00967       else if (HOiter->flagField(HcalCaloFlagLabels::TimingAddedBit))
00968         h_FlagMap_TIMEADD->Fill(rbxindex,rm);
00969       else if (HOiter->flagField(HcalCaloFlagLabels::TimingErrorBit))
00970         h_FlagMap_TIMEERROR->Fill(rbxindex,rm);
00971       
00972       
00973       //Looping over HO searching for flags --- cris
00974       for (int f=0;f<32;f++)
00975         {
00976           if (HOiter->flagField(f))
00977             HOflagcounter_[f]++;
00978         }
00979       
00980       ++occupancy_[calcEta][iphi-1][depth-1];
00981       energy_[calcEta][iphi-1][depth-1]+=en;
00982       energy2_[calcEta][iphi-1][depth-1]+=pow(en,2);
00983       time_[calcEta][iphi-1][depth-1]+=ti;
00984       ++hoocc;
00985       if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
00986         h_HOTime->Fill(ti);
00987       else
00988         ++HOtime_[int(ti-RECHITMON_TIME_MIN)];
00989 
00990       // We don't calculate HOplus/HOminus values (independent of trigger), so require min bias trigger 
00991       // along with E, ET thresholds directly in this HO loop:
00992 
00993       if (en>=HOenergyThreshold_  
00994           && en/cosh(fEta)>=HOETThreshold_
00995           && passedMinBiasHLT==true   
00996           )
00997         {
00998           ++occupancy_thresh_[calcEta][iphi-1][depth-1];
00999           energy_thresh_[calcEta][iphi-1][depth-1]+=en;
01000           energy2_thresh_[calcEta][iphi-1][depth-1]+=pow(en,2);
01001           time_thresh_[calcEta][iphi-1][depth-1]+=ti;
01002 
01003           ++hooccthresh;
01004           if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
01005             h_HOThreshTime->Fill(ti);
01006           else
01007             ++HOtime_thresh_[int(ti-RECHITMON_TIME_MIN)];
01008         } 
01009     } // loop over all HO hits
01010 
01011   ++HO_occupancy_[hoocc/10];
01012   ++HO_occupancy_thresh_[hooccthresh/10];
01013    
01014   // loop over HF
01015   h_HFsizeVsLS->Fill(currentLS,hfHits.size());
01016 
01017   HtPlus=0; HtMinus=0;
01018   
01019   int hfocc=0;
01020   int hfoccthresh=0;
01021   for (HFRecHitCollection::const_iterator HFiter=hfHits.begin(); HFiter!=hfHits.end(); ++HFiter) 
01022     { // loop over all hits
01023       float en = HFiter->energy();
01024       float ti = HFiter->time();
01025       if (en> HFenergyThreshold_)
01026         h_HFTimeVsEnergy->Fill(en,ti);
01027 
01028       HcalDetId id(HFiter->detid().rawId());
01029       int ieta = id.ieta();
01030       int iphi = id.iphi();
01031       int depth = id.depth();
01032 
01033       if (en>0.5)
01034         {
01035           h_rechitieta_05->Fill(ieta);
01036           h_rechitiphi_05->Fill(iphi);
01037           if (en>1.)
01038             {
01039               h_rechitieta_10->Fill(ieta);
01040               h_rechitiphi_10->Fill(iphi);
01041               if (en>2.5)
01042                 {
01043                   h_rechitieta_25->Fill(ieta);
01044                   h_rechitiphi_25->Fill(iphi);
01045                   if (en>10.)
01046                     {
01047                       h_rechitieta_100->Fill(ieta);
01048                       h_rechitiphi_100->Fill(iphi);
01049                     }
01050                 }
01051             }
01052         }
01053 
01054       double fEta=fabs(0.5*(theHFEtaBounds[abs(ieta)-29]+theHFEtaBounds[abs(ieta)-28]));
01055       int calcEta = CalcEtaBin(HcalForward,ieta,depth);
01056 
01057       int rbxindex=logicalMap->getHcalFrontEndId(HFiter->detid()).rbxIndex();
01058       int rm= logicalMap->getHcalFrontEndId(HFiter->detid()).rm(); 
01059          
01060       h_HF_FlagCorr->Fill(HFiter->flagField(HcalCaloFlagLabels::HFDigiTime),HFiter->flagField(HcalCaloFlagLabels::HFLongShort)); 
01061       if (HFiter->flagField(HcalCaloFlagLabels::TimingSubtractedBit))
01062         h_FlagMap_TIMESUBTRACT->Fill(rbxindex,rm);
01063       else if (HFiter->flagField(HcalCaloFlagLabels::TimingAddedBit))
01064         h_FlagMap_TIMEADD->Fill(rbxindex,rm);
01065       else if (HFiter->flagField(HcalCaloFlagLabels::TimingErrorBit))
01066         h_FlagMap_TIMEERROR->Fill(rbxindex,rm);
01067 
01068       if (HFiter->flagField(HcalCaloFlagLabels::HFDigiTime))
01069         {
01070           h_FlagMap_DIGITIME->Fill(rbxindex,rm);
01071           h_HFDigiTime_vs_LS->Fill(currentLS,1);
01072         }
01073       if (HFiter->flagField(HcalCaloFlagLabels::HFLongShort))
01074         {
01075           h_FlagMap_LONGSHORT->Fill(rbxindex,rm);
01076           h_HFLongShort_vs_LS->Fill(currentLS,1);
01077         }
01078       //Looping over HF searching for flags --- cris
01079       for (int f=0;f<32;f++)
01080         {
01081           if (HFiter->flagField(f))
01082             HFflagcounter_[f]++;
01083         }
01084 
01085       // Occupancy plots, without threshold
01086       ++occupancy_[calcEta][iphi-1][depth-1];
01087       energy_[calcEta][iphi-1][depth-1]+=en;
01088       energy2_[calcEta][iphi-1][depth-1]+=pow(en,2);
01089       time_[calcEta][iphi-1][depth-1]+=ti;
01090       ++hfocc;
01091       if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
01092         h_HFTime->Fill(ti);
01093       else
01094         ++HFtime_[int(ti-RECHITMON_TIME_MIN)];
01095 
01096       ieta>0 ?  HtPlus+=en/cosh(fEta)  : HtMinus+=en/cosh(fEta);  // add energy from all cells, or only those > threshold?
01097 
01098       if (en>=HFenergyThreshold_ && 
01099           en/cosh(fEta)>=HFETThreshold_ 
01100           )
01101         {
01102           // Occupancy plots require min bias trigger, along with thresholds exceeded
01103           if (passedMinBiasHLT)
01104             {
01105               ++occupancy_thresh_[calcEta][iphi-1][depth-1];
01106               energy_thresh_[calcEta][iphi-1][depth-1]+=en;
01107               energy2_thresh_[calcEta][iphi-1][depth-1]+=pow(en,2);
01108               time_thresh_[calcEta][iphi-1][depth-1]+=ti;
01109               
01110               ++hfoccthresh;
01111               if (ti<RECHITMON_TIME_MIN || ti>RECHITMON_TIME_MAX)
01112                 h_HFThreshTime->Fill(ti);
01113               else
01114                 ++HFtime_thresh_[int(ti-RECHITMON_TIME_MIN)];
01115             }
01116 
01117           if (ieta>0)
01118             {
01119               HFtPlus+=en*ti;
01120               HFePlus+=en;
01121               hfpocc++;
01122             }
01123           else if (ieta<0)
01124             {
01125               HFtMinus+=en*ti;
01126               HFeMinus+=en;
01127               hfmocc++;
01128             }
01129         } // if (en>thresh, ET>thresh)
01130     } // loop over all HF hits
01131      
01132   ++HF_occupancy_[hfocc/10];
01133   ++HF_occupancy_thresh_[hfoccthresh/10];
01134 
01135   
01136   // Form event-wide variables (time averages, etc.), and plot them
01137 
01138   // Calculate weighted times.  (Set tPlus, tMinus to overflow in case where total energy < 0)
01139   HFePlus>0  ? HFtPlus/=HFePlus    : HFtPlus  =  10000;
01140   HFeMinus>0 ? HFtMinus/=HFeMinus  : HFtMinus = -10000;
01141      
01142   double mintime=99;  // used to be min(tPlus,tMinus);
01143   double minHT=std::min(HtMinus,HtPlus);
01144   minHT==HtMinus ?  mintime=HFtMinus : mintime = HFtPlus;
01145   //mintime = min(HFtPlus,HFtMinus); // I think we might want to use this value for mintime?
01146 
01147 
01148   h_LumiPlot_MinTime_vs_MinHT->Fill(minHT, mintime);
01149   h_LumiPlot_timeHT_HFM->Fill(HtMinus,HFtMinus);
01150   h_LumiPlot_timeHT_HFP->Fill(HtPlus,HFtPlus);
01151 
01152   if (passedMinBiasHLT==true)
01153     {
01154       h_LumiPlot_SumHT_HFPlus_vs_HFMinus->Fill(HtMinus,HtPlus);
01155       // HtMinus, HtPlus require no energy cuts for their contributing cells
01156       // HFeMinus, HFePlus require that cells be > threshold cut
01157       
01158       if (HtMinus>1 && HtPlus > 1) // is this the condition we want, or do we want hfmocc>0 && hfpocc >0?
01159         {
01160           h_LumiPlot_SumEnergy_HFPlus_vs_HFMinus->Fill(HFeMinus,HFePlus);
01161           h_LumiPlot_timeHFPlus_vs_timeHFMinus->Fill(HFtMinus,HFtPlus);
01162 
01163           h_HFP_weightedTime->Fill(HFtPlus);
01164           h_HFM_weightedTime->Fill(HFtMinus);
01165           h_HBP_weightedTime->Fill(HBtPlus);
01166           h_HBM_weightedTime->Fill(HBtMinus);
01167           
01168           h_HEP_weightedTime->Fill(HEtPlus);
01169           h_HEM_weightedTime->Fill(HEtMinus);
01170 
01171           if (hepocc>0 && hemocc>0)
01172             {
01173               h_HEtimedifference->Fill(HEtPlus-HEtMinus);
01174               if (HEePlus-HEeMinus!=0) h_HEenergydifference->Fill((HEePlus-HEeMinus)/(HEePlus+HEeMinus));
01175             }
01176           if (hfpocc>0 && hfmocc>0)  // which condition do we want?
01177             {
01178               h_HFtimedifference->Fill((HFtPlus)-(HFtMinus));
01179               if (HFePlus+HFeMinus!=0) h_HFenergydifference->Fill((HFePlus-HFeMinus)/(HFePlus+HFeMinus));
01180             }
01181 
01182           h_LumiPlot_LS_MinBiasEvents_notimecut->Fill(currentLS);
01183           h_LumiPlot_BX_MinBiasEvents_notimecut->Fill(BCN);
01184           if (fabs(HFtPlus-HFtMinus)<timediffThresh_)
01185             {
01186               h_LumiPlot_LS_MinBiasEvents->Fill(currentLS);
01187               h_LumiPlot_BX_MinBiasEvents->Fill(BCN);
01188             }
01189           
01190           HFP_HFM_Energy->Fill(HFeMinus/1000., HFePlus/1000.);
01191         }
01192  
01193       if (debug_>1) std::cout <<"\t<HcalRecHitMonitor:: HF averages>  TPLUS = "<<HFtPlus<<"  EPLUS = "<<HFePlus<<"  TMINUS = "<<HFtMinus<<"  EMINUS = "<<HFeMinus<<"  Weighted Time Diff = "<<((HFtPlus)-(HFtMinus))<<std::endl;
01194       
01195 
01196     } // if (passedMinBiasHLT)
01197 
01198   if (passedHcalHLT && HtMinus>1 && HtPlus> 1 )
01199     {
01200       if (hfpocc>0 && hfmocc>0)
01201         {
01202           h_HF_HcalHLT_weightedtimedifference->Fill(HFtPlus-HFtMinus);
01203           if (HFePlus+HFeMinus!=0) h_HF_HcalHLT_energydifference->Fill((HFePlus-HFeMinus)/(HFePlus+HFeMinus));
01204         }
01205       if  (hepocc>0 && hemocc>0)
01206         {
01207           h_HE_HcalHLT_weightedtimedifference->Fill(HEtPlus-HEtMinus);
01208           if (HEePlus-HEeMinus!=0) h_HE_HcalHLT_energydifference->Fill((HEePlus-HEeMinus)/(HEePlus+HEeMinus));
01209         }
01210 
01211       h_LumiPlot_LS_HcalHLTEvents_notimecut->Fill(currentLS);
01212       h_LumiPlot_BX_HcalHLTEvents_notimecut->Fill(BCN);
01213       if (fabs(HFtPlus-HFtMinus)<timediffThresh_)
01214         {
01215           h_LumiPlot_LS_HcalHLTEvents->Fill(currentLS);
01216           h_LumiPlot_BX_HcalHLTEvents->Fill(BCN);
01217         }
01218      } // passsed Hcal HLT
01219    
01220  return;
01221 } // void HcalRecHitMonitor::processEvent_rechitenergy
01222 
01223 /* --------------------------------------- */
01224 
01225 
01226 void HcalRecHitMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
01227                                            const edm::EventSetup& c)
01228 
01229 {
01230   // don't fill lumi block information if it's already been filled
01231   if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
01232   fill_Nevents();
01233   return;
01234 } //endLuminosityBlock
01235 
01236 
01237 void HcalRecHitMonitor::fill_Nevents(void)
01238 {
01239   // looking at the contents of HbFlagcounters
01240   if (debug_>0)
01241     {
01242       for (int k = 0; k < 32; k++){
01243         std::cout << "<HcalRecHitMonitor::fill_Nevents>  HF Flag counter:  Bin #" << k+1 << " = "<< HFflagcounter_[k] << std::endl;
01244       }
01245     }
01246 
01247   for (int i=0;i<32;i++)
01248     {
01249       h_HBflagcounter->Fill(i,HBflagcounter_[i]);
01250       h_HEflagcounter->Fill(i,HEflagcounter_[i]);
01251       h_HOflagcounter->Fill(i,HOflagcounter_[i]);
01252       h_HFflagcounter->Fill(i,HFflagcounter_[i]);
01253       HBflagcounter_[i]=0;
01254       HEflagcounter_[i]=0;
01255       HOflagcounter_[i]=0;
01256       HFflagcounter_[i]=0;
01257     }
01258 
01259   // Fill Occupancy & Sum Energy, Time plots
01260   int myieta=-1;
01261   if (ievt_>0)
01262     {
01263       for (int mydepth=0;mydepth<4;++mydepth)
01264         {
01265           for (int eta=0;eta<OccupancyByDepth.depth[mydepth]->getNbinsX();++eta)
01266             {
01267               myieta=CalcIeta(eta,mydepth+1);
01268 
01269               for (int phi=0;phi<72;++phi)
01270                 {
01271                   if (occupancy_[eta][phi][mydepth]>0)
01272                     {
01273                       h_rechitieta->Fill(myieta,occupancy_[eta][phi][mydepth]);
01274                       h_rechitiphi->Fill(phi+1,occupancy_[eta][phi][mydepth]);
01275                     }
01276                   if (occupancy_thresh_[eta][phi][mydepth]>0)
01277                     {
01278                       h_rechitieta_thresh->Fill(myieta,occupancy_thresh_[eta][phi][mydepth]);
01279                       h_rechitiphi_thresh->Fill(phi+1,occupancy_thresh_[eta][phi][mydepth]);
01280                     }
01281                   OccupancyByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,occupancy_[eta][phi][mydepth]);
01282                   SumEnergyByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,energy_[eta][phi][mydepth]);
01283                   SqrtSumEnergy2ByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,sqrt(energy2_[eta][phi][mydepth]));
01284                   SumTimeByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,time_[eta][phi][mydepth]);
01285 
01286                   OccupancyThreshByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,occupancy_thresh_[eta][phi][mydepth]);
01287                   SumEnergyThreshByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,energy_thresh_[eta][phi][mydepth]);
01288                   SqrtSumEnergy2ThreshByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,sqrt(energy2_thresh_[eta][phi][mydepth]));
01289                   SumTimeThreshByDepth.depth[mydepth]->setBinContent(eta+1,phi+1,time_thresh_[eta][phi][mydepth]);
01290                 } // for (int phi=0;phi<72;++phi)
01291             } // for (int eta=0;eta<OccupancyByDepth...;++eta)
01292         } // for (int mydepth=0;...)
01293 
01294       FillUnphysicalHEHFBins(OccupancyByDepth);
01295       FillUnphysicalHEHFBins(OccupancyThreshByDepth);
01296       FillUnphysicalHEHFBins(SumEnergyByDepth);
01297       FillUnphysicalHEHFBins(SqrtSumEnergy2ByDepth);
01298       FillUnphysicalHEHFBins(SumEnergyThreshByDepth);
01299       FillUnphysicalHEHFBins(SqrtSumEnergy2ThreshByDepth);
01300       FillUnphysicalHEHFBins(SumTimeByDepth);
01301       FillUnphysicalHEHFBins(SumTimeThreshByDepth);
01302 
01303     } // if (ievt_>0)
01304 
01305   // Fill subdet plots
01306 
01307   for (int i=0;i<(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN);++i)
01308     {
01309       if (HBtime_[i]!=0)
01310         {
01311           h_HBTime->setBinContent(i+1,HBtime_[i]);
01312         }
01313       if (HBtime_thresh_[i]!=0)
01314         {
01315           h_HBThreshTime->setBinContent(i+1,HBtime_thresh_[i]);
01316         }
01317       if (HEtime_[i]!=0)
01318         {
01319 
01320           h_HETime->setBinContent(i+1,HEtime_[i]);
01321         }
01322       if (HEtime_thresh_[i]!=0)
01323         {
01324           h_HEThreshTime->setBinContent(i+1,HEtime_thresh_[i]);
01325         }
01326       if (HOtime_[i]!=0)
01327         {
01328           h_HOTime->setBinContent(i+1,HOtime_[i]);
01329         }
01330       if (HOtime_thresh_[i]!=0)
01331         {
01332           h_HOThreshTime->setBinContent(i+1,HOtime_thresh_[i]);
01333         }
01334       if (HFtime_[i]!=0)
01335         {
01336           h_HFTime->setBinContent(i+1,HFtime_[i]);
01337         }
01338       if (HFtime_thresh_[i]!=0)
01339         {
01340           h_HFThreshTime->setBinContent(i+1,HFtime_thresh_[i]);
01341         }
01342     } // for (int  i=0;i<(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN);++i)
01343 
01344   for (int i=0;i<260;++i)
01345     {
01346       if (HB_occupancy_[i]>0)
01347         {
01348           h_HBOccupancy->setBinContent(i+1,HB_occupancy_[i]);
01349         }
01350       if (HB_occupancy_thresh_[i]>0)
01351         {
01352           h_HBThreshOccupancy->setBinContent(i+1,HB_occupancy_thresh_[i]);
01353         }
01354       if (HE_occupancy_[i]>0)
01355         {
01356           h_HEOccupancy->setBinContent(i+1,HE_occupancy_[i]);
01357         }
01358       if (HE_occupancy_thresh_[i]>0)
01359         {
01360           h_HEThreshOccupancy->setBinContent(i+1,HE_occupancy_thresh_[i]);
01361         }
01362     }//for (int i=0;i<260;++i)
01363 
01364   for (int i=0;i<217;++i)
01365     {
01366       if (HO_occupancy_[i]>0)
01367         {
01368           h_HOOccupancy->setBinContent(i+1,HO_occupancy_[i]);
01369         }
01370       if (HO_occupancy_thresh_[i]>0)
01371         {
01372           h_HOThreshOccupancy->setBinContent(i+1,HO_occupancy_thresh_[i]);
01373         }
01374     }//  for (int i=0;i<217;++i)
01375 
01376   for (int i=0;i<173;++i)
01377     {
01378       if (HF_occupancy_[i]>0)
01379         {
01380           h_HFOccupancy->setBinContent(i+1,HF_occupancy_[i]);
01381         }
01382       if (HF_occupancy_thresh_[i]>0)
01383         {
01384           h_HFThreshOccupancy->setBinContent(i+1,HF_occupancy_thresh_[i]);
01385         }
01386     }//  for (int i=0;i<173;++i)
01387 
01388   //zeroCounters();
01389 
01390   if (debug_>0)
01391     std::cout <<"<HcalRecHitMonitor::fill_Nevents> FILLED REC HIT CELL PLOTS"<<std::endl;
01392 
01393 } // void HcalRecHitMonitor::fill_Nevents(void)
01394 
01395 
01396 void HcalRecHitMonitor::zeroCounters(void)
01397 {
01398   // Set all histogram counters back to zero
01399 
01400   for (int i=0;i<32;++i)
01401     {
01402       HBflagcounter_[i]=0;
01403       HEflagcounter_[i]=0;
01404       HOflagcounter_[i]=0;
01405       HFflagcounter_[i]=0;
01406 
01407     }
01408   // TH2F counters
01409   for (int i=0;i<85;++i)
01410     {
01411       for (int j=0;j<72;++j)
01412         {
01413           for (int k=0;k<4;++k)
01414             {
01415               occupancy_[i][j][k]=0;
01416               occupancy_thresh_[i][j][k]=0;
01417               energy_[i][j][k]=0;
01418               energy2_[i][j][k]=0;
01419               energy_thresh_[i][j][k]=0;
01420               energy2_thresh_[i][j][k]=0;
01421               time_[i][j][k]=0;
01422               time_thresh_[i][j][k]=0;
01423             }
01424         } // for (int j=0;j<PHIBINS;++j)
01425     } // for (int i=0;i<87;++i)
01426 
01427   // TH1F counters
01428   
01429   for (int i=0;i<200;++i)
01430     {
01431       HFenergyLong_[i]=0;
01432       HFenergyLong_thresh_[i]=0;
01433       HFenergyShort_[i]=0;
01434       HFenergyShort_thresh_[i]=0;
01435     }
01436 
01437   // time
01438   for (int i=0;i<(RECHITMON_TIME_MAX-RECHITMON_TIME_MIN);++i)
01439     {
01440       HBtime_[i]=0;
01441       HBtime_thresh_[i]=0;
01442       HEtime_[i]=0;
01443       HEtime_thresh_[i]=0;
01444       HOtime_[i]=0;
01445       HOtime_thresh_[i]=0;
01446       HFtime_[i]=0;
01447       HFtime_thresh_[i]=0;
01448       HFtimeLong_[i]=0;
01449       HFtimeLong_thresh_[i]=0;
01450       HFtimeShort_[i]=0;
01451       HFtimeShort_thresh_[i]=0;
01452     }
01453 
01454   // occupancy
01455   for (int i=0;i<865;++i)
01456     {
01457       if (i<260)
01458         {
01459           HB_occupancy_[i]=0;
01460           HE_occupancy_[i]=0;
01461           HB_occupancy_thresh_[i]=0;
01462           HE_occupancy_thresh_[i]=0;
01463         }
01464       if (i<218)
01465         {
01466           HO_occupancy_[i]=0;
01467           HO_occupancy_thresh_[i]=0;
01468         }
01469       if (i<174)
01470         {
01471           HF_occupancy_[i]=0;
01472           HF_occupancy_thresh_[i]=0;
01473         }
01474 
01475       HFlong_occupancy_[i] =0;
01476       HFshort_occupancy_[i]=0;
01477       HFlong_occupancy_thresh_[i] =0;
01478       HFshort_occupancy_thresh_[i]=0;
01479     } // for (int i=0;i<865;++i)
01480 
01481   return;
01482 } //void HcalRecHitMonitor::zeroCounters(void)
01483 
01484 DEFINE_FWK_MODULE(HcalRecHitMonitor);