CMS 3D CMS Logo

ECALRegFEDSelector.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
11 
21 
25 
27 public:
29  ~ECALRegFEDSelector() override = default;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 private:
34  void beginJob() override {}
35  void produce(edm::Event&, const edm::EventSetup&) override;
36  void endJob() override {}
37 
38  std::unique_ptr<const EcalElectronicsMapping> ec_mapping;
39 
40  const double delta_;
41  bool fedSaved[1200];
42 
45 };
46 
48  : delta_(iConfig.getParameter<double>("delta")),
49  tok_seed_(consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("regSeedLabel"))),
50  tok_raw_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"))) {
51  ec_mapping = std::make_unique<EcalElectronicsMapping>();
52 
53  produces<FEDRawDataCollection>();
54  produces<EcalListOfFEDS>();
55 
56  for (int p = 0; p < 1200; p++) {
57  fedSaved[p] = false;
58  }
59 }
60 
62  for (int p = 0; p < 1200; p++) {
63  fedSaved[p] = false;
64  }
65 
66  auto producedData = std::make_unique<FEDRawDataCollection>();
67 
68  auto fedList = std::make_unique<EcalListOfFEDS>();
69 
71 
72  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
73  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
74 
75  const edm::Handle<FEDRawDataCollection>& rawIn = iEvent.getHandle(tok_raw_);
76 
77  // std::vector<int> EC_FED_IDs;
78 
79  for (uint32_t p = 0; p < isoPixTrackRefs.size(); p++) {
80  double etaObj_ = isoPixTrackRefs[p]->track()->eta();
81  double phiObj_ = isoPixTrackRefs[p]->track()->phi();
82 
83  RectangularEtaPhiRegion ecEtaPhi(etaObj_ - delta_, etaObj_ + delta_, phiObj_ - delta_, phiObj_ + delta_);
84 
85  const std::vector<int> EC_FED_IDs = ec_mapping->GetListofFEDs(ecEtaPhi);
86 
87  const FEDRawDataCollection* rdc = rawIn.product();
88 
89  for (int j = 0; j <= FEDNumbering::MAXFEDID; j++) {
90  bool rightFED = false;
91  for (uint32_t k = 0; k < EC_FED_IDs.size(); k++) {
92  if (j == EcalRegionCabling::fedIndex(EC_FED_IDs[k])) {
93  if (!fedSaved[j]) {
94  fedList->AddFED(j);
95  rightFED = true;
96  fedSaved[j] = true;
97  }
98  }
99  }
101  fedSaved[j] = true;
102  rightFED = true;
103  }
104  if (!rightFED)
105  continue;
106  const FEDRawData& fedData = rdc->FEDData(j);
107  size_t size = fedData.size();
108 
109  if (size > 0) {
110  // this fed has data -- lets copy it
111  FEDRawData& fedDataProd = producedData->FEDData(j);
112  if (fedDataProd.size() != 0) {
113  edm::LogVerbatim("HcalCalib") << " More than one FEDRawDataCollection with data in FED " << j
114  << " Skipping the 2nd";
115  continue;
116  }
117  fedDataProd.resize(size);
118  unsigned char* dataProd = fedDataProd.data();
119  const unsigned char* data = fedData.data();
120  for (unsigned int k = 0; k < size; ++k) {
121  dataProd[k] = data[k];
122  }
123  }
124  }
125  }
126 
127  iEvent.put(std::move(producedData));
128  iEvent.put(std::move(fedList));
129 }
130 
133  desc.add<edm::InputTag>("regSeedLabel", edm::InputTag("hltPixelIsolTrackFilter"));
134  desc.add<edm::InputTag>("rawInputLabel", edm::InputTag("rawDataCollector"));
135  desc.add<double>("delta", 1.0);
136  descriptions.add("ecalFED", desc);
137 }
138 
141 
size
Write out results.
Log< level::Info, true > LogVerbatim
void beginJob() override
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_seed_
T const * product() const
Definition: Handle.h:70
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
ECALRegFEDSelector(const edm::ParameterSet &)
void endJob() override
static int fedIndex(const uint32_t index)
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< const EcalElectronicsMapping > ec_mapping
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< unsigned int > const fedList
Definition: Constants.h:66
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
~ECALRegFEDSelector() override=default
void produce(edm::Event &, const edm::EventSetup &) override
void resize(size_t newsize, size_t wordsize=8)
Definition: FEDRawData.cc:28
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
def move(src, dest)
Definition: eostools.py:511