CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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(0),
22  topology_p(0)
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  produces< EcalRecHitCollection > (OutputLabelES_);
43 
44 }
45 
47  if (topology_p) delete topology_p;
48 }
49 
51  ESHandle<CaloGeometry> geoHandle;
52  iSetup.get<CaloGeometryRecord>().get(geoHandle);
53  const CaloSubdetectorGeometry *geometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
54  geometry_p = dynamic_cast<const EcalPreshowerGeometry *>(geometry);
55  if (!geometry_p){
56  edm::LogError("WrongGeometry")<<
57  "could not cast the subdet geometry to preshower geometry";
58  }
59 
60  if (geometry) topology_p = new EcalPreshowerTopology(geoHandle);
61 
62 }
63 
65 
66 
68  e.getByToken(InputRecHitES_, ESRecHits_);
69 
70  std::auto_ptr<EcalRecHitCollection> output(new EcalRecHitCollection);
71 
72  edm::Handle<reco::SuperClusterCollection> pEndcapSuperClusters;
73  e.getByToken(InputSuperClusterEE_, pEndcapSuperClusters);
74  {
75  const reco::SuperClusterCollection* eeSuperClusters = pEndcapSuperClusters.product();
76 
77  for (reco::SuperClusterCollection::const_iterator isc = eeSuperClusters->begin(); isc != eeSuperClusters->end(); ++isc) {
78 
79  if (isc->energy() < scEtThresh_) continue;
80  if (fabs(isc->eta()) < 1.65 || fabs(isc->eta()) > 2.6) continue;
81  //cout<<"SC energy : "<<isc->energy()<<" "<<isc->eta()<<endl;
82 
83  //Int_t nBC = 0;
84  reco::CaloCluster_iterator ibc = isc->clustersBegin();
85  for ( ; ibc != isc->clustersEnd(); ++ibc ) {
86 
87  //cout<<"BC : "<<nBC<<endl;
88 
89  const GlobalPoint point((*ibc)->x(),(*ibc)->y(),(*ibc)->z());
90 
93 
94  collectIds(esId1, esId2, 0);
95  collectIds(esId1, esId2, 1);
96  collectIds(esId1, esId2, -1);
97 
98  //nBC++;
99  }
100 
101  }
102 
103  }
104 
105 
107  for( unsigned int t = 0; t < interestingDetIdCollections_.size(); ++t )
108  {
110  if(!detId.isValid())
111  {
112  Labels labels;
114  edm::LogError("MissingInput")<<"no reason to skip detid from : (" << labels.module << ", "
115  << labels.productInstance << ", "
116  << labels.process << ")" << std::endl;
117  continue;
118  }
119  collectedIds_.insert(detId->begin(),detId->end());
120  }
121 
122 
123  output->reserve( collectedIds_.size());
125  for (it = ESRecHits_->begin(); it != ESRecHits_->end(); ++it) {
126  if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue;
127  if (collectedIds_.find(it->id())!=collectedIds_.end()){
128  output->push_back(*it);
129  }
130  }
131  collectedIds_.clear();
132 
133  e.put(output, OutputLabelES_);
134 
135 }
136 
137 void ReducedESRecHitCollectionProducer::collectIds(const ESDetId esDetId1, const ESDetId esDetId2, const int & row) {
138 
139  //cout<<row<<endl;
140 
141  map<DetId,const EcalRecHit*>::iterator it;
142  map<DetId, int>::iterator itu;
143  ESDetId next;
144  ESDetId strip1;
145  ESDetId strip2;
146 
147  strip1 = esDetId1;
148  strip2 = esDetId2;
149 
150  EcalPreshowerNavigator theESNav1(strip1, topology_p);
151  theESNav1.setHome(strip1);
152 
153  EcalPreshowerNavigator theESNav2(strip2, topology_p);
154  theESNav2.setHome(strip2);
155 
156  if (row == 1) {
157  if (strip1 != ESDetId(0)) strip1 = theESNav1.north();
158  if (strip2 != ESDetId(0)) strip2 = theESNav2.east();
159  } else if (row == -1) {
160  if (strip1 != ESDetId(0)) strip1 = theESNav1.south();
161  if (strip2 != ESDetId(0)) strip2 = theESNav2.west();
162  }
163 
164  // Plane 1
165  if (strip1 == ESDetId(0)) {
166  } else {
167  collectedIds_.insert(strip1);
168  //cout<<"center : "<<strip1<<endl;
169  // east road
170  for (int i=0; i<15; ++i) {
171  next = theESNav1.east();
172  //cout<<"east : "<<i<<" "<<next<<endl;
173  if (next != ESDetId(0)) {
174  collectedIds_.insert(next);
175  } else {
176  break;
177  }
178  }
179 
180  // west road
181  theESNav1.setHome(strip1);
182  theESNav1.home();
183  for (int i=0; i<15; ++i) {
184  next = theESNav1.west();
185  //cout<<"west : "<<i<<" "<<next<<endl;
186  if (next != ESDetId(0)) {
187  collectedIds_.insert(next);
188  } else {
189  break;
190  }
191  }
192 
193  }
194 
195  if (strip2 == ESDetId(0)) {
196  } else {
197  collectedIds_.insert(strip2);
198  //cout<<"center : "<<strip2<<endl;
199  // north road
200  for (int i=0; i<15; ++i) {
201  next = theESNav2.north();
202  //cout<<"north : "<<i<<" "<<next<<endl;
203  if (next != ESDetId(0)) {
204  collectedIds_.insert(next);
205  } else {
206  break;
207  }
208  }
209 
210  // south road
211  theESNav2.setHome(strip2);
212  theESNav2.home();
213  for (int i=0; i<15; ++i) {
214  next = theESNav2.south();
215  //cout<<"south : "<<i<<" "<<next<<endl;
216  if (next != ESDetId(0)) {
217  collectedIds_.insert(next);
218  } else {
219  break;
220  }
221  }
222  }
223 }
224 
225 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual void beginRun(edm::Run const &, const edm::EventSetup &) overridefinal
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< edm::EDGetTokenT< DetIdCollection > > interestingDetIdCollections_
std::vector< EcalRecHit >::const_iterator const_iterator
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
void collectIds(const ESDetId strip1, const ESDetId strip2, const int &row=0)
void setHome(const T &startingPoint)
set the starting position
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
T west() const
move the navigator west
Definition: CaloNavigator.h:59
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
T south() const
move the navigator south
Definition: CaloNavigator.h:45
bool isValid() const
Definition: HandleBase.h:76
T east() const
move the navigator east
Definition: CaloNavigator.h:52
void home() const
move the navigator back to the starting point
edm::EDGetTokenT< ESRecHitCollection > InputRecHitES_
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< reco::SuperClusterCollection > InputSuperClusterEE_
T const * product() const
Definition: Handle.h:81
void produce(edm::Event &e, const edm::EventSetup &c)
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
ESHandle< TrackerGeometry > geometry
T north() const
move the navigator north
Definition: CaloNavigator.h:38
ReducedESRecHitCollectionProducer(const edm::ParameterSet &pset)
*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
Definition: Run.h:41