CMS 3D CMS Logo

ProducerAnalyzer.cc

Go to the documentation of this file.
00001 // system include files
00002 
00003 // user include files
00004 
00005 #include "Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.h"
00006 #include "DataFormats/Provenance/interface/Provenance.h"
00007 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00008 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00009 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00010 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00011 #include "DataFormats/MuonReco/interface/Muon.h"
00012 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00013 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00014 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00015 #include "DataFormats/TrackReco/interface/Track.h"
00016 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00017 #include "Geometry/Records/interface/CaloGeometryRecord.h" 
00018 #include "Geometry/CaloGeometry/interface/CaloGeometry.h" 
00019 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" 
00020 #include "DataFormats/HcalCalibObjects/interface/HOCalibVariables.h"
00021 #include "DataFormats/HcalCalibObjects/interface/HOCalibVariableCollection.h"
00022 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00023 #include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
00024 #include "RecoTracker/TrackProducer/interface/TrackProducerBase.h"
00025 
00026 #include <map>
00027 
00028 using namespace std;
00029 using namespace reco;
00030 
00031 namespace cms
00032 {
00033 
00034 //
00035 // constructors and destructor
00036 //
00037 ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig)
00038 {
00039   // get name of output file with histogramms  
00040    
00041    nameProd_ = iConfig.getUntrackedParameter<std::string>("nameProd");
00042    jetCalo_ = iConfig.getUntrackedParameter<std::string>("jetCalo","GammaJetJetBackToBackCollection");
00043    gammaClus_ = iConfig.getUntrackedParameter<std::string>("gammaClus","GammaJetGammaBackToBackCollection");
00044    ecalInput_=iConfig.getUntrackedParameter<std::string>("ecalInput","GammaJetEcalRecHitCollection");
00045    hbheInput_ = iConfig.getUntrackedParameter<std::string>("hbheInput");
00046    hoInput_ = iConfig.getUntrackedParameter<std::string>("hoInput");
00047    hfInput_ = iConfig.getUntrackedParameter<std::string>("hfInput");
00048    Tracks_ = iConfig.getUntrackedParameter<std::string>("Tracks","GammaJetTracksCollection");    
00049 
00050 }
00051 
00052 ProducerAnalyzer::~ProducerAnalyzer()
00053 {
00054  
00055    // do anything here that needs to be done at desctruction time
00056    // (e.g. close files, deallocate resources etc.)
00057 
00058 }
00059 
00060 void ProducerAnalyzer::beginJob( const edm::EventSetup& iSetup)
00061 {
00062 }
00063 
00064 void ProducerAnalyzer::endJob()
00065 {
00066 }
00067 
00068 
00069 //
00070 // member functions
00071 //
00072 
00073 // ------------ method called to produce the data  ------------
00074 void
00075 ProducerAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00076 {
00077 
00078   using namespace edm;
00079 
00080    const CaloGeometry* geo;
00081    edm::ESHandle<CaloGeometry> pG;
00082    iSetup.get<CaloGeometryRecord>().get(pG);
00083    geo = pG.product();
00084    
00085 
00086   std::vector<Provenance const*> theProvenance;
00087   iEvent.getAllProvenance(theProvenance);
00088   for( std::vector<Provenance const*>::const_iterator ip = theProvenance.begin();
00089                                                       ip != theProvenance.end(); ip++)
00090   {
00091      cout<<" Print all module/label names "<<(**ip).moduleName()<<" "<<(**ip).moduleLabel()<<
00092      " "<<(**ip).productInstanceName()<<endl;
00093   }
00094   
00095   bool allowMissingInputs_ = true;
00096   
00097   if(nameProd_ == "hoCalibProducer")
00098   {
00099      edm::Handle<HOCalibVariableCollection> ho;
00100      iEvent.getByLabel(nameProd_,hoInput_, ho);
00101      const HOCalibVariableCollection Hitho = *(ho.product());
00102      std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
00103   }
00104   
00105    if(nameProd_ == "ALCARECOMuAlZMuMu" )
00106    {
00107    
00108    edm::Handle<HORecHitCollection> ho;
00109    iEvent.getByLabel("horeco", ho);
00110    const HORecHitCollection Hitho = *(ho.product());
00111    std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
00112    edm::Handle<MuonCollection> mucand;
00113    iEvent.getByLabel(nameProd_,"SelectedMuons", mucand);
00114    std::cout<<" Size of muon collection "<<mucand->size()<<std::endl;
00115    for(MuonCollection::const_iterator it =  mucand->begin(); it != mucand->end(); it++)
00116    {
00117       TrackRef mu = (*it).combinedMuon();
00118       std::cout<<" Pt muon "<<mu->innerMomentum()<<std::endl;
00119    }
00120    
00121    }  
00122   
00123    if(nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer")
00124    {
00125    edm::Handle<HBHERecHitCollection> hbhe;
00126    iEvent.getByLabel(nameProd_,hbheInput_, hbhe);
00127    const HBHERecHitCollection Hithbhe = *(hbhe.product());
00128    std::cout<<" Size of HBHE "<<(Hithbhe).size()<<std::endl;
00129 
00130 
00131    edm::Handle<HORecHitCollection> ho;
00132    iEvent.getByLabel(nameProd_,hoInput_, ho);
00133    const HORecHitCollection Hitho = *(ho.product());
00134    std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
00135 
00136 
00137    edm::Handle<HFRecHitCollection> hf;
00138    iEvent.getByLabel(nameProd_,hfInput_, hf);
00139    const HFRecHitCollection Hithf = *(hf.product());
00140    std::cout<<" Size of HF "<<(Hithf).size()<<std::endl;
00141    }
00142    if(nameProd_ == "IsoProd")
00143    {
00144    cout<<" We are here "<<endl;
00145    edm::Handle<reco::TrackCollection> tracks;
00146    iEvent.getByLabel(nameProd_,Tracks_,tracks);
00147  
00148    
00149    std::cout<<" Tracks size "<<(*tracks).size()<<std::endl;
00150    reco::TrackCollection::const_iterator track = tracks->begin ();
00151 
00152           for (; track != tracks->end (); track++)
00153          {
00154            cout<<" P track "<<(*track).p()<<" eta "<<(*track).eta()<<" phi "<<(*track).phi()<<" Outer "<<(*track).outerMomentum()<<" "<<
00155            (*track).outerPosition()<<endl;
00156            TrackExtraRef myextra = (*track).extra();
00157            cout<<" Track extra "<<myextra->outerMomentum()<<" "<<myextra->outerPosition()<<endl;
00158          }  
00159 
00160    edm::Handle<EcalRecHitCollection> ecal;
00161    iEvent.getByLabel(nameProd_,ecalInput_,ecal);
00162    const EcalRecHitCollection Hitecal = *(ecal.product());
00163    std::cout<<" Size of Ecal "<<(Hitecal).size()<<std::endl;
00164    EcalRecHitCollection::const_iterator hite = (ecal.product())->begin ();
00165 
00166          double energyECAL = 0.;
00167          double energyHCAL = 0.;
00168 
00169           for (; hite != (ecal.product())->end (); hite++)
00170          {
00171 
00172 //           cout<<" Energy ECAL "<<(*hite).energy()<<endl;
00173 
00174 
00175 //         " eta "<<(*hite).detid()<<" phi "<<(*hite).detid().getPosition().phi()<<endl;
00176 
00177          GlobalPoint posE = geo->getPosition((*hite).detid());
00178 
00179            cout<<" Energy ECAL "<<(*hite).energy()<<
00180            " eta "<<posE.eta()<<" phi "<<posE.phi()<<endl;
00181 
00182          energyECAL = energyECAL + (*hite).energy();
00183          
00184          }
00185 
00186    edm::Handle<HBHERecHitCollection> hbhe;
00187    iEvent.getByLabel(nameProd_,hbheInput_,hbhe);
00188    const HBHERecHitCollection Hithbhe = *(hbhe.product());
00189    std::cout<<" Size of HBHE "<<(Hithbhe).size()<<std::endl;
00190    HBHERecHitCollection::const_iterator hith = (hbhe.product())->begin ();
00191 
00192           for (; hith != (hbhe.product())->end (); hith++)
00193          {
00194 
00195          GlobalPoint posH = geo->getPosition((*hith).detid());
00196 
00197            cout<<" Energy HCAL "<<(*hith).energy()<<
00198            " eta "<<posH.eta()<<" phi "<<posH.phi()<<endl;
00199 
00200          energyHCAL = energyHCAL + (*hith).energy();
00201          
00202          }
00203    
00204    cout<<" Energy ECAL "<< energyECAL<<" Energy HCAL "<< energyHCAL<<endl;
00205    
00206    edm::Handle<HORecHitCollection> ho;
00207    iEvent.getByLabel(nameProd_,hoInput_,ho);
00208    const HORecHitCollection Hitho = *(ho.product());
00209    std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
00210    HORecHitCollection::const_iterator hito = (ho.product())->begin ();
00211 
00212           for (; hito != (ho.product())->end (); hito++)
00213          {
00214 //           cout<<" Energy HO    "<<(*hito).energy()<<endl;
00215 //         " eta "<<(*hite).eta()<<" phi "<<(*hite).phi()<<endl;
00216          }
00217 
00218    }
00219    
00220    
00221    if(nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd")
00222    {
00223     cout<<" we are in GammaJetProd area "<<endl;
00224    edm::Handle<EcalRecHitCollection> ecal;
00225    iEvent.getByLabel(nameProd_,ecalInput_, ecal);
00226    std::cout<<" Size of ECAL "<<(*ecal).size()<<std::endl;
00227 
00228    edm::Handle<reco::CaloJetCollection> jets;
00229    iEvent.getByLabel(nameProd_,jetCalo_, jets);
00230    std::cout<<" Jet size "<<(*jets).size()<<std::endl; 
00231    reco::CaloJetCollection::const_iterator jet = jets->begin ();
00232           for (; jet != jets->end (); jet++)
00233          {
00234            cout<<" Et jet "<<(*jet).et()<<" eta "<<(*jet).eta()<<" phi "<<(*jet).phi()<<endl;
00235          }  
00236 
00237    edm::Handle<reco::TrackCollection> tracks;
00238    iEvent.getByLabel(nameProd_,Tracks_, tracks);
00239    std::cout<<" Tracks size "<<(*tracks).size()<<std::endl; 
00240    }
00241    if( nameProd_ == "GammaJetProd")
00242    {
00243    edm::Handle<reco::SuperClusterCollection> eclus;
00244    iEvent.getByLabel(nameProd_,gammaClus_, eclus);
00245    std::cout<<" GammaClus size "<<(*eclus).size()<<std::endl;
00246       reco::SuperClusterCollection::const_iterator iclus = eclus->begin ();
00247           for (; iclus != eclus->end (); iclus++)
00248          {
00249            cout<<" Et gamma "<<(*iclus).energy()/cosh((*iclus).eta())<<" eta "<<(*iclus).eta()<<" phi "<<(*iclus).phi()<<endl;
00250          }
00251    }
00252 
00253 }
00254 //define this as a plug-in
00255 //DEFINE_ANOTHER_FWK_MODULE(ProducerAnalyzer)
00256 }

Generated on Tue Jun 9 17:25:34 2009 for CMSSW by  doxygen 1.5.4