CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
HcalCalibFEDSelector(const edm::ParameterSet &)
std::vector< int > extraFEDs_
void produce(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
void resize(size_t newsize)
Definition: FEDRawData.cc:28
edm::EDGetTokenT< FEDRawDataCollection > tok_fed_
Definition: value.py:1
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Log< level::Warning, false > LogWarning
static constexpr int lastFEDId()
Definition: FEDNumbering.h:19
std::vector< int > getListOfFEDs()
Definition: HcalFEDList.h:19
def move(src, dest)
Definition: eostools.py:511