CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies Struct Reference

Public Member Functions

void init_from_db (const edm::ESHandle< TrackerGeometry > &, const edm::ESHandle< SiPixelDynamicInefficiency > &)
 
bool matches (const DetId &, const DetId &, const std::vector< uint32_t > &)
 
 PixelEfficiencies (const edm::ParameterSet &conf, bool AddPixelInefficiency, int NumberOfBarrelLayers, int NumberOfEndcapDisks)
 

Public Attributes

std::map< uint32_t, double > ChipGeomFactors
 
std::map< uint32_t, double > ColGeomFactors
 
unsigned int FPixIndex
 
bool FromConfig
 
std::map< uint32_t, size_t > iPU
 
std::map< uint32_t, double > PixelGeomFactors
 
std::vector< double > pu_scale
 
double theInnerEfficiency_FPix [20]
 
double theInstLumiScaleFactor
 
std::vector< double > theLadderEfficiency_BPix [20]
 
std::vector< double > theModuleEfficiency_BPix [20]
 
double theOuterEfficiency_FPix [20]
 
double thePixelChipEfficiency [20]
 
double thePixelColEfficiency [20]
 
double thePixelEfficiency [20]
 
std::vector< std::vector
< double > > 
thePUEfficiency
 

Detailed Description

Internal use only.

Definition at line 83 of file DataMixingSiPixelMCDigiWorker.h.

Constructor & Destructor Documentation

edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::PixelEfficiencies ( const edm::ParameterSet conf,
bool  AddPixelInefficiency,
int  NumberOfBarrelLayers,
int  NumberOfEndcapDisks 
)

Definition at line 92 of file DataMixingSiPixelMCDigiWorker.cc.

References Exception, edm::ParameterSet::exists(), FPixIndex, FromConfig, edm::ParameterSet::getParameter(), i, j, edm::DataMixingSiPixelMCDigiWorker::NumberOfBarrelLayers, edm::DataMixingSiPixelMCDigiWorker::NumberOfEndcapDisks, pu_scale, findQualityFiles::size, theInnerEfficiency_FPix, theInstLumiScaleFactor, theLadderEfficiency_BPix, theModuleEfficiency_BPix, theOuterEfficiency_FPix, thePixelChipEfficiency, thePixelColEfficiency, thePixelEfficiency, and thePUEfficiency.

92  {
93  // pixel inefficiency
94  // Don't use Hard coded values, read inefficiencies in from DB/python config or don't use any
95  int NumberOfTotLayers = NumberOfBarrelLayers + NumberOfEndcapDisks;
98  FromConfig =
99  conf.exists("thePixelColEfficiency_BPix1") && conf.exists("thePixelColEfficiency_BPix2") && conf.exists("thePixelColEfficiency_BPix3") &&
100  conf.exists("thePixelColEfficiency_FPix1") && conf.exists("thePixelColEfficiency_FPix2") &&
101  conf.exists("thePixelEfficiency_BPix1") && conf.exists("thePixelEfficiency_BPix2") && conf.exists("thePixelEfficiency_BPix3") &&
102  conf.exists("thePixelEfficiency_FPix1") && conf.exists("thePixelEfficiency_FPix2") &&
103  conf.exists("thePixelChipEfficiency_BPix1") && conf.exists("thePixelChipEfficiency_BPix2") && conf.exists("thePixelChipEfficiency_BPix3") &&
104  conf.exists("thePixelChipEfficiency_FPix1") && conf.exists("thePixelChipEfficiency_FPix2");
105  if (NumberOfBarrelLayers==3) FromConfig = FromConfig && conf.exists("theLadderEfficiency_BPix1") && conf.exists("theLadderEfficiency_BPix2") && conf.exists("theLadderEfficiency_BPix3") &&
106  conf.exists("theModuleEfficiency_BPix1") && conf.exists("theModuleEfficiency_BPix2") && conf.exists("theModuleEfficiency_BPix3") &&
107  conf.exists("thePUEfficiency_BPix1") && conf.exists("thePUEfficiency_BPix2") && conf.exists("thePUEfficiency_BPix3") &&
108  conf.exists("theInnerEfficiency_FPix1") && conf.exists("theInnerEfficiency_FPix2") &&
109  conf.exists("theOuterEfficiency_FPix1") && conf.exists("theOuterEfficiency_FPix2") &&
110  conf.exists("thePUEfficiency_FPix_Inner") && conf.exists("thePUEfficiency_FPix_Outer") &&
111  conf.exists("theInstLumiScaleFactor");
112  if (NumberOfBarrelLayers>=4) FromConfig = FromConfig && conf.exists("thePixelColEfficiency_BPix4") &&
113  conf.exists("thePixelEfficiency_BPix4") && conf.exists("thePixelChipEfficiency_BPix4");
114  if (NumberOfEndcapDisks>=3) FromConfig = FromConfig && conf.exists("thePixelColEfficiency_FPix4") &&
115  conf.exists("thePixelEfficiency_FPix3") && conf.exists("thePixelChipEfficiency_FPix3");
116  if (FromConfig) {
117  LogInfo ("PixelDigitizer ") <<"The PixelDigitizer inefficiency configuration is read from the config file.\n";
118  theInstLumiScaleFactor = conf.getParameter<double>("theInstLumiScaleFactor");
119  int i=0;
120  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix1");
121  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix2");
122  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix3");
123  if (NumberOfBarrelLayers>=4){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_BPix4");}
124  //
125  i=0;
126  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix1");
127  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix2");
128  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix3");
129  if (NumberOfBarrelLayers>=4){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_BPix4");}
130  //
131  i=0;
132  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix1");
133  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix2");
134  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix3");
135  if (NumberOfBarrelLayers>=4){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_BPix4");}
136  //
137  if (NumberOfBarrelLayers==3){
138  i=0;
139  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix1");
140  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix2");
141  theLadderEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theLadderEfficiency_BPix3");
142  if ( ((theLadderEfficiency_BPix[0].size()!=20) || (theLadderEfficiency_BPix[1].size()!=32) ||
143  (theLadderEfficiency_BPix[2].size()!=44)) && (NumberOfBarrelLayers==3) )
144  throw cms::Exception("Configuration") << "Wrong ladder number in efficiency config!";
145  //
146  i=0;
147  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix1");
148  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix2");
149  theModuleEfficiency_BPix[i++] = conf.getParameter<std::vector<double> >("theModuleEfficiency_BPix3");
150  if ( ((theModuleEfficiency_BPix[0].size()!=4) || (theModuleEfficiency_BPix[1].size()!=4) ||
151  (theModuleEfficiency_BPix[2].size()!=4)) && (NumberOfBarrelLayers==3) )
152  throw cms::Exception("Configuration") << "Wrong module number in efficiency config!";
153  //
154  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_BPix1"));
155  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_BPix2"));
156  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_BPix3"));
157  if ( ((thePUEfficiency[0].size()==0) || (thePUEfficiency[1].size()==0) ||
158  (thePUEfficiency[2].size()==0)) && (NumberOfBarrelLayers==3) )
159  throw cms::Exception("Configuration") << "At least one PU efficiency (BPix) number is needed in efficiency config!";
160  }
161  // The next is needed for Phase2 Tracker studies
162  if (NumberOfBarrelLayers>=5){
163  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
164  // For Phase2 tracker layers just set the outermost BPix inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
165  for (int j=5 ; j<=NumberOfBarrelLayers ; j++){
166  thePixelColEfficiency[j-1]=0.999;
167  thePixelEfficiency[j-1]=0.999;
168  thePixelChipEfficiency[j-1]=0.999;
169  }
170  }
171  //
172  i=FPixIndex;
173  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix1");
174  thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix2");
175  if (NumberOfEndcapDisks>=3){thePixelColEfficiency[i++] = conf.getParameter<double>("thePixelColEfficiency_FPix3");}
176  i=FPixIndex;
177  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix1");
178  thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix2");
179  if (NumberOfEndcapDisks>=3){thePixelEfficiency[i++] = conf.getParameter<double>("thePixelEfficiency_FPix3");}
180  i=FPixIndex;
181  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix1");
182  thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix2");
183  if (NumberOfEndcapDisks>=3){thePixelChipEfficiency[i++] = conf.getParameter<double>("thePixelChipEfficiency_FPix3");}
184  // The next is needed for Phase2 Tracker studies
185  if (NumberOfEndcapDisks>=4){
186  if (NumberOfTotLayers>20){throw cms::Exception("Configuration") <<"SiPixelDigitizer was given more layers than it can handle";}
187  // For Phase2 tracker layers just set the extra FPix disk inefficiency to 99.9% THESE VALUES ARE HARDCODED ALSO ELSEWHERE IN THIS FILE
188  for (int j=4+FPixIndex ; j<=NumberOfEndcapDisks+NumberOfBarrelLayers ; j++){
189  thePixelColEfficiency[j-1]=0.999;
190  thePixelEfficiency[j-1]=0.999;
191  thePixelChipEfficiency[j-1]=0.999;
192  }
193  }
194  //FPix Dynamic Inefficiency
195  if (NumberOfBarrelLayers==3){
196  i=FPixIndex;
197  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix1");
198  theInnerEfficiency_FPix[i++] = conf.getParameter<double>("theInnerEfficiency_FPix2");
199  i=FPixIndex;
200  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix1");
201  theOuterEfficiency_FPix[i++] = conf.getParameter<double>("theOuterEfficiency_FPix2");
202  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Inner"));
203  thePUEfficiency.push_back(conf.getParameter<std::vector<double> >("thePUEfficiency_FPix_Outer"));
204  if ( ((thePUEfficiency[3].size()==0) || (thePUEfficiency[4].size()==0)) && (NumberOfEndcapDisks==2) )
205  throw cms::Exception("Configuration") << "At least one (FPix) PU efficiency number is needed in efficiency config!";
206  pu_scale.resize(thePUEfficiency.size());
207  }
208  }
209  else LogInfo ("PixelDigitizer ") <<"The PixelDigitizer inefficiency configuration is read from the database.\n";
210 
211  }
212  // the first "NumberOfBarrelLayers" settings [0],[1], ... , [NumberOfBarrelLayers-1] are for the barrel pixels
213  // the next "NumberOfEndcapDisks" settings [NumberOfBarrelLayers],[NumberOfBarrelLayers+1], ... [NumberOfEndcapDisks+NumberOfBarrelLayers-1]
214 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool exists(std::string const &parameterName) const
checks if a parameter exists
int j
Definition: DBlmapReader.cc:9
tuple size
Write out results.

Member Function Documentation

void edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::init_from_db ( const edm::ESHandle< TrackerGeometry > &  geom,
const edm::ESHandle< SiPixelDynamicInefficiency > &  SiPixelDynamicInefficiency 
)

Definition at line 225 of file DataMixingSiPixelMCDigiWorker.cc.

References cond::rpcobgas::detid, Exception, i, matches, and DetId::rawId().

Referenced by edm::DataMixingSiPixelMCDigiWorker::init_DynIneffDB().

225  {
226 
227  theInstLumiScaleFactor = SiPixelDynamicInefficiency->gettheInstLumiScaleFactor();
228  std::map<uint32_t, double> PixelGeomFactorsDB = SiPixelDynamicInefficiency->getPixelGeomFactors();
229  std::map<uint32_t, double> ColGeomFactorsDB = SiPixelDynamicInefficiency->getColGeomFactors();
230  std::map<uint32_t, double> ChipGeomFactorsDB = SiPixelDynamicInefficiency->getChipGeomFactors();
231  std::map<uint32_t, std::vector<double> > PUFactors = SiPixelDynamicInefficiency->getPUFactors();
232  std::vector<uint32_t > DetIdmasks = SiPixelDynamicInefficiency->getDetIdmasks();
233 
234  // Loop on all modules, calculate geometrical scale factors and store in map for easy access
235  for(TrackerGeometry::DetUnitContainer::const_iterator it_module = geom->detUnits().begin(); it_module != geom->detUnits().end(); it_module++) {
236  if( dynamic_cast<PixelGeomDetUnit const*>((*it_module))==0) continue;
237  const DetId detid = (*it_module)->geographicalId();
238  uint32_t rawid = detid.rawId();
239  PixelGeomFactors[rawid] = 1;
240  ColGeomFactors[rawid] = 1;
241  ChipGeomFactors[rawid] = 1;
242  for (auto db_factor : PixelGeomFactorsDB) if (matches(detid, DetId(db_factor.first), DetIdmasks)) PixelGeomFactors[rawid] *= db_factor.second;
243  for (auto db_factor : ColGeomFactorsDB) if (matches(detid, DetId(db_factor.first), DetIdmasks)) ColGeomFactors[rawid] *= db_factor.second;
244  for (auto db_factor : ChipGeomFactorsDB) if (matches(detid, DetId(db_factor.first), DetIdmasks)) ChipGeomFactors[rawid] *= db_factor.second;
245  }
246 
247  // piluep scale factors are calculated once per event
248  // therefore vector index is stored in a map for each module that matches to a db_id
249  size_t i=0;
250  for (auto factor : PUFactors) {
251  const DetId db_id = DetId(factor.first);
252  for(TrackerGeometry::DetUnitContainer::const_iterator it_module = geom->detUnits().begin(); it_module != geom->detUnits().end(); it_module++) {
253  if( dynamic_cast<PixelGeomDetUnit const*>((*it_module))==0) continue;
254  const DetId detid = (*it_module)->geographicalId();
255  if (!matches(detid, db_id, DetIdmasks)) continue;
256  if (iPU.count(detid.rawId())) {
257  throw cms::Exception("Database")<<"Multiple db_ids match to same module in SiPixelDynamicInefficiency DB Object";
258  } else {
259  iPU[detid.rawId()] = i;
260  }
261  }
262  thePUEfficiency.push_back(factor.second);
263  ++i;
264  }
265  pu_scale.resize(thePUEfficiency.size());
266 }
int i
Definition: DBlmapReader.cc:9
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool matches(const DetId &, const DetId &, const std::vector< uint32_t > &)
Definition: DetId.h:18
bool edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::matches ( const DetId detid,
const DetId db_id,
const std::vector< uint32_t > &  DetIdmasks 
)

Definition at line 268 of file DataMixingSiPixelMCDigiWorker.cc.

References DetId::det(), i, DetId::rawId(), and DetId::subdetId().

268  {
269  if (detid.subdetId() != db_id.subdetId()) return false;
270  for (size_t i=0; i<DetIdmasks.size(); ++i) {
271  DetId maskid = DetId(DetIdmasks.at(i));
272  if (maskid.subdetId() != db_id.subdetId()) continue;
273  if ((detid.rawId()&maskid.rawId()) != (db_id.rawId()&maskid.rawId()) &&
274  (db_id.rawId()&maskid.rawId()) != DetId(db_id.det(), db_id.subdetId()).rawId()) return false;
275  }
276  return true;
277 }
int i
Definition: DBlmapReader.cc:9
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
Detector det() const
get the detector field from this detid
Definition: DetId.h:35

Member Data Documentation

std::map<uint32_t, double> edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::ChipGeomFactors
std::map<uint32_t, double> edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::ColGeomFactors
unsigned int edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::FPixIndex
bool edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::FromConfig
std::map<uint32_t, size_t > edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::iPU
std::map<uint32_t, double> edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::PixelGeomFactors
std::vector<double> edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::pu_scale
double edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::theInnerEfficiency_FPix[20]
double edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::theInstLumiScaleFactor
std::vector<double> edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::theLadderEfficiency_BPix[20]
std::vector<double> edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::theModuleEfficiency_BPix[20]
double edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::theOuterEfficiency_FPix[20]
double edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::thePixelChipEfficiency[20]
double edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::thePixelColEfficiency[20]
double edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::thePixelEfficiency[20]
std::vector<std::vector<double> > edm::DataMixingSiPixelMCDigiWorker::PixelEfficiencies::thePUEfficiency