12 return o1.first < o2.first;
15 return o1.second.sum() < o2.second.sum();
27 for (
auto it = theChamberAndPartitions.begin(); it != theChamberAndPartitions.end(); ++it) {
31 theChamberAndPartitions.push_back(part);
36 for (
auto it = theElePaths.begin(); it != theElePaths.end(); ++it) {
41 theElePaths.push_back(ele);
46 for (
unsigned int i = 0;
i < 8; ++
i)
54 theCounts[bxDiff] = 1;
63 for (
unsigned int i = 0;
i < 8; ++
i)
70 for (
unsigned int i = 0;
i < 8; ++
i)
71 result += theCounts[
i];
77 for (
unsigned int i = 0;
i < 8; ++
i)
78 result +=
i * theCounts[
i];
83 unsigned int sum = mom0();
84 return sum == 0 ? 0. : mom1() / sum;
92 double mean = mom1() / sum;
93 for (
int i = 0;
i < 8; ++
i)
94 result += theCounts[
i] * (mean -
i) * (mean -
i);
100 std::ostringstream
str;
101 str <<
" mean: " << std::setw(8) <<
mean();
102 str <<
" rms: " << std::setw(8) <<
rms();
104 for (
int i = 0;
i < 8; ++
i)
105 str <<
" " << std::setw(4) << theCounts[
i];
110 for (
unsigned int idx = 0; idx < 8; ++idx)
117 for (
unsigned int i1 = 0; i1 <=
MAXDCCINDEX; ++i1) {
118 for (
unsigned int i2 = 0; i2 <=
MAXRBCINDEX; i2++) {
120 for (
unsigned int i4 = 0; i4 <=
MAXLBINDEX; ++i4) {
132 std::vector<const DccSpec*> dccs = theCabling->
dccList();
133 for (
auto it1 = dccs.begin(); it1 != dccs.end(); ++it1) {
134 const std::vector<TriggerBoardSpec>& rmbs = (*it1)->triggerBoards();
135 for (
auto it2 = rmbs.begin(); it2 != rmbs.end(); ++it2) {
136 const std::vector<LinkConnSpec>&
links = it2->linkConns();
137 for (
auto it3 = links.begin(); it3 != links.end(); ++it3) {
138 const std::vector<LinkBoardSpec>& lbs = it3->linkBoards();
139 for (
auto it4 = lbs.begin(); it4 != lbs.end(); ++it4) {
141 (*it1)->id(), it2->
dccInputChannelNum(), it3->triggerBoardInputNumber(), it4->linkBoardNumInLink()};
142 LinkBoard linkBoard(it4->linkBoardName());
144 std::vector<BoardAndCounts>::iterator candid_place =
146 if (candid_place !=
theLinkStatMap.end() && candid.first == candid_place->first) {
147 candid_place->first.add(ele);
150 candid_place->first.add(ele);
151 if (addChamberInfo) {
152 const std::vector<FebConnectorSpec>& febs = it4->febs();
153 for (std::vector<FebConnectorSpec>::const_iterator it5 = febs.begin(); it5 != febs.end(); ++it5) {
154 std::string chamberName = it5->chamber().chamberLocationName();
155 std::string partitionName = it5->feb().localEtaPartitionName();
157 candid_place->first.add(chamberAndPartition);
167 for (
auto it = paths.begin(); it != paths.end(); ++it) {
176 std::vector<ShortLinkInfo> slis;
177 for (
auto it = vItem.begin(); it != vItem.end(); ++it) {
179 unsigned int bxDiff = it->second;
184 if (hits[idx] == 0) {
187 hits[idx] = slis.size();
189 std::vector<unsigned int>&
v = slis[hits[idx] - 1].hit_paths;
190 std::vector<unsigned int>::iterator
iv =
lower_bound(v.begin(), v.end(), eleCode);
191 if (iv == v.end() || (*iv) != eleCode)
192 v.insert(iv, eleCode);
194 slis[hits[idx] - 1].counts.set(bxDiff);
197 for (
auto ic = slis.begin(); ic != slis.end(); ++ic) {
203 if (
theLinkStatMap[ic->idx].first.paths().size() != ic->hit_paths.size()) {
204 const std::vector<LinkBoardElectronicIndex>&
paths =
theLinkStatMap[ic->idx].first.paths();
205 problems.insert(problems.end(), paths.begin(), paths.end());
211 std::ostringstream
str;
213 stable_sort(sortedStat.begin(), sortedStat.end(),
LessCountSum());
214 for (
unsigned int idx = 0; idx < sortedStat.size(); ++idx) {
215 const LinkBoard& board = sortedStat[idx].first;
219 str << std::setw(20) << board.
name();
222 str <<
" " << counts.
print();
226 const std::vector<LinkBoardElectronicIndex>&
paths = board.
paths();
227 for (
auto ip = paths.begin(); ip != paths.end(); ++ip)
228 str <<
"{" << ip->dccId <<
"," << std::setw(2) << ip->dccInputChannelNum <<
"," << std::setw(2)
229 << ip->tbLinkInputNum <<
"," << ip->lbNumInLink <<
"}";
232 std::map<std::string, std::vector<std::string> > chMap;
233 const std::vector<LinkBoard::ChamberAndPartition>& chamberAndPartitions = board.
chamberAndPartitions();
234 for (
auto it = chamberAndPartitions.begin(); it != chamberAndPartitions.end(); ++it) {
235 std::vector<std::string>&
partitions = chMap[it->first];
236 if (
find(partitions.begin(), partitions.end(), it->second) == partitions.end())
237 partitions.push_back(it->second);
239 str <<
" chambers: ";
240 for (
auto im = chMap.begin(); im != chMap.end(); ++im) {
241 str << im->first <<
"(";
242 for (std::vector<std::string>::const_iterator ip = im->second.begin(); ip != im->second.end(); ++ip) {
244 if ((ip + 1) != (im->second.end()))
253 LogTrace(
"RPCLinkSynchroStat") <<
"RPCLinkSynchroStat::dumpDelays, SIZE OF LINKS IS: " <<
theLinkStatMap.size()
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]
std::pair< std::string, std::string > ChamberAndPartition
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
if(conf_.getParameter< bool >("UseStripCablingDB"))
void set(unsigned int bxDiff)
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)
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
bool operator==(const SynchroCounts &) const
const std::string & name() const
std::vector< unsigned int > theCounts
std::vector< BoardAndCounts > theLinkStatMap