CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Validation/CaloTowers/src/CaloTowersValidation.cc

Go to the documentation of this file.
00001 #include "Validation/CaloTowers/interface/CaloTowersValidation.h"
00002 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00003 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00004 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00005 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00006 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00007 
00008 CaloTowersValidation::CaloTowersValidation(edm::ParameterSet const& conf):
00009   theCaloTowerCollectionLabel(conf.getUntrackedParameter<edm::InputTag>("CaloTowerCollectionLabel"))
00010 {
00011   // DQM ROOT output
00012   outputFile_ = conf.getUntrackedParameter<std::string>("outputFile", "myfile.root");
00013 
00014   hcalselector_ = conf.getUntrackedParameter<std::string>("hcalselector", "all");
00015 
00016   mc_           = conf.getUntrackedParameter<std::string>("mc", "yes");
00017   useAllHistos_ = conf.getUntrackedParameter<bool>("useAllHistos", false);
00018 
00019   etaMin[0] = 0.;
00020   etaMax[0] = 1.4;
00021   etaMin[1] = 1.4;
00022   etaMax[1] = 2.9;
00023   etaMin[2] = 2.9;
00024   etaMax[2] = 5.2;
00025 
00026   isub = 0;
00027   if(hcalselector_ == "HB") isub = 1;
00028   if(hcalselector_ == "HE") isub = 2;
00029   if(hcalselector_ == "HF") isub = 3;
00030 
00031   imc = 1;
00032   if(mc_ == "no") imc = 0;
00033   
00034   if ( outputFile_.size() != 0 ) {
00035     edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will be saved to '" << outputFile_.c_str() << "'";
00036   } else {
00037     edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will NOT be saved";
00038   }
00039   
00040   dbe_ = 0;
00041   // get hold of back-end interface
00042   dbe_ = edm::Service<DQMStore>().operator->();
00043    
00044   // const char * sub = hcalselector_.c_str();
00045 
00046   Char_t histo[100];
00047 
00048   if ( dbe_ ) {
00049     dbe_->setCurrentFolder("CaloTowersV/CaloTowersTask");
00050   }
00051 
00052   //These two histos are not drawn by our macros, but they are used
00053   //in the EndJob for norms and such so I am leaving them alone for now
00054   //-------------------------------------------------------------------------------------------
00055   sprintf  (histo, "Ntowers_per_event_vs_ieta" );
00056   Ntowers_vs_ieta = dbe_->book1D(histo, histo, 82, -41., 41.);
00057   
00058   sprintf  (histo, "CaloTowersTask_map_Nentries" );
00059   mapEnergy_N = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00060   //-------------------------------------------------------------------------------------------
00061 
00062   //These the single pion scan histos
00063   //-------------------------------------------------------------------------------------------
00064   //The first three are not used
00065   if (useAllHistos_){
00066     sprintf  (histo, "emean_vs_ieta_E" );
00067     emean_vs_ieta_E = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000., "s");
00068     sprintf  (histo, "emean_vs_ieta_H" );
00069     emean_vs_ieta_H = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000., "s");
00070     sprintf  (histo, "emean_vs_ieta_EH" );
00071     emean_vs_ieta_EH = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000., "s");
00072   }
00073   //These are drawn
00074   sprintf  (histo, "emean_vs_ieta_E1" );
00075   emean_vs_ieta_E1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000., "s");
00076   sprintf  (histo, "emean_vs_ieta_H1" );
00077   emean_vs_ieta_H1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000., "s");
00078   sprintf  (histo, "emean_vs_ieta_EH1" );
00079   emean_vs_ieta_EH1 = dbe_->bookProfile(histo, histo, 82, -41., 41., 2100, -100., 2000., "s");
00080   //-------------------------------------------------------------------------------------------
00081 
00082   //Map energy histos are not drawn
00083   if (useAllHistos_){
00084     sprintf  (histo, "CaloTowersTask_map_energy_E" );
00085     mapEnergy_E = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00086     sprintf  (histo, "CaloTowersTask_map_energy_H");
00087     mapEnergy_H = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00088     sprintf  (histo, "CaloTowersTask_map_energy_EH" );
00089     mapEnergy_EH = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00090   }
00091 
00092   //All ECAL cell histos are used
00093   // XXX: ECAL 0-25 [0-26, 26 bins]   HCAL 0-4 [0-5, 5 bins]
00094   sprintf  (histo, "number_of_bad_cells_Ecal_EB");
00095   numBadCellsEcal_EB = dbe_->book1D(histo, histo, 26, 0, 26);
00096   sprintf  (histo, "number_of_bad_cells_Ecal_EE");
00097   numBadCellsEcal_EE = dbe_->book1D(histo, histo, 26, 0, 26);
00098   sprintf  (histo, "number_of_recovered_cells_Ecal_EB");
00099   numRcvCellsEcal_EB = dbe_->book1D(histo, histo, 26, 0, 26);
00100   sprintf  (histo, "number_of_recovered_cells_Ecal_EE");
00101   numRcvCellsEcal_EE = dbe_->book1D(histo, histo, 26, 0, 26);
00102   sprintf  (histo, "number_of_problematic_cells_Ecal_EB");
00103   numPrbCellsEcal_EB = dbe_->book1D(histo, histo, 26, 0, 26);
00104   sprintf  (histo, "number_of_problematic_cells_Ecal_EE");
00105   numPrbCellsEcal_EE = dbe_->book1D(histo, histo, 26, 0, 26); 
00106 
00107   //Occupancy vs. ieta is drawn, occupancy map is needed to draw it 
00108   sprintf  (histo, "CaloTowersTask_map_occupancy" );
00109   occupancy_map = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00110 
00111   sprintf  (histo, "CaloTowersTask_occupancy_vs_ieta" );
00112   occupancy_vs_ieta = dbe_->book1D(histo, histo, 82, -41, 41);
00113   
00114   if( isub == 1 || isub == 0) {
00115     //All cell histos are used
00116     sprintf  (histo, "number_of_bad_cells_Hcal_HB");
00117     numBadCellsHcal_HB = dbe_->book1D(histo, histo, 5, 0, 5);
00118     sprintf  (histo, "number_of_recovered_cells_Hcal_HB");
00119     numRcvCellsHcal_HB = dbe_->book1D(histo, histo, 5, 0, 5);
00120     sprintf  (histo, "number_of_problematic_cells_Hcal_HB");
00121     numPrbCellsHcal_HB = dbe_->book1D(histo, histo, 5, 0, 5); 
00122     
00123     //These are the five oldest CaloTower histos used: NTowers, E in HCAL/ECAL, MET and SET
00124     //-------------------------------------------------------------------------------------------
00125     sprintf (histo, "CaloTowersTask_energy_HCAL_HB" ) ;
00126     meEnergyHcal_HB    = dbe_->book1D(histo, histo, 4100, -200, 8000);  
00127     
00128     sprintf (histo, "CaloTowersTask_energy_ECAL_HB" ) ;
00129     meEnergyEcal_HB    = dbe_->book1D(histo, histo, 3100, -200, 6000); 
00130     
00131     sprintf (histo, "CaloTowersTask_number_of_fired_towers_HB" ) ;
00132     meNumFiredTowers_HB = dbe_->book1D(histo, histo, 1000, 0, 2000); 
00133 
00134     sprintf  (histo, "CaloTowersTask_MET_HB" ) ;
00135     MET_HB = dbe_->book1D(histo, histo, 3000, 0. , 3000. ) ;
00136     
00137     sprintf  (histo, "CaloTowersTask_SET_HB" ) ;
00138     SET_HB = dbe_->book1D(histo, histo, 8000, 0. , 8000. ) ;
00139     //-------------------------------------------------------------------------------------------
00140 
00141     //Timing histos and profiles -- all six are necessary
00142     //-------------------------------------------------------------------------------------------
00143     sprintf  (histo, "CaloTowersTask_EM_Timing_HB" ) ;
00144     emTiming_HB = dbe_->book1D(histo, histo, 110, -120., 100. ) ;
00145 
00146     sprintf  (histo, "CaloTowersTask_HAD_Timing_HB" ) ;
00147     hadTiming_HB = dbe_->book1D(histo, histo, 70, -48., 92. ) ;
00148 
00149     //Energy-Timing histos are divided into low, medium and high to reduce memory usage
00150     //EM
00151     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_Low_HB" ) ;
00152     emEnergyTiming_Low_HB = dbe_->book2D(histo, histo, 40, 0. , 40., 110, -120., 100.  ) ;
00153 
00154     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_HB" ) ;
00155     emEnergyTiming_HB = dbe_->book2D(histo, histo, 200, 0. , 400., 110, -120., 100.  ) ;
00156 
00157     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_High_HB" ) ;
00158     emEnergyTiming_High_HB = dbe_->book2D(histo, histo, 200, 0. , 3000., 110, -120., 100.  ) ;
00159 
00160     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_profile_Low_HB" ) ;
00161     emEnergyTiming_profile_Low_HB = dbe_->bookProfile(histo, histo, 40, 0. , 40., 110, -120., 100.  ) ;
00162 
00163     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_profile_HB" ) ;
00164     emEnergyTiming_profile_HB = dbe_->bookProfile(histo, histo, 200, 0. , 400., 110, -120., 100.  ) ;
00165 
00166     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_profile_High_HB" ) ;
00167     emEnergyTiming_profile_High_HB = dbe_->bookProfile(histo, histo, 200, 0. , 3000., 110, -120., 100.  ) ;
00168 
00169     //HAD
00170     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_Low_HB" ) ;
00171     hadEnergyTiming_Low_HB = dbe_->book2D(histo, histo, 40, 0. , 40., 70, -48., 92. ) ;
00172 
00173     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_HB" ) ;
00174     hadEnergyTiming_HB = dbe_->book2D(histo, histo, 100, 0. , 200., 70, -48., 92. ) ;
00175 
00176     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_High_HB" ) ;
00177     hadEnergyTiming_High_HB = dbe_->book2D(histo, histo, 300, 0. , 3000., 70, -48., 92. ) ;
00178 
00179     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_Low_HB" ) ;
00180     hadEnergyTiming_profile_Low_HB = dbe_->bookProfile(histo, histo, 40, 0. , 40., 70, -48., 92. ) ;
00181 
00182     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_HB" ) ;
00183     hadEnergyTiming_profile_HB = dbe_->bookProfile(histo, histo, 100, 0. , 200., 70, -48., 92. ) ;
00184 
00185     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_High_HB" ) ;
00186     hadEnergyTiming_profile_High_HB = dbe_->bookProfile(histo, histo, 300, 0. , 3000., 70, -48., 92. ) ;
00187     //-------------------------------------------------------------------------------------------
00188 
00189     //Everything else is not drawn
00190     if (useAllHistos_){
00191       sprintf (histo, "CaloTowersTask_sum_of_energy_HCAL_vs_ECAL_HB") ;
00192       meEnergyHcalvsEcal_HB    = dbe_->book2D(histo, histo, 500, 0., 500., 500, 0., 500.);
00193       
00194       sprintf (histo, "CaloTowersTask_energy_OUTER_HB" ) ;
00195       meEnergyHO_HB    = dbe_->book1D(histo, histo, 1640, -200, 8000);   
00196       
00197       sprintf (histo, "CaloTowersTask_energy_of_ECAL_component_of_tower_HB" ) ;
00198       meEnergyEcalTower_HB = dbe_->book1D(histo, histo, 440, -200, 2000); 
00199       
00200       sprintf (histo, "CaloTowersTask_energy_of_HCAL_component_of_tower_HB" ) ;
00201       meEnergyHcalTower_HB = dbe_->book1D(histo, histo, 440 , -200 , 2000); 
00202       
00203       sprintf  (histo, "CaloTowersTask_energy_HcalPlusEcalPlusHO_HB" ) ;
00204       meTotEnergy_HB = dbe_->book1D(histo, histo,400, 0., 2000.) ;
00205       
00206       sprintf  (histo, "CaloTowersTask_map_energy_HB" );
00207       mapEnergy_HB = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00208       sprintf  (histo, "CaloTowersTask_map_energy_HCAL_HB");
00209       mapEnergyHcal_HB = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00210       sprintf  (histo, "CaloTowersTask_map_energy_ECAL_HB" );
00211       mapEnergyEcal_HB = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00212       
00213       sprintf  (histo, "CaloTowersTask_phi_MET_HB" ) ;
00214       phiMET_HB = dbe_->book1D(histo, histo, 72, -3.1415926535898, 3.1415926535898 ) ;
00215     }
00216   } 
00217   
00218   if( isub == 2 || isub == 0) {
00219     //All cell histos are used
00220     sprintf  (histo, "number_of_bad_cells_Hcal_HE");
00221     numBadCellsHcal_HE = dbe_->book1D(histo, histo, 5, 0, 5);
00222     sprintf  (histo, "number_of_recovered_cells_Hcal_HE");
00223     numRcvCellsHcal_HE = dbe_->book1D(histo, histo, 5, 0, 5);
00224     sprintf  (histo, "number_of_problematic_cells_Hcal_HE");
00225     numPrbCellsHcal_HE = dbe_->book1D(histo, histo, 5, 0, 5); 
00226 
00227     //These are the five oldest CaloTower histos used: NTowers, E in HCAL/ECAL, MET and SET
00228     //-------------------------------------------------------------------------------------------
00229     sprintf (histo, "CaloTowersTask_energy_HCAL_HE" ) ;
00230     meEnergyHcal_HE    = dbe_->book1D(histo, histo, 440, -200, 2000);  
00231     
00232     sprintf (histo, "CaloTowersTask_energy_ECAL_HE" ) ;
00233     meEnergyEcal_HE    = dbe_->book1D(histo, histo, 440, -200, 2000); 
00234     
00235     sprintf (histo, "CaloTowersTask_number_of_fired_towers_HE" ) ;
00236     meNumFiredTowers_HE = dbe_->book1D(histo, histo, 1000, 0, 2000); 
00237 
00238     sprintf  (histo, "CaloTowersTask_MET_HE" ) ;
00239     MET_HE = dbe_->book1D(histo, histo, 1000, 0. , 1000. ) ;
00240     
00241     sprintf  (histo, "CaloTowersTask_SET_HE" ) ;
00242     SET_HE = dbe_->book1D(histo, histo, 2000, 0. , 2000. ) ;
00243     //-------------------------------------------------------------------------------------------
00244 
00245     //Timing histos and profiles -- all six are necessary
00246     //-------------------------------------------------------------------------------------------
00247     sprintf  (histo, "CaloTowersTask_EM_Timing_HE" ) ;
00248     emTiming_HE = dbe_->book1D(histo, histo, 110, -120., 100. ) ;
00249 
00250     sprintf  (histo, "CaloTowersTask_HAD_Timing_HE" ) ;
00251     hadTiming_HE = dbe_->book1D(histo, histo, 70, -48., 92. ) ;
00252 
00253     //Energy-Timing histos are divided into low and normal to reduce memory usage
00254     //EM
00255     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_Low_HE" ) ;
00256     emEnergyTiming_Low_HE = dbe_->book2D(histo, histo, 160, 0. , 160., 110, -120., 100.  ) ;
00257 
00258     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_HE" ) ;
00259     emEnergyTiming_HE = dbe_->book2D(histo, histo, 200, 0. , 800., 110, -120., 100.  ) ;
00260 
00261     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_profile_Low_HE" ) ;
00262     emEnergyTiming_profile_Low_HE = dbe_->bookProfile(histo, histo, 160, 0. , 160., 110, -120., 100.  ) ;
00263 
00264     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_profile_HE" ) ;
00265     emEnergyTiming_profile_HE = dbe_->bookProfile(histo, histo, 200, 0. , 800., 110, -120., 100.  ) ;
00266 
00267     //HAD
00268     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_Low_HE" ) ;
00269     hadEnergyTiming_Low_HE = dbe_->book2D(histo, histo, 160, 0. , 160., 70, -48., 92. ) ;
00270 
00271     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_HE" ) ;
00272     hadEnergyTiming_HE = dbe_->book2D(histo, histo, 200, 0. , 800., 70, -48., 92. ) ;
00273 
00274     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_Low_HE" ) ;
00275     hadEnergyTiming_profile_Low_HE = dbe_->bookProfile(histo, histo, 160, 0. , 160., 70, -48., 92. ) ;
00276 
00277     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_HE" ) ;
00278     hadEnergyTiming_profile_HE = dbe_->bookProfile(histo, histo, 200, 0. , 800., 70, -48., 92. ) ;
00279     //-------------------------------------------------------------------------------------------
00280 
00281     //Everything else is not drawn
00282     if (useAllHistos_){
00283       sprintf (histo, "CaloTowersTask_sum_of_energy_HCAL_vs_ECAL_HE") ;
00284       meEnergyHcalvsEcal_HE    = dbe_->book2D(histo, histo, 500, 0., 500., 500, 0., 500.);
00285       
00286       sprintf (histo, "CaloTowersTask_energy_OUTER_HE" ) ;
00287       meEnergyHO_HE    = dbe_->book1D(histo, histo, 440, -200, 2000);   
00288       
00289       sprintf (histo, "CaloTowersTask_energy_of_ECAL_component_of_tower_HE" ) ;
00290       meEnergyEcalTower_HE = dbe_->book1D(histo, histo, 1100, -200, 2000); 
00291       
00292       sprintf (histo, "CaloTowersTask_energy_of_HCAL_component_of_tower_HE" ) ;
00293       meEnergyHcalTower_HE = dbe_->book1D(histo, histo, 1100 , -200 , 2000); 
00294       
00295       sprintf  (histo, "CaloTowersTask_energy_HcalPlusEcalPlusHO_HE" ) ;
00296       meTotEnergy_HE = dbe_->book1D(histo, histo,400, 0., 2000.) ;
00297       
00298       sprintf  (histo, "CaloTowersTask_map_energy_HE" );
00299       mapEnergy_HE = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00300       sprintf  (histo, "CaloTowersTask_map_energy_HCAL_HE");
00301       mapEnergyHcal_HE = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00302       sprintf  (histo, "CaloTowersTask_map_energy_ECAL_HE" );
00303       mapEnergyEcal_HE = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00304       
00305       sprintf  (histo, "CaloTowersTask_phi_MET_HE" ) ;
00306       phiMET_HE = dbe_->book1D(histo, histo, 72, -3.1415926535898, 3.1415926535898 ) ;
00307     }
00308   }
00309 
00310 
00311   if( isub == 3 || isub == 0) {
00312     //All cell histos are used
00313     sprintf  (histo, "number_of_bad_cells_Hcal_HF");
00314     numBadCellsHcal_HF = dbe_->book1D(histo, histo, 5, 0, 5);
00315     sprintf  (histo, "number_of_recovered_cells_Hcal_HF");
00316     numRcvCellsHcal_HF = dbe_->book1D(histo, histo, 5, 0, 5);
00317     sprintf  (histo, "number_of_problematic_cells_Hcal_HF");
00318     numPrbCellsHcal_HF = dbe_->book1D(histo, histo, 5, 0, 5); 
00319 
00320     //These are the five oldest CaloTower histos used: NTowers, E in HCAL/ECAL, MET and SET
00321     //-------------------------------------------------------------------------------------------
00322     sprintf (histo, "CaloTowersTask_energy_HCAL_HF" ) ;
00323     meEnergyHcal_HF    = dbe_->book1D(histo, histo, 440, -200, 2000);  
00324     
00325     sprintf (histo, "CaloTowersTask_energy_ECAL_HF" ) ;
00326     meEnergyEcal_HF    = dbe_->book1D(histo, histo, 440, -200, 2000); 
00327 
00328     sprintf (histo, "CaloTowersTask_number_of_fired_towers_HF" ) ;
00329     meNumFiredTowers_HF = dbe_->book1D(histo, histo, 1000, 0, 2000); 
00330 
00331     sprintf  (histo, "CaloTowersTask_MET_HF" ) ;
00332     MET_HF = dbe_->book1D(histo, histo, 500, 0. , 500. ) ;
00333     
00334     sprintf  (histo, "CaloTowersTask_SET_HF" ) ;
00335     SET_HF = dbe_->book1D(histo, histo, 200, 0. , 200. ) ;
00336     //-------------------------------------------------------------------------------------------
00337 
00338     //Timing histos and profiles -- all six are necessary
00339     //-------------------------------------------------------------------------------------------
00340     sprintf  (histo, "CaloTowersTask_EM_Timing_HF" ) ;
00341     emTiming_HF = dbe_->book1D(histo, histo, 110, -120., 100. ) ;
00342 
00343     sprintf  (histo, "CaloTowersTask_HAD_Timing_HF" ) ;
00344     hadTiming_HF = dbe_->book1D(histo, histo, 70, -48., 92. ) ;
00345 
00346     //EM
00347     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_HF" ) ;
00348     emEnergyTiming_HF = dbe_->book2D(histo, histo, 150, 0. , 300., 110, -120., 100.  ) ;
00349 
00350     sprintf  (histo, "CaloTowersTask_EM_Energy_Timing_profile_HF" ) ;
00351     emEnergyTiming_profile_HF = dbe_->bookProfile(histo, histo, 150, 0. , 300., 110, -120., 100.  ) ;
00352 
00353     //HAD (requires two different sets of histograms to lower RAM usage)
00354     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_Low_HF" ) ;
00355     hadEnergyTiming_Low_HF = dbe_->book2D(histo, histo, 40, 0. , 40., 70, -48., 92. ) ;
00356 
00357     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_HF" ) ;
00358     hadEnergyTiming_HF = dbe_->book2D(histo, histo, 200, 0. , 600., 70, -48., 92. ) ;
00359 
00360     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_Low_HF" ) ;
00361     hadEnergyTiming_profile_Low_HF = dbe_->bookProfile(histo, histo, 40, 0. , 40., 70, -48., 92. ) ;
00362 
00363     sprintf  (histo, "CaloTowersTask_HAD_Energy_Timing_profile_HF" ) ;
00364     hadEnergyTiming_profile_HF = dbe_->bookProfile(histo, histo, 200, 0. , 600., 70, -48., 92. ) ;
00365     //-------------------------------------------------------------------------------------------
00366 
00367     //Everything else is not drawn
00368     if (useAllHistos_){
00369       sprintf (histo, "CaloTowersTask_sum_of_energy_HCAL_vs_ECAL_HF") ;
00370       meEnergyHcalvsEcal_HF    = dbe_->book2D(histo, histo, 500, 0., 500., 500, 0., 500.);
00371       
00372       sprintf (histo, "CaloTowersTask_energy_OUTER_HF" ) ;
00373       meEnergyHO_HF    = dbe_->book1D(histo, histo, 440, -200, 2000);   
00374       
00375       sprintf (histo, "CaloTowersTask_energy_of_ECAL_component_of_tower_HF" ) ;
00376       meEnergyEcalTower_HF = dbe_->book1D(histo, histo, 440, -200, 2000); 
00377       
00378       sprintf (histo, "CaloTowersTask_energy_of_HCAL_component_of_tower_HF" ) ;
00379       meEnergyHcalTower_HF = dbe_->book1D(histo, histo, 440 , -200 , 2000); 
00380       
00381       sprintf  (histo, "CaloTowersTask_energy_HcalPlusEcalPlusHO_HF" ) ;
00382       meTotEnergy_HF = dbe_->book1D(histo, histo, 400, 0., 2000.) ;
00383       
00384       sprintf  (histo, "CaloTowersTask_map_energy_HF" );
00385       mapEnergy_HF = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00386       sprintf  (histo, "CaloTowersTask_map_energy_HCAL_HF");
00387       mapEnergyHcal_HF = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00388       sprintf  (histo, "CaloTowersTask_map_energy_ECAL_HF" );
00389       mapEnergyEcal_HF = dbe_->book2D(histo, histo, 82, -41., 41., 72, 0., 72.);
00390       
00391       sprintf  (histo, "CaloTowersTask_phi_MET_HF" ) ;
00392       phiMET_HF = dbe_->book1D(histo, histo, 72, -3.1415926535898, 3.1415926535898 ) ;
00393     }
00394   }
00395 
00396 }
00397 
00398 
00399 void CaloTowersValidation::beginRun() {}
00400 
00401 void CaloTowersValidation::endRun() {}
00402 
00403 CaloTowersValidation::~CaloTowersValidation() {
00404   
00405 }
00406 
00407 void CaloTowersValidation::endJob() {
00408 /*
00409   // mean number of towers per ieta
00410   int nx = Ntowers_vs_ieta->getNbinsX();
00411   float cont;
00412   float fev = float(nevent);
00413 
00414   for (int i = 1; i <= nx; i++) {
00415     cont = Ntowers_vs_ieta -> getBinContent(i) / fev ;
00416     Ntowers_vs_ieta -> setBinContent(i,cont);
00417   }
00418 
00419   // mean energies & occupancies evaluation
00420   
00421   nx = mapEnergy_N->getNbinsX();    
00422   int ny = mapEnergy_N->getNbinsY();
00423   float cnorm;
00424   float phi_factor;    
00425 
00426   for (int i = 1; i <= nx; i++) {
00427     float sumphi = 0.;
00428 
00429     for (int j = 1; j <= ny; j++) {      
00430       
00431       // Emean
00432       cnorm   = mapEnergy_N -> getBinContent(i,j);
00433       //Phi histos are not used in the macros
00434       if(cnorm > 0.000001 && useAllHistos_) {
00435         
00436         cont = mapEnergy_E -> getBinContent(i,j) / cnorm ;
00437         mapEnergy_E -> setBinContent(i,j,cont);       
00438         
00439         cont = mapEnergy_H -> getBinContent(i,j) / cnorm ;
00440         mapEnergy_H -> setBinContent(i,j,cont);       
00441         
00442         cont = mapEnergy_EH -> getBinContent(i,j) / cnorm ;
00443         mapEnergy_EH -> setBinContent(i,j,cont);              
00444       }
00445       
00446       // Occupancy (needed for occupancy vs ieta)
00447       cnorm   = occupancy_map -> getBinContent(i,j) / fev; 
00448       if(cnorm > 1.e-30) occupancy_map -> setBinContent(i,j,cnorm);
00449       
00450       sumphi += cnorm;
00451       
00452     } // end of iphy cycle (j)
00453     
00454     //Occupancy vs ieta histo is drawn
00455     // phi-factor evaluation for occupancy_vs_ieta calculation
00456     int ieta = i - 42;        // -41 -1, 0 40 
00457     if(ieta >=0 ) ieta +=1;   // -41 -1, 1 41  - to make it detector-like
00458     
00459     if(ieta >= -20 && ieta <= 20 )
00460       {phi_factor = 72.;}
00461       else {
00462         if(ieta >= 40 || ieta <= -40 ) {phi_factor = 18.;}
00463         else 
00464           phi_factor = 36.;
00465       }  
00466     if(ieta >= 0) ieta -= 1; // -41 -1, 0 40  - to bring back to histo num
00467     
00468     cnorm = sumphi / phi_factor;
00469     occupancy_vs_ieta->Fill(double(ieta), cnorm);
00470 
00471 
00472   } // end of ieta cycle (i)
00473 
00474   if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
00475 */
00476 }
00477 
00478 void CaloTowersValidation::beginJob(){ nevent = 0; }
00479 
00480 void CaloTowersValidation::analyze(edm::Event const& event, edm::EventSetup const& c) {
00481 
00482   nevent++;
00483 
00484   // bool     MC = false; // UNUSED
00485   double   phi_MC = 9999.;
00486   double   eta_MC = 9999.;
00487   
00488   if (imc != 0){
00489     edm::Handle<edm::HepMCProduct> evtMC;
00490     //  ev.getByLabel("VtxSmeared",evtMC);
00491     event.getByLabel("generator",evtMC);  // generator in late 310_preX
00492     if (!evtMC.isValid()) {
00493       std::cout << "no HepMCProduct found" << std::endl;    
00494     } else {
00495       // MC=true; // UNUSED
00496       //    std::cout << "*** source HepMCProduct found"<< std::endl;
00497     }  
00498 
00499     // MC particle with highest pt is taken as a direction reference  
00500     double maxPt = -99999.;
00501     int npart    = 0;
00502     const HepMC::GenEvent * myGenEvent = evtMC->GetEvent();
00503     for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
00504           p != myGenEvent->particles_end(); ++p ) {
00505       double phip = (*p)->momentum().phi();
00506       double etap = (*p)->momentum().eta();
00507       //    phi_MC = phip;
00508       //    eta_MC = etap;
00509       double pt  = (*p)->momentum().perp();
00510       if(pt > maxPt) { npart++; maxPt = pt; phi_MC = phip; eta_MC = etap; }
00511     }
00512     //  std::cout << "*** Max pT = " << maxPt <<  std::endl;  
00513   }    
00514 
00515   edm::Handle<CaloTowerCollection> towers;
00516   event.getByLabel(theCaloTowerCollectionLabel,towers);
00517   CaloTowerCollection::const_iterator cal;
00518 
00519   double met;
00520   double phimet;
00521 
00522   // ieta scan 
00523   double partR  = 0.3;
00524   double Rmin   = 9999.;
00525   double Econe  = 0.;
00526   double Hcone  = 0.;
00527   double Ee1    = 0.;
00528   double Eh1    = 0.;
00529   double ieta_MC = 9999;
00530   double iphi_MC = 9999;
00531   //  double  etaM   = 9999.;
00532 
00533 
00534   // HB   
00535   double sumEnergyHcal_HB = 0.;
00536   double sumEnergyEcal_HB = 0.;
00537   double sumEnergyHO_HB   = 0.;
00538   Int_t numFiredTowers_HB = 0;
00539   double metx_HB   =  0.;
00540   double mety_HB   =  0.;
00541   double metz_HB   =  0.;
00542   double sEt_HB    =  0.;
00543   // HE   
00544   double sumEnergyHcal_HE = 0.;
00545   double sumEnergyEcal_HE = 0.;
00546   double sumEnergyHO_HE   = 0.;
00547   Int_t numFiredTowers_HE = 0;
00548   double metx_HE   =  0.;
00549   double mety_HE   =  0.;
00550   double metz_HE   =  0.;
00551   double sEt_HE    =  0.;
00552   // HF   
00553   double sumEnergyHcal_HF = 0.;
00554   double sumEnergyEcal_HF = 0.;
00555   double sumEnergyHO_HF   = 0.;
00556   Int_t numFiredTowers_HF = 0;
00557   double metx_HF   =  0.;
00558   double mety_HF   =  0.;
00559   double metz_HF   =  0.;
00560   double sEt_HF    =  0.;
00561 
00562   for ( cal = towers->begin(); cal != towers->end(); ++cal ) {
00563     
00564     double eE     = cal->emEnergy();
00565     double eH     = cal->hadEnergy();
00566     double eHO    = cal->outerEnergy();
00567     double etaT   = cal->eta();
00568     double phiT   = cal->phi();
00569     double en     = cal->energy();
00570     double etT    = cal->et();
00571     double had_tm = cal->hcalTime();
00572     double em_tm  = cal->ecalTime();
00573 
00574     int numBadEcalCells = cal->numBadEcalCells();
00575     int numRcvEcalCells = cal->numRecoveredEcalCells();
00576     int numPrbEcalCells = cal->numProblematicEcalCells();
00577 
00578     int numBadHcalCells = cal->numBadHcalCells();
00579     int numRcvHcalCells = cal->numRecoveredHcalCells();
00580     int numPrbHcalCells = cal->numProblematicHcalCells(); 
00581 
00582     math::RhoEtaPhiVector mom(cal->et(), cal->eta(), cal->phi());
00583                               //  Vector mom  = cal->momentum(); 
00584   
00585     // cell properties    
00586     CaloTowerDetId idT = cal->id();
00587     int ieta = idT.ieta();
00588     if(ieta > 0) ieta -= 1;
00589     int iphi = idT.iphi();
00590 
00591     // ecal:  0 EcalBarrel  1 EcalEndcap
00592     // hcal:  0 hcalBarrel  1 HcalEndcap  2 HcalForward
00593     std::vector<int> inEcals(2), inHcals(3);
00594     unsigned int constitSize = cal->constituentsSize();
00595     for(unsigned int ic=0; ic<constitSize; ic++){
00596        DetId detId = cal->constituent(ic);
00597        if(detId.det() == DetId::Ecal){
00598           if( detId.subdetId()==EcalBarrel ) inEcals[0] =1;
00599           else if( detId.subdetId()==EcalEndcap ) inEcals[1] =1;
00600        }
00601        if(detId.det() == DetId::Hcal){
00602           if( HcalDetId(detId).subdet()==HcalBarrel ) inHcals[0] =1;
00603           else if( HcalDetId(detId).subdet()==HcalEndcap ) inHcals[1] =1;
00604           else if( HcalDetId(detId).subdet()==HcalForward ) inHcals[2] =1;
00605        }
00606     }
00607     //All cell histos are used
00608     if( inEcals[0] ) {
00609        numBadCellsEcal_EB->Fill(numBadEcalCells);
00610        numRcvCellsEcal_EB->Fill(numRcvEcalCells);
00611        numPrbCellsEcal_EB->Fill(numPrbEcalCells);
00612     }
00613     if( inEcals[1] ) {
00614        numBadCellsEcal_EE->Fill(numBadEcalCells);
00615        numRcvCellsEcal_EE->Fill(numRcvEcalCells);
00616        numPrbCellsEcal_EE->Fill(numPrbEcalCells);
00617     } 
00618     
00619     if (imc != 0){
00620       double r    = dR(eta_MC, phi_MC, etaT, phiT);
00621       
00622       if( r < partR ){
00623         Econe += eE; 
00624         Hcone += eH; 
00625         
00626         // closest to MC
00627         if(r < Rmin) { 
00628           if( fabs(eta_MC) < 3.0 && (ieta > 29 || ieta < -29)) {;}
00629           else {    
00630             Rmin = r;
00631             ieta_MC = ieta; 
00632             iphi_MC = iphi; 
00633             Ee1     = eE;
00634             Eh1     = eH;
00635           }
00636         }
00637       }
00638     }
00639       
00640     //Ntowers is used in EndJob, occupancy_map is used for occupancy vs ieta
00641     Ntowers_vs_ieta -> Fill(double(ieta),1.);
00642     occupancy_map -> Fill(double(ieta),double(iphi));
00643     
00644 
00645     if((isub == 0 || isub == 1) 
00646        && (fabs(etaT) <  etaMax[0] && fabs(etaT) >= etaMin[0] )) {
00647       
00648       //All cell histos are used
00649       numBadCellsHcal_HB->Fill(numBadHcalCells);
00650       numRcvCellsHcal_HB->Fill(numRcvHcalCells);
00651       numPrbCellsHcal_HB->Fill(numPrbHcalCells);
00652       
00653       //Map energy histos are not used
00654       if (useAllHistos_){
00655         mapEnergy_HB     -> Fill(double(ieta), double(iphi), en); 
00656         mapEnergyHcal_HB -> Fill(double(ieta), double(iphi), eH); 
00657         mapEnergyEcal_HB -> Fill(double(ieta), double(iphi), eE); 
00658       }
00659       //      std::cout << " e_ecal = " << eE << std::endl;
00660       
00661       //  simple sums
00662       sumEnergyHcal_HB += eH;
00663       sumEnergyEcal_HB += eE;
00664       sumEnergyHO_HB   += eHO;
00665       
00666       numFiredTowers_HB++;
00667       
00668       //Not used
00669       if (useAllHistos_){
00670         meEnergyEcalTower_HB->Fill(eE);
00671         meEnergyHcalTower_HB->Fill(eH);    
00672       }
00673       
00674       // MET, SET & phimet
00675       //  double  etT = cal->et();
00676       metx_HB += mom.x();   
00677       mety_HB += mom.y();  //etT * sin(phiT);          
00678       sEt_HB  += etT;
00679 
00680       //Timing (all histos are used)
00681       emTiming_HB->Fill(em_tm);
00682       hadTiming_HB->Fill(had_tm);
00683 
00684       emEnergyTiming_Low_HB->Fill(eE, em_tm);
00685       emEnergyTiming_HB->Fill(eE, em_tm);
00686       emEnergyTiming_High_HB->Fill(eE, em_tm);
00687       emEnergyTiming_profile_Low_HB->Fill(eE, em_tm);
00688       emEnergyTiming_profile_HB->Fill(eE, em_tm);
00689       emEnergyTiming_profile_High_HB->Fill(eE, em_tm);
00690 
00691       hadEnergyTiming_Low_HB->Fill(eH, had_tm); 
00692       hadEnergyTiming_HB->Fill(eH, had_tm); 
00693       hadEnergyTiming_High_HB->Fill(eH, had_tm); 
00694       hadEnergyTiming_profile_Low_HB->Fill(eH, had_tm);     
00695       hadEnergyTiming_profile_HB->Fill(eH, had_tm);     
00696       hadEnergyTiming_profile_High_HB->Fill(eH, had_tm);     
00697     }
00698    
00699     if((isub == 0 || isub == 2) 
00700        && (fabs(etaT) <  etaMax[1] && fabs(etaT) >= etaMin[1] )) {
00701      
00702       //All cell histos are used
00703       numBadCellsHcal_HE->Fill(numBadHcalCells);
00704       numRcvCellsHcal_HE->Fill(numRcvHcalCells);
00705       numPrbCellsHcal_HE->Fill(numPrbHcalCells);
00706     
00707       //Map energy histos are not used
00708       if (useAllHistos_){
00709         mapEnergy_HE     -> Fill(double(ieta), double(iphi), en); 
00710         mapEnergyHcal_HE -> Fill(double(ieta), double(iphi), eH); 
00711         mapEnergyEcal_HE -> Fill(double(ieta), double(iphi), eE); 
00712       }
00713       //      std::cout << " e_ecal = " << eE << std::endl;
00714       
00715       //  simple sums
00716       sumEnergyHcal_HE += eH;
00717       sumEnergyEcal_HE += eE;
00718       sumEnergyHO_HE   += eHO;
00719       
00720       numFiredTowers_HE++;
00721       
00722       //Not used
00723       if (useAllHistos_){
00724         meEnergyEcalTower_HE->Fill(eE);
00725         meEnergyHcalTower_HE->Fill(eH);    
00726       }
00727       // MET, SET & phimet
00728       //  double  etT = cal->et();
00729       metx_HE += mom.x();   
00730       mety_HE += mom.y();  //etT * sin(phiT);          
00731       sEt_HE  += etT;    
00732 
00733       //Timing (all histos are used)
00734       emTiming_HE->Fill(em_tm);
00735       hadTiming_HE->Fill(had_tm);
00736 
00737       emEnergyTiming_Low_HE->Fill(eE, em_tm);
00738       emEnergyTiming_HE->Fill(eE, em_tm);
00739       emEnergyTiming_profile_Low_HE->Fill(eE, em_tm);
00740       emEnergyTiming_profile_HE->Fill(eE, em_tm);
00741 
00742       hadEnergyTiming_Low_HE->Fill(eH, had_tm);     
00743       hadEnergyTiming_HE->Fill(eH, had_tm);   
00744       hadEnergyTiming_profile_Low_HE->Fill(eH, had_tm);     
00745       hadEnergyTiming_profile_HE->Fill(eH, had_tm);     
00746     }
00747 
00748     if((isub == 0 || isub == 3) 
00749        && (fabs(etaT) <  etaMax[2] && fabs(etaT) >= etaMin[2] )) {
00750       
00751       //All cell histos are used
00752       numBadCellsHcal_HF->Fill(numBadHcalCells);
00753       numRcvCellsHcal_HF->Fill(numRcvHcalCells);
00754       numPrbCellsHcal_HF->Fill(numPrbHcalCells);
00755      
00756       //Map energy histos are not used
00757       if (useAllHistos_){
00758         mapEnergy_HF     -> Fill(double(ieta), double(iphi), en); 
00759         mapEnergyHcal_HF -> Fill(double(ieta), double(iphi), eH); 
00760         mapEnergyEcal_HF -> Fill(double(ieta), double(iphi), eE); 
00761       }
00762       //      std::cout << " e_ecal = " << eE << std::endl;
00763       
00764       //  simple sums
00765       sumEnergyHcal_HF += eH;
00766       sumEnergyEcal_HF += eE;
00767       sumEnergyHO_HF   += eHO;
00768       
00769       numFiredTowers_HF++;
00770       
00771       //Not used
00772       if (useAllHistos_){
00773         meEnergyEcalTower_HF->Fill(eE);
00774         meEnergyHcalTower_HF->Fill(eH);    
00775       }
00776       // MET, SET & phimet
00777       //  double  etT = cal->et();
00778       metx_HF += mom.x();   
00779       mety_HF += mom.y();  //etT * sin(phiT);          
00780       sEt_HF  += etT;    
00781 
00782       //Timing (all histos are used)
00783       emTiming_HF->Fill(em_tm);
00784       hadTiming_HF->Fill(had_tm);
00785       emEnergyTiming_HF->Fill(eE, em_tm);
00786       emEnergyTiming_profile_HF->Fill(eE, em_tm);
00787 
00788       hadEnergyTiming_Low_HF->Fill(eH, had_tm);     
00789       hadEnergyTiming_HF->Fill(eH, had_tm);     
00790       hadEnergyTiming_profile_Low_HF->Fill(eH, had_tm);     
00791       hadEnergyTiming_profile_HF->Fill(eH, had_tm);     
00792     }
00793 
00794 
00795 
00796   } // end of Towers cycle 
00797 
00798   //These are the six single pion histos; only the second set is used
00799   if (useAllHistos_){
00800     emean_vs_ieta_E  -> Fill(double(ieta_MC), Econe); 
00801     emean_vs_ieta_H  -> Fill(double(ieta_MC), Hcone); 
00802     emean_vs_ieta_EH -> Fill(double(ieta_MC), Econe+Hcone); 
00803   }
00804   emean_vs_ieta_E1  -> Fill(double(ieta_MC), Ee1); 
00805   emean_vs_ieta_H1  -> Fill(double(ieta_MC), Eh1); 
00806   emean_vs_ieta_EH1 -> Fill(double(ieta_MC), Ee1+Eh1); 
00807   
00808   //Map histos are not used except the last one in EndJob
00809   if (useAllHistos_){
00810     mapEnergy_E -> Fill(double(ieta_MC), double(iphi_MC), Ee1); 
00811     mapEnergy_H -> Fill(double(ieta_MC), double(iphi_MC), Eh1); 
00812     mapEnergy_EH -> Fill(double(ieta_MC), double(iphi_MC), Ee1+Eh1);
00813   } 
00814   mapEnergy_N  -> Fill(double(ieta_MC), double(iphi_MC), 1.); 
00815 
00816 
00817   if(isub == 0 || isub == 1) {
00818     met    = sqrt(metx_HB*metx_HB + mety_HB*mety_HB);
00819     Vector metv(metx_HB,mety_HB,metz_HB);
00820     phimet = metv.phi();
00821 
00822     //Five oldest drawn histos first; the rest are not used
00823     meEnergyHcal_HB->      Fill(sumEnergyHcal_HB);
00824     meEnergyEcal_HB->      Fill(sumEnergyEcal_HB);
00825     meNumFiredTowers_HB->  Fill(numFiredTowers_HB);
00826     MET_HB    -> Fill (met); 
00827     SET_HB    -> Fill (sEt_HB); 
00828     
00829     if (useAllHistos_){
00830       meEnergyHcalvsEcal_HB->Fill(sumEnergyEcal_HB, sumEnergyHcal_HB);
00831       meEnergyHO_HB->        Fill(sumEnergyHO_HB);
00832       meTotEnergy_HB->       Fill(sumEnergyHcal_HB+sumEnergyEcal_HB
00833                                   +sumEnergyHO_HB);    
00834       phiMET_HB -> Fill (phimet);
00835     } 
00836   }    
00837 
00838 
00839   if(isub == 0 || isub == 2) {
00840     met    = sqrt(metx_HE*metx_HE + mety_HE*mety_HE);
00841     Vector metv(metx_HE,mety_HE,metz_HE);
00842     phimet = metv.phi();
00843 
00844     //Five oldest drawn histos first; the rest are not used
00845     meEnergyHcal_HE->      Fill(sumEnergyHcal_HE);
00846     meEnergyEcal_HE->      Fill(sumEnergyEcal_HE);
00847     meNumFiredTowers_HE->  Fill(numFiredTowers_HE);
00848     MET_HE    -> Fill (met); 
00849     SET_HE    -> Fill (sEt_HE); 
00850     
00851     if (useAllHistos_){
00852       meEnergyHcalvsEcal_HE->Fill(sumEnergyEcal_HE, sumEnergyHcal_HE);
00853       meEnergyHO_HE->        Fill(sumEnergyHO_HE);
00854       meTotEnergy_HE->       Fill(sumEnergyHcal_HE+sumEnergyEcal_HE
00855                                   +sumEnergyHO_HE);    
00856       phiMET_HE -> Fill (phimet); 
00857     }
00858   }
00859 
00860   if(isub == 0 || isub == 3) {
00861     met    = sqrt(metx_HF*metx_HF + mety_HF*mety_HF);
00862     Vector metv(metx_HF,mety_HF,metz_HF);
00863     phimet = metv.phi();
00864     
00865     //Five oldest drawn histos first; the rest are not used
00866     meEnergyHcal_HF->      Fill(sumEnergyHcal_HF);
00867     meEnergyEcal_HF->      Fill(sumEnergyEcal_HF);
00868     meNumFiredTowers_HF->  Fill(numFiredTowers_HF);
00869     MET_HF    -> Fill (met); 
00870     SET_HF    -> Fill (sEt_HF); 
00871 
00872     if (useAllHistos_){
00873       meEnergyHcalvsEcal_HF->Fill(sumEnergyEcal_HF, sumEnergyHcal_HF);
00874       meEnergyHO_HF->        Fill(sumEnergyHO_HF);
00875       meTotEnergy_HF->       Fill(sumEnergyHcal_HF+sumEnergyEcal_HF
00876                                   +sumEnergyHO_HF);    
00877       phiMET_HF -> Fill (phimet);
00878     }
00879   }
00880 
00881 }
00882 
00883 double CaloTowersValidation::dR(double eta1, double phi1, double eta2, double phi2) { 
00884   double PI = 3.1415926535898;
00885   double deltaphi= phi1 - phi2;
00886   if( phi2 > phi1 ) { deltaphi= phi2 - phi1;}
00887   if(deltaphi > PI) { deltaphi = 2.*PI - deltaphi;}
00888   double deltaeta = eta2 - eta1;
00889   double tmp = sqrt(deltaeta* deltaeta + deltaphi*deltaphi);
00890   return tmp;
00891 }
00892 
00893 DEFINE_FWK_MODULE(CaloTowersValidation);
00894