CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DQMOffline/Hcal/src/HcalRecHitsAnalyzer.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Hcal/interface/HcalRecHitsAnalyzer.h"
00002 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00003 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00004 
00005 HcalRecHitsAnalyzer::HcalRecHitsAnalyzer(edm::ParameterSet const& conf) {
00006   // DQM ROOT output
00007   outputFile_ = conf.getUntrackedParameter<std::string>("outputFile", "myfile.root");
00008   
00009   if ( outputFile_.size() != 0 ) {
00010     edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will be saved to '" << outputFile_.c_str() << "'";
00011   } else {
00012     edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will NOT be saved";
00013   }
00014   
00015   nevtot = 0;
00016   
00017   dbe_ = 0;
00018   // get hold of back-end interface
00019   dbe_ = edm::Service<DQMStore>().operator->();
00020    
00021   Char_t histo[200];
00022 
00023   hcalselector_ = conf.getUntrackedParameter<std::string>("hcalselector", "all");
00024   ecalselector_ = conf.getUntrackedParameter<std::string>("ecalselector", "yes");
00025   eventype_     = conf.getUntrackedParameter<std::string>("eventype", "single");
00026   sign_         = conf.getUntrackedParameter<std::string>("sign", "*");
00027   useAllHistos_ = conf.getUntrackedParameter<bool>("useAllHistos", false);
00028 
00029   //Collections
00030   theHBHERecHitCollectionLabel = conf.getUntrackedParameter<edm::InputTag>("HBHERecHitCollectionLabel");
00031   theHFRecHitCollectionLabel   = conf.getUntrackedParameter<edm::InputTag>("HFRecHitCollectionLabel");
00032   theHORecHitCollectionLabel   = conf.getUntrackedParameter<edm::InputTag>("HORecHitCollectionLabel");
00033 
00034   subdet_ = 5;
00035   if (hcalselector_ == "noise") subdet_ = 0;
00036   if (hcalselector_ == "HB"   ) subdet_ = 1;
00037   if (hcalselector_ == "HE"   ) subdet_ = 2;
00038   if (hcalselector_ == "HO"   ) subdet_ = 3;
00039   if (hcalselector_ == "HF"   ) subdet_ = 4;
00040   if (hcalselector_ == "all"  ) subdet_ = 5;
00041   if (hcalselector_ == "ZS"   ) subdet_ = 6;
00042 
00043   etype_ = 1;
00044   if (eventype_ == "multi") etype_ = 2;
00045 
00046   iz = 1;
00047   if(sign_ == "-") iz = -1;
00048   if(sign_ == "*") iz = 0;
00049 
00050   imc = 0;
00051 
00052   if ( dbe_ ) {
00053     dbe_->setCurrentFolder("HcalRecHitsD/HcalRecHitTask");
00054 
00055     // General counters (drawn)
00056     sprintf  (histo, "N_HB" );
00057     Nhb = dbe_->book1D(histo, histo, 2600,0.,2600.);
00058     sprintf  (histo, "N_HE" );
00059     Nhe = dbe_->book1D(histo, histo, 2600,0.,2600.);
00060     sprintf  (histo, "N_HO" );
00061     Nho = dbe_->book1D(histo, histo, 2200,0.,2200.);
00062     sprintf  (histo, "N_HF" );
00063     Nhf = dbe_->book1D(histo, histo, 1800,0., 1800.);
00064 
00065     // ZS
00066     if(subdet_ == 6) {
00067 
00068       for (unsigned int i1 = 0;  i1 < 82; i1++) {
00069         for (unsigned int i2 = 0;  i2 < 72; i2++) {
00070           for (unsigned int i3 = 0;  i3 < 4;  i3++) {
00071             for (unsigned int i4 = 0;  i4 < 4;  i4++) {
00072               emap_min [i1][i2][i3][i4] = 99999.;     
00073             }
00074           }
00075         }
00076       }
00077 
00078       //None of the ZS histos are drawn
00079       if (useAllHistos_){
00080         sprintf  (histo, "ZSmin_map_depth1" );
00081         map_depth1 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00082         sprintf  (histo, "ZSmin_map_depth2" );
00083         map_depth2 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00084         sprintf  (histo, "ZSmin_map_depth3" );
00085         map_depth3 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00086         sprintf  (histo, "ZSmin_map_depth4" );
00087         map_depth4 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00088         
00089       
00090         sprintf  (histo, "ZS_Nreco_HB1" );
00091         ZS_nHB1 = dbe_->book1D(histo, histo, 2500, 0., 2500.);
00092         sprintf  (histo, "ZS_Nreco_HB2" );
00093         ZS_nHB2 = dbe_->book1D(histo, histo,  500, 0.,  500.);
00094         sprintf  (histo, "ZS_Nreco_HE1" );
00095         ZS_nHE1 = dbe_->book1D(histo, histo, 2000, 0., 2000.);
00096         sprintf  (histo, "ZS_Nreco_HE2" );
00097         ZS_nHE2 = dbe_->book1D(histo, histo, 2000, 0., 2000.);
00098         sprintf  (histo, "ZS_Nreco_HE3" );
00099         ZS_nHE3 = dbe_->book1D(histo, histo,  500, 0.,  500.);
00100         sprintf  (histo, "ZS_Nreco_HO" );
00101         ZS_nHO  = dbe_->book1D(histo, histo, 2500, 0., 2500.);
00102         sprintf  (histo, "ZS_Nreco_HF1" );
00103         ZS_nHF1 = dbe_->book1D(histo, histo, 1000, 0., 1000.);
00104         sprintf  (histo, "ZS_Nreco_HF2" );
00105         ZS_nHF2 = dbe_->book1D(histo, histo, 1000, 0., 1000.);
00106       
00107         sprintf  (histo, "ZSmin_simple1D_HB1" );
00108         ZS_HB1 = dbe_->book1D(histo, histo,120, -2., 10.);
00109         sprintf  (histo, "ZSmin_simple1D_HB2" );
00110         ZS_HB2 = dbe_->book1D(histo, histo,120, -2., 10.);
00111         sprintf  (histo, "ZSmin_simple1D_HE1" );
00112         ZS_HE1 = dbe_->book1D(histo, histo,120, -2., 10.);
00113         sprintf  (histo, "ZSmin_simple1D_HE2" );
00114         ZS_HE2 = dbe_->book1D(histo, histo,120, -2., 10.);
00115         sprintf  (histo, "ZSmin_simple1D_HE3" );
00116         ZS_HE3 = dbe_->book1D(histo, histo,120, -2., 10.);
00117         sprintf  (histo, "ZSmin_simple1D_HO" );
00118         ZS_HO = dbe_->book1D(histo, histo,120, -2., 10.);
00119         sprintf  (histo, "ZSmin_simple1D_HF1" );
00120         ZS_HF1 = dbe_->book1D(histo, histo,200, -10., 10.);
00121         sprintf  (histo, "ZSmin_simple1D_HF2" );
00122         ZS_HF2 = dbe_->book1D(histo, histo,200, -10., 10.);
00123         
00124         sprintf  (histo, "ZSmin_sequential1D_HB1" );
00125         ZS_seqHB1 = dbe_->book1D(histo, histo,2400, -1200., 1200.);
00126         sprintf  (histo, "ZSmin_sequential1D_HB2" );
00127         ZS_seqHB2 = dbe_->book1D(histo, histo,2400, -1200., 1200.);
00128         sprintf  (histo, "ZSmin_sequential1D_HE1" );
00129         ZS_seqHE1 = dbe_->book1D(histo, histo,4400, -2200., 2200.);
00130         sprintf  (histo, "ZSmin_sequential1D_HE2" );
00131         ZS_seqHE2 = dbe_->book1D(histo, histo,4400, -2200., 2200.);
00132         sprintf  (histo, "ZSmin_sequential1D_HE3" );
00133         ZS_seqHE3 = dbe_->book1D(histo, histo,4400, -2200., 2200.);
00134         sprintf  (histo, "ZSmin_sequential1D_HO" );
00135         ZS_seqHO  = dbe_->book1D(histo, histo,2400, -1200., 1200.);
00136         sprintf  (histo, "ZSmin_sequential1D_HF1" );
00137         ZS_seqHF1 = dbe_->book1D(histo, histo,6000, -3000., 3000.);
00138         sprintf  (histo, "ZSmin_sequential1D_HF2" );
00139         ZS_seqHF2 = dbe_->book1D(histo, histo,6000, -3000., 3000.);
00140       }
00141     }
00142 
00143     // ALL others, except ZS
00144     else {
00145   
00146       sprintf  (histo, "emap_depth1" );
00147       emap_depth1 = dbe_->book2D(histo, histo, 84, -42., 42., 72, 0., 72.);
00148       sprintf  (histo, "emap_depth2" );
00149       emap_depth2 = dbe_->book2D(histo, histo, 84, -42., 42., 72, 0., 72.);
00150       sprintf  (histo, "emap_depth3" );
00151       emap_depth3 = dbe_->book2D(histo, histo, 84, -42., 42., 72, 0., 72.);
00152       sprintf  (histo, "emap_depth4" );
00153       emap_depth4 = dbe_->book2D(histo, histo, 84, -42., 42., 72, 0., 72.);
00154       
00155       if (useAllHistos_){
00156         
00157         if (ecalselector_ == "yes") {
00158           sprintf  (histo, "map_ecal" );
00159           map_ecal = dbe_->book2D(histo, histo, 70, -3.045, 3.045, 72, -3.1415926536, 3.1415926536);
00160         }
00161       }
00162       
00163       //The mean energy histos are drawn, but not the RMS or emean seq
00164       sprintf  (histo, "emean_vs_ieta_HB1" );
00165       emean_vs_ieta_HB1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s");
00166       sprintf  (histo, "emean_vs_ieta_HB2" );
00167       emean_vs_ieta_HB2 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s");
00168       sprintf  (histo, "emean_vs_ieta_HE1" );
00169       emean_vs_ieta_HE1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10. ,2000., "s" );
00170       sprintf  (histo, "emean_vs_ieta_HE2" );
00171       emean_vs_ieta_HE2 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s");
00172       sprintf  (histo, "emean_vs_ieta_HE3" );
00173       emean_vs_ieta_HE3 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s" );
00174       sprintf  (histo, "emean_vs_ieta_HO" );
00175       emean_vs_ieta_HO = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s" );
00176       sprintf  (histo, "emean_vs_ieta_HF1" );
00177       emean_vs_ieta_HF1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s" );
00178       sprintf  (histo, "emean_vs_ieta_HF2" );
00179       emean_vs_ieta_HF2 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2010, -10., 2000., "s" );
00180 
00181       if (useAllHistos_){
00182         sprintf  (histo, "RMS_vs_ieta_HB1" );
00183         RMS_vs_ieta_HB1 = dbe_->book1D(histo, histo, 82, -41., 41.);
00184         sprintf  (histo, "RMS_vs_ieta_HB2" );
00185         RMS_vs_ieta_HB2 = dbe_->book1D(histo, histo, 82, -41., 41.);
00186         sprintf  (histo, "RMS_vs_ieta_HE1" );
00187         RMS_vs_ieta_HE1 = dbe_->book1D(histo, histo, 82, -41., 41.);
00188         sprintf  (histo, "RMS_vs_ieta_HE2" );
00189         RMS_vs_ieta_HE2 = dbe_->book1D(histo, histo, 82, -41., 41.);
00190         sprintf  (histo, "RMS_vs_ieta_HE3" );
00191         RMS_vs_ieta_HE3 = dbe_->book1D(histo, histo, 82, -41., 41.);
00192         sprintf  (histo, "RMS_vs_ieta_HO" );
00193         RMS_vs_ieta_HO = dbe_->book1D(histo, histo, 82, -41., 41.);
00194         sprintf  (histo, "RMS_vs_ieta_HF1" );
00195         RMS_vs_ieta_HF1 = dbe_->book1D(histo, histo, 82, -41., 41.);
00196         sprintf  (histo, "RMS_vs_ieta_HF2" );
00197         RMS_vs_ieta_HF2 = dbe_->book1D(histo, histo, 82, -41., 41.);
00198         
00199         // Sequential emean and RMS
00200         sprintf  (histo, "emean_seq_HB1" );
00201         emean_seqHB1 = dbe_->bookProfile(histo, histo, 2400, -1200., 1200.,  2010, -10., 2000., "s" );
00202         sprintf  (histo, "emean_seq_HB2" );
00203         emean_seqHB2 = dbe_->bookProfile(histo, histo, 2400, -1200., 1200.,  2010, -10., 2000., "s" );
00204         sprintf  (histo, "emean_seq_HE1" );
00205         emean_seqHE1 = dbe_->bookProfile(histo, histo, 4400, -2200., 2200.,  2010, -10., 2000., "s" );
00206         sprintf  (histo, "emean_seq_HE2" );
00207         emean_seqHE2 = dbe_->bookProfile(histo, histo, 4400, -2200., 2200.,  2010, -10., 2000., "s" );
00208         sprintf  (histo, "emean_seq_HE3" );
00209         emean_seqHE3 = dbe_->bookProfile(histo, histo, 4400, -2200., 2200.,  2010, -10., 2000., "s" );
00210         sprintf  (histo, "emean_seq_HO" );
00211         emean_seqHO = dbe_->bookProfile(histo, histo,  2400, -1200., 1200.,  2010, -10., 2000., "s" );
00212         sprintf  (histo, "emean_seq_HF1" );
00213         emean_seqHF1 = dbe_->bookProfile(histo, histo, 6000, -3000., 3000.,  2010, -10., 2000., "s" );
00214         sprintf  (histo, "emean_seq_HF2" );
00215         emean_seqHF2 = dbe_->bookProfile(histo, histo, 6000, -3000., 3000.,  2010, -10., 2000., "s" );
00216         
00217         sprintf  (histo, "RMS_seq_HB1" );
00218         RMS_seq_HB1 = dbe_->book1D(histo, histo, 2400, -1200., 1200.);
00219         sprintf  (histo, "RMS_seq_HB2" );
00220         RMS_seq_HB2 = dbe_->book1D(histo, histo, 2400, -1200., 1200.);
00221         sprintf  (histo, "RMS_seq_HE1" );
00222         RMS_seq_HE1 = dbe_->book1D(histo, histo, 4400, -2200., 2200.);
00223         sprintf  (histo, "RMS_seq_HE2" );
00224         RMS_seq_HE2 = dbe_->book1D(histo, histo, 4400, -2200., 2200.);
00225         sprintf  (histo, "RMS_seq_HE3" );
00226         RMS_seq_HE3 = dbe_->book1D(histo, histo, 4400, -2200., 2200.);
00227         sprintf  (histo, "RMS_seq_HO" );
00228         RMS_seq_HO = dbe_->book1D(histo, histo, 2400, -1200., 1200.);
00229         sprintf  (histo, "RMS_seq_HF1" );
00230         RMS_seq_HF1 = dbe_->book1D(histo, histo, 6000, -3000., 3000.);
00231         sprintf  (histo, "RMS_seq_HF2" );
00232         RMS_seq_HF2 = dbe_->book1D(histo, histo, 6000, -3000., 3000.);
00233       }
00234       // Occupancy
00235       //The only occupancy histos drawn are occupancy vs. ieta
00236       //but the maps are needed because this is where the latter are filled from
00237       sprintf  (histo, "occupancy_map_HB1" );
00238       occupancy_map_HB1 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00239       sprintf  (histo, "occupancy_map_HB2" );
00240       occupancy_map_HB2 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00241       sprintf  (histo, "occupancy_map_HE1" );
00242       occupancy_map_HE1 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00243       sprintf  (histo, "occupancy_map_HE2" );
00244       occupancy_map_HE2 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);      
00245       sprintf  (histo, "occupancy_map_HE3" );
00246       occupancy_map_HE3 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00247       sprintf  (histo, "occupancy_map_HO" );
00248       occupancy_map_HO = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);      
00249       sprintf  (histo, "occupancy_map_HF1" );
00250       occupancy_map_HF1 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00251       sprintf  (histo, "occupancy_map_HF2" );
00252       occupancy_map_HF2 = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00253       
00254       //These are drawn
00255       sprintf  (histo, "occupancy_vs_ieta_HB1" );
00256       occupancy_vs_ieta_HB1 = dbe_->book1D(histo, histo, 82, -41., 41.);
00257       sprintf  (histo, "occupancy_vs_ieta_HB2" );
00258       occupancy_vs_ieta_HB2 = dbe_->book1D(histo, histo, 82, -41., 41.);
00259       sprintf  (histo, "occupancy_vs_ieta_HE1" );
00260       occupancy_vs_ieta_HE1 = dbe_->book1D(histo, histo, 82, -41., 41.);
00261       sprintf  (histo, "occupancy_vs_ieta_HE2" );
00262       occupancy_vs_ieta_HE2 = dbe_->book1D(histo, histo, 82, -41., 41.);
00263       sprintf  (histo, "occupancy_vs_ieta_HE3" );
00264       occupancy_vs_ieta_HE3 = dbe_->book1D(histo, histo, 82, -41., 41.);
00265       sprintf  (histo, "occupancy_vs_ieta_HO" );
00266       occupancy_vs_ieta_HO = dbe_->book1D(histo, histo, 82, -41., 41.);
00267       sprintf  (histo, "occupancy_vs_ieta_HF1" );
00268       occupancy_vs_ieta_HF1 = dbe_->book1D(histo, histo, 82, -41., 41.);
00269       sprintf  (histo, "occupancy_vs_ieta_HF2" );
00270       occupancy_vs_ieta_HF2 = dbe_->book1D(histo, histo, 82, -41., 41.);
00271       
00272       //These are not
00273       if (useAllHistos_){
00274         sprintf  (histo, "occ_sequential1D_HB1" );
00275         occupancy_seqHB1 = dbe_->book1D(histo, histo,2400, -1200., 1200.);
00276         sprintf  (histo, "occ_sequential1D_HB2" );
00277         occupancy_seqHB2 = dbe_->book1D(histo, histo,2400, -1200., 1200.);
00278         sprintf  (histo, "occ_sequential1D_HE1" );
00279         occupancy_seqHE1 = dbe_->book1D(histo, histo,4400, -2200., 2200.);
00280         sprintf  (histo, "occ_sequential1D_HE2" );
00281         occupancy_seqHE2 = dbe_->book1D(histo, histo,4400, -2200., 2200.);
00282         sprintf  (histo, "occ_sequential1D_HE3" );
00283         occupancy_seqHE3 = dbe_->book1D(histo, histo,4400, -2200., 2200.);
00284         sprintf  (histo, "occ_sequential1D_HO" );
00285         occupancy_seqHO  = dbe_->book1D(histo, histo,2400, -1200., 1200.);
00286         sprintf  (histo, "occ_sequential1D_HF1" );
00287         occupancy_seqHF1 = dbe_->book1D(histo, histo,6000, -3000., 3000.);
00288         sprintf  (histo, "occ_sequential1D_HF2" );
00289         occupancy_seqHF2 = dbe_->book1D(histo, histo,6000, -3000., 3000.);
00290       }
00291 
00292       //All status word histos except HF67 are drawn
00293       sprintf (histo, "HcalRecHitTask_RecHit_StatusWord_HB" ) ;
00294       RecHit_StatusWord_HB = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00295       
00296       sprintf (histo, "HcalRecHitTask_RecHit_StatusWord_HE" ) ;
00297       RecHit_StatusWord_HE = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00298 
00299       sprintf (histo, "HcalRecHitTask_RecHit_StatusWord_HF" ) ;
00300       RecHit_StatusWord_HF = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00301 
00302       if (useAllHistos_){
00303         sprintf (histo, "HcalRecHitTask_RecHit_StatusWord_HF67" ) ;
00304         RecHit_StatusWord_HF67 = dbe_->book1D(histo, histo, 3 , 0.5, 3.5); 
00305       }
00306       sprintf (histo, "HcalRecHitTask_RecHit_StatusWord_HO" ) ;
00307       RecHit_StatusWord_HO = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00308 
00309       //Aux status word histos
00310       sprintf (histo, "HcalRecHitTask_RecHit_Aux_StatusWord_HB" ) ;
00311       RecHit_Aux_StatusWord_HB = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00312       
00313       sprintf (histo, "HcalRecHitTask_RecHit_Aux_StatusWord_HE" ) ;
00314       RecHit_Aux_StatusWord_HE = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00315 
00316       sprintf (histo, "HcalRecHitTask_RecHit_Aux_StatusWord_HF" ) ;
00317       RecHit_Aux_StatusWord_HF = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00318 
00319       sprintf (histo, "HcalRecHitTask_RecHit_Aux_StatusWord_HO" ) ;
00320       RecHit_Aux_StatusWord_HO = dbe_->book1D(histo, histo, 32 , -0.5, 31.5); 
00321 
00322     }  // end-of (subdet_ =! 6)
00323 
00324     //======================= Now various cases one by one ===================
00325 
00326     //Histograms drawn for single pion scan
00327     if(subdet_ != 0 && imc != 0) { // just not for noise  
00328       sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
00329       meEnConeEtaProfile = dbe_->bookProfile(histo, histo, 82, -41., 41.,        2100, -100., 2000.);  
00330       
00331       sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
00332       meEnConeEtaProfile_E = dbe_->bookProfile(histo, histo, 82, -41., 41.,      2100, -100., 2000.);  
00333       
00334       sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");
00335       meEnConeEtaProfile_EH = dbe_->bookProfile(histo, histo, 82, -41., 41.,     2100, -100., 2000.);  
00336     }
00337     //The other cone profile, delta ieta/phi and noise histos are not drawn
00338     if (useAllHistos_){
00339       if(subdet_ != 0 && imc != 0) { // just not for noise  
00340         
00341         //    meEnConeEtaProfiel_depth1->Fill(eta_RecHit, HcalCone_d1);
00342         
00343         sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_depth1");
00344         meEnConeEtaProfile_depth1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000.);   
00345         
00346         sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_depth2");
00347         meEnConeEtaProfile_depth2 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000.);  
00348         
00349         sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_depth3");
00350         meEnConeEtaProfile_depth3 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000.);  
00351         
00352         sprintf (histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_depth4");
00353         meEnConeEtaProfile_depth4 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000.);  
00354         
00355       }
00356       
00357       if(etype_ == 1 && subdet_ != 0) { // single part., not for noise
00358         
00359         sprintf  (histo, "Delta_phi_cluster-MC");
00360         meDeltaPhi =  dbe_->book2D(histo, histo, 520, -5.2, 5.2, 60, -0.6, 0.6);
00361         
00362         sprintf  (histo, "Delta_eta_cluster-MC");
00363         meDeltaEta =  dbe_->book2D(histo, histo, 520, -5.2, 5.2, 60, -0.6, 0.6);
00364       
00365       }
00366       // NOISE-specific
00367       
00368       if (hcalselector_ == "noise" ){
00369         
00370         sprintf  (histo, "e_hb" ) ;
00371         e_hb = dbe_->book1D(histo, histo,1000, -5., 5.);
00372         sprintf  (histo, "e_he" ) ;
00373         e_he = dbe_->book1D(histo, histo,1000, -5., 5.);
00374         sprintf  (histo, "e_ho" ) ;
00375         e_ho = dbe_->book1D(histo, histo,1000, -5., 5.);
00376         sprintf  (histo, "e_hfl" ) ;
00377         e_hfl = dbe_->book1D(histo, histo,2000, -10., 10.);
00378         sprintf  (histo, "e_hfs" ) ;
00379         e_hfs = dbe_->book1D(histo, histo,2000, -10., 10.);
00380       }
00381     }
00382     // ************** HB **********************************
00383     if (subdet_ == 1 || subdet_ == 5 ){
00384 
00385       //Only severity level, energy of rechits and overall HB timing histos are drawn  
00386       if (useAllHistos_){
00387         if(etype_ == 1 && subdet_ == 1 ) { 
00388           if(imc != 0) {
00389             sprintf (histo, "HcalRecHitTask_number_of_rechits_in_cone_HB" ) ;
00390             meNumRecHitsConeHB    = dbe_->book1D(histo, histo, 100, 0., 100.);
00391             
00392             sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_in_cone_HB" ) ;
00393             meSumRecHitsEnergyConeHB = dbe_->book1D(histo,histo, 60 ,-20., 280.);
00394           }
00395           
00396           sprintf (histo, "HcalRecHitTask_number_of_rechits_above_1GeV_HB");
00397           meNumRecHitsThreshHB = dbe_->book1D(histo, histo,  30, 0., 30.); 
00398           
00399           sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_HB" ) ;
00400           meSumRecHitsEnergyHB = dbe_->book1D(histo,histo, 60 , -20., 280.);
00401         
00402           if (ecalselector_ == "yes") {  
00403             if(imc != 0) {
00404               sprintf (histo, "HcalRecHitTask_number_of_ecalrechits_in_cone_HB");
00405               meNumEcalRecHitsConeHB = dbe_->book1D(histo, histo, 300, 0., 300.);           
00406               sprintf (histo, "HcalRecHitTask_energy_ecal_plus_hcal_in_cone_HB");
00407               meEcalHcalEnergyConeHB =  dbe_->book1D(histo,histo, 60 , -20., 280.);
00408             }
00409             
00410             sprintf (histo, "HcalRecHitTask_energy_hcal_vs_ecal_HB");
00411             meEnergyHcalVsEcalHB = dbe_->book2D(histo, histo, 300, 0., 150., 300, 0., 150.);    
00412             sprintf (histo, "HcalRecHitTask_energy_ecal_plus_hcal_HB" ) ;
00413             meEcalHcalEnergyHB = dbe_->book1D(histo,histo, 60 , -20., 280.);
00414           }
00415         }
00416       }
00417       
00418       sprintf(histo, "HcalRecHitTask_severityLevel_HB");
00419       sevLvl_HB = dbe_->book1D(histo, histo, 25, -0.5, 24.5); 
00420 
00421       sprintf (histo, "HcalRecHitTask_energy_of_rechits_HB" ) ;
00422       meRecHitsEnergyHB = dbe_->book1D(histo, histo, 2010 , -10. , 2000.); 
00423       
00424       sprintf (histo, "HcalRecHitTask_timing_HB" ) ;
00425       meTimeHB = dbe_->book1D(histo, histo, 70, -48., 92.); 
00426 
00427       //High, medium and low histograms to reduce RAM usage
00428       sprintf (histo, "HcalRecHitTask_timing_vs_energy_Low_HB" ) ;
00429       meTE_Low_HB = dbe_->book2D(histo, histo, 50, -5., 45.,  70, -48., 92.);
00430 
00431       sprintf (histo, "HcalRecHitTask_timing_vs_energy_HB" ) ;
00432       meTE_HB = dbe_->book2D(histo, histo, 150, -5., 295.,  70, -48., 92.);
00433 
00434       sprintf (histo, "HcalRecHitTask_timing_vs_energy_High_HB" ) ;
00435       meTE_High_HB = dbe_->book2D(histo, histo, 150, -5., 2995.,  70, -48., 92.);
00436       
00437       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HB" ) ;
00438       meTEprofileHB_Low = dbe_->bookProfile(histo, histo, 50, -5., 45., 70, -48., 92.); 
00439 
00440       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HB" ) ;
00441       meTEprofileHB = dbe_->bookProfile(histo, histo, 150, -5., 295., 70, -48., 92.); 
00442 
00443       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_High_HB" ) ;
00444       meTEprofileHB_High = dbe_->bookProfile(histo, histo, 150, -5., 2995., 70, -48., 92.); 
00445 
00446     }
00447     
00448     // ********************** HE ************************************
00449     if ( subdet_ == 2 || subdet_ == 5 ){
00450 
00451       //None of these are drawn
00452       if (useAllHistos_){
00453         if(etype_ == 1 && subdet_ == 2 ) { 
00454           
00455           if(imc != 0) {
00456             sprintf (histo, "HcalRecHitTask_number_of_rechits_in_cone_HE" ) ;
00457             meNumRecHitsConeHE    = dbe_->book1D(histo, histo, 100, 0., 100.);
00458             
00459             sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_in_cone_HE" ) ;
00460             meSumRecHitsEnergyConeHE = dbe_->book1D(histo,histo, 60 ,-20., 280.);
00461           }     
00462           
00463           sprintf (histo, "HcalRecHitTask_number_of_rechits_above_1GeV_HE");
00464           meNumRecHitsThreshHE = dbe_->book1D(histo, histo,  30, 0., 30.);  
00465           
00466           sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_HE" ) ;
00467           meSumRecHitsEnergyHE = dbe_->book1D(histo,histo, 60 , -20., 280.);
00468           
00469           if (ecalselector_ == "yes") {         
00470             sprintf (histo, "HcalRecHitTask_energy_ecal_plus_hcal_HE" ) ;
00471             meEcalHcalEnergyHE = dbe_->book1D(histo,histo, 80, -20., 380.);
00472             
00473             sprintf (histo, "HcalRecHitTask_energy_hcal_vs_ecal_HE");
00474             meEnergyHcalVsEcalHE = dbe_->book2D(histo, histo, 300, 0., 150., 300, 0., 150.);
00475             if(imc != 0) {
00476               sprintf (histo, "HcalRecHitTask_number_of_ecalrechits_in_cone_HE");
00477               meNumEcalRecHitsConeHE = dbe_->book1D(histo, histo, 300, 0., 300.);   
00478               sprintf (histo, "HcalRecHitTask_energy_ecal_plus_hcal_in_cone_HE");
00479               meEcalHcalEnergyConeHE =  dbe_->book1D(histo,histo, 60,-20., 280.);
00480             }
00481           }           
00482         }
00483       }
00484       
00485       //Only severity level, energy of rechits and overall HB timing histos are drawn  
00486       sprintf(histo, "HcalRecHitTask_severityLevel_HE");
00487       sevLvl_HE = dbe_->book1D(histo, histo, 25, -0.5, 24.5); 
00488       
00489       sprintf (histo, "HcalRecHitTask_energy_of_rechits_HE" ) ;
00490       meRecHitsEnergyHE = dbe_->book1D(histo, histo, 510, -10., 500.); 
00491       
00492       sprintf (histo, "HcalRecHitTask_timing_HE" ) ;
00493       meTimeHE = dbe_->book1D(histo, histo, 70, -48., 92.); 
00494       
00495       sprintf (histo, "HcalRecHitTask_timing_vs_energy_Low_HE" ) ;
00496       meTE_Low_HE = dbe_->book2D(histo, histo, 80, -5., 75.,  70, -48., 92.);
00497 
00498       sprintf (histo, "HcalRecHitTask_timing_vs_energy_HE" ) ;
00499       meTE_HE = dbe_->book2D(histo, histo, 200, -5., 395.,  70, -48., 92.);
00500       
00501       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HE" ) ;
00502       meTEprofileHE_Low = dbe_->bookProfile(histo, histo, 80, -5., 75., 70, -48., 92.); 
00503 
00504       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HE" ) ;
00505       meTEprofileHE = dbe_->bookProfile(histo, histo, 200, -5., 395., 70, -48., 92.); 
00506       
00507     }
00508 
00509     // ************** HO ****************************************
00510     if ( subdet_ == 3 || subdet_ == 5  ){
00511       
00512       //Only severity level, energy of rechits and overall HB timing histos are drawn  
00513       if (useAllHistos_){
00514         if(etype_ == 1 && subdet_ == 3) { 
00515           if (imc != 0) {
00516             sprintf (histo, "HcalRecHitTask_number_of_rechits_in_cone_HO" ) ;
00517             meNumRecHitsConeHO    = dbe_->book1D(histo, histo, 100, 0 , 100.);
00518             
00519             sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_in_cone_HO" ) ;
00520             meSumRecHitsEnergyConeHO = dbe_->book1D(histo,histo, 80 ,-20., 380.);
00521           }
00522           
00523           sprintf (histo, "HcalRecHitTask_number_of_rechits_above_1GeV_HO");
00524           meNumRecHitsThreshHO = dbe_->book1D(histo, histo,   100, 0., 100.);   
00525           
00526           sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_HO" ) ;
00527           meSumRecHitsEnergyHO = dbe_->book1D(histo,histo, 80 , -20., 380.);
00528         }
00529       }      
00530       
00531       sprintf(histo, "HcalRecHitTask_severityLevel_HO");
00532       sevLvl_HO = dbe_->book1D(histo, histo, 25, -0.5, 24.5); 
00533 
00534       sprintf (histo, "HcalRecHitTask_energy_of_rechits_HO" ) ;
00535       meRecHitsEnergyHO = dbe_->book1D(histo, histo, 510 , -10. , 500.); 
00536       
00537       sprintf (histo, "HcalRecHitTask_timing_HO" ) ;
00538       meTimeHO = dbe_->book1D(histo, histo, 70, -48., 92.); 
00539       
00540       sprintf (histo, "HcalRecHitTask_timing_vs_energy_HO" ) ;
00541       meTE_HO= dbe_->book2D(histo, histo, 60, -5., 55., 70, -48., 92.);
00542 
00543       sprintf (histo, "HcalRecHitTask_timing_vs_energy_High_HO" ) ;
00544       meTE_High_HO= dbe_->book2D(histo, histo, 100, -5., 995., 70, -48., 92.);
00545       
00546       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HO" ) ;
00547       meTEprofileHO = dbe_->bookProfile(histo, histo, 60, -5., 55.,  70, -48., 92.); 
00548 
00549       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_High_HO" ) ;
00550       meTEprofileHO_High = dbe_->bookProfile(histo, histo, 100, -5., 995.,  70, -48., 92.); 
00551       
00552     }   
00553   
00554     // ********************** HF ************************************
00555     if ( subdet_ == 4 || subdet_ == 5 ){
00556 
00557       //Only severity level, energy of rechits and overall HB timing histos are drawn  
00558       if (useAllHistos_){
00559         if(etype_ == 1 &&  subdet_ == 4) { 
00560           
00561           if(imc != 0) {
00562             sprintf (histo, "HcalRecHitTask_number_of_rechits_in_cone_HF" ) ;
00563             meNumRecHitsConeHF    = dbe_->book1D(histo, histo, 30, 0 , 30.);
00564             
00565             sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_in_cone_HF" ) ;
00566             meSumRecHitsEnergyConeHF = dbe_->book1D(histo,histo,100, -20., 180.);
00567             
00568             sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_in_cone_HFL" );
00569             meSumRecHitsEnergyConeHFL = dbe_->book1D(histo,histo,100,-20., 180.);
00570             
00571             sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_in_cone_HFS");
00572             meSumRecHitsEnergyConeHFS = dbe_->book1D(histo,histo,100,-20., 180.);
00573           }
00574           sprintf (histo, "HcalRecHitTask_sum_of_rechits_energy_HF" ) ;
00575           meSumRecHitsEnergyHF = dbe_->book1D(histo,histo, 80 , -20., 380.);  
00576         }
00577       }
00578       
00579       sprintf(histo, "HcalRecHitTask_severityLevel_HF");
00580       sevLvl_HF = dbe_->book1D(histo, histo, 25, -0.5, 24.5); 
00581 
00582       sprintf (histo, "HcalRecHitTask_energy_of_rechits_HF" ) ;
00583       meRecHitsEnergyHF = dbe_->book1D(histo, histo, 1010 , -10. , 1000.); 
00584 
00585       sprintf (histo, "HcalRecHitTask_timing_HF" ) ;
00586       meTimeHF = dbe_->book1D(histo, histo, 70, -48., 92.); 
00587       
00588       sprintf (histo, "HcalRecHitTask_timing_vs_energy_Low_HF" ) ;
00589       meTE_Low_HF = dbe_->book2D(histo, histo, 100, -5., 195., 70, -48., 92.);
00590 
00591       sprintf (histo, "HcalRecHitTask_timing_vs_energy_HF" ) ;
00592       meTE_HF = dbe_->book2D(histo, histo, 200, -5., 995., 70, -48., 92.);
00593       
00594       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HF" ) ;
00595       meTEprofileHF_Low = dbe_->bookProfile(histo, histo, 100, -5., 195., 70, -48., 92.); 
00596 
00597       sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HF" ) ;
00598       meTEprofileHF = dbe_->bookProfile(histo, histo, 200, -5., 995., 70, -48., 92.); 
00599 
00600     }
00601   }  //end-of if(_dbe) 
00602 
00603 }
00604 
00605 
00606 HcalRecHitsAnalyzer::~HcalRecHitsAnalyzer() { }
00607 
00608 void HcalRecHitsAnalyzer::endJob() { }
00609 
00610 
00611 void HcalRecHitsAnalyzer::beginJob(){ }
00612 
00613 void HcalRecHitsAnalyzer::analyze(edm::Event const& ev, edm::EventSetup const& c) {
00614 
00615   using namespace edm;
00616 
00617   // cuts for each subdet_ector mimiking  "Scheme B"
00618   //  double cutHB = 0.9, cutHE = 1.4, cutHO = 1.1, cutHFL = 1.2, cutHFS = 1.8; 
00619 
00620   // energy in HCAL
00621   double eHcal        = 0.;
00622   double eHcalCone    = 0.;  
00623   double eHcalConeHB  = 0.;  
00624   double eHcalConeHE  = 0.;  
00625   double eHcalConeHO  = 0.;  
00626   double eHcalConeHF  = 0.;  
00627   double eHcalConeHFL = 0.;  
00628   double eHcalConeHFS = 0.;  
00629   // Total numbet of RecHits in HCAL, in the cone, above 1 GeV theshold
00630   int nrechits       = 0;
00631   int nrechitsCone   = 0;
00632   int nrechitsThresh = 0;
00633 
00634   // energy in ECAL
00635   double eEcal       = 0.;
00636   double eEcalB      = 0.;
00637   double eEcalE      = 0.;
00638   double eEcalCone   = 0.;
00639   int numrechitsEcal = 0;
00640 
00641   // HCAL energy around MC eta-phi at all depths;
00642   double partR = 0.3;
00643 //   double ehcal_coneMC_1 = 0.;
00644 //   double ehcal_coneMC_2 = 0.;
00645 //   double ehcal_coneMC_3 = 0.;
00646 //   double ehcal_coneMC_4 = 0.;
00647 
00648   // Cone size for serach of the hottest HCAL cell around MC
00649 //   double searchR = 1.0; 
00650   double eps     = 0.001;
00651 
00652   // Single particle samples: actual eta-phi position of cluster around
00653   // hottest cell
00654   double etaHot  = 99999.; 
00655   double phiHot  = 99999.; 
00656 
00657   //   std::cout << "*** 2" << std::endl; 
00658   //   previously was:  c.get<IdealGeometryRecord>().get (geometry);
00659   c.get<CaloGeometryRecord>().get (geometry);
00660 
00661   // HCAL channel status map ****************************************
00662   edm::ESHandle<HcalChannelQuality> hcalChStatus;
00663   c.get<HcalChannelQualityRcd>().get( hcalChStatus );
00664   theHcalChStatus = hcalChStatus.product();
00665   // Assignment of severity levels **********************************
00666   edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
00667   c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
00668   theHcalSevLvlComputer = hcalSevLvlComputerHndl.product(); 
00669 
00670   // Fill working vectors of HCAL RecHits quantities (all of these are drawn)
00671   fillRecHitsTmp(subdet_, ev); 
00672 
00673   // HB   
00674   if( subdet_ ==5 || subdet_ == 1 ){ 
00675      for(unsigned int iv=0; iv<hcalHBSevLvlVec.size(); iv++){
00676         sevLvl_HB->Fill(hcalHBSevLvlVec[iv]);
00677      }    
00678   }
00679   // HE   
00680   if( subdet_ ==5 || subdet_ == 2 ){
00681      for(unsigned int iv=0; iv<hcalHESevLvlVec.size(); iv++){
00682         sevLvl_HE->Fill(hcalHESevLvlVec[iv]);
00683      }
00684   }
00685   // HO 
00686   if( subdet_ ==5 || subdet_ == 3 ){
00687      for(unsigned int iv=0; iv<hcalHOSevLvlVec.size(); iv++){
00688         sevLvl_HO->Fill(hcalHOSevLvlVec[iv]);
00689      }
00690   }
00691   // HF 
00692   if( subdet_ ==5 || subdet_ == 4 ){
00693      for(unsigned int iv=0; iv<hcalHFSevLvlVec.size(); iv++){
00694         sevLvl_HF->Fill(hcalHFSevLvlVec[iv]);
00695      }
00696   } 
00697 
00698   //  std::cout << "*** 3" << std::endl; 
00699 
00700 
00701   //===========================================================================
00702  // IN ALL other CASES : ieta-iphi maps 
00703   //===========================================================================
00704 
00705   // ECAL 
00706   if(ecalselector_ == "yes" && (subdet_ == 1 || subdet_ == 2 || subdet_ == 5)) {
00707     Handle<EBRecHitCollection> rhitEB;
00708 
00709 
00710       ev.getByLabel("ecalRecHit","EcalRecHitsEB", rhitEB);
00711 
00712     EcalRecHitCollection::const_iterator RecHit = rhitEB.product()->begin();  
00713     EcalRecHitCollection::const_iterator RecHitEnd = rhitEB.product()->end();  
00714     
00715     for (; RecHit != RecHitEnd ; ++RecHit) {
00716       EBDetId EBid = EBDetId(RecHit->id());
00717        
00718       const CaloCellGeometry* cellGeometry =
00719         geometry->getSubdetectorGeometry (EBid)->getGeometry (EBid) ;
00720       double eta = cellGeometry->getPosition ().eta () ;
00721       double phi = cellGeometry->getPosition ().phi () ;
00722       double en  = RecHit->energy();
00723       eEcal  += en;
00724       eEcalB += en;
00725 
00726       if (useAllHistos_) map_ecal->Fill(eta, phi, en);
00727 
00728     }
00729 
00730     
00731     Handle<EERecHitCollection> rhitEE;
00732  
00733       ev.getByLabel("ecalRecHit","EcalRecHitsEE", rhitEE);
00734 
00735     RecHit = rhitEE.product()->begin();  
00736     RecHitEnd = rhitEE.product()->end();  
00737     
00738     for (; RecHit != RecHitEnd ; ++RecHit) {
00739       EEDetId EEid = EEDetId(RecHit->id());
00740       
00741       const CaloCellGeometry* cellGeometry =
00742         geometry->getSubdetectorGeometry (EEid)->getGeometry (EEid) ;
00743       double eta = cellGeometry->getPosition ().eta () ;
00744       double phi = cellGeometry->getPosition ().phi () ;        
00745       double en   = RecHit->energy();
00746       eEcal  += en;
00747       eEcalE += en;
00748 
00749       if (useAllHistos_) map_ecal->Fill(eta, phi, en);
00750 
00751     }
00752   }     // end of ECAL selection 
00753 
00754 
00755   //     std::cout << "*** 4" << std::endl; 
00756 
00757 
00758   // Counting, including ZS items
00759   // Filling HCAL maps  ----------------------------------------------------
00760 //   double maxE = -99999.;
00761   
00762   int nhb1 = 0;
00763   int nhb2 = 0;
00764   int nhe1 = 0;
00765   int nhe2 = 0;
00766   int nhe3 = 0;
00767   int nho  = 0;
00768   int nhf1 = 0;
00769   int nhf2 = 0;  
00770   
00771   for (unsigned int i = 0; i < cen.size(); i++) {
00772     
00773     int sub       = csub[i];
00774     int depth     = cdepth[i];
00775     int ieta      = cieta[i]; 
00776     int iphi      = ciphi[i]; 
00777     double en     = cen[i]; 
00778     //     double eta    = ceta[i]; 
00779     //     double phi    = cphi[i]; 
00780     uint32_t stwd = cstwd[i];
00781     uint32_t auxstwd = cauxstwd[i];
00782     //    double z   = cz[i];
00783 
00784     int index = ieta * 72 + iphi; //  for sequential histos
00785     
00786     /*   
00787          std::cout << "*** point 4-1" << " ieta, iphi, depth, sub = "
00788          << ieta << ", " << iphi << ", " << depth << ", " << sub  
00789          << std::endl;
00790     */
00791     
00792     
00793     if( sub == 1 && depth == 1)  nhb1++;
00794     if( sub == 1 && depth == 2)  nhb2++;
00795     if( sub == 2 && depth == 1)  nhe1++;
00796     if( sub == 2 && depth == 2)  nhe2++;
00797     if( sub == 2 && depth == 3)  nhe3++;
00798     if( sub == 3 && depth == 4)  nho++;
00799     if( sub == 4 && depth == 1)  nhf1++;
00800     if( sub == 4 && depth == 2)  nhf2++;
00801     
00802     if( subdet_ == 6) {                                    // ZS specific
00803       if( en < emap_min[ieta+41][iphi][depth-1][sub-1] )
00804         emap_min[ieta+41][iphi][depth-1][sub-1] = en;
00805     }
00806     
00807 //     double emin = 1.;
00808 //     if(fabs(eta) > 3.) emin = 5.; 
00809     
00810     /*   
00811     if(ieta == 27 ) { 
00812       std::cout << "*** ieta=28, iphi = " << iphi << "  det = " 
00813                 << sub << "  depth = " << depth << std::endl;
00814     }
00815     */
00816 
00817     if( subdet_ != 6) {  
00818 
00819       //      std::cout << "*** 4-1" << std::endl; 
00820       //The emean_vs_ieta histos are drawn as well as the e_maps
00821 
00822 
00823       // to distinguish HE and HF
00824       if( depth == 1 || depth == 2 ) {
00825         int ieta1 =  ieta;
00826         if(sub == 4) { 
00827           if (ieta1 < 0) ieta1--;
00828           else  ieta1++;   
00829         }
00830         if (depth == 1) emap_depth1->Fill(double(ieta1), double(iphi), en);
00831         if (depth == 2) emap_depth2->Fill(double(ieta1), double(iphi), en);
00832       }
00833 
00834       if( depth == 3) emap_depth3->Fill(double(ieta), double(iphi), en);
00835       if( depth == 4) emap_depth4->Fill(double(ieta), double(iphi), en);
00836       
00837       if (depth == 1 && sub == 1 ) {
00838         emean_vs_ieta_HB1->Fill(double(ieta), en);
00839         occupancy_map_HB1->Fill(double(ieta), double(iphi));          
00840         if(useAllHistos_){
00841           emean_seqHB1->Fill(double(index), en);
00842         }
00843       }
00844       if (depth == 2  && sub == 1) {
00845         emean_vs_ieta_HB2->Fill(double(ieta), en);
00846         occupancy_map_HB2->Fill(double(ieta), double(iphi));          
00847         if(useAllHistos_){
00848           emean_seqHB2->Fill(double(index), en);
00849         }
00850       }
00851       if (depth == 1 && sub == 2) {
00852         emean_vs_ieta_HE1->Fill(double(ieta), en);
00853         occupancy_map_HE1->Fill(double(ieta), double(iphi));   
00854         if(useAllHistos_){
00855           emean_seqHE1->Fill(double(index), en);
00856         }
00857       }
00858       if (depth == 2 && sub == 2) {
00859         emean_vs_ieta_HE2->Fill(double(ieta), en);
00860         occupancy_map_HE2->Fill(double(ieta), double(iphi));          
00861         if(useAllHistos_){
00862           emean_seqHE2->Fill(double(index), en);
00863         }
00864       }
00865       if (depth == 3 && sub == 2) {
00866         emean_vs_ieta_HE3->Fill(double(ieta), en);
00867         occupancy_map_HE3->Fill(double(ieta), double(iphi));          
00868         if(useAllHistos_){
00869           emean_seqHE3->Fill(double(index), en);
00870         }
00871       }
00872       if (depth == 4 ) {
00873         emean_vs_ieta_HO->Fill(double(ieta), en);
00874         occupancy_map_HO->Fill(double(ieta), double(iphi));          
00875         if(useAllHistos_){
00876           emean_seqHO->Fill(double(index), en);
00877         }
00878       }
00879       if (depth == 1 && sub == 4) {
00880         emean_vs_ieta_HF1->Fill(double(ieta), en);
00881         occupancy_map_HF1->Fill(double(ieta), double(iphi));          
00882         if(useAllHistos_){
00883           emean_seqHF1->Fill(double(index), en);
00884         }
00885       }
00886       if (depth == 2 && sub == 4) {
00887         emean_vs_ieta_HF2->Fill(double(ieta), en);
00888         occupancy_map_HF2->Fill(double(ieta), double(iphi));          
00889         if(useAllHistos_){
00890           emean_seqHF2->Fill(double(index), en);
00891         }
00892       }
00893     }
00894     
00895 
00896 //     if( r < partR ) {
00897 //       if (depth == 1) ehcal_coneMC_1 += en; 
00898 //       if (depth == 2) ehcal_coneMC_2 += en; 
00899 //       if (depth == 3) ehcal_coneMC_3 += en; 
00900 //       if (depth == 4) ehcal_coneMC_4 += en; 
00901 //     }
00902     
00903     //32-bit status word  
00904     uint32_t statadd;
00905     unsigned int isw67 = 0;
00906     for (unsigned int isw = 0; isw < 32; isw++){
00907       statadd = 0x1<<(isw);
00908       if (stwd & statadd){
00909         if      (sub == 1) RecHit_StatusWord_HB->Fill(isw);
00910         else if (sub == 2) RecHit_StatusWord_HE->Fill(isw);
00911         else if (sub == 3) RecHit_StatusWord_HO->Fill(isw);
00912         else if (sub == 4){
00913           RecHit_StatusWord_HF->Fill(isw);
00914           if (isw == 6) isw67 += 1;
00915           if (isw == 7) isw67 += 2;
00916         }
00917       }
00918     }
00919     if (isw67 != 0 && useAllHistos_) RecHit_StatusWord_HF67->Fill(isw67); //This one is not drawn
00920 
00921     for (unsigned int isw =0; isw < 32; isw++){
00922       statadd = 0x1<<(isw);
00923       if( auxstwd & statadd ){
00924         if      (sub == 1) RecHit_Aux_StatusWord_HB->Fill(isw);
00925         else if (sub == 2) RecHit_Aux_StatusWord_HE->Fill(isw);
00926         else if (sub == 3) RecHit_Aux_StatusWord_HO->Fill(isw);
00927         else if (sub == 4) RecHit_Aux_StatusWord_HF->Fill(isw);
00928       }
00929 
00930     }
00931 
00932   } 
00933  
00934   //  std::cout << "*** 4-2" << std::endl; 
00935   
00936   if( subdet_ == 6 && useAllHistos_) {               // ZS plots; not drawn
00937     ZS_nHB1->Fill(double(nhb1));  
00938     ZS_nHB2->Fill(double(nhb2));  
00939     ZS_nHE1->Fill(double(nhe1));  
00940     ZS_nHE2->Fill(double(nhe2));  
00941     ZS_nHE3->Fill(double(nhe3));  
00942     ZS_nHO ->Fill(double(nho));  
00943     ZS_nHF1->Fill(double(nhf1));  
00944     ZS_nHF2->Fill(double(nhf2));  
00945   }
00946   else{ 
00947     Nhb->Fill(double(nhb1 + nhb2));
00948     Nhe->Fill(double(nhe1 + nhe2 + nhe3));
00949     Nho->Fill(double(nho));
00950     Nhf->Fill(double(nhf1 + nhf2));
00951 
00952   }
00953 
00954   //  std::cout << "*** 5" << std::endl; 
00955     
00956 
00957   //  NOISE ================================================================= 
00958   //Not drawn
00959   if (hcalselector_ == "noise" && useAllHistos_) {
00960     for (unsigned int i = 0; i < cen.size(); i++) {
00961       
00962       int sub   = csub[i];
00963       int depth = cdepth[i];
00964       double en = cen[i]; 
00965       
00966       if (sub == 1) e_hb->Fill(en);
00967       if (sub == 2) e_he->Fill(en);  
00968       if (sub == 3) e_ho->Fill(en);  
00969       if (sub == 4) {
00970         if(depth == 1)  
00971           e_hfl->Fill(en);  
00972         else 
00973           e_hfs->Fill(en);  
00974       }
00975     }
00976   }
00977 
00978   //===========================================================================
00979   // SUBSYSTEMS,  
00980   //===========================================================================
00981   
00982   else if ((subdet_ != 6) && (subdet_ != 0)) {
00983 
00984     //       std::cout << "*** 6" << std::endl; 
00985     
00986     
00987     double clusEta = 999.;
00988     double clusPhi = 999.; 
00989     double clusEn  = 0.;
00990     
00991     double HcalCone_d1 = 0.;
00992     double HcalCone_d2 = 0.;
00993     double HcalCone_d3 = 0.;
00994     double HcalCone_d4 = 0.;
00995     double HcalCone    = 0.;
00996 
00997     int ietaMax1  =  9999;
00998     int ietaMax2  =  9999;
00999     int ietaMax3  =  9999;
01000     int ietaMax4  =  9999;
01001     int ietaMax   =  9999;
01002     //     double enMax1 = -9999.;
01003     //     double enMax2 = -9999.;
01004     //     double enMax3 = -9999.;
01005     //     double enMax4 = -9999.;
01006     //     double enMax  = -9999.;
01007     //     double etaMax =  9999.;
01008 
01009     //   CYCLE over cells ====================================================
01010 
01011     for (unsigned int i = 0; i < cen.size(); i++) {
01012       int sub    = csub[i];
01013       int depth  = cdepth[i];
01014       double eta = ceta[i]; 
01015       double phi = cphi[i]; 
01016       double en  = cen[i]; 
01017       double t   = ctime[i];
01018 //       int   ieta = cieta[i];
01019 
01020       double rhot = dR(etaHot, phiHot, eta, phi); 
01021       if(rhot < partR && en > 1.) { 
01022         clusEta = (clusEta * clusEn + eta * en)/(clusEn + en);
01023         clusPhi = phi12(clusPhi, clusEn, phi, en); 
01024         clusEn += en;
01025       }
01026 
01027       nrechits++;           
01028       eHcal += en;
01029       if(en > 1. ) nrechitsThresh++;
01030       
01031       //The energy and overall timing histos are drawn while
01032       //the ones split by depth are not
01033       if(sub == 1 && (subdet_ == 1 || subdet_ == 5)) {  
01034         meTimeHB->Fill(t);
01035         meRecHitsEnergyHB->Fill(en);
01036         
01037         meTE_Low_HB->Fill( en, t);
01038         meTE_HB->Fill( en, t);
01039         meTE_High_HB->Fill( en, t);
01040         meTEprofileHB_Low->Fill(en, t);
01041         meTEprofileHB->Fill(en, t);
01042         meTEprofileHB_High->Fill(en, t);
01043 
01044         if (useAllHistos_){
01045           if      (depth == 1) meTE_HB1->Fill( en, t);
01046           else if (depth == 2) meTE_HB2->Fill( en, t);
01047         }
01048       }     
01049       if(sub == 2 && (subdet_ == 2 || subdet_ == 5)) {  
01050         meTimeHE->Fill(t);
01051         meRecHitsEnergyHE->Fill(en);
01052 
01053         meTE_Low_HE->Fill( en, t);
01054         meTE_HE->Fill( en, t);
01055         meTEprofileHE_Low->Fill(en, t);
01056         meTEprofileHE->Fill(en, t);
01057 
01058         if (useAllHistos_){
01059           if      (depth == 1) meTE_HE1->Fill( en, t);
01060           else if (depth == 2) meTE_HE2->Fill( en, t);
01061         }
01062       }
01063       if(sub == 4 && (subdet_ == 4 || subdet_ == 5)) {  
01064         meTimeHF->Fill(t);
01065         meRecHitsEnergyHF->Fill(en);      
01066 
01067         meTE_Low_HF->Fill(en, t);
01068         meTE_HF->Fill(en, t);
01069         meTEprofileHF_Low->Fill(en, t);
01070         meTEprofileHF->Fill(en, t);
01071 
01072         if (useAllHistos_){
01073           if   (depth == 1) meTE_HFL->Fill( en, t);
01074           else              meTE_HFS->Fill( en, t);
01075         }
01076       }
01077       if(sub == 3 && (subdet_ == 3 || subdet_ == 5)) {  
01078         meTimeHO->Fill(t);
01079         meRecHitsEnergyHO->Fill(en);
01080 
01081         meTE_HO->Fill( en, t);
01082         meTE_High_HO->Fill( en, t);
01083         meTEprofileHO->Fill(en, t);
01084         meTEprofileHO_High->Fill(en, t);
01085       }
01086     }
01087 
01088     if(imc != 0) {
01089       //Cone by depth are not drawn, the others are used for pion scan
01090       if (useAllHistos_){
01091         meEnConeEtaProfile_depth1->Fill(double(ietaMax1), HcalCone_d1);
01092         meEnConeEtaProfile_depth2->Fill(double(ietaMax2), HcalCone_d2);
01093         meEnConeEtaProfile_depth3->Fill(double(ietaMax3), HcalCone_d3);
01094         meEnConeEtaProfile_depth4->Fill(double(ietaMax4), HcalCone_d4);
01095       }
01096       meEnConeEtaProfile       ->Fill(double(ietaMax),  HcalCone);   // 
01097       meEnConeEtaProfile_E     ->Fill(double(ietaMax), eEcalCone);   
01098       meEnConeEtaProfile_EH    ->Fill(double(ietaMax),  HcalCone+eEcalCone); 
01099     }
01100 
01101     //     std::cout << "*** 7" << std::endl; 
01102 
01103     
01104     // Single particle samples ONLY !  ======================================
01105     // Fill up some histos for "integrated" subsustems. 
01106     // These are not drawn
01107     if(etype_ == 1 && useAllHistos_) {
01108 
01109       /*
01110       std::cout << "*** point 7-1" << "  eta_MC, phi_MC   clusEta, clusPhi = "
01111                 << eta_MC  << ", " << phi_MC << "   "
01112                 << clusEta << ", " << clusPhi 
01113                 << std::endl;
01114       */    
01115 
01116 //       double phidev = dPhiWsign(clusPhi, phi_MC);
01117 //       meDeltaPhi->Fill(eta_MC, phidev);
01118 //       double etadev = clusEta - eta_MC;
01119 //       meDeltaEta->Fill(eta_MC, etadev);
01120 
01121       if(subdet_ == 1) {
01122         meSumRecHitsEnergyHB->Fill(eHcal);
01123         if(imc != 0) meSumRecHitsEnergyConeHB->Fill(eHcalConeHB);    
01124         if(imc != 0) meNumRecHitsConeHB->Fill(double(nrechitsCone));
01125         meNumRecHitsThreshHB->Fill(double(nrechitsThresh));
01126       }
01127 
01128       if(subdet_ == 2) {
01129         meSumRecHitsEnergyHE->Fill(eHcal);
01130         if(imc != 0) meSumRecHitsEnergyConeHE->Fill(eHcalConeHE);    
01131         if(imc != 0) meNumRecHitsConeHE->Fill(double(nrechitsCone));
01132         meNumRecHitsThreshHE->Fill(double(nrechitsThresh));
01133       }
01134 
01135       if(subdet_ == 3) {
01136         meSumRecHitsEnergyHO->Fill(eHcal);
01137         if(imc != 0) meSumRecHitsEnergyConeHO->Fill(eHcalConeHO);    
01138         if(imc != 0) meNumRecHitsConeHO->Fill(double(nrechitsCone));
01139         meNumRecHitsThreshHO->Fill(double(nrechitsThresh));
01140       }
01141 
01142       if(subdet_ == 4) {
01143         if(eHcalConeHF > eps ) {
01144           meSumRecHitsEnergyHF ->Fill(eHcal);
01145           if(imc != 0) { 
01146             meSumRecHitsEnergyConeHF ->Fill(eHcalConeHF);    
01147             meNumRecHitsConeHF->Fill(double(nrechitsCone));
01148             meSumRecHitsEnergyConeHFL ->Fill(eHcalConeHFL);    
01149             meSumRecHitsEnergyConeHFS ->Fill(eHcalConeHFS);    
01150           }
01151         }
01152       }
01153 
01154       //         std::cout << "*** 8" << std::endl; 
01155 
01156 
01157       // Also combine with ECAL if needed 
01158       if(subdet_ == 1  && ecalselector_ == "yes") {
01159         
01160         /*
01161           std::cout << "*** point 8-1" 
01162           << "  eEcalB " << eEcalB << "  eHcal " << eHcal
01163           << "  eEcalCone " <<  eEcalCone << "  eHcalCone " 
01164                   << eHcalCone
01165                   << "  numrechitsEcal " <<  numrechitsEcal
01166                   << std::endl;
01167                   
01168         */
01169         
01170         meEcalHcalEnergyHB->Fill(eEcalB+eHcal);
01171         meEcalHcalEnergyConeHB->Fill(eEcalCone+eHcalCone);
01172         meNumEcalRecHitsConeHB->Fill(double(numrechitsEcal));
01173         
01174       }
01175       
01176       if(subdet_ == 2  && ecalselector_ == "yes"){
01177         
01178         /*
01179           std::cout << "*** point 8-2a" 
01180           << "  eEcalE " << eEcalE << "  eHcal " << eHcal
01181           << "  eEcalCone " <<  eEcalCone << "  eHcalCone " 
01182           << eHcalCone
01183           << "  numrechitsEcal " <<  numrechitsEcal
01184           << std::endl;
01185         */
01186         
01187         meEcalHcalEnergyHE->Fill(eEcalE+eHcal);
01188         if(imc != 0) meEcalHcalEnergyConeHE->Fill(eEcalCone+eHcalCone);
01189         if(imc != 0) meNumEcalRecHitsConeHE->Fill(double(numrechitsEcal));
01190       } 
01191 
01192       // Banana plots finally
01193       if(imc != 0) {
01194         if(subdet_ == 1 && ecalselector_ == "yes")
01195           meEnergyHcalVsEcalHB -> Fill(eEcalCone,eHcalCone);
01196         if(subdet_ == 2 && ecalselector_ == "yes") 
01197           meEnergyHcalVsEcalHE -> Fill(eEcalCone,eHcalCone);
01198       }
01199     }
01200   }
01201   //  std::cout << "*** 9" << std::endl; 
01202 
01203   nevtot++;
01204 }
01205 
01206 
01208 void HcalRecHitsAnalyzer::fillRecHitsTmp(int subdet_, edm::Event const& ev){
01209   
01210   using namespace edm;
01211   
01212   
01213   // initialize data vectors
01214   csub.clear();
01215   cen.clear();
01216   ceta.clear();
01217   cphi.clear();
01218   ctime.clear();
01219   cieta.clear();
01220   ciphi.clear();
01221   cdepth.clear();
01222   cz.clear();
01223   cstwd.clear();
01224   cauxstwd.clear();
01225   hcalHBSevLvlVec.clear();
01226   hcalHESevLvlVec.clear();
01227   hcalHFSevLvlVec.clear();
01228   hcalHOSevLvlVec.clear(); 
01229 
01230   if( subdet_ == 1 || subdet_ == 2  || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
01231     
01232     //HBHE
01233     edm::Handle<HBHERecHitCollection> hbhecoll;
01234     ev.getByLabel(theHBHERecHitCollectionLabel, hbhecoll);
01235     
01236     for (HBHERecHitCollection::const_iterator j=hbhecoll->begin(); j != hbhecoll->end(); j++) {
01237       HcalDetId cell(j->id());
01238       const CaloCellGeometry* cellGeometry =
01239         geometry->getSubdetectorGeometry (cell)->getGeometry (cell) ;
01240       double eta  = cellGeometry->getPosition().eta () ;
01241       double phi  = cellGeometry->getPosition().phi () ;
01242       double zc   = cellGeometry->getPosition().z ();
01243       int sub     = cell.subdet();
01244       int depth   = cell.depth();
01245       int inteta  = cell.ieta();
01246       if(inteta > 0) inteta -= 1;
01247       int intphi  = cell.iphi()-1;
01248       double en   = j->energy();
01249       double t    = j->time();
01250       int stwd    = j->flags();
01251       int auxstwd = j->aux();
01252       
01253       int serivityLevel = hcalSevLvl( (CaloRecHit*) &*j );
01254       if( cell.subdet()==HcalBarrel ){
01255          hcalHBSevLvlVec.push_back(serivityLevel);
01256       }else if (cell.subdet()==HcalEndcap ){
01257          hcalHESevLvlVec.push_back(serivityLevel);
01258       } 
01259       
01260       if((iz > 0 && eta > 0.) || (iz < 0 && eta <0.) || iz == 0) { 
01261         
01262         csub.push_back(sub);
01263         cen.push_back(en);
01264         ceta.push_back(eta);
01265         cphi.push_back(phi);
01266         ctime.push_back(t);
01267         cieta.push_back(inteta);
01268         ciphi.push_back(intphi);
01269         cdepth.push_back(depth);
01270         cz.push_back(zc);
01271         cstwd.push_back(stwd);
01272         cauxstwd.push_back(auxstwd);
01273       }
01274     }
01275     
01276   }
01277 
01278   if( subdet_ == 4 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
01279 
01280     //HF
01281     edm::Handle<HFRecHitCollection> hfcoll;
01282     ev.getByLabel(theHFRecHitCollectionLabel, hfcoll);
01283 
01284     for (HFRecHitCollection::const_iterator j = hfcoll->begin(); j != hfcoll->end(); j++) {
01285       HcalDetId cell(j->id());
01286       const CaloCellGeometry* cellGeometry =
01287         geometry->getSubdetectorGeometry (cell)->getGeometry (cell) ;
01288       double eta   = cellGeometry->getPosition().eta () ;
01289       double phi   = cellGeometry->getPosition().phi () ;
01290       double zc     = cellGeometry->getPosition().z ();
01291       int sub      = cell.subdet();
01292       int depth    = cell.depth();
01293       int inteta   = cell.ieta();
01294       if(inteta > 0) inteta -= 1;
01295       int intphi   = cell.iphi()-1;
01296       double en    = j->energy();
01297       double t     = j->time();
01298       int stwd     = j->flags();
01299       int auxstwd  = j->aux();
01300 
01301       int serivityLevel = hcalSevLvl( (CaloRecHit*) &*j );
01302       if( cell.subdet()==HcalForward ){
01303          hcalHFSevLvlVec.push_back(serivityLevel);
01304       } 
01305 
01306       if((iz > 0 && eta > 0.) || (iz < 0 && eta <0.) || iz == 0) { 
01307         
01308         csub.push_back(sub);
01309         cen.push_back(en);
01310         ceta.push_back(eta);
01311         cphi.push_back(phi);
01312         ctime.push_back(t);
01313         cieta.push_back(inteta);
01314         ciphi.push_back(intphi);
01315         cdepth.push_back(depth);
01316         cz.push_back(zc);
01317         cstwd.push_back(stwd);
01318         cauxstwd.push_back(auxstwd);
01319       }
01320     }
01321   }
01322 
01323   //HO
01324   if( subdet_ == 3 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
01325   
01326     edm::Handle<HORecHitCollection> hocoll;
01327     ev.getByLabel(theHORecHitCollectionLabel, hocoll);
01328     
01329     for (HORecHitCollection::const_iterator j = hocoll->begin(); j != hocoll->end(); j++) {
01330       HcalDetId cell(j->id());
01331       const CaloCellGeometry* cellGeometry =
01332         geometry->getSubdetectorGeometry (cell)->getGeometry (cell) ;
01333       double eta   = cellGeometry->getPosition().eta () ;
01334       double phi   = cellGeometry->getPosition().phi () ;
01335       double zc    = cellGeometry->getPosition().z ();
01336       int sub      = cell.subdet();
01337       int depth    = cell.depth();
01338       int inteta   = cell.ieta();
01339       if(inteta > 0) inteta -= 1;
01340       int intphi   = cell.iphi()-1;
01341       double t     = j->time();
01342       double en    = j->energy();
01343       int stwd     = j->flags();
01344       int auxstwd  = j->aux();
01345 
01346       int serivityLevel = hcalSevLvl( (CaloRecHit*) &*j );
01347       if( cell.subdet()==HcalOuter ){
01348          hcalHOSevLvlVec.push_back(serivityLevel);
01349       } 
01350       
01351       if((iz > 0 && eta > 0.) || (iz < 0 && eta <0.) || iz == 0) { 
01352         csub.push_back(sub);
01353         cen.push_back(en);
01354         ceta.push_back(eta);
01355         cphi.push_back(phi);
01356         ctime.push_back(t);
01357         cieta.push_back(inteta);
01358         ciphi.push_back(intphi);
01359         cdepth.push_back(depth);
01360         cz.push_back(zc);
01361         cstwd.push_back(stwd);
01362         cauxstwd.push_back(auxstwd);
01363       }
01364     }
01365   }
01366 }
01367 
01368 double HcalRecHitsAnalyzer::dR(double eta1, double phi1, double eta2, double phi2) { 
01369   double PI = 3.1415926535898;
01370   double deltaphi= phi1 - phi2;
01371   if( phi2 > phi1 ) { deltaphi= phi2 - phi1;}
01372   if(deltaphi > PI) { deltaphi = 2.*PI - deltaphi;}
01373   double deltaeta = eta2 - eta1;
01374   double tmp = sqrt(deltaeta* deltaeta + deltaphi*deltaphi);
01375   return tmp;
01376 }
01377 
01378 double HcalRecHitsAnalyzer::phi12(double phi1, double en1, double phi2, double en2) {
01379   // weighted mean value of phi1 and phi2
01380   
01381   double tmp;
01382   double PI = 3.1415926535898;
01383   double a1 = phi1; double a2  = phi2;
01384 
01385   if( a1 > 0.5*PI  && a2 < 0.) a2 += 2*PI; 
01386   if( a2 > 0.5*PI  && a1 < 0.) a1 += 2*PI; 
01387   tmp = (a1 * en1 + a2 * en2)/(en1 + en2);
01388   if(tmp > PI) tmp -= 2.*PI; 
01389  
01390   return tmp;
01391 
01392 }
01393 
01394 double HcalRecHitsAnalyzer::dPhiWsign(double phi1, double phi2) {
01395   // clockwise      phi2 w.r.t phi1 means "+" phi distance
01396   // anti-clockwise phi2 w.r.t phi1 means "-" phi distance 
01397 
01398   double PI = 3.1415926535898;
01399   double a1 = phi1; double a2  = phi2;
01400   double tmp =  a2 - a1;
01401   if( a1*a2 < 0.) {
01402     if(a1 > 0.5 * PI)  tmp += 2.*PI;
01403     if(a2 > 0.5 * PI)  tmp -= 2.*PI;
01404   }
01405   return tmp;
01406 
01407 }
01408 
01409 int HcalRecHitsAnalyzer::hcalSevLvl(const CaloRecHit* hit){
01410 
01411    const DetId id = hit->detid();
01412 
01413    const uint32_t recHitFlag = hit->flags();
01414    const uint32_t dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
01415 
01416    int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
01417 
01418    return severityLevel;
01419 
01420 } 
01421 
01422 DEFINE_FWK_MODULE(HcalRecHitsAnalyzer);
01423