CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiStripQuality Class Reference

#include <SiStripQuality.cc>

Inheritance diagram for SiStripQuality:
SiStripBadStrip

Classes

struct  BadComponent
 
class  BadComponentStrictWeakOrdering
 

Public Member Functions

void add (const uint32_t &, const SiStripBadStrip::Range &)
 
void add (const SiStripBadStrip *)
 
void add (const SiStripDetCabling *)
 
void add (const SiStripDetVOff *)
 
void add (const RunInfo *)
 
void addInvalidConnectionFromCabling ()
 
void addNotConnectedConnectionFromCabling ()
 
bool cleanUp (bool force=false)
 
void clear ()
 
void compact (unsigned int &, std::vector< unsigned int > &)
 
void fillBadComponents ()
 
short getBadApvs (const uint32_t &detid) const
 
const std::vector< BadComponent > & getBadComponentList () const
 
short getBadFibers (const uint32_t &detid) const
 
edm::FileInPath getFileInPath () const
 
bool IsApvBad (const uint32_t &detid, const short &apvNb) const
 
bool IsFiberBad (const uint32_t &detid, const short &fiberNb) const
 
bool IsModuleBad (const uint32_t &detid) const
 
bool IsModuleUsable (const uint32_t &detid) const
 
bool IsStripBad (const uint32_t &detid, const short &strip) const
 
bool IsStripBad (const Range &range, const short &strip) const
 
int nBadStripsOnTheLeft (const Range &range, const short &strip) const
 
int nBadStripsOnTheRight (const Range &range, const short &strip) const
 
bool operator!= (const SiStripQuality &) const
 
SiStripQualityoperator+= (const SiStripQuality &)
 
const SiStripQuality operator- (const SiStripQuality &) const
 
SiStripQualityoperator-= (const SiStripQuality &)
 
bool operator== (const SiStripQuality &) const
 
void ReduceGranularity (double)
 
void setPrintDebugOutput (const bool printDebug)
 
void setUseEmptyRunInfo (const bool useEmptyRunInfo)
 
 SiStripQuality ()
 
 SiStripQuality (edm::FileInPath &)
 
 SiStripQuality (const SiStripQuality &)
 
 ~SiStripQuality ()
 
- Public Member Functions inherited from SiStripBadStrip
data decode (const unsigned int &value) const
 
unsigned int encode (const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
 
ContainerIterator getDataVectorBegin () const
 
ContainerIterator getDataVectorEnd () const
 
void getDetIds (std::vector< uint32_t > &DetIds_) const
 
const Range getRange (const uint32_t &detID) const
 
RegistryIterator getRegistryVectorBegin () const
 
RegistryIterator getRegistryVectorEnd () const
 
void printDebug (std::stringstream &ss) const
 
void printSummary (std::stringstream &ss) const
 
bool put (const uint32_t &detID, const InputVector &vect)
 
bool put (const uint32_t &detID, Range input)
 
 SiStripBadStrip ()
 
 SiStripBadStrip (const SiStripBadStrip &orig)
 
virtual ~SiStripBadStrip ()
 

Private Member Functions

void compact (std::vector< unsigned int > &, std::vector< unsigned int > &, unsigned short &)
 
void printActiveFedsInfo (const std::vector< uint16_t > &activeFedsFromCabling, const std::vector< int > &activeFedsFromRunInfo, const std::vector< int > &differentFeds, const bool printDebug)
 Prints debug output for the active feds comparing the list in RunInfo and FedCabling. More...
 
void printDetInfo (const uint32_t &detId, const uint32_t &apvPairNumber, std::stringstream &ss)
 Prints debug output for a given detId. More...
 
bool put_replace (const uint32_t &DetId, Range input)
 
void subtract (std::vector< unsigned int > &, const std::vector< unsigned int > &)
 
void subtraction (std::vector< unsigned int > &, const unsigned int &)
 
void turnOffFeds (const std::vector< int > &fedsList, const bool turnOffStrips, const bool printDebug)
 

Private Attributes

std::vector< BadComponentBadComponentVect
 
edm::FileInPath FileInPath_
 
bool printDebug_
 
SiStripDetInfoFileReaderreader
 
const SiStripDetCablingSiStripDetCabling_
 
bool toCleanUp
 
bool useEmptyRunInfo_
 

Additional Inherited Members

- Public Types inherited from SiStripBadStrip
typedef std::vector< unsigned int > Container
 
typedef std::vector< unsigned
int >::const_iterator 
ContainerIterator
 
typedef Container InputVector
 
typedef std::pair
< ContainerIterator,
ContainerIterator
Range
 
typedef std::vector< DetRegistryRegistry
 
typedef Registry::const_iterator RegistryIterator
 
- Protected Attributes inherited from SiStripBadStrip
Registry indexes
 
Container v_badstrips
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 33 of file SiStripQuality.h.

Constructor & Destructor Documentation

SiStripQuality::SiStripQuality ( )

Definition at line 20 of file SiStripQuality.cc.

References FileInPath_, edm::FileInPath::fullPath(), reader, and OfflineSiStripConfigDb_cff::SiStripDetInfoFileReader.

Referenced by operator-().

20  :
21  toCleanUp(false),
22  FileInPath_("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"),
24  printDebug_(false),
25  useEmptyRunInfo_(false)
26 {
28 }
#define NULL
Definition: scimark2.h:8
const SiStripDetCabling * SiStripDetCabling_
SiStripDetInfoFileReader * reader
edm::FileInPath FileInPath_
std::string fullPath() const
Definition: FileInPath.cc:171
SiStripQuality::SiStripQuality ( edm::FileInPath file)

Definition at line 30 of file SiStripQuality.cc.

References FileInPath_, edm::FileInPath::fullPath(), reader, and OfflineSiStripConfigDb_cff::SiStripDetInfoFileReader.

31 {
33 }
#define NULL
Definition: scimark2.h:8
const SiStripDetCabling * SiStripDetCabling_
SiStripDetInfoFileReader * reader
edm::FileInPath FileInPath_
std::string fullPath() const
Definition: FileInPath.cc:171
SiStripQuality::SiStripQuality ( const SiStripQuality other)

Definition at line 35 of file SiStripQuality.cc.

References BadComponentVect, FileInPath_, SiStripBadStrip::indexes, printDebug_, reader, SiStripDetCabling_, OfflineSiStripConfigDb_cff::SiStripDetInfoFileReader, toCleanUp, useEmptyRunInfo_, and SiStripBadStrip::v_badstrips.

36 {
39  toCleanUp=other.toCleanUp;
40  indexes=other.indexes;
46 }
std::vector< BadComponent > BadComponentVect
const SiStripDetCabling * SiStripDetCabling_
Container v_badstrips
SiStripDetInfoFileReader * reader
edm::FileInPath FileInPath_
SiStripQuality::~SiStripQuality ( )
inline

Definition at line 53 of file SiStripQuality.h.

References LogTrace, and reader.

53  {
54  LogTrace("SiStripQuality") << "SiStripQuality destructor" << std::endl;
55  delete reader;
56  }
#define LogTrace(id)
SiStripDetInfoFileReader * reader

Member Function Documentation

void SiStripQuality::add ( const uint32_t &  detid,
const SiStripBadStrip::Range baserange 
)

Definition at line 284 of file SiStripQuality.cc.

References compact(), SiStripBadStrip::decode(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::data::flag, SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), SiStripBadStrip::getRange(), LogTrace, put_replace(), SiStripBadStrip::data::range, reader, and tmp.

Referenced by add(), addInvalidConnectionFromCabling(), addNotConnectedConnectionFromCabling(), operator+=(), ReduceGranularity(), and turnOffFeds().

285 {
286  std::vector<unsigned int> vect, tmp;
287 
288  unsigned short Nstrips=reader->getNumberOfApvsAndStripLength(detid).first*128;
289 
290  //Is this detid already in the collections owned by this class?
292 
293  //Append bad strips
294  tmp.clear();
295  if (range.first==range.second){
296  LogTrace("SiStripQuality") << "new detid" << std::endl;
297  //It's a new detid
298  tmp.insert(tmp.end(),baserange.first,baserange.second);
299  std::stable_sort(tmp.begin(),tmp.end());
300  LogTrace("SiStripQuality") << "ordered" << std::endl;
301  } else {
302  LogTrace("SiStripQuality") << "already exists" << std::endl;
303  //alredy existing detid
304 
305  //if full det is bad go to next detid
306  SiStripBadStrip::data data_=decode(*(range.first));
307  if(range.second-range.first==1
308  && data_.firstStrip==0
309  && data_.range>=Nstrips){
310  LogTrace("SiStripQuality") << "full det is bad.. " << range.second-range.first << " " << decode(*(range.first)).firstStrip << " " << decode(*(range.first)).range << " " << decode(*(range.first)).flag <<"\n"<< std::endl;
311  return;
312  }
313 
314  tmp.insert(tmp.end(),baserange.first,baserange.second);
315  tmp.insert(tmp.end(),range.first,range.second);
316  std::stable_sort(tmp.begin(),tmp.end());
317  LogTrace("SiStripQuality") << "ordered" << std::endl;
318  }
319  //Compact data
320  compact(tmp,vect,Nstrips);
321  SiStripBadStrip::Range newrange(vect.begin(),vect.end());
322  if ( ! put_replace(detid,newrange) )
323  edm::LogError("SiStripQuality")<<"[" << __PRETTY_FUNCTION__ << "] " << std::endl;
324 }
unsigned short range
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void compact(unsigned int &, std::vector< unsigned int > &)
#define LogTrace(id)
bool put_replace(const uint32_t &DetId, Range input)
unsigned short firstStrip
const Range getRange(const uint32_t &detID) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::pair< ContainerIterator, ContainerIterator > Range
SiStripDetInfoFileReader * reader
data decode(const unsigned int &value) const
void SiStripQuality::add ( const SiStripBadStrip base)

Definition at line 267 of file SiStripQuality.cc.

References add(), cond::rpcobgas::detid, SiStripBadStrip::getDataVectorBegin(), SiStripBadStrip::getRegistryVectorBegin(), SiStripBadStrip::getRegistryVectorEnd(), and LogTrace.

268 {
271 
272  //the Registry already contains data
273  //Loop on detids
274  for (SiStripBadStrip::RegistryIterator basep=basebegin; basep != baseend; ++basep) {
275  uint32_t detid=basep->detid;
276  LogTrace("SiStripQuality") << "add detid " <<detid << std::endl;
277 
278  SiStripBadStrip::Range baserange = SiStripBadStrip::Range( base->getDataVectorBegin()+basep->ibegin , base->getDataVectorBegin()+basep->iend );
279 
280  add(detid,baserange);
281  }
282 }
void add(const uint32_t &, const SiStripBadStrip::Range &)
Registry::const_iterator RegistryIterator
RegistryIterator getRegistryVectorEnd() const
#define LogTrace(id)
ContainerIterator getDataVectorBegin() const
RegistryIterator getRegistryVectorBegin() const
std::pair< ContainerIterator, ContainerIterator > Range
void SiStripQuality::add ( const SiStripDetCabling cab)

Definition at line 201 of file SiStripQuality.cc.

References addInvalidConnectionFromCabling(), addNotConnectedConnectionFromCabling(), and SiStripDetCabling_.

202 {
203  SiStripDetCabling_=cab;
206 }
void addInvalidConnectionFromCabling()
const SiStripDetCabling * SiStripDetCabling_
void addNotConnectedConnectionFromCabling()
void SiStripQuality::add ( const SiStripDetVOff Voff)

Definition at line 112 of file SiStripQuality.cc.

References add(), SiStripBadStrip::encode(), SiStripDetVOff::getDetIds(), SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), LogTrace, and reader.

113 {
114  std::vector<unsigned int> vect;
115  short firstStrip=0;
116  short range=0;
117 
118  //Get vector of Voff dets
119  std::vector<uint32_t> vdets;
120  Voff->getDetIds(vdets);
121  std::vector<uint32_t>::const_iterator iter=vdets.begin();
122  std::vector<uint32_t>::const_iterator iterEnd=vdets.end();
123 
124  for(;iter!=iterEnd;++iter){
125  vect.clear();
126  range = (short) (reader->getNumberOfApvsAndStripLength(*iter).first*128.);
127  LogTrace("SiStripQuality") << "[add Voff] add detid " << *iter << " first strip " << firstStrip << " range " << range << std::endl;
128  vect.push_back(encode(firstStrip,range));
129  SiStripBadStrip::Range Range(vect.begin(),vect.end());
130  add(*iter,Range);
131  }
132 }
void add(const uint32_t &, const SiStripBadStrip::Range &)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void getDetIds(std::vector< uint32_t > &DetIds_) const
#define LogTrace(id)
std::pair< ContainerIterator, ContainerIterator > Range
SiStripDetInfoFileReader * reader
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void SiStripQuality::add ( const RunInfo runInfo)

Used to get the cabling from RunInfo.
It compares the feds from cabling with those from runInfo and it turns off all the strips associated to feds that are off for the RunInfo but not for FedCabling.

Definition at line 134 of file SiStripQuality.cc.

References CastorDataFrameFilter_impl::check(), SiStripDetCabling::fedCabling(), SiStripFedCabling::feds(), RunInfo::m_fed_in, FEDNumbering::MAXSiStripFEDID, FEDNumbering::MINSiStripFEDID, printActiveFedsInfo(), printDebug_, SiStripDetCabling_, python.multivaluedict::sort(), turnOffFeds(), and useEmptyRunInfo_.

135 {
136  bool allFedsEmpty = runInfo->m_fed_in.empty();
137  if( allFedsEmpty ) {
138  std::stringstream ss;
139  ss << "WARNING: the full list of feds in RunInfo is empty. ";
140  if( useEmptyRunInfo_ ) {
141  ss << " SiStripQuality will still use it and all tracker will be off." << std::endl;
142  }
143  else {
144  ss << " SiStripQuality will not use it." << std::endl;
145  }
146  edm::LogInfo("SiStripQuality") << ss.str();
147  }
148 
149  if( !allFedsEmpty || useEmptyRunInfo_ ) {
150  // Take the list of active feds from fedCabling
151  std::vector<uint16_t> activeFedsFromCabling = SiStripDetCabling_->fedCabling()->feds();
152 
153  // Take the list of active feds from RunInfo
154  std::vector<int> activeFedsFromRunInfo;
155  // Take only Tracker feds (remove all non Tracker)
156  std::remove_copy_if( runInfo->m_fed_in.begin(),
157  runInfo->m_fed_in.end(),
158  std::back_inserter(activeFedsFromRunInfo),
159  !boost::bind(std::logical_and<bool>(),
160  boost::bind(std::greater_equal<int>(), _1, int(FEDNumbering::MINSiStripFEDID)),
161  boost::bind(std::less_equal<int>(), _1, int(FEDNumbering::MAXSiStripFEDID))) );
162 
163  // Compare the two. If a fedId from RunInfo is not present in the fedCabling we need to
164  // get all the corresponding fedChannels and then the single apv pairs and use them to
165  // turn off the corresponding strips (apvNumber*256).
166  // set_difference returns the set of elements that are in the first and not in the second
167  std::sort(activeFedsFromCabling.begin(), activeFedsFromCabling.end());
168  std::sort(activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end());
169  std::vector<int> differentFeds;
170  // Take the feds active for cabling but not for runInfo
171  std::set_difference(activeFedsFromCabling.begin(), activeFedsFromCabling.end(),
172  activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end(),
173  std::back_inserter(differentFeds));
174 
175  printActiveFedsInfo(activeFedsFromCabling, activeFedsFromRunInfo, differentFeds, printDebug_);
176 
177  // Feds in the differentFeds vector are now to be turned off as they are off according to RunInfo
178  // but were not off in cabling and thus are still active for the SiStripQuality.
179  // The "true" means that the strips are to be set as bad.
180  turnOffFeds(differentFeds, true, printDebug_);
181 
182  // Consistency check
183  // -----------------
184  std::vector<int> check;
185  std::set_difference(activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end(),
186  activeFedsFromCabling.begin(), activeFedsFromCabling.end(),
187  std::back_inserter(check));
188  // This must not happen
189  if( !check.empty() ) {
190  // throw cms::Exception("LogicError")
191  edm::LogWarning("SiStripQuality")
192  << "The cabling should always include the active feds in runInfo and possibly have some more"
193  << "there are instead " << check.size() << " feds only active in runInfo";
194  // The "false" means that we are only printing the output, but not setting the strips as bad.
195  // The second bool means that we always want the debug output in this case.
196  turnOffFeds(check, false, true);
197  }
198  }
199 }
const std::vector< uint16_t > & feds() const
std::vector< int > m_fed_in
Definition: RunInfo.h:24
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
const SiStripDetCabling * SiStripDetCabling_
const SiStripFedCabling * fedCabling() const
void turnOffFeds(const std::vector< int > &fedsList, const bool turnOffStrips, const bool printDebug)
void printActiveFedsInfo(const std::vector< uint16_t > &activeFedsFromCabling, const std::vector< int > &activeFedsFromRunInfo, const std::vector< int > &differentFeds, const bool printDebug)
Prints debug output for the active feds comparing the list in RunInfo and FedCabling.
void SiStripQuality::addInvalidConnectionFromCabling ( )

Definition at line 227 of file SiStripQuality.cc.

References add(), SiStripDetCabling::addActiveDetectorsRawIds(), SiStripBadStrip::encode(), SiStripDetCabling::getConnections(), sistrip::invalid_, LogTrace, SiStripDetCabling::nApvPairs(), and SiStripDetCabling_.

Referenced by add().

228 {
229  std::vector<uint32_t> connected_detids;
230  SiStripDetCabling_->addActiveDetectorsRawIds(connected_detids);
231  std::vector<uint32_t>::const_iterator itdet = connected_detids.begin();
232  std::vector<uint32_t>::const_iterator itdetEnd = connected_detids.end();
233  for(;itdet!=itdetEnd;++itdet){
234  //LogTrace("SiStripQuality") << "[addInvalidConnectionFromCabling] looking at detid " <<*itdet << std::endl;
235  const std::vector<const FedChannelConnection *>& fedconns=SiStripDetCabling_->getConnections(*itdet);
236  std::vector<const FedChannelConnection *>::const_iterator itconns=fedconns.begin();
237  std::vector<const FedChannelConnection *>::const_iterator itconnsEnd=fedconns.end();
238 
239  unsigned short nApvPairs=SiStripDetCabling_->nApvPairs(*itdet);
240  short ngoodConn=0, goodConn=0;
241  for(;itconns!=itconnsEnd;++itconns){
242  //LogTrace("SiStripQuality") << "[addInvalidConnectionFromCabling] apvpair " << (*itconns)->apvPairNumber() << " napvpair " << (*itconns)->nApvPairs()<< " detid " << (*itconns)->detId() << std::endl;
243  if( (*itconns == 0) || ((*itconns)->nApvPairs()==sistrip::invalid_) )
244  continue;
245  ngoodConn++;
246  goodConn = goodConn | ( 0x1 << (*itconns)->apvPairNumber() );
247  }
248 
249  if (ngoodConn!=nApvPairs){
250  std::vector<unsigned int> vect;
251  for (size_t idx=0;idx<nApvPairs;++idx){
252  if( !(goodConn & ( 0x1 << idx)) ) {
253  short firstStrip=idx*256;
254  short range=256;
255  LogTrace("SiStripQuality") << "[addInvalidConnectionFromCabling] add detid " <<*itdet << "firstStrip " << firstStrip<< std::endl;
256  vect.push_back(encode(firstStrip,range));
257  }
258  }
259  if(!vect.empty()){
260  SiStripBadStrip::Range Range(vect.begin(),vect.end());
261  add(*itdet,Range);
262  }
263  }
264  }
265 }
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
void add(const uint32_t &, const SiStripBadStrip::Range &)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
const SiStripDetCabling * SiStripDetCabling_
#define LogTrace(id)
static const uint16_t invalid_
Definition: Constants.h:17
const uint16_t nApvPairs(uint32_t det_id) const
std::pair< ContainerIterator, ContainerIterator > Range
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void SiStripQuality::addNotConnectedConnectionFromCabling ( )

Definition at line 208 of file SiStripQuality.cc.

References add(), SiStripBadStrip::encode(), SiStripDetInfoFileReader::getAllData(), SiStripDetCabling::IsConnected(), LogTrace, reader, and SiStripDetCabling_.

Referenced by add().

209 {
210  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > allData = reader->getAllData();
211  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator iter=allData.begin();
212  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator iterEnd=allData.end();
213  std::vector<unsigned int> vect;
214  short firstStrip=0;
215  short range=0;
216  for(;iter!=iterEnd;++iter)
217  if (!SiStripDetCabling_->IsConnected(iter->first)){
218  vect.clear();
219  range=iter->second.nApvs*128;
220  LogTrace("SiStripQuality") << "[addNotConnectedConnectionFromCabling] add detid " << iter->first << std::endl;
221  vect.push_back(encode(firstStrip,range));
222  SiStripBadStrip::Range Range(vect.begin(),vect.end());
223  add(iter->first,Range);
224  }
225 }
void add(const uint32_t &, const SiStripBadStrip::Range &)
bool IsConnected(const uint32_t &det_id) const
const std::map< uint32_t, DetInfo > & getAllData() const
const SiStripDetCabling * SiStripDetCabling_
#define LogTrace(id)
std::pair< ContainerIterator, ContainerIterator > Range
SiStripDetInfoFileReader * reader
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
bool SiStripQuality::cleanUp ( bool  force = false)

Definition at line 490 of file SiStripQuality.cc.

References SiStripBadStrip::indexes, LogTrace, SiStripBadStrip::put(), toCleanUp, and SiStripBadStrip::v_badstrips.

Referenced by SiStripBadModuleGenerator::createObject(), operator+=(), and operator-=().

491 {
492  if (!toCleanUp && !force)
493  return false;
494 
495  toCleanUp=false;
496 
497  std::vector<unsigned int> v_badstrips_tmp=v_badstrips;
498  std::vector<DetRegistry> indexes_tmp=indexes;
499 
500  LogTrace("SiStripQuality") << "[SiStripQuality::cleanUp] before cleanUp v_badstrips.size()= " << v_badstrips.size() << " indexes.size()=" << indexes.size() << std::endl;
501 
502  v_badstrips.clear();
503  indexes.clear();
504 
505  SiStripBadStrip::RegistryIterator basebegin = indexes_tmp.begin();
506  SiStripBadStrip::RegistryIterator baseend = indexes_tmp.end();
507 
508  for (SiStripBadStrip::RegistryIterator basep=basebegin; basep != baseend; ++basep) {
509  if(basep->ibegin!=basep->iend){
510  SiStripBadStrip::Range range( v_badstrips_tmp.begin()+basep->ibegin, v_badstrips_tmp.begin()+basep->iend );
511  if ( ! put(basep->detid,range) )
512  edm::LogError("SiStripQuality")<<"[" << __PRETTY_FUNCTION__ << "] " << std::endl;
513  }
514  }
515 
516  LogTrace("SiStripQuality") << "[SiStripQuality::cleanUp] after cleanUp v_badstrips.size()= " << v_badstrips.size() << " indexes.size()=" << indexes.size() << std::endl;
517  return true;
518 }
Registry::const_iterator RegistryIterator
#define LogTrace(id)
Container v_badstrips
std::pair< ContainerIterator, ContainerIterator > Range
bool put(const uint32_t &detID, const InputVector &vect)
void SiStripQuality::clear ( void  )
inline
void SiStripQuality::compact ( unsigned int &  detid,
std::vector< unsigned int > &  vect 
)

Definition at line 326 of file SiStripQuality.cc.

References SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), reader, and tmp.

Referenced by add(), SiStripBadAPVAlgorithmFromClusterOccupancy::AnalyzeOccupancy(), SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::AnalyzeOccupancy(), SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips(), SiStripHitEffFromCalibTree::makeSQLite(), and SiStripCondObjBuilderFromDb::storeQuality().

327 {
328  std::vector<unsigned int> tmp=vect;
329  vect.clear();
330  std::stable_sort(tmp.begin(),tmp.end());
331  unsigned short Nstrips=reader->getNumberOfApvsAndStripLength(detid).first*128;
332  compact(tmp,vect,Nstrips);
333 }
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void compact(unsigned int &, std::vector< unsigned int > &)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
SiStripDetInfoFileReader * reader
void SiStripQuality::compact ( std::vector< unsigned int > &  tmp,
std::vector< unsigned int > &  vect,
unsigned short &  Nstrips 
)
private

Definition at line 410 of file SiStripQuality.cc.

References SiStripBadStrip::decode(), SiStripBadStrip::encode(), SiStripBadStrip::data::firstStrip, and SiStripBadStrip::data::range.

411 {
412  SiStripBadStrip::data fs_0, fs_1;
413  vect.clear();
414 
415  ContainerIterator it=tmp.begin();
416  fs_0=decode(*it);
417 
418  //Check if at the module end
419  if (fs_0.firstStrip+fs_0.range>=Nstrips){
420  vect.push_back(encode(fs_0.firstStrip,Nstrips-fs_0.firstStrip));
421  return;
422  }
423 
424  ++it;
425  for(;it!=tmp.end();++it){
426  fs_1=decode(*it);
427 
428  if (fs_0.firstStrip+fs_0.range>=fs_1.firstStrip+fs_1.range){
429  //fs_0 includes fs_1, go ahead
430  } else if (fs_0.firstStrip+fs_0.range>=fs_1.firstStrip){
431  // contiguous or superimposed intervals
432  //Check if at the module end
433  if (fs_1.firstStrip+fs_1.range>=Nstrips){
434  vect.push_back(encode(fs_0.firstStrip,Nstrips-fs_0.firstStrip));
435  return;
436  }else{
437  //create new fs_0
438  fs_0.range=fs_1.firstStrip+fs_1.range-fs_0.firstStrip;
439  }
440  } else{
441  //separated intervals
442  vect.push_back(encode(fs_0.firstStrip,fs_0.range));
443  fs_0=fs_1;
444  }
445  }
446  vect.push_back(encode(fs_0.firstStrip,fs_0.range));
447 }
unsigned short range
std::vector< unsigned int >::const_iterator ContainerIterator
unsigned short firstStrip
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
data decode(const unsigned int &value) const
void SiStripQuality::fillBadComponents ( )

Definition at line 520 of file SiStripQuality.cc.

References SiStripQuality::BadComponent::BadApvs, BadComponentVect, SiStripQuality::BadComponent::BadFibers, SiStripQuality::BadComponent::BadModule, SiStripBadStrip::decode(), SiStripQuality::BadComponent::detid, SiStripBadStrip::data::firstStrip, SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), SiStripBadStrip::indexes, SiStripBadStrip::data::range, reader, query::result, and SiStripBadStrip::v_badstrips.

Referenced by SiStripBadAPVAlgorithmFromClusterOccupancy::extractBadAPVs(), SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy::extractBadAPVSandStrips(), SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips(), SiStripHitEffFromCalibTree::makeSQLite(), operator+=(), and operator-=().

521 {
522  BadComponentVect.clear();
523 
524  for (SiStripBadStrip::RegistryIterator basep=indexes.begin(); basep != indexes.end(); ++basep) {
525 
526  SiStripBadStrip::Range range( v_badstrips.begin()+basep->ibegin, v_badstrips.begin()+basep->iend );
527 
528  //Fill BadModules, BadFibers, BadApvs vectors
529  unsigned short resultA=0, resultF=0;
530  BadComponent result;
531 
533  unsigned short Nstrips=reader->getNumberOfApvsAndStripLength(basep->detid).first*128;
534 
535  //BadModules
536  fs=decode(*(range.first));
537  if (basep->iend - basep->ibegin == 1 &&
538  fs.firstStrip==0 &&
539  fs.range==Nstrips ){
540  result.detid=basep->detid;
541  result.BadModule=true;
542  result.BadFibers=(1<< (Nstrips/256))-1;
543  result.BadApvs=(1<< (Nstrips/128))-1;
544 
545  BadComponentVect.push_back(result);
546 
547  } else {
548 
549  //Bad Fibers and Apvs
550  for(SiStripBadStrip::ContainerIterator it=range.first;it!=range.second;++it){
551  fs=decode(*it);
552 
553  //BadApvs
554  for(short apvNb=0;apvNb<6;++apvNb){
555  if ( fs.firstStrip<=apvNb*128 && (apvNb+1)*128<=fs.firstStrip+fs.range ){
556  resultA=resultA | (1<<apvNb);
557  }
558  }
559  //BadFibers
560  for(short fiberNb=0;fiberNb<3;++fiberNb){
561  if ( fs.firstStrip<=fiberNb*256 && (fiberNb+1)*256<=fs.firstStrip+fs.range ){
562  resultF=resultF | (1<<fiberNb);
563  }
564  }
565  }
566  if (resultA!=0){
567  result.detid=basep->detid;
568  result.BadModule=false;
569  result.BadFibers=resultF;
570  result.BadApvs=resultA;
571  BadComponentVect.push_back(result);
572  }
573  }
574  }
575 }
unsigned short range
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::vector< unsigned int >::const_iterator ContainerIterator
Registry::const_iterator RegistryIterator
std::vector< BadComponent > BadComponentVect
tuple result
Definition: query.py:137
unsigned short firstStrip
Container v_badstrips
std::pair< ContainerIterator, ContainerIterator > Range
SiStripDetInfoFileReader * reader
data decode(const unsigned int &value) const
short SiStripQuality::getBadApvs ( const uint32_t &  detid) const

Definition at line 665 of file SiStripQuality.cc.

References BadComponentVect, cond::rpcobgas::detid, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by StMeasurementDetSet::initializeStripStatus().

666 {
667  std::vector<BadComponent>::const_iterator p = std::lower_bound(BadComponentVect.begin(),BadComponentVect.end(),detid,SiStripQuality::BadComponentStrictWeakOrdering());
668  if (p!=BadComponentVect.end() && p->detid==detid)
669  return p->BadApvs;
670  return 0;
671 }
std::vector< BadComponent > BadComponentVect
const std::vector<BadComponent>& SiStripQuality::getBadComponentList ( ) const
inline

Definition at line 121 of file SiStripQuality.h.

References BadComponentVect.

Referenced by SiStripHitEffFromCalibTree::algoAnalyze(), and SiStripBadModuleGenerator::createObject().

121 { return BadComponentVect; }
std::vector< BadComponent > BadComponentVect
short SiStripQuality::getBadFibers ( const uint32_t &  detid) const

Definition at line 673 of file SiStripQuality.cc.

References BadComponentVect, cond::rpcobgas::detid, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by StMeasurementDetSet::initializeStripStatus().

674 {
675  std::vector<BadComponent>::const_iterator p = std::lower_bound(BadComponentVect.begin(),BadComponentVect.end(),detid,SiStripQuality::BadComponentStrictWeakOrdering());
676  if (p!=BadComponentVect.end() && p->detid==detid)
677  return p->BadFibers;
678  return 0;
679 }
std::vector< BadComponent > BadComponentVect
edm::FileInPath SiStripQuality::getFileInPath ( ) const
inline

Definition at line 91 of file SiStripQuality.h.

References FileInPath_.

91 {return FileInPath_;}
edm::FileInPath FileInPath_
bool SiStripQuality::IsApvBad ( const uint32_t &  detid,
const short &  apvNb 
) const

Definition at line 609 of file SiStripQuality.cc.

References BadComponentVect, cond::rpcobgas::detid, and AlCaHLTBitMon_ParallelJobs::p.

610 {
611  std::vector<BadComponent>::const_iterator p = std::lower_bound(BadComponentVect.begin(),BadComponentVect.end(),detid,SiStripQuality::BadComponentStrictWeakOrdering());
612  if (p!=BadComponentVect.end() && p->detid==detid)
613  return ((p->BadApvs>>apvNb)&0x1);
614  return false;
615 }
std::vector< BadComponent > BadComponentVect
bool SiStripQuality::IsFiberBad ( const uint32_t &  detid,
const short &  fiberNb 
) const

Definition at line 601 of file SiStripQuality.cc.

References BadComponentVect, cond::rpcobgas::detid, and AlCaHLTBitMon_ParallelJobs::p.

602 {
603  std::vector<BadComponent>::const_iterator p = std::lower_bound(BadComponentVect.begin(),BadComponentVect.end(),detid,SiStripQuality::BadComponentStrictWeakOrdering());
604  if (p!=BadComponentVect.end() && p->detid==detid)
605  return ((p->BadFibers>>fiberNb)&0x1);
606  return false;
607 }
std::vector< BadComponent > BadComponentVect
bool SiStripQuality::IsModuleBad ( const uint32_t &  detid) const

Definition at line 593 of file SiStripQuality.cc.

References BadComponentVect, cond::rpcobgas::detid, and AlCaHLTBitMon_ParallelJobs::p.

594 {
595  std::vector<BadComponent>::const_iterator p = std::lower_bound(BadComponentVect.begin(),BadComponentVect.end(),detid,SiStripQuality::BadComponentStrictWeakOrdering());
596  if (p!=BadComponentVect.end() && p->detid==detid)
597  return p->BadModule;
598  return false;
599 }
std::vector< BadComponent > BadComponentVect
bool SiStripQuality::IsModuleUsable ( const uint32_t &  detid) const

Definition at line 579 of file SiStripQuality.cc.

References BadComponentVect, cond::rpcobgas::detid, SiStripDetCabling::IsConnected(), NULL, AlCaHLTBitMon_ParallelJobs::p, and SiStripDetCabling_.

Referenced by StMeasurementDetSet::initializeStripStatus().

580 {
581  std::vector<BadComponent>::const_iterator p = std::lower_bound(BadComponentVect.begin(),BadComponentVect.end(),detid,SiStripQuality::BadComponentStrictWeakOrdering());
582  if (p!=BadComponentVect.end() && p->detid==detid)
583  if(p->BadModule)
584  return false;
585 
588  return false;
589 
590  return true;
591 }
#define NULL
Definition: scimark2.h:8
bool IsConnected(const uint32_t &det_id) const
std::vector< BadComponent > BadComponentVect
const SiStripDetCabling * SiStripDetCabling_
bool SiStripQuality::IsStripBad ( const uint32_t &  detid,
const short &  strip 
) const

Definition at line 617 of file SiStripQuality.cc.

References SiStripBadStrip::getRange().

Referenced by jptJetAnalysis::StripSignalOverNoiseCalculator::signalOverNoise().

618 {
620  return IsStripBad(range,strip);
621 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
bool IsStripBad(const uint32_t &detid, const short &strip) const
const Range getRange(const uint32_t &detID) const
std::pair< ContainerIterator, ContainerIterator > Range
bool SiStripQuality::IsStripBad ( const Range range,
const short &  strip 
) const

Definition at line 623 of file SiStripQuality.cc.

References SiStripBadStrip::decode(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::data::range, and query::result.

624 {
625  bool result=false;
627  for(SiStripBadStrip::ContainerIterator it=range.first;it!=range.second;++it){
628  fs=decode(*it);
629  if ( fs.firstStrip<=strip && strip<fs.firstStrip+fs.range ){
630  result=true;
631  break;
632  }
633  }
634  return result;
635 }
unsigned short range
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::vector< unsigned int >::const_iterator ContainerIterator
tuple result
Definition: query.py:137
unsigned short firstStrip
data decode(const unsigned int &value) const
int SiStripQuality::nBadStripsOnTheLeft ( const Range range,
const short &  strip 
) const

Definition at line 637 of file SiStripQuality.cc.

References SiStripBadStrip::decode(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::data::range, and query::result.

638 {
639  int result=0;
641  for(SiStripBadStrip::ContainerIterator it=range.first;it!=range.second;++it){
642  fs=decode(*it);
643  if ( fs.firstStrip<=strip && strip<fs.firstStrip+fs.range ){
644  result=strip-fs.firstStrip+1;
645  break;
646  }
647  }
648  return result;
649 }
unsigned short range
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::vector< unsigned int >::const_iterator ContainerIterator
tuple result
Definition: query.py:137
unsigned short firstStrip
data decode(const unsigned int &value) const
int SiStripQuality::nBadStripsOnTheRight ( const Range range,
const short &  strip 
) const

Definition at line 651 of file SiStripQuality.cc.

References SiStripBadStrip::decode(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::data::range, query::result, and strip().

652 {
653  int result=0;
655  for(SiStripBadStrip::ContainerIterator it=range.first;it!=range.second;++it){
656  fs=decode(*it);
657  if ( fs.firstStrip<=strip && strip<fs.firstStrip+fs.range ){
658  result=fs.firstStrip+fs.range-strip;
659  break;
660  }
661  }
662  return result;
663 }
unsigned short range
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
std::vector< unsigned int >::const_iterator ContainerIterator
tuple result
Definition: query.py:137
unsigned short firstStrip
data decode(const unsigned int &value) const
bool SiStripQuality::operator!= ( const SiStripQuality other) const

Definition at line 110 of file SiStripQuality.cc.

110 { return !(*this == other) ; }
SiStripQuality & SiStripQuality::operator+= ( const SiStripQuality other)

Definition at line 49 of file SiStripQuality.cc.

References add(), cleanUp(), and fillBadComponents().

50 {
51  this->add(&other);
52  this->cleanUp();
53  this->fillBadComponents();
54  return *this;
55 }
bool cleanUp(bool force=false)
void add(const uint32_t &, const SiStripBadStrip::Range &)
void fillBadComponents()
const SiStripQuality SiStripQuality::operator- ( const SiStripQuality other) const

Definition at line 99 of file SiStripQuality.cc.

References SiStripQuality().

100 {
101  return SiStripQuality(*this) -= other;
102 }
SiStripQuality & SiStripQuality::operator-= ( const SiStripQuality other)

Definition at line 57 of file SiStripQuality.cc.

References cleanUp(), SiStripBadStrip::decode(), cond::rpcobgas::detid, fillBadComponents(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::getDataVectorBegin(), SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(), SiStripBadStrip::getRange(), SiStripBadStrip::getRegistryVectorBegin(), SiStripBadStrip::getRegistryVectorEnd(), put_replace(), SiStripBadStrip::data::range, reader, and subtract().

58 {
61  std::vector<unsigned int> ovect,vect;
62  uint32_t detid;
63  unsigned short Nstrips;
64 
65  for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
66 
67  detid=rp->detid;
68  Nstrips=reader->getNumberOfApvsAndStripLength(detid).first*128;
69 
70  SiStripBadStrip::Range orange = SiStripBadStrip::Range( other.getDataVectorBegin()+rp->ibegin , other.getDataVectorBegin()+rp->iend );
71 
72  //Is this detid already in the collections owned by this class?
73  SiStripBadStrip::Range range = getRange(detid);
74  if (range.first!=range.second){ //yes, it is
75 
76  vect.clear();
77  ovect.clear();
78 
79  //if other full det is bad, remove det from this
80  SiStripBadStrip::data data_=decode(*(orange.first));
81  if(orange.second-orange.first!=1
82  || data_.firstStrip!=0
83  || data_.range<Nstrips){
84 
85  ovect.insert(ovect.end(),orange.first,orange.second);
86  vect.insert(vect.end(),range.first,range.second);
87  subtract(vect,ovect);
88  }
89  SiStripBadStrip::Range newrange(vect.begin(),vect.end());
90  if ( ! put_replace(detid,newrange) )
91  edm::LogError("SiStripQuality")<<"[" << __PRETTY_FUNCTION__ << "] " << std::endl;
92  }
93  }
94  cleanUp();
96  return *this;
97 }
unsigned short range
bool cleanUp(bool force=false)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
Registry::const_iterator RegistryIterator
void subtract(std::vector< unsigned int > &, const std::vector< unsigned int > &)
RegistryIterator getRegistryVectorEnd() const
void fillBadComponents()
bool put_replace(const uint32_t &DetId, Range input)
ContainerIterator getDataVectorBegin() const
unsigned short firstStrip
const Range getRange(const uint32_t &detID) const
RegistryIterator getRegistryVectorBegin() const
std::pair< ContainerIterator, ContainerIterator > Range
SiStripDetInfoFileReader * reader
data decode(const unsigned int &value) const
bool SiStripQuality::operator== ( const SiStripQuality other) const

Definition at line 104 of file SiStripQuality.cc.

References a, SiStripBadStrip::getRegistryVectorBegin(), and SiStripBadStrip::getRegistryVectorEnd().

105 {
106  SiStripQuality a = (*this) - other ;
108 }
RegistryIterator getRegistryVectorEnd() const
RegistryIterator getRegistryVectorBegin() const
double a
Definition: hdecay.h:121
void SiStripQuality::printActiveFedsInfo ( const std::vector< uint16_t > &  activeFedsFromCabling,
const std::vector< int > &  activeFedsFromRunInfo,
const std::vector< int > &  differentFeds,
const bool  printDebug 
)
private

Prints debug output for the active feds comparing the list in RunInfo and FedCabling.

Definition at line 726 of file SiStripQuality.cc.

References filterCSVwithJSON::copy.

Referenced by add().

730 {
731  std::ostringstream ss;
732 
733  if( printDebug ) {
734  ss << "activeFedsFromCabling:" << std::endl;
735  std::copy(activeFedsFromCabling.begin(), activeFedsFromCabling.end(), std::ostream_iterator<uint16_t>(ss, " "));
736  ss << std::endl;
737  ss << "activeFedsFromRunInfo:" << std::endl;
738  std::copy(activeFedsFromRunInfo.begin(), activeFedsFromRunInfo.end(), std::ostream_iterator<int>(ss, " "));
739  ss << std::endl;
740  }
741  if( differentFeds.size() != 440 ) {
742  ss << "differentFeds : " << std::endl;
743  std::copy(differentFeds.begin(), differentFeds.end(), std::ostream_iterator<int>(ss, " "));
744  ss << std::endl;
745  }
746  else {
747  ss << "There are 440 feds (all) active for Cabling but off for RunInfo. Tracker was probably not in this run" << std::endl;
748  }
749  edm::LogInfo("SiStripQuality") << ss.str() << std::endl;
750 }
void printDebug(std::stringstream &ss) const
void SiStripQuality::printDetInfo ( const uint32_t &  detId,
const uint32_t &  apvPairNumber,
std::stringstream &  ss 
)
private

Prints debug output for a given detId.

Definition at line 681 of file SiStripQuality.cc.

References cond::rpcobgas::detid, TOBDetId::layer(), TIBDetId::layer(), DetId::rawId(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, and TECDetId::wheel().

Referenced by turnOffFeds().

682 {
683  int layer = 0;
684  int stereo = 0;
685  std::string subDetName;
686  DetId detid(detId);
687  switch (detid.subdetId()) {
689  {
690  TIBDetId theTIBDetId(detid.rawId());
691  layer = theTIBDetId.layer();
692  stereo = theTIBDetId.stereo();
693  subDetName = "TIB";
694  break;
695  }
697  {
698  TOBDetId theTOBDetId(detid.rawId());
699  layer = theTOBDetId.layer();
700  stereo = theTOBDetId.stereo();
701  subDetName = "TOB";
702  break;
703  }
705  {
706  TECDetId theTECDetId(detid.rawId());
707  // is this module in TEC+ or TEC-?
708  layer = theTECDetId.wheel();
709  stereo = theTECDetId.stereo();
710  subDetName = "TEC";
711  break;
712  }
714  {
715  TECDetId theTIDDetId(detid.rawId());
716  // is this module in TID+ or TID-?
717  layer = theTIDDetId.wheel();
718  stereo = theTIDDetId.stereo();
719  subDetName = "TID";
720  break;
721  }
722  }
723  ss << detId << " and apv = " << apvPairNumber << " of subDet = " << subDetName << ", layer = " << layer << " stereo = " << stereo << std::endl;
724 }
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
Definition: DetId.h:20
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
bool SiStripQuality::put_replace ( const uint32_t &  DetId,
Range  input 
)
private

Definition at line 335 of file SiStripQuality.cc.

References SiStripBadStrip::DetRegistry::detid, SiStripBadStrip::DetRegistry::ibegin, SiStripBadStrip::DetRegistry::iend, SiStripBadStrip::indexes, LogTrace, AlCaHLTBitMon_ParallelJobs::p, sd, toCleanUp, and SiStripBadStrip::v_badstrips.

Referenced by add(), and operator-=().

336 {
337  // put in SiStripQuality::v_badstrips of DetId
338  Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripBadStrip::StrictWeakOrdering());
339 
340  size_t sd= input.second-input.first;
341  DetRegistry detregistry;
342  detregistry.detid=DetId;
343  detregistry.ibegin=v_badstrips.size();
344  detregistry.iend=v_badstrips.size()+sd;
345 
346  v_badstrips.insert(v_badstrips.end(),input.first,input.second);
347 
348  if (p!=indexes.end() && p->detid==DetId){
349  LogTrace("SiStripQuality") << "[SiStripQuality::put_replace] Replacing SiStripQuality for already stored DetID " << DetId << std::endl;
350  toCleanUp=true;
351  *p=detregistry;
352  } else {
353  indexes.insert(p,detregistry);
354  }
355 
356  return true;
357 }
#define LogTrace(id)
Definition: DetId.h:20
Container v_badstrips
double sd
void SiStripQuality::ReduceGranularity ( double  threshold)

Definition at line 365 of file SiStripQuality.cc.

References add(), SiStripBadStrip::decode(), cond::rpcobgas::detid, SiStripBadStrip::encode(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::getDataVectorBegin(), SiStripBadStrip::getRegistryVectorBegin(), SiStripBadStrip::getRegistryVectorEnd(), i, LogTrace, max(), min, and SiStripBadStrip::data::range.

366 {
369  SiStripBadStrip::data data_;
370  uint16_t BadStripPerApv[6], ipos;
371  std::vector<unsigned int> vect;
372 
373  for (; rp != rend; ++rp) {
374  uint32_t detid=rp->detid;
375 
376  BadStripPerApv[0]=0; BadStripPerApv[1]=0; BadStripPerApv[2]=0; BadStripPerApv[3]=0; BadStripPerApv[4]=0; BadStripPerApv[5]=0;
377  ipos=0;
378 
380 
381  for(int it=0;it<sqrange.second-sqrange.first;it++){
382 
383  data_=decode( *(sqrange.first+it) );
384  LogTrace("SiStripQuality") << "[SiStripQuality::ReduceGranularity] detid " << detid << " first strip " << data_.firstStrip << " lastStrip " << data_.firstStrip+data_.range-1 << " range " << data_.range;
385  ipos= data_.firstStrip/128;
386  while (ipos<=(data_.firstStrip+data_.range-1)/128){
387  BadStripPerApv[ipos]+=std::min(data_.firstStrip+data_.range,(ipos+1)*128)-std::max(data_.firstStrip*1,ipos*128);
388  LogTrace("SiStripQuality") << "[SiStripQuality::ReduceGranularity] ipos " << ipos << " Counter " << BadStripPerApv[ipos] << " min " << std::min(data_.firstStrip+data_.range,(ipos+1)*128) << " max " << std::max(data_.firstStrip*1,ipos*128) << " added " << std::min(data_.firstStrip+data_.range,(ipos+1)*128)-std::max(data_.firstStrip*1,ipos*128);
389  ipos++;
390  }
391  }
392 
393  LogTrace("SiStripQuality") << "[SiStripQuality::ReduceGranularity] Total for detid " << detid << " values " << BadStripPerApv[0] << " " << BadStripPerApv[1] << " " << BadStripPerApv[2] << " " <<BadStripPerApv[3] << " " <<BadStripPerApv[4] << " " << BadStripPerApv[5];
394 
395 
396  vect.clear();
397  for(size_t i=0;i<6;++i){
398  if (BadStripPerApv[i]>=threshold*128){
399  vect.push_back(encode(i*128,128));
400  }
401  }
402  if(!vect.empty()){
403  SiStripBadStrip::Range Range(vect.begin(),vect.end());
404  add(detid,Range);
405  }
406  }
407 }
unsigned short range
int i
Definition: DBlmapReader.cc:9
void add(const uint32_t &, const SiStripBadStrip::Range &)
#define min(a, b)
Definition: mlp_lapack.h:161
Registry::const_iterator RegistryIterator
RegistryIterator getRegistryVectorEnd() const
const T & max(const T &a, const T &b)
#define LogTrace(id)
ContainerIterator getDataVectorBegin() const
unsigned short firstStrip
RegistryIterator getRegistryVectorBegin() const
std::pair< ContainerIterator, ContainerIterator > Range
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
data decode(const unsigned int &value) const
void SiStripQuality::setPrintDebugOutput ( const bool  printDebug)
inline

Definition at line 125 of file SiStripQuality.h.

References SiStripBadStrip::printDebug(), and printDebug_.

125 { printDebug_ = printDebug; }
void printDebug(std::stringstream &ss) const
void SiStripQuality::setUseEmptyRunInfo ( const bool  useEmptyRunInfo)
inline

Definition at line 126 of file SiStripQuality.h.

References useEmptyRunInfo_.

126 { useEmptyRunInfo_ = useEmptyRunInfo; }
void SiStripQuality::subtract ( std::vector< unsigned int > &  A,
const std::vector< unsigned int > &  B 
)
private

Definition at line 449 of file SiStripQuality.cc.

References subtraction().

Referenced by operator-=().

450 {
451  ContainerIterator it=B.begin();
452  ContainerIterator itend=B.end();
453  for(;it!=itend;++it){
454  subtraction(A,*it);
455  }
456 }
std::vector< unsigned int >::const_iterator ContainerIterator
void subtraction(std::vector< unsigned int > &, const unsigned int &)
void SiStripQuality::subtraction ( std::vector< unsigned int > &  A,
const unsigned int &  B 
)
private

Definition at line 458 of file SiStripQuality.cc.

References SiStripBadStrip::decode(), SiStripBadStrip::encode(), SiStripBadStrip::data::firstStrip, SiStripBadStrip::data::range, and tmp.

Referenced by subtract().

459 {
460  SiStripBadStrip::data fs_A, fs_B, fs_m, fs_M;
461  std::vector<unsigned int> tmp;
462 
463  fs_B=decode(B);
464  ContainerIterator jt=A.begin();
465  ContainerIterator jtend=A.end();
466  for(;jt!=jtend;++jt){
467  fs_A=decode(*jt);
468  if (B<*jt){
469  fs_m=fs_B;
470  fs_M=fs_A;
471  }else{
472  fs_m=fs_A;
473  fs_M=fs_B;
474  }
475  //A) Verify the range to be subtracted crosses the new range
476  if (fs_m.firstStrip+fs_m.range>fs_M.firstStrip){
477  if (*jt<B){
478  tmp.push_back(encode(fs_A.firstStrip,fs_B.firstStrip-fs_A.firstStrip));
479  }
480  if (fs_A.firstStrip+fs_A.range>fs_B.firstStrip+fs_B.range){
481  tmp.push_back(encode(fs_B.firstStrip+fs_B.range,fs_A.firstStrip+fs_A.range-(fs_B.firstStrip+fs_B.range)));
482  }
483  }else{
484  tmp.push_back(*jt);
485  }
486  }
487  A=tmp;
488 }
unsigned short range
std::vector< unsigned int >::const_iterator ContainerIterator
unsigned short firstStrip
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
data decode(const unsigned int &value) const
void SiStripQuality::turnOffFeds ( const std::vector< int > &  fedsList,
const bool  turnOffStrips,
const bool  printDebug 
)
private

Loop on all the fedIds, take the fedChannels and then the detId. Depending on the value of a bool turn off or not the strips in the list.

Definition at line 752 of file SiStripQuality.cc.

References add(), SiStripFedCabling::connections(), SiStripBadStrip::encode(), SiStripDetCabling::fedCabling(), LogTrace, printDetInfo(), and SiStripDetCabling_.

Referenced by add().

753 {
754 
755  std::stringstream ss;
756  if( printDebug ) {
757  ss << "associated to detIds : " << std::endl;
758  }
759 
760  std::vector<int>::const_iterator fedIdIt = fedsList.begin();
761  for( ; fedIdIt != fedsList.end(); ++fedIdIt ) {
762  std::vector<FedChannelConnection>::const_iterator fedChIt = SiStripDetCabling_->fedCabling()->connections( *fedIdIt ).begin();
763  for( ; fedChIt != SiStripDetCabling_->fedCabling()->connections( *fedIdIt ).end(); ++fedChIt ) {
764  uint32_t detId = fedChIt->detId();
765  if (detId == 0 || detId == 0xFFFFFFFF) continue;
766  uint16_t apvPairNumber = fedChIt->apvPairNumber();
767 
768  if( printDebug ) {
769  printDetInfo(detId, apvPairNumber, ss);
770  }
771 
772  if( turnOffStrips ) {
773  // apvPairNumber == i it means that the i*256 strips are to be set off
774  std::vector<unsigned int> vect;
775  vect.push_back(encode(apvPairNumber*256,256));
776  SiStripBadStrip::Range Range(vect.begin(), vect.end());
777  add(detId,Range);
778  LogTrace("SiStripQuality") << "[addOffForRunInfo] adding apvPairNumber "<<apvPairNumber<<" for detId "<<detId<<" off according to RunInfo" << std::endl;
779  }
780  }
781  }
782  if( printDebug ) {
783  edm::LogInfo("SiStripQuality") << ss.str() << std::endl;
784  }
785 }
void printDetInfo(const uint32_t &detId, const uint32_t &apvPairNumber, std::stringstream &ss)
Prints debug output for a given detId.
void add(const uint32_t &, const SiStripBadStrip::Range &)
const SiStripDetCabling * SiStripDetCabling_
void printDebug(std::stringstream &ss) const
#define LogTrace(id)
const SiStripFedCabling * fedCabling() const
std::pair< ContainerIterator, ContainerIterator > Range
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const

Member Data Documentation

std::vector<BadComponent> SiStripQuality::BadComponentVect
private
edm::FileInPath SiStripQuality::FileInPath_
private

Definition at line 150 of file SiStripQuality.h.

Referenced by getFileInPath(), and SiStripQuality().

bool SiStripQuality::printDebug_
private

Definition at line 156 of file SiStripQuality.h.

Referenced by add(), setPrintDebugOutput(), and SiStripQuality().

SiStripDetInfoFileReader* SiStripQuality::reader
private
const SiStripDetCabling* SiStripQuality::SiStripDetCabling_
private
bool SiStripQuality::toCleanUp
private

Definition at line 149 of file SiStripQuality.h.

Referenced by cleanUp(), clear(), put_replace(), and SiStripQuality().

bool SiStripQuality::useEmptyRunInfo_
private

Definition at line 157 of file SiStripQuality.h.

Referenced by add(), setUseEmptyRunInfo(), and SiStripQuality().