CMS 3D CMS Logo

HLTHcalCalibTypeFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTHcalCalibTypeFilter
4 // Class: HLTHcalCalibTypeFilter
5 //
13 //
14 // Original Author: Bryan DAHMES
15 // Created: Tue Jan 22 13:55:00 CET 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <string>
22 #include <iostream>
23 #include <memory>
24 
25 // user include files
27 
35 
41 #include "HLTHcalCalibTypeFilter.h"
42 
43 //
44 // constructors and destructor
45 //
47  DataInputToken_( consumes<FEDRawDataCollection>( config.getParameter<edm::InputTag>("InputTag") ) ),
48  CalibTypes_( config.getParameter< std::vector<int> >("CalibTypes") ),
49  Summary_( config.getUntrackedParameter<bool>("FilterSummary", false) ),
50  eventsByType_()
51 {
52  for (auto & i : eventsByType_) i = 0;
53 }
54 
55 
57 {
58 
59  // do anything here that needs to be done at desctruction time
60  // (e.g. close files, deallocate resources etc.)
61 
62 }
63 
64 void
67  desc.add<edm::InputTag>("InputTag",edm::InputTag("source"));
68  std::vector<int> temp; for (int i=1; i<=5; i++) temp.push_back(i);
69  desc.add<std::vector<int> >("CalibTypes", temp);
70  desc.addUntracked<bool>("FilterSummary",false);
71  descriptions.add("hltHcalCalibTypeFilter",desc);
72 }
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called on each new Event ------------
79 bool
81 {
82  using namespace edm;
83 
85  iEvent.getByToken(DataInputToken_,rawdata);
86 
87  // some inits
88  int numZeroes(0), numPositives(0);
89 
90  // loop over all HCAL FEDs
91  for (int fed=FEDNumbering::MINHCALFEDID;
92  fed<=FEDNumbering::MAXHCALuTCAFEDID; fed++)
93  {
94  // skip FEDs in between VME and uTCA
96  continue;
97 
98  // get raw data and check if there are empty feds
99  const FEDRawData& fedData = rawdata->FEDData(fed) ;
100  if ( fedData.size() < 24 ) continue ;
101 
103  {
104  // VME get event type
105  int eventtype = ((const HcalDCCHeader*)(fedData.data()))->getCalibType();
106  if (eventtype==0) numZeroes++; else numPositives++;
107  }
108  else
109  {
110  // UTCA
111  hcal::AMC13Header const *hamc13 = (hcal::AMC13Header const*) fedData.data();
112  for (int iamc=0; iamc<hamc13->NAMC(); iamc++)
113  {
114  HcalUHTRData uhtr(hamc13->AMCPayload(iamc), hamc13->AMCSize(iamc));
115  int eventtype = uhtr.getEventType();
116  if (eventtype==0) numZeroes++; else numPositives++;
117  }
118  }
119  }
120 
121  //
122  // if there are FEDs with Non-Collission event type, check what the majority is
123  // if calibs - true
124  // if 0s - false
125  //
126  if (numPositives>0)
127  {
128  if (numPositives>numZeroes) return true;
129  else
130  edm::LogWarning("HLTHcalCalibTypeFilter")
131  << "Conflicting Calibration Types found";
132  }
133 
134  // return false if there are no positives
135  // and if the majority has 0 calib type
136  return false;
137 }
138 
139 // ------------ method called once each job just after ending the event loop ------------
140 void
142  if ( Summary_ )
143  edm::LogWarning("HLTHcalCalibTypeFilter") << "Summary of filter decisions: "
144  << eventsByType_.at(hc_Null) << "(No Calib), "
145  << eventsByType_.at(hc_Pedestal) << "(Pedestal), "
146  << eventsByType_.at(hc_RADDAM) << "(RADDAM), "
147  << eventsByType_.at(hc_HBHEHPD) << "(HBHE/HPD), "
148  << eventsByType_.at(hc_HOHPD) << "(HO/HPD), "
149  << eventsByType_.at(hc_HFPMT) << "(HF/PMT)" ;
150 }
151 
152 // declare this class as a framework plugin
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: config.py:1
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int AMCSize(int i) const
Definition: AMC13Header.h:37
const edm::EDGetTokenT< FEDRawDataCollection > DataInputToken_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int getEventType() const
Get the event type.
Definition: HcalUHTRData.h:90
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::array< std::atomic< int >, 8 > eventsByType_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int NAMC() const
Definition: AMC13Header.h:25
HLT enums.
const uint64_t * AMCPayload(int i) const
Definition: AMC13Header.cc:4
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
HLTHcalCalibTypeFilter(const edm::ParameterSet &)