CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InterestingDetIdFromSuperClusterProducer.cc
Go to the documentation of this file.
2 
6 
7 
10 
13 
17 
21 
22 
24 {
25 
26  recHitsToken_ =
27  consumes<EcalRecHitCollection>(iConfig.getParameter< edm::InputTag > ("recHitsLabel"));
29  consumes<reco::SuperClusterCollection>(iConfig.getParameter< edm::InputTag >("superClustersLabel"));
30 
31  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
32 
33  minimalEtaSize_ = iConfig.getParameter<int> ("etaSize");
34  minimalPhiSize_ = iConfig.getParameter<int> ("phiSize");
35  if ( minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
36  edm::LogError("InterestingDetIdFromSuperClusterProducerError") << "Size of eta/phi should be odd numbers";
37 
38  //register your products
39  produces< DetIdCollection > (interestingDetIdCollection_) ;
40 
41  severityLevel_ = iConfig.getParameter<int>("severityLevel");
42  keepNextToDead_ = iConfig.getParameter<bool>("keepNextToDead");
43  keepNextToBoundary_ = iConfig.getParameter<bool>("keepNextToBoundary");
44 }
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.getByToken(superClustersToken_, pClusters);
69 
70  // take EcalRecHits
71  Handle<EcalRecHitCollection> recHitsHandle;
72  iEvent.getByToken(recHitsToken_,recHitsHandle);
73 
74  //Create empty output collections
75  std::vector<DetId> indexToStore;
76  indexToStore.reserve(1000);
77 
78  reco::SuperClusterCollection::const_iterator sclusIt;
79 
80  std::vector<DetId> xtalsToStore;
81  xtalsToStore.reserve(50);
82 
83  //loop over superclusters
84  for (sclusIt=pClusters->begin(); sclusIt!=pClusters->end(); sclusIt++) {
85  //loop over subclusters
86  for (reco::CaloCluster_iterator clusIt = sclusIt->clustersBegin(); clusIt!=sclusIt->clustersEnd(); ++clusIt) {
87  //PG barrel
88 
89  float eMax=0.;
90  DetId eMaxId(0);
91 
92  std::vector<std::pair<DetId,float> > clusterDetIds = (*clusIt)->hitsAndFractions();
93  std::vector<std::pair<DetId,float> >::iterator posCurrent;
94 
95  EcalRecHit testEcalRecHit;
96 
97  for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
98  {
99  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
100  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax) )
101  {
102  eMax = (*itt).energy();
103  eMaxId = (*itt).id();
104  }
105  }
106 
107  if (eMaxId.null())
108  continue;
109 
111 
112  xtalsToStore=topology->getWindow(eMaxId,minimalEtaSize_,minimalPhiSize_);
113  std::vector<std::pair<DetId,float > > xtalsInClus=(*clusIt)->hitsAndFractions();
114 
115  for (unsigned int ii=0;ii<xtalsInClus.size();ii++)
116  {
117  xtalsToStore.push_back(xtalsInClus[ii].first);
118  }
119 
120  indexToStore.insert(indexToStore.end(),xtalsToStore.begin(),xtalsToStore.end());
121  }
122  }
123 
124 
125 
126  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
127  // also add recHits of dead TT if the corresponding TP is saturated
128  if ( it->checkFlag(EcalRecHit::kTPSaturated) ) {
129  indexToStore.push_back(it->id());
130  }
131  // add hits for severities above a threshold
132  if ( severityLevel_>=0 &&
134 
135  indexToStore.push_back(it->id());
136  }
137  if (keepNextToDead_) {
138  // also keep channels next to dead ones
139  if (EcalTools::isNextToDead(it->id(), iSetup)) {
140  indexToStore.push_back(it->id());
141  }
142  }
143 
144  if (keepNextToBoundary_){
145  // keep channels around EB/EE boundary
146  if (it->id().subdetId() == EcalBarrel){
147  EBDetId ebid(it->id());
148  if (abs(ebid.ieta())== 85)
149  indexToStore.push_back(it->id());
150  } else {
151 
152  if (EEDetId::isNextToRingBoundary(it->id()))
153  indexToStore.push_back(it->id());
154  }
155 
156  }
157 
158  }
159 
160  //unify the vector
161  std::sort(indexToStore.begin(),indexToStore.end());
162  std::unique(indexToStore.begin(),indexToStore.end());
163 
164  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection(indexToStore) ) ;
165 
166 
167  iEvent.put( detIdCollection, interestingDetIdCollection_ );
168 
169 }
T getParameter(std::string const &) const
static bool isNextToDead(const DetId &id, const edm::EventSetup &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:52
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
std::vector< EcalRecHit >::const_iterator const_iterator
int ii
Definition: cuy.py:588
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:375
float energy() const
Definition: EcalRecHit.h:68
virtual void beginRun(edm::Run const &, const edm::EventSetup &) overridefinal
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
virtual void produce(edm::Event &, const edm::EventSetup &)
producer
Definition: DetId.h:18
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
const T & get() const
Definition: EventSetup.h:55
bool null() const
is this a null id ?
Definition: DetId.h:45
T const * product() const
Definition: ESHandle.h:86
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:35
Definition: Run.h:41