CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
26 
29 
32 
35 
40 
41 //
42 // class declaration
43 //
44 
46 public:
47  explicit HiSpikeCleaner(const edm::ParameterSet&);
48  ~HiSpikeCleaner() override;
49 
50 private:
51  void produce(edm::Event&, const edm::EventSetup&) override;
52 
53  // ----------member data ---------------------------
54 
60 
62  double TimingCut_;
63  double swissCutThr_;
64  double etCut_;
65 };
66 
68  : ecalSevLvlAlgoToken_(esConsumes()), ecalClusterToolsESGetTokens_{consumesCollector()} {
69  //register your products
70  /* Examples
71  produces<ExampleData2>();
72 
73  //if do put with a label
74  produces<ExampleData2>("label");
75 */
76  //now do what ever other initialization is needed
77 
78  rHInputProducerBToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitProducerBarrel"));
79  rHInputProducerEToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitProducerEndcap"));
80 
81  sCInputProducerToken_ =
82  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("originalSuperClusterProducer"));
83  TimingCut_ = iConfig.getUntrackedParameter<double>("TimingCut", 4.0);
84  swissCutThr_ = iConfig.getUntrackedParameter<double>("swissCutThr", 0.95);
85  etCut_ = iConfig.getParameter<double>("etCut");
86 
87  outputCollection_ = iConfig.getParameter<std::string>("outputColl");
88  produces<reco::SuperClusterCollection>(outputCollection_);
89 }
90 
92  // do anything here that needs to be done at desctruction time
93  // (e.g. close files, deallocate resources etc.)
94 }
95 
96 //
97 // member functions
98 //
99 
100 // ------------ method called to produce the data ------------
102  using namespace edm;
103 
104  // Get raw SuperClusters from the event
105  Handle<reco::SuperClusterCollection> pRawSuperClusters;
106  iEvent.getByToken(sCInputProducerToken_, pRawSuperClusters);
107 
108  // Get the RecHits from the event
110  iEvent.getByToken(rHInputProducerBToken_, pRecHitsB);
111 
112  // Get the RecHits from the event
114  iEvent.getByToken(rHInputProducerEToken_, pRecHitsE);
115 
116  // get the channel status from the DB
117  // edm::ESHandle<EcalChannelStatus> chStatus;
118  // iSetup.get<EcalChannelStatusRcd>().get(chStatus);
119 
120  auto const& ecalSevLvlAlgo = iSetup.getData(ecalSevLvlAlgoToken_);
121 
122  // Create a pointer to the RecHits and raw SuperClusters
123  const reco::SuperClusterCollection* rawClusters = pRawSuperClusters.product();
124 
125  EcalClusterLazyTools lazyTool(
127 
128  // Define a collection of corrected SuperClusters to put back into the event
129  auto corrClusters = std::make_unique<reco::SuperClusterCollection>();
130 
131  // Loop over raw clusters and make corrected ones
132  reco::SuperClusterCollection::const_iterator aClus;
133  for (aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++) {
134  double theEt = aClus->energy() / cosh(aClus->eta());
135  // std::cout << " et of SC = " << theEt << std::endl;
136 
137  if (theEt < etCut_)
138  continue; // cut off low pT superclusters
139 
140  bool flagS = true;
141  float swissCrx(0);
142 
143  const reco::CaloClusterPtr seed = aClus->seed();
144  DetId id = lazyTool.getMaximum(*seed).first;
145  const EcalRecHitCollection& rechits = *pRecHitsB;
147 
148  if (it != rechits.end()) {
149  ecalSevLvlAlgo.severityLevel(id, rechits);
150  swissCrx = EcalTools::swissCross(id, rechits, 0., true);
151  // std::cout << "swissCross = " << swissCrx <<std::endl;
152  // std::cout << " timing = " << it->time() << std::endl;
153  }
154 
155  if (fabs(it->time()) > TimingCut_) {
156  flagS = false;
157  // std::cout << " timing = " << it->time() << std::endl;
158  // std::cout << " timing is bad........" << std::endl;
159  }
160  if (swissCrx > (float)swissCutThr_) {
161  flagS = false; // swissCross cut
162  // std::cout << "swissCross = " << swissCrx <<std::endl;
163  // std::cout << " removed by swiss cross cut" << std::endl;
164  }
165  // - kGood --> good channel
166  // - kProblematic --> problematic (e.g. noisy)
167  // - kRecovered --> recovered (e.g. an originally dead or saturated)
168  // - kTime --> the channel is out of time (e.g. spike)
169  // - kWeird --> weird (e.g. spike)
170  // - kBad --> bad, not suitable to be used in the reconstruction
171  // enum EcalSeverityLevel { kGood=0, kProblematic, kRecovered, kTime, kWeird, kBad };
172 
173  reco::SuperCluster newClus;
174  if (flagS == true)
175  newClus = *aClus;
176  else
177  continue;
178  corrClusters->push_back(newClus);
179  }
180 
181  // Put collection of corrected SuperClusters into the event
182  iEvent.put(std::move(corrClusters), outputCollection_);
183 }
184 
185 //define this as a plug-in
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > ecalSevLvlAlgoToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< reco::SuperClusterCollection > sCInputProducerToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< EcalRecHit >::const_iterator const_iterator
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
def move
Definition: eostools.py:511
std::string outputCollection_
const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
HiSpikeCleaner(const edm::ParameterSet &)
Definition: DetId.h:17
void produce(edm::Event &, const edm::EventSetup &) override
ESData get(edm::EventSetup const &eventSetup) const
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::EDGetTokenT< EcalRecHitCollection > rHInputProducerBToken_
~HiSpikeCleaner() override
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducerEToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283