CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
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  double delta_;
40  bool fedSaved[1200];
41 
44 };
45 
47  tok_seed_ = consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("regSeedLabel"));
48  delta_ = iConfig.getParameter<double>("delta");
49 
50  tok_raw_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"));
51 
52  ec_mapping = std::make_unique<EcalElectronicsMapping>();
53 
54  produces<FEDRawDataCollection>();
55  produces<EcalListOfFEDS>();
56 
57  for (int p = 0; p < 1200; p++) {
58  fedSaved[p] = false;
59  }
60 }
61 
63 
65  for (int p = 0; p < 1200; p++) {
66  fedSaved[p] = false;
67  }
68 
69  auto producedData = std::make_unique<FEDRawDataCollection>();
70 
71  auto fedList = std::make_unique<EcalListOfFEDS>();
72 
74  iEvent.getByToken(tok_seed_, trigSeedTrks);
75 
76  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
77  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
78 
80  iEvent.getByToken(tok_raw_, rawIn);
81 
82  // std::vector<int> EC_FED_IDs;
83 
84  for (uint32_t p = 0; p < isoPixTrackRefs.size(); p++) {
85  double etaObj_ = isoPixTrackRefs[p]->track()->eta();
86  double phiObj_ = isoPixTrackRefs[p]->track()->phi();
87 
88  RectangularEtaPhiRegion ecEtaPhi(etaObj_ - delta_, etaObj_ + delta_, phiObj_ - delta_, phiObj_ + delta_);
89 
90  const std::vector<int> EC_FED_IDs = ec_mapping->GetListofFEDs(ecEtaPhi);
91 
92  const FEDRawDataCollection* rdc = rawIn.product();
93 
94  for (int j = 0; j < FEDNumbering::MAXFEDID; j++) {
95  bool rightFED = false;
96  for (uint32_t k = 0; k < EC_FED_IDs.size(); k++) {
97  if (j == EcalRegionCabling::fedIndex(EC_FED_IDs[k])) {
98  if (!fedSaved[j]) {
99  fedList->AddFED(j);
100  rightFED = true;
101  fedSaved[j] = true;
102  }
103  }
104  }
106  fedSaved[j] = true;
107  rightFED = true;
108  }
109  if (!rightFED)
110  continue;
111  const FEDRawData& fedData = rdc->FEDData(j);
112  size_t size = fedData.size();
113 
114  if (size > 0) {
115  // this fed has data -- lets copy it
116  FEDRawData& fedDataProd = producedData->FEDData(j);
117  if (fedDataProd.size() != 0) {
118  // std::cout << " More than one FEDRawDataCollection with data in FED ";
119  // std::cout << j << " Skipping the 2nd\n";
120  continue;
121  }
122  fedDataProd.resize(size);
123  unsigned char* dataProd = fedDataProd.data();
124  const unsigned char* data = fedData.data();
125  for (unsigned int k = 0; k < size; ++k) {
126  dataProd[k] = data[k];
127  }
128  }
129  }
130  }
131 
132  iEvent.put(std::move(producedData));
133  iEvent.put(std::move(fedList));
134 }
135 
138  desc.add<edm::InputTag>("regSeedLabel", edm::InputTag("hltPixelIsolTrackFilter"));
139  desc.add<edm::InputTag>("rawInputLabel", edm::InputTag("rawDataCollector"));
140  desc.add<double>("delta", 1.0);
141  descriptions.add("ecalFED", desc);
142 }
143 
146 
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
~ECALRegFEDSelector() override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void beginJob() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_seed_
ECALRegFEDSelector(const edm::ParameterSet &)
void endJob() override
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
static int fedIndex(const uint32_t index)
int iEvent
Definition: GenABIO.cc:224
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::unique_ptr< const EcalElectronicsMapping > ec_mapping
void resize(size_t newsize)
Definition: FEDRawData.cc:28
def move
Definition: eostools.py:511
std::vector< unsigned int > const fedList
Definition: Constants.h:63
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: Handle.h:70
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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
tuple size
Write out results.