CMS 3D CMS Logo

HiSpikeCleaner.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //111
3 // Package: HiSpikeCleaner
4 // Class: HiSpikeCleaner
5 //
13 //
14 // Original Author: Yong Kim,32 4-A08,+41227673039,
15 // Created: Mon Nov 1 18:22:21 CET 2010
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
27 
30 
33 
36 
41 
42 //
43 // class declaration
44 //
45 
47 public:
48  explicit HiSpikeCleaner(const edm::ParameterSet&);
49  ~HiSpikeCleaner() override;
50 
51 private:
52  void produce(edm::Event&, const edm::EventSetup&) override;
53 
54  // ----------member data ---------------------------
55 
59 
61  double TimingCut_;
62  double swissCutThr_;
63  double etCut_;
64 };
65 
67  //register your products
68  /* Examples
69  produces<ExampleData2>();
70 
71  //if do put with a label
72  produces<ExampleData2>("label");
73 */
74  //now do what ever other initialization is needed
75 
76  rHInputProducerBToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitProducerBarrel"));
77  rHInputProducerEToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitProducerEndcap"));
78 
80  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("originalSuperClusterProducer"));
81  TimingCut_ = iConfig.getUntrackedParameter<double>("TimingCut", 4.0);
82  swissCutThr_ = iConfig.getUntrackedParameter<double>("swissCutThr", 0.95);
83  etCut_ = iConfig.getParameter<double>("etCut");
84 
85  outputCollection_ = iConfig.getParameter<std::string>("outputColl");
86  produces<reco::SuperClusterCollection>(outputCollection_);
87 }
88 
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 }
93 
94 //
95 // member functions
96 //
97 
98 // ------------ method called to produce the data ------------
100  using namespace edm;
101 
102  // Get raw SuperClusters from the event
103  Handle<reco::SuperClusterCollection> pRawSuperClusters;
104  try {
105  iEvent.getByToken(sCInputProducerToken_, pRawSuperClusters);
106  } catch (cms::Exception& ex) {
107  edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the rawSuperClusters ";
108  }
109 
110  // Get the RecHits from the event
112  try {
113  iEvent.getByToken(rHInputProducerBToken_, pRecHitsB);
114  } catch (cms::Exception& ex) {
115  edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the RecHits ";
116  }
117 
118  // Get the RecHits from the event
120  try {
121  iEvent.getByToken(rHInputProducerEToken_, pRecHitsE);
122  } catch (cms::Exception& ex) {
123  edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the RecHits ";
124  }
125 
126  // get the channel status from the DB
127  // edm::ESHandle<EcalChannelStatus> chStatus;
128  // iSetup.get<EcalChannelStatusRcd>().get(chStatus);
129 
130  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
131  iSetup.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
132 
133  // Create a pointer to the RecHits and raw SuperClusters
134  const reco::SuperClusterCollection* rawClusters = pRawSuperClusters.product();
135 
137 
138  // Define a collection of corrected SuperClusters to put back into the event
139  auto corrClusters = std::make_unique<reco::SuperClusterCollection>();
140 
141  // Loop over raw clusters and make corrected ones
142  reco::SuperClusterCollection::const_iterator aClus;
143  for (aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++) {
144  double theEt = aClus->energy() / cosh(aClus->eta());
145  // std::cout << " et of SC = " << theEt << std::endl;
146 
147  if (theEt < etCut_)
148  continue; // cut off low pT superclusters
149 
150  bool flagS = true;
151  float swissCrx(0);
152 
153  const reco::CaloClusterPtr seed = aClus->seed();
154  DetId id = lazyTool.getMaximum(*seed).first;
155  const EcalRecHitCollection& rechits = *pRecHitsB;
157 
158  if (it != rechits.end()) {
159  ecalSevLvlAlgoHndl->severityLevel(id, rechits);
160  swissCrx = EcalTools::swissCross(id, rechits, 0., true);
161  // std::cout << "swissCross = " << swissCrx <<std::endl;
162  // std::cout << " timing = " << it->time() << std::endl;
163  }
164 
165  if (fabs(it->time()) > TimingCut_) {
166  flagS = false;
167  // std::cout << " timing = " << it->time() << std::endl;
168  // std::cout << " timing is bad........" << std::endl;
169  }
170  if (swissCrx > (float)swissCutThr_) {
171  flagS = false; // swissCross cut
172  // std::cout << "swissCross = " << swissCrx <<std::endl;
173  // std::cout << " removed by swiss cross cut" << std::endl;
174  }
175  // - kGood --> good channel
176  // - kProblematic --> problematic (e.g. noisy)
177  // - kRecovered --> recovered (e.g. an originally dead or saturated)
178  // - kTime --> the channel is out of time (e.g. spike)
179  // - kWeird --> weird (e.g. spike)
180  // - kBad --> bad, not suitable to be used in the reconstruction
181  // enum EcalSeverityLevel { kGood=0, kProblematic, kRecovered, kTime, kWeird, kBad };
182 
183  reco::SuperCluster newClus;
184  if (flagS == true)
185  newClus = *aClus;
186  else
187  continue;
188  corrClusters->push_back(newClus);
189  }
190 
191  // Put collection of corrected SuperClusters into the event
192  iEvent.put(std::move(corrClusters), outputCollection_);
193 }
194 
195 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< reco::SuperClusterCollection > sCInputProducerToken_
std::vector< EcalRecHit >::const_iterator const_iterator
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::string outputCollection_
HiSpikeCleaner(const edm::ParameterSet &)
Definition: DetId.h:17
void produce(edm::Event &, const edm::EventSetup &) override
T const * product() const
Definition: Handle.h:69
static float swissCross(const DetId &id, const EcalRecHitCollection &recHits, float recHitThreshold, bool avoidIeta85=true)
the good old 1-e4/e1. Ignore hits below recHitThreshold
Definition: EcalTools.cc:11
HLT enums.
T get() const
Definition: EventSetup.h:73
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducerBToken_
~HiSpikeCleaner() override
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducerEToken_
def move(src, dest)
Definition: eostools.py:511