CMS 3D CMS Logo

ReducedESRecHitCollectionProducer.cc
Go to the documentation of this file.
15 
16 using namespace edm;
17 using namespace std;
18 using namespace reco;
19 
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 }
40 
42 
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 }
55 
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) {
96  e.getByToken(interestingDetIdCollections_[t], detId);
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 }
144 
145 void ReducedESRecHitCollectionProducer::collectIds(const ESDetId esDetId1, const ESDetId esDetId2, const int& row) {
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 }
ReducedESRecHitCollectionProducer::InputRecHitES_
edm::EDGetTokenT< ESRecHitCollection > InputRecHitES_
Definition: ReducedESRecHitCollectionProducer.h:38
EcalPreshowerTopology.h
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::EDCollection::begin
const_iterator begin() const
Definition: EDCollection.h:117
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ReducedESRecHitCollectionProducer::beginRun
void beginRun(edm::Run const &, const edm::EventSetup &) final
Definition: ReducedESRecHitCollectionProducer.cc:43
ESHandle.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::Run
Definition: Run.h:45
BasicCluster.h
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
ReducedESRecHitCollectionProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: ReducedESRecHitCollectionProducer.cc:56
edm::PtrVectorItr
Definition: PtrVector.h:51
ESDetId
Definition: ESDetId.h:15
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
EcalRecHitCollections.h
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ReducedESRecHitCollectionProducer::collectIds
void collectIds(const ESDetId strip1, const ESDetId strip2, const int &row=0)
Definition: ReducedESRecHitCollectionProducer.cc:145
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
ReducedESRecHitCollectionProducer.h
edm::ESHandle< CaloGeometry >
ReducedESRecHitCollectionProducer::InputSuperClusterEE_
edm::EDGetTokenT< reco::SuperClusterCollection > InputSuperClusterEE_
Definition: ReducedESRecHitCollectionProducer.h:39
CaloNavigator::setHome
void setHome(const T &startingPoint)
set the starting position
Definition: CaloNavigator.h:90
ReducedESRecHitCollectionProducer::topology_p
std::unique_ptr< CaloSubdetectorTopology > topology_p
Definition: ReducedESRecHitCollectionProducer.h:34
EcalPreshowerGeometry.h
Point3DBase< float, GlobalTag >
OrderedSet.t
t
Definition: OrderedSet.py:90
CaloGeometryRecord.h
ReducedESRecHitCollectionProducer::scEtThresh_
double scEtThresh_
Definition: ReducedESRecHitCollectionProducer.h:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::vector_transform
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
EcalPreshowerGeometry::getClosestCellInPlane
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
Definition: EcalPreshowerGeometry.cc:130
EcalPreshowerNavigator.h
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
ReducedESRecHitCollectionProducer::geometry_p
const EcalPreshowerGeometry * geometry_p
Definition: ReducedESRecHitCollectionProducer.h:33
ReducedESRecHitCollectionProducer::ReducedESRecHitCollectionProducer
ReducedESRecHitCollectionProducer(const edm::ParameterSet &pset)
Definition: ReducedESRecHitCollectionProducer.cc:20
edm::EventSetup
Definition: EventSetup.h:57
DetId::Ecal
Definition: DetId.h:27
ReducedESRecHitCollectionProducer::interestingDetIdCollectionsNotToClean_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollectionsNotToClean_
Definition: ReducedESRecHitCollectionProducer.h:43
get
#define get
ReducedESRecHitCollectionProducer::interestingDetIdCollections_
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
Definition: ReducedESRecHitCollectionProducer.h:41
ReducedESRecHitCollectionProducer::collectedIds_
std::set< DetId > collectedIds_
Definition: ReducedESRecHitCollectionProducer.h:45
ReducedESRecHitCollectionProducer::OutputLabelES_
std::string OutputLabelES_
Definition: ReducedESRecHitCollectionProducer.h:40
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalPreshower
Definition: EcalSubdetector.h:10
CaloNavigator
Definition: CaloNavigator.h:7
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
transform.h
SuperCluster.h
EventSetup.h
Exception.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
point
*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
edm::Event
Definition: Event.h:73
ReducedESRecHitCollectionProducer::~ReducedESRecHitCollectionProducer
~ReducedESRecHitCollectionProducer() override
edm::InputTag
Definition: InputTag.h:15
edm::EDCollection::end
const_iterator end() const
Definition: EDCollection.h:122
hit
Definition: SiStripHitEffFromCalibTree.cc:88
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316