CMS 3D CMS Logo

Classes | Public Member Functions | Protected Types | Protected Attributes | Static Protected Attributes | Friends

RPCLinkSynchroStat Class Reference

#include <RPCLinkSynchroStat.h>

List of all members.

Classes

struct  LessCountSum
struct  LessLinkName
class  LinkBoard
struct  ShortLinkInfo
class  SynchroCounts

Public Member Functions

void add (const RPCRawSynchro::ProdItem &counts, std::vector< LinkBoardElectronicIndex > &problems)
void add (const std::string &lbName, const unsigned int *hits)
std::string dumpDelays ()
void init (const RPCReadOutMapping *theCabling, bool addChamberInfo)
 RPCLinkSynchroStat (bool useFirstHitOnly)
virtual ~RPCLinkSynchroStat ()

Protected Types

typedef std::pair< LinkBoard,
SynchroCounts
BoardAndCounts

Protected Attributes

std::vector< BoardAndCountstheLinkStatMap
unsigned int theLinkStatNavi [MAXDCCINDEX+1][MAXRBCINDEX+1][MAXLINKINDEX+1][MAXLBINDEX+1]
bool theUseFirstHitOnly

Static Protected Attributes

static const unsigned int DCCINDEXSHIFT = 790
static const unsigned int MAXDCCINDEX = 2
static const unsigned int MAXLBINDEX = 2
static const unsigned int MAXLINKINDEX = 17
static const unsigned int MAXRBCINDEX = 35

Friends

class RPCLinkSynchroHistoMaker

Detailed Description

Definition at line 12 of file RPCLinkSynchroStat.h.


Member Typedef Documentation

Definition at line 69 of file RPCLinkSynchroStat.h.


Constructor & Destructor Documentation

RPCLinkSynchroStat::RPCLinkSynchroStat ( bool  useFirstHitOnly)

Definition at line 103 of file RPCLinkSynchroStat.cc.

References MAXDCCINDEX, MAXLBINDEX, MAXLINKINDEX, MAXRBCINDEX, theLinkStatMap, and theLinkStatNavi.

  : theUseFirstHitOnly(useFirstFitOnly)
{
  for (unsigned int i1=0; i1<=MAXDCCINDEX; ++i1) {
    for (unsigned int i2=0; i2<=MAXRBCINDEX; i2++) {
      for (unsigned int i3=0; i3 <=MAXLINKINDEX; ++i3) {
        for (unsigned int i4=0; i4<=MAXLBINDEX; ++i4) {
          theLinkStatNavi[i1][i2][i3][i4]=0;
        }
      }
    }
  }
  theLinkStatMap.push_back( std::make_pair(LinkBoard("Dummy"), SynchroCounts()) );
}
virtual RPCLinkSynchroStat::~RPCLinkSynchroStat ( ) [inline, virtual]

Definition at line 17 of file RPCLinkSynchroStat.h.

{}

Member Function Documentation

void RPCLinkSynchroStat::add ( const RPCRawSynchro::ProdItem counts,
std::vector< LinkBoardElectronicIndex > &  problems 
)

Definition at line 162 of file RPCLinkSynchroStat.cc.

References LinkBoardElectronicIndex::dccId, DCCINDEXSHIFT, LinkBoardElectronicIndex::dccInputChannelNum, if(), LinkBoardElectronicIndex::lbNumInLink, path(), EgammaValidation_cff::paths, LinkBoardElectronicIndex::tbLinkInputNum, theLinkStatMap, theLinkStatNavi, theUseFirstHitOnly, and v.

Referenced by RPCMonitorLinkSynchro::analyze().

{
  std::vector< int > hits(theLinkStatMap.size(),0);
  std::vector<ShortLinkInfo> slis;
  for ( RPCRawSynchro::ProdItem::const_iterator it = vItem.begin(); it != vItem.end(); ++it) {
    const LinkBoardElectronicIndex & path = it->first;
    unsigned int bxDiff = it->second;
    unsigned int eleCode = (path.dccId-DCCINDEXSHIFT)*100000 + path.dccInputChannelNum*1000 + path.tbLinkInputNum*10+path.lbNumInLink;
    unsigned int idx = theLinkStatNavi[path.dccId-DCCINDEXSHIFT][path.dccInputChannelNum][path.tbLinkInputNum][path.lbNumInLink];
    if  (hits[idx]==0) {
      ShortLinkInfo sli = { idx, std::vector<unsigned int>(1, eleCode), SynchroCounts() };
      slis.push_back( sli );
      hits[idx]=slis.size();
    } 
    else {
      std::vector<unsigned int> & v = slis[hits[idx]-1].hit_paths;
      std::vector<unsigned int>::iterator iv = lower_bound (v.begin(), v.end(), eleCode);
      if (iv == v.end() || (*iv) != eleCode) v.insert(iv,eleCode);
    } 
    slis[hits[idx]-1].counts.set(bxDiff); // ensure one count per LB per BX
  }

  for (std::vector<ShortLinkInfo>::const_iterator ic = slis.begin(); ic !=slis.end(); ++ic) {
    if (theUseFirstHitOnly) {
      theLinkStatMap[ic->idx].second.increment( ic->counts.firstHit() );  // first hit only  
    } else  {
      theLinkStatMap[ic->idx].second += ic->counts;
    }
    if (theLinkStatMap[ ic->idx].first.paths().size() != ic->hit_paths.size()) {
       const std::vector<LinkBoardElectronicIndex> & paths =  theLinkStatMap[ ic->idx].first.paths();
       problems.insert(problems.end(),paths.begin(),paths.end());
    }
  }

}
void RPCLinkSynchroStat::add ( const std::string &  lbName,
const unsigned int *  hits 
)

Definition at line 14 of file RPCLinkSynchroStat.cc.

References theLinkStatMap.

{
  LinkBoard lb(lbName);
  SynchroCounts counts(hits);
  for (std::vector<BoardAndCounts>::iterator it = theLinkStatMap.begin(); it != theLinkStatMap.end(); ++it)  if (it->first == lb) it->second += counts;
}
std::string RPCLinkSynchroStat::dumpDelays ( )

Definition at line 198 of file RPCLinkSynchroStat.cc.

References RPCLinkSynchroStat::LinkBoard::chamberAndPartitions(), spr::find(), LogTrace, python::multivaluedict::map(), RPCLinkSynchroStat::LinkBoard::name(), RPCLinkSynchroStat::LinkBoard::paths(), EgammaValidation_cff::paths, RPCLinkSynchroStat::SynchroCounts::print(), and theLinkStatMap.

Referenced by RPCMonitorLinkSynchro::endJob().

{
  std::ostringstream str;
  std::vector<BoardAndCounts> sortedStat = theLinkStatMap;
  stable_sort(sortedStat.begin(),sortedStat.end(),LessCountSum()); 
  for (unsigned int idx=0; idx<sortedStat.size(); ++idx) {
    const LinkBoard & board = sortedStat[idx].first;
    const SynchroCounts & counts = sortedStat[idx].second;

    // DUMP LINKNAME
    str << std::setw(20) << board.name();

    // DUMP COUNTS
    str <<" "<<counts.print();

    //PATHS
    str <<" paths: ";
    const std::vector<LinkBoardElectronicIndex> & paths=board.paths();
    for (std::vector<LinkBoardElectronicIndex>::const_iterator ip=paths.begin(); ip!=paths.end();++ip) 
      str<<"{"<<ip->dccId<<","<<std::setw(2)<<ip->dccInputChannelNum<<","<<std::setw(2)<<ip->tbLinkInputNum<<","<<ip->lbNumInLink<<"}";

    // DUMP CHAMBERS
    std::map<std::string,std::vector<std::string> > chMap;
    const std::vector<LinkBoard::ChamberAndPartition> & chamberAndPartitions = board.chamberAndPartitions();
    for (std::vector<LinkBoard::ChamberAndPartition>::const_iterator it=chamberAndPartitions.begin(); it!=chamberAndPartitions.end();++it) {
      std::vector<std::string> & partitions = chMap[it->first];
      if (find(partitions.begin(), partitions.end(), it->second) == partitions.end()) partitions.push_back(it->second);
    }
    str << " chambers: ";
    for (std::map<std::string,std::vector<std::string> >::const_iterator im=chMap.begin(); im != chMap.end(); ++im) {
      str <<im->first<<"(";
      for (std::vector<std::string>::const_iterator ip=im->second.begin(); ip != im->second.end(); ++ip) { str << *ip; if ((ip+1)!= (im->second.end()) ) str<<","; else str <<")"; }
    }

    
    str <<std::endl;
  }
  LogTrace("RPCLinkSynchroStat") <<"RPCLinkSynchroStat::dumpDelays,  SIZE OF LINKS IS: " << theLinkStatMap.size() << std::endl;
  return str.str();
}
void RPCLinkSynchroStat::init ( const RPCReadOutMapping theCabling,
bool  addChamberInfo 
)

Definition at line 118 of file RPCLinkSynchroStat.cc.

References DCCINDEXSHIFT, LinkBoardElectronicIndex::dccInputChannelNum, RPCReadOutMapping::dccList(), EgammaValidation_cff::paths, theLinkStatMap, and theLinkStatNavi.

Referenced by RPCMonitorLinkSynchro::beginRun().

{
  if (!theCabling) return;
  std::vector<const DccSpec*> dccs = theCabling->dccList();
  for (std::vector<const DccSpec*>::const_iterator it1= dccs.begin(); it1!= dccs.end(); ++it1) {
    const std::vector<TriggerBoardSpec> & rmbs = (*it1)->triggerBoards();
    for (std::vector<TriggerBoardSpec>::const_iterator it2 = rmbs.begin(); it2 != rmbs.end(); ++it2) {
      const  std::vector<LinkConnSpec> & links = it2->linkConns();
      for (std::vector<LinkConnSpec>::const_iterator it3 = links.begin(); it3 != links.end(); ++it3) {
        const  std::vector<LinkBoardSpec> & lbs = it3->linkBoards();
        for (std::vector<LinkBoardSpec>::const_iterator it4=lbs.begin(); it4 != lbs.end(); ++it4) {
          LinkBoardElectronicIndex ele = { (*it1)->id(), it2->dccInputChannelNum(), it3->triggerBoardInputNumber(), it4->linkBoardNumInLink()}; 
          LinkBoard linkBoard(it4->linkBoardName());
          BoardAndCounts candid = std::make_pair(linkBoard,SynchroCounts());              
          std::vector<BoardAndCounts>::iterator candid_place = lower_bound(theLinkStatMap.begin(), theLinkStatMap.end(), candid, LessLinkName());
          if (candid_place != theLinkStatMap.end() && candid.first == candid_place->first) {
            candid_place->first.add(ele);
          } 
          else {
            candid_place = theLinkStatMap.insert(candid_place,candid);
            candid_place->first.add(ele);
            if (addChamberInfo) {
            const  std::vector<FebConnectorSpec> & febs = it4->febs(); 
            for (std::vector<FebConnectorSpec>::const_iterator it5=febs.begin(); it5!= febs.end(); ++it5) {
              std::string chamberName = it5->chamber().chamberLocationName();
              std::string partitionName = it5->feb().localEtaPartitionName();
              LinkBoard::ChamberAndPartition chamberAndPartition = std::make_pair(chamberName, partitionName);
              candid_place->first.add(chamberAndPartition);
            }
            } 
          }
        }
      } 
    }
  }
  for (unsigned int idx=0; idx<theLinkStatMap.size(); ++idx) {
    const std::vector<LinkBoardElectronicIndex> &paths= theLinkStatMap[idx].first.paths();
    for  (std::vector<LinkBoardElectronicIndex>::const_iterator it=paths.begin(); it!= paths.end();++it) {
      theLinkStatNavi[it->dccId-DCCINDEXSHIFT][it->dccInputChannelNum][it->tbLinkInputNum][it->lbNumInLink]=idx;
    }
  }
//  LogTrace("RPCLinkSynchroStat") <<" SIZE OF LINKS IS: " << theLinkStatMap.size() << endl;
}

Friends And Related Function Documentation

friend class RPCLinkSynchroHistoMaker [friend]

Definition at line 84 of file RPCLinkSynchroStat.h.


Member Data Documentation

const unsigned int RPCLinkSynchroStat::DCCINDEXSHIFT = 790 [static, protected]

Definition at line 77 of file RPCLinkSynchroStat.h.

Referenced by add(), and init().

const unsigned int RPCLinkSynchroStat::MAXDCCINDEX = 2 [static, protected]

Definition at line 76 of file RPCLinkSynchroStat.h.

Referenced by RPCLinkSynchroStat().

const unsigned int RPCLinkSynchroStat::MAXLBINDEX = 2 [static, protected]

Definition at line 80 of file RPCLinkSynchroStat.h.

Referenced by RPCLinkSynchroStat().

const unsigned int RPCLinkSynchroStat::MAXLINKINDEX = 17 [static, protected]

Definition at line 79 of file RPCLinkSynchroStat.h.

Referenced by RPCLinkSynchroStat().

const unsigned int RPCLinkSynchroStat::MAXRBCINDEX = 35 [static, protected]

Definition at line 78 of file RPCLinkSynchroStat.h.

Referenced by RPCLinkSynchroStat().

Definition at line 81 of file RPCLinkSynchroStat.h.

Referenced by add(), init(), and RPCLinkSynchroStat().

Definition at line 74 of file RPCLinkSynchroStat.h.

Referenced by add().