CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQMOffline/JetMET/src/SUSYDQMAnalyzer.cc

Go to the documentation of this file.
00001 //authors:  Francesco Costanza (DESY)
00002 //          Dirk Kruecker (DESY)
00003 //date:     05/05/11
00004 
00005 //================================================================  
00006 // CMS FW and Data Handlers
00007 
00008 #include "DataFormats/Common/interface/Handle.h"
00009 
00010 #include "DQMServices/Core/interface/DQMStore.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012 
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 
00020 //================================================================  
00021 // Jet & Jet collections  // MET & MET collections
00022 
00023 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00024 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00025 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00026 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00027 
00028 #include "DataFormats/JetReco/interface/CaloJet.h"
00029 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00030 #include "DataFormats/JetReco/interface/PFJet.h"
00031 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00032 #include "DataFormats/JetReco/interface/JPTJet.h"
00033 #include "DataFormats/JetReco/interface/JPTJetCollection.h"
00034 
00035 #include "DataFormats/METReco/interface/MET.h"
00036 #include "DataFormats/METReco/interface/METCollection.h"
00037 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00038 #include "DataFormats/METReco/interface/CaloMET.h"
00039 #include "DataFormats/METReco/interface/PFMET.h"
00040 #include "DataFormats/METReco/interface/PFMETCollection.h"
00041 #include "DataFormats/METReco/interface/PFMETFwd.h"
00042 
00043 //================================================================  
00044 // SUSY Classes
00045 
00046 #include "DataFormats/Math/interface/LorentzVector.h"
00047 #include "DQMOffline/JetMET/interface/SUSYDQMAnalyzer.h"
00048 #include "DQMOffline/JetMET/interface/SusyDQM/alpha_T.h"
00049 #include "DQMOffline/JetMET/interface/SusyDQM/HT.h"
00050 
00051 //================================================================  
00052 // ROOT Classes
00053 
00054 #include "TH1.h"
00055 #include "TVector2.h"
00056 #include "TLorentzVector.h"
00057 
00058 //================================================================  
00059 // Ordinary C++ stuff
00060 
00061 #include <cmath>
00062 #include <vector>
00063 #include <fstream>
00064 #include <sstream>
00065 #include <string>
00066 
00067 using namespace edm;
00068 using namespace reco;
00069 using namespace math;
00070 using namespace std;
00071 
00072 SUSYDQMAnalyzer::SUSYDQMAnalyzer( const edm::ParameterSet& pSet)
00073 {
00074   iConfig = pSet;
00075   
00076   SUSYFolder = iConfig.getParameter<std::string>("folderName");
00077   dqm = edm::Service<DQMStore>().operator->();
00078   //std::cout<<"here 1!"<<std::endl;
00079 }
00080 
00081 
00082 void SUSYDQMAnalyzer::beginJob(void){
00083 
00084   // Load parameters
00085   //std::cout<<"here 2!"<<std::endl;
00086   thePFMETCollectionLabel     = iConfig.getParameter<edm::InputTag>("PFMETCollectionLabel");
00087   theCaloMETCollectionLabel   = iConfig.getParameter<edm::InputTag>("CaloMETCollectionLabel");
00088   theTCMETCollectionLabel     = iConfig.getParameter<edm::InputTag>("TCMETCollectionLabel");
00089 
00090   theCaloJetCollectionLabel   = iConfig.getParameter<edm::InputTag>("CaloJetCollectionLabel");
00091   theJPTJetCollectionLabel    = iConfig.getParameter<edm::InputTag>("JPTJetCollectionLabel");
00092   thePFJetCollectionLabel     = iConfig.getParameter<edm::InputTag>("PFJetCollectionLabel");
00093 
00094   _ptThreshold = iConfig.getParameter<double>("ptThreshold");
00095   _maxNJets = iConfig.getParameter<double>("maxNJets");
00096   _maxAbsEta = iConfig.getParameter<double>("maxAbsEta");
00097 
00098   //std::cout<<"here 3!"<<std::endl;
00099   //std::cout<<thePFJetCollectionLabel<<std::endl;
00100 }
00101 
00102 void SUSYDQMAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup){
00103   //std::cout<<"here 4!"<<std::endl;
00104   if( dqm ) {
00105     //std::cout<<"here 5!"<<std::endl;
00106     //===========================================================  
00107     // book HT histos.
00108 
00109     std::string dir=SUSYFolder;
00110     dir+="HT";
00111     dqm->setCurrentFolder(dir);
00112     hCaloHT = dqm->book1D("Calo_HT", "", 500, 0., 2000);
00113     hPFHT   = dqm->book1D("PF_HT"  , "", 500, 0., 2000);
00114     hJPTHT  = dqm->book1D("JPT_HT" , "", 500, 0., 2000);
00115 
00116     //===========================================================  
00117     // book MET histos.
00118 
00119     dir=SUSYFolder;
00120     dir+="MET";
00121     dqm->setCurrentFolder(dir);
00122     hCaloMET = dqm->book1D("Calo_MET", "", 500, 0., 1000);
00123     hPFMET   = dqm->book1D("PF_MET"  , "", 500, 0., 1000);
00124     hTCMET   = dqm->book1D("TC_MET"  , "", 500, 0., 1000);
00125 
00126     //===========================================================  
00127     // book MHT histos.
00128 
00129     dir=SUSYFolder;
00130     dir+="MHT"; 
00131     dqm->setCurrentFolder(dir);
00132     hCaloMHT = dqm->book1D("Calo_MHT", "", 500, 0., 1000);
00133     hPFMHT   = dqm->book1D("PF_MHT"  , "", 500, 0., 1000);
00134     hJPTMHT  = dqm->book1D("JPT_MHT" , "", 500, 0., 1000);
00135    
00136     //===========================================================  
00137     // book alpha_T histos.
00138 
00139     dir=SUSYFolder;
00140     dir+="Alpha_T";
00141     dqm->setCurrentFolder(dir);
00142     hCaloAlpha_T = dqm->book1D("Calo_AlphaT", "", 100, 0., 1.);
00143     hJPTAlpha_T  = dqm->book1D("PF_AlphaT"  , "", 100, 0., 1.);
00144     hPFAlpha_T   = dqm->book1D("JPT_AlphaT"  , "", 100, 0., 1.);
00145     //std::cout<<"here 6!"<<std::endl;
00146   }
00147 }
00148 
00149 void SUSYDQMAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00150 {
00151   //std::cout<<"here 7!"<<std::endl;
00152   // Commenting out unused but initialized variables. [Suchandra Dutta]
00153 //  EventID TheEvent = iEvent.id();
00154   //int BXN = iEvent.bunchCrossing() ;
00155   //bool Dump = TextFileName.size();
00156   //int TheEventNumber = TheEvent.event();
00157   //int Lumi = iEvent.luminosityBlock();
00158   //int Run  = iEvent.run();
00159 
00160   //###########################################################
00161   // HTand MHT
00162   
00163   //===========================================================
00164   // Calo HT, MHT and alpha_T
00165 
00166   edm::Handle<reco::CaloJetCollection> CaloJetcoll;
00167 
00168   iEvent.getByLabel(theCaloJetCollectionLabel, CaloJetcoll);
00169 
00170   if(!CaloJetcoll.isValid()) return;
00171   
00172   std::vector<math::XYZTLorentzVector> Ps;
00173   for (reco::CaloJetCollection::const_iterator jet = CaloJetcoll->begin(); jet!=CaloJetcoll->end(); ++jet){
00174     if ((jet->pt()>_ptThreshold) && (abs(jet->eta()) < _maxAbsEta)){
00175       if(Ps.size()>_maxNJets) {
00176         std::cout<<"NMax Jets exceded.."<<std::endl;
00177         break;
00178       }
00179       Ps.push_back(jet->p4());
00180     }
00181   }
00182 
00183   hCaloAlpha_T->Fill( alpha_T()(Ps));
00184   //std::cout<<"Calo Alpha_T "<<alpha_T()(Ps)<<std::endl;
00185 
00186   HT< reco::CaloJetCollection > CaloHT(CaloJetcoll, _ptThreshold, _maxAbsEta);
00187 
00188   //std::cout << "Calo MHT " << CaloHT.v.Mod() << std::endl;
00189   //std::cout << "Calo HT " << CaloHT.ScalarSum << std::endl;
00190   hCaloHT->Fill(CaloHT.ScalarSum);
00191   hCaloMHT->Fill(CaloHT.v.Mod());
00192 
00193   //===========================================================
00194   // PF HT, MHT and alpha_T
00195 
00196   edm::Handle<reco::PFJetCollection> PFjetcoll;
00197 
00198   iEvent.getByLabel(thePFJetCollectionLabel, PFjetcoll);
00199 
00200   if(!PFjetcoll.isValid()) return;
00201 
00202   Ps.clear();
00203   for (reco::PFJetCollection::const_iterator jet = PFjetcoll->begin(); jet!=PFjetcoll->end(); ++jet){
00204     if ((jet->pt()>_ptThreshold) && (abs(jet->eta()) < _maxAbsEta)){
00205       if(Ps.size()>_maxNJets) {
00206         std::cout<<"NMax Jets exceded.."<<std::endl;
00207         break;
00208       }
00209       Ps.push_back(jet->p4());
00210     }
00211   }
00212   //std::cout<<Ps.size()<<" "<<Ps.max_size()<<std::endl;
00213   hPFAlpha_T->Fill( alpha_T()(Ps));
00214   //std::cout<<"PF Alpha_T "<<alpha_T()(Ps)<<std::endl;
00215 
00216   HT<reco::PFJetCollection> PFHT(PFjetcoll, _ptThreshold, _maxAbsEta);
00217 
00218   //std::cout << "PF MHT " << PFHT.v.Mod() << std::endl;
00219   //std::cout << "PF HT " << PFHT.ScalarSum << std::endl;
00220   hPFHT->Fill(PFHT.ScalarSum);
00221   hPFMHT->Fill(PFHT.v.Mod());
00222   
00223   //===========================================================
00224   // JPT HT, MHT and alpha_T
00225 
00226   edm::Handle<reco::JPTJetCollection> JPTjetcoll;
00227 
00228   iEvent.getByLabel(theJPTJetCollectionLabel, JPTjetcoll);
00229 
00230   if(!JPTjetcoll.isValid()) return;
00231 
00232   Ps.clear();
00233   for (reco::JPTJetCollection::const_iterator jet = JPTjetcoll->begin(); jet!=JPTjetcoll->end(); ++jet){
00234     if ((jet->pt()>_ptThreshold) && (abs(jet->eta())<_maxAbsEta)){
00235       if(Ps.size()>_maxNJets) {
00236         std::cout<<"NMax Jets exceded..."<<std::endl;
00237         break;
00238       }
00239       Ps.push_back(jet->p4());
00240     }
00241   }
00242   hJPTAlpha_T->Fill( alpha_T()(Ps));
00243   //std::cout<<"JPT Alpha_T "<<alpha_T()(Ps)<<std::endl;
00244 
00245   HT<reco::JPTJetCollection> JPTHT(JPTjetcoll, _ptThreshold, _maxAbsEta);
00246 
00247   //std::cout << "JPT MHT " << JPTHT.v.Mod() << std::endl;
00248   //std::cout << "JPT HT " << JPTHT.ScalarSum << std::endl;
00249   hJPTHT->Fill(JPTHT.ScalarSum);
00250   hJPTMHT->Fill(JPTHT.v.Mod());
00251 
00252   //###########################################################
00253   // MET
00254 
00255   //===========================================================  
00256   // Calo MET
00257 
00258   edm::Handle<reco::CaloMETCollection> calometcoll;
00259   iEvent.getByLabel(theCaloMETCollectionLabel, calometcoll);
00260 
00261   if(!calometcoll.isValid()) return;
00262 
00263   const CaloMETCollection *calometcol = calometcoll.product();
00264   const CaloMET *calomet;
00265   calomet = &(calometcol->front());
00266   
00267   hCaloMET->Fill(calomet->pt());
00268   //std::cout<<"Calo MET "<<calomet->pt()<<std::endl;
00269 
00270   //===========================================================
00271   // PF MET
00272 
00273   edm::Handle<reco::PFMETCollection> pfmetcoll;
00274   iEvent.getByLabel(thePFMETCollectionLabel, pfmetcoll);
00275   
00276   if(!pfmetcoll.isValid()) return;
00277 
00278   const PFMETCollection *pfmetcol = pfmetcoll.product();
00279   const PFMET *pfmet;
00280   pfmet = &(pfmetcol->front());
00281 
00282   hPFMET->Fill(pfmet->pt());
00283   //std::cout<<"PF MET "<<pfmet->pt()<<std::endl;
00284 
00285   //===========================================================
00286   // TC MET
00287 
00288   edm::Handle<reco::METCollection> tcmetcoll;
00289   iEvent.getByLabel(theTCMETCollectionLabel, tcmetcoll);
00290   
00291   if(!tcmetcoll.isValid()) return;
00292 
00293   const METCollection *tcmetcol = tcmetcoll.product();
00294   const MET *tcmet;
00295   tcmet = &(tcmetcol->front());
00296 
00297   hTCMET->Fill(tcmet->pt());
00298   //std::cout<<"TC MET "<<tcmet->pt()<<std::endl;
00299 
00300 }
00301 
00302 void SUSYDQMAnalyzer::endRun(const edm::Run&, const edm::EventSetup&){  
00303 }
00304 
00305 SUSYDQMAnalyzer::~SUSYDQMAnalyzer(){
00306 }