CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DQMOffline/JetMET/src/CaloMETAnalyzer.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2012/05/20 13:12:05 $
00005  *  $Revision: 1.72 $
00006  *  \author F. Chlebana - Fermilab
00007  *          K. Hatakeyama - Rockefeller University
00008  */
00009 
00010 #include "DQMOffline/JetMET/interface/CaloMETAnalyzer.h"
00011 #include "DataFormats/Common/interface/Handle.h"
00012 
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 #include "FWCore/Common/interface/TriggerNames.h"
00015 
00016 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00017 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00018 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00019 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00020 
00021 #include "DataFormats/Math/interface/LorentzVector.h"
00022 
00023 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00024 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00026 
00027 #include "TLorentzVector.h"
00028 
00029 #include <string>
00030 using namespace edm;
00031 
00032 // ***********************************************************
00033 CaloMETAnalyzer::CaloMETAnalyzer(const edm::ParameterSet& pSet) {
00034 
00035   parameters = pSet;
00036 
00037   edm::ParameterSet highptjetparms = parameters.getParameter<edm::ParameterSet>("highPtJetTrigger");
00038   edm::ParameterSet lowptjetparms  = parameters.getParameter<edm::ParameterSet>("lowPtJetTrigger" );
00039   edm::ParameterSet minbiasparms   = parameters.getParameter<edm::ParameterSet>("minBiasTrigger"  );
00040   edm::ParameterSet highmetparms   = parameters.getParameter<edm::ParameterSet>("highMETTrigger"  );
00041   //  edm::ParameterSet lowmetparms    = parameters.getParameter<edm::ParameterSet>("lowMETTrigger"   );
00042   edm::ParameterSet eleparms       = parameters.getParameter<edm::ParameterSet>("eleTrigger"      );
00043   edm::ParameterSet muonparms      = parameters.getParameter<edm::ParameterSet>("muonTrigger"     );
00044 
00045   //genericTriggerEventFlag_( new GenericTriggerEventFlag( conf_ ) );
00046   _HighPtJetEventFlag = new GenericTriggerEventFlag( highptjetparms );
00047   _LowPtJetEventFlag  = new GenericTriggerEventFlag( lowptjetparms  );
00048   _MinBiasEventFlag   = new GenericTriggerEventFlag( minbiasparms   );
00049   _HighMETEventFlag   = new GenericTriggerEventFlag( highmetparms   );
00050   //  _LowMETEventFlag    = new GenericTriggerEventFlag( lowmetparms    );
00051   _EleEventFlag       = new GenericTriggerEventFlag( eleparms       );
00052   _MuonEventFlag      = new GenericTriggerEventFlag( muonparms      );
00053 
00054   highPtJetExpr_ = highptjetparms.getParameter<std::vector<std::string> >("hltPaths");
00055   lowPtJetExpr_  = lowptjetparms .getParameter<std::vector<std::string> >("hltPaths");
00056   highMETExpr_   = highmetparms  .getParameter<std::vector<std::string> >("hltPaths");
00057   //  lowMETExpr_    = lowmetparms   .getParameter<std::vector<std::string> >("hltPaths");
00058   muonExpr_      = muonparms     .getParameter<std::vector<std::string> >("hltPaths");
00059   elecExpr_      = eleparms      .getParameter<std::vector<std::string> >("hltPaths");
00060   minbiasExpr_   = minbiasparms  .getParameter<std::vector<std::string> >("hltPaths");
00061 
00062 }
00063 
00064 // ***********************************************************
00065 CaloMETAnalyzer::~CaloMETAnalyzer() { 
00066 
00067   delete _HighPtJetEventFlag;
00068   delete _LowPtJetEventFlag;
00069   delete _MinBiasEventFlag;
00070   delete _HighMETEventFlag;
00071   //  delete _LowMETEventFlag;
00072   delete _EleEventFlag;
00073   delete _MuonEventFlag;
00074 
00075 }
00076 
00077 // ***********************************************************
00078 void CaloMETAnalyzer::beginJob(DQMStore * dbe) {
00079 
00080   evtCounter = 0;
00081   metname = "caloMETAnalyzer";
00082 
00083   // trigger information
00084   HLTPathsJetMBByName_ = parameters.getParameter<std::vector<std::string > >("HLTPathsJetMB");
00085 
00086   theCleaningParameters = parameters.getParameter<ParameterSet>("CleaningParameters"),
00087 
00088   //Trigger parameters
00089   gtTag          = theCleaningParameters.getParameter<edm::InputTag>("gtLabel");
00090   _techTrigsAND  = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsAND");
00091   _techTrigsOR   = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsOR");
00092   _techTrigsNOT  = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsNOT");
00093 
00094   _doHLTPhysicsOn = theCleaningParameters.getParameter<bool>("doHLTPhysicsOn");
00095   _hlt_PhysDec    = theCleaningParameters.getParameter<std::string>("HLT_PhysDec");
00096 
00097   _tightBHFiltering     = theCleaningParameters.getParameter<bool>("tightBHFiltering");
00098   _tightJetIDFiltering  = theCleaningParameters.getParameter<int>("tightJetIDFiltering");
00099 
00100   // ==========================================================
00101   //DCS information
00102   // ==========================================================
00103   DCSFilter = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilter"));
00104 
00105   //Vertex requirements
00106   _doPVCheck          = theCleaningParameters.getParameter<bool>("doPrimaryVertexCheck");
00107   vertexTag  = theCleaningParameters.getParameter<edm::InputTag>("vertexLabel");
00108 
00109   if (_doPVCheck) {
00110     _nvtx_min        = theCleaningParameters.getParameter<int>("nvtx_min");
00111     _nvtxtrks_min    = theCleaningParameters.getParameter<int>("nvtxtrks_min");
00112     _vtxndof_min     = theCleaningParameters.getParameter<int>("vtxndof_min");
00113     _vtxchi2_max     = theCleaningParameters.getParameter<double>("vtxchi2_max");
00114     _vtxz_max        = theCleaningParameters.getParameter<double>("vtxz_max");
00115   }
00116 
00117 
00118   // CaloMET information
00119   theCaloMETCollectionLabel       = parameters.getParameter<edm::InputTag>("METCollectionLabel");
00120   _source                         = parameters.getParameter<std::string>("Source");
00121 
00122   if (theCaloMETCollectionLabel.label() == "corMetGlobalMuons" ) {
00123     inputBeamSpotLabel      = parameters.getParameter<edm::InputTag>("InputBeamSpotLabel");
00124   }
00125   
00126   // Other data collections
00127   theCaloTowersLabel          = parameters.getParameter<edm::InputTag>("CaloTowersLabel");
00128   theJetCollectionLabel       = parameters.getParameter<edm::InputTag>("JetCollectionLabel");
00129   HcalNoiseRBXCollectionTag   = parameters.getParameter<edm::InputTag>("HcalNoiseRBXCollection");
00130   BeamHaloSummaryTag          = parameters.getParameter<edm::InputTag>("BeamHaloSummaryLabel");
00131   HBHENoiseFilterResultTag    = parameters.getParameter<edm::InputTag>("HBHENoiseFilterResultLabel");
00132 
00133   // misc
00134   _verbose     = parameters.getParameter<int>("verbose");
00135   _print       = parameters.getParameter<int>("printOut");
00136   _etThreshold = parameters.getParameter<double>("etThreshold"); // MET threshold
00137   _allhist     = parameters.getParameter<bool>("allHist");       // Full set of monitoring histograms
00138   _allSelection= parameters.getParameter<bool>("allSelection");  // Plot with all sets of event selection
00139   _cleanupSelection= parameters.getParameter<bool>("cleanupSelection");  // Plot with all sets of event selection
00140 
00141   _highPtJetThreshold = parameters.getParameter<double>("HighPtJetThreshold"); // High Pt Jet threshold
00142   _lowPtJetThreshold = parameters.getParameter<double>("LowPtJetThreshold"); // Low Pt Jet threshold
00143   _highMETThreshold = parameters.getParameter<double>("HighMETThreshold"); // High MET threshold
00144   //  _lowMETThreshold = parameters.getParameter<double>("LowMETThreshold"); // Low MET threshold
00145 
00146   //
00147   jetID = new reco::helper::JetIDHelper(parameters.getParameter<ParameterSet>("JetIDParams"));
00148 
00149   // DQStore stuff
00150   LogTrace(metname)<<"[CaloMETAnalyzer] Parameters initialization";
00151   std::string DirName = "JetMET/MET/"+_source;
00152   dbe->setCurrentFolder(DirName);
00153 
00154   hmetME = dbe->book1D("metReco", "metReco", 4, 1, 5);
00155   hmetME->setBinLabel(1,"CaloMET",1);
00156 
00157   _dbe = dbe;
00158 
00159   _FolderNames.push_back("All");
00160   _FolderNames.push_back("BasicCleanup");
00161   _FolderNames.push_back("ExtraCleanup");
00162   _FolderNames.push_back("HcalNoiseFilter");
00163   _FolderNames.push_back("JetIDMinimal");
00164   _FolderNames.push_back("JetIDLoose");
00165   _FolderNames.push_back("JetIDTight");
00166   _FolderNames.push_back("BeamHaloIDTightPass");
00167   _FolderNames.push_back("BeamHaloIDLoosePass");
00168   _FolderNames.push_back("Triggers");
00169   _FolderNames.push_back("PV");
00170 
00171   for (std::vector<std::string>::const_iterator ic = _FolderNames.begin(); 
00172        ic != _FolderNames.end(); ic++){
00173     if (*ic=="All")             bookMESet(DirName+"/"+*ic);
00174     if (_cleanupSelection){
00175     if (*ic=="BasicCleanup")    bookMESet(DirName+"/"+*ic);
00176     if (*ic=="ExtraCleanup")    bookMESet(DirName+"/"+*ic);
00177     }
00178     if (_allSelection){
00179     if (*ic=="HcalNoiseFilter")      bookMESet(DirName+"/"+*ic);
00180     if (*ic=="JetIDMinimal")         bookMESet(DirName+"/"+*ic);
00181     if (*ic=="JetIDLoose")           bookMESet(DirName+"/"+*ic);
00182     if (*ic=="JetIDTight")           bookMESet(DirName+"/"+*ic);
00183     if (*ic=="BeamHaloIDTightPass")  bookMESet(DirName+"/"+*ic);
00184     if (*ic=="BeamHaloIDLoosePass")  bookMESet(DirName+"/"+*ic);
00185     if (*ic=="Triggers")             bookMESet(DirName+"/"+*ic);
00186     if (*ic=="PV")                   bookMESet(DirName+"/"+*ic);
00187     }
00188   }
00189 }
00190 
00191 
00192 // ***********************************************************
00193 void CaloMETAnalyzer::endJob() {
00194 
00195   delete jetID;
00196   delete DCSFilter;
00197 
00198 }
00199 
00200 
00201 // ***********************************************************
00202 void CaloMETAnalyzer::bookMESet(std::string DirName)
00203 {
00204   bool bLumiSecPlot=false;
00205   if (DirName.find("All")!=std::string::npos) bLumiSecPlot=true;
00206 
00207   bookMonitorElement(DirName,bLumiSecPlot);
00208 
00209   if ( _HighPtJetEventFlag->on() ) {
00210     bookMonitorElementTriggered(DirName+"/"+"HighPtJet",false);
00211     hTriggerName_HighPtJet = _dbe->bookString("triggerName_HighPtJet", highPtJetExpr_[0]);
00212   }  
00213 
00214   if ( _LowPtJetEventFlag->on() ) {
00215     bookMonitorElementTriggered(DirName+"/"+"LowPtJet",false);
00216     hTriggerName_LowPtJet = _dbe->bookString("triggerName_LowPtJet", lowPtJetExpr_[0]);
00217   }
00218 
00219   if ( _MinBiasEventFlag->on() ) {
00220     bookMonitorElementTriggered(DirName+"/"+"MinBias",false);
00221     hTriggerName_MinBias = _dbe->bookString("triggerName_MinBias", minbiasExpr_[0]);
00222     if (_verbose) std::cout << "_MinBiasEventFlag is on, folder created\n";
00223   }
00224 
00225   if ( _HighMETEventFlag->on() ) {
00226     bookMonitorElementTriggered(DirName+"/"+"HighMET",false);
00227     hTriggerName_HighMET = _dbe->bookString("triggerName_HighMET", highMETExpr_[0]);
00228   }
00229 
00230   //  if ( _LowMETEventFlag->on() ) {
00231   //    bookMonitorElementTriggered(DirName+"/"+"LowMET",false);
00232   //    hTriggerName_LowMET = _dbe->bookString("triggerName_LowMET", lowMETExpr_[0]);
00233   //  }
00234 
00235   if ( _EleEventFlag->on() ) {
00236     bookMonitorElementTriggered(DirName+"/"+"Ele",false);
00237     hTriggerName_Ele = _dbe->bookString("triggerName_Ele", elecExpr_[0]);
00238     if (_verbose) std::cout << "_EleEventFlag is on, folder created\n";
00239   }
00240 
00241   if ( _MuonEventFlag->on() ) {
00242     bookMonitorElementTriggered(DirName+"/"+"Muon",false);
00243     hTriggerName_Muon = _dbe->bookString("triggerName_Muon", muonExpr_[0]);
00244     if (_verbose) std::cout << "_MuonEventFlag is on, folder created\n";
00245   }
00246 }  
00247 
00248 // ***********************************************************
00249 void CaloMETAnalyzer::bookMonitorElement(std::string DirName, bool bLumiSecPlot=false)
00250 {
00251   if (_verbose) std::cout << "bookMonitorElement " << DirName << std::endl;
00252 
00253   _dbe->setCurrentFolder(DirName);
00254 
00255   bookMonitorElementTriggered(DirName, bLumiSecPlot);
00256 
00257 
00258   if (_allhist) {
00259 
00260     hCaloMaxEtInEmTowers    = _dbe->book1D("METTask_CaloMaxEtInEmTowers",   "METTask_CaloMaxEtInEmTowers"   ,100,0,2000);
00261     hCaloMaxEtInEmTowers->setAxisTitle("Et(Max) in EM Tower [GeV]",1);
00262     hCaloMaxEtInHadTowers   = _dbe->book1D("METTask_CaloMaxEtInHadTowers",  "METTask_CaloMaxEtInHadTowers"  ,100,0,2000);
00263     hCaloMaxEtInHadTowers->setAxisTitle("Et(Max) in Had Tower [GeV]",1);
00264 
00265     hCaloHadEtInHB          = _dbe->book1D("METTask_CaloHadEtInHB","METTask_CaloHadEtInHB",100,0,2000);
00266     hCaloHadEtInHB->setAxisTitle("Had Et [GeV]",1);
00267     hCaloHadEtInHO          = _dbe->book1D("METTask_CaloHadEtInHO","METTask_CaloHadEtInHO",25,0,500);
00268     hCaloHadEtInHO->setAxisTitle("Had Et [GeV]",1);
00269     hCaloHadEtInHE          = _dbe->book1D("METTask_CaloHadEtInHE","METTask_CaloHadEtInHE",100,0,2000);
00270     hCaloHadEtInHE->setAxisTitle("Had Et [GeV]",1);
00271     hCaloHadEtInHF          = _dbe->book1D("METTask_CaloHadEtInHF","METTask_CaloHadEtInHF",50,0,1000);
00272     hCaloHadEtInHF->setAxisTitle("Had Et [GeV]",1);
00273     hCaloEmEtInHF           = _dbe->book1D("METTask_CaloEmEtInHF" ,"METTask_CaloEmEtInHF" ,25,0,500);
00274     hCaloEmEtInHF->setAxisTitle("EM Et [GeV]",1);
00275     hCaloEmEtInEE           = _dbe->book1D("METTask_CaloEmEtInEE" ,"METTask_CaloEmEtInEE" ,50,0,1000);
00276     hCaloEmEtInEE->setAxisTitle("EM Et [GeV]",1);
00277     hCaloEmEtInEB           = _dbe->book1D("METTask_CaloEmEtInEB" ,"METTask_CaloEmEtInEB" ,100,0,2000);
00278     hCaloEmEtInEB->setAxisTitle("EM Et [GeV]",1);
00279 
00280     hCaloEmMEx= _dbe->book1D("METTask_CaloEmMEx","METTask_CaloEmMEx",200,-500,500);
00281     hCaloEmMEx->setAxisTitle("EM MEx [GeV]",1);
00282     hCaloEmMEy= _dbe->book1D("METTask_CaloEmMEy","METTask_CaloEmMEy",200,-500,500);
00283     hCaloEmMEy->setAxisTitle("EM MEy [GeV]",1);
00284     hCaloEmMET= _dbe->book1D("METTask_CaloEmMET","METTask_CaloEmMET",200,0,1000);
00285     hCaloEmMET->setAxisTitle("EM MET [GeV]",1);
00286     hCaloEmMETPhi= _dbe->book1D("METTask_CaloEmMETPhi","METTask_CaloEmMETPhi", 60, -3.2, 3.2);
00287     hCaloEmMETPhi->setAxisTitle("EM METPhi [rad]",1);
00288 
00289     hCaloHaMEx= _dbe->book1D("METTask_CaloHaMEx","METTask_CaloHaMEx",200,-500,500);
00290     hCaloHaMEx->setAxisTitle("HA MEx [GeV]",1);
00291     hCaloHaMEy= _dbe->book1D("METTask_CaloHaMEy","METTask_CaloHaMEy",200,-500,500);
00292     hCaloHaMEy->setAxisTitle("HA MEy [GeV]",1);
00293     hCaloHaMET= _dbe->book1D("METTask_CaloHaMET","METTask_CaloHaMET",200,0,1000); 
00294     hCaloHaMET->setAxisTitle("HA MET [GeV]",1);
00295     hCaloHaMETPhi= _dbe->book1D("METTask_CaloHaMETPhi","METTask_CaloHaMETPhi", 60, -3.2, 3.2);
00296     hCaloHaMETPhi->setAxisTitle("HA METPhi [rad]",1);
00297   }
00298 }
00299 
00300 
00301 // ***********************************************************
00302 void CaloMETAnalyzer::bookMonitorElementTriggered(std::string DirName, bool bLumiSecPlot=false)
00303 {
00304   if (_verbose) std::cout << "bookMonitorElementTriggered " << DirName << std::endl;
00305 
00306   _dbe->setCurrentFolder(DirName);
00307 
00308 
00309   hCaloMEx        = _dbe->book1D("METTask_CaloMEx",        "METTask_CaloMEx",        200, -500,  500);
00310   hCaloMEy        = _dbe->book1D("METTask_CaloMEy",        "METTask_CaloMEy",        200, -500,  500); 
00311   hCaloMET        = _dbe->book1D("METTask_CaloMET",        "METTask_CaloMET",        200,    0, 1000); 
00312   hCaloMET1       = _dbe->book1D("METTask_CaloMET1",       "METTask_CaloMET1",        80,    0,  200);
00313   hCaloMETNoHF    = _dbe->book1D("METTask_CaloMETNoHF",    "METTask_CaloMETNoHF",    200,    0, 1000); 
00314   hCaloSumET      = _dbe->book1D("METTask_CaloSumET",      "METTask_CaloSumET",      400,    0, 4000); 
00315   hCaloMETSig     = _dbe->book1D("METTask_CaloMETSig",     "METTask_CaloMETSig",      51,    0,   51);
00316   hCaloMETPhi     = _dbe->book1D("METTask_CaloMETPhi",     "METTask_CaloMETPhi",      60, -3.2,  3.2); 
00317   hCaloMETPhi020  = _dbe->book1D("METTask_CaloMETPhi020",  "METTask_CaloMETPhi020",   60, -3.2,  3.2);
00318   hCaloMET_logx   = _dbe->book1D("METTask_CaloMET_logx",   "METTask_CaloMET_logx",    40,   -1,    7);
00319   hCaloSumET_logx = _dbe->book1D("METTask_CaloSumET_logx", "METTask_CaloSumET_logx",  40,   -1,    7);
00320 
00321   hCaloMEx       ->setAxisTitle("MEx [GeV]",                 1);
00322   hCaloMEy       ->setAxisTitle("MEy [GeV]",                 1);
00323   hCaloMET       ->setAxisTitle("MET [GeV]",                 1);
00324   hCaloMET1      ->setAxisTitle("MET [GeV]",                 1);
00325   hCaloMETNoHF   ->setAxisTitle("MET (No HF) [GeV]",         1);
00326   hCaloSumET     ->setAxisTitle("SumET [GeV]",               1);
00327   hCaloMETSig    ->setAxisTitle("METSig",                    1);
00328   hCaloMETPhi    ->setAxisTitle("METPhi [rad]",              1);
00329   hCaloMETPhi020 ->setAxisTitle("METPhi [rad] (MET>20 GeV)", 1);
00330   hCaloMET_logx  ->setAxisTitle("log(MET) [GeV]",            1);
00331   hCaloSumET_logx->setAxisTitle("log(SumET) [GeV]",          1);
00332 
00333 
00334   // Book NPV profiles
00335   //----------------------------------------------------------------------------
00336   hCaloMEx_profile     = _dbe->bookProfile("METTask_CaloMEx_profile",     "MEx [GeV]",     nbinsPV, PVlow, PVup, 200, -500,  500);
00337   hCaloMEy_profile     = _dbe->bookProfile("METTask_CaloMEy_profile",     "MEy [GeV]",     nbinsPV, PVlow, PVup, 200, -500,  500); 
00338   hCaloMET_profile     = _dbe->bookProfile("METTask_CaloMET_profile",     "MET [GeV]",     nbinsPV, PVlow, PVup, 200,    0, 1000); 
00339   hCaloMETNoHF_profile = _dbe->bookProfile("METTask_CaloMETNoHF_profile", "METNoHF [GeV]", nbinsPV, PVlow, PVup, 200,    0, 1000); 
00340   hCaloSumET_profile   = _dbe->bookProfile("METTask_CaloSumET_profile",   "SumET [GeV]",   nbinsPV, PVlow, PVup, 400,    0, 4000); 
00341 
00342 
00343   // Set NPV profiles x-axis title
00344   //----------------------------------------------------------------------------
00345   hCaloMEx_profile    ->setAxisTitle("nvtx", 1);
00346   hCaloMEy_profile    ->setAxisTitle("nvtx", 1);
00347   hCaloMET_profile    ->setAxisTitle("nvtx", 1);
00348   hCaloMETNoHF_profile->setAxisTitle("nvtx", 1);
00349   hCaloSumET_profile  ->setAxisTitle("nvtx", 1);
00350 
00351 
00352   if (_allhist){
00353     if (bLumiSecPlot){
00354       hCaloMExLS              = _dbe->book2D("METTask_CaloMEx_LS","METTask_CaloMEx_LS",200,-200,200,50,0.,500.);
00355       hCaloMExLS->setAxisTitle("MEx [GeV]",1);
00356       hCaloMExLS->setAxisTitle("Lumi Section",2);
00357       hCaloMEyLS              = _dbe->book2D("METTask_CaloMEy_LS","METTask_CaloMEy_LS",200,-200,200,50,0.,500.);
00358       hCaloMEyLS->setAxisTitle("MEy [GeV]",1);
00359       hCaloMEyLS->setAxisTitle("Lumi Section",2);
00360     }
00361 
00362     //hCaloMaxEtInEmTowers    = _dbe->book1D("METTask_CaloMaxEtInEmTowers",   "METTask_CaloMaxEtInEmTowers"   ,100,0,2000);
00363     //hCaloMaxEtInEmTowers->setAxisTitle("Et(Max) in EM Tower [GeV]",1);
00364     //hCaloMaxEtInHadTowers   = _dbe->book1D("METTask_CaloMaxEtInHadTowers",  "METTask_CaloMaxEtInHadTowers"  ,100,0,2000);
00365     //hCaloMaxEtInHadTowers->setAxisTitle("Et(Max) in Had Tower [GeV]",1);
00366     hCaloEtFractionHadronic = _dbe->book1D("METTask_CaloEtFractionHadronic","METTask_CaloEtFractionHadronic",100,0,1);
00367     hCaloEtFractionHadronic->setAxisTitle("Hadronic Et Fraction",1);
00368     hCaloEmEtFraction       = _dbe->book1D("METTask_CaloEmEtFraction",      "METTask_CaloEmEtFraction"      ,100,0,1);
00369     hCaloEmEtFraction->setAxisTitle("EM Et Fraction",1);
00370 
00371     //hCaloEmEtFraction002    = _dbe->book1D("METTask_CaloEmEtFraction002",   "METTask_CaloEmEtFraction002"      ,100,0,1);
00372     //hCaloEmEtFraction002->setAxisTitle("EM Et Fraction (MET>2 GeV)",1);
00373     //hCaloEmEtFraction010    = _dbe->book1D("METTask_CaloEmEtFraction010",   "METTask_CaloEmEtFraction010"      ,100,0,1);
00374     //hCaloEmEtFraction010->setAxisTitle("EM Et Fraction (MET>10 GeV)",1);
00375     hCaloEmEtFraction020    = _dbe->book1D("METTask_CaloEmEtFraction020",   "METTask_CaloEmEtFraction020"      ,100,0,1);
00376     hCaloEmEtFraction020->setAxisTitle("EM Et Fraction (MET>20 GeV)",1);
00377   }
00378   
00379   if (theCaloMETCollectionLabel.label() == "corMetGlobalMuons" ) {
00380     hCalomuPt    = _dbe->book1D("METTask_CalomuonPt", "METTask_CalomuonPt", 50, 0, 500);
00381     hCalomuEta   = _dbe->book1D("METTask_CalomuonEta", "METTask_CalomuonEta", 60, -3.0, 3.0);
00382     hCalomuNhits = _dbe->book1D("METTask_CalomuonNhits", "METTask_CalomuonNhits", 50, 0, 50);
00383     hCalomuChi2  = _dbe->book1D("METTask_CalomuonNormalizedChi2", "METTask_CalomuonNormalizedChi2", 20, 0, 20);
00384     hCalomuD0    = _dbe->book1D("METTask_CalomuonD0", "METTask_CalomuonD0", 50, -1, 1);
00385     hCaloMExCorrection       = _dbe->book1D("METTask_CaloMExCorrection", "METTask_CaloMExCorrection", 100, -500.0,500.0);
00386     hCaloMEyCorrection       = _dbe->book1D("METTask_CaloMEyCorrection", "METTask_CaloMEyCorrection", 100, -500.0,500.0);
00387     hCaloMuonCorrectionFlag  = _dbe->book1D("METTask_CaloCorrectionFlag","METTask_CaloCorrectionFlag", 5, -0.5, 4.5);
00388   }
00389 
00390 }
00391 
00392 // ***********************************************************
00393 void CaloMETAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
00394 {
00395   if ( _HighPtJetEventFlag->on() ) _HighPtJetEventFlag->initRun( iRun, iSetup );
00396   if ( _LowPtJetEventFlag ->on() ) _LowPtJetEventFlag ->initRun( iRun, iSetup );
00397   if ( _MinBiasEventFlag  ->on() ) _MinBiasEventFlag  ->initRun( iRun, iSetup );
00398   if ( _HighMETEventFlag  ->on() ) _HighMETEventFlag  ->initRun( iRun, iSetup );
00399   //  if ( _LowMETEventFlag   ->on() ) _LowMETEventFlag   ->initRun( iRun, iSetup );
00400   if ( _EleEventFlag      ->on() ) _EleEventFlag      ->initRun( iRun, iSetup );
00401   if ( _MuonEventFlag     ->on() ) _MuonEventFlag     ->initRun( iRun, iSetup );
00402 
00403   if (_HighPtJetEventFlag->on() && _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00404     highPtJetExpr_ = _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup);
00405   if (_LowPtJetEventFlag->on() && _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00406     lowPtJetExpr_  = _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(),   iSetup);
00407   if (_HighMETEventFlag->on() && _HighMETEventFlag->expressionsFromDB(_HighMETEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00408     highMETExpr_   = _HighMETEventFlag->expressionsFromDB(_HighMETEventFlag->hltDBKey(),     iSetup);
00409   //  if (_LowMETEventFlag->on() && _LowMETEventFlag->expressionsFromDB(_LowMETEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00410   //    lowMETExpr_    = _LowMETEventFlag->expressionsFromDB(_LowMETEventFlag->hltDBKey(),       iSetup);
00411   if (_MuonEventFlag->on() && _MuonEventFlag->expressionsFromDB(_MuonEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00412     muonExpr_      = _MuonEventFlag->expressionsFromDB(_MuonEventFlag->hltDBKey(),           iSetup);
00413   if (_EleEventFlag->on() && _EleEventFlag->expressionsFromDB(_EleEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00414     elecExpr_      = _EleEventFlag->expressionsFromDB(_EleEventFlag->hltDBKey(),             iSetup);
00415   if (_MinBiasEventFlag->on() && _MinBiasEventFlag->expressionsFromDB(_MinBiasEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
00416     minbiasExpr_   = _MinBiasEventFlag->expressionsFromDB(_MinBiasEventFlag->hltDBKey(),     iSetup);
00417 
00418 }
00419 
00420 
00421 // ***********************************************************
00422 void CaloMETAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup, DQMStore * dbe)
00423 {
00424   
00425   //
00426   //--- Check the time length of the Run from the lumi section plots
00427 
00428   std::string dirName = "JetMET/MET/"+_source+"/";
00429   _dbe->setCurrentFolder(dirName);
00430 
00431   TH1F* tlumisec;
00432 
00433   MonitorElement *meLumiSec = _dbe->get("aaa");
00434   meLumiSec = _dbe->get("JetMET/lumisec");
00435 
00436   int totlsec=0;
00437   double totltime=0.;
00438   if ( meLumiSec->getRootObject() ) {
00439     tlumisec = meLumiSec->getTH1F();
00440     for (int i=0; i<500; i++){
00441       if (tlumisec->GetBinContent(i+1)) totlsec++;
00442     }
00443     totltime = double(totlsec*90); // one lumi sec ~ 90 (sec)
00444   }
00445 
00446   if (totltime==0.) totltime=1.; 
00447 
00448   //
00449   //--- Make the integrated plots with rate (Hz)
00450 
00451   for (std::vector<std::string>::const_iterator ic = _FolderNames.begin(); ic != _FolderNames.end(); ic++)
00452     {
00453 
00454       std::string DirName;
00455       DirName = dirName+*ic;
00456 
00457       makeRatePlot(DirName,totltime);
00458       if ( _HighPtJetEventFlag->on() ) 
00459         makeRatePlot(DirName+"/"+"triggerName_HighJetPt",totltime);
00460       if ( _LowPtJetEventFlag->on() ) 
00461         makeRatePlot(DirName+"/"+"triggerName_LowJetPt",totltime);
00462       if ( _MinBiasEventFlag->on() ) 
00463         makeRatePlot(DirName+"/"+"triggerName_MinBias",totltime);
00464       if ( _HighMETEventFlag->on() ) 
00465         makeRatePlot(DirName+"/"+"triggerName_HighMET",totltime);
00466       //      if ( _LowMETEventFlag->on() ) 
00467       //        makeRatePlot(DirName+"/"+"triggerName_LowMET",totltime);
00468       if ( _EleEventFlag->on() ) 
00469         makeRatePlot(DirName+"/"+"triggerName_Ele",totltime);
00470       if ( _MuonEventFlag->on() ) 
00471         makeRatePlot(DirName+"/"+"triggerName_Muon",totltime);
00472     }
00473 }
00474 
00475 
00476 // ***********************************************************
00477 void CaloMETAnalyzer::makeRatePlot(std::string DirName, double totltime)
00478 {
00479 
00480   _dbe->setCurrentFolder(DirName);
00481   MonitorElement *meCaloMET = _dbe->get(DirName+"/"+"METTask_CaloMET");
00482 
00483   TH1F* tCaloMET;
00484   TH1F* tCaloMETRate;
00485 
00486   if ( meCaloMET )
00487     if ( meCaloMET->getRootObject() ) {
00488       tCaloMET     = meCaloMET->getTH1F();
00489       
00490       // Integral plot & convert number of events to rate (hz)
00491       tCaloMETRate = (TH1F*) tCaloMET->Clone("METTask_CaloMETRate");
00492       for (int i = tCaloMETRate->GetNbinsX()-1; i>=0; i--){
00493         tCaloMETRate->SetBinContent(i+1,tCaloMETRate->GetBinContent(i+2)+tCaloMET->GetBinContent(i+1));
00494       }
00495       for (int i = 0; i<tCaloMETRate->GetNbinsX(); i++){
00496         tCaloMETRate->SetBinContent(i+1,tCaloMETRate->GetBinContent(i+1)/double(totltime));
00497       }      
00498 
00499       tCaloMETRate->SetName("METTask_CaloMETRate");
00500       tCaloMETRate->SetTitle("METTask_CaloMETRate");
00501       hCaloMETRate = _dbe->book1D("METTask_CaloMETRate",tCaloMETRate);
00502       hCaloMETRate->setAxisTitle("MET Threshold [GeV]",1);
00503     }
00504 }
00505 
00506 
00507 // ***********************************************************
00508 void CaloMETAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup, 
00509                               const edm::TriggerResults& triggerResults) {
00510 
00511   if (_verbose) std::cout << "CaloMETAnalyzer analyze" << std::endl;
00512 
00513   std::string DirName = "JetMET/MET/"+_source;
00514   if (_print){
00515   std::cout << " " << std::endl;
00516   std::cout << "Event = " << iEvent.id().event() << std::endl;
00517   }
00518 
00519   LogTrace(metname)<<"[CaloMETAnalyzer] Analyze CaloMET";
00520 
00521   hmetME->Fill(1);
00522 
00523   // ==========================================================  
00524   // Trigger information 
00525   //
00526   _trig_JetMB=0;
00527   _trig_HighPtJet=0;
00528   _trig_LowPtJet=0;
00529   _trig_MinBias=0;
00530   _trig_HighMET=0;
00531   //  _trig_LowMET=0;
00532   _trig_Ele=0;
00533   _trig_Muon=0;
00534   _trig_PhysDec=0;
00535   if(&triggerResults) {   
00536     
00538     
00539     //
00540     //
00541     // Check how many HLT triggers are in triggerResults 
00542     int ntrigs = triggerResults.size();
00543     if (_verbose) std::cout << "ntrigs=" << ntrigs << std::endl;
00544     
00545     //
00546     //
00547     // If index=ntrigs, this HLT trigger doesn't exist in the HLT table for this data.
00548     const edm::TriggerNames & triggerNames = iEvent.triggerNames(triggerResults);
00549 
00550     //
00551     //
00552     const unsigned int nTrig(triggerNames.size());
00553     for (unsigned int i=0;i<nTrig;++i)
00554       {
00555         if (triggerNames.triggerName(i).find(highPtJetExpr_[0].substr(0,highPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00556           _trig_HighPtJet=true;
00557         else if (triggerNames.triggerName(i).find(lowPtJetExpr_[0].substr(0,lowPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00558           _trig_LowPtJet=true;
00559         else if (triggerNames.triggerName(i).find(highMETExpr_[0].substr(0,highMETExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00560           _trig_HighMET=true;
00561         //        else if (triggerNames.triggerName(i).find(lowMETExpr_[0].substr(0,lowMETExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00562         //        _trig_LowMET=true;
00563         else if (triggerNames.triggerName(i).find(muonExpr_[0].substr(0,muonExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00564           _trig_Muon=true;
00565         else if (triggerNames.triggerName(i).find(elecExpr_[0].substr(0,elecExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00566           _trig_Ele=true;
00567         else if (triggerNames.triggerName(i).find(minbiasExpr_[0].substr(0,minbiasExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults.accept(i))
00568           _trig_MinBias=true;
00569       }
00570 
00571     // count number of requested Jet or MB HLT paths which have fired
00572     for (unsigned int i=0; i!=HLTPathsJetMBByName_.size(); i++) {
00573       unsigned int triggerIndex = triggerNames.triggerIndex(HLTPathsJetMBByName_[i]);
00574       if (triggerIndex<triggerResults.size()) {
00575         if (triggerResults.accept(triggerIndex)) {
00576           _trig_JetMB++;
00577         }
00578       }
00579     }
00580     // for empty input vectors (n==0), take all HLT triggers!
00581     if (HLTPathsJetMBByName_.size()==0) _trig_JetMB=triggerResults.size()-1;
00582 
00583     /*
00584       if ( _HighPtJetEventFlag->on() && _HighPtJetEventFlag->accept( iEvent, iSetup) )
00585       _trig_HighPtJet=1;
00586       
00587       if ( _LowPtJetEventFlag->on() && _LowPtJetEventFlag->accept( iEvent, iSetup) )
00588       _trig_LowPtJet=1;
00589       
00590       if ( _MinBiasEventFlag->on() && _MinBiasEventFlag->accept( iEvent, iSetup) )
00591       _trig_MinBias=1;
00592       
00593       if ( _HighMETEventFlag->on() && _HighMETEventFlag->accept( iEvent, iSetup) )
00594       _trig_HighMET=1;
00595       
00596       if ( _LowMETEventFlag->on() && _LowMETEventFlag->accept( iEvent, iSetup) )
00597       _trig_LowMET=1;
00598       
00599       if ( _EleEventFlag->on() && _EleEventFlag->accept( iEvent, iSetup) )
00600       _trig_Ele=1;
00601       
00602       if ( _MuonEventFlag->on() && _MuonEventFlag->accept( iEvent, iSetup) )
00603       _trig_Muon=1;
00604     */
00605       
00606     if (triggerNames.triggerIndex(_hlt_PhysDec)   != triggerNames.size() &&
00607         triggerResults.accept(triggerNames.triggerIndex(_hlt_PhysDec)))   _trig_PhysDec=1;
00608   } else {
00609 
00610     edm::LogInfo("CaloMetAnalyzer") << "TriggerResults::HLT not found, "
00611         "automatically select events"; 
00612     //
00613     // TriggerResults object not found. Look at all events.    
00614     _trig_JetMB=1;
00615     
00616   }
00617   
00618   // ==========================================================  
00619   // CaloMET information
00620 
00621   // **** Get the MET container  
00622   edm::Handle<reco::CaloMETCollection> calometcoll;
00623   iEvent.getByLabel(theCaloMETCollectionLabel, calometcoll);
00624 
00625   if(!calometcoll.isValid()) {
00626     std::cout<<"Unable to find MET results for CaloMET collection "<<theCaloMETCollectionLabel<<std::endl;
00627     return;
00628   }
00629 
00630   const reco::CaloMETCollection *calometcol = calometcoll.product();
00631   const reco::CaloMET *calomet;
00632   calomet = &(calometcol->front());
00633   
00634   LogTrace(metname)<<"[CaloMETAnalyzer] Call to the CaloMET analyzer";
00635 
00636   // **** Get the MET no HF container  
00637   edm::Handle<reco::CaloMETCollection> calometnohfcoll;
00638   iEvent.getByLabel("metNoHF", calometnohfcoll);
00639 
00640   if(!calometnohfcoll.isValid()) {
00641     std::cout<<"Unable to find MET results for CaloMETNoHF collection metNoHF"<<std::endl;
00642     return;
00643   }
00644 
00645   const reco::CaloMETCollection *calometnohfcol = calometnohfcoll.product();
00646   const reco::CaloMET *calometnohf;
00647   calometnohf = &(calometnohfcol->front());
00648   
00649   //LogTrace(metname)<<"[CaloMETAnalyzer] Call to the CaloMET analyzer";
00650 
00651   //Only for corMetGlobalMuons
00652   if (theCaloMETCollectionLabel.label() == "corMetGlobalMuons" ) {
00653     
00654     iEvent.getByLabel("muonMETValueMapProducer" , "muCorrData", corMetGlobalMuons_ValueMap_Handle);
00655     iEvent.getByLabel("muons", muon_h);
00656     iEvent.getByLabel(inputBeamSpotLabel, beamSpot_h);
00657     
00658     if(!beamSpot_h.isValid()) edm::LogInfo("OutputInfo") << "falied to retrieve beam spot data require by MET Task";
00659     
00660     bspot = ( beamSpot_h.isValid() ) ? beamSpot_h->position() : math::XYZPoint(0, 0, 0);
00661     
00662   }
00663 
00664 
00665   // ==========================================================
00666   //
00667   edm::Handle<reco::HcalNoiseRBXCollection> HRBXCollection;
00668   iEvent.getByLabel(HcalNoiseRBXCollectionTag,HRBXCollection);
00669   if (!HRBXCollection.isValid()) {
00670       LogDebug("") << "CaloMETAnalyzer: Could not find HcalNoiseRBX Collection" << std::endl;
00671       if (_verbose) std::cout << "CaloMETAnalyzer: Could not find HcalNoiseRBX Collection" << std::endl;
00672   }
00673   
00674 
00675   edm::Handle<bool> HBHENoiseFilterResultHandle;
00676   iEvent.getByLabel(HBHENoiseFilterResultTag, HBHENoiseFilterResultHandle);
00677   bool HBHENoiseFilterResult = *HBHENoiseFilterResultHandle;
00678   if (!HBHENoiseFilterResultHandle.isValid()) {
00679     LogDebug("") << "CaloMETAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
00680     if (_verbose) std::cout << "CaloMETAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
00681   }
00682 
00683 
00684   edm::Handle<reco::CaloJetCollection> caloJets;
00685   iEvent.getByLabel(theJetCollectionLabel, caloJets);
00686   if (!caloJets.isValid()) {
00687     LogDebug("") << "CaloMETAnalyzer: Could not find jet product" << std::endl;
00688     if (_verbose) std::cout << "CaloMETAnalyzer: Could not find jet product" << std::endl;
00689   }
00690 
00691   edm::Handle<edm::View<reco::Candidate> > towers;
00692   iEvent.getByLabel(theCaloTowersLabel, towers);
00693   if (!towers.isValid()) {
00694     LogDebug("") << "CaloMETAnalyzer: Could not find caltower product" << std::endl;
00695     if (_verbose) std::cout << "CaloMETAnalyzer: Could not find caltower product" << std::endl;
00696   }
00697  
00698   // ==========================================================
00699   // CaloMET sanity check
00700 
00701   if (_source=="CaloMET") validateMET(*calomet,towers);
00702 
00703   // ==========================================================
00704 
00705   if (_allhist) computeEmHaMET(towers);
00706     
00707   // ==========================================================
00708   // JetID 
00709 
00710   if (_verbose) std::cout << "JetID starts" << std::endl;
00711   
00712   //
00713   // --- Minimal cuts
00714   //
00715   bool bJetIDMinimal=true;
00716   int nj=0;
00717   for (reco::CaloJetCollection::const_iterator cal = caloJets->begin(); 
00718        cal!=caloJets->end(); ++cal){
00719     jetID->calculate(iEvent, *cal);
00720     if (_print && nj<=1) std::cout << "Jet pT = " << cal->pt() << " (GeV) "
00721                                    << " eta = " << cal->eta() << " "
00722                                    << " phi = " << cal->phi() << " "
00723                                    << " emf = " << cal->emEnergyFraction() << std::endl;
00724     nj++;
00725     if (cal->pt()>10.){
00726       if (fabs(cal->eta())<=2.6 && 
00727           cal->emEnergyFraction()<=0.01) bJetIDMinimal=false;
00728     }
00729   }
00730 
00731   //
00732   // --- Loose cuts
00733   //
00734   bool bJetIDLoose=true;
00735   for (reco::CaloJetCollection::const_iterator cal = caloJets->begin(); 
00736        cal!=caloJets->end(); ++cal){
00737     jetID->calculate(iEvent, *cal);
00738     if (_verbose) std::cout << jetID->n90Hits() << " " 
00739                             << jetID->restrictedEMF() << " "
00740                             << cal->pt() << std::endl;
00741     if (cal->pt()>10.){
00742       //
00743       // for all regions
00744       if (jetID->n90Hits()<2)  bJetIDLoose=false; 
00745       if (jetID->fHPD()>=0.98) bJetIDLoose=false; 
00746       //
00747       // for non-forward
00748       if (fabs(cal->eta())<2.55){
00749         if (cal->emEnergyFraction()<=0.01) bJetIDLoose=false; 
00750       }
00751       // for forward
00752       else {
00753         if (cal->emEnergyFraction()<=-0.9) bJetIDLoose=false; 
00754         if (cal->pt()>80.){
00755         if (cal->emEnergyFraction()>= 1.0) bJetIDLoose=false; 
00756         }
00757       } // forward vs non-forward
00758     }   // pt>10 GeV/c
00759   }     // calor-jets loop
00760 
00761   //
00762   // --- Tight cuts
00763   //
00764   bool bJetIDTight=true;
00765   bJetIDTight=bJetIDLoose;
00766   for (reco::CaloJetCollection::const_iterator cal = caloJets->begin(); 
00767        cal!=caloJets->end(); ++cal){
00768     jetID->calculate(iEvent, *cal);
00769     if (cal->pt()>25.){
00770       //
00771       // for all regions
00772       if (jetID->fHPD()>=0.95) bJetIDTight=false; 
00773       //
00774       // for 1.0<|eta|<1.75
00775       if (fabs(cal->eta())>=1.00 && fabs(cal->eta())<1.75){
00776         if (cal->pt()>80. && cal->emEnergyFraction()>=1.) bJetIDTight=false; 
00777       }
00778       //
00779       // for 1.75<|eta|<2.55
00780       else if (fabs(cal->eta())>=1.75 && fabs(cal->eta())<2.55){
00781         if (cal->pt()>80. && cal->emEnergyFraction()>=1.) bJetIDTight=false; 
00782       }
00783       //
00784       // for 2.55<|eta|<3.25
00785       else if (fabs(cal->eta())>=2.55 && fabs(cal->eta())<3.25){
00786         if (cal->pt()< 50.                   && cal->emEnergyFraction()<=-0.3) bJetIDTight=false; 
00787         if (cal->pt()>=50. && cal->pt()< 80. && cal->emEnergyFraction()<=-0.2) bJetIDTight=false; 
00788         if (cal->pt()>=80. && cal->pt()<340. && cal->emEnergyFraction()<=-0.1) bJetIDTight=false; 
00789         if (cal->pt()>=340.                  && cal->emEnergyFraction()<=-0.1 
00790                                              && cal->emEnergyFraction()>=0.95) bJetIDTight=false; 
00791       }
00792       //
00793       // for 3.25<|eta|
00794       else if (fabs(cal->eta())>=3.25){
00795         if (cal->pt()< 50.                   && cal->emEnergyFraction()<=-0.3
00796                                              && cal->emEnergyFraction()>=0.90) bJetIDTight=false; 
00797         if (cal->pt()>=50. && cal->pt()<130. && cal->emEnergyFraction()<=-0.2
00798                                              && cal->emEnergyFraction()>=0.80) bJetIDTight=false; 
00799         if (cal->pt()>=130.                  && cal->emEnergyFraction()<=-0.1 
00800                                              && cal->emEnergyFraction()>=0.70) bJetIDTight=false; 
00801       }
00802     }   // pt>10 GeV/c
00803   }     // calor-jets loop
00804   
00805   if (_verbose) std::cout << "JetID ends" << std::endl;
00806      
00807   // ==========================================================
00808   // HCAL Noise filter
00809   
00810   bool bHcalNoiseFilter = HBHENoiseFilterResult;
00811 
00812   // ==========================================================
00813   // Get BeamHaloSummary
00814   edm::Handle<reco::BeamHaloSummary> TheBeamHaloSummary ;
00815   iEvent.getByLabel(BeamHaloSummaryTag, TheBeamHaloSummary) ;
00816 
00817   bool bBeamHaloIDTightPass = true;
00818   bool bBeamHaloIDLoosePass = true;
00819   
00820   if(TheBeamHaloSummary.isValid()) {
00821     
00822     const reco::BeamHaloSummary TheSummary = (*TheBeamHaloSummary.product() );
00823     
00824     //   std::cout << TheSummary.EcalLooseHaloId() << " "
00825     //      << TheSummary.HcalLooseHaloId() << " "
00826     //      << TheSummary.CSCLooseHaloId()  << " "
00827     //      << TheSummary.GlobalLooseHaloId() << std::endl;
00828     
00829     if( TheSummary.EcalLooseHaloId()  || TheSummary.HcalLooseHaloId() || 
00830         TheSummary.CSCLooseHaloId()   || TheSummary.GlobalLooseHaloId() )
00831       bBeamHaloIDLoosePass = false;
00832     
00833     if( TheSummary.EcalTightHaloId()  || TheSummary.HcalTightHaloId() || 
00834         TheSummary.CSCTightHaloId()   || TheSummary.GlobalTightHaloId() )
00835       bBeamHaloIDTightPass = false;
00836     
00837   }
00838   
00839   if (_verbose) std::cout << "BeamHaloSummary ends" << std::endl;
00840   
00841   // ==========================================================
00842   //Vertex information
00843 
00844   _numPV = 0;
00845   bool bPrimaryVertex = true;
00846   if(_doPVCheck){
00847     bPrimaryVertex = false;
00848     Handle<reco::VertexCollection> vertexHandle;
00849 
00850     iEvent.getByLabel(vertexTag, vertexHandle);
00851 
00852     if (!vertexHandle.isValid()) {
00853       LogDebug("") << "CaloMETAnalyzer: Could not find vertex collection" << std::endl;
00854       if (_verbose) std::cout << "CaloMETAnalyzer: Could not find vertex collection" << std::endl;
00855     }
00856     
00857     if ( vertexHandle.isValid() ){
00858       reco::VertexCollection vertexCollection = *(vertexHandle.product());
00859       int vertex_number     = vertexCollection.size();
00860       reco::VertexCollection::const_iterator v = vertexCollection.begin();
00861       for ( ; v != vertexCollection.end(); ++v) {
00862         double vertex_chi2    = v->normalizedChi2();
00863         double vertex_ndof    = v->ndof();
00864         bool   fakeVtx        = v->isFake();
00865         double vertex_Z       = v->z();
00866         
00867         if (  !fakeVtx
00868               && vertex_number>=_nvtx_min
00869               && vertex_ndof   >_vtxndof_min
00870               && vertex_chi2   <_vtxchi2_max
00871               && fabs(vertex_Z)<_vtxz_max ) {
00872           bPrimaryVertex = true;
00873           ++_numPV;
00874         }
00875       }
00876     }
00877   }
00878   // ==========================================================
00879 
00880   edm::Handle< L1GlobalTriggerReadoutRecord > gtReadoutRecord;
00881   iEvent.getByLabel( gtTag, gtReadoutRecord);
00882 
00883   if (!gtReadoutRecord.isValid()) {
00884     LogDebug("") << "CaloMETAnalyzer: Could not find GT readout record" << std::endl;
00885     if (_verbose) std::cout << "CaloMETAnalyzer: Could not find GT readout record product" << std::endl;
00886   }
00887   
00888   bool bTechTriggers    = true;
00889   bool bTechTriggersAND = true;
00890   bool bTechTriggersOR  = false;
00891   bool bTechTriggersNOT = false;
00892 
00893   if (gtReadoutRecord.isValid()) {
00894     const TechnicalTriggerWord&  technicalTriggerWordBeforeMask = gtReadoutRecord->technicalTriggerWord();
00895 
00896     if (_techTrigsAND.size() == 0)
00897       bTechTriggersAND = true;
00898     else
00899       for (unsigned ttr = 0; ttr != _techTrigsAND.size(); ttr++) {
00900         bTechTriggersAND = bTechTriggersAND && technicalTriggerWordBeforeMask.at(_techTrigsAND.at(ttr));
00901       }
00902     
00903     if (_techTrigsAND.size() == 0)
00904       bTechTriggersOR = true;
00905     else
00906       for (unsigned ttr = 0; ttr != _techTrigsOR.size(); ttr++) {
00907         bTechTriggersOR = bTechTriggersOR || technicalTriggerWordBeforeMask.at(_techTrigsOR.at(ttr));
00908       }
00909     if (_techTrigsNOT.size() == 0)
00910       bTechTriggersNOT = false;
00911     else
00912       for (unsigned ttr = 0; ttr != _techTrigsNOT.size(); ttr++) {
00913         bTechTriggersNOT = bTechTriggersNOT || technicalTriggerWordBeforeMask.at(_techTrigsNOT.at(ttr));
00914       }
00915   }
00916   else
00917     {
00918       bTechTriggersAND = true;
00919       bTechTriggersOR  = true;
00920       bTechTriggersNOT = false;
00921     }
00922     
00923   if (_techTrigsAND.size()==0)
00924     bTechTriggersAND = true;
00925   if (_techTrigsOR.size()==0)
00926     bTechTriggersOR = true;
00927   if (_techTrigsNOT.size()==0)
00928     bTechTriggersNOT = false;
00929   
00930   bTechTriggers = bTechTriggersAND && bTechTriggersOR && !bTechTriggersNOT;
00931     
00932   // ==========================================================
00933   // Reconstructed MET Information - fill MonitorElements
00934   
00935   bool bHcalNoise  = bHcalNoiseFilter;
00936   bool bBeamHaloID = bBeamHaloIDLoosePass;
00937   bool bJetID      = bJetIDMinimal;
00938 
00939   bool bPhysicsDeclared = true;
00940   if(_doHLTPhysicsOn) bPhysicsDeclared =_trig_PhysDec;
00941 
00942   if      (_tightBHFiltering)       bBeamHaloID = bBeamHaloIDTightPass;
00943 
00944   if      (_tightJetIDFiltering==1)  bJetID      = bJetIDMinimal;
00945   else if (_tightJetIDFiltering==2)  bJetID      = bJetIDLoose;
00946   else if (_tightJetIDFiltering==3)  bJetID      = bJetIDTight;
00947   else if (_tightJetIDFiltering==-1) bJetID      = true;
00948 
00949   bool bBasicCleanup = bTechTriggers && bPrimaryVertex && bPhysicsDeclared;
00950   bool bExtraCleanup = bBasicCleanup && bHcalNoise && bJetID && bBeamHaloID;
00951 
00952   //std::string DirName = "JetMET/MET/"+_source;
00953   
00954   for (std::vector<std::string>::const_iterator ic = _FolderNames.begin(); 
00955        ic != _FolderNames.end(); ic++){
00956     if (*ic=="All")                                             fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00957     if (DCSFilter->filter(iEvent, iSetup)) {
00958       if (_cleanupSelection){
00959         if (*ic=="BasicCleanup"   && bBasicCleanup)                 fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00960         if (*ic=="ExtraCleanup"   && bExtraCleanup)                 fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00961       }
00962       if (_allSelection) {
00963         if (*ic=="HcalNoiseFilter"      && bHcalNoiseFilter )       fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00964         if (*ic=="JetIDMinimal"         && bJetIDMinimal)           fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00965         if (*ic=="JetIDLoose"           && bJetIDLoose)             fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00966         if (*ic=="JetIDTight"           && bJetIDTight)             fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00967         if (*ic=="BeamHaloIDTightPass"  && bBeamHaloIDTightPass)    fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00968         if (*ic=="BeamHaloIDLoosePass"  && bBeamHaloIDLoosePass)    fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00969         if (*ic=="Triggers"             && bTechTriggers)           fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00970         if (*ic=="PV"                   && bPrimaryVertex)          fillMESet(iEvent, DirName+"/"+*ic, *calomet, *calometnohf);
00971       }
00972     } // DCS
00973   }
00974 } // CaloMETAnalyzer::analyze
00975 
00976 // ***********************************************************
00977 void CaloMETAnalyzer::computeEmHaMET(edm::Handle<edm::View<reco::Candidate> > towers)
00978 {
00979 
00980   edm::View<reco::Candidate>::const_iterator towerCand = towers->begin();
00981   
00982   double sum_em_et = 0.0;
00983   double sum_em_ex = 0.0;
00984   double sum_em_ey = 0.0;
00985   double sum_em_ez = 0.0;
00986   
00987   double sum_ha_et = 0.0;
00988   double sum_ha_ex = 0.0;
00989   double sum_ha_ey = 0.0;
00990   double sum_ha_ez = 0.0;
00991   
00992   for ( ; towerCand != towers->end(); towerCand++)
00993     {
00994       const reco::Candidate* candidate = &(*towerCand);
00995       if (candidate)
00996         {
00997           const CaloTower* calotower = dynamic_cast<const CaloTower*> (candidate);
00998           if (calotower){
00999             double Tower_ET = calotower->et();
01000             if (Tower_ET>0.3) {
01001               
01002               double phi   = candidate->phi();
01003               double theta = candidate->theta();
01004               //double e     = candidate->energy();
01005               double e_em  = calotower->emEnergy();
01006               double e_ha  = calotower->hadEnergy();
01007               double et_em = e_em*sin(theta);
01008               double et_ha = e_ha*sin(theta);
01009 
01010               sum_em_ez += e_em*cos(theta);
01011               sum_em_et += et_em;
01012               sum_em_ex += et_em*cos(phi);
01013               sum_em_ey += et_em*sin(phi);
01014 
01015               sum_ha_ez += e_ha*cos(theta);
01016               sum_ha_et += et_ha;
01017               sum_ha_ex += et_ha*cos(phi);
01018               sum_ha_ey += et_ha*sin(phi);
01019 
01020             } // Et>0.5
01021           }   // calotower
01022         }     // candidate
01023     }         // loop
01024   
01025   //
01026   _EmMEx = -sum_em_ex;
01027   _EmMEy = -sum_em_ey;
01028   _EmMET = pow(_EmMEx*_EmMEx+_EmMEy*_EmMEy,0.5);
01029   _EmCaloEz = sum_em_ez;
01030   _EmSumEt  = sum_em_et;
01031   _EmMetPhi   = atan2( _EmMEy, _EmMEx ); 
01032   //
01033   _HaMEx = -sum_ha_ex;
01034   _HaMEy = -sum_ha_ey;
01035   _HaMET = pow(_HaMEx*_HaMEx+_HaMEy*_HaMEy,0.5);
01036   _HaCaloEz = sum_ha_ez;
01037   _HaSumEt  = sum_ha_et;
01038   _HaMetPhi   = atan2( _HaMEy, _HaMEx ); 
01039   
01040 }
01041 // ***********************************************************
01042 void CaloMETAnalyzer::validateMET(const reco::CaloMET& calomet, 
01043                                   edm::Handle<edm::View<reco::Candidate> > towers)
01044 {
01045 
01046   edm::View<reco::Candidate>::const_iterator towerCand = towers->begin();
01047   
01048   double sum_et = 0.0;
01049   double sum_ex = 0.0;
01050   double sum_ey = 0.0;
01051   double sum_ez = 0.0;
01052   
01053   for ( ; towerCand != towers->end(); towerCand++)
01054     {
01055       const reco::Candidate* candidate = &(*towerCand);
01056       if (candidate)
01057         {
01058           const CaloTower* calotower = dynamic_cast<const CaloTower*> (candidate);
01059           if (calotower){
01060             double Tower_ET = calotower->et();
01061             if (Tower_ET>0.3) {
01062               
01063               double phi   = candidate->phi();
01064               double theta = candidate->theta();
01065               double e     = candidate->energy();
01066               double et    = e*sin(theta);
01067               sum_ez += e*cos(theta);
01068               sum_et += et;
01069               sum_ex += et*cos(phi);
01070               sum_ey += et*sin(phi);
01071 
01072             } // Et>0.5
01073           }   // calotower
01074         }     // candidate
01075     }         // loop
01076   
01077   double Mex   = -sum_ex;
01078   double Mey   = -sum_ey;
01079   //double Mez   = -sum_ez;
01080   double Met   = sqrt( sum_ex*sum_ex + sum_ey*sum_ey );
01081   double Sumet = sum_et;
01082   //double MetPhi   = atan2( -sum_ey, -sum_ex ); // since MET is now a candidate,
01083   
01084   if (_verbose){
01085     if (Sumet!=calomet.sumEt() || Mex!=calomet.px() || Mey!=calomet.py() || Met!=calomet.pt() ){
01086       std::cout << _source << std::endl;
01087       std::cout << "SUMET" << Sumet << " METBlock" << calomet.sumEt() << std::endl;
01088       std::cout << "MEX"   << Mex   << " METBlock" << calomet.px()    << std::endl;
01089       std::cout << "MEY"   << Mey   << " METBlock" << calomet.py()    << std::endl;
01090       std::cout << "MET"   << Met   << " METBlock" << calomet.pt()    << std::endl;
01091     }
01092   }  
01093 
01094   if (_print){
01095     std::cout << "SUMET = " << calomet.sumEt() << " (GeV) "
01096               << "MEX"   << calomet.px() << " (GeV) "
01097               << "MEY"   << calomet.py() << " (GeV) " 
01098               << "MET"   << calomet.pt() << " (GeV) " << std::endl;
01099   }
01100 
01101 }
01102 
01103 // ***********************************************************
01104 void CaloMETAnalyzer::fillMESet(const edm::Event& iEvent, std::string DirName, 
01105                                 const reco::CaloMET& calomet,
01106                                 const reco::CaloMET& calometnohf)
01107 {
01108 
01109   _dbe->setCurrentFolder(DirName);
01110 
01111   bool bLumiSecPlot=false;
01112   if (DirName.find("All")) bLumiSecPlot=true;
01113 
01114   if (_trig_JetMB)
01115     fillMonitorElement(iEvent,DirName,"",calomet,calometnohf, bLumiSecPlot);
01116   if (_trig_HighPtJet)
01117     fillMonitorElementTriggered(iEvent,DirName,"HighPtJet",calomet,calometnohf,false);
01118   if (_trig_LowPtJet)
01119     fillMonitorElementTriggered(iEvent,DirName,"LowPtJet",calomet,calometnohf,false);
01120   if (_trig_MinBias)
01121     fillMonitorElementTriggered(iEvent,DirName,"MinBias",calomet,calometnohf,false);
01122   if (_trig_HighMET)
01123     fillMonitorElementTriggered(iEvent,DirName,"HighMET",calomet,calometnohf,false);
01124   //  if (_trig_LowMET)
01125   //    fillMonitorElementTriggered(iEvent,DirName,"LowMET",calomet,calometnohf,false);
01126   if (_trig_Ele)
01127     fillMonitorElementTriggered(iEvent,DirName,"Ele",calomet,calometnohf,false);
01128   if (_trig_Muon) {
01129     fillMonitorElementTriggered(iEvent,DirName,"Muon",calomet,calometnohf,false);
01130   }
01131 }
01132 
01133 // ***********************************************************
01134 void CaloMETAnalyzer::fillMonitorElement(const edm::Event& iEvent, std::string DirName, 
01135                                          std::string TriggerTypeName, 
01136                                          const reco::CaloMET& calomet,
01137                                          const reco::CaloMET& calometnohf,
01138                                          bool bLumiSecPlot)
01139 {
01140   fillMonitorElementTriggered(iEvent, DirName, TriggerTypeName, calomet, calometnohf, bLumiSecPlot);
01141 
01142   double caloSumET = calomet.sumEt();
01143 
01144   /*
01145   double caloMETSig = calomet.mEtSig();
01146   //double caloEz     = calomet.e_longitudinal();
01147   double caloMET    = calomet.pt();
01148   double caloMEx    = calomet.px();
01149   double caloMEy    = calomet.py();
01150   double caloMETPhi = calomet.phi();
01151 
01152   double caloMETNoHF    = calometnohf.pt();
01153   //double caloMETNoHFPhi = calometnohf.phi();
01154 
01155   if (_verbose) std::cout << _source << " " << caloMET << std::endl;
01156 
01157   double caloEtFractionHadronic = calomet.etFractionHadronic();
01158   double caloEmEtFraction       = calomet.emEtFraction();
01159   */
01160   double caloMaxEtInEMTowers    = calomet.maxEtInEmTowers();
01161   double caloMaxEtInHadTowers   = calomet.maxEtInHadTowers();
01162 
01163   double caloHadEtInHB = calomet.hadEtInHB();
01164   double caloHadEtInHO = calomet.hadEtInHO();
01165   double caloHadEtInHE = calomet.hadEtInHE();
01166   double caloHadEtInHF = calomet.hadEtInHF();
01167   double caloEmEtInEB  = calomet.emEtInEB();
01168   double caloEmEtInEE  = calomet.emEtInEE();
01169   double caloEmEtInHF  = calomet.emEtInHF();
01170   //
01171   //  int myLuminosityBlock;
01172   //  myLuminosityBlock = (evtCounter++)/1000;
01173   //  myLuminosityBlock = iEvent.luminosityBlock();
01174   //
01175 
01176   if (TriggerTypeName!="") DirName = DirName +"/"+TriggerTypeName;
01177 
01178   if (_verbose) std::cout << "_etThreshold = " << _etThreshold << std::endl;
01179   if (caloSumET>_etThreshold){
01180   /*
01181     hCaloMEx    = _dbe->get(DirName+"/"+"METTask_CaloMEx");    if (hCaloMEx     && hCaloMEx->getRootObject() )    hCaloMEx->Fill(caloMEx);
01182     hCaloMEy    = _dbe->get(DirName+"/"+"METTask_CaloMEy");    if (hCaloMEy     && hCaloMEy->getRootObject() )    hCaloMEy->Fill(caloMEy);
01183     hCaloMET    = _dbe->get(DirName+"/"+"METTask_CaloMET");    if (hCaloMET     && hCaloMET->getRootObject() )    hCaloMET->Fill(caloMET);
01184     hCaloMET1   = _dbe->get(DirName+"/"+"METTask_CaloMET1");   if (hCaloMET1    && hCaloMET1->getRootObject() )   hCaloMET1->Fill(caloMET);
01185     hCaloMETPhi = _dbe->get(DirName+"/"+"METTask_CaloMETPhi"); if (hCaloMETPhi  && hCaloMETPhi->getRootObject() ) hCaloMETPhi->Fill(caloMETPhi);
01186     hCaloSumET  = _dbe->get(DirName+"/"+"METTask_CaloSumET");  if (hCaloSumET   && hCaloSumET->getRootObject() )  hCaloSumET->Fill(caloSumET);
01187     hCaloMETSig = _dbe->get(DirName+"/"+"METTask_CaloMETSig"); if (hCaloMETSig  && hCaloMETSig->getRootObject() ) hCaloMETSig->Fill(caloMETSig);
01188     //hCaloEz     = _dbe->get(DirName+"/"+"METTask_CaloEz");     if (hCaloEz      && hCaloEz->getRootObject() )     hCaloEz->Fill(caloEz);
01189     
01190     hCaloMETNoHF    = _dbe->get(DirName+"/"+"METTask_CaloMETNoHF");    if (hCaloMETNoHF     && hCaloMETNoHF->getRootObject() )    hCaloMETNoHF->Fill(caloMETNoHF);
01191     
01192     hCaloMET_logx   = _dbe->get(DirName+"/"+"METTask_CaloMET_logx");      if (hCaloMET_logx    && hCaloMET_logx->getRootObject() )   hCaloMET_logx->Fill(log10(caloMET));
01193     hCaloSumET_logx = _dbe->get(DirName+"/"+"METTask_CaloSumET_logx");    if (hCaloSumET_logx  && hCaloSumET_logx->getRootObject() ) hCaloSumET_logx->Fill(log10(caloSumET));
01194     
01195     //  hCaloMETIonFeedbck = _dbe->get(DirName+"/"+"METTask_CaloMETIonFeedbck"); if (hCaloMETIonFeedbck  && hCaloMETIonFeedbck->getRootObject() ) hCaloMETIonFeedbck->Fill(caloMET);
01196     //  hCaloMETHPDNoise   = _dbe->get(DirName+"/"+"METTask_CaloMETHPDNoise");   if (hCaloMETHPDNoise    && hCaloMETHPDNoise->getRootObject() )   hCaloMETHPDNoise->Fill(caloMET);
01197 
01198     //hCaloMETPhi002 = _dbe->get(DirName+"/"+"METTask_CaloMETPhi002");    if (caloMET>  2. && hCaloMETPhi002  &&  hCaloMETPhi002->getRootObject()) { hCaloMETPhi002->Fill(caloMETPhi);}
01199     //hCaloMETPhi010 = _dbe->get(DirName+"/"+"METTask_CaloMETPhi010");    if (caloMET> 10. && hCaloMETPhi010  &&  hCaloMETPhi010->getRootObject()) { hCaloMETPhi010->Fill(caloMETPhi);}
01200     hCaloMETPhi020 = _dbe->get(DirName+"/"+"METTask_CaloMETPhi020");    if (caloMET> 20. && hCaloMETPhi020  &&  hCaloMETPhi020->getRootObject()) { hCaloMETPhi020->Fill(caloMETPhi);}
01201   */
01202   
01203     if (_allhist){
01204       /*
01205       if (bLumiSecPlot){
01206         hCaloMExLS = _dbe->get(DirName+"/"+"METTask_CaloMEx_LS");   if (hCaloMExLS  &&  hCaloMExLS->getRootObject())    hCaloMExLS->Fill(caloMEx,myLuminosityBlock);
01207         hCaloMEyLS = _dbe->get(DirName+"/"+"METTask_CaloMEy_LS");   if (hCaloMEyLS  &&  hCaloMEyLS->getRootObject())    hCaloMEyLS->Fill(caloMEy,myLuminosityBlock);
01208       }
01209       hCaloEtFractionHadronic = _dbe->get(DirName+"/"+"METTask_CaloEtFractionHadronic"); if (hCaloEtFractionHadronic && hCaloEtFractionHadronic->getRootObject())  hCaloEtFractionHadronic->Fill(caloEtFractionHadronic);
01210       hCaloEmEtFraction       = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction");       if (hCaloEmEtFraction       && hCaloEmEtFraction->getRootObject())        hCaloEmEtFraction->Fill(caloEmEtFraction);
01211       
01212       //hCaloEmEtFraction002 = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction002");       if (caloMET>  2.  &&  hCaloEmEtFraction002    && hCaloEmEtFraction002->getRootObject()) hCaloEmEtFraction002->Fill(caloEmEtFraction);
01213       //hCaloEmEtFraction010 = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction010");       if (caloMET> 10.  &&  hCaloEmEtFraction010    && hCaloEmEtFraction010->getRootObject()) hCaloEmEtFraction010->Fill(caloEmEtFraction);
01214       hCaloEmEtFraction020 = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction020");       if (caloMET> 20.  &&  hCaloEmEtFraction020    && hCaloEmEtFraction020->getRootObject()) hCaloEmEtFraction020->Fill(caloEmEtFraction);
01215       */
01216 
01217       hCaloMaxEtInEmTowers  = _dbe->get(DirName+"/"+"METTask_CaloMaxEtInEmTowers");   if (hCaloMaxEtInEmTowers  && hCaloMaxEtInEmTowers->getRootObject())   hCaloMaxEtInEmTowers->Fill(caloMaxEtInEMTowers);
01218       hCaloMaxEtInHadTowers = _dbe->get(DirName+"/"+"METTask_CaloMaxEtInHadTowers");  if (hCaloMaxEtInHadTowers && hCaloMaxEtInHadTowers->getRootObject())  hCaloMaxEtInHadTowers->Fill(caloMaxEtInHadTowers);
01219 
01220       hCaloHadEtInHB = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHB");  if (hCaloHadEtInHB  &&  hCaloHadEtInHB->getRootObject())  hCaloHadEtInHB->Fill(caloHadEtInHB);
01221       hCaloHadEtInHO = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHO");  if (hCaloHadEtInHO  &&  hCaloHadEtInHO->getRootObject())  hCaloHadEtInHO->Fill(caloHadEtInHO);
01222       hCaloHadEtInHE = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHE");  if (hCaloHadEtInHE  &&  hCaloHadEtInHE->getRootObject())  hCaloHadEtInHE->Fill(caloHadEtInHE);
01223       hCaloHadEtInHF = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHF");  if (hCaloHadEtInHF  &&  hCaloHadEtInHF->getRootObject())  hCaloHadEtInHF->Fill(caloHadEtInHF);
01224       hCaloEmEtInEB  = _dbe->get(DirName+"/"+"METTask_CaloEmEtInEB");   if (hCaloEmEtInEB   &&  hCaloEmEtInEB->getRootObject())   hCaloEmEtInEB->Fill(caloEmEtInEB);
01225       hCaloEmEtInEE  = _dbe->get(DirName+"/"+"METTask_CaloEmEtInEE");   if (hCaloEmEtInEE   &&  hCaloEmEtInEE->getRootObject())   hCaloEmEtInEE->Fill(caloEmEtInEE);
01226       hCaloEmEtInHF  = _dbe->get(DirName+"/"+"METTask_CaloEmEtInHF");   if (hCaloEmEtInHF   &&  hCaloEmEtInHF->getRootObject())   hCaloEmEtInHF->Fill(caloEmEtInHF);
01227 
01228       hCaloEmMEx    = _dbe->get(DirName+"/"+"METTask_CaloEmMEx");     if (hCaloEmMEx    && hCaloEmMEx->getRootObject())     hCaloEmMEx->Fill(_EmMEx);
01229       hCaloEmMEy    = _dbe->get(DirName+"/"+"METTask_CaloEmMEy");     if (hCaloEmMEy    && hCaloEmMEy->getRootObject())     hCaloEmMEy->Fill(_EmMEy);
01230       //hCaloEmEz     = _dbe->get(DirName+"/"+"METTask_CaloEmEz");      if (hCaloEmEz     && hCaloEmEz->getRootObject())      hCaloEmEz->Fill(_EmCaloEz);
01231       hCaloEmMET    = _dbe->get(DirName+"/"+"METTask_CaloEmMET");     if (hCaloEmMET    && hCaloEmMET->getRootObject())     hCaloEmMET->Fill(_EmMET);
01232       hCaloEmMETPhi = _dbe->get(DirName+"/"+"METTask_CaloEmMETPhi");  if (hCaloEmMETPhi && hCaloEmMETPhi->getRootObject())  hCaloEmMETPhi->Fill(_EmMetPhi);
01233       //hCaloEmSumET  = _dbe->get(DirName+"/"+"METTask_CaloEmSumET");   if (hCaloEmSumET  && hCaloEmSumET->getRootObject())   hCaloEmSumET->Fill(_EmSumEt);
01234 
01235       hCaloHaMEx    = _dbe->get(DirName+"/"+"METTask_CaloHaMEx");     if (hCaloHaMEx    && hCaloHaMEx->getRootObject())     hCaloHaMEx->Fill(_HaMEx);
01236       hCaloHaMEy    = _dbe->get(DirName+"/"+"METTask_CaloHaMEy");     if (hCaloHaMEy    && hCaloHaMEy->getRootObject())     hCaloHaMEy->Fill(_HaMEy);
01237       //hCaloHaEz     = _dbe->get(DirName+"/"+"METTask_CaloHaEz");      if (hCaloHaEz     && hCaloHaEz->getRootObject())      hCaloHaEz->Fill(_HaCaloEz);
01238       hCaloHaMET    = _dbe->get(DirName+"/"+"METTask_CaloHaMET");     if (hCaloHaMET    && hCaloHaMET->getRootObject())     hCaloHaMET->Fill(_HaMET);
01239       hCaloHaMETPhi = _dbe->get(DirName+"/"+"METTask_CaloHaMETPhi");  if (hCaloHaMETPhi && hCaloHaMETPhi->getRootObject())  hCaloHaMETPhi->Fill(_HaMetPhi);
01240       //hCaloHaSumET  = _dbe->get(DirName+"/"+"METTask_CaloHaSumET");   if (hCaloHaSumET  && hCaloHaSumET->getRootObject())   hCaloHaSumET->Fill(_HaSumEt);
01241 
01242     } // _allhist
01243     /*
01244     if (theCaloMETCollectionLabel.label() == "corMetGlobalMuons" ) {
01245 
01246       for( reco::MuonCollection::const_iterator muonit = muon_h->begin(); muonit != muon_h->end(); muonit++ ) {
01247         const reco::TrackRef siTrack = muonit->innerTrack();
01248         hCalomuPt    = _dbe->get(DirName+"/"+"METTask_CalomuPt");     if (hCalomuPt    && hCalomuPt->getRootObject())     hCalomuPt->Fill( muonit->p4().pt() );
01249         hCalomuEta   = _dbe->get(DirName+"/"+"METTask_CalomuEta");    if (hCalomuEta   && hCalomuEta->getRootObject())    hCalomuEta->Fill( muonit->p4().eta() );
01250         hCalomuNhits = _dbe->get(DirName+"/"+"METTask_CalomuNhits");  if (hCalomuNhits && hCalomuNhits->getRootObject())  hCalomuNhits->Fill( siTrack.isNonnull() ? siTrack->numberOfValidHits() : -999 );
01251         hCalomuChi2  = _dbe->get(DirName+"/"+"METTask_CalomuChi2");   if (hCalomuChi2  && hCalomuChi2->getRootObject())   hCalomuChi2->Fill( siTrack.isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
01252         double d0 = siTrack.isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
01253         hCalomuD0    = _dbe->get(DirName+"/"+"METTask_CalomuD0");     if (hCalomuD0    && hCalomuD0->getRootObject())  hCalomuD0->Fill( d0 );
01254       }
01255       
01256       const unsigned int nMuons = muon_h->size();      
01257       for( unsigned int mus = 0; mus < nMuons; mus++ ) {
01258         reco::MuonRef muref( muon_h, mus);
01259         reco::MuonMETCorrectionData muCorrData = (*corMetGlobalMuons_ValueMap_Handle)[muref];
01260         hCaloMExCorrection      = _dbe->get(DirName+"/"+"METTask_CaloMExCorrection");       if (hCaloMExCorrection      && hCaloMExCorrection->getRootObject())       hCaloMExCorrection-> Fill(muCorrData.corrY());
01261         hCaloMEyCorrection      = _dbe->get(DirName+"/"+"METTask_CaloMEyCorrection");       if (hCaloMEyCorrection      && hCaloMEyCorrection->getRootObject())       hCaloMEyCorrection-> Fill(muCorrData.corrX());
01262         hCaloMuonCorrectionFlag = _dbe->get(DirName+"/"+"METTask_CaloMuonCorrectionFlag");  if (hCaloMuonCorrectionFlag && hCaloMuonCorrectionFlag->getRootObject())  hCaloMuonCorrectionFlag-> Fill(muCorrData.type());
01263       }
01264     }    
01265     */
01266   } // et threshold cut
01267 
01268 }
01269 
01270 // ***********************************************************
01271 void CaloMETAnalyzer::fillMonitorElementTriggered(const edm::Event& iEvent, std::string DirName, 
01272                                                   std::string TriggerTypeName, 
01273                                                   const reco::CaloMET& calomet,
01274                                                   const reco::CaloMET& calometnohf,
01275                                                   bool bLumiSecPlot)
01276 {
01277 
01278   if (TriggerTypeName=="HighPtJet") {
01279     if (!selectHighPtJetEvent(iEvent)) return;
01280   }
01281   else if (TriggerTypeName=="LowPtJet") {
01282     if (!selectLowPtJetEvent(iEvent)) return;
01283   }
01284   else if (TriggerTypeName=="HighMET") {
01285     if (calomet.pt()<_highMETThreshold) return;
01286   }
01287   //  else if (TriggerTypeName=="LowMET") {
01288   //    if (calomet.pt()<_lowMETThreshold) return;
01289   //  }
01290   else if (TriggerTypeName=="Ele") {
01291     if (!selectWElectronEvent(iEvent)) return;
01292   }
01293   else if (TriggerTypeName=="Muon") {
01294     if (!selectWMuonEvent(iEvent)) return;
01295   }
01296 
01297   double caloSumET  = calomet.sumEt();
01298   double caloMETSig = calomet.mEtSig();
01299   //double caloEz     = calomet.e_longitudinal();
01300   double caloMET    = calomet.pt();
01301   double caloMEx    = calomet.px();
01302   double caloMEy    = calomet.py();
01303   double caloMETPhi = calomet.phi();
01304 
01305   double caloMETNoHF    = calometnohf.pt();
01306   //double caloMETNoHFPhi = calometnohf.phi();
01307 
01308   if (_verbose) std::cout << _source << " " << caloMET << std::endl;
01309 
01310   double caloEtFractionHadronic = calomet.etFractionHadronic();
01311   double caloEmEtFraction       = calomet.emEtFraction();
01312 
01313   //double caloMaxEtInEMTowers    = calomet.maxEtInEmTowers();
01314   //double caloMaxEtInHadTowers   = calomet.maxEtInHadTowers();
01315 
01316   //double caloHadEtInHB = calomet.hadEtInHB();
01317   //double caloHadEtInHO = calomet.hadEtInHO();
01318   //double caloHadEtInHE = calomet.hadEtInHE();
01319   //double caloHadEtInHF = calomet.hadEtInHF();
01320   //double caloEmEtInEB  = calomet.emEtInEB();
01321   //double caloEmEtInEE  = calomet.emEtInEE();
01322   //double caloEmEtInHF  = calomet.emEtInHF();
01323 
01324   //
01325   int myLuminosityBlock;
01326   //  myLuminosityBlock = (evtCounter++)/1000;
01327   myLuminosityBlock = iEvent.luminosityBlock();
01328   //
01329 
01330   if (TriggerTypeName!="") DirName = DirName +"/"+TriggerTypeName;
01331 
01332   if (_verbose) std::cout << "_etThreshold = " << _etThreshold << std::endl;
01333   if (caloSumET>_etThreshold){
01334     hCaloMEx    = _dbe->get(DirName+"/"+"METTask_CaloMEx");    if (hCaloMEx     && hCaloMEx->getRootObject() )    hCaloMEx->Fill(caloMEx);
01335     hCaloMEy    = _dbe->get(DirName+"/"+"METTask_CaloMEy");    if (hCaloMEy     && hCaloMEy->getRootObject() )    hCaloMEy->Fill(caloMEy);
01336     hCaloMET    = _dbe->get(DirName+"/"+"METTask_CaloMET");    if (hCaloMET     && hCaloMET->getRootObject() )    hCaloMET->Fill(caloMET);
01337     hCaloMET1   = _dbe->get(DirName+"/"+"METTask_CaloMET1");   if (hCaloMET1    && hCaloMET1->getRootObject() )   hCaloMET1->Fill(caloMET);
01338     hCaloMETPhi = _dbe->get(DirName+"/"+"METTask_CaloMETPhi"); if (hCaloMETPhi  && hCaloMETPhi->getRootObject() ) hCaloMETPhi->Fill(caloMETPhi);
01339     hCaloSumET  = _dbe->get(DirName+"/"+"METTask_CaloSumET");  if (hCaloSumET   && hCaloSumET->getRootObject() )  hCaloSumET->Fill(caloSumET);
01340     hCaloMETSig = _dbe->get(DirName+"/"+"METTask_CaloMETSig"); if (hCaloMETSig  && hCaloMETSig->getRootObject() ) hCaloMETSig->Fill(caloMETSig);
01341     //hCaloEz     = _dbe->get(DirName+"/"+"METTask_CaloEz");     if (hCaloEz      && hCaloEz->getRootObject() )     hCaloEz->Fill(caloEz);
01342 
01343     hCaloMETNoHF    = _dbe->get(DirName+"/"+"METTask_CaloMETNoHF");    if (hCaloMETNoHF     && hCaloMETNoHF->getRootObject() )    hCaloMETNoHF->Fill(caloMETNoHF);
01344 
01345     hCaloMET_logx   = _dbe->get(DirName+"/"+"METTask_CaloMET_logx");      if (hCaloMET_logx    && hCaloMET_logx->getRootObject() )   hCaloMET_logx->Fill(log10(caloMET));
01346     hCaloSumET_logx = _dbe->get(DirName+"/"+"METTask_CaloSumET_logx");    if (hCaloSumET_logx  && hCaloSumET_logx->getRootObject() ) hCaloSumET_logx->Fill(log10(caloSumET));
01347 
01348 
01349     // Fill NPV profiles
01350     //--------------------------------------------------------------------------
01351     hCaloMEx_profile     = _dbe->get(DirName + "/METTask_CaloMEx_profile");
01352     hCaloMEy_profile     = _dbe->get(DirName + "/METTask_CaloMEy_profile");
01353     hCaloMET_profile     = _dbe->get(DirName + "/METTask_CaloMET_profile");
01354     hCaloMETNoHF_profile = _dbe->get(DirName + "/METTask_CaloMETNoHF_profile");
01355     hCaloSumET_profile   = _dbe->get(DirName + "/METTask_CaloSumET_profile");
01356     
01357     if (hCaloMEx_profile     && hCaloMEx_profile    ->getRootObject()) hCaloMEx_profile    ->Fill(_numPV, caloMEx);
01358     if (hCaloMEy_profile     && hCaloMEy_profile    ->getRootObject()) hCaloMEy_profile    ->Fill(_numPV, caloMEy);
01359     if (hCaloMET_profile     && hCaloMET_profile    ->getRootObject()) hCaloMET_profile    ->Fill(_numPV, caloMET);
01360     if (hCaloMETNoHF_profile && hCaloMETNoHF_profile->getRootObject()) hCaloMETNoHF_profile->Fill(_numPV, caloMETNoHF);
01361     if (hCaloSumET_profile   && hCaloSumET_profile  ->getRootObject()) hCaloSumET_profile  ->Fill(_numPV, caloSumET);
01362 
01363 
01364     //hCaloEz     = _dbe->get(DirName+"/"+"METTask_CaloEz_profile");     if (hCaloEz      && hCaloEz_profile->getRootObject() )     hCaloEz_profile->Fill(caloEz);
01365     //  hCaloMETIonFeedbck = _dbe->get(DirName+"/"+"METTask_CaloMETIonFeedbck"); if (hCaloMETIonFeedbck  && hCaloMETIonFeedbck->getRootObject() ) hCaloMETIonFeedbck->Fill(caloMET);
01366     //  haloMETHPDNoise   = _dbe->get(DirName+"/"+"METTask_CaloMETHPDNoise");   if (hCaloMETHPDNoise    && hCaloMETHPDNoise->getRootObject() )   hCaloMETHPDNoise->Fill(caloMET);
01367 
01368     //hCaloMETPhi002 = _dbe->get(DirName+"/"+"METTask_CaloMETPhi002");    if (caloMET>  2. && hCaloMETPhi002  &&  hCaloMETPhi002->getRootObject()) { hCaloMETPhi002->Fill(caloMETPhi);}
01369     //hCaloMETPhi010 = _dbe->get(DirName+"/"+"METTask_CaloMETPhi010");    if (caloMET> 10. && hCaloMETPhi010  &&  hCaloMETPhi010->getRootObject()) { hCaloMETPhi010->Fill(caloMETPhi);}
01370     hCaloMETPhi020 = _dbe->get(DirName+"/"+"METTask_CaloMETPhi020");    if (caloMET> 20. && hCaloMETPhi020  &&  hCaloMETPhi020->getRootObject()) { hCaloMETPhi020->Fill(caloMETPhi);}
01371 
01372     if (_allhist){
01373       if (bLumiSecPlot){
01374         hCaloMExLS = _dbe->get(DirName+"/"+"METTask_CaloMEx_LS");   if (hCaloMExLS  &&  hCaloMExLS->getRootObject())    hCaloMExLS->Fill(caloMEx,myLuminosityBlock);
01375         hCaloMEyLS = _dbe->get(DirName+"/"+"METTask_CaloMEy_LS");   if (hCaloMEyLS  &&  hCaloMEyLS->getRootObject())    hCaloMEyLS->Fill(caloMEy,myLuminosityBlock);
01376       }
01377       
01378       hCaloEtFractionHadronic = _dbe->get(DirName+"/"+"METTask_CaloEtFractionHadronic"); if (hCaloEtFractionHadronic && hCaloEtFractionHadronic->getRootObject())  hCaloEtFractionHadronic->Fill(caloEtFractionHadronic);
01379       hCaloEmEtFraction       = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction");       if (hCaloEmEtFraction       && hCaloEmEtFraction->getRootObject())        hCaloEmEtFraction->Fill(caloEmEtFraction);
01380       
01381       //hCaloEmEtFraction002 = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction002");       if (caloMET>  2.  &&  hCaloEmEtFraction002    && hCaloEmEtFraction002->getRootObject()) hCaloEmEtFraction002->Fill(caloEmEtFraction);
01382       //hCaloEmEtFraction010 = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction010");       if (caloMET> 10.  &&  hCaloEmEtFraction010    && hCaloEmEtFraction010->getRootObject()) hCaloEmEtFraction010->Fill(caloEmEtFraction);
01383       hCaloEmEtFraction020 = _dbe->get(DirName+"/"+"METTask_CaloEmEtFraction020");       if (caloMET> 20.  &&  hCaloEmEtFraction020    && hCaloEmEtFraction020->getRootObject()) hCaloEmEtFraction020->Fill(caloEmEtFraction);
01384 
01385       //hCaloMaxEtInEmTowers  = _dbe->get(DirName+"/"+"METTask_CaloMaxEtInEmTowers");   if (hCaloMaxEtInEmTowers  && hCaloMaxEtInEmTowers->getRootObject())   hCaloMaxEtInEmTowers->Fill(caloMaxEtInEMTowers);
01386       //hCaloMaxEtInHadTowers = _dbe->get(DirName+"/"+"METTask_CaloMaxEtInHadTowers");  if (hCaloMaxEtInHadTowers && hCaloMaxEtInHadTowers->getRootObject())  hCaloMaxEtInHadTowers->Fill(caloMaxEtInHadTowers);
01387       //
01388       //hCaloHadEtInHB = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHB");  if (hCaloHadEtInHB  &&  hCaloHadEtInHB->getRootObject())  hCaloHadEtInHB->Fill(caloHadEtInHB);
01389       //hCaloHadEtInHO = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHO");  if (hCaloHadEtInHO  &&  hCaloHadEtInHO->getRootObject())  hCaloHadEtInHO->Fill(caloHadEtInHO);
01390       //hCaloHadEtInHE = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHE");  if (hCaloHadEtInHE  &&  hCaloHadEtInHE->getRootObject())  hCaloHadEtInHE->Fill(caloHadEtInHE);
01391       //hCaloHadEtInHF = _dbe->get(DirName+"/"+"METTask_CaloHadEtInHF");  if (hCaloHadEtInHF  &&  hCaloHadEtInHF->getRootObject())  hCaloHadEtInHF->Fill(caloHadEtInHF);
01392       //hCaloEmEtInEB  = _dbe->get(DirName+"/"+"METTask_CaloEmEtInEB");   if (hCaloEmEtInEB   &&  hCaloEmEtInEB->getRootObject())   hCaloEmEtInEB->Fill(caloEmEtInEB);
01393       //hCaloEmEtInEE  = _dbe->get(DirName+"/"+"METTask_CaloEmEtInEE");   if (hCaloEmEtInEE   &&  hCaloEmEtInEE->getRootObject())   hCaloEmEtInEE->Fill(caloEmEtInEE);
01394       //hCaloEmEtInHF  = _dbe->get(DirName+"/"+"METTask_CaloEmEtInHF");   if (hCaloEmEtInHF   &&  hCaloEmEtInHF->getRootObject())   hCaloEmEtInHF->Fill(caloEmEtInHF);
01395       //
01396       //hCaloEmMEx    = _dbe->get(DirName+"/"+"METTask_CaloEmMEx");     if (hCaloEmMEx    && hCaloEmMEx->getRootObject())     hCaloEmMEx->Fill(_EmMEx);
01397       //hCaloEmMEy    = _dbe->get(DirName+"/"+"METTask_CaloEmMEy");     if (hCaloEmMEy    && hCaloEmMEy->getRootObject())     hCaloEmMEy->Fill(_EmMEy);
01399       //hCaloEmMET    = _dbe->get(DirName+"/"+"METTask_CaloEmMET");     if (hCaloEmMET    && hCaloEmMET->getRootObject())     hCaloEmMET->Fill(_EmMET);
01400       //hCaloEmMETPhi = _dbe->get(DirName+"/"+"METTask_CaloEmMETPhi");  if (hCaloEmMETPhi && hCaloEmMETPhi->getRootObject())  hCaloEmMETPhi->Fill(_EmMetPhi);
01402       //
01403       //hCaloHaMEx    = _dbe->get(DirName+"/"+"METTask_CaloHaMEx");     if (hCaloHaMEx    && hCaloHaMEx->getRootObject())     hCaloHaMEx->Fill(_HaMEx);
01404       //hCaloHaMEy    = _dbe->get(DirName+"/"+"METTask_CaloHaMEy");     if (hCaloHaMEy    && hCaloHaMEy->getRootObject())     hCaloHaMEy->Fill(_HaMEy);
01406       //hCaloHaMET    = _dbe->get(DirName+"/"+"METTask_CaloHaMET");     if (hCaloHaMET    && hCaloHaMET->getRootObject())     hCaloHaMET->Fill(_HaMET);
01407       //hCaloHaMETPhi = _dbe->get(DirName+"/"+"METTask_CaloHaMETPhi");  if (hCaloHaMETPhi && hCaloHaMETPhi->getRootObject())  hCaloHaMETPhi->Fill(_HaMetPhi);
01409 
01410     } // _allhist
01411     if (theCaloMETCollectionLabel.label() == "corMetGlobalMuons" ) {
01412 
01413       for( reco::MuonCollection::const_iterator muonit = muon_h->begin(); muonit != muon_h->end(); muonit++ ) {
01414         const reco::TrackRef siTrack = muonit->innerTrack();
01415         hCalomuPt    = _dbe->get(DirName+"/"+"METTask_CalomuPt");     if (hCalomuPt    && hCalomuPt->getRootObject())     hCalomuPt->Fill( muonit->p4().pt() );
01416         hCalomuEta   = _dbe->get(DirName+"/"+"METTask_CalomuEta");    if (hCalomuEta   && hCalomuEta->getRootObject())    hCalomuEta->Fill( muonit->p4().eta() );
01417         hCalomuNhits = _dbe->get(DirName+"/"+"METTask_CalomuNhits");  if (hCalomuNhits && hCalomuNhits->getRootObject())  hCalomuNhits->Fill( siTrack.isNonnull() ? siTrack->numberOfValidHits() : -999 );
01418         hCalomuChi2  = _dbe->get(DirName+"/"+"METTask_CalomuChi2");   if (hCalomuChi2  && hCalomuChi2->getRootObject())   hCalomuChi2->Fill( siTrack.isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
01419         double d0 = siTrack.isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
01420         hCalomuD0    = _dbe->get(DirName+"/"+"METTask_CalomuD0");     if (hCalomuD0    && hCalomuD0->getRootObject())  hCalomuD0->Fill( d0 );
01421       }
01422       
01423       const unsigned int nMuons = muon_h->size();      
01424       for( unsigned int mus = 0; mus < nMuons; mus++ ) {
01425         reco::MuonRef muref( muon_h, mus);
01426         reco::MuonMETCorrectionData muCorrData = (*corMetGlobalMuons_ValueMap_Handle)[muref];
01427         hCaloMExCorrection      = _dbe->get(DirName+"/"+"METTask_CaloMExCorrection");       if (hCaloMExCorrection      && hCaloMExCorrection->getRootObject())       hCaloMExCorrection-> Fill(muCorrData.corrY());
01428         hCaloMEyCorrection      = _dbe->get(DirName+"/"+"METTask_CaloMEyCorrection");       if (hCaloMEyCorrection      && hCaloMEyCorrection->getRootObject())       hCaloMEyCorrection-> Fill(muCorrData.corrX());
01429         hCaloMuonCorrectionFlag = _dbe->get(DirName+"/"+"METTask_CaloMuonCorrectionFlag");  if (hCaloMuonCorrectionFlag && hCaloMuonCorrectionFlag->getRootObject())  hCaloMuonCorrectionFlag-> Fill(muCorrData.type());
01430       }
01431     }    
01432   } // et threshold cut
01433 
01434 }
01435 
01436 // ***********************************************************
01437 bool CaloMETAnalyzer::selectHighPtJetEvent(const edm::Event& iEvent){
01438 
01439   bool return_value=false;
01440 
01441   edm::Handle<reco::CaloJetCollection> caloJets;
01442   iEvent.getByLabel(theJetCollectionLabel, caloJets);
01443   if (!caloJets.isValid()) {
01444     LogDebug("") << "CaloMETAnalyzer: Could not find jet product" << std::endl;
01445     if (_verbose) std::cout << "CaloMETAnalyzer: Could not find jet product" << std::endl;
01446   }
01447 
01448   for (reco::CaloJetCollection::const_iterator cal = caloJets->begin(); 
01449        cal!=caloJets->end(); ++cal){
01450     if (cal->pt()>_highPtJetThreshold){
01451       return_value=true;
01452     }
01453   }
01454 
01455   return return_value;
01456 
01457 }
01458 
01459 // ***********************************************************
01460 bool CaloMETAnalyzer::selectLowPtJetEvent(const edm::Event& iEvent){
01461 
01462   bool return_value=false;
01463 
01464   edm::Handle<reco::CaloJetCollection> caloJets;
01465   iEvent.getByLabel(theJetCollectionLabel, caloJets);
01466   if (!caloJets.isValid()) {
01467     LogDebug("") << "CaloMETAnalyzer: Could not find jet product" << std::endl;
01468     if (_verbose) std::cout << "CaloMETAnalyzer: Could not find jet product" << std::endl;
01469   }
01470 
01471   for (reco::CaloJetCollection::const_iterator cal = caloJets->begin(); 
01472        cal!=caloJets->end(); ++cal){
01473     if (cal->pt()>_lowPtJetThreshold){
01474       return_value=true;
01475     }
01476   }
01477 
01478   return return_value;
01479 
01480 }
01481 
01482 // ***********************************************************
01483 bool CaloMETAnalyzer::selectWElectronEvent(const edm::Event& iEvent){
01484 
01485   bool return_value=true;
01486 
01487   /*
01488     W-electron event selection comes here
01489    */
01490 
01491   return return_value;
01492 
01493 }
01494 
01495 // ***********************************************************
01496 bool CaloMETAnalyzer::selectWMuonEvent(const edm::Event& iEvent){
01497 
01498   bool return_value=true;
01499 
01500   /*
01501     W-muon event selection comes here
01502    */
01503 
01504   return return_value;
01505 
01506 }
01507