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