CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/RecoLocalCalo/CaloTowersCreator/src/CaloTowerCandidateCreator.cc

Go to the documentation of this file.
00001 // makes CaloTowerCandidates from CaloTowers
00002 // original author: L.Lista INFN
00003 // modifyed by: F.Ratnikov UMd
00004 // $Id: CaloTowerCandidateCreator.cc,v 1.10 2008/03/04 04:47:26 anastass Exp $
00005 #include <cmath>
00006 #include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
00007 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "FWCore/Framework/interface/Event.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "RecoLocalCalo/CaloTowersCreator/src/CaloTowerCandidateCreator.h"
00012 using namespace edm;
00013 using namespace reco;
00014 using namespace std;
00015 
00016 CaloTowerCandidateCreator::CaloTowerCandidateCreator( const ParameterSet & p ) 
00017   :
00018   mVerbose (p.getUntrackedParameter<int> ("verbose", 0)),
00019   mSource (p.getParameter<edm::InputTag> ("src")),
00020   mEtThreshold (p.getParameter<double> ("minimumEt")),
00021   mEThreshold (p.getParameter<double> ("minimumE"))
00022 {
00023   produces<CandidateCollection>();
00024 }
00025 
00026 CaloTowerCandidateCreator::~CaloTowerCandidateCreator() {
00027 }
00028 
00029 void CaloTowerCandidateCreator::produce( Event& evt, const EventSetup& ) {
00030   Handle<CaloTowerCollection> caloTowers;
00031   evt.getByLabel( mSource, caloTowers );
00032   
00033   auto_ptr<CandidateCollection> cands( new CandidateCollection );
00034   cands->reserve( caloTowers->size() );
00035   unsigned idx = 0;
00036   for (; idx < caloTowers->size (); idx++) {
00037     const CaloTower* cal = &((*caloTowers) [idx]);
00038     if (mVerbose >= 2) {
00039       std::cout << "CaloTowerCandidateCreator::produce-> " << idx << " tower et/eta/phi/e: " 
00040                 << cal->et() << '/' << cal->eta() << '/' << cal->phi() << '/' << cal->energy() << " is...";
00041     }
00042     if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold ) {
00043       math::PtEtaPhiMLorentzVector p( cal->et(), cal->eta(), cal->phi(), 0 );
00044       RecoCaloTowerCandidate * c = 
00045         new RecoCaloTowerCandidate( 0, Candidate::LorentzVector( p ) );
00046       c->setCaloTower (CaloTowerRef( caloTowers, idx) );
00047       cands->push_back( c );
00048       if (mVerbose >= 2) std::cout << "accepted: pT/eta/phi:" << c->pt() << '/' << c->eta() <<  '/' << c->phi() <<std::endl;
00049     }
00050     else {
00051       if (mVerbose >= 2) std::cout << "rejected" << std::endl;
00052     }
00053   }
00054   if (mVerbose >= 1) {
00055     std::cout << "CaloTowerCandidateCreator::produce-> " << cands->size () << " candidates created" << std::endl;
00056   }
00057   evt.put( cands );
00058 }