CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InterestingDetIdCollectionProducer.cc
Go to the documentation of this file.
2 
6 
8 
11 
15 
19 
22 
23 
25 {
26 
27  recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel");
28  basicClusters_ = iConfig.getParameter< edm::InputTag > ("basicClustersLabel");
29 
30  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
31 
32  minimalEtaSize_ = iConfig.getParameter<int> ("etaSize");
33  minimalPhiSize_ = iConfig.getParameter<int> ("phiSize");
34  if ( minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
35  edm::LogError("InterestingDetIdCollectionProducerError") << "Size of eta/phi should be odd numbers";
36 
37  //register your products
38  produces< DetIdCollection > (interestingDetIdCollection_) ;
39 
40  severityLevel_ = iConfig.getParameter<int>("severityLevel");
41 }
42 
43 
45 {}
46 
48 {
49  edm::ESHandle<CaloTopology> theCaloTopology;
50  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
51  caloTopology_ = &(*theCaloTopology);
52 
54  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
55  severity_ = sevLv.product();
56 }
57 
58 // ------------ method called to produce the data ------------
59 void
61  const edm::EventSetup& iSetup)
62 {
63  using namespace edm;
64  using namespace std;
65 
66  // take BasicClusters
68  iEvent.getByLabel(basicClusters_, pClusters);
69 
70  // take EcalRecHits
71  Handle<EcalRecHitCollection> recHitsHandle;
72  iEvent.getByLabel(recHitsLabel_,recHitsHandle);
73 
74  //Create empty output collections
75  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
76 
77  reco::BasicClusterCollection::const_iterator clusIt;
78 
79  for (clusIt=pClusters->begin(); clusIt!=pClusters->end(); clusIt++) {
80  //PG barrel
81 
82  float eMax=0.;
83  DetId eMaxId(0);
84 
85  std::vector<std::pair<DetId,float> > clusterDetIds = (*clusIt).hitsAndFractions();
86  std::vector<std::pair<DetId,float> >::iterator posCurrent;
87 
88  EcalRecHit testEcalRecHit;
89 
90  for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
91  {
92  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
93  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax) )
94  {
95  eMax = (*itt).energy();
96  eMaxId = (*itt).id();
97  }
98  }
99 
100  if (eMaxId.null())
101  continue;
102 
103  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(eMaxId.det(),eMaxId.subdetId());
104  std::vector<DetId> xtalsToStore=topology->getWindow(eMaxId,minimalEtaSize_,minimalPhiSize_);
105  std::vector<std::pair<DetId,float > > xtalsInClus=(*clusIt).hitsAndFractions();
106 
107  for (unsigned int ii=0;ii<xtalsInClus.size();ii++)
108  {
109  if (std::find(xtalsToStore.begin(),xtalsToStore.end(),xtalsInClus[ii].first) == xtalsToStore.end())
110  xtalsToStore.push_back(xtalsInClus[ii].first);
111  }
112 
113  for (unsigned int iCry=0;iCry<xtalsToStore.size();iCry++)
114  {
115  if (
116  std::find(detIdCollection->begin(),detIdCollection->end(),xtalsToStore[iCry]) == detIdCollection->end()
117  )
118  detIdCollection->push_back(xtalsToStore[iCry]);
119  }
120  }
121 
122  // also add recHits of dead TT if the corresponding TP is saturated
123  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
124  if ( it->checkFlag(EcalRecHit::kTPSaturated) ) {
125  if ( std::find( detIdCollection->begin(), detIdCollection->end(), it->id() ) == detIdCollection->end()
126  ) {
127  detIdCollection->push_back( it->id() );
128  }
129  }else if ( severityLevel_>=0 && severity_->severityLevel(*it) >=severityLevel_){
130  detIdCollection->push_back( it->id() );
131  }
132 
133  }
134 
135  // std::cout << "Interesting DetId Collection size is " << detIdCollection->size() << " BCs are " << pClusters->size() << std::endl;
136  iEvent.put( detIdCollection, interestingDetIdCollection_ );
137 
138 }
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
producer
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
EcalSeverityLevel severityLevel(const DetId &id, const EcalRecHitCollection &rhs) const
Evaluate status from id.
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
float energy() const
Definition: CaloRecHit.h:19
InterestingDetIdCollectionProducer(const edm::ParameterSet &)
ctor
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
Definition: DetId.h:20
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
void beginRun(edm::Run &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
bool null() const
is this a null id ?
Definition: DetId.h:47
T const * product() const
Definition: ESHandle.h:62
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
edm::EDCollection< DetId > DetIdCollection
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
Definition: Run.h:32