CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GamIsoDetIdCollectionProducer.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  const edm::EventSetup& iSetup)
81 {
82  using namespace edm;
83  using namespace std;
84 
85  //Get EM Object
87  iEvent.getByLabel(emObjectLabel_,emObjectH);
88 
89  // take EcalRecHits
91  iEvent.getByLabel(recHitsLabel_,recHitsH);
92  std::auto_ptr<CaloRecHitMetaCollectionV> recHits_(0);
93  recHits_ = std::auto_ptr<CaloRecHitMetaCollectionV>(new EcalRecHitMetaCollection(*recHitsH));
94 
96  iSetup.get<CaloGeometryRecord>().get(pG);
97  const CaloGeometry* caloGeom = pG.product();
98 
100  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
101  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
102 
103  CaloDualConeSelector *doubleConeSel_ = 0;
104  if(recHitsLabel_.instance() == "EcalRecHitsEB")
106  else if(recHitsLabel_.instance() == "EcalRecHitsEE")
108 
109  //Create empty output collections
110  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
111 
112  reco::PhotonCollection::const_iterator emObj;
113  if(doubleConeSel_) { //if cone selector was created
114  for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) { //Loop over candidates
115 
116  if(emObj->et() < etCandCut_) continue;
117 
118  GlobalPoint pclu (emObj->caloPosition().x(),emObj->caloPosition().y(),emObj->caloPosition().z());
119  std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*recHits_);
120 
122  for (recIt = chosen->begin(); recIt!= chosen->end () ; ++recIt) { // Select RecHits
123 
124  if ( (recIt->energy()) < energyCut_) continue; //dont fill if below E noise value
125 
126  double et = recIt->energy() *
127  caloGeom->getPosition(recIt->detid()).perp() /
128  caloGeom->getPosition(recIt->detid()).mag();
129 
130  if ( et < etCut_) continue; //dont fill if below ET noise value
131 
132  bool isBarrel = false;
133  if (fabs(caloGeom->getPosition(recIt->detid()).eta() < 1.479))
134  isBarrel = true;
135 
136  int severityFlag = sevLevel->severityLevel(recIt->detid(), *recHitsH);
137  std::vector<int>::const_iterator sit;
138  if (isBarrel) {
139  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
140  if (sit!= severitiesexclEB_.end())
141  continue;
142  } else {
143  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
144  if (sit!= severitiesexclEE_.end())
145  continue;
146  }
147 
148  std::vector<int>::const_iterator vit;
149  if (isBarrel) {
150  // new rechit flag checks
151  //vit = std::find(flagsexclEB_.begin(), flagsexclEB_.end(), ((EcalRecHit*)(&*recIt))->recoFlag());
152  //if (vit != flagsexclEB_.end())
153  // continue;
154  if (!((EcalRecHit*)(&*recIt))->checkFlag(EcalRecHit::kGood)) {
155  if (((EcalRecHit*)(&*recIt))->checkFlags(flagsexclEB_)) {
156  continue;
157  }
158  }
159  } else {
160  // new rechit flag checks
161  //vit = std::find(flagsexclEE_.begin(), flagsexclEE_.end(), ((EcalRecHit*)(&*recIt))->recoFlag());
162  //if (vit != flagsexclEE_.end())
163  // continue;
164  if (!((EcalRecHit*)(&*recIt))->checkFlag(EcalRecHit::kGood)) {
165  if (((EcalRecHit*)(&*recIt))->checkFlags(flagsexclEE_)) {
166  continue;
167  }
168  }
169  }
170 
171  if(std::find(detIdCollection->begin(),detIdCollection->end(),recIt->detid()) == detIdCollection->end())
172  detIdCollection->push_back(recIt->detid());
173  } //end rechits
174 
175  } //end candidates
176 
177  delete doubleConeSel_;
178  } //end if cone selector was created
179 
180  iEvent.put( detIdCollection, interestingDetIdCollection_ );
181 }
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())
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
virtual void produce(edm::Event &, const edm::EventSetup &)
producer
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
GamIsoDetIdCollectionProducer(const edm::ParameterSet &)
ctor
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