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_
 
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, and edm::vector_transform().

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

Definition at line 51 of file ReducedESRecHitCollectionProducer.cc.

References topology_p.

51  {
52  if (topology_p) delete topology_p;
53 }

Member Function Documentation

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

Definition at line 55 of file ReducedESRecHitCollectionProducer.cc.

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

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

Definition at line 168 of file ReducedESRecHitCollectionProducer.cc.

References collectedIds_, CaloNavigator< T, TOPO >::east(), CaloNavigator< T, TOPO >::home(), mps_fire::i, GetRecoTauVFromDQM_MC_cff::next, CaloNavigator< T, TOPO >::north(), CaloNavigator< T, TOPO >::setHome(), CaloNavigator< T, TOPO >::south(), topology_p, and CaloNavigator< T, TOPO >::west().

Referenced by produce().

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

Definition at line 68 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 lumiQTWidget::t.

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