CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalLaserCorrFilter.cc
Go to the documentation of this file.
1 
15 
22 
28 
29 
31 
32  public:
33 
34  explicit EcalLaserCorrFilter(const edm::ParameterSet & iConfig);
36 
37  private:
38 
39  virtual bool filter(edm::Event & iEvent, const edm::EventSetup & iSetup) override;
40 
43 
44  // thresholds to laser corr to set kPoorCalib
46  const bool taggingMode_, debug_;
47 };
48 
49 
51  : ebRHSrcToken_ (consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("EBRecHitSource")))
52  , eeRHSrcToken_ (consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("EERecHitSource")))
53  , EBLaserMIN_ (iConfig.getParameter<double>("EBLaserMIN"))
54  , EELaserMIN_ (iConfig.getParameter<double>("EELaserMIN"))
55  , EBLaserMAX_ (iConfig.getParameter<double>("EBLaserMAX"))
56  , EELaserMAX_ (iConfig.getParameter<double>("EELaserMAX"))
57  , EBEnegyMIN_ (iConfig.getParameter<double>("EBEnegyMIN"))
58  , EEEnegyMIN_ (iConfig.getParameter<double>("EEEnegyMIN"))
59  , taggingMode_ (iConfig.getParameter<bool>("taggingMode"))
60  , debug_ (iConfig.getParameter<bool>("Debug"))
61 {
62  produces<bool>();
63 }
64 
65 
67 
68  using namespace edm;
69  using namespace reco;
70  using namespace std;
71 
73  iEvent.getByToken(ebRHSrcToken_, ebRHs);
74 
76  iEvent.getByToken(eeRHSrcToken_, eeRHs);
77 
78  // Laser corrections
80  iSetup.get<EcalLaserDbRecord>().get(laser);
81 
82 
83  bool goodCalib = true;
84 
85  // check EE RecHits
86  for (EcalRecHitCollection::const_iterator eerh = eeRHs->begin(); eerh != eeRHs->end(); ++eerh) {
87 
88  EcalRecHit hit = (*eerh);
89  EEDetId eeDet = hit.id();
90  double energy = eerh->energy();
91  double time = eerh->time();
92  int jx = EEDetId((*eerh).id()).ix();
93  int jy = EEDetId((*eerh).id()).iy();
94  int jz = EEDetId((*eerh).id()).zside();
95 
96  // get laser coefficient
97  float lasercalib = laser->getLaserCorrection( EEDetId(eeDet), iEvent.time());
98 
99  if( energy>EEEnegyMIN_ && (lasercalib < EELaserMIN_ || lasercalib > EELaserMAX_) ) {
100  goodCalib = false;
101  if(debug_) {
102  std::cout << "RecHit EE "
103  << iEvent.id().run()<< ":" << iEvent.luminosityBlock() <<":"<<iEvent.id().event()
104  << " lasercalib " << lasercalib << " rechit ene " << energy << " time " << time
105  << " ix, iy, z = " << jx << " " << jy << " " << jz
106  << std::endl;
107  }
108  }
109 
110  //if (!goodCalib) break;
111  }
112 
113  // check EB RecHits
114  for (EcalRecHitCollection::const_iterator ebrh = ebRHs->begin(); ebrh != ebRHs->end(); ++ebrh) {
115 
116  EcalRecHit hit = (*ebrh);
117  EBDetId ebDet = hit.id();
118  double energy = ebrh->energy();
119  double time = ebrh->time();
120  int etarec = EBDetId((*ebrh).id()).ieta();
121  int phirec = EBDetId((*ebrh).id()).iphi();
122  int zrec = EBDetId((*ebrh).id()).zside();
123 
124 
125  // get laser coefficient
126  float lasercalib = laser->getLaserCorrection( EBDetId(ebDet), iEvent.time());
127 
128  if (energy>EBEnegyMIN_ && (lasercalib < EBLaserMIN_ || lasercalib > EBLaserMAX_) ) {
129  goodCalib = false;
130  if(debug_) {
131  std::cout << "RecHit EB "
132  << iEvent.id().run()<< ":" << iEvent.luminosityBlock() <<":"<<iEvent.id().event()
133  << " lasercalib " << lasercalib << " rechit ene " << energy << " time " << time
134  << " eta, phi, z = " << etarec << " " << phirec << " " << zrec
135  << std::endl;
136  }
137  }
138  //if (!goodCalib) break;
139  }
140 
141 
142  bool result = goodCalib;
143  //std::cout << " *********** Result ******** " << result << std::endl;
144 
145  iEvent.put( std::auto_ptr<bool>(new bool(result)) );
146 
147  return taggingMode_ || result;
148 
149 }
150 
152 
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalRecHit >::const_iterator const_iterator
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
int zside(DetId const &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
tuple result
Definition: query.py:137
edm::EDGetTokenT< EcalRecHitCollection > ebRHSrcToken_
DetId id() const
get the id
Definition: EcalRecHit.h:76
const T & get() const
Definition: EventSetup.h:56
edm::EDGetTokenT< EcalRecHitCollection > eeRHSrcToken_
EcalLaserCorrFilter(const edm::ParameterSet &iConfig)
edm::EventID id() const
Definition: EventBase.h:60
tuple cout
Definition: gather_cfg.py:121
edm::Timestamp time() const
Definition: EventBase.h:61
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &iSetup) override