CMS 3D CMS Logo

Public Member Functions | Private Attributes

InterestingDetIdCollectionProducer Class Reference

#include <InterestingDetIdCollectionProducer.h>

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

List of all members.

Public Member Functions

void beginRun (edm::Run &, const edm::EventSetup &)
 InterestingDetIdCollectionProducer (const edm::ParameterSet &)
 ctor
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer
 ~InterestingDetIdCollectionProducer ()

Private Attributes

edm::InputTag basicClusters_
const CaloTopologycaloTopology_
std::string interestingDetIdCollection_
int minimalEtaSize_
int minimalPhiSize_
edm::InputTag recHitsLabel_

Detailed Description

Original author: Paolo Meridiani PH/CMG

Implementation: <Notes on="" implementation>="">

Definition at line 33 of file InterestingDetIdCollectionProducer.h.


Constructor & Destructor Documentation

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

ctor

Definition at line 22 of file InterestingDetIdCollectionProducer.cc.

References basicClusters_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, minimalEtaSize_, minimalPhiSize_, and recHitsLabel_.

{

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

  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
  
  minimalEtaSize_ = iConfig.getParameter<int> ("etaSize");
  minimalPhiSize_ = iConfig.getParameter<int> ("phiSize");
  if ( minimalPhiSize_ % 2 == 0 ||  minimalEtaSize_ % 2 == 0)
    edm::LogError("InterestingDetIdCollectionProducerError") << "Size of eta/phi should be odd numbers";
 
   //register your products
  produces< DetIdCollection > (interestingDetIdCollection_) ;
  
}
InterestingDetIdCollectionProducer::~InterestingDetIdCollectionProducer ( )

Definition at line 41 of file InterestingDetIdCollectionProducer.cc.

{}

Member Function Documentation

void InterestingDetIdCollectionProducer::beginRun ( edm::Run run,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 44 of file InterestingDetIdCollectionProducer.cc.

References caloTopology_, and edm::EventSetup::get().

{
  edm::ESHandle<CaloTopology> theCaloTopology;
  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
  caloTopology_ = &(*theCaloTopology); 
}
void InterestingDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

producer

Implements edm::EDProducer.

Definition at line 53 of file InterestingDetIdCollectionProducer.cc.

References basicClusters_, caloTopology_, DetId::det(), jptDQMConfig_cff::eMax, CaloRecHit::energy(), spr::find(), edm::Event::getByLabel(), CaloTopology::getSubdetectorTopology(), CaloSubdetectorTopology::getWindow(), interestingDetIdCollection_, EcalRecHit::kTPSaturated, minimalEtaSize_, minimalPhiSize_, DetId::null(), edm::Event::put(), recHitsLabel_, and DetId::subdetId().

{
   using namespace edm;
   using namespace std;

   // take BasicClusters
  Handle<reco::BasicClusterCollection> pClusters;
  iEvent.getByLabel(basicClusters_, pClusters);
  
  // take EcalRecHits
  Handle<EcalRecHitCollection> recHitsHandle;
  iEvent.getByLabel(recHitsLabel_,recHitsHandle);

  //Create empty output collections
  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
  
  reco::BasicClusterCollection::const_iterator clusIt;
  
  for (clusIt=pClusters->begin(); clusIt!=pClusters->end(); clusIt++) {
    //PG barrel
    
    float eMax=0.;
    DetId eMaxId(0);

    std::vector<std::pair<DetId,float> > clusterDetIds = (*clusIt).hitsAndFractions();
    std::vector<std::pair<DetId,float> >::iterator posCurrent;

    EcalRecHit testEcalRecHit;
    
    for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
      {
        EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
        if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax) )
          {
            eMax = (*itt).energy();
            eMaxId = (*itt).id();
          }
      }
    
    if (eMaxId.null())
    continue;
    
    const CaloSubdetectorTopology* topology  = caloTopology_->getSubdetectorTopology(eMaxId.det(),eMaxId.subdetId());
    std::vector<DetId> xtalsToStore=topology->getWindow(eMaxId,minimalEtaSize_,minimalPhiSize_);
    std::vector<std::pair<DetId,float > > xtalsInClus=(*clusIt).hitsAndFractions();
    
    for (unsigned int ii=0;ii<xtalsInClus.size();ii++)
      {
        if (std::find(xtalsToStore.begin(),xtalsToStore.end(),xtalsInClus[ii].first) == xtalsToStore.end())
          xtalsToStore.push_back(xtalsInClus[ii].first);
      }
    
    for (unsigned int iCry=0;iCry<xtalsToStore.size();iCry++)
      {
        if ( 
            std::find(detIdCollection->begin(),detIdCollection->end(),xtalsToStore[iCry]) == detIdCollection->end()
            )
          detIdCollection->push_back(xtalsToStore[iCry]);
      }     
  }

  // also add recHits of dead TT if the corresponding TP is saturated
  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
          if ( it->flagBits() & (0x1 << EcalRecHit::kTPSaturated) ) {
                  if ( std::find( detIdCollection->begin(), detIdCollection->end(), it->id() ) == detIdCollection->end()
                     ) {
                          detIdCollection->push_back( it->id() );
                  }
          }
  }
  
  //  std::cout << "Interesting DetId Collection size is " << detIdCollection->size() <<  " BCs are " << pClusters->size() << std::endl;
  iEvent.put( detIdCollection, interestingDetIdCollection_ );

}

Member Data Documentation

Definition at line 49 of file InterestingDetIdCollectionProducer.h.

Referenced by beginRun(), and produce().