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 
60 
62  double TimingCut_;
63  double swissCutThr_;
64  double etCut_;
65 };
66 
67 HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig) : ecalClusterToolsESGetTokens_{consumesCollector()} {
68  //register your products
69  /* Examples
70  produces<ExampleData2>();
71 
72  //if do put with a label
73  produces<ExampleData2>("label");
74 */
75  //now do what ever other initialization is needed
76 
77  rHInputProducerBToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitProducerBarrel"));
78  rHInputProducerEToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitProducerEndcap"));
79 
80  sCInputProducerToken_ =
81  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("originalSuperClusterProducer"));
82  TimingCut_ = iConfig.getUntrackedParameter<double>("TimingCut", 4.0);
83  swissCutThr_ = iConfig.getUntrackedParameter<double>("swissCutThr", 0.95);
84  etCut_ = iConfig.getParameter<double>("etCut");
85 
86  outputCollection_ = iConfig.getParameter<std::string>("outputColl");
87  produces<reco::SuperClusterCollection>(outputCollection_);
88 }
89 
91  // do anything here that needs to be done at desctruction time
92  // (e.g. close files, deallocate resources etc.)
93 }
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to produce the data ------------
101  using namespace edm;
102 
103  // Get raw SuperClusters from the event
104  Handle<reco::SuperClusterCollection> pRawSuperClusters;
105  try {
106  iEvent.getByToken(sCInputProducerToken_, pRawSuperClusters);
107  } catch (cms::Exception& ex) {
108  edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the rawSuperClusters ";
109  }
110 
111  // Get the RecHits from the event
113  try {
114  iEvent.getByToken(rHInputProducerBToken_, pRecHitsB);
115  } catch (cms::Exception& ex) {
116  edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the RecHits ";
117  }
118 
119  // Get the RecHits from the event
121  try {
122  iEvent.getByToken(rHInputProducerEToken_, pRecHitsE);
123  } catch (cms::Exception& ex) {
124  edm::LogError("EgammaSCCorrectionMakerError") << "Error! can't get the RecHits ";
125  }
126 
127  // get the channel status from the DB
128  // edm::ESHandle<EcalChannelStatus> chStatus;
129  // iSetup.get<EcalChannelStatusRcd>().get(chStatus);
130 
131  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
132  iSetup.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
133 
134  // Create a pointer to the RecHits and raw SuperClusters
135  const reco::SuperClusterCollection* rawClusters = pRawSuperClusters.product();
136 
137  EcalClusterLazyTools lazyTool(
139 
140  // Define a collection of corrected SuperClusters to put back into the event
141  auto corrClusters = std::make_unique<reco::SuperClusterCollection>();
142 
143  // Loop over raw clusters and make corrected ones
144  reco::SuperClusterCollection::const_iterator aClus;
145  for (aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++) {
146  double theEt = aClus->energy() / cosh(aClus->eta());
147  // std::cout << " et of SC = " << theEt << std::endl;
148 
149  if (theEt < etCut_)
150  continue; // cut off low pT superclusters
151 
152  bool flagS = true;
153  float swissCrx(0);
154 
155  const reco::CaloClusterPtr seed = aClus->seed();
156  DetId id = lazyTool.getMaximum(*seed).first;
157  const EcalRecHitCollection& rechits = *pRecHitsB;
159 
160  if (it != rechits.end()) {
161  ecalSevLvlAlgoHndl->severityLevel(id, rechits);
162  swissCrx = EcalTools::swissCross(id, rechits, 0., true);
163  // std::cout << "swissCross = " << swissCrx <<std::endl;
164  // std::cout << " timing = " << it->time() << std::endl;
165  }
166 
167  if (fabs(it->time()) > TimingCut_) {
168  flagS = false;
169  // std::cout << " timing = " << it->time() << std::endl;
170  // std::cout << " timing is bad........" << std::endl;
171  }
172  if (swissCrx > (float)swissCutThr_) {
173  flagS = false; // swissCross cut
174  // std::cout << "swissCross = " << swissCrx <<std::endl;
175  // std::cout << " removed by swiss cross cut" << std::endl;
176  }
177  // - kGood --> good channel
178  // - kProblematic --> problematic (e.g. noisy)
179  // - kRecovered --> recovered (e.g. an originally dead or saturated)
180  // - kTime --> the channel is out of time (e.g. spike)
181  // - kWeird --> weird (e.g. spike)
182  // - kBad --> bad, not suitable to be used in the reconstruction
183  // enum EcalSeverityLevel { kGood=0, kProblematic, kRecovered, kTime, kWeird, kBad };
184 
185  reco::SuperCluster newClus;
186  if (flagS == true)
187  newClus = *aClus;
188  else
189  continue;
190  corrClusters->push_back(newClus);
191  }
192 
193  // Put collection of corrected SuperClusters into the event
194  iEvent.put(std::move(corrClusters), outputCollection_);
195 }
196 
197 //define this as a plug-in
HiSpikeCleaner::HiSpikeCleaner
HiSpikeCleaner(const edm::ParameterSet &)
Definition: HiSpikeCleaner.cc:67
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalSeverityLevelAlgo::severityLevel
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Definition: EcalSeverityLevelAlgo.cc:85
ESHandle.h
reco::SuperCluster
Definition: SuperCluster.h:18
EcalSeverityLevelAlgoRcd.h
edm::EDGetTokenT< reco::SuperClusterCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
EDProducer.h
edm::SortedCollection< EcalRecHit >
HiSpikeCleaner::rHInputProducerBToken_
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducerBToken_
Definition: HiSpikeCleaner.cc:57
PhotonFwd.h
EcalClusterLazyTools.h
HiSpikeCleaner::ecalClusterToolsESGetTokens_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
Definition: HiSpikeCleaner.cc:59
EcalTools::swissCross
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:9
edm::Handle
Definition: AssociativeIterator.h:50
HiSpikeCleaner::etCut_
double etCut_
Definition: HiSpikeCleaner.cc:64
fileCollector.seed
seed
Definition: fileCollector.py:127
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
DetId
Definition: DetId.h:17
MakerMacros.h
Photon.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESHandle< EcalSeverityLevelAlgo >
EcalSeverityLevelAlgoRcd
Definition: EcalSeverityLevelAlgoRcd.h:12
HiSpikeCleaner::~HiSpikeCleaner
~HiSpikeCleaner() override
Definition: HiSpikeCleaner.cc:90
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
EcalClusterLazyToolsBase::ESGetTokens
Definition: EcalClusterLazyTools.h:55
EcalClusterLazyTools
EcalSeverityLevelAlgo.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HiSpikeCleaner::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HiSpikeCleaner.cc:100
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
EcalTools.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalClusterLazyToolsBase::ESGetTokens::get
ESData get(edm::EventSetup const &eventSetup) const
Definition: EcalClusterLazyTools.h:64
InputTag.h
edm::Ptr< CaloCluster >
HiSpikeCleaner::rHInputProducerEToken_
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducerEToken_
Definition: HiSpikeCleaner.cc:58
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
HiSpikeCleaner::swissCutThr_
double swissCutThr_
Definition: HiSpikeCleaner.cc:63
HiSpikeCleaner::TimingCut_
double TimingCut_
Definition: HiSpikeCleaner.cc:62
EventSetup.h
HiSpikeCleaner::sCInputProducerToken_
edm::EDGetTokenT< reco::SuperClusterCollection > sCInputProducerToken_
Definition: HiSpikeCleaner.cc:56
cms::Exception
Definition: Exception.h:70
HiSpikeCleaner::outputCollection_
std::string outputCollection_
Definition: HiSpikeCleaner.cc:61
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
HiSpikeCleaner
Definition: HiSpikeCleaner.cc:46