CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMSimSetUp.cc
Go to the documentation of this file.
4 
6 {
7  auto pset = config.getParameter<edm::ParameterSet>("digiModelConfig");
8 
9  averageEfficiency_ = pset.getParameter<double>("averageEfficiency");
10  averageNoiseRate_ = pset.getParameter<double>("averageNoiseRate");
11  timeCalibrationOffset_ = pset.getParameter<double>("timeCalibrationOffset");
12  numberOfStripsPerPartition_ = pset.getParameter<int>("numberOfStripsPerPartition");
13 }
14 
15 void GEMSimSetUp::setup(std::vector<RPCStripNoises::NoiseItem> &vnoise,
16  std::vector<float> &vcluster)
17 {
18  std::cout << "GEMSimSetUp::setup()" << std::endl;
19  unsigned int counter = 1;
20  unsigned int row = 1;
21  std::vector<float> sum_clsize;
22 
23  for(unsigned int n = 0; n < vcluster.size(); ++n)
24  {
25  sum_clsize.push_back(vcluster[n]);
26 
27  if(counter == row * 20)
28  {
29  clusterMap_[row] = sum_clsize;
30  row++;
31  sum_clsize.clear();
32  }
33  counter++;
34  }
35 
37 }
38 
39 
40 void GEMSimSetUp::setup(std::vector<RPCStripNoises::NoiseItem> &vnoise,
41  std::vector<RPCClusterSize::ClusterSizeItem> &vClusterSize)
42 {
43  int clusterCounter = 1;
44  std::vector<float> clusterVect;
45 
46  for(auto cluster: vClusterSize)
47  {
48  clusterVect.push_back(cluster.clusterSize);
49  if( !(clusterCounter % 100) && clusterCounter != 0 )
50  {
51  mapDetClusterMap_[cluster.dpid] = clusterVect;
52  clusterVect.clear();
53  clusterCounter = 0;
54  }
55  ++clusterCounter;
56  }
57 
59 }
60 
61 
62 // setup the noise vector
64 {
65  /*
66  Container for the noise items. Its total size is 331776
67  - 2 stations
68  - 2 layers/station
69  - 36 chambers/layer
70  - 6 eta partitions/chamber
71  - 384 strips/eta partition
72  */
73  std::vector<RPCStripNoises::NoiseItem> vnoise;
74  vnoise.reserve(geometry_->dets().size() * numberOfStripsPerPartition_);
75 
76  // Loop over the detIds
77  for(const auto &det: geometry_->dets())
78  {
79  GEMEtaPartition* roll = dynamic_cast< GEMEtaPartition* >( det );
80 
81  // check for valid rolls
82  if(roll == nullptr) continue;
83 
84  const int nStrips = roll->nstrips();
85  if (numberOfStripsPerPartition_ != nStrips)
86  {
87  throw cms::Exception("DataCorrupt")
88  << "GEMSimSetUp::setup() - numberOfStripsPerPartition given in configuration "
89  <<numberOfStripsPerPartition_ <<" is not the same as in geometry "<<nStrips;
90  }
91 
92  // Loop over the strips
93  for(int iStrip=0; iStrip <= nStrips-1; ++iStrip)
94  {
95  // construct noise item for each strip
97  noise.dpid = roll->id();
98  noise.eff = averageEfficiency_;
99  noise.noise = averageNoiseRate_;
101 
102  // add noise item to noise vector
103  vnoise.push_back(noise);
104  }
105  setupTimeCalibration(det->geographicalId(),timeCalibrationOffset_);
106  }
107  setupNoiseAndEfficiency(vnoise);
108 }
109 
110 // return the vector of noise values for a particular chamber
111 const std::vector<float>& GEMSimSetUp::getNoise(uint32_t id)
112 {
113  auto iter = mapDetIdNoise_.find(id);
114  if(iter == mapDetIdNoise_.end())
115  {
116  throw cms::Exception("DataCorrupt")
117  << "GEMSimSetUp::getNoise() - no noise information for DetId "<<id<< "\n";
118  }
119  return iter->second;
120 }
121 
122 // return the vector of efficiency values for a particular chamber
123 const std::vector<float>& GEMSimSetUp::getEfficiency(uint32_t id)
124 {
125  auto iter = mapDetIdEfficiency_.find(id);
126  if(iter == mapDetIdEfficiency_.end())
127  {
128  throw cms::Exception("DataCorrupt")
129  << "GEMSimSetUp::getEfficiency() - no efficiency information for DetId "<<id<< "\n";
130  }
131  if((iter->second).size() != (unsigned) numberOfStripsPerPartition_)
132  {
133  throw cms::Exception("DataCorrupt")
134  << "GEMSimSetUp::getEfficiency() - efficiency information in a wrong format for DetId "<<id<< "\n";
135  }
136  return iter->second;
137 }
138 
139 // return the time calibration for this chamber
140 float GEMSimSetUp::getTime(uint32_t id)
141 {
142  GEMDetId detid(id);
143  auto iter = bxmap_.find(detid);
144  if(iter == bxmap_.end())
145  {
146  throw cms::Exception("DataCorrupt")
147  << "GEMSimSetUp::getTime() - no timing information for gemid.rawId() "<<detid.rawId()<< "\n";
148  }
149  return iter->second;
150 }
151 
152 
153 const std::map< int, std::vector<float> >& GEMSimSetUp::getClusterMap()
154 {
155  if(clusterMap_.size() != 5)
156  {
157  throw cms::Exception("DataCorrupt")
158  << "GEMSimSetUp::getClusterMap() - cluster size has the wrong format.\n";
159  }
160  return clusterMap_;
161 }
162 
163 
164 const std::vector<float>& GEMSimSetUp::getCluster(uint32_t id)
165 {
166  auto iter = mapDetClusterMap_.find(id);
167  if(iter == mapDetClusterMap_.end())
168  {
169  throw cms::Exception("DataCorrupt")
170  << "GEMSimSetUp::getCluster() - no cluster size information for DetId "<<id<< "\n";
171  }
172  if((iter->second).size() != 100)
173  {
174  throw cms::Exception("DataCorrupt")
175  << "GEMSimSetUp::getCluster() - cluster size information in a wrong format for DetId "<<id<< "\n";
176  }
177  return iter->second;
178 }
179 
180 
181 void GEMSimSetUp::setupNoiseAndEfficiency(std::vector<RPCStripNoises::NoiseItem> &vnoise)
182 {
183  unsigned int iStrip = 0;
184  uint32_t roll = 0;
185  std::vector<float> vEfficiency, vNoise;
186  vEfficiency.clear();
187  vNoise.clear();
188 
189  // loop over the noise vector
190  for(auto noise: vnoise)
191  {
192  if(iStrip % numberOfStripsPerPartition_ == 0)
193  {
194  // the first strip of new chamber
195  if(iStrip > 0)
196  {
197  // fill map with noise and efficiency vectors of the previous chamber
198  mapDetIdNoise_[roll] = vNoise;
199  mapDetIdEfficiency_[roll] = vEfficiency;
200  // clear the vectors and start over
201  vEfficiency.clear();
202  vNoise.clear();
203  vNoise.push_back(noise.noise);
204  vEfficiency.push_back(noise.eff);
205  }
206  // the very first strip in the collection
207  else if (iStrip == 0 )
208  {
209  // nothing to add to map yet
210  vNoise.push_back(noise.noise);
211  vEfficiency.push_back(noise.eff);
212  }
213  }
214  // the very last strip in the collection
215  else if (iStrip == vnoise.size() - 1 )
216  {
217  roll = noise.dpid;
218  vNoise.push_back(noise.noise);
219  vEfficiency.push_back(noise.eff);
220  // fill map with noise and efficiency vectors of the last chamber
221  mapDetIdNoise_[roll]= vNoise;
222  mapDetIdEfficiency_[roll] = vEfficiency;
223  }
224  // a regular strip
225  else
226  {
227  roll = noise.dpid;
228  vNoise.push_back(noise.noise);
229  vEfficiency.push_back(noise.eff);
230  }
231  iStrip++;
232  }
233 }
234 
235 
236 // set up the time calibration for each detId
238 {
239  bxmap_[id] = timing;
240 }
241 
242 
243 
244 
T getParameter(std::string const &) const
double averageEfficiency_
Definition: GEMSimSetUp.h:58
int numberOfStripsPerPartition_
Definition: GEMSimSetUp.h:61
const std::vector< float > & getNoise(uint32_t id)
Definition: GEMSimSetUp.cc:111
std::map< GEMDetId, float > bxmap_
Definition: GEMSimSetUp.h:54
void setupNoiseAndEfficiency(std::vector< RPCStripNoises::NoiseItem > &vnoise)
Definition: GEMSimSetUp.cc:181
double averageNoiseRate_
Definition: GEMSimSetUp.h:59
void setupTimeCalibration(GEMDetId id, float timing)
Definition: GEMSimSetUp.cc:237
GEMDetId id() const
std::map< uint32_t, std::vector< float > > mapDetIdEfficiency_
Definition: GEMSimSetUp.h:53
std::map< uint32_t, std::vector< float > > mapDetClusterMap_
Definition: GEMSimSetUp.h:56
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const std::map< int, std::vector< float > > & getClusterMap()
Definition: GEMSimSetUp.cc:153
int nstrips() const
Return the chamber this roll belongs to.
GEMSimSetUp(const edm::ParameterSet &ps)
Definition: GEMSimSetUp.cc:5
virtual const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: GEMGeometry.cc:25
std::map< uint32_t, std::vector< float > > mapDetIdNoise_
Definition: GEMSimSetUp.h:52
const std::vector< float > & getEfficiency(uint32_t id)
Definition: GEMSimSetUp.cc:123
std::map< int, std::vector< float > > clusterMap_
Definition: GEMSimSetUp.h:55
static std::atomic< unsigned int > counter
double timeCalibrationOffset_
Definition: GEMSimSetUp.h:60
tuple cout
Definition: gather_cfg.py:121
float getTime(uint32_t id)
Definition: GEMSimSetUp.cc:140
const std::vector< float > & getCluster(uint32_t id)
Definition: GEMSimSetUp.cc:164
const GEMGeometry * geometry_
Definition: GEMSimSetUp.h:50
void setup()
Definition: GEMSimSetUp.cc:63