CMS 3D CMS Logo

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