CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OptoScanHistograms.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>("OptoScanParameters"),
21  bei,
22  sistrip::OPTO_SCAN )
23 {
24  factory_ = auto_ptr<OptoScanSummaryFactory>( new OptoScanSummaryFactory );
26  << "[OptoScanHistograms::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[OptoScanHistograms::" << __func__ << "]"
35  << " Denstructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[OptoScanHistograms::" << __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  << "[OptoScanHistograms::" << __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  OptoScanAnalysis* anal = new OptoScanAnalysis( iter->first );
78  OptoScanAlgorithm 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  << "[OptoScanHistograms::" << __func__ << "]"
91  << " Analyzed histograms for " << histos().size()
92  << " FED channels, of which " << valid
93  << " (" << 100 * valid / histos().size()
94  << "%) are valid.";
95  } else {
97  << "[OptoScanHistograms::" << __func__ << "]"
98  << " No histograms to analyze!";
99  }
100 
101  if ( !histos().empty() ) {
103  << "[OptoScanHistograms::" << __func__ << "]"
104  << " Analyzed histograms for " << histos().size()
105  << " FED channels, of which " << valid
106  << " (" << 100 * valid / histos().size()
107  << "%) are valid.";
108  if ( !errors.empty() ) {
109  uint16_t count = 0;
110  std::stringstream ss;
111  ss << std::endl;
112  std::map<std::string,uint16_t>::const_iterator ii;
113  for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
114  ss << " " << ii->first << ": " << ii->second << std::endl;
115  count += ii->second;
116  }
118  << "[OptoScanHistograms::" << __func__ << "]"
119  << " Found " << count << " errors ("
120  << 100 * count / histos().size() << "%): "
121  << ss.str();
122  }
123  } else {
125  << "[OptoScanHistograms::" << __func__ << "]"
126  << " No histograms to analyze!";
127  }
128 
129 }
130 
131 // -----------------------------------------------------------------------------
134  Analyses::iterator ianal = data().begin();
135  Analyses::iterator janal = data().end();
136  for ( ; ianal != janal; ++ianal ) {
137  if ( ianal->second ) {
138  std::stringstream ss;
139  if ( ianal->second->isValid() ) {
140  ianal->second->print( ss );
141  LogTrace(mlDqmClient_) << ss.str();
142  } else {
143  ianal->second->print( ss, 0 );
144  ianal->second->print( ss, 1 );
145  ianal->second->print( ss, 2 );
146  ianal->second->print( ss, 3 );
147  edm::LogWarning(mlDqmClient_) << ss.str();
148  }
149  }
150  }
151 }
152 
Histogram-based analysis for opto bias/gain scan.
void analysis(const std::vector< TH1 * > &)
bool isValid() const
const edm::ParameterSet & pset() const
OptoScanHistograms(const edm::ParameterSet &pset, DQMStore *)
static const char mlDqmClient_[]
#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
#define debug
Definition: MEtoEDMFormat.h:34
const VString & getErrorCodes() const
void histoAnalysis(bool debug)
const HistosMap & histos() const