CMS 3D CMS Logo

ECALRegFEDSelector.cc
Go to the documentation of this file.
1 
7 
9  tok_seed_ = consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("regSeedLabel"));
10  delta_ = iConfig.getParameter<double>("delta");
11 
12  tok_raw_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"));
13 
14  ec_mapping = std::make_unique<EcalElectronicsMapping>();
15 
16  produces<FEDRawDataCollection>();
17  produces<EcalListOfFEDS>();
18 
19  for (int p = 0; p < 1200; p++) {
20  fedSaved[p] = false;
21  }
22 }
23 
25 
27  for (int p = 0; p < 1200; p++) {
28  fedSaved[p] = false;
29  }
30 
31  auto producedData = std::make_unique<FEDRawDataCollection>();
32 
33  auto fedList = std::make_unique<EcalListOfFEDS>();
34 
36  iEvent.getByToken(tok_seed_, trigSeedTrks);
37 
38  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
39  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
40 
42  iEvent.getByToken(tok_raw_, rawIn);
43 
44  // std::vector<int> EC_FED_IDs;
45 
46  for (uint32_t p = 0; p < isoPixTrackRefs.size(); p++) {
47  double etaObj_ = isoPixTrackRefs[p]->track()->eta();
48  double phiObj_ = isoPixTrackRefs[p]->track()->phi();
49 
50  RectangularEtaPhiRegion ecEtaPhi(etaObj_ - delta_, etaObj_ + delta_, phiObj_ - delta_, phiObj_ + delta_);
51 
52  const std::vector<int> EC_FED_IDs = ec_mapping->GetListofFEDs(ecEtaPhi);
53 
54  const FEDRawDataCollection* rdc = rawIn.product();
55 
56  for (int j = 0; j < FEDNumbering::MAXFEDID; j++) {
57  bool rightFED = false;
58  for (uint32_t k = 0; k < EC_FED_IDs.size(); k++) {
59  if (j == EcalRegionCabling::fedIndex(EC_FED_IDs[k])) {
60  if (!fedSaved[j]) {
61  fedList->AddFED(j);
62  rightFED = true;
63  fedSaved[j] = true;
64  }
65  }
66  }
68  fedSaved[j] = true;
69  rightFED = true;
70  }
71  if (!rightFED)
72  continue;
73  const FEDRawData& fedData = rdc->FEDData(j);
74  size_t size = fedData.size();
75 
76  if (size > 0) {
77  // this fed has data -- lets copy it
78  FEDRawData& fedDataProd = producedData->FEDData(j);
79  if (fedDataProd.size() != 0) {
80  // std::cout << " More than one FEDRawDataCollection with data in FED ";
81  // std::cout << j << " Skipping the 2nd\n";
82  continue;
83  }
84  fedDataProd.resize(size);
85  unsigned char* dataProd = fedDataProd.data();
86  const unsigned char* data = fedData.data();
87  for (unsigned int k = 0; k < size; ++k) {
88  dataProd[k] = data[k];
89  }
90  }
91  }
92  }
93 
94  iEvent.put(std::move(producedData));
95  iEvent.put(std::move(fedList));
96 }
97 
99 
size
Write out results.
T getParameter(std::string const &) const
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
~ECALRegFEDSelector() override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void beginJob() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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
std::vector< unsigned int > const fedList
Definition: Constants.h:55
T const * product() const
Definition: Handle.h:69
void produce(edm::Event &, const edm::EventSetup &) override
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