CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Calibration/HcalIsolatedTrackReco/src/EcalIsolatedParticleCandidateProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EcalIsolatedParticleCandidateProducer
00004 // Class:      EcalIsolatedParticleCandidateProducer
00005 // 
00013 //
00014 // Original Author:  Grigory Safronov
00015 //         Created:  Thu Jun  7 17:21:58 MSD 2007
00016 // $Id: EcalIsolatedParticleCandidateProducer.cc,v 1.9 2010/01/13 22:25:52 wmtan Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 
00026 #include "FWCore/Framework/interface/EventSetup.h"
00027 
00028 
00029 #include "DataFormats/Common/interface/Ref.h"
00030 #include "DataFormats/DetId/interface/DetId.h"
00031 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00032 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
00033 
00034 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00035 
00036 #include "Calibration/HcalIsolatedTrackReco/interface/EcalIsolatedParticleCandidateProducer.h"
00037 
00038 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00039 
00040 
00041 
00042 EcalIsolatedParticleCandidateProducer::EcalIsolatedParticleCandidateProducer(const edm::ParameterSet& conf)
00043 {
00044   InConeSize_ = conf.getParameter<double>("EcalInnerConeSize");
00045   OutConeSize_= conf.getParameter<double>("EcalOuterConeSize");
00046   hitCountEthr_= conf.getParameter<double>("ECHitCountEnergyThreshold");
00047   hitEthr_=conf.getParameter<double>("ECHitEnergyThreshold");
00048   l1tausource_=conf.getParameter<edm::InputTag>("L1eTauJetsSource");
00049   hltGTseedlabel_=conf.getParameter<edm::InputTag>("L1GTSeedLabel");
00050   EBrecHitCollectionLabel_=conf.getParameter<edm::InputTag>("EBrecHitCollectionLabel");
00051   EErecHitCollectionLabel_=conf.getParameter<edm::InputTag>("EErecHitCollectionLabel");
00052 
00053    //register your products
00054   produces< reco::IsolatedPixelTrackCandidateCollection >();
00055 
00056 }
00057 
00058 
00059 EcalIsolatedParticleCandidateProducer::~EcalIsolatedParticleCandidateProducer()
00060 {
00061  
00062    // do anything here that needs to be done at desctruction time
00063    // (e.g. close files, deallocate resources etc.)
00064 
00065 }
00066 
00067 
00068 //
00069 // member functions
00070 //
00071 
00072 // ------------ method called to produce the data  ------------
00073 void 
00074 EcalIsolatedParticleCandidateProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00075 {
00076  
00077   using namespace edm;
00078 
00079 //  std::cout<<"get tau"<<std::endl;
00080 
00081   Handle<l1extra::L1JetParticleCollection> l1Taus;
00082   iEvent.getByLabel(l1tausource_,l1Taus);
00083 
00084 //  std::cout<<"get geom"<<std::endl;
00085 
00086   ESHandle<CaloGeometry> pG;
00087   iSetup.get<CaloGeometryRecord>().get(pG);
00088   geo = pG.product();
00089 
00090 //  std::cout<<" get ec rechit"<<std::endl;
00091 
00092   Handle<EcalRecHitCollection> ecalEB;
00093   iEvent.getByLabel(EBrecHitCollectionLabel_,ecalEB);
00094 
00095   Handle<EcalRecHitCollection> ecalEE;
00096   iEvent.getByLabel(EErecHitCollectionLabel_,ecalEE);
00097 
00098 //  std::cout<<"get l1 trig obj"<<std::endl;
00099 
00100   Handle<trigger::TriggerFilterObjectWithRefs> l1trigobj;
00101   iEvent.getByLabel(hltGTseedlabel_, l1trigobj);
00102 
00103   std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
00104   std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
00105 
00106   l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
00107   l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
00108    
00109   double ptTriggered=-10;
00110   double etaTriggered=-100;
00111   double phiTriggered=-100;
00112 
00113 //  std::cout<<"find highest pT triggered obj"<<std::endl;
00114 
00115   for (unsigned int p=0; p<l1tauobjref.size(); p++)
00116         {
00117         if (l1tauobjref[p]->pt()>ptTriggered)
00118                 {
00119                 ptTriggered=l1tauobjref[p]->pt();
00120                 phiTriggered=l1tauobjref[p]->phi();
00121                 etaTriggered=l1tauobjref[p]->eta();
00122                 }
00123         }
00124   for (unsigned int p=0; p<l1jetobjref.size(); p++)
00125         {
00126         if (l1jetobjref[p]->pt()>ptTriggered)
00127                 {
00128                 ptTriggered=l1jetobjref[p]->pt();
00129                 phiTriggered=l1jetobjref[p]->phi();
00130                 etaTriggered=l1jetobjref[p]->eta();
00131                 }
00132         }
00133 
00134   reco::IsolatedPixelTrackCandidateCollection * iptcCollection=new reco::IsolatedPixelTrackCandidateCollection;
00135 
00136 //  std::cout<<"loop over l1taus"<<std::endl;
00137 
00138   for (l1extra::L1JetParticleCollection::const_iterator tit=l1Taus->begin(); tit!=l1Taus->end(); tit++)
00139         {
00140         double dphi=fabs(tit->phi()-phiTriggered);
00141         if (dphi>3.1415926535) dphi=2*3.1415926535-dphi;
00142         double Rseed=sqrt(pow(etaTriggered-tit->eta(),2)+dphi*dphi);
00143         if (Rseed<1.2) continue;
00144         int nhitOut=0;
00145         int nhitIn=0;
00146         double OutEnergy=0;
00147         double InEnergy=0;
00148 //      std::cout<<" loops over rechits"<<std::endl;
00149         for (EcalRecHitCollection::const_iterator eItr=ecalEB->begin(); eItr!=ecalEB->end(); eItr++)
00150                 {
00151                 double phiD, R;
00152                 GlobalPoint pos = geo->getPosition(eItr->detid());
00153                 double phihit = pos.phi();
00154                 double etahit = pos.eta();
00155                 phiD=fabs(phihit-tit->phi());
00156                 if (phiD>3.1415926535) phiD=2*3.1415926535-phiD;
00157                 R=sqrt(pow(etahit-tit->eta(),2)+phiD*phiD);
00158                 
00159                 if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitCountEthr_)
00160                         {
00161                         nhitOut++;
00162                         }
00163                 if (R<InConeSize_&&eItr->energy()>hitCountEthr_)
00164                         {
00165                         nhitIn++;
00166                         }
00167 
00168                 if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitEthr_)
00169                         {
00170                         OutEnergy+=eItr->energy();
00171                         }
00172                 if (R<InConeSize_&&eItr->energy()>hitEthr_)
00173                         {
00174                         InEnergy+=eItr->energy();
00175                         }
00176 
00177                 }
00178 
00179         for (EcalRecHitCollection::const_iterator eItr=ecalEE->begin(); eItr!=ecalEE->end(); eItr++)
00180                 {
00181                 double phiD, R;
00182                 GlobalPoint pos = geo->getPosition(eItr->detid());
00183                 double phihit = pos.phi();
00184                 double etahit = pos.eta();
00185                 phiD=fabs(phihit-tit->phi());
00186                 if (phiD>3.1415926535) phiD=2*3.1415926535-phiD;
00187                 R=sqrt(pow(etahit-tit->eta(),2)+phiD*phiD);
00188                 if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitCountEthr_)
00189                         {
00190                         nhitOut++;
00191                         }
00192                 if (R<InConeSize_&&eItr->energy()>hitCountEthr_)
00193                         {
00194                         nhitIn++;
00195                         }
00196                 if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitEthr_)
00197                         {
00198                         OutEnergy+=eItr->energy();
00199                         }
00200                 if (R<InConeSize_&&eItr->energy()>hitEthr_)
00201                         {
00202                         InEnergy+=eItr->energy();
00203                         }
00204 
00205                 }
00206 //      std::cout<<"create and push_back candidate"<<std::endl;
00207         reco::IsolatedPixelTrackCandidate newca(l1extra::L1JetParticleRef(l1Taus,tit-l1Taus->begin()), InEnergy, OutEnergy, nhitIn, nhitOut);
00208         iptcCollection->push_back(newca);       
00209         }
00210 
00211 
00212   
00213   //Use the ExampleData to create an ExampleData2 which 
00214   // is put into the Event
00215   
00216 //  std::cout<<"put cand into event"<<std::endl;
00217   std::auto_ptr<reco::IsolatedPixelTrackCandidateCollection> pOut(iptcCollection);
00218   iEvent.put(pOut);
00219 
00220 }
00221 // ------------ method called once each job just before starting event loop  ------------
00222 void 
00223 EcalIsolatedParticleCandidateProducer::beginJob() {
00224 }
00225 
00226 // ------------ method called once each job just after ending the event loop  ------------
00227 void 
00228 EcalIsolatedParticleCandidateProducer::endJob() {
00229 }
00230