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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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().

20  :
21  geometry_p(nullptr)
22 {
23 
24  scEtThresh_ = ps.getParameter<double>("scEtThreshold");
25 
27  consumes<ESRecHitCollection>(ps.getParameter<edm::InputTag>("EcalRecHitCollectionES"));
29  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("EndcapSuperClusterCollection"));
30 
31  OutputLabelES_ = ps.getParameter<std::string>("OutputLabel_ES");
32 
35  ps.getParameter<std::vector<edm::InputTag>>("interestingDetIds"),
36  [this](edm::InputTag const & tag) {
37  return consumes<DetIdCollection>(tag);
38  }
39  );
40 
41  interestingDetIdCollectionsNotToClean_ = edm::vector_transform(ps.getParameter<std::vector<edm::InputTag>>("interestingDetIdsNotToClean"),
42  [this](edm::InputTag const & tag)
43  { return consumes<DetIdCollection>(tag); }
44  );
45 
46  produces< EcalRecHitCollection > (OutputLabelES_);
47 
48 }
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 52 of file ReducedESRecHitCollectionProducer.cc.

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

52  {
53  ESHandle<CaloGeometry> geoHandle;
54  iSetup.get<CaloGeometryRecord>().get(geoHandle);
56  if (!geometry_p){
57  edm::LogError("WrongGeometry")<<
58  "could not cast the subdet geometry to preshower geometry";
59  }
60 
61  if (geometry_p) topology_p = std::make_unique<EcalPreshowerTopology>();
62 
63 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
std::unique_ptr< CaloSubdetectorTopology > topology_p
T get() const
Definition: EventSetup.h:71
void ReducedESRecHitCollectionProducer::collectIds ( const ESDetId  strip1,
const ESDetId  strip2,
const int &  row = 0 
)

Definition at line 165 of file ReducedESRecHitCollectionProducer.cc.

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

Referenced by produce().

165  {
166 
167  //cout<<row<<endl;
168 
169  map<DetId,const EcalRecHit*>::iterator it;
170  map<DetId, int>::iterator itu;
171  ESDetId next;
172  ESDetId strip1;
173  ESDetId strip2;
174 
175  strip1 = esDetId1;
176  strip2 = esDetId2;
177 
178  EcalPreshowerNavigator theESNav1(strip1, topology_p.get());
179  theESNav1.setHome(strip1);
180 
181  EcalPreshowerNavigator theESNav2(strip2, topology_p.get());
182  theESNav2.setHome(strip2);
183 
184  if (row == 1) {
185  if (strip1 != ESDetId(0)) strip1 = theESNav1.north();
186  if (strip2 != ESDetId(0)) strip2 = theESNav2.east();
187  } else if (row == -1) {
188  if (strip1 != ESDetId(0)) strip1 = theESNav1.south();
189  if (strip2 != ESDetId(0)) strip2 = theESNav2.west();
190  }
191 
192  // Plane 1
193  if (strip1 == ESDetId(0)) {
194  } else {
195  collectedIds_.insert(strip1);
196  //cout<<"center : "<<strip1<<endl;
197  // east road
198  for (int i=0; i<15; ++i) {
199  next = theESNav1.east();
200  //cout<<"east : "<<i<<" "<<next<<endl;
201  if (next != ESDetId(0)) {
202  collectedIds_.insert(next);
203  } else {
204  break;
205  }
206  }
207 
208  // west road
209  theESNav1.setHome(strip1);
210  theESNav1.home();
211  for (int i=0; i<15; ++i) {
212  next = theESNav1.west();
213  //cout<<"west : "<<i<<" "<<next<<endl;
214  if (next != ESDetId(0)) {
215  collectedIds_.insert(next);
216  } else {
217  break;
218  }
219  }
220 
221  }
222 
223  if (strip2 == ESDetId(0)) {
224  } else {
225  collectedIds_.insert(strip2);
226  //cout<<"center : "<<strip2<<endl;
227  // north road
228  for (int i=0; i<15; ++i) {
229  next = theESNav2.north();
230  //cout<<"north : "<<i<<" "<<next<<endl;
231  if (next != ESDetId(0)) {
232  collectedIds_.insert(next);
233  } else {
234  break;
235  }
236  }
237 
238  // south road
239  theESNav2.setHome(strip2);
240  theESNav2.home();
241  for (int i=0; i<15; ++i) {
242  next = theESNav2.south();
243  //cout<<"south : "<<i<<" "<<next<<endl;
244  if (next != ESDetId(0)) {
245  collectedIds_.insert(next);
246  } else {
247  break;
248  }
249  }
250  }
251 }
void setHome(const T &startingPoint)
set the starting position
std::unique_ptr< CaloSubdetectorTopology > topology_p
void ReducedESRecHitCollectionProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 65 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(), tablePrinter::labels, eostools::move(), convertSQLitetoXML_cfg::output, OutputLabelES_, point, edm::Event::put(), scEtThresh_, and protons_cff::t.

65  {
66 
67 
69  e.getByToken(InputRecHitES_, ESRecHits_);
70 
71  auto output = std::make_unique<EcalRecHitCollection>();
72 
73  edm::Handle<reco::SuperClusterCollection> pEndcapSuperClusters;
74  e.getByToken(InputSuperClusterEE_, pEndcapSuperClusters);
75  {
76  const reco::SuperClusterCollection* eeSuperClusters = pEndcapSuperClusters.product();
77 
78  for (reco::SuperClusterCollection::const_iterator isc = eeSuperClusters->begin(); isc != eeSuperClusters->end(); ++isc) {
79 
80  if (isc->energy() < scEtThresh_) continue;
81  if (fabs(isc->eta()) < 1.65 || fabs(isc->eta()) > 2.6) continue;
82  //cout<<"SC energy : "<<isc->energy()<<" "<<isc->eta()<<endl;
83 
84  //Int_t nBC = 0;
85  reco::CaloCluster_iterator ibc = isc->clustersBegin();
86  for ( ; ibc != isc->clustersEnd(); ++ibc ) {
87 
88  //cout<<"BC : "<<nBC<<endl;
89 
90  const GlobalPoint point((*ibc)->x(),(*ibc)->y(),(*ibc)->z());
91 
94 
95  collectIds(esId1, esId2, 0);
96  collectIds(esId1, esId2, 1);
97  collectIds(esId1, esId2, -1);
98 
99  //nBC++;
100  }
101 
102  }
103 
104  }
105 
106 
108  for( unsigned int t = 0; t < interestingDetIdCollections_.size(); ++t )
109  {
111  if(!detId.isValid())
112  {
113  Labels labels;
114  labelsForToken(interestingDetIdCollections_[t], labels);
115  edm::LogError("MissingInput")<<"no reason to skip detid from : (" << labels.module << ", "
116  << labels.productInstance << ", "
117  << labels.process << ")" << std::endl;
118  continue;
119  }
120  collectedIds_.insert(detId->begin(),detId->end());
121  }
122 
123 
124  //screw it, cant think of a better solution, not the best but lets run over all the rec hits, remove the ones failing cleaning
125  //and then merge in the collection not to be cleaned
126  //mainly as I suspect its more efficient to find an object in the DetIdSet rather than the rec-hit in the rec-hit collecition
127  //with only a det id
128  //if its a CPU issues then revisit
129  for(const auto& hit : *ESRecHits_) {
130  if(hit.recoFlag()==1 || hit.recoFlag()==14 || (hit.recoFlag()<=10 && hit.recoFlag()>=5)){ //right we might need to erase it from the collection
131  auto idIt = collectedIds_.find(hit.id());
132  if(idIt!=collectedIds_.end()) collectedIds_.erase(idIt);
133  }
134  }
135 
136 
137  for(const auto& token : interestingDetIdCollectionsNotToClean_) {
138  e.getByToken(token,detId);
139  if(!detId.isValid()){ //meh might as well keep the warning
140  Labels labels;
141  labelsForToken(token, labels);
142  edm::LogError("MissingInput")<<"no reason to skip detid from : (" << labels.module << ", "
143  << labels.productInstance << ", "
144  << labels.process << ")" << std::endl;
145  continue;
146  }
147  collectedIds_.insert(detId->begin(),detId->end());
148  }
149 
150 
151  output->reserve( collectedIds_.size());
153  for (it = ESRecHits_->begin(); it != ESRecHits_->end(); ++it) {
154  if (collectedIds_.find(it->id())!=collectedIds_.end()){
155  output->push_back(*it);
156  }
157  }
158  collectedIds_.clear();
159 
161 
162 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const_iterator end() const
Definition: EDCollection.h:153
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:74
unsigned int id
const_iterator begin() const
Definition: EDCollection.h:146
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 47 of file ReducedESRecHitCollectionProducer.h.

Referenced by collectIds(), and produce().

const EcalPreshowerGeometry* ReducedESRecHitCollectionProducer::geometry_p
private

Definition at line 36 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 37 of file ReducedESRecHitCollectionProducer.h.

Referenced by beginRun(), and collectIds().