CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
InterestingDetIdCollectionProducer Class Reference

#include <InterestingDetIdCollectionProducer.h>

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

Public Member Functions

void beginRun (edm::Run &, const edm::EventSetup &)
 
 InterestingDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer More...
 
 ~InterestingDetIdCollectionProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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_.

23 {
24 
25  recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel");
26  basicClusters_ = iConfig.getParameter< edm::InputTag > ("basicClustersLabel");
27 
28  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
29 
30  minimalEtaSize_ = iConfig.getParameter<int> ("etaSize");
31  minimalPhiSize_ = iConfig.getParameter<int> ("phiSize");
32  if ( minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
33  edm::LogError("InterestingDetIdCollectionProducerError") << "Size of eta/phi should be odd numbers";
34 
35  //register your products
36  produces< DetIdCollection > (interestingDetIdCollection_) ;
37 
38 }
T getParameter(std::string const &) const
InterestingDetIdCollectionProducer::~InterestingDetIdCollectionProducer ( )

Definition at line 41 of file InterestingDetIdCollectionProducer.cc.

42 {}

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().

45 {
46  edm::ESHandle<CaloTopology> theCaloTopology;
47  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
48  caloTopology_ = &(*theCaloTopology);
49 }
const T & get() const
Definition: EventSetup.h:55
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().

55 {
56  using namespace edm;
57  using namespace std;
58 
59  // take BasicClusters
61  iEvent.getByLabel(basicClusters_, pClusters);
62 
63  // take EcalRecHits
64  Handle<EcalRecHitCollection> recHitsHandle;
65  iEvent.getByLabel(recHitsLabel_,recHitsHandle);
66 
67  //Create empty output collections
68  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
69 
70  reco::BasicClusterCollection::const_iterator clusIt;
71 
72  for (clusIt=pClusters->begin(); clusIt!=pClusters->end(); clusIt++) {
73  //PG barrel
74 
75  float eMax=0.;
76  DetId eMaxId(0);
77 
78  std::vector<std::pair<DetId,float> > clusterDetIds = (*clusIt).hitsAndFractions();
79  std::vector<std::pair<DetId,float> >::iterator posCurrent;
80 
81  EcalRecHit testEcalRecHit;
82 
83  for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
84  {
85  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
86  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax) )
87  {
88  eMax = (*itt).energy();
89  eMaxId = (*itt).id();
90  }
91  }
92 
93  if (eMaxId.null())
94  continue;
95 
96  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(eMaxId.det(),eMaxId.subdetId());
97  std::vector<DetId> xtalsToStore=topology->getWindow(eMaxId,minimalEtaSize_,minimalPhiSize_);
98  std::vector<std::pair<DetId,float > > xtalsInClus=(*clusIt).hitsAndFractions();
99 
100  for (unsigned int ii=0;ii<xtalsInClus.size();ii++)
101  {
102  if (std::find(xtalsToStore.begin(),xtalsToStore.end(),xtalsInClus[ii].first) == xtalsToStore.end())
103  xtalsToStore.push_back(xtalsInClus[ii].first);
104  }
105 
106  for (unsigned int iCry=0;iCry<xtalsToStore.size();iCry++)
107  {
108  if (
109  std::find(detIdCollection->begin(),detIdCollection->end(),xtalsToStore[iCry]) == detIdCollection->end()
110  )
111  detIdCollection->push_back(xtalsToStore[iCry]);
112  }
113  }
114 
115  // also add recHits of dead TT if the corresponding TP is saturated
116  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
117  if ( it->flagBits() & (0x1 << EcalRecHit::kTPSaturated) ) {
118  if ( std::find( detIdCollection->begin(), detIdCollection->end(), it->id() ) == detIdCollection->end()
119  ) {
120  detIdCollection->push_back( it->id() );
121  }
122  }
123  }
124 
125  // std::cout << "Interesting DetId Collection size is " << detIdCollection->size() << " BCs are " << pClusters->size() << std::endl;
126  iEvent.put( detIdCollection, interestingDetIdCollection_ );
127 
128 }
std::vector< T >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
float energy() const
Definition: CaloRecHit.h:19
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
Definition: DetId.h:20
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
edm::EDCollection< DetId > DetIdCollection

Member Data Documentation

edm::InputTag InterestingDetIdCollectionProducer::basicClusters_
private
const CaloTopology* InterestingDetIdCollectionProducer::caloTopology_
private

Definition at line 49 of file InterestingDetIdCollectionProducer.h.

Referenced by beginRun(), and produce().

std::string InterestingDetIdCollectionProducer::interestingDetIdCollection_
private
int InterestingDetIdCollectionProducer::minimalEtaSize_
private
int InterestingDetIdCollectionProducer::minimalPhiSize_
private
edm::InputTag InterestingDetIdCollectionProducer::recHitsLabel_
private