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.
16 
17 using namespace edm;
18 using namespace std;
19 using namespace reco;
20 
22  geometry_p(0),
23  topology_p(0)
24 {
25 
26  scEtThresh_ = ps.getParameter<double>("scEtThreshold");
27 
28  InputRecHitES_ = ps.getParameter<edm::InputTag>("EcalRecHitCollectionES");
29  InputSpuerClusterEE_ = ps.getParameter<edm::InputTag>("EndcapSuperClusterCollection");
30 
31  OutputLabelES_ = ps.getParameter<std::string>("OutputLabel_ES");
32 
33  interestingDetIdCollections_ = ps.getParameter<std::vector< edm::InputTag> >("interestingDetIds");
34 
35  produces< EcalRecHitCollection > (OutputLabelES_);
36 
37 }
38 
40  if (topology_p) delete topology_p;
41 }
42 
44  ESHandle<CaloGeometry> geoHandle;
45  iSetup.get<CaloGeometryRecord>().get(geoHandle);
46  const CaloSubdetectorGeometry *geometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
47  geometry_p = dynamic_cast<const EcalPreshowerGeometry *>(geometry);
48  if (!geometry_p){
49  edm::LogError("WrongGeometry")<<
50  "could not cast the subdet geometry to preshower geometry";
51  }
52 
53  if (geometry) topology_p = new EcalPreshowerTopology(geoHandle);
54 
55 }
56 
58 
59 
61  e.getByLabel(InputRecHitES_, ESRecHits_);
62 
63  std::auto_ptr<EcalRecHitCollection> output(new EcalRecHitCollection);
64 
65  edm::Handle<reco::SuperClusterCollection> pEndcapSuperClusters;
66  e.getByLabel(InputSpuerClusterEE_, pEndcapSuperClusters);
67  {
68  const reco::SuperClusterCollection* eeSuperClusters = pEndcapSuperClusters.product();
69 
70  for (reco::SuperClusterCollection::const_iterator isc = eeSuperClusters->begin(); isc != eeSuperClusters->end(); ++isc) {
71 
72  if (isc->energy() < scEtThresh_) continue;
73  if (fabs(isc->eta()) < 1.65 || fabs(isc->eta()) > 2.6) continue;
74  //cout<<"SC energy : "<<isc->energy()<<" "<<isc->eta()<<endl;
75 
76  //Int_t nBC = 0;
77  reco::CaloCluster_iterator ibc = isc->clustersBegin();
78  for ( ; ibc != isc->clustersEnd(); ++ibc ) {
79 
80  //cout<<"BC : "<<nBC<<endl;
81 
82  const GlobalPoint point((*ibc)->x(),(*ibc)->y(),(*ibc)->z());
83 
86 
87  collectIds(esId1, esId2, 0);
88  collectIds(esId1, esId2, 1);
89  collectIds(esId1, esId2, -1);
90 
91  //nBC++;
92  }
93 
94  }
95 
96  }
97 
98 
100  for( unsigned int t = 0; t < interestingDetIdCollections_.size(); ++t )
101  {
103  if (!detId.isValid()){
104  edm::LogError("MissingInput")<<"the collection of interesting detIds:"<<interestingDetIdCollections_[t]<<" is not found.";
105  continue;
106  }
107  collectedIds_.insert(detId->begin(),detId->end());
108  }
109 
110 
111  output->reserve( collectedIds_.size());
113  for (it = ESRecHits_->begin(); it != ESRecHits_->end(); ++it) {
114  if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue;
115  if (collectedIds_.find(it->id())!=collectedIds_.end()){
116  output->push_back(*it);
117  }
118  }
119  collectedIds_.clear();
120 
121  e.put(output, OutputLabelES_);
122 
123 }
124 
125 void ReducedESRecHitCollectionProducer::collectIds(const ESDetId esDetId1, const ESDetId esDetId2, const int & row) {
126 
127  //cout<<row<<endl;
128 
129  map<DetId,const EcalRecHit*>::iterator it;
130  map<DetId, int>::iterator itu;
131  ESDetId next;
132  ESDetId strip1;
133  ESDetId strip2;
134 
135  strip1 = esDetId1;
136  strip2 = esDetId2;
137 
138  EcalPreshowerNavigator theESNav1(strip1, topology_p);
139  theESNav1.setHome(strip1);
140 
141  EcalPreshowerNavigator theESNav2(strip2, topology_p);
142  theESNav2.setHome(strip2);
143 
144  if (row == 1) {
145  if (strip1 != ESDetId(0)) strip1 = theESNav1.north();
146  if (strip2 != ESDetId(0)) strip2 = theESNav2.east();
147  } else if (row == -1) {
148  if (strip1 != ESDetId(0)) strip1 = theESNav1.south();
149  if (strip2 != ESDetId(0)) strip2 = theESNav2.west();
150  }
151 
152  // Plane 1
153  if (strip1 == ESDetId(0)) {
154  } else {
155  collectedIds_.insert(strip1);
156  //cout<<"center : "<<strip1<<endl;
157  // east road
158  for (int i=0; i<15; ++i) {
159  next = theESNav1.east();
160  //cout<<"east : "<<i<<" "<<next<<endl;
161  if (next != ESDetId(0)) {
162  collectedIds_.insert(next);
163  } else {
164  break;
165  }
166  }
167 
168  // west road
169  theESNav1.setHome(strip1);
170  theESNav1.home();
171  for (int i=0; i<15; ++i) {
172  next = theESNav1.west();
173  //cout<<"west : "<<i<<" "<<next<<endl;
174  if (next != ESDetId(0)) {
175  collectedIds_.insert(next);
176  } else {
177  break;
178  }
179  }
180 
181  }
182 
183  if (strip2 == ESDetId(0)) {
184  } else {
185  collectedIds_.insert(strip2);
186  //cout<<"center : "<<strip2<<endl;
187  // north road
188  for (int i=0; i<15; ++i) {
189  next = theESNav2.north();
190  //cout<<"north : "<<i<<" "<<next<<endl;
191  if (next != ESDetId(0)) {
192  collectedIds_.insert(next);
193  } else {
194  break;
195  }
196  }
197 
198  // south road
199  theESNav2.setHome(strip2);
200  theESNav2.home();
201  for (int i=0; i<15; ++i) {
202  next = theESNav2.south();
203  //cout<<"south : "<<i<<" "<<next<<endl;
204  if (next != ESDetId(0)) {
205  collectedIds_.insert(next);
206  } else {
207  break;
208  }
209  }
210  }
211 }
212 
213 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void setHome(const T &startingPoint)
set the starting position
void home() const
move the navigator back to the starting point
virtual T west() const
move the navigator west
Definition: CaloNavigator.h:81
std::vector< EcalRecHit >::const_iterator const_iterator
virtual T north() const
move the navigator north
Definition: CaloNavigator.h:51
void collectIds(const ESDetId strip1, const ESDetId strip2, const int &row=0)
virtual T east() const
move the navigator east
Definition: CaloNavigator.h:71
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void beginRun(edm::Run &, const edm::EventSetup &)
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const T & get() const
Definition: EventSetup.h:55
std::vector< edm::InputTag > interestingDetIdCollections_
T const * product() const
Definition: Handle.h:74
void produce(edm::Event &e, const edm::EventSetup &c)
ESHandle< TrackerGeometry > geometry
virtual T south() const
move the navigator south
Definition: CaloNavigator.h:61
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:33