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 
10 {
11  edm::LogInfo("SiStripBadModuleGenerator") << "[SiStripBadModuleGenerator::SiStripBadModuleGenerator]";
12 }
13 
14 
16  edm::LogInfo("SiStripBadModuleGenerator") << "[SiStripBadModuleGenerator::~SiStripBadModuleGenerator]";
17 }
18 
19 
21 
23 
24  edm::FileInPath fp_ = _pset.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
25  printdebug_ = _pset.getUntrackedParameter<bool>("printDebug",false);
27 
28 
30  const std::vector<uint32_t>& DetIds= reader.getAllDetIds();
31  std::vector<uint32_t> selDetIds;
32  selectDetectors(tTopo,DetIds,selDetIds);
33 
34  edm::LogInfo("SiStripQualityConfigurableFakeESSource")<<"[produce] number of selected dets to be removed " << selDetIds.size() <<std::endl;
35 
36  std::stringstream ss;
37  std::vector<uint32_t>::const_iterator iter=selDetIds.begin();
38  std::vector<uint32_t>::const_iterator iterEnd=selDetIds.end();
39  for(;iter!=iterEnd;++iter){
40 
41  SiStripQuality::InputVector theSiStripVector;
42 
43  unsigned short firstBadStrip=0, NconsecutiveBadStrips=reader.getNumberOfApvsAndStripLength(*iter).first * 128;
44  unsigned int theBadStripRange;
45 
46  theBadStripRange = obj->encode(firstBadStrip,NconsecutiveBadStrips);
47 
48  if (printdebug_)
49  ss << "detid " << *iter << " \t"
50  << " firstBadStrip " << firstBadStrip << "\t "
51  << " NconsecutiveBadStrips " << NconsecutiveBadStrips << "\t "
52  << " packed integer " << std::hex << theBadStripRange << std::dec
53  << std::endl;
54 
55  theSiStripVector.push_back(theBadStripRange);
56 
57  SiStripBadStrip::Range range(theSiStripVector.begin(),theSiStripVector.end());
58  if ( ! obj->put(*iter,range) )
59  edm::LogError("SiStripQualityConfigurableFakeESSource")<<"[produce] detid already exists"<<std::endl;
60  }
61  if (printdebug_)
62  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss.str();
63 
64  obj->cleanUp();
65  //obj->fillBadComponents();
66 
67  std::stringstream ss1;
68  if (printdebug_){
69  for (std::vector<SiStripQuality::BadComponent>::const_iterator iter=obj->getBadComponentList().begin();iter!=obj->getBadComponentList().end();++iter)
70  ss1 << "bad module " << iter->detid << " " << iter->BadModule << "\n";
71  edm::LogInfo("SiStripQualityConfigurableFakeESSource") << ss1.str();
72  }
73 
74 // obj_ = new SiStripBadStrip( *(dynamic_cast<SiStripBadStrip*> (obj)));
75  return obj;
76 }
77 
78 
79 void SiStripBadModuleGenerator::selectDetectors(const TrackerTopology* tTopo, const std::vector<uint32_t>& DetIds, std::vector<uint32_t>& list){
80  std::stringstream ss;
81 
82  for(Parameters::iterator iBadComponent = BadComponentList_.begin(); iBadComponent != BadComponentList_.end(); ++iBadComponent ) {
83 
84  if (printdebug_)
85  ss << "Bad SubDet " << iBadComponent->getParameter<std::string>("SubDet") << " \t";
86 
88  if (iBadComponent->getParameter<std::string>("SubDet")=="TIB")
89  subDet=SiStripDetId::TIB;
90  else if (iBadComponent->getParameter<std::string>("SubDet")=="TID")
91  subDet=SiStripDetId::TID;
92  else if (iBadComponent->getParameter<std::string>("SubDet")=="TOB")
93  subDet=SiStripDetId::TOB;
94  else if (iBadComponent->getParameter<std::string>("SubDet")=="TEC")
95  subDet=SiStripDetId::TEC;
96  std::vector<uint32_t> genericBadDetIds( iBadComponent->getUntrackedParameter<std::vector<uint32_t> >("detidList", std::vector<uint32_t>()) );
97 
98  bool anySubDet = true;
99  if( genericBadDetIds.empty() ) anySubDet = false;
100 
101  std::cout << "genericBadDetIds.size() = " << genericBadDetIds.size() << std::endl;
102 
103  uint32_t startDet=DetId(DetId::Tracker,subDet).rawId();
104  uint32_t stopDet=DetId(DetId::Tracker,subDet+1).rawId();
105 
106  if( anySubDet ) {
109  }
110 
111  std::vector<uint32_t>::const_iterator iter=lower_bound(DetIds.begin(),DetIds.end(),startDet);
112  std::vector<uint32_t>::const_iterator iterEnd=lower_bound(DetIds.begin(),DetIds.end(),stopDet);
113 
114  bool resp;
115  for ( ;iter!=iterEnd;++iter){
116  const DetId detectorId=DetId(*iter);
117  resp=false;
118  if (iBadComponent->getParameter<std::string>("SubDet")=="TIB")
119  resp=isTIBDetector(tTopo,detectorId,
120  iBadComponent->getParameter<uint32_t>("layer"),
121  iBadComponent->getParameter<uint32_t>("bkw_frw"),
122  iBadComponent->getParameter<uint32_t>("int_ext"),
123  iBadComponent->getParameter<uint32_t>("ster"),
124  iBadComponent->getParameter<uint32_t>("string_"),
125  iBadComponent->getParameter<uint32_t>("detid")
126  );
127  else if (iBadComponent->getParameter<std::string>("SubDet")=="TID")
128  resp=isTIDDetector(tTopo,detectorId,
129  iBadComponent->getParameter<uint32_t>("side"),
130  iBadComponent->getParameter<uint32_t>("wheel"),
131  iBadComponent->getParameter<uint32_t>("ring"),
132  iBadComponent->getParameter<uint32_t>("ster"),
133  iBadComponent->getParameter<uint32_t>("detid")
134  );
135  else if (iBadComponent->getParameter<std::string>("SubDet")=="TOB")
136  resp=isTOBDetector(tTopo,detectorId,
137  iBadComponent->getParameter<uint32_t>("layer"),
138  iBadComponent->getParameter<uint32_t>("bkw_frw"),
139  iBadComponent->getParameter<uint32_t>("rod"),
140  iBadComponent->getParameter<uint32_t>("ster"),
141  iBadComponent->getParameter<uint32_t>("detid")
142  );
143  else if (iBadComponent->getParameter<std::string>("SubDet")=="TEC")
144  resp=isTECDetector(tTopo,detectorId,
145  iBadComponent->getParameter<uint32_t>("side"),
146  iBadComponent->getParameter<uint32_t>("wheel"),
147  iBadComponent->getParameter<uint32_t>("petal_bkw_frw"),
148  iBadComponent->getParameter<uint32_t>("petal"),
149  iBadComponent->getParameter<uint32_t>("ring"),
150  iBadComponent->getParameter<uint32_t>("ster"),
151  iBadComponent->getParameter<uint32_t>("detid")
152  );
153  if( anySubDet ) {
154  std::cout << "AnySubDet" << *iter << std::endl;
155  if( std::find(genericBadDetIds.begin(), genericBadDetIds.end(), *iter) == genericBadDetIds.end() ) resp = false;
156  else resp = true;
157  }
158 
159  if(resp)
160  list.push_back(*iter);
161  }
162  }
163  if (printdebug_)
164  edm::LogInfo("SiStripBadModuleGenerator") << ss.str();
165 }
166 
167 
169  const DetId & therawid,
170  uint32_t requested_layer,
171  uint32_t requested_bkw_frw,
172  uint32_t requested_int_ext,
173  uint32_t requested_string,
174  uint32_t requested_ster,
175  uint32_t requested_detid) const{
176  if( therawid.subdetId() == SiStripDetId::TIB ){ // check if subdetector field is a TIB, both tested numbers are int
177  if( // check if TIB is from the ones requested
178  ( (tTopo->tibLayer(therawid)==requested_layer) || requested_layer==0 ) // take everything if default value is 0
179  &&
180  ( (tTopo->tibIsZPlusSide(therawid) && requested_bkw_frw==2) || (!tTopo->tibIsZPlusSide(therawid) && requested_bkw_frw==1) || requested_bkw_frw==0)
181  &&
182  ( (tTopo->tibIsInternalString(therawid) && requested_int_ext==1) || (!tTopo->tibIsInternalString(therawid) && requested_int_ext==2) || requested_int_ext==0 )
183  &&
184  ( (tTopo->tibIsStereo(therawid) && requested_ster==1) || (tTopo->tibIsRPhi(therawid) && requested_ster==2) || requested_ster==0 )
185  &&
186  ( (tTopo->tibString(therawid)==requested_string) || requested_string==0 )
187  &&
188  ( (therawid.rawId()==requested_detid) || requested_detid==0 )
189  )
190  return 1;
191  }
192  return 0;
193 }
194 
196  const DetId & therawid,
197  uint32_t requested_layer,
198  uint32_t requested_bkw_frw,
199  uint32_t requested_rod,
200  uint32_t requested_ster,
201  uint32_t requested_detid) const{
202  if( therawid.subdetId() == SiStripDetId::TOB ){ // check if subdetector field is a TOB, both tested numbers are int
203  if( // check if TOB is from the ones requested
204  ( (tTopo->tobLayer(therawid)==requested_layer) || requested_layer==0 ) // take everything if default value is 0
205  &&
206  ( (tTopo->tobIsZPlusSide(therawid) && requested_bkw_frw==2) || (!tTopo->tobIsZPlusSide(therawid) && requested_bkw_frw==1) || requested_bkw_frw==0)
207  &&
208  ( (tTopo->tobIsStereo(therawid) && requested_ster==1) || (tTopo->tobIsRPhi(therawid) && requested_ster==2) || requested_ster==0 )
209  &&
210  ( (tTopo->tobRod(therawid) ==requested_rod) || requested_rod==0 )
211  &&
212  ( (therawid.rawId()==requested_detid) || requested_detid==0 )
213  )
214  return 1;
215  }
216  return 0;
217 }
218 
219 
221  const DetId & therawid,
222  uint32_t requested_side,
223  uint32_t requested_wheel,
224  uint32_t requested_ring,
225  uint32_t requested_ster,
226  uint32_t requested_detid) const{
227  if( therawid.subdetId() == SiStripDetId::TID ){ // check if subdetector field is a TID, both tested numbers are int
228  if( // check if TID is from the ones requested
229  ( (tTopo->tidWheel(therawid)==requested_wheel) || requested_wheel==0 ) // take everything if default value is 0
230  &&
231  ( (tTopo->tidIsZPlusSide(therawid) && requested_side==2) || (!tTopo->tidIsZPlusSide(therawid) && requested_side==1) || requested_side==0)
232  &&
233  ( (tTopo->tidIsStereo(therawid) && requested_ster==1) || (tTopo->tidIsRPhi(therawid) && requested_ster==2) || requested_ster==0 )
234  &&
235  ( (tTopo->tidRing(therawid) ==requested_ring) || requested_ring==0 )
236  &&
237  ( (therawid.rawId()==requested_detid) || requested_detid==0 )
238  )
239  return 1;
240  }
241  return 0;
242 }
243 
244 
246  const DetId & therawid,
247  uint32_t requested_side,
248  uint32_t requested_wheel,
249  uint32_t requested_petal_bkw_frw,
250  uint32_t requested_petal,
251  uint32_t requested_ring,
252  uint32_t requested_ster,
253  uint32_t requested_detid) const{
254  if( therawid.subdetId() == SiStripDetId::TEC ){ // check if subdetector field is a TEC, both tested numbers are int
255  if( // check if TEC is from the ones requested
256  ( (tTopo->tecWheel(therawid)==requested_wheel) || requested_wheel==0 ) // take everything if default value is 0
257  &&
258  ( (tTopo->tecIsZPlusSide(therawid) && requested_side==2) || (!tTopo->tecIsZPlusSide(therawid) && requested_side==1) || requested_side==0)
259  &&
260  ( (tTopo->tecIsStereo(therawid) && requested_ster==1) || (!tTopo->tecIsStereo(therawid) && requested_ster==2) || requested_ster==0 )
261  &&
262  ( (tTopo->tecIsFrontPetal(therawid)&& requested_petal_bkw_frw==2) || (!tTopo->tecIsFrontPetal(therawid) && requested_petal_bkw_frw==2) || requested_petal_bkw_frw==0 )
263  &&
264  ( (tTopo->tecPetalNumber(therawid)==requested_petal) || requested_petal==0 )
265  &&
266  ( (tTopo->tecRing(therawid)==requested_ring) || requested_ring==0 )
267  &&
268  ( (therawid.rawId()==requested_detid) || requested_detid==0 )
269  )
270  return 1;
271  }
272  return 0;
273 }
274 
T getUntrackedParameter(std::string const &, T const &) const
void selectDetectors(const TrackerTopology *tTopo, const std::vector< uint32_t > &, std::vector< uint32_t > &)
bool cleanUp(bool force=false)
const std::vector< BadComponent > & getBadComponentList() const
unsigned int tibLayer(const DetId &id) const
unsigned int tibString(const DetId &id) const
unsigned int tidRing(const DetId &id) const
bool isTIDDetector(const TrackerTopology *tTopo, const DetId &therawid, uint32_t requested_side, uint32_t requested_wheel, uint32_t requested_ring, uint32_t requested_ster, uint32_t requested_detid) const
bool tobIsStereo(const DetId &id) const
std::vector< edm::ParameterSet > Parameters
unsigned int tecRing(const DetId &id) const
ring id
unsigned int tidWheel(const DetId &id) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool tobIsRPhi(const DetId &id) const
bool tidIsStereo(const DetId &id) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool tibIsZPlusSide(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool tibIsRPhi(const DetId &id) const
bool isTIBDetector(const TrackerTopology *tTopo, const DetId &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
bool tobIsZPlusSide(const DetId &id) const
SiStripBadModuleGenerator(const edm::ParameterSet &, const edm::ActivityRegistry &)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool tecIsFrontPetal(const DetId &id) const
Definition: DetId.h:18
bool tidIsRPhi(const DetId &id) const
bool tidIsZPlusSide(const DetId &id) const
bool tibIsStereo(const DetId &id) const
SiStripBadStrip * createObject(const TrackerTopology *tTopo)
bool isTOBDetector(const TrackerTopology *tTopo, const DetId &therawid, uint32_t requested_layer, uint32_t requested_bkw_frw, uint32_t requested_rod, uint32_t requested_ster, uint32_t requested_detid) const
bool tecIsZPlusSide(const DetId &id) const
bool isTECDetector(const TrackerTopology *tTopo, const DetId &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
unsigned int tecPetalNumber(const DetId &id) const
tuple cout
Definition: gather_cfg.py:121
std::string fullPath() const
Definition: FileInPath.cc:165
unsigned int tobRod(const DetId &id) const
bool put(const uint32_t &detID, const InputVector &vect)
bool tibIsInternalString(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
unsigned int tobLayer(const DetId &id) 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
Container InputVector