18 for (std::vector<BoardAndCounts>::iterator it =
theLinkStatMap.begin(); it !=
theLinkStatMap.end(); ++it)
if (it->first == lb) it->second += counts;
23 for (std::vector<ChamberAndPartition>::const_iterator it=theChamberAndPartitions.begin(); it != theChamberAndPartitions.end(); ++it) {
24 if( (*it)==
part)
return 1;
26 theChamberAndPartitions.push_back(part);
32 for (std::vector<LinkBoardElectronicIndex>::const_iterator it=theElePaths.begin(); it != theElePaths.end(); ++it) {
33 if ( it->dccId == ele.
dccId 38 theElePaths.push_back(ele);
44 for (
unsigned int i=0;
i <8 ; ++
i)
if(theCounts[
i])
return i;
50 if (bxDiff < 8) theCounts[bxDiff]=1;
55 if (bxDiff < 8) theCounts[bxDiff]++;
65 {
unsigned int result = 0;
for (
unsigned int i=0;
i<8; ++
i) result += theCounts[
i];
return result; }
68 {
double result = 0.;
for (
unsigned int i=0;
i<8; ++
i) result +=
i*theCounts[
i];
return result; }
71 {
unsigned int sum = mom0();
return sum==0 ? 0. : mom1()/sum; }
77 if (sum==0)
return 0.;
78 double mean = mom1()/sum;
79 for (
int i=0;
i<8; ++
i) result += theCounts[
i]*(mean-
i)*(mean-
i);
86 std::ostringstream
str;
87 str<<
" mean: "<<std::setw(8)<<
mean();
88 str<<
" rms: "<<std::setw(8)<<
rms();
89 str<<
" counts:";
for (
int i=0;
i<8; ++
i) str<<
" "<<std::setw(4)<<theCounts[
i];
109 for (
unsigned int i4=0; i4<=
MAXLBINDEX; ++i4) {
120 if (!theCabling)
return;
121 std::vector<const DccSpec*> dccs = theCabling->
dccList();
122 for (std::vector<const DccSpec*>::const_iterator it1= dccs.begin(); it1!= dccs.end(); ++it1) {
123 const std::vector<TriggerBoardSpec> & rmbs = (*it1)->triggerBoards();
124 for (std::vector<TriggerBoardSpec>::const_iterator it2 = rmbs.begin(); it2 != rmbs.end(); ++it2) {
125 const std::vector<LinkConnSpec> & links = it2->linkConns();
126 for (std::vector<LinkConnSpec>::const_iterator it3 = links.begin(); it3 != links.end(); ++it3) {
127 const std::vector<LinkBoardSpec> & lbs = it3->linkBoards();
128 for (std::vector<LinkBoardSpec>::const_iterator it4=lbs.begin(); it4 != lbs.end(); ++it4) {
130 LinkBoard linkBoard(it4->linkBoardName());
133 if (candid_place !=
theLinkStatMap.end() && candid.first == candid_place->first) {
134 candid_place->first.add(ele);
138 candid_place->first.add(ele);
139 if (addChamberInfo) {
140 const std::vector<FebConnectorSpec> & febs = it4->febs();
141 for (std::vector<FebConnectorSpec>::const_iterator it5=febs.begin(); it5!= febs.end(); ++it5) {
142 std::string chamberName = it5->chamber().chamberLocationName();
143 std::string partitionName = it5->feb().localEtaPartitionName();
145 candid_place->first.add(chamberAndPartition);
154 const std::vector<LinkBoardElectronicIndex> &paths=
theLinkStatMap[
idx].first.paths();
155 for (std::vector<LinkBoardElectronicIndex>::const_iterator it=paths.begin(); it!= paths.end();++it) {
165 std::vector<ShortLinkInfo> slis;
166 for ( RPCRawSynchro::ProdItem::const_iterator it = vItem.begin(); it != vItem.end(); ++it) {
168 unsigned int bxDiff = it->second;
173 slis.push_back( sli );
177 std::vector<unsigned int> &
v = slis[
hits[
idx]-1].hit_paths;
178 std::vector<unsigned int>::iterator iv =
lower_bound (v.begin(), v.end(), eleCode);
179 if (iv == v.end() || (*iv) != eleCode) v.insert(iv,eleCode);
181 slis[
hits[
idx]-1].counts.set(bxDiff);
184 for (std::vector<ShortLinkInfo>::const_iterator ic = slis.begin(); ic !=slis.end(); ++ic) {
186 theLinkStatMap[ic->idx].second.increment( ic->counts.firstHit() );
190 if (
theLinkStatMap[ ic->idx].first.paths().size() != ic->hit_paths.size()) {
191 const std::vector<LinkBoardElectronicIndex> & paths =
theLinkStatMap[ ic->idx].first.paths();
192 problems.insert(problems.end(),paths.begin(),paths.end());
200 std::ostringstream
str;
202 stable_sort(sortedStat.begin(),sortedStat.end(),
LessCountSum());
203 for (
unsigned int idx=0;
idx<sortedStat.size(); ++
idx) {
208 str << std::setw(20) << board.
name();
211 str <<
" "<<counts.
print();
215 const std::vector<LinkBoardElectronicIndex> & paths=board.
paths();
216 for (std::vector<LinkBoardElectronicIndex>::const_iterator ip=paths.begin(); ip!=paths.end();++ip)
217 str<<
"{"<<ip->dccId<<
","<<std::setw(2)<<ip->dccInputChannelNum<<
","<<std::setw(2)<<ip->tbLinkInputNum<<
","<<ip->lbNumInLink<<
"}";
220 std::map<std::string,std::vector<std::string> > chMap;
221 const std::vector<LinkBoard::ChamberAndPartition> & chamberAndPartitions = board.
chamberAndPartitions();
222 for (std::vector<LinkBoard::ChamberAndPartition>::const_iterator it=chamberAndPartitions.begin(); it!=chamberAndPartitions.end();++it) {
223 std::vector<std::string> &
partitions = chMap[it->first];
224 if (
find(partitions.begin(), partitions.end(), it->second) == partitions.end()) partitions.push_back(it->second);
226 str <<
" chambers: ";
227 for (
std::map<
std::string,std::vector<std::string> >::const_iterator im=chMap.begin(); im != chMap.end(); ++im) {
228 str <<im->first<<
"(";
229 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 <<
")"; }
235 LogTrace(
"RPCLinkSynchroStat") <<
"RPCLinkSynchroStat::dumpDelays, SIZE OF LINKS IS: " <<
theLinkStatMap.size() << std::endl;
bool operator()(const BoardAndCounts &o1, const BoardAndCounts &o2)
void init(const RPCReadOutMapping *theCabling, bool addChamberInfo)
bool operator()(const BoardAndCounts &o1, const BoardAndCounts &o2)
unsigned int theLinkStatNavi[MAXDCCINDEX+1][MAXRBCINDEX+1][MAXLINKINDEX+1][MAXLBINDEX+1]
unsigned int firstHit() const
static const unsigned int MAXLINKINDEX
void increment(unsigned int bxDiff)
std::vector< const DccSpec * > dccList() const
all FEDs in map
static const unsigned int MAXLBINDEX
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned int mom0() const
const std::vector< ChamberAndPartition > & chamberAndPartitions() const
std::pair< LinkBoard, SynchroCounts > BoardAndCounts
RPCLinkSynchroStat(bool useFirstHitOnly)
SynchroCounts & operator+=(const SynchroCounts &rhs)
const std::vector< LinkBoardElectronicIndex > & paths() const
std::vector< std::pair< LinkBoardElectronicIndex, int > > ProdItem
static const unsigned int MAXRBCINDEX
void set(unsigned int bxDiff)
std::pair< std::string, std::string > ChamberAndPartition
static const unsigned int DCCINDEXSHIFT
std::string print() const
void add(const RPCRawSynchro::ProdItem &counts, std::vector< LinkBoardElectronicIndex > &problems)
static const unsigned int MAXDCCINDEX
int add(const ChamberAndPartition &part)
bool operator==(const SynchroCounts &) const
const std::string & name() const
std::vector< unsigned int > theCounts
std::vector< BoardAndCounts > theLinkStatMap