CMS 3D CMS Logo

Public Member Functions | Private Attributes

ReduceHcalRecHitCollectionProducer Class Reference

Inheritance diagram for ReduceHcalRecHitCollectionProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Attributes

edm::InputTag inputCollection_
TrackAssociatorParameters parameters_
double ptcut_
edm::InputTag recHitsLabel_
std::string reducedHitsCollection_
TrackDetectorAssociator trackAssociator_

Detailed Description

Definition at line 66 of file ReduceHcalRecHitCollectionProducer.cc.


Constructor & Destructor Documentation

ReduceHcalRecHitCollectionProducer::ReduceHcalRecHitCollectionProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 93 of file ReduceHcalRecHitCollectionProducer.cc.

References edm::ParameterSet::getParameter(), inputCollection_, TrackAssociatorParameters::loadParameters(), Parameters::parameters, parameters_, ptcut_, recHitsLabel_, reducedHitsCollection_, trackAssociator_, and TrackDetectorAssociator::useDefaultPropagator().

{
  recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel");

  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
  
   //register your products
  produces< HBHERecHitCollection > (reducedHitsCollection_) ;

    inputCollection_ = iConfig.getParameter< edm::InputTag >("inputCollection");    ptcut_= iConfig.getParameter< double >("TrackPt");

    produces< DetIdCollection >() ;
   // TrackAssociator parameters
   edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
   parameters_.loadParameters( parameters );
   trackAssociator_.useDefaultPropagator();
 
}
ReduceHcalRecHitCollectionProducer::~ReduceHcalRecHitCollectionProducer ( )

Definition at line 113 of file ReduceHcalRecHitCollectionProducer.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 128 of file ReduceHcalRecHitCollectionProducer.cc.

References TrackDetectorAssociator::associate(), TrackDetMatchInfo::crossedHcalIds, edm::Event::getByLabel(), TrackDetMatchInfo::hcalRecHits, info, inputCollection_, TrackDetectorAssociator::InsideOut, parameters_, ptcut_, edm::Event::put(), recHitsLabel_, reducedHitsCollection_, and trackAssociator_.

{
   using namespace edm;

   using namespace std;

   using reco::TrackCollection;

   Handle<HBHERecHitCollection> recHitsHandle;
   iEvent.getByLabel(recHitsLabel_,recHitsHandle);
   if( !recHitsHandle.isValid() ) 
     {
       edm::LogError("ReduceHcalRecHitCollectionProducer") << "RecHit collection not found";
       return;
     }
   
   //Create empty output collections
   std::auto_ptr< HBHERecHitCollection > miniRecHitCollection (new HBHERecHitCollection) ;
    
//loop through tracks. 
   Handle<TrackCollection> tkTracks;
   iEvent.getByLabel(inputCollection_,tkTracks);
   std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ;
   for(TrackCollection::const_iterator itTrack = tkTracks->begin();
       itTrack != tkTracks->end();                      
       ++itTrack) {
        if(itTrack->pt()>ptcut_){
  
           TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
  
          if(info.crossedHcalIds.size()>0){
             //loop through hits in the cone
             for(std::vector<const HBHERecHit*>::const_iterator hit = info.hcalRecHits.begin(); 
                 hit != info.hcalRecHits.end(); ++hit)
             {
                DetId hitid=(*hit)->id();
                HBHERecHitCollection::const_iterator iRecHit = recHitsHandle->find(hitid);
                if ( (iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(hitid) == miniRecHitCollection->end()) )
                   miniRecHitCollection->push_back(*iRecHit);
             }
             

          }
        }
   }

   iEvent.put( miniRecHitCollection,reducedHitsCollection_ );



}

Member Data Documentation