CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripRegFEDSelector.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
14 
21 
23 public:
25  ~SiStripRegFEDSelector() override;
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
28 
29 private:
30  void beginJob() override {}
31  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
32  void endJob() override {}
33 
37  const double delta_;
38 };
39 
41  : tok_seed_(consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("regSeedLabel"))),
42  tok_raw_(consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("rawInputLabel"))),
44  delta_(iConfig.getParameter<double>("delta")) {
45  produces<FEDRawDataCollection>();
46 }
47 
49 
51  auto producedData = std::make_unique<FEDRawDataCollection>();
52 
54  iEvent.getByToken(tok_seed_, trigSeedTrks);
55 
56  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
57  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
58 
60  iEvent.getByToken(tok_raw_, rawIn);
61 
62  const SiStripRegionCabling* strip_cabling = &iSetup.getData(tok_strip_);
63  std::vector<int> stripFEDVec;
64 
65  //get vector of regions
66  const SiStripRegionCabling::Cabling& ccab = strip_cabling->getRegionCabling();
67 
68  //size of region (eta,phi)
69  const std::pair<double, double> regDim = strip_cabling->regionDimensions();
70 
72 
73  bool fedSaved[1000];
74  for (int i = 0; i < 1000; i++)
75  fedSaved[i] = false;
76 
77  //cycle on seeds
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  //cycle on regions
83  for (uint32_t i = 0; i < ccab.size(); i++) {
84  SiStripRegionCabling::Position pos = strip_cabling->position(i);
85  double dphi = fabs(pos.second - phiObj_);
86  if (dphi > acos(-1))
87  dphi = 2 * acos(-1) - dphi;
88  double R = sqrt(pow(pos.first - etaObj_, 2) + dphi * dphi);
89  if (R - sqrt(pow(regDim.first / 2, 2) + pow(regDim.second / 2, 2)) > delta_)
90  continue;
91  //get vector of subdets within region
92  const SiStripRegionCabling::RegionCabling regSubdets = ccab[i];
93  //cycle on subdets
94  for (uint32_t idet = 0; idet < SiStripRegionCabling::ALLSUBDETS; idet++) {
95  //get vector of layers within subdet of region
96  const SiStripRegionCabling::WedgeCabling regSubdetLayers = regSubdets[idet];
97  for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
98  //get map of vectors of feds withing the layer of subdet of region
99  const SiStripRegionCabling::ElementCabling fedVectorMap = regSubdetLayers[ilayer];
100  SiStripRegionCabling::ElementCabling::const_iterator it = fedVectorMap.begin();
101  for (; it != fedVectorMap.end(); it++) {
102  for (uint32_t op = 0; op < (it->second).size(); op++) {
103  //get fed id
104  int fediid = (it->second)[op].fedId();
105  if (!fedSaved[fediid]) {
106  stripFEDVec.push_back(fediid);
107  }
108  fedSaved[fediid] = true;
109  }
110  }
111  }
112  }
113  }
114  }
115 
117 
118  const FEDRawDataCollection* rdc = rawIn.product();
119 
120  // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) )
121  // continue ; // skip all raw collections not produced by the current process
122 
123  for (int j = 0; j < FEDNumbering::MAXFEDID; ++j) {
124  bool rightFED = false;
125  for (uint32_t k = 0; k < stripFEDVec.size(); k++) {
126  if (j == stripFEDVec[k]) {
127  rightFED = true;
128  }
129  }
130  if (!rightFED)
131  continue;
132  const FEDRawData& fedData = rdc->FEDData(j);
133  size_t size = fedData.size();
134 
135  if (size > 0) {
136  // this fed has data -- lets copy it
137  FEDRawData& fedDataProd = producedData->FEDData(j);
138  if (fedDataProd.size() != 0) {
139  edm::LogVerbatim("HcalIsoTrack") << " More than one FEDRawDataCollection with data in FED " << j
140  << " Skipping the 2nd *****";
141  continue;
142  }
143  fedDataProd.resize(size);
144  unsigned char* dataProd = fedDataProd.data();
145  const unsigned char* data = fedData.data();
146  for (unsigned int k = 0; k < size; ++k) {
147  dataProd[k] = data[k];
148  }
149  }
150  }
151 
152  iEvent.put(std::move(producedData));
153 }
154 
157  desc.add<edm::InputTag>("regSeedLabel", edm::InputTag("hltIsolPixelTrackFilter"));
158  desc.add<edm::InputTag>("rawInputLabel", edm::InputTag("rawDataCollector"));
159  desc.add<double>("delta", 1.0);
160  descriptions.add("stripFED", desc);
161 }
162 
165 
SiStripRegFEDSelector(const edm::ParameterSet &)
Log< level::Info, true > LogVerbatim
const std::pair< double, double > regionDimensions() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
std::vector< Element > ElementCabling
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:28
T sqrt(T t)
Definition: SSEVec.h:19
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_seed_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
def move
Definition: eostools.py:511
std::vector< RegionCabling > Cabling
const Cabling & getRegionCabling() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const Position position(const uint32_t) const
T const * product() const
Definition: Handle.h:70
std::pair< double, double > Position
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< WedgeCabling > RegionCabling
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
std::vector< ElementCabling > WedgeCabling
const edm::ESGetToken< SiStripRegionCabling, SiStripRegionCablingRcd > tok_strip_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29