CMS 3D CMS Logo

VpspScanHistograms.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>("VpspScanParameters"),
21  bei,
23 {
24  factory_ = auto_ptr<VpspScanSummaryFactory>( new VpspScanSummaryFactory );
26  << "[VpspScanHistograms::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[VpspScanHistograms::" << __func__ << "]"
35  << " Denstructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[VpspScanHistograms::" << __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  << "[VpspScanHistograms::" << __func__ << "]"
64  << " Zero histograms found!" << endl;
65  continue;
66  }
67 
68  // Retrieve pointers to profile histos for this FED channel
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  VpspScanAnalysis* anal = new VpspScanAnalysis( iter->first );
78  VpspScanAlgorithm algo( this->pset(), anal );
79  algo.analysis( profs );
80  data()[iter->first] = anal;
81  if ( anal->isValid() ) { valid++; }
82  if ( !anal->getErrorCodes().empty() ) {
83  errors[anal->getErrorCodes()[0]]++;
84  }
85 
86  }
87 
88  if ( !histos().empty() ) {
90  << "[VpspScanHistograms::" << __func__ << "]"
91  << " Analyzed histograms for " << histos().size()
92  << " FED channels, of which " << valid
93  << " (" << 100 * valid / histos().size()
94  << "%) are valid.";
95  if ( !errors.empty() ) {
96  uint16_t count = 0;
97  std::stringstream ss;
98  ss << std::endl;
99  std::map<std::string,uint16_t>::const_iterator ii;
100  for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
101  ss << " " << ii->first << ": " << ii->second << std::endl;
102  count += ii->second;
103  }
105  << "[VpspScanHistograms::" << __func__ << "]"
106  << " Found " << count << " errors ("
107  << 100 * count / histos().size() << "%): "
108  << ss.str();
109  }
110  } else {
112  << "[VpspScanHistograms::" << __func__ << "]"
113  << " No histograms to analyze!";
114  }
115 
116 }
117 
118 // -----------------------------------------------------------------------------
121  Analyses::iterator ianal = data().begin();
122  Analyses::iterator janal = data().end();
123  for ( ; ianal != janal; ++ianal ) {
124  if ( ianal->second ) {
125  std::stringstream ss;
126  ianal->second->print( ss, 1 );
127  ianal->second->print( ss, 2 );
128  if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str();
129  } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
130  }
131  }
132 }
void analysis(const std::vector< TH1 * > &)
const edm::ParameterSet & pset() const
void histoAnalysis(bool debug)
static const char mlDqmClient_[]
sistrip classes
#define LogTrace(id)
ii
Definition: cuy.py:588
Histogram-based analysis for VPSP scan.
int extract(std::vector< int > *output, const std::string &dati)
#define debug
Definition: HDRShower.cc:19
Histogram-based analysis for VPSP scan.
std::auto_ptr< Factory > factory_
#define begin
Definition: vmac.h:30
HLT enums.
bool isValid() const
VpspScanHistograms(const edm::ParameterSet &pset, DQMStore *)
const VString & getErrorCodes() const
const HistosMap & histos() const