CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
20 // system include files
21 #include <memory>
22 
23 // user include files
28 
31 
34 
37 
42 
43 
44 
45 //
46 // class declaration
47 //
48 
50  public:
51  explicit HiSpikeCleaner(const edm::ParameterSet&);
53 
54  private:
55  virtual void beginJob() override ;
56  virtual void produce(edm::Event&, const edm::EventSetup&) override;
57  virtual void endJob() override ;
58 
59  // ----------member data ---------------------------
60 
64 
66  double TimingCut_;
67  double swissCutThr_;
68  double etCut_;
69 
70 };
71 
72 //
73 // constants, enums and typedefs
74 //
75 
76 
77 //
78 // static data member definitions
79 //
80 
81 //
82 // constructors and destructor
83 //
85 {
86  //register your products
87 /* Examples
88  produces<ExampleData2>();
89 
90  //if do put with a label
91  produces<ExampleData2>("label");
92 */
93  //now do what ever other initialization is needed
94 
95  rHInputProducerB_ = iConfig.getParameter<edm::InputTag>("recHitProducerBarrel");
96  rHInputProducerE_ = iConfig.getParameter<edm::InputTag>("recHitProducerEndcap");
97 
98  sCInputProducer_ = iConfig.getParameter<edm::InputTag>("originalSuperClusterProducer");
99  TimingCut_ = iConfig.getUntrackedParameter<double> ("TimingCut",4.0);
100  swissCutThr_ = iConfig.getUntrackedParameter<double>("swissCutThr",0.95);
101  etCut_ = iConfig.getParameter<double>("etCut");
102 
103  outputCollection_ = iConfig.getParameter<std::string>("outputColl");
104  produces<reco::SuperClusterCollection>(outputCollection_);
105 
106 
107 
108 }
109 
110 
112 {
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 }
116 
117 
118 //
119 // member functions
120 //
121 
122 // ------------ method called to produce the data ------------
123 void
125 {
126  using namespace edm;
127 
128 
129  // Get raw SuperClusters from the event
130  Handle<reco::SuperClusterCollection> pRawSuperClusters;
131  try {
132  iEvent.getByLabel(sCInputProducer_, pRawSuperClusters);
133  } catch ( cms::Exception& ex ) {
134  edm::LogError("EgammaSCCorrectionMakerError")
135  << "Error! can't get the rawSuperClusters "
136  << sCInputProducer_.label() ;
137  }
138 
139  // Get the RecHits from the event
141  try {
142  iEvent.getByLabel(rHInputProducerB_, pRecHitsB);
143  } catch ( cms::Exception& ex ) {
144  edm::LogError("EgammaSCCorrectionMakerError")
145  << "Error! can't get the RecHits "
147  }
148  // Get the RecHits from the event
150  try {
151  iEvent.getByLabel(rHInputProducerE_, pRecHitsE);
152  } catch ( cms::Exception& ex ) {
153  edm::LogError("EgammaSCCorrectionMakerError")
154  << "Error! can't get the RecHits "
156  }
157 
158 
159  // get the channel status from the DB
160  // edm::ESHandle<EcalChannelStatus> chStatus;
161  // iSetup.get<EcalChannelStatusRcd>().get(chStatus);
162 
163  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
164  iSetup.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
165 
166 
167  // Create a pointer to the RecHits and raw SuperClusters
168  const reco::SuperClusterCollection *rawClusters = pRawSuperClusters.product();
169 
170 
171  EcalClusterLazyTools lazyTool(iEvent, iSetup, rHInputProducerB_,rHInputProducerE_);
172 
173  // Define a collection of corrected SuperClusters to put back into the event
174  std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
175 
176  // Loop over raw clusters and make corrected ones
177  reco::SuperClusterCollection::const_iterator aClus;
178  for(aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++)
179  {
180  double theEt = aClus->energy()/cosh( aClus->eta() ) ;
181  // std::cout << " et of SC = " << theEt << std::endl;
182 
183  if ( theEt < etCut_ ) continue; // cut off low pT superclusters
184 
185  bool flagS = true;
186  float swissCrx(0);
187 
188  const reco::CaloClusterPtr seed = aClus->seed();
189  DetId id = lazyTool.getMaximum(*seed).first;
190  const EcalRecHitCollection & rechits = *pRecHitsB;
192 
193  if( it != rechits.end() ) {
194  ecalSevLvlAlgoHndl->severityLevel(id, rechits);
195  swissCrx = EcalTools::swissCross (id, rechits, 0.,true);
196  // std::cout << "swissCross = " << swissCrx <<std::endl;
197  // std::cout << " timing = " << it->time() << std::endl;
198  }
199 
200  if ( fabs(it->time()) > TimingCut_ ) {
201  flagS = false;
202  // std::cout << " timing = " << it->time() << std::endl;
203  // std::cout << " timing is bad........" << std::endl;
204  }
205  if ( swissCrx > (float)swissCutThr_ ) {
206  flagS = false ; // swissCross cut
207  // std::cout << "swissCross = " << swissCrx <<std::endl;
208  // std::cout << " removed by swiss cross cut" << std::endl;
209  }
210  // - kGood --> good channel
211  // - kProblematic --> problematic (e.g. noisy)
212  // - kRecovered --> recovered (e.g. an originally dead or saturated)
213  // - kTime --> the channel is out of time (e.g. spike)
214  // - kWeird --> weird (e.g. spike)
215  // - kBad --> bad, not suitable to be used in the reconstruction
216  // enum EcalSeverityLevel { kGood=0, kProblematic, kRecovered, kTime, kWeird, kBad };
217 
218 
219  reco::SuperCluster newClus;
220  if ( flagS == true)
221  newClus=*aClus;
222  else
223  continue;
224  corrClusters->push_back(newClus);
225  }
226 
227  // Put collection of corrected SuperClusters into the event
228  iEvent.put(corrClusters, outputCollection_);
229 
230 }
231 
232 // ------------ method called once each job just before starting event loop ------------
233 void
235 {
236 }
237 
238 // ------------ method called once each job just after ending the event loop ------------
239 void
241 }
242 
243 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::InputTag rHInputProducerE_
std::vector< EcalRecHit >::const_iterator const_iterator
int iEvent
Definition: GenABIO.cc:243
edm::InputTag sCInputProducer_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::string outputCollection_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
HiSpikeCleaner(const edm::ParameterSet &)
Definition: DetId.h:18
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual void beginJob() override
const T & get() const
Definition: EventSetup.h:55
std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster)
std::string const & label() const
Definition: InputTag.h:42
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
edm::InputTag rHInputProducerB_
virtual void endJob() override
volatile std::atomic< bool > shutdown_flag false