#include <RecoBTag/JetCrystalsAssociator/src/JetCrystalsAssociator.cc>
Public Member Functions | |
JetCrystalsAssociator (const edm::ParameterSet &) | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
~JetCrystalsAssociator () | |
Private Member Functions | |
std::auto_ptr < JetCrystalsAssociationCollection > | associate (const edm::Handle< CaloJetCollection > &jets, const edm::OrphanHandle< EMLorentzVectorCollection > &myLorentzRecHits) const |
Private Attributes | |
double | m_deltaRCut |
edm::InputTag | m_EBRecHits |
edm::InputTag | m_EERecHits |
edm::InputTag | m_jetsSrc |
Implementation: <Notes on="" implementation>="">
Definition at line 67 of file JetCrystalsAssociator.cc.
JetCrystalsAssociator::JetCrystalsAssociator | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 89 of file JetCrystalsAssociator.cc.
References edm::ParameterSet::getParameter(), m_deltaRCut, m_EBRecHits, m_EERecHits, and m_jetsSrc.
00090 { 00091 produces<reco::JetCrystalsAssociationCollection>(); 00092 produces<reco::EMLorentzVectorCollection>(); 00093 00094 m_EBRecHits = iConfig.getParameter<edm::InputTag>("EBRecHits"); 00095 m_EERecHits = iConfig.getParameter<edm::InputTag>("EERecHits"); 00096 m_jetsSrc = iConfig.getParameter<edm::InputTag>("jets"); 00097 m_deltaRCut = iConfig.getParameter<double>("coneSize"); 00098 }
JetCrystalsAssociator::~JetCrystalsAssociator | ( | ) |
Definition at line 101 of file JetCrystalsAssociator.cc.
00102 { 00103 00104 // do anything here that needs to be done at desctruction time 00105 // (e.g. close files, deallocate resources etc.) 00106 00107 }
std::auto_ptr< JetCrystalsAssociationCollection > JetCrystalsAssociator::associate | ( | const edm::Handle< CaloJetCollection > & | jets, | |
const edm::OrphanHandle< EMLorentzVectorCollection > & | myLorentzRecHits | |||
) | const [private] |
Definition at line 210 of file JetCrystalsAssociator.cc.
References j, m_deltaRCut, p4, and t.
Referenced by produce().
00213 { 00214 // we know we will save an element per input jet 00215 std::auto_ptr<JetCrystalsAssociationCollection> outputCollection( new JetCrystalsAssociationCollection( jets->size() ) ); 00216 00217 //loop on jets and associate 00218 for (size_t j = 0; j < jets->size(); j++) { 00219 (*outputCollection)[j].first = edm::RefToBase<Jet>(CaloJetRef(jets, j)); 00220 for (size_t t = 0; t < myLorentzRecHits->size(); t++) { 00221 double delta = ROOT::Math::VectorUtil::DeltaR((*jets)[j].p4().Vect(), (*myLorentzRecHits)[t]); 00222 if (delta < m_deltaRCut) 00223 (*outputCollection)[j].second.push_back( EMLorentzVectorRef(myLorentzRecHits, t) ); 00224 } 00225 } 00226 return outputCollection; 00227 }
void JetCrystalsAssociator::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 116 of file JetCrystalsAssociator.cc.
References associate(), DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, relval_parameters_module::energy, eta, PV3DBase< T, PVType, FrameType >::eta(), edm::EventSetup::get(), edm::Event::getByLabel(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), j, pfTauBenchmarkGeneric_cfi::jets, m_EBRecHits, m_EERecHits, m_jetsSrc, p, PV3DBase< T, PVType, FrameType >::phi(), phi, edm::Event::put(), HcalSimpleRecAlgoImpl::reco(), funct::sin(), std, DetId::subdetId(), t, theta, and PV3DBase< T, PVType, FrameType >::theta().
00117 { 00118 using namespace edm; 00119 using namespace reco; 00120 using namespace std; 00121 00122 // geometry initialization 00123 ESHandle<CaloGeometry> geometry; 00124 iSetup.get<CaloGeometryRecord>().get(geometry); 00125 00126 const CaloSubdetectorGeometry* EB = geometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel); 00127 const CaloSubdetectorGeometry* EE = geometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap); 00128 // end 00129 00130 Handle<CaloJetCollection> jets; 00131 iEvent.getByLabel(m_jetsSrc, jets); 00132 00133 // get calo towers collection 00134 // Handle<CaloTowerCollection> caloTowers; 00135 // iEvent.getByLabel(m_towersSrc, caloTowers); 00136 00137 // calculation of ECAL isolation 00138 Handle<EBRecHitCollection> EBRecHits; 00139 Handle<EERecHitCollection> EERecHits; 00140 iEvent.getByLabel( m_EBRecHits, EBRecHits ); 00141 iEvent.getByLabel( m_EERecHits, EERecHits ); 00142 00143 std::auto_ptr<EMLorentzVectorCollection> jetRecHits( new EMLorentzVectorCollection() ); 00144 //loop on jets and associate 00145 for (size_t t = 0; t < jets->size(); t++) 00146 { 00147 const std::vector<CaloTowerPtr> myTowers=(*jets)[t].getCaloConstituents(); 00148 // cout <<"Jet id "<<t<<endl; 00149 // cout <<"Tower size "<<myTowers.size()<<endl; 00150 for (unsigned int iTower = 0; iTower < myTowers.size(); iTower++) 00151 { 00152 CaloTowerPtr theTower = myTowers[iTower]; 00153 size_t numRecHits = theTower->constituentsSize(); 00154 // access CaloRecHits 00155 for (size_t j = 0; j < numRecHits; j++) { 00156 DetId RecHitDetID=theTower->constituent(j); 00157 DetId::Detector DetNum=RecHitDetID.det(); 00158 if( DetNum == DetId::Ecal ){ 00159 int EcalNum = RecHitDetID.subdetId(); 00160 if( EcalNum == 1 ){ 00161 EBDetId EcalID = RecHitDetID; 00162 EBRecHitCollection::const_iterator theRecHit=EBRecHits->find(EcalID); 00163 if(theRecHit != EBRecHits->end()){ 00164 DetId id = theRecHit->detid(); 00165 const CaloCellGeometry* this_cell = EB->getGeometry(id); 00166 if (this_cell) { 00167 GlobalPoint posi = this_cell->getPosition(); 00168 double energy = theRecHit->energy(); 00169 double eta = posi.eta(); 00170 double phi = posi.phi(); 00171 double theta = posi.theta(); 00172 if(theta > M_PI) theta = 2 * M_PI- theta; 00173 double et = energy * sin(theta); 00174 // cout <<"Et "<<et<<endl; 00175 EMLorentzVector p(et, eta, phi, energy); 00176 jetRecHits->push_back(p); 00177 } 00178 } 00179 } else if ( EcalNum == 2 ) { 00180 EEDetId EcalID = RecHitDetID; 00181 EERecHitCollection::const_iterator theRecHit=EERecHits->find(EcalID); 00182 if(theRecHit != EBRecHits->end()){ 00183 DetId id = theRecHit->detid(); 00184 const CaloCellGeometry* this_cell = EE->getGeometry(id); 00185 if (this_cell) { 00186 GlobalPoint posi = this_cell->getPosition(); 00187 double energy = theRecHit->energy(); 00188 double eta = posi.eta(); 00189 double phi = posi.phi(); 00190 double theta = posi.theta(); 00191 if (theta > M_PI) theta = 2 * M_PI - theta; 00192 double et = energy * sin(theta); 00193 // cout <<"Et "<<et<<endl; 00194 EMLorentzVector p(et, eta, phi, energy); 00195 jetRecHits->push_back(p); 00196 } 00197 } 00198 } 00199 } 00200 } 00201 } 00202 } 00203 00204 edm::OrphanHandle <reco::EMLorentzVectorCollection> myRecHits = iEvent.put(jetRecHits); 00205 00206 std::auto_ptr<JetCrystalsAssociationCollection> jetCrystals = associate(jets,myRecHits); 00207 iEvent.put( jetCrystals ); 00208 }
double JetCrystalsAssociator::m_deltaRCut [private] |
Definition at line 86 of file JetCrystalsAssociator.cc.
Referenced by associate(), and JetCrystalsAssociator().
Definition at line 83 of file JetCrystalsAssociator.cc.
Referenced by JetCrystalsAssociator(), and produce().
Definition at line 84 of file JetCrystalsAssociator.cc.
Referenced by JetCrystalsAssociator(), and produce().
Definition at line 82 of file JetCrystalsAssociator.cc.
Referenced by JetCrystalsAssociator(), and produce().