CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EleIsoDetIdCollectionProducer.cc
Go to the documentation of this file.
2 
7 
9 
20 
23 
25 
28 
31 
33  recHitsLabel_(iConfig.getParameter< edm::InputTag > ("recHitsLabel")),
34  emObjectLabel_(iConfig.getParameter< edm::InputTag > ("emObjectLabel")),
35  energyCut_(iConfig.getParameter<double>("energyCut")),
36  etCut_(iConfig.getParameter<double>("etCut")),
37  etCandCut_(iConfig.getParameter<double> ("etCandCut")),
38  outerRadius_(iConfig.getParameter<double>("outerRadius")),
39  innerRadius_(iConfig.getParameter<double>("innerRadius")),
40  interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection"))
41  {
42 
43  const std::vector<std::string> flagnamesEB =
44  iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
45 
46  const std::vector<std::string> flagnamesEE =
47  iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
48 
49  flagsexclEB_=
50  StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
51 
53  StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
54 
55  const std::vector<std::string> severitynamesEB =
56  iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
57 
59  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
60 
61  const std::vector<std::string> severitynamesEE =
62  iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
63 
65  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
66 
67  //register your products
68  produces< DetIdCollection > (interestingDetIdCollection_) ;
69 }
70 
72 {}
73 
75 {}
76 
77 // ------------ method called to produce the data ------------
78  void
80  using namespace edm;
81  using namespace std;
82 
83  //Get EM Object
85  iEvent.getByLabel(emObjectLabel_,emObjectH);
86 
87  // take EcalRecHits
89  iEvent.getByLabel(recHitsLabel_,recHitsH);
90  std::auto_ptr<CaloRecHitMetaCollectionV> recHits_(0);
91  recHits_ = std::auto_ptr<CaloRecHitMetaCollectionV>(new EcalRecHitMetaCollection(*recHitsH));
92 
94  iSetup.get<CaloGeometryRecord>().get(pG);
95  const CaloGeometry* caloGeom = pG.product();
96 
97  //Get the channel status from the db
98  //edm::ESHandle<EcalChannelStatus> chStatus;
99  //iSetup.get<EcalChannelStatusRcd>().get(chStatus);
100 
102  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
103  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
104 
105  CaloDualConeSelector *doubleConeSel_ = 0;
106  if(recHitsLabel_.instance() == "EcalRecHitsEB")
108  else if(recHitsLabel_.instance() == "EcalRecHitsEE")
110 
111  //Create empty output collections
112  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
113 
114  reco::GsfElectronCollection::const_iterator emObj;
115  if(doubleConeSel_) { //if cone selector was created
116  for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) { //Loop over candidates
117 
118  if(emObj->et() < etCandCut_) continue; //don't calculate if object hasn't enough energy
119 
120  GlobalPoint pclu (emObj->caloPosition().x(),emObj->caloPosition().y(),emObj->caloPosition().z());
121  std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*recHits_);
122 
124  for (recIt = chosen->begin(); recIt!= chosen->end () ; ++recIt) { // Select RecHits
125 
126  if (recIt->energy() < energyCut_)
127  continue; //dont fill if below E noise value
128 
129  double et = recIt->energy() *
130  caloGeom->getPosition(recIt->detid()).perp() /
131  caloGeom->getPosition(recIt->detid()).mag();
132 
133  bool isBarrel = false;
134  if (fabs(caloGeom->getPosition(recIt->detid()).eta() < 1.479))
135  isBarrel = true;
136 
137  if (et < etCut_)
138  continue; //dont fill if below ET noise value
139 
140  std::vector<int>::const_iterator sit;
141  int severityFlag = sevLevel->severityLevel(recIt->detid(), *recHitsH);
142  if (isBarrel) {
143  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
144  if (sit != severitiesexclEB_.end())
145  continue;
146  } else {
147  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
148  if (sit != severitiesexclEE_.end())
149  continue;
150  }
151 
152  std::vector<int>::const_iterator vit;
153  if (isBarrel) {
154  // new rechit flag checks
155  //vit = std::find(flagsexclEB_.begin(), flagsexclEB_.end(), ((EcalRecHit*)(&*recIt))->recoFlag());
156  //if (vit != flagsexclEB_.end())
157  // continue;
158  if (!((EcalRecHit*)(&*recIt))->checkFlag(EcalRecHit::kGood)) {
159  if (((EcalRecHit*)(&*recIt))->checkFlags(flagsexclEB_)) {
160  continue;
161  }
162  }
163  } else {
164  // new rechit flag checks
165  //vit = std::find(flagsexclEE_.begin(), flagsexclEE_.end(), ((EcalRecHit*)(&*recIt))->recoFlag());
166  //if (vit != flagsexclEE_.end())
167  // continue;
168  if (!((EcalRecHit*)(&*recIt))->checkFlag(EcalRecHit::kGood)) {
169  if (((EcalRecHit*)(&*recIt))->checkFlags(flagsexclEE_)) {
170  continue;
171  }
172  }
173  }
174 
175  if(std::find(detIdCollection->begin(),detIdCollection->end(),recIt->detid()) == detIdCollection->end())
176  detIdCollection->push_back(recIt->detid());
177  } //end rechits
178 
179  } //end candidates
180 
181  delete doubleConeSel_;
182  } //end if cone selector was created
183 
184  iEvent.put( detIdCollection, interestingDetIdCollection_ );
185 }
T getParameter(std::string const &) const
const DetId & detid() const
Definition: CaloRecHit.h:22
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
EleIsoDetIdCollectionProducer(const edm::ParameterSet &)
ctor
virtual void produce(edm::Event &, const edm::EventSetup &)
producer
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
float energy() const
Definition: CaloRecHit.h:19
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
const T & get() const
Definition: EventSetup.h:55
T perp() const
Magnitude of transverse component.
SimpleCaloRecHitMetaCollection< EcalRecHitCollection > EcalRecHitMetaCollection
edm::EDCollection< DetId > DetIdCollection
std::string const & instance() const
Definition: InputTag.h:43