CMS 3D CMS Logo

SiStripRegFEDSelector.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  produces<FEDRawDataCollection>();
15 }
16 
18 
20  auto producedData = std::make_unique<FEDRawDataCollection>();
21 
23  iEvent.getByToken(tok_seed_, trigSeedTrks);
24 
25  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
26  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
27 
29  iEvent.getByToken(tok_raw_, rawIn);
30 
32 
33  std::vector<int> stripFEDVec;
34 
35  //get vector of regions
37 
38  //size of region (eta,phi)
39  const std::pair<double, double> regDim = strip_cabling->regionDimensions();
40 
42 
43  bool fedSaved[1000];
44  for (int i = 0; i < 1000; i++)
45  fedSaved[i] = false;
46 
47  //cycle on seeds
48  for (uint32_t p = 0; p < isoPixTrackRefs.size(); p++) {
49  double etaObj_ = isoPixTrackRefs[p]->track()->eta();
50  double phiObj_ = isoPixTrackRefs[p]->track()->phi();
51 
52  //cycle on regions
53  for (uint32_t i = 0; i < ccab.size(); i++) {
55  double dphi = fabs(pos.second - phiObj_);
56  if (dphi > acos(-1))
57  dphi = 2 * acos(-1) - dphi;
58  double R = sqrt(pow(pos.first - etaObj_, 2) + dphi * dphi);
59  if (R - sqrt(pow(regDim.first / 2, 2) + pow(regDim.second / 2, 2)) > delta_)
60  continue;
61  //get vector of subdets within region
62  const SiStripRegionCabling::RegionCabling regSubdets = ccab[i];
63  //cycle on subdets
64  for (uint32_t idet = 0; idet < SiStripRegionCabling::ALLSUBDETS; idet++) {
65  //get vector of layers within subdet of region
66  const SiStripRegionCabling::WedgeCabling regSubdetLayers = regSubdets[idet];
67  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
68  //get map of vectors of feds withing the layer of subdet of region
69  const SiStripRegionCabling::ElementCabling fedVectorMap = regSubdetLayers[ilayer];
70  SiStripRegionCabling::ElementCabling::const_iterator it = fedVectorMap.begin();
71  for (; it != fedVectorMap.end(); it++) {
72  for (uint32_t op = 0; op < (it->second).size(); op++) {
73  //get fed id
74  int fediid = (it->second)[op].fedId();
75  if (!fedSaved[fediid]) {
76  stripFEDVec.push_back(fediid);
77  }
78  fedSaved[fediid] = true;
79  }
80  }
81  }
82  }
83  }
84  }
85 
87 
88  const FEDRawDataCollection* rdc = rawIn.product();
89 
90  // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) )
91  // continue ; // skip all raw collections not produced by the current process
92 
93  for (int j = 0; j < FEDNumbering::MAXFEDID; ++j) {
94  bool rightFED = false;
95  for (uint32_t k = 0; k < stripFEDVec.size(); k++) {
96  if (j == stripFEDVec[k]) {
97  rightFED = true;
98  }
99  }
100  if (!rightFED)
101  continue;
102  const FEDRawData& fedData = rdc->FEDData(j);
103  size_t size = fedData.size();
104 
105  if (size > 0) {
106  // this fed has data -- lets copy it
107  FEDRawData& fedDataProd = producedData->FEDData(j);
108  if (fedDataProd.size() != 0) {
109  // std::cout << " More than one FEDRawDataCollection with data in FED ";
110  // std::cout << j << " Skipping the 2nd\n";
111  continue;
112  }
113  fedDataProd.resize(size);
114  unsigned char* dataProd = fedDataProd.data();
115  const unsigned char* data = fedData.data();
116  for (unsigned int k = 0; k < size; ++k) {
117  dataProd[k] = data[k];
118  }
119  }
120  }
121 
122  iEvent.put(std::move(producedData));
123 }
124 
126 
size
Write out results.
SiStripRegFEDSelector(const edm::ParameterSet &)
T getParameter(std::string const &) const
const std::pair< double, double > regionDimensions() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void produce(edm::Event &, const edm::EventSetup &) override
edm::ESHandle< SiStripRegionCabling > strip_cabling
std::vector< Element > ElementCabling
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_seed_
int iEvent
Definition: GenABIO.cc:224
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
T sqrt(T t)
Definition: SSEVec.h:18
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
std::vector< RegionCabling > Cabling
const Cabling & getRegionCabling() const
int k[5][pyjets_maxn]
const Position position(const uint32_t) const
T const * product() const
Definition: Handle.h:74
std::pair< double, double > Position
std::vector< WedgeCabling > RegionCabling
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
T get() const
Definition: EventSetup.h:71
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
std::vector< ElementCabling > WedgeCabling
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:511