CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripBadModuleGenerator.cc
Go to the documentation of this file.
3 #include <boost/cstdint.hpp>
7 
15 
18 {
19  edm::LogInfo("SiStripBadModuleGenerator") << "[SiStripBadModuleGenerator::SiStripBadModuleGenerator]";
20 }
21 
22 
24  edm::LogInfo("SiStripBadModuleGenerator") << "[SiStripBadModuleGenerator::~SiStripBadModuleGenerator]";
25 }
26 
27 
29 
31 
32  edm::FileInPath fp_ = _pset.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
33  printdebug_ = _pset.getUntrackedParameter<bool>("printDebug",false);
35 
36 
38  const std::vector<uint32_t>& DetIds= reader.getAllDetIds();
39  std::vector<uint32_t> selDetIds;
40  selectDetectors(DetIds,selDetIds);
41 
42  edm::LogInfo("SiStripQualityConfigurableFakeESSource")<<"[produce] number of selected dets to be removed " << selDetIds.size() <<std::endl;
43 
44  std::stringstream ss;
45  std::vector<uint32_t>::const_iterator iter=selDetIds.begin();
46  std::vector<uint32_t>::const_iterator iterEnd=selDetIds.end();
47  for(;iter!=iterEnd;++iter){
48 
49  SiStripQuality::InputVector theSiStripVector;
50 
51  unsigned short firstBadStrip=0, NconsecutiveBadStrips=reader.getNumberOfApvsAndStripLength(*iter).first * 128;
52  unsigned int theBadStripRange;
53 
54  theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);
55 
56  if (printdebug_)
57  ss << "detid " << *iter << " \t"
58  << " firstBadStrip " << firstBadStrip << "\t "
59  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
60  << " packed integer " << std::hex << theBadStripRange << std::dec
61  << std::endl;
62 
63  theSiStripVector.push_back(theBadStripRange);
64 
65  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
66  if ( ! obj->put(*iter,range) )
67  edm::LogError("SiStripQualityConfigurableFakeESSource")<<"[produce] detid already exists"<<std::endl;
68  }
69  if (printdebug_)
70  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss.str();
71 
72  obj->cleanUp();
73  //obj->fillBadComponents();
74 
75  std::stringstream ss1;
76  if (printdebug_){
77  for (std::vector<SiStripQuality::BadComponent>::const_iterator iter=obj->getBadComponentList().begin();iter!=obj->getBadComponentList().end();++iter)
78  ss1 << "bad module " << iter->detid << " " << iter->BadModule << "\n";
79  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss1.str();
80  }
81 
82 // obj_ = new SiStripBadStrip( *(dynamic_cast<SiStripBadStrip*> (obj)));
83  return obj;
84 }
85 
86 
87 void SiStripBadModuleGenerator::selectDetectors(const std::vector<uint32_t>& DetIds, std::vector<uint32_t>& list){
88 
89  SiStripSubStructure siStripSubStructure;
90  std::stringstream ss;
91 
92  for(Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end(); ++iBadComponent ) {
93 
94  if (printdebug_)
95  ss << "Bad SubDet " << iBadComponent->getParameter<std::string>("SubDet") << " \t";
96 
98  if (iBadComponent->getParameter<std::string>("SubDet")=="TIB")
99  subDet=SiStripDetId::TIB;
100  else if (iBadComponent->getParameter<std::string>("SubDet")=="TID")
101  subDet=SiStripDetId::TID;
102  else if (iBadComponent->getParameter<std::string>("SubDet")=="TOB")
103  subDet=SiStripDetId::TOB;
104  else if (iBadComponent->getParameter<std::string>("SubDet")=="TEC")
105  subDet=SiStripDetId::TEC;
106  std::vector<uint32_t> genericBadDetIds( iBadComponent->getUntrackedParameter<std::vector<uint32_t> >("detidList", std::vector<uint32_t>()) );
107 
108  bool anySubDet = true;
109  if( genericBadDetIds.empty() ) anySubDet = false;
110 
111  std::cout << "genericBadDetIds.size() = " << genericBadDetIds.size() << std::endl;
112 
113  uint32_t startDet=DetId(DetId::Tracker,subDet).rawId();
114  uint32_t stopDet=DetId(DetId::Tracker,subDet+1).rawId();
115 
116  if( anySubDet ) {
119  }
120 
121  std::vector<uint32_t>::const_iterator iter=lower_bound(DetIds.begin(),DetIds.end(),startDet);
122  std::vector<uint32_t>::const_iterator iterEnd=lower_bound(DetIds.begin(),DetIds.end(),stopDet);
123 
124  bool resp;
125  for ( ;iter!=iterEnd;++iter){
126 
127  resp=false;
128  if (iBadComponent->getParameter<std::string>("SubDet")=="TIB")
129  resp=isTIBDetector(*iter,
130  iBadComponent->getParameter<uint32_t>("layer"),
131  iBadComponent->getParameter<uint32_t>("bkw_frw"),
132  iBadComponent->getParameter<uint32_t>("int_ext"),
133  iBadComponent->getParameter<uint32_t>("ster"),
134  iBadComponent->getParameter<uint32_t>("string_"),
135  iBadComponent->getParameter<uint32_t>("detid")
136  );
137  else if (iBadComponent->getParameter<std::string>("SubDet")=="TID")
138  resp=isTIDDetector(*iter,
139  iBadComponent->getParameter<uint32_t>("side"),
140  iBadComponent->getParameter<uint32_t>("wheel"),
141  iBadComponent->getParameter<uint32_t>("ring"),
142  iBadComponent->getParameter<uint32_t>("ster"),
143  iBadComponent->getParameter<uint32_t>("detid")
144  );
145  else if (iBadComponent->getParameter<std::string>("SubDet")=="TOB")
146  resp=isTOBDetector(*iter,
147  iBadComponent->getParameter<uint32_t>("layer"),
148  iBadComponent->getParameter<uint32_t>("bkw_frw"),
149  iBadComponent->getParameter<uint32_t>("rod"),
150  iBadComponent->getParameter<uint32_t>("ster"),
151  iBadComponent->getParameter<uint32_t>("detid")
152  );
153  else if (iBadComponent->getParameter<std::string>("SubDet")=="TEC")
154  resp=isTECDetector(*iter,
155  iBadComponent->getParameter<uint32_t>("side"),
156  iBadComponent->getParameter<uint32_t>("wheel"),
157  iBadComponent->getParameter<uint32_t>("petal_bkw_frw"),
158  iBadComponent->getParameter<uint32_t>("petal"),
159  iBadComponent->getParameter<uint32_t>("ring"),
160  iBadComponent->getParameter<uint32_t>("ster"),
161  iBadComponent->getParameter<uint32_t>("detid")
162  );
163  if( anySubDet ) {
164  std::cout << "AnySubDet" << *iter << std::endl;
165  if( std::find(genericBadDetIds.begin(), genericBadDetIds.end(), *iter) == genericBadDetIds.end() ) resp = false;
166  else resp = true;
167  }
168 
169  if(resp)
170  list.push_back(*iter);
171  }
172  }
173  if (printdebug_)
174  edm::LogInfo("SiStripBadModuleGenerator") << ss.str();
175 }
176 
177 
178 bool SiStripBadModuleGenerator::isTIBDetector(const uint32_t & therawid,
179  uint32_t requested_layer,
180  uint32_t requested_bkw_frw,
181  uint32_t requested_int_ext,
182  uint32_t requested_string,
183  uint32_t requested_ster,
184  uint32_t requested_detid) const{
185  TIBDetId potentialDet = TIBDetId(therawid); // build TIBDetId, at this point is just DetId, but do not want to cast twice
186  if( potentialDet.subDetector() == SiStripDetId::TIB ){ // check if subdetector field is a TIB, both tested numbers are int
187  if( // check if TIB is from the ones requested
188  ( (potentialDet.layerNumber()==requested_layer) || requested_layer==0 ) // take everything if default value is 0
189  &&
190  ( (potentialDet.isZPlusSide() && requested_bkw_frw==2) || (!potentialDet.isZPlusSide() && requested_bkw_frw==1) || requested_bkw_frw==0)
191  &&
192  ( (potentialDet.isInternalString() && requested_int_ext==1) || (!potentialDet.isInternalString() && requested_int_ext==2) || requested_int_ext==0 )
193  &&
194  ( (potentialDet.isStereo() && requested_ster==1) || (potentialDet.isRPhi() && requested_ster==2) || requested_ster==0 )
195  &&
196  ( (potentialDet.stringNumber()==requested_string) || requested_string==0 )
197  &&
198  ( (potentialDet.rawId()==requested_detid) || requested_detid==0 )
199  )
200  return 1;
201  }
202  return 0;
203 }
204 
205 bool SiStripBadModuleGenerator::isTOBDetector(const uint32_t & therawid,
206  uint32_t requested_layer,
207  uint32_t requested_bkw_frw,
208  uint32_t requested_rod,
209  uint32_t requested_ster,
210  uint32_t requested_detid) const{
211  TOBDetId potentialDet = TOBDetId(therawid); // build TOBDetId, at this point is just DetId, but do not want to cast twice
212  if( potentialDet.subDetector() == SiStripDetId::TOB ){ // check if subdetector field is a TOB, both tested numbers are int
213  if( // check if TOB is from the ones requested
214  ( (potentialDet.layerNumber()==requested_layer) || requested_layer==0 ) // take everything if default value is 0
215  &&
216  ( (potentialDet.isZPlusSide() && requested_bkw_frw==2) || (!potentialDet.isZPlusSide() && requested_bkw_frw==1) || requested_bkw_frw==0)
217  &&
218  ( (potentialDet.isStereo() && requested_ster==1) || (potentialDet.isRPhi() && requested_ster==2) || requested_ster==0 )
219  &&
220  ( (potentialDet.rodNumber()==requested_rod) || requested_rod==0 )
221  &&
222  ( (potentialDet.rawId()==requested_detid) || requested_detid==0 )
223  )
224  return 1;
225  }
226  return 0;
227 }
228 
229 
230 bool SiStripBadModuleGenerator::isTIDDetector(const uint32_t & therawid,
231  uint32_t requested_side,
232  uint32_t requested_wheel,
233  uint32_t requested_ring,
234  uint32_t requested_ster,
235  uint32_t requested_detid) const{
236  TIDDetId potentialDet = TIDDetId(therawid); // build TIDDetId, at this point is just DetId, but do not want to cast twice
237  if( potentialDet.subDetector() == SiStripDetId::TID ){ // check if subdetector field is a TID, both tested numbers are int
238  if( // check if TID is from the ones requested
239  ( (potentialDet.diskNumber()==requested_wheel) || requested_wheel==0 ) // take everything if default value is 0
240  &&
241  ( (potentialDet.isZPlusSide() && requested_side==2) || (!potentialDet.isZPlusSide() && requested_side==1) || requested_side==0)
242  &&
243  ( (potentialDet.isStereo() && requested_ster==1) || (potentialDet.isRPhi() && requested_ster==2) || requested_ster==0 )
244  &&
245  ( (potentialDet.ringNumber()==requested_ring) || requested_ring==0 )
246  &&
247  ( (potentialDet.rawId()==requested_detid) || requested_detid==0 )
248  )
249  return 1;
250  }
251  return 0;
252 }
253 
254 
255 bool SiStripBadModuleGenerator::isTECDetector(const uint32_t & therawid,
256  uint32_t requested_side,
257  uint32_t requested_wheel,
258  uint32_t requested_petal_bkw_frw,
259  uint32_t requested_petal,
260  uint32_t requested_ring,
261  uint32_t requested_ster,
262  uint32_t requested_detid) const{
263  TECDetId potentialDet = TECDetId(therawid); // build TECDetId, at this point is just DetId, but do not want to cast twice
264  if( potentialDet.subDetector() == SiStripDetId::TEC ){ // check if subdetector field is a TEC, both tested numbers are int
265  if( // check if TEC is from the ones requested
266  ( (potentialDet.wheelNumber()==requested_wheel) || requested_wheel==0 ) // take everything if default value is 0
267  &&
268  ( (potentialDet.isZPlusSide() && requested_side==2) || (!potentialDet.isZPlusSide() && requested_side==1) || requested_side==0)
269  &&
270  ( (potentialDet.isStereo() && requested_ster==1) || (!potentialDet.isStereo() && requested_ster==2) || requested_ster==0 )
271  &&
272  ( (potentialDet.isFrontPetal() && requested_petal_bkw_frw==2) || (!potentialDet.isFrontPetal() && requested_petal_bkw_frw==2) || requested_petal_bkw_frw==0 )
273  &&
274  ( (potentialDet.petalNumber()==requested_petal) || requested_petal==0 )
275  &&
276  ( (potentialDet.ringNumber()==requested_ring) || requested_ring==0 )
277  &&
278  ( (potentialDet.rawId()==requested_detid) || requested_detid==0 )
279  )
280  return 1;
281  }
282  return 0;
283 }
284 
unsigned int rodNumber() const
Definition: TOBDetId.h:77
T getUntrackedParameter(std::string const &, T const &) const
unsigned int petalNumber() const
Definition: TECDetId.h:94
unsigned int stringNumber() const
Definition: TIBDetId.h:87
bool isStereo()
Definition: TIDDetId.h:109
std::vector< edm::ParameterSet > Parameters
unsigned int ringNumber() const
Definition: TIDDetId.h:97
unsigned int wheelNumber() const
Definition: TECDetId.h:90
bool isTIBDetector(const uint32_t &therawid, uint32_t requested_layer, uint32_t requested_bkw_frw, uint32_t requested_int_ext, uint32_t requested_string, uint32_t requested_ster, uint32_t requested_detid) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void selectDetectors(const std::vector< uint32_t > &, std::vector< uint32_t > &)
unsigned int layerNumber() const
Definition: TIBDetId.h:83
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
unsigned int layerNumber() const
Definition: TOBDetId.h:73
bool isZPlusSide() const
Definition: TIBDetId.h:75
bool isStereo()
Definition: TECDetId.h:118
bool isRPhi()
Definition: TIDDetId.h:105
SiStripBadModuleGenerator(const edm::ParameterSet &, const edm::ActivityRegistry &)
bool isZPlusSide() const
Definition: TECDetId.h:82
bool isStereo()
Definition: TOBDetId.h:89
SubDetector subDetector() const
Definition: SiStripDetId.h:114
Definition: DetId.h:18
bool isInternalString() const
Definition: TIBDetId.h:95
unsigned int ringNumber() const
Definition: TECDetId.h:98
bool isStereo()
Definition: TIBDetId.h:107
bool isTECDetector(const uint32_t &therawid, uint32_t requested_side, uint32_t requested_wheel, uint32_t requested_petal_bkw_frw, uint32_t requested_petal, uint32_t requested_ring, uint32_t requested_ster, uint32_t requested_detid) const
std::pair< ContainerIterator, ContainerIterator > Range
bool isZPlusSide() const
Definition: TIDDetId.h:77
bool isTOBDetector(const uint32_t &therawid, uint32_t requested_layer, uint32_t requested_bkw_frw, uint32_t requested_rod, uint32_t requested_ster, uint32_t requested_detid) const
tuple cout
Definition: gather_cfg.py:121
bool isFrontPetal() const
Definition: TECDetId.h:110
bool isZPlusSide() const
Definition: TOBDetId.h:65
bool isRPhi()
Definition: TOBDetId.h:85
std::string fullPath() const
Definition: FileInPath.cc:171
bool isRPhi()
Definition: TIBDetId.h:103
bool isTIDDetector(const uint32_t &therawid, uint32_t requested_side, uint32_t requested_wheel, uint32_t requested_ring, uint32_t requested_ster, uint32_t requested_detid) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
unsigned int diskNumber() const
Definition: TIDDetId.h:93