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 
6 
8 
19 
22 
24 
27 
30 
32  recHitsLabel_(iConfig.getParameter< edm::InputTag > ("recHitsLabel")),
33  emObjectLabel_(iConfig.getParameter< edm::InputTag > ("emObjectLabel")),
34  energyCut_(iConfig.getParameter<double>("energyCut")),
35  etCut_(iConfig.getParameter<double>("etCut")),
36  etCandCut_(iConfig.getParameter<double> ("etCandCut")),
37  outerRadius_(iConfig.getParameter<double>("outerRadius")),
38  innerRadius_(iConfig.getParameter<double>("innerRadius")),
39  interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection")),
40  severityLevelCut_(iConfig.getParameter<int>("severityLevelCut")),
41  //severityRecHitThreshold_(iConfig.getParameter<double>("severityRecHitThreshold")),
42  //spIdString_(iConfig.getParameter<std::string>("spikeIdString")),
43  //spIdThreshold_(iConfig.getParameter<double>("spikeIdThreshold")),
44  v_chstatus_(iConfig.getParameter<std::vector<int> >("recHitFlagsToBeExcluded")) {
45 
46 // if ( !spIdString_.compare("kE1OverE9") ) spId_ = EcalSeverityLevelAlgo::kE1OverE9;
47 // else if( !spIdString_.compare("kSwissCross") ) spId_ = EcalSeverityLevelAlgo::kSwissCross;
48 // else if( !spIdString_.compare("kSwissCrossBordersIncluded") ) spId_ = EcalSeverityLevelAlgo::kSwissCrossBordersIncluded;
49 // else spId_ = EcalSeverityLevelAlgo::kSwissCross;
50 
51  //register your products
52  produces< DetIdCollection > (interestingDetIdCollection_) ;
53 }
54 
56 
58 {}
59 
60 // ------------ method called to produce the data ------------
61  void
63  const edm::EventSetup& iSetup)
64 {
65  using namespace edm;
66  using namespace std;
67 
68  //Get EM Object
70  iEvent.getByLabel(emObjectLabel_,emObjectH);
71 
72  // take EcalRecHits
74  iEvent.getByLabel(recHitsLabel_,recHitsH);
75  std::auto_ptr<CaloRecHitMetaCollectionV> recHits_(0);
76  recHits_ = std::auto_ptr<CaloRecHitMetaCollectionV>(new EcalRecHitMetaCollection(*recHitsH));
77 
79  iSetup.get<CaloGeometryRecord>().get(pG);
80  const CaloGeometry* caloGeom = pG.product();
81 
82  //Get the channel status from the db
84  iSetup.get<EcalChannelStatusRcd>().get(chStatus);
85 
87  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
88  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
89 
90  CaloDualConeSelector *doubleConeSel_ = 0;
91  if(recHitsLabel_.instance() == "EcalRecHitsEB")
93  else if(recHitsLabel_.instance() == "EcalRecHitsEE")
95 
96  //Create empty output collections
97  std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
98 
99  reco::PhotonCollection::const_iterator emObj;
100  if(doubleConeSel_) { //if cone selector was created
101  for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) { //Loop over candidates
102 
103  if(emObj->et() < etCandCut_) continue;
104 
105  GlobalPoint pclu (emObj->caloPosition().x(),emObj->caloPosition().y(),emObj->caloPosition().z());
106  std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*recHits_);
107 
109  for (recIt = chosen->begin(); recIt!= chosen->end () ; ++recIt) { // Select RecHits
110 
111  if ( fabs(recIt->energy()) < energyCut_) continue; //dont fill if below E noise value
112 
113  double et = recIt->energy() *
114  caloGeom->getPosition(recIt->detid()).perp() /
115  caloGeom->getPosition(recIt->detid()).mag();
116 
117  if ( fabs(et) < etCut_) continue; //dont fill if below ET noise value
118 
119  //make sure we have a barrel rechit
120  //call the severity level method
121  //passing the EBDetId
122  //the rechit collection in order to calculate the swiss crss
123  //and the EcalChannelRecHitRcd
124  //only consider rechits with ET >
125  //the SpikeId method (currently kE1OverE9 or kSwissCross)
126  //cut value for above
127  //then if the severity level is too high, we continue to the next rechit
128  if(recHitsLabel_.instance() == "EcalRecHitsEB" &&
129  sevLevel->severityLevel(EBDetId(recIt->detid()), *recHitsH)>= severityLevelCut_) continue;
130  // *chStatus,
131  // severityRecHitThreshold_,
132  // spId_,
133  // spIdThreshold_
134  // ) >= severityLevelCut_) continue;
135 
136  //Check based on flags to protect from recovered channels from non-read towers
137  //Assumption is that v_chstatus_ is empty unless doFlagChecks() has been called
138  std::vector<int>::const_iterator vit = std::find( v_chstatus_.begin(), v_chstatus_.end(), ((EcalRecHit*)(&*recIt))->recoFlag() );
139  if ( vit != v_chstatus_.end() ) continue; // the recHit has to be excluded from the iso sum
140 
141  if(std::find(detIdCollection->begin(),detIdCollection->end(),recIt->detid()) == detIdCollection->end())
142  detIdCollection->push_back(recIt->detid());
143  } //end rechits
144 
145  } //end candidates
146 
147  delete doubleConeSel_;
148  } //end if cone selector was created
149 
150  iEvent.put( detIdCollection, interestingDetIdCollection_ );
151 }
const DetId & detid() const
Definition: CaloRecHit.h:21
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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:84
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:355
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:26