CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastFedCablingHistograms.cc
Go to the documentation of this file.
8 #include "TProfile.h"
9 #include <iostream>
10 #include <sstream>
11 #include <iomanip>
12 
13 using namespace std;
14 using namespace sistrip;
15 
16 // -----------------------------------------------------------------------------
19  DQMStore* bei )
20  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("FastFedCablingParameters"),
21  bei,
22  sistrip::FAST_CABLING )
23 {
24  factory_ = auto_ptr<FastFedCablingSummaryFactory>( new FastFedCablingSummaryFactory );
26  << "[FastFedCablingHistograms::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[FastFedCablingHistograms::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[FastFedCablingHistograms::" << __func__ << "]";
43 
44  // Some initialisation
45  uint16_t valid = 0;
46  HistosMap::const_iterator iter;
47  Analyses::iterator ianal;
48  std::map<std::string,uint16_t> errors;
49 
50  // Clear map holding analysis objects
51  for ( ianal = data().begin(); ianal != data().end(); ianal++ ) {
52  if ( ianal->second ) { delete ianal->second; }
53  }
54  data().clear();
55 
56  // Iterate through map containing histograms
57  for ( iter = histos().begin();
58  iter != histos().end(); iter++ ) {
59 
60  // Check vector of histos is not empty
61  if ( iter->second.empty() ) {
63  << "[FastFedCablingHistograms::" << __func__ << "]"
64  << " Zero histograms found!";
65  continue;
66  }
67 
68  // Retrieve pointers to histos
69  std::vector<TH1*> profs;
70  Histos::const_iterator ihis = iter->second.begin();
71  for ( ; ihis != iter->second.end(); ihis++ ) {
72  TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
73  if ( prof ) { profs.push_back(prof); }
74  }
75 
76  // Perform histo analysis
77  FastFedCablingAnalysis* anal = new FastFedCablingAnalysis( iter->first );
78  FastFedCablingAlgorithm algo( this->pset(), anal );
79  FedToFecMap::const_iterator ifed = mapping().find( iter->first );
80  if ( ifed != mapping().end() ) { anal->fecKey( ifed->second ); }
81  algo.analysis( profs );
82  data()[iter->first] = anal;
83  if ( anal->isValid() ) { valid++; }
84  if ( !anal->getErrorCodes().empty() ) {
85  errors[anal->getErrorCodes()[0]]++;
86  }
87 
88  }
89 
90  if ( !histos().empty() ) {
92  << "[FastFedCablingHistograms::" << __func__ << "]"
93  << " Analyzed histograms for " << histos().size()
94  << " FED channels, of which " << valid
95  << " (" << 100 * valid / histos().size()
96  << "%) are valid.";
97  if ( !errors.empty() ) {
98  uint16_t count = 0;
99  std::stringstream ss;
100  ss << std::endl;
101  std::map<std::string,uint16_t>::const_iterator ii;
102  for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
103  ss << " " << ii->first << ": " << ii->second << std::endl;
104  count += ii->second;
105  }
107  << "[FastFedCablingHistograms::" << __func__ << "]"
108  << " Found " << count << " error strings: "
109  << ss.str();
110  }
111  } else {
113  << "[FastFedCablingHistograms::" << __func__ << "]"
114  << " No histograms to analyze!";
115  }
116 
117 }
118 
119 // -----------------------------------------------------------------------------
122  Analyses::iterator ianal = data().begin();
123  Analyses::iterator janal = data().end();
124  for ( ; ianal != janal; ++ianal ) {
125 
126  FastFedCablingAnalysis* anal = dynamic_cast<FastFedCablingAnalysis*>( ianal->second );
127  if ( !anal ) {
129  << "[FastFedCablingHistograms::" << __func__ << "]"
130  << " NULL pointer to analysis object!";
131  continue;
132  }
133 
134  std::stringstream ss;
135  anal->print( ss );
136  if ( anal->isValid() &&
137  !(anal->isDirty()) &&
138  !(anal->badTrimDac()) ) { LogTrace(mlDqmClient_) << ss.str();
139  } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
140 
141  }
142 
143 }
144 
145 // -----------------------------------------------------------------------------
148 
149  std::stringstream good;
150  std::stringstream bad;
151 
152  Analyses::iterator ianal = data().begin();
153  Analyses::iterator janal = data().end();
154  for ( ; ianal != janal; ++ianal ) {
155 
156  FastFedCablingAnalysis* anal = dynamic_cast<FastFedCablingAnalysis*>( ianal->second );
157  if ( !anal ) {
159  << "[FastFedCablingHistograms::" << __func__ << "]"
160  << " NULL pointer to analysis object!";
161  continue;
162  }
163 
164  if ( anal->isValid() &&
165  !(anal->isDirty()) &&
166  !(anal->badTrimDac()) ) {
167  anal->summary( good );
168  } else { anal->summary( bad ); }
169 
170  }
171 
172  if ( good.str().empty() ) { good << "None found!"; }
174  << "[FastFedCablingHistograms::" << __func__ << "]"
175  << " Printing summary of good analyses:" << "\n"
176  << good.str();
177 
178  if ( bad.str().empty() ) { return; } //@@ bad << "None found!"; }
180  << "[FastFedCablingHistograms::" << __func__ << "]"
181  << " Printing summary of bad analyses:" << "\n"
182  << bad.str();
183 
184 }
void analysis(const std::vector< TH1 * > &)
void summary(std::stringstream &) const
const FedToFecMap & mapping() const
const edm::ParameterSet & pset() const
static const char mlDqmClient_[]
int bad(Items const &cont)
Histogram-based analysis for connection loop.
Histogram-based analysis for connection loop.
void print(std::stringstream &, uint32_t not_used=0)
const uint32_t & fecKey() const
#define end
Definition: vmac.h:38
#define LogTrace(id)
int extract(std::vector< int > *output, const std::string &dati)
std::auto_ptr< Factory > factory_
#define begin
Definition: vmac.h:31
LimitAlgo * algo
Definition: Combine.cc:60
FastFedCablingHistograms(const edm::ParameterSet &pset, DQMStore *)
#define debug
Definition: MEtoEDMFormat.h:34
const VString & getErrorCodes() const
const HistosMap & histos() const