CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ReducedESRecHitCollectionProducer Class Reference

#include <ReducedESRecHitCollectionProducer.h>

Inheritance diagram for ReducedESRecHitCollectionProducer:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &, const edm::EventSetup &) final
 
void collectIds (const ESDetId strip1, const ESDetId strip2, const int &row=0)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ReducedESRecHitCollectionProducer (const edm::ParameterSet &pset)
 
 ~ReducedESRecHitCollectionProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

std::set< DetIdcollectedIds_
 
const EcalPreshowerGeometrygeometry_p
 
edm::EDGetTokenT< ESRecHitCollectionInputRecHitES_
 
edm::EDGetTokenT< reco::SuperClusterCollectionInputSuperClusterEE_
 
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
 
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollectionsNotToClean_
 
std::string OutputLabelES_
 
double scEtThresh_
 
std::unique_ptr< CaloSubdetectorTopologytopology_p
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 24 of file ReducedESRecHitCollectionProducer.h.

Constructor & Destructor Documentation

ReducedESRecHitCollectionProducer::ReducedESRecHitCollectionProducer ( const edm::ParameterSet pset)

Definition at line 20 of file ReducedESRecHitCollectionProducer.cc.

References edm::ParameterSet::getParameter(), InputRecHitES_, InputSuperClusterEE_, interestingDetIdCollections_, interestingDetIdCollectionsNotToClean_, OutputLabelES_, scEtThresh_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, edm::vector_transform(), and ~ReducedESRecHitCollectionProducer().

21  : geometry_p(nullptr) {
22  scEtThresh_ = ps.getParameter<double>("scEtThreshold");
23 
24  InputRecHitES_ = consumes<ESRecHitCollection>(ps.getParameter<edm::InputTag>("EcalRecHitCollectionES"));
26  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("EndcapSuperClusterCollection"));
27 
28  OutputLabelES_ = ps.getParameter<std::string>("OutputLabel_ES");
29 
31  edm::vector_transform(ps.getParameter<std::vector<edm::InputTag>>("interestingDetIds"),
32  [this](edm::InputTag const& tag) { return consumes<DetIdCollection>(tag); });
33 
35  edm::vector_transform(ps.getParameter<std::vector<edm::InputTag>>("interestingDetIdsNotToClean"),
36  [this](edm::InputTag const& tag) { return consumes<DetIdCollection>(tag); });
37 
38  produces<EcalRecHitCollection>(OutputLabelES_);
39 }
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollectionsNotToClean_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
edm::EDGetTokenT< ESRecHitCollection > InputRecHitES_
edm::EDGetTokenT< reco::SuperClusterCollection > InputSuperClusterEE_
ReducedESRecHitCollectionProducer::~ReducedESRecHitCollectionProducer ( )
overridedefault

Member Function Documentation

void ReducedESRecHitCollectionProducer::beginRun ( edm::Run const &  ,
const edm::EventSetup iSetup 
)
final

Definition at line 43 of file ReducedESRecHitCollectionProducer.cc.

References DetId::Ecal, EcalPreshower, geometry_p, edm::EventSetup::get(), CaloGeometry::getSubdetectorGeometry(), and topology_p.

43  {
44  ESHandle<CaloGeometry> geoHandle;
45  iSetup.get<CaloGeometryRecord>().get(geoHandle);
46  geometry_p =
47  dynamic_cast<const EcalPreshowerGeometry*>(geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower));
48  if (!geometry_p) {
49  edm::LogError("WrongGeometry") << "could not cast the subdet geometry to preshower geometry";
50  }
51 
52  if (geometry_p)
53  topology_p = std::make_unique<EcalPreshowerTopology>();
54 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
std::unique_ptr< CaloSubdetectorTopology > topology_p
T get() const
Definition: EventSetup.h:73
void ReducedESRecHitCollectionProducer::collectIds ( const ESDetId  strip1,
const ESDetId  strip2,
const int &  row = 0 
)

Definition at line 145 of file ReducedESRecHitCollectionProducer.cc.

References collectedIds_, mps_fire::i, GetRecoTauVFromDQM_MC_cff::next, CaloNavigator< T, TOPO >::setHome(), and topology_p.

Referenced by produce().

145  {
146  //cout<<row<<endl;
147 
148  map<DetId, const EcalRecHit*>::iterator it;
149  map<DetId, int>::iterator itu;
150  ESDetId next;
151  ESDetId strip1;
152  ESDetId strip2;
153 
154  strip1 = esDetId1;
155  strip2 = esDetId2;
156 
157  EcalPreshowerNavigator theESNav1(strip1, topology_p.get());
158  theESNav1.setHome(strip1);
159 
160  EcalPreshowerNavigator theESNav2(strip2, topology_p.get());
161  theESNav2.setHome(strip2);
162 
163  if (row == 1) {
164  if (strip1 != ESDetId(0))
165  strip1 = theESNav1.north();
166  if (strip2 != ESDetId(0))
167  strip2 = theESNav2.east();
168  } else if (row == -1) {
169  if (strip1 != ESDetId(0))
170  strip1 = theESNav1.south();
171  if (strip2 != ESDetId(0))
172  strip2 = theESNav2.west();
173  }
174 
175  // Plane 1
176  if (strip1 == ESDetId(0)) {
177  } else {
178  collectedIds_.insert(strip1);
179  //cout<<"center : "<<strip1<<endl;
180  // east road
181  for (int i = 0; i < 15; ++i) {
182  next = theESNav1.east();
183  //cout<<"east : "<<i<<" "<<next<<endl;
184  if (next != ESDetId(0)) {
185  collectedIds_.insert(next);
186  } else {
187  break;
188  }
189  }
190 
191  // west road
192  theESNav1.setHome(strip1);
193  theESNav1.home();
194  for (int i = 0; i < 15; ++i) {
195  next = theESNav1.west();
196  //cout<<"west : "<<i<<" "<<next<<endl;
197  if (next != ESDetId(0)) {
198  collectedIds_.insert(next);
199  } else {
200  break;
201  }
202  }
203  }
204 
205  if (strip2 == ESDetId(0)) {
206  } else {
207  collectedIds_.insert(strip2);
208  //cout<<"center : "<<strip2<<endl;
209  // north road
210  for (int i = 0; i < 15; ++i) {
211  next = theESNav2.north();
212  //cout<<"north : "<<i<<" "<<next<<endl;
213  if (next != ESDetId(0)) {
214  collectedIds_.insert(next);
215  } else {
216  break;
217  }
218  }
219 
220  // south road
221  theESNav2.setHome(strip2);
222  theESNav2.home();
223  for (int i = 0; i < 15; ++i) {
224  next = theESNav2.south();
225  //cout<<"south : "<<i<<" "<<next<<endl;
226  if (next != ESDetId(0)) {
227  collectedIds_.insert(next);
228  } else {
229  break;
230  }
231  }
232  }
233 }
void setHome(const T &startingPoint)
set the starting position
Definition: CaloNavigator.h:91
std::unique_ptr< CaloSubdetectorTopology > topology_p
void ReducedESRecHitCollectionProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 56 of file ReducedESRecHitCollectionProducer.cc.

References edm::EDCollection< T >::begin(), collectedIds_, collectIds(), edm::EDCollection< T >::end(), geometry_p, edm::Event::getByToken(), EcalPreshowerGeometry::getClosestCellInPlane(), hit::id, InputRecHitES_, InputSuperClusterEE_, interestingDetIdCollections_, interestingDetIdCollectionsNotToClean_, edm::HandleBase::isValid(), SummaryClient_cfi::labels, eostools::move(), convertSQLitetoXML_cfg::output, OutputLabelES_, point, edm::Event::put(), scEtThresh_, OrderedSet::t, and unpackBuffers-CaloStage2::token.

56  {
58  e.getByToken(InputRecHitES_, ESRecHits_);
59 
60  auto output = std::make_unique<EcalRecHitCollection>();
61 
62  edm::Handle<reco::SuperClusterCollection> pEndcapSuperClusters;
63  e.getByToken(InputSuperClusterEE_, pEndcapSuperClusters);
64  {
65  const reco::SuperClusterCollection* eeSuperClusters = pEndcapSuperClusters.product();
66 
67  for (reco::SuperClusterCollection::const_iterator isc = eeSuperClusters->begin(); isc != eeSuperClusters->end();
68  ++isc) {
69  if (isc->energy() < scEtThresh_)
70  continue;
71  if (fabs(isc->eta()) < 1.65 || fabs(isc->eta()) > 2.6)
72  continue;
73  //cout<<"SC energy : "<<isc->energy()<<" "<<isc->eta()<<endl;
74 
75  //Int_t nBC = 0;
76  reco::CaloCluster_iterator ibc = isc->clustersBegin();
77  for (; ibc != isc->clustersEnd(); ++ibc) {
78  //cout<<"BC : "<<nBC<<endl;
79 
80  const GlobalPoint point((*ibc)->x(), (*ibc)->y(), (*ibc)->z());
81 
84 
85  collectIds(esId1, esId2, 0);
86  collectIds(esId1, esId2, 1);
87  collectIds(esId1, esId2, -1);
88 
89  //nBC++;
90  }
91  }
92  }
93 
95  for (unsigned int t = 0; t < interestingDetIdCollections_.size(); ++t) {
97  if (!detId.isValid()) {
98  Labels labels;
99  labelsForToken(interestingDetIdCollections_[t], labels);
100  edm::LogError("MissingInput") << "no reason to skip detid from : (" << labels.module << ", "
101  << labels.productInstance << ", " << labels.process << ")" << std::endl;
102  continue;
103  }
104  collectedIds_.insert(detId->begin(), detId->end());
105  }
106 
107  //screw it, cant think of a better solution, not the best but lets run over all the rec hits, remove the ones failing cleaning
108  //and then merge in the collection not to be cleaned
109  //mainly as I suspect its more efficient to find an object in the DetIdSet rather than the rec-hit in the rec-hit collecition
110  //with only a det id
111  //if its a CPU issues then revisit
112  for (const auto& hit : *ESRecHits_) {
113  if (hit.recoFlag() == 1 || hit.recoFlag() == 14 ||
114  (hit.recoFlag() <= 10 && hit.recoFlag() >= 5)) { //right we might need to erase it from the collection
115  auto idIt = collectedIds_.find(hit.id());
116  if (idIt != collectedIds_.end())
117  collectedIds_.erase(idIt);
118  }
119  }
120 
121  for (const auto& token : interestingDetIdCollectionsNotToClean_) {
122  e.getByToken(token, detId);
123  if (!detId.isValid()) { //meh might as well keep the warning
124  Labels labels;
125  labelsForToken(token, labels);
126  edm::LogError("MissingInput") << "no reason to skip detid from : (" << labels.module << ", "
127  << labels.productInstance << ", " << labels.process << ")" << std::endl;
128  continue;
129  }
130  collectedIds_.insert(detId->begin(), detId->end());
131  }
132 
133  output->reserve(collectedIds_.size());
135  for (it = ESRecHits_->begin(); it != ESRecHits_->end(); ++it) {
136  if (collectedIds_.find(it->id()) != collectedIds_.end()) {
137  output->push_back(*it);
138  }
139  }
140  collectedIds_.clear();
141 
143 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const_iterator end() const
Definition: EDCollection.h:122
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollectionsNotToClean_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
std::vector< EcalRecHit >::const_iterator const_iterator
void collectIds(const ESDetId strip1, const ESDetId strip2, const int &row=0)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
bool isValid() const
Definition: HandleBase.h:70
unsigned int id
const_iterator begin() const
Definition: EDCollection.h:117
edm::EDGetTokenT< ESRecHitCollection > InputRecHitES_
edm::EDGetTokenT< reco::SuperClusterCollection > InputSuperClusterEE_
def move(src, dest)
Definition: eostools.py:511
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

Member Data Documentation

std::set<DetId> ReducedESRecHitCollectionProducer::collectedIds_
private

Definition at line 45 of file ReducedESRecHitCollectionProducer.h.

Referenced by collectIds(), and produce().

const EcalPreshowerGeometry* ReducedESRecHitCollectionProducer::geometry_p
private

Definition at line 33 of file ReducedESRecHitCollectionProducer.h.

Referenced by beginRun(), and produce().

edm::EDGetTokenT<ESRecHitCollection> ReducedESRecHitCollectionProducer::InputRecHitES_
private
edm::EDGetTokenT<reco::SuperClusterCollection> ReducedESRecHitCollectionProducer::InputSuperClusterEE_
private
std::vector<edm::EDGetTokenT<DetIdCollection> > ReducedESRecHitCollectionProducer::interestingDetIdCollections_
private
std::vector<edm::EDGetTokenT<DetIdCollection> > ReducedESRecHitCollectionProducer::interestingDetIdCollectionsNotToClean_
private
std::string ReducedESRecHitCollectionProducer::OutputLabelES_
private
double ReducedESRecHitCollectionProducer::scEtThresh_
private
std::unique_ptr<CaloSubdetectorTopology> ReducedESRecHitCollectionProducer::topology_p
private

Definition at line 34 of file ReducedESRecHitCollectionProducer.h.

Referenced by beginRun(), and collectIds().