CMS 3D CMS Logo

HcalCalibFEDSelector.cc
Go to the documentation of this file.
1 // user include files
4 
7 
10 
16 
18 public:
20  ~HcalCalibFEDSelector() override;
21 
22 private:
23  void beginJob() override;
24  void produce(edm::Event&, const edm::EventSetup&) override;
25  void endJob() override;
26 
27  // ----------member data ---------------------------
29  std::vector<int> extraFEDs_;
30 };
31 
33  tok_fed_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"));
34  extraFEDs_ = iConfig.getParameter<std::vector<int> >("extraFEDsToKeep");
35  produces<FEDRawDataCollection>();
36 }
37 
39 
41  auto producedData = std::make_unique<FEDRawDataCollection>();
42 
44  iEvent.getByToken(tok_fed_, rawIn);
45 
46  std::vector<int> selFEDs;
47 
48  //--- Get the list of FEDs to be kept ---//
49  int calibType = -1;
51  const FEDRawData& fedData = rawIn->FEDData(i);
52  if (fedData.size() < 24)
53  continue; // FED is empty
54  int value = ((const HcalDCCHeader*)(fedData.data()))->getCalibType();
55  if (calibType < 0) {
56  calibType = value;
57  } else {
58  if (calibType != value)
59  edm::LogWarning("HcalCalibFEDSelector") << "Conflicting calibration types found: " << calibType << " vs. "
60  << value << ". Staying with " << calibType;
61  }
62  }
63 
64  HcalFEDList calibFeds(calibType);
65  selFEDs = calibFeds.getListOfFEDs();
66  for (unsigned int i = 0; i < extraFEDs_.size(); i++) {
67  bool duplicate = false;
68  for (unsigned int j = 0; j < selFEDs.size(); j++) {
69  if (extraFEDs_.at(i) == selFEDs.at(j)) {
70  duplicate = true;
71  break;
72  }
73  }
74  if (!duplicate)
75  selFEDs.push_back(extraFEDs_.at(i));
76  }
77 
78  // Copying:
79  const FEDRawDataCollection* rdc = rawIn.product();
80 
81  for (int j = 0; j < FEDNumbering::lastFEDId(); ++j) {
82  bool rightFED = false;
83  for (uint32_t k = 0; k < selFEDs.size(); k++) {
84  if (j == selFEDs[k]) {
85  rightFED = true;
86  }
87  }
88  if (!rightFED)
89  continue;
90  const FEDRawData& fedData = rdc->FEDData(j);
91  size_t size = fedData.size();
92 
93  if (size > 0) {
94  // this fed has data -- lets copy it
95  FEDRawData& fedDataProd = producedData->FEDData(j);
96  if (fedDataProd.size() != 0) {
97  continue;
98  }
99  fedDataProd.resize(size);
100  unsigned char* dataProd = fedDataProd.data();
101  const unsigned char* data = fedData.data();
102  // memcpy is at-least-as-fast as assignment and can be much faster
103  memcpy(dataProd, data, size);
104  }
105  }
106 
107  iEvent.put(std::move(producedData));
108 }
109 
110 // ------------ method called once each job just before starting event loop ------------
112 
113 // ------------ method called once each job just after ending the event loop ------------
115 
FEDNumbering.h
HcalFEDList.h
mps_fire.i
i
Definition: mps_fire.py:428
HcalCalibFEDSelector::extraFEDs_
std::vector< int > extraFEDs_
Definition: HcalCalibFEDSelector.cc:29
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EDProducer.h
ESHandle.h
FEDNumbering::lastFEDId
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19
edm::EDGetTokenT< FEDRawDataCollection >
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
HcalCalibFEDSelector
Definition: HcalCalibFEDSelector.cc:17
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqmdumpme.k
k
Definition: dqmdumpme.py:60
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
value
Definition: value.py:1
HcalFEDList
Definition: HcalFEDList.h:7
edm::EventSetup
Definition: EventSetup.h:57
HcalCalibFEDSelector::HcalCalibFEDSelector
HcalCalibFEDSelector(const edm::ParameterSet &)
Definition: HcalCalibFEDSelector.cc:32
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
HcalDCCHeader
Definition: HcalDCCHeader.h:17
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalCalibFEDSelector::~HcalCalibFEDSelector
~HcalCalibFEDSelector() override
Definition: HcalCalibFEDSelector.cc:38
Frameworkfwd.h
HcalCalibFEDSelector::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HcalCalibFEDSelector.cc:40
HcalCalibFEDSelector::beginJob
void beginJob() override
Definition: HcalCalibFEDSelector.cc:111
HcalCalibFEDSelector::tok_fed_
edm::EDGetTokenT< FEDRawDataCollection > tok_fed_
Definition: HcalCalibFEDSelector.cc:28
relativeConstraints.value
value
Definition: relativeConstraints.py:53
FEDNumbering::MINHCALFEDID
Definition: FEDNumbering.h:47
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
edm::EDProducer
Definition: EDProducer.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
HcalDCCHeader.h
HcalFEDList::getListOfFEDs
std::vector< int > getListOfFEDs()
Definition: HcalFEDList.h:19
ParameterSet.h
FEDNumbering::MAXHCALFEDID
Definition: FEDNumbering.h:48
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
HcalCalibFEDSelector::endJob
void endJob() override
Definition: HcalCalibFEDSelector.cc:114
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443