CMS 3D CMS Logo

cms::AlCaDiJetsProducer Class Reference

#include <Calibration/HcalAlCaRecoProducers/interface/AlCaDiJetsProducer.h>

Inheritance diagram for cms::AlCaDiJetsProducer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 AlCaDiJetsProducer (const edm::ParameterSet &)
virtual void beginJob (const edm::EventSetup &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~AlCaDiJetsProducer ()

Private Attributes

bool allowMissingInputs_
std::vector< edm::InputTagecalLabels_
edm::InputTag hbheInput_
edm::InputTag hfInput_
edm::InputTag hoInput_
edm::InputTag jetsInput_


Detailed Description

Definition at line 38 of file AlCaDiJetsProducer.h.


Constructor & Destructor Documentation

cms::AlCaDiJetsProducer::AlCaDiJetsProducer ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 17 of file AlCaDiJetsProducer.cc.

References allowMissingInputs_, ecalLabels_, edm::ParameterSet::getParameter(), hbheInput_, hfInput_, hoInput_, and jetsInput_.

00018 {
00019    jetsInput_ = iConfig.getParameter<edm::InputTag>("jetsInput");
00020    ecalLabels_=iConfig.getParameter<std::vector<edm::InputTag> >("ecalInputs");
00021    hbheInput_ = iConfig.getParameter<edm::InputTag>("hbheInput");
00022    hoInput_ = iConfig.getParameter<edm::InputTag>("hoInput");
00023    hfInput_ = iConfig.getParameter<edm::InputTag>("hfInput"); 
00024    allowMissingInputs_ = true;
00025 
00026 //register your products
00027    produces<CaloJetCollection>("DiJetsBackToBackCollection");
00028    produces<EcalRecHitCollection>("DiJetsEcalRecHitCollection");
00029    produces<HBHERecHitCollection>("DiJetsHBHERecHitCollection");
00030    produces<HORecHitCollection>("DiJetsHORecHitCollection");
00031    produces<HFRecHitCollection>("DiJetsHFRecHitCollection");
00032 
00033 }

cms::AlCaDiJetsProducer::~AlCaDiJetsProducer (  ) 

Definition at line 38 of file AlCaDiJetsProducer.cc.

00039 {
00040  
00041 
00042 }


Member Function Documentation

void cms::AlCaDiJetsProducer::beginJob ( const edm::EventSetup iSetup  )  [virtual]

Reimplemented from edm::EDProducer.

Definition at line 34 of file AlCaDiJetsProducer.cc.

00035 {
00036 }

void cms::AlCaDiJetsProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 47 of file AlCaDiJetsProducer.cc.

References allowMissingInputs_, GenMuonPlsPt100GeV_cfg::cout, e, ecalLabels_, lat::endl(), eta, PV3DBase< T, PVType, FrameType >::eta(), edm::EventSetup::get(), edm::Event::getByLabel(), CaloGeometry::getPosition(), hbheInput_, hfInput_, hoInput_, i, pfTauBenchmarkGeneric_cfi::jets, jetsInput_, PV3DBase< T, PVType, FrameType >::phi(), phi, reco::Particle::phi(), pi, edm::ESHandle< T >::product(), edm::Event::put(), HLT_VtxMuL3::result, and funct::sqrt().

00048 {
00049 
00050   double pi = 4.*atan(1.);
00051 
00052    std::auto_ptr<CaloJetCollection> result (new CaloJetCollection); //Corrected jets
00053    std::auto_ptr<EcalRecHitCollection> miniDiJetsEcalRecHitCollection(new EcalRecHitCollection);
00054    std::auto_ptr<HBHERecHitCollection> miniDiJetsHBHERecHitCollection(new HBHERecHitCollection);
00055    std::auto_ptr<HORecHitCollection> miniDiJetsHORecHitCollection(new HORecHitCollection);
00056    std::auto_ptr<HFRecHitCollection> miniDiJetsHFRecHitCollection(new HFRecHitCollection);
00057 
00058    edm::ESHandle<CaloGeometry> pG;
00059    iSetup.get<CaloGeometryRecord>().get(pG);
00060    const CaloGeometry* geo = pG.product();
00061 
00062   // Jets Collections 
00063 
00064    vector<CaloJet> jetv; 
00065    try {
00066    CaloJet fJet1, fJet2, fJet3;
00067    edm::Handle<CaloJetCollection> jets;                
00068    iEvent.getByLabel(jetsInput_, jets);    
00069    int iflag_select = 0; 
00070    if(jets->size()>1){
00071     fJet1 = (*jets)[0];
00072     fJet2 = (*jets)[1];
00073     double dphi = fabs(fJet1.phi() - fJet2.phi());  
00074     if(dphi > pi){dphi = 2*pi - dphi;}
00075     double degreedphi = dphi*180./pi; 
00076     if(fabs(degreedphi-180)<30.){iflag_select = 1;}
00077    }
00078    if(iflag_select == 1){
00079      result->push_back(fJet1);
00080      result->push_back(fJet2);
00081      jetv.push_back(fJet1); 
00082      jetv.push_back(fJet2); 
00083      if(jets->size()>2){
00084      fJet3 = (*jets)[2]; 
00085      result->push_back(fJet3);
00086      jetv.push_back(fJet3);
00087      }     
00088    } else {
00089      iEvent.put( result, "DiJetsBackToBackCollection");
00090      iEvent.put( miniDiJetsEcalRecHitCollection,"DiJetsEcalRecHitCollection");
00091      iEvent.put( miniDiJetsHBHERecHitCollection, "DiJetsHBHERecHitCollection");
00092      iEvent.put( miniDiJetsHORecHitCollection, "DiJetsHORecHitCollection");
00093      iEvent.put( miniDiJetsHFRecHitCollection, "DiJetsHFRecHitCollection");
00094      return;
00095    }  
00096    } catch (cms::Exception& e) { // can't find it!
00097      if (!allowMissingInputs_) { cout << "No jets collection" << endl; throw e; }  
00098    }
00099 
00100   // Ecal Collections 
00101 
00102    std::vector<edm::InputTag>::const_iterator i;
00103    for (i=ecalLabels_.begin(); i!=ecalLabels_.end(); i++) {
00104    try {
00105    edm::Handle<EcalRecHitCollection> ec;
00106    iEvent.getByLabel(*i,ec);
00107    for(EcalRecHitCollection::const_iterator ecItr = (*ec).begin();
00108                                                  ecItr != (*ec).end(); ++ecItr)
00109         {
00110 // EcalBarrel = 1, EcalEndcap = 2
00111           GlobalPoint pos = geo->getPosition(ecItr->detid());
00112           double phihit = pos.phi();
00113           double etahit = pos.eta();
00114           int iflag_select = 0;  
00115           for(unsigned int i=0; i<jetv.size(); i++){
00116             double deta = fabs(etahit - jetv[i].eta());
00117             double dphi = fabs(phihit - jetv[i].phi());
00118             if(dphi > pi) dphi = 2*pi - dphi;
00119             double dr = sqrt(deta*deta+dphi*dphi);
00120             if(dr < 1.4){iflag_select = 1;}
00121           }  
00122           if(iflag_select==1){miniDiJetsEcalRecHitCollection->push_back(*ecItr);}
00123        }
00124 
00125    } catch (cms::Exception& e) { // can't find it!
00126      if (!allowMissingInputs_) { cout << "No Ecal Collections" << endl; throw e;}
00127    }
00128    }
00129 
00130   // HB & HE Collections 
00131    
00132    try {
00133    edm::Handle<HBHERecHitCollection> hbhe;
00134    iEvent.getByLabel(hbheInput_,hbhe);
00135    for(HBHERecHitCollection::const_iterator hbheItr=hbhe->begin(); 
00136                                                   hbheItr!=hbhe->end(); hbheItr++)
00137         {
00138           GlobalPoint pos = geo->getPosition(hbheItr->detid());
00139           double phihit = pos.phi();
00140           double etahit = pos.eta();
00141           int iflag_select = 0;  
00142           for(unsigned int i=0; i<jetv.size(); i++){
00143             double deta = fabs(etahit - jetv[i].eta());
00144             double dphi = fabs(phihit - jetv[i].phi());
00145             if(dphi > pi) dphi = 2*pi - dphi;
00146             double dr = sqrt(deta*deta+dphi*dphi);
00147             if(dr < 1.4){iflag_select = 1;}
00148           }  
00149           if(iflag_select==1){miniDiJetsHBHERecHitCollection->push_back(*hbheItr);}
00150         }
00151    } catch (cms::Exception& e) { // can't find it!
00152      if (!allowMissingInputs_) {cout<<"No HBHE collection "<<endl; throw e;}
00153    }
00154 
00155 // HO Collections 
00156 
00157    try{  
00158    edm::Handle<HORecHitCollection> ho;
00159    iEvent.getByLabel(hoInput_,ho);
00160    for(HORecHitCollection::const_iterator hoItr=ho->begin(); 
00161                                                 hoItr!=ho->end(); hoItr++)
00162      {
00163           GlobalPoint pos = geo->getPosition(hoItr->detid());
00164           double phihit = pos.phi();
00165           double etahit = pos.eta();
00166           int iflag_select = 0;  
00167           for(unsigned int i=0; i<jetv.size(); i++){
00168             double deta = fabs(etahit - jetv[i].eta());
00169             double dphi = fabs(phihit - jetv[i].phi());
00170             if(dphi > pi) dphi = 2*pi - dphi;
00171             double dr = sqrt(deta*deta+dphi*dphi);
00172             if(dr < 1.4){iflag_select = 1;}
00173           }  
00174           if(iflag_select==1){miniDiJetsHORecHitCollection->push_back(*hoItr);}
00175         }
00176    } catch (cms::Exception& e) { // can't find it!
00177      if (!allowMissingInputs_) {cout<<" No HO collection "<<endl; throw e;}
00178    }
00179 
00180   // HF Collection
00181 
00182    try {
00183    edm::Handle<HFRecHitCollection> hf;
00184    iEvent.getByLabel(hfInput_,hf);
00185    for(HFRecHitCollection::const_iterator hfItr=hf->begin(); 
00186                                                 hfItr!=hf->end(); hfItr++)
00187        {
00188           GlobalPoint pos = geo->getPosition(hfItr->detid());
00189           double phihit = pos.phi();
00190           double etahit = pos.eta();
00191           int iflag_select = 0;  
00192           for(unsigned int i=0; i<jetv.size(); i++){
00193             double deta = fabs(etahit - jetv[i].eta());
00194             double dphi = fabs(phihit - jetv[i].phi());
00195             if(dphi > pi) dphi = 2*pi - dphi;
00196             double dr = sqrt(deta*deta+dphi*dphi);
00197             if(dr < 1.4){iflag_select = 1;}
00198           }  
00199           if(iflag_select==1){miniDiJetsHFRecHitCollection->push_back(*hfItr);}
00200        }
00201    } catch (cms::Exception& e) { // can't find it!
00202      if (!allowMissingInputs_) throw e;
00203    }
00204 
00205   //Put selected information in the event
00206 
00207    iEvent.put( result, "DiJetsBackToBackCollection");
00208    iEvent.put( miniDiJetsEcalRecHitCollection,"DiJetsEcalRecHitCollection");
00209    iEvent.put( miniDiJetsHBHERecHitCollection, "DiJetsHBHERecHitCollection");
00210    iEvent.put( miniDiJetsHORecHitCollection, "DiJetsHORecHitCollection");
00211    iEvent.put( miniDiJetsHFRecHitCollection, "DiJetsHFRecHitCollection");
00212 }


Member Data Documentation

bool cms::AlCaDiJetsProducer::allowMissingInputs_ [private]

Definition at line 54 of file AlCaDiJetsProducer.h.

Referenced by AlCaDiJetsProducer(), and produce().

std::vector<edm::InputTag> cms::AlCaDiJetsProducer::ecalLabels_ [private]

Definition at line 49 of file AlCaDiJetsProducer.h.

Referenced by AlCaDiJetsProducer(), and produce().

edm::InputTag cms::AlCaDiJetsProducer::hbheInput_ [private]

Definition at line 50 of file AlCaDiJetsProducer.h.

Referenced by AlCaDiJetsProducer(), and produce().

edm::InputTag cms::AlCaDiJetsProducer::hfInput_ [private]

Definition at line 52 of file AlCaDiJetsProducer.h.

Referenced by AlCaDiJetsProducer(), and produce().

edm::InputTag cms::AlCaDiJetsProducer::hoInput_ [private]

Definition at line 51 of file AlCaDiJetsProducer.h.

Referenced by AlCaDiJetsProducer(), and produce().

edm::InputTag cms::AlCaDiJetsProducer::jetsInput_ [private]

Definition at line 48 of file AlCaDiJetsProducer.h.

Referenced by AlCaDiJetsProducer(), and produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:36:22 2009 for CMSSW by  doxygen 1.5.4