CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalMIPRecHitFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalMIPRecHitFilter
4 // Class: EcalMIPRecHitFilter
5 //
13 //
14 // Original Author: Giovanni FRANZONI
15 // Created: Wed Sep 19 16:21:29 CEST 2007
16 // $Id: EcalMIPRecHitFilter.cc,v 1.7 2012/01/21 14:56:54 fwyzard Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <vector>
24 
25 // user include files
28 
32 
34 
38 
42 
47 
50 
51 //
52 // class declaration
53 //
54 
56  public:
57  explicit EcalMIPRecHitFilter(const edm::ParameterSet&);
59 
60  private:
61  virtual void beginJob() ;
62  virtual bool hltFilter(edm::Event&, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct);
63  virtual void endJob() ;
64 
65  // ----------member data ---------------------------
66 
68  double minAmp1_;
69  double minAmp2_;
70  double minSingleAmp_;
71  std::vector<int> maskedList_;
72  int side_;
73 
74 };
75 
76 //
77 // constructors and destructor
78 //
80  HLTFilter(iConfig)
81 {
82  // now do what ever initialization is needed
83  minSingleAmp_ = iConfig.getUntrackedParameter<double>("SingleAmpMin", 0.108);
84  minAmp1_ = iConfig.getUntrackedParameter<double>("AmpMinSeed", 0.063);
85  minAmp2_ = iConfig.getUntrackedParameter<double>("AmpMin2", 0.045);
86  maskedList_ = iConfig.getUntrackedParameter<std::vector<int> >("maskedChannels", maskedList_); //this is using the ashed index
87  EcalRecHitCollection_ = iConfig.getParameter<edm::InputTag>("EcalRecHitCollection");
88  side_ = iConfig.getUntrackedParameter<int>("side", 3);
89 }
90 
91 
93 {
94 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98 }
99 
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called on each new Event ------------
106 bool
108 {
109  using namespace edm;
110 
111  // getting very basic uncalRH
113  //try {
114  // iEvent.getByLabel(EcalRecHitCollection_, recHits);
115  //} catch ( std::exception& ex) {
116  // LogWarning("EcalMIPRecHitFilter") << EcalRecHitCollection_ << " not available";
117  //}
118  iEvent.getByLabel(EcalRecHitCollection_, recHits);
119  if (!recHits.isValid()){
120  LogWarning("EcalMIPRecHitFilter") << EcalRecHitCollection_ << " not available";
121  }
122 
123  ESHandle<CaloTopology> caloTopo;
124  iSetup.get<CaloTopologyRecord>().get(caloTopo);
125 
126  // Intercalib constants
128  iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
129  const EcalIntercalibConstants* ical = pIcal.product();
130  const EcalIntercalibConstantMap& icalMap=ical->getMap();
131 
133  iSetup.get<EcalLaserDbRecord>().get( pLaser );
134 
136  iSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
137  const EcalADCToGeVConstant* agc = pAgc.product();
138  //std::cout << "Global EB ADC->GeV scale: " << agc->getEBValue() << " GeV/ADC count" ;
139  float adcconst = agc->getEBValue();
140 
141  bool thereIsSignal = false;
142  // loop on rechits
143  for ( EcalRecHitCollection::const_iterator hitItr = recHits->begin(); hitItr != recHits->end(); ++hitItr ) {
144 
145  EcalRecHit hit = (*hitItr);
146 
147  // masking noisy channels //KEEP this for now, just in case a few show up
148  std::vector<int>::iterator result;
149  result = find( maskedList_.begin(), maskedList_.end(), EBDetId(hit.id()).hashedIndex() );
150  if (result != maskedList_.end())
151  // LogWarning("EcalFilter") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli_ ;
152  continue;
153 
154  float ampli_ = hit.energy();
155  EBDetId ebDet = hit.id();
156 
157  // find intercalib constant for this xtal
158  EcalIntercalibConstantMap::const_iterator icalit=icalMap.find(ebDet);
159  EcalIntercalibConstant icalconst = 1.;
160  if( icalit!=icalMap.end() ){
161  icalconst = (*icalit);
162  // LogDebug("EcalRecHitDebug") << "Found intercalib for xtal " << EBDetId(it->id()).ic() << " " << icalconst ;
163  } else {
164  //edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EBDetId(ebDet) << "! something wrong with EcalIntercalibConstants in your DB? " ;
165  }
166  float lasercalib = pLaser->getLaserCorrection( EBDetId(ebDet), iEvent.time() );
167 
168  ampli_ /= (icalconst * lasercalib * adcconst);
169  // seeking channels with signal and displaced jitter
170  if (ampli_ >= minSingleAmp_ )
171  {
172  //std::cout << " THIS AMPLITUDE WORKS " << ampli_ << std::endl;
173  thereIsSignal = true;
174  // LogWarning("EcalFilter") << "at evet: " << iEvent.id().event()
175  // << " and run: " << iEvent.id().run()
176  // << " there is OUT OF TIME signal at chanel: " << ic
177  // << " with amplitude " << ampli_ << " and max at: " << jitter_;
178  break;
179  }
180 
181  //Check for more robust selection other than just single crystal cosmics
182  if (ampli_ >= minAmp1_)
183  {
184  //std::cout << " THIS AMPLITUDE WORKS " << ampli_ << std::endl;
185  std::vector<DetId> neighbors = caloTopo->getWindow(ebDet,side_,side_);
186  float secondMin = 0.;
187  for(std::vector<DetId>::const_iterator detitr = neighbors.begin(); detitr != neighbors.end(); ++detitr)
188  {
189  EcalRecHitCollection::const_iterator thishit = recHits->find((*detitr));
190  if (thishit == recHits->end())
191  {
192  //LogWarning("EcalMIPRecHitFilter") << "No RecHit available, for "<< EBDetId(*detitr);
193  continue;
194  }
195  if ((*thishit).id() != ebDet)
196  {
197  float thisamp = (*thishit).energy();
198  // find intercalib constant for this xtal
199  EcalIntercalibConstantMap::const_iterator icalit2=icalMap.find((*thishit).id());
200  EcalIntercalibConstant icalconst2 = 1.;
201  if( icalit2!=icalMap.end() ){
202  icalconst2 = (*icalit2);
203  // LogDebug("EcalRecHitDebug") << "Found intercalib for xtal " << EBDetId(it->id()).ic() << " " << icalconst ;
204  } else {
205  //edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EBDetId(ebDet) << "! something wrong with EcalIntercalibConstants in your DB? " ;
206  }
207  float lasercalib2 = pLaser->getLaserCorrection( EBDetId((*thishit).id()), iEvent.time() );
208  thisamp /= (icalconst2 * lasercalib2 * adcconst);
209  if (thisamp > secondMin) secondMin = thisamp;
210  }
211  }
212 
213  if (secondMin > minAmp2_ )
214  {
215  thereIsSignal = true;
216  break;
217  }
218  }
219  }
220  //std::cout << " Ok is There one of THEM " << thereIsSignal << std::endl;
221  return thereIsSignal;
222 }
223 
224 // ------------ method called once each job just before starting event loop ------------
225 void
227 {
228 }
229 
230 // ------------ method called once each job just after ending the event loop ------------
231 void
233 }
234 
235 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
EcalMIPRecHitFilter(const edm::ParameterSet &)
const self & getMap() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalRecHit >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
int iEvent
Definition: GenABIO.cc:243
float energy() const
Definition: CaloRecHit.h:19
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct)
tuple result
Definition: query.py:137
edm::InputTag EcalRecHitCollection_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
DetId id() const
get the id
Definition: EcalRecHit.h:76
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
std::vector< int > maskedList_
edm::Timestamp time() const
Definition: EventBase.h:57
float EcalIntercalibConstant