CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripRegFEDSelector.cc
Go to the documentation of this file.
1 
8 
10 {
11  seedLabel_=iConfig.getParameter<edm::InputTag>("regSeedLabel");
12  delta_=iConfig.getParameter<double>("delta");
13 
14  rawInLabel_=iConfig.getParameter<edm::InputTag>("rawInputLabel");
15 
16  produces<FEDRawDataCollection>();
17 }
18 
19 
21 {
22 
23 }
24 
25 void
27 {
28  std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);
29 
31  iEvent.getByLabel(seedLabel_,trigSeedTrks);
32 
33  std::vector< edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
34  trigSeedTrks->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
35 
37  iEvent.getByLabel(rawInLabel_,rawIn);
38 
40 
41  std::vector<int> stripFEDVec;
42 
43  //get vector of regions
44  const SiStripRegionCabling::Cabling ccab=strip_cabling->getRegionCabling();
45 
46  //size of region (eta,phi)
47  const std::pair<double,double> regDim=strip_cabling->regionDimensions();
48 
50 
51  bool fedSaved[1000];
52  for (int i=0; i<1000; i++) fedSaved[i]=false;
53 
54  //cycle on seeds
55  for (uint32_t p=0; p<isoPixTrackRefs.size(); p++)
56  {
57  double etaObj_=isoPixTrackRefs[p]->track()->eta();
58  double phiObj_=isoPixTrackRefs[p]->track()->phi();
59 
60  //cycle on regions
61  for (uint32_t i=0; i<ccab.size(); i++)
62  {
64  double dphi=fabs(pos.second-phiObj_);
65  if (dphi>acos(-1)) dphi=2*acos(-1)-dphi;
66  double R=sqrt(pow(pos.first-etaObj_,2)+dphi*dphi);
67  if (R-sqrt(pow(regDim.first/2,2)+pow(regDim.second/2,2))>delta_) continue;
68  //get vector of subdets within region
69  const SiStripRegionCabling::RegionCabling regSubdets= ccab[i];
70  //cycle on subdets
71  for (uint32_t idet=0; idet<SiStripRegionCabling::ALLSUBDETS; idet++)
72  {
73  //get vector of layers within subdet of region
74  const SiStripRegionCabling::WedgeCabling regSubdetLayers=regSubdets[idet];
75  for (uint32_t ilayer=0; ilayer<SiStripRegionCabling::ALLLAYERS; ilayer++)
76  {
77  //get map of vectors of feds withing the layer of subdet of region
78  const SiStripRegionCabling::ElementCabling fedVectorMap=regSubdetLayers[ilayer];
79  SiStripRegionCabling::ElementCabling::const_iterator it=fedVectorMap.begin();
80  for( ; it!=fedVectorMap.end(); it++)
81  {
82  for (uint32_t op=0; op<(it->second).size(); op++)
83  {
84  //get fed id
85  int fediid=(it->second)[op].fedId();
86  if (!fedSaved[fediid])
87  {
88  stripFEDVec.push_back(fediid);
89  }
90  fedSaved[fediid]=true;
91 
92  }
93  }
94 
95  }
96 
97  }
98  }
99  }
100 
101 
103 
104  const FEDRawDataCollection *rdc=rawIn.product();
105 
106  // if ( ( rawData[i].provenance()->processName() != e.processHistory().rbegin()->processName() ) )
107  // continue ; // skip all raw collections not produced by the current process
108 
109  for ( int j=0; j< FEDNumbering::MAXFEDID; ++j )
110  {
111  bool rightFED=false;
112  for (uint32_t k=0; k<stripFEDVec.size(); k++)
113  {
114  if (j==stripFEDVec[k])
115  {
116  rightFED=true;
117  }
118  }
119  if (!rightFED) continue;
120  const FEDRawData & fedData = rdc->FEDData(j);
121  size_t size=fedData.size();
122 
123  if ( size > 0 )
124  {
125  // this fed has data -- lets copy it
126  FEDRawData & fedDataProd = producedData->FEDData(j);
127  if ( fedDataProd.size() != 0 ) {
128 // std::cout << " More than one FEDRawDataCollection with data in FED ";
129 // std::cout << j << " Skipping the 2nd\n";
130  continue;
131  }
132  fedDataProd.resize(size);
133  unsigned char *dataProd=fedDataProd.data();
134  const unsigned char *data=fedData.data();
135  for ( unsigned int k=0; k<size; ++k ) {
136  dataProd[k]=data[k];
137  }
138  }
139  }
140 
141  iEvent.put(producedData);
142 
143 }
144 
145 void
147 }
148 
149 void
151 }
SiStripRegFEDSelector(const edm::ParameterSet &)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::ESHandle< SiStripRegionCabling > strip_cabling
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
int iEvent
Definition: GenABIO.cc:243
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< ElementCabling > WedgeCabling
T sqrt(T t)
Definition: SSEVec.h:46
std::pair< double, double > Position
int j
Definition: DBlmapReader.cc:9
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
int k[5][pyjets_maxn]
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
std::vector< WedgeCabling > RegionCabling
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::map< uint32_t, std::vector< FedChannelConnection > > ElementCabling
std::vector< RegionCabling > Cabling