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
10 
20 
24 
26 public:
28  ~ECALRegFEDSelector() override = default;
29 
30  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
31 
32 private:
33  void beginJob() override {}
34  void produce(edm::Event&, const edm::EventSetup&) override;
35  void endJob() override {}
36 
37  std::unique_ptr<const EcalElectronicsMapping> ec_mapping;
38 
39  const double delta_;
40  bool fedSaved[1200];
41 
44 };
45 
47  : delta_(iConfig.getParameter<double>("delta")),
48  tok_seed_(consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("regSeedLabel"))),
49  tok_raw_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"))) {
50  ec_mapping = std::make_unique<EcalElectronicsMapping>();
51 
52  produces<FEDRawDataCollection>();
53  produces<EcalListOfFEDS>();
54 
55  for (int p = 0; p < 1200; p++) {
56  fedSaved[p] = false;
57  }
58 }
59 
61  for (int p = 0; p < 1200; p++) {
62  fedSaved[p] = false;
63  }
64 
65  auto producedData = std::make_unique<FEDRawDataCollection>();
66 
67  auto fedList = std::make_unique<EcalListOfFEDS>();
68 
70 
71  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
72  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
73 
74  const edm::Handle<FEDRawDataCollection>& rawIn = iEvent.getHandle(tok_raw_);
75 
76  // std::vector<int> EC_FED_IDs;
77 
78  for (uint32_t p = 0; p < isoPixTrackRefs.size(); p++) {
79  double etaObj_ = isoPixTrackRefs[p]->track()->eta();
80  double phiObj_ = isoPixTrackRefs[p]->track()->phi();
81 
82  RectangularEtaPhiRegion ecEtaPhi(etaObj_ - delta_, etaObj_ + delta_, phiObj_ - delta_, phiObj_ + delta_);
83 
84  const std::vector<int> EC_FED_IDs = ec_mapping->GetListofFEDs(ecEtaPhi);
85 
86  const FEDRawDataCollection* rdc = rawIn.product();
87 
88  for (int j = 0; j < FEDNumbering::MAXFEDID; j++) {
89  bool rightFED = false;
90  for (uint32_t k = 0; k < EC_FED_IDs.size(); k++) {
91  if (j == EcalRegionCabling::fedIndex(EC_FED_IDs[k])) {
92  if (!fedSaved[j]) {
93  fedList->AddFED(j);
94  rightFED = true;
95  fedSaved[j] = true;
96  }
97  }
98  }
100  fedSaved[j] = true;
101  rightFED = true;
102  }
103  if (!rightFED)
104  continue;
105  const FEDRawData& fedData = rdc->FEDData(j);
106  size_t size = fedData.size();
107 
108  if (size > 0) {
109  // this fed has data -- lets copy it
110  FEDRawData& fedDataProd = producedData->FEDData(j);
111  if (fedDataProd.size() != 0) {
112  // std::cout << " More than one FEDRawDataCollection with data in FED ";
113  // std::cout << j << " Skipping the 2nd\n";
114  continue;
115  }
116  fedDataProd.resize(size);
117  unsigned char* dataProd = fedDataProd.data();
118  const unsigned char* data = fedData.data();
119  for (unsigned int k = 0; k < size; ++k) {
120  dataProd[k] = data[k];
121  }
122  }
123  }
124  }
125 
126  iEvent.put(std::move(producedData));
127  iEvent.put(std::move(fedList));
128 }
129 
132  desc.add<edm::InputTag>("regSeedLabel", edm::InputTag("hltPixelIsolTrackFilter"));
133  desc.add<edm::InputTag>("rawInputLabel", edm::InputTag("rawDataCollector"));
134  desc.add<double>("delta", 1.0);
135  descriptions.add("ecalFED", desc);
136 }
137 
140 
size
Write out results.
void beginJob() override
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_seed_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T const * product() const
Definition: Handle.h:70
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
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
void resize(size_t newsize)
Definition: FEDRawData.cc:28
std::vector< unsigned int > const fedList
Definition: Constants.h:63
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 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:79
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