CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Validation/HcalRecHits/interface/HcalRecHitsValidation.h

Go to the documentation of this file.
00001 #ifndef HcalRecHitsValidation_H
00002 #define HcalRecHitsValidation_H
00003 
00004 #include "FWCore/Framework/interface/Frameworkfwd.h"
00005 #include "FWCore/Framework/interface/EDAnalyzer.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/Framework/interface/MakerMacros.h"
00012 #include "FWCore/PluginManager/interface/ModuleDef.h"
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 
00015 #include "DQMServices/Core/interface/DQMStore.h"
00016 
00017 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00018 #include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
00019 
00020 #include <DataFormats/EcalDetId/interface/EBDetId.h>
00021 #include <DataFormats/EcalDetId/interface/EEDetId.h>
00022 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00023 
00024 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
00025 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00026 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00027 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00028 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00029 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00030 
00031 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00032 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00033 
00034 #include <vector>
00035 #include <utility>
00036 #include <ostream>
00037 #include <string>
00038 #include <algorithm>
00039 #include <cmath>
00040 #include "DQMServices/Core/interface/MonitorElement.h"
00041 
00042 #include "DataFormats/DetId/interface/DetId.h"
00043 // channel status
00044 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00045 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00046 
00047 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00048 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
00049 
00050 // severity level assignment for HCAL
00051 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00052 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00053 
00054 // severity level assignment for ECAL
00055 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00056 
00057 
00058 class HcalRecHitsValidation : public edm::EDAnalyzer {
00059  public:
00060   HcalRecHitsValidation(edm::ParameterSet const& conf);
00061   ~HcalRecHitsValidation();
00062   virtual void analyze(edm::Event const& ev, edm::EventSetup const& c);
00063   virtual void beginJob() ;
00064   virtual void endJob() ;
00065  private:
00066   
00067   virtual void fillRecHitsTmp(int subdet_, edm::Event const& ev);
00068   double dR(double eta1, double phi1, double eta2, double phi2);
00069   double phi12(double phi1, double en1, double phi2, double en2);
00070   double dPhiWsign(double phi1,double phi2);  
00071 
00072   DQMStore* dbe_;
00073   
00074   std::string outputFile_;
00075   std::string hcalselector_;
00076   std::string ecalselector_;
00077   std::string eventype_;
00078   std::string sign_;
00079   std::string mc_;
00080   bool        famos_;
00081   bool        useAllHistos_;
00082 
00083   //RecHit Collection input tags
00084   edm::InputTag theHBHERecHitCollectionLabel;
00085   edm::InputTag theHFRecHitCollectionLabel;
00086   edm::InputTag theHORecHitCollectionLabel;
00087 
00088   // choice of subdetector in config : noise/HB/HE/HO/HF/ALL (0/1/2/3/4/5)
00089   int subdet_;
00090 
00091   // single/multi-particle sample (1/2)
00092   int etype_;
00093   int iz;
00094   int imc;
00095 
00096   // for checking the status of ECAL and HCAL channels stored in the DB 
00097   const HcalChannelQuality* theHcalChStatus;
00098   // calculator of severety level for HCAL
00099   const HcalSeverityLevelComputer* theHcalSevLvlComputer;
00100   int hcalSevLvl(const CaloRecHit* hit);
00101 
00102   std::vector<int> hcalHBSevLvlVec, hcalHESevLvlVec, hcalHFSevLvlVec, hcalHOSevLvlVec;
00103 
00104   MonitorElement* sevLvl_HB;
00105   MonitorElement* sevLvl_HE;
00106   MonitorElement* sevLvl_HF;
00107   MonitorElement* sevLvl_HO; 
00108 
00109   // RecHits counters
00110   MonitorElement* Nhb;
00111   MonitorElement* Nhe;
00112   MonitorElement* Nho;
00113   MonitorElement* Nhf;
00114 
00115   // ZS-specific
00116 
00117   MonitorElement* map_depth1;
00118   MonitorElement* map_depth2;
00119   MonitorElement* map_depth3;
00120   MonitorElement* map_depth4;
00121 
00122   MonitorElement* ZS_HB1;
00123   MonitorElement* ZS_HB2;
00124   MonitorElement* ZS_HE1;
00125   MonitorElement* ZS_HE2;
00126   MonitorElement* ZS_HE3;
00127   MonitorElement* ZS_HO;
00128   MonitorElement* ZS_HF1;
00129   MonitorElement* ZS_HF2;
00130 
00131   MonitorElement* ZS_nHB1;
00132   MonitorElement* ZS_nHB2;
00133   MonitorElement* ZS_nHE1;
00134   MonitorElement* ZS_nHE2;
00135   MonitorElement* ZS_nHE3;
00136   MonitorElement* ZS_nHO;
00137   MonitorElement* ZS_nHF1;
00138   MonitorElement* ZS_nHF2;
00139 
00140   MonitorElement* ZS_seqHB1;
00141   MonitorElement* ZS_seqHB2;
00142   MonitorElement* ZS_seqHE1;
00143   MonitorElement* ZS_seqHE2;
00144   MonitorElement* ZS_seqHE3;
00145   MonitorElement* ZS_seqHO;
00146   MonitorElement* ZS_seqHF1;
00147   MonitorElement* ZS_seqHF2;
00148 
00149   // In ALL other cases : 2D ieta-iphi maps 
00150   // without and with cuts (a la "Scheme B") on energy
00151   // - only in the cone around particle for single-part samples (mc = "yes")
00152   // - for all calls in milti-particle samples (mc = "no")
00153 
00154   MonitorElement* map_ecal;
00155 
00156   MonitorElement* emap_depth1;
00157   MonitorElement* emap_depth2;
00158   MonitorElement* emap_depth3;
00159   MonitorElement* emap_depth4;
00160 
00161   MonitorElement* emean_vs_ieta_HB1;
00162   MonitorElement* emean_vs_ieta_HB2;
00163   MonitorElement* emean_vs_ieta_HE1;
00164   MonitorElement* emean_vs_ieta_HE2;
00165   MonitorElement* emean_vs_ieta_HE3;
00166   MonitorElement* emean_vs_ieta_HO;
00167   MonitorElement* emean_vs_ieta_HF1;
00168   MonitorElement* emean_vs_ieta_HF2;
00169 
00170   MonitorElement* RMS_vs_ieta_HB1;
00171   MonitorElement* RMS_vs_ieta_HB2;
00172   MonitorElement* RMS_vs_ieta_HE1;
00173   MonitorElement* RMS_vs_ieta_HE2;
00174   MonitorElement* RMS_vs_ieta_HE3;
00175   MonitorElement* RMS_vs_ieta_HO;
00176   MonitorElement* RMS_vs_ieta_HF1;
00177   MonitorElement* RMS_vs_ieta_HF2;
00178 
00179   MonitorElement* emean_seqHB1;
00180   MonitorElement* emean_seqHB2;
00181   MonitorElement* emean_seqHE1;
00182   MonitorElement* emean_seqHE2;
00183   MonitorElement* emean_seqHE3;
00184   MonitorElement* emean_seqHO;
00185   MonitorElement* emean_seqHF1;
00186   MonitorElement* emean_seqHF2;
00187 
00188   MonitorElement* RMS_seq_HB1;
00189   MonitorElement* RMS_seq_HB2;
00190   MonitorElement* RMS_seq_HE1;
00191   MonitorElement* RMS_seq_HE2;
00192   MonitorElement* RMS_seq_HE3;
00193   MonitorElement* RMS_seq_HO;
00194   MonitorElement* RMS_seq_HF1;
00195   MonitorElement* RMS_seq_HF2;
00196 
00197   MonitorElement* occupancy_map_HB1;
00198   MonitorElement* occupancy_map_HB2;
00199   MonitorElement* occupancy_map_HE1;
00200   MonitorElement* occupancy_map_HE2;
00201   MonitorElement* occupancy_map_HE3;
00202   MonitorElement* occupancy_map_HO;
00203   MonitorElement* occupancy_map_HF1;
00204   MonitorElement* occupancy_map_HF2;
00205 
00206   MonitorElement* occupancy_vs_ieta_HB1;
00207   MonitorElement* occupancy_vs_ieta_HB2;
00208   MonitorElement* occupancy_vs_ieta_HE1;
00209   MonitorElement* occupancy_vs_ieta_HE2;
00210   MonitorElement* occupancy_vs_ieta_HE3;
00211   MonitorElement* occupancy_vs_ieta_HO;
00212   MonitorElement* occupancy_vs_ieta_HF1;
00213   MonitorElement* occupancy_vs_ieta_HF2;
00214 
00215   MonitorElement* occupancy_seqHB1;
00216   MonitorElement* occupancy_seqHB2;
00217   MonitorElement* occupancy_seqHE1;
00218   MonitorElement* occupancy_seqHE2;
00219   MonitorElement* occupancy_seqHE3;
00220   MonitorElement* occupancy_seqHO;
00221   MonitorElement* occupancy_seqHF1;
00222   MonitorElement* occupancy_seqHF2;
00223 
00224 
00225   // also - energy in the cone around MC particle
00226   MonitorElement* map_econe_depth1;
00227   MonitorElement* map_econe_depth2;
00228   MonitorElement* map_econe_depth3;
00229   MonitorElement* map_econe_depth4;
00230  
00231   // for single monoenergetic particles - cone collection profile vs ieta.
00232   MonitorElement* meEnConeEtaProfile_depth1;
00233   MonitorElement* meEnConeEtaProfile_depth2;
00234   MonitorElement* meEnConeEtaProfile_depth3;
00235   MonitorElement* meEnConeEtaProfile_depth4;
00236   MonitorElement* meEnConeEtaProfile;
00237   MonitorElement* meEnConeEtaProfile_E;
00238   MonitorElement* meEnConeEtaProfile_EH;
00239   // Single particles - deviation of cluster from MC truth
00240   MonitorElement* meDeltaPhi;
00241   MonitorElement* meDeltaEta;
00242   MonitorElement* meDeltaPhiS;  // simcluster
00243   MonitorElement* meDeltaEtaS;  // simculster
00244 
00245   //----------- NOISE case
00246   MonitorElement* e_hb;
00247   MonitorElement* e_he;
00248   MonitorElement* e_ho;
00249   MonitorElement* e_hfl;
00250   MonitorElement* e_hfs;
00251 
00252   // number of rechits above threshold 1GEV
00253   MonitorElement* meNumRecHitsThreshHB;
00254   MonitorElement* meNumRecHitsThreshHE;
00255   MonitorElement* meNumRecHitsThreshHO;
00256 
00257   // number of rechits in the cone
00258   MonitorElement* meNumRecHitsConeHB;
00259   MonitorElement* meNumRecHitsConeHE;
00260   MonitorElement* meNumRecHitsConeHO;
00261   MonitorElement* meNumRecHitsConeHF;
00262 
00263   // time?
00264   MonitorElement* meTimeHB;
00265   MonitorElement* meTimeHE;
00266   MonitorElement* meTimeHO;
00267   MonitorElement* meTimeHF;
00268 
00269   // energy of rechits
00270   MonitorElement* meRecHitsEnergyHB;
00271   MonitorElement* meRecHitsEnergyHE;
00272   MonitorElement* meRecHitsEnergyHO;
00273   MonitorElement* meRecHitsEnergyHF;
00274 
00275   MonitorElement* meTE_Low_HB;
00276   MonitorElement* meTE_HB;
00277   MonitorElement* meTE_High_HB;
00278   MonitorElement* meTE_HB1;
00279   MonitorElement* meTE_HB2;
00280   MonitorElement* meTEprofileHB_Low;
00281   MonitorElement* meTEprofileHB;
00282   MonitorElement* meTEprofileHB_High;
00283 
00284   MonitorElement* meTE_Low_HE;
00285   MonitorElement* meTE_HE;
00286   MonitorElement* meTE_HE1;
00287   MonitorElement* meTE_HE2;
00288   MonitorElement* meTEprofileHE_Low;
00289   MonitorElement* meTEprofileHE;
00290 
00291   MonitorElement* meTE_HO;
00292   MonitorElement* meTE_High_HO;
00293   MonitorElement* meTEprofileHO;
00294   MonitorElement* meTEprofileHO_High;
00295 
00296   MonitorElement* meTE_Low_HF;
00297   MonitorElement* meTE_HF;
00298   MonitorElement* meTE_HFL;
00299   MonitorElement* meTE_HFS;
00300   MonitorElement* meTEprofileHF_Low;
00301   MonitorElement* meTEprofileHF;
00302 
00303 
00304   MonitorElement* meSumRecHitsEnergyHB;
00305   MonitorElement* meSumRecHitsEnergyHE;
00306   MonitorElement* meSumRecHitsEnergyHO;
00307   MonitorElement* meSumRecHitsEnergyHF;
00308 
00309 
00310   MonitorElement* meSumRecHitsEnergyConeHB;
00311   MonitorElement* meSumRecHitsEnergyConeHE;
00312   MonitorElement* meSumRecHitsEnergyConeHO;
00313   MonitorElement* meSumRecHitsEnergyConeHF;
00314   MonitorElement* meSumRecHitsEnergyConeHFL;
00315   MonitorElement* meSumRecHitsEnergyConeHFS;
00316 
00317 
00318   MonitorElement* meEcalHcalEnergyHB;
00319   MonitorElement* meEcalHcalEnergyHE;
00320    
00321   MonitorElement* meEcalHcalEnergyConeHB; 
00322   MonitorElement* meEcalHcalEnergyConeHE; 
00323   MonitorElement* meEcalHcalEnergyConeHO; 
00324   MonitorElement* meEcalHcalEnergyConeHF; 
00325  
00326   // Histo (2D plot) for sum of RecHits vs SimHits (hcal only)
00327   MonitorElement* meRecHitSimHitHB;
00328   MonitorElement* meRecHitSimHitHE;
00329   MonitorElement* meRecHitSimHitHO;
00330   MonitorElement* meRecHitSimHitHF;
00331   MonitorElement* meRecHitSimHitHFL;
00332   MonitorElement* meRecHitSimHitHFS;
00333   // profile histo (2D plot) for sum of RecHits vs SimHits (hcal only)
00334   MonitorElement* meRecHitSimHitProfileHB;
00335   MonitorElement* meRecHitSimHitProfileHE;
00336   MonitorElement* meRecHitSimHitProfileHO;
00337   MonitorElement* meRecHitSimHitProfileHF;
00338   MonitorElement* meRecHitSimHitProfileHFL;
00339   MonitorElement* meRecHitSimHitProfileHFS;
00340 
00341   // 2D plot of sum of RecHits in HCAL as function of ECAL's one
00342   MonitorElement* meEnergyHcalVsEcalHB;
00343   MonitorElement* meEnergyHcalVsEcalHE;
00344   
00345   // number of ECAL's rechits in cone 0.3 
00346   MonitorElement* meNumEcalRecHitsConeHB;
00347   MonitorElement* meNumEcalRecHitsConeHE;
00348 
00349   edm::ESHandle<CaloGeometry> geometry ;
00350 
00351   //Status word histos
00352   MonitorElement* RecHit_StatusWord_HB;
00353   MonitorElement* RecHit_StatusWord_HE;
00354   MonitorElement* RecHit_StatusWord_HF;
00355   MonitorElement* RecHit_StatusWord_HF67;
00356   MonitorElement* RecHit_StatusWord_HO;
00357 
00358   //Aux Status word histos
00359   MonitorElement* RecHit_Aux_StatusWord_HB;
00360   MonitorElement* RecHit_Aux_StatusWord_HE;
00361   MonitorElement* RecHit_Aux_StatusWord_HF;
00362   MonitorElement* RecHit_Aux_StatusWord_HO;
00363 
00364  // Filling vectors with essential RecHits data
00365   std::vector<int>      csub;
00366   std::vector<int>      cieta;
00367   std::vector<int>      ciphi;
00368   std::vector<int>      cdepth;
00369   std::vector<double>   cen;
00370   std::vector<double>   ceta;
00371   std::vector<double>   cphi;
00372   std::vector<double>   ctime;
00373   std::vector<double>   cz;
00374   std::vector<uint32_t> cstwd;
00375   std::vector<uint32_t> cauxstwd;
00376 
00377   // array or min. e-values  ieta x iphi x depth x subdet
00378   double emap_min[82][72][4][4];
00379 
00380   // counter
00381   int nevtot;
00382 
00383 };
00384 
00385 #endif