CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HcalLaserHBHEFilter2012 Class Reference

#include <UserCode/HcalLaserHBHEFilter2012/src/HcalLaserHBHEFilter2012.cc>

Inheritance diagram for HcalLaserHBHEFilter2012:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HcalLaserHBHEFilter2012 (const edm::ParameterSet &)
 
 ~HcalLaserHBHEFilter2012 ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

virtual void endJob () override
 
virtual bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< int > CalibTS_
 
edm::InputTag digiLabel_
 
bool forceFilterTrue_
 
double HBHEcalibThreshold_
 
int minCalibChannelsHBHELaser_
 
double minFracDiffHBHELaser_
 
std::ofstream outfile_
 
std::string prefix_
 
edm::EDGetTokenT
< HcalCalibDigiCollection
tok_calib_
 
edm::EDGetTokenT
< HBHEDigiCollection
tok_hbhe_
 
bool verbose_
 
bool WriteBadToFile_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [filters out HBHE laser events based on number of HBHE calib digis above threshold and the distribution of HBHE calib digis]

Implementation: [Notes on implementation]

Definition at line 51 of file HcalLaserHBHEFilter2012.cc.

Constructor & Destructor Documentation

HcalLaserHBHEFilter2012::HcalLaserHBHEFilter2012 ( const edm::ParameterSet ps)
explicit

Definition at line 89 of file HcalLaserHBHEFilter2012.cc.

References CalibTS_, digiLabel_, forceFilterTrue_, edm::ParameterSet::getUntrackedParameter(), HBHEcalibThreshold_, i, minCalibChannelsHBHELaser_, minFracDiffHBHELaser_, outfile_, prefix_, AlCaHLTBitMon_QueryRunRegistry::string, tok_calib_, tok_hbhe_, verbose_, and WriteBadToFile_.

90 {
91  //now do what ever initialization is needed
92  verbose_ = ps.getUntrackedParameter<bool>("verbose",false);
93  prefix_ = ps.getUntrackedParameter<std::string>("prefix","");
94  minCalibChannelsHBHELaser_ = ps.getUntrackedParameter<int>("minCalibChannelsHBHELaser",20);
95  minFracDiffHBHELaser_ = ps.getUntrackedParameter<double>("minFracDiffHBHELaser",0.3);
96  edm::InputTag digi_default("hcalDigis");
97  digiLabel_ = ps.getUntrackedParameter<edm::InputTag>("digiLabel",digi_default);
98 
99  tok_calib_ = consumes<HcalCalibDigiCollection>(digiLabel_);
100  tok_hbhe_ = consumes<HBHEDigiCollection>(digiLabel_);
101 
102  HBHEcalibThreshold_ = ps.getUntrackedParameter<double>("HBHEcalibThreshold",15);
103  std::vector <int> dummyTS;
104  for (int i=3;i<=6;++i)
105  dummyTS.push_back(i);
106  CalibTS_ = ps.getUntrackedParameter<std::vector<int> >("CalibTS",dummyTS);
107  WriteBadToFile_=ps.getUntrackedParameter<bool>("WriteBadToFile",false);
108  if (WriteBadToFile_)
109  outfile_.open("badHcalLaserList_hbhefilter.txt");
110  forceFilterTrue_=ps.getUntrackedParameter<bool>("forceFilterTrue",false);
111 } // HcalLaserHBHEFilter2012::HcalLaserHBHEFilter2012 constructor
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
HcalLaserHBHEFilter2012::~HcalLaserHBHEFilter2012 ( )

Definition at line 114 of file HcalLaserHBHEFilter2012.cc.

115 {
116 
117  // do anything here that needs to be done at destruction time
118  // (e.g. close files, deallocate resources etc.)
119 
120 }

Member Function Documentation

void HcalLaserHBHEFilter2012::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 235 of file HcalLaserHBHEFilter2012.cc.

References outfile_, and WriteBadToFile_.

235  {
236  if (WriteBadToFile_) outfile_.close();
237 
238 }
void HcalLaserHBHEFilter2012::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 242 of file HcalLaserHBHEFilter2012.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

242  {
243  //The following says we do not know what parameters are allowed so do no validation
244  // Please change this to state exactly what you do use, even if it is no parameters
246  desc.setUnknown();
247  descriptions.addDefault(desc);
248 }
void addDefault(ParameterSetDescription const &psetDescription)
bool HcalLaserHBHEFilter2012::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 129 of file HcalLaserHBHEFilter2012.cc.

References HcalCalibDetId::calibFlavor(), CalibTS_, gather_cfg::cout, digiLabel_, edm::EventID::event(), forceFilterTrue_, edm::Event::getByToken(), HBHEcalibThreshold_, HcalBarrel, HcalEndcap, HcalCalibDetId::hcalSubdet(), HcalCalibDetId::HOCrosstalk, i, HcalCalibDataFrame::id(), HBHEDataFrame::id(), edm::EventBase::id(), HcalDetId::ieta(), HcalDetId::iphi(), edm::HandleBase::isValid(), edm::EventBase::luminosityBlock(), minCalibChannelsHBHELaser_, minFracDiffHBHELaser_, outfile_, prefix_, edm::EventID::run(), HcalDetId::subdet(), tok_calib_, tok_hbhe_, verbose_, WriteBadToFile_, and HcalCalibDataFrame::zsMarkAndPass().

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

130 {
131  // Step 1:: try to get calib digi and HBHE collections.
132  // Return true if collection not found? Or false? What should default behavior be?
134  if (!(iEvent.getByToken(tok_calib_,calib_digi)))
135  {
136  edm::LogWarning("HcalLaserHBHEFilter2012")<< digiLabel_<<" calib_digi not available";
137  return true;
138  }
139 
140  if (!(calib_digi.isValid()))
141  {
142  edm::LogWarning("HcalLaserHBHEFilter2012")<< digiLabel_<<" calib_digi is not valid";
143  return true;
144  }
145 
147  if (!(iEvent.getByToken(tok_hbhe_,hbhe_digi)))
148  {
149  edm::LogWarning("HcalLaserHBHEFilter2012")<< digiLabel_<<" hbhe_digi not available";
150  return true;
151  }
152 
153  if (!(hbhe_digi.isValid()))
154  {
155  edm::LogWarning("HcalLaserHBHEFilter2012")<< digiLabel_<<" hbhe_digi is not valid";
156  return true;
157  }
158 
159  // Step 2: Count HBHE digi calib channels
160  int ncalibHBHE=0; // this will track number of HBHE digi channels
161 
162 
163  for (HcalCalibDigiCollection::const_iterator Calibiter = calib_digi->begin();
164  Calibiter != calib_digi->end(); ++ Calibiter)
165  {
166  const HcalCalibDataFrame digi = (const HcalCalibDataFrame)(*Calibiter);
167  if (digi.zsMarkAndPass()) continue; // skip digis labeled as "mark and pass" in NZS events
168  HcalCalibDetId myid=(HcalCalibDetId)digi.id();
169  if (myid.hcalSubdet()!=HcalBarrel && myid.hcalSubdet()!=HcalEndcap) continue;
170  if ( myid.calibFlavor()==HcalCalibDetId::HOCrosstalk) continue;
171  // Compute charge in current channel (for relevant TS only)
172  // If total charge in channel exceeds threshold, increment count of calib channels
173  double thischarge=0;
174  for (unsigned int i=0;i<CalibTS_.size();++i)
175  {
176  thischarge+=digi[CalibTS_[i]].nominal_fC();
177  if (thischarge> HBHEcalibThreshold_ )
178  {
179  ++ncalibHBHE;
180  break;
181  }
182  }
183 
184  if (ncalibHBHE>=minCalibChannelsHBHELaser_)
185  {
186  if (verbose_)
187  std::cout <<prefix_<<iEvent.id().run()<<":"<<iEvent.luminosityBlock()<<":"<<iEvent.id().event()<<std::endl;
188  if (WriteBadToFile_)
189  outfile_<<iEvent.id().run()<<":"<<iEvent.luminosityBlock()<<":"<<iEvent.id().event()<<std::endl;
190  if (forceFilterTrue_) return true; // if special input boolean set, always return true, regardless of filter decision
191  else return false;
192  }
193  }
194 
195  // Step 3: Look at distribution of HBHE hits
196 
197  // Count digis in good, bad RBXes. ('bad' RBXes see no laser signal)
198  double badrbxfrac=0.;
199  double goodrbxfrac=0.;
200  int Nbad=72*3; // 3 bad RBXes, 72 channels each
201  int Ngood=2592*2-Nbad; // remaining HBHE channels are 'good'
202  for (HBHEDigiCollection::const_iterator hbhe = hbhe_digi->begin();
203  hbhe != hbhe_digi->end(); ++ hbhe)
204  {
205  const HBHEDataFrame digi = (const HBHEDataFrame)(*hbhe);
206  HcalDetId myid=(HcalDetId)digi.id();
207  bool isbad=false; // assume channel is not bad
208  if ( myid.subdet()==HcalBarrel && myid.ieta()<0 )
209  {
210  if (myid.iphi()>=15 && myid.iphi()<=18) isbad=true;
211  else if (myid.iphi()>=27 && myid.iphi()<=34) isbad=true;
212  }
213  if (isbad==true) badrbxfrac+=1.;
214  else goodrbxfrac+=1.;
215  }
216  goodrbxfrac/=Ngood;
217  badrbxfrac/=Nbad;
218  if (goodrbxfrac-badrbxfrac>minFracDiffHBHELaser_)
219  {
220  if (verbose_)
221  std::cout <<prefix_<<iEvent.id().run()<<":"<<iEvent.luminosityBlock()<<":"<<iEvent.id().event()<<std::endl;
222  if (WriteBadToFile_)
223  outfile_<<iEvent.id().run()<<":"<<iEvent.luminosityBlock()<<":"<<iEvent.id().event()<<std::endl;
224 
225  if (forceFilterTrue_) return true; // if special input boolean set, always return true, regardless of filter decision
226  else return false;
227  }
228  // Step 4: HBHE laser tests passed. return true
229  return true;
230 
231 } // HcalLaserHBHEFilter2012::filter
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
int i
Definition: DBlmapReader.cc:9
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:45
CalibDetType calibFlavor() const
get the flavor of this calibration detid
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< HcalCalibDataFrame >::const_iterator const_iterator
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
const HcalCalibDetId & id() const
bool isValid() const
Definition: HandleBase.h:75
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
edm::EventID id() const
Definition: EventBase.h:60
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
tuple cout
Definition: gather_cfg.py:121
bool zsMarkAndPass() const
was ZS MarkAndPass?
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_

Member Data Documentation

std::vector<int> HcalLaserHBHEFilter2012::CalibTS_
private

Definition at line 72 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

edm::InputTag HcalLaserHBHEFilter2012::digiLabel_
private

Definition at line 67 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

bool HcalLaserHBHEFilter2012::forceFilterTrue_
private

Definition at line 74 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

double HcalLaserHBHEFilter2012::HBHEcalibThreshold_
private

Definition at line 71 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

int HcalLaserHBHEFilter2012::minCalibChannelsHBHELaser_
private

Definition at line 65 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

double HcalLaserHBHEFilter2012::minFracDiffHBHELaser_
private

Definition at line 66 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

std::ofstream HcalLaserHBHEFilter2012::outfile_
private

Definition at line 75 of file HcalLaserHBHEFilter2012.cc.

Referenced by endJob(), filter(), and HcalLaserHBHEFilter2012().

std::string HcalLaserHBHEFilter2012::prefix_
private

Definition at line 64 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

edm::EDGetTokenT<HcalCalibDigiCollection> HcalLaserHBHEFilter2012::tok_calib_
private

Definition at line 68 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

edm::EDGetTokenT<HBHEDigiCollection> HcalLaserHBHEFilter2012::tok_hbhe_
private

Definition at line 69 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

bool HcalLaserHBHEFilter2012::verbose_
private

Definition at line 63 of file HcalLaserHBHEFilter2012.cc.

Referenced by filter(), and HcalLaserHBHEFilter2012().

bool HcalLaserHBHEFilter2012::WriteBadToFile_
private

Definition at line 73 of file HcalLaserHBHEFilter2012.cc.

Referenced by endJob(), filter(), and HcalLaserHBHEFilter2012().