CMS 3D CMS Logo

PedsFullNoiseHistograms.cc
Go to the documentation of this file.
8 #include <iostream>
9 #include <sstream>
10 #include <iomanip>
11 #include "TProfile.h"
12 
13 using namespace std;
14 using namespace sistrip;
15 
16 // -----------------------------------------------------------------------------
19  DQMStore* bei )
20  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("PedsFullNoiseParameters"),
21  bei,
23 {
24 
25  factory_ = unique_ptr<PedsFullNoiseSummaryFactory>( new PedsFullNoiseSummaryFactory );
27  << "[PedsFullNoiseHistograms::" << __func__ << "]"
28  << " Constructing object...";
29 }
30 
31 // -----------------------------------------------------------------------------
35  << "[PedsFullNoiseHistograms::" << __func__ << "]"
36  << " Destructing object...";
37 }
38 
39 // -----------------------------------------------------------------------------
42 
44  << "[PedsFullNoiseHistograms::" << __func__ << "]";
45 
46  // Some initialisation
47  uint16_t valid = 0;
48  HistosMap::const_iterator iter;
49  Analyses::iterator ianal;
50  std::map<std::string,uint16_t> errors;
51 
52  // Clear map holding analysis objects
53  for ( ianal = data().begin(); ianal != data().end(); ianal++ ) {
54  if ( ianal->second ) { delete ianal->second; }
55  }
56  data().clear();
57 
58  // Iterate through map containing histograms
59  long int ichannel = 0;
60  long int nchannel = histos().size();
61  for ( iter = histos().begin();
62  iter != histos().end(); iter++ ) {
63 
64  // Check vector of histos is not empty
65  if ( iter->second.empty() ) {
67  << "[PedsFullNoiseHistograms::" << __func__ << "]"
68  << " Zero histograms found!";
69  continue;
70  }
71 
72  // Retrieve pointers to peds and noise histos
73  std::vector<TH1*> hists;
74  Histos::const_iterator ihis = iter->second.begin();
75 
76  for ( ; ihis != iter->second.end(); ihis++ ) {
77  // pedestal and noise 1D profiles
78  TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
79  if ( prof ) { hists.push_back(prof);
80  }
81  // 2D noise histograms
82  TH2S * his2D = ExtractTObject<TH2S>().extract( (*ihis)->me_ );
83  if ( his2D ) {
84  hists.push_back(his2D); }
85  }
86 
87  if(ichannel % 100 == 0)
89  << "[PedsFullNoiseHistograms::" << __func__ << "]"
90  << " Analyzing channel " << ichannel << " out of "<<nchannel;
91  ichannel++;
92 
93  // Perform histo analysis
94  PedsFullNoiseAnalysis * anal = new PedsFullNoiseAnalysis( iter->first );
95  PedsFullNoiseAlgorithm algo( this->pset(), anal );
96  algo.analysis( hists );
97 
98  data()[iter->first] = anal;
99  if (anal->isValid() ) { valid++; }
100  if (!anal->getErrorCodes().empty() ) {
101  errors[anal->getErrorCodes()[0]]++;
102  }
103 
104  }
105 
106  if ( !histos().empty() ) {
108  << "[PedsFullNoiseHistograms::" << __func__ << "]"
109  << " Analyzed histograms for " << histos().size()
110  << " FED channels, of which " << valid
111  << " (" << 100 * valid / histos().size()
112  << "%) are valid.";
113  if ( !errors.empty() ) {
114  uint16_t count = 0;
115  std::stringstream ss;
116  ss << std::endl;
117  std::map<std::string,uint16_t>::const_iterator ii;
118  for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
119  ss << " " << ii->first << ": " << ii->second << std::endl;
120  count += ii->second;
121  }
123  << "[PedsFullNoiseHistograms::" << __func__ << "]"
124  << " Found " << count << " errors ("
125  << 100 * count / histos().size() << "%): "
126  << ss.str();
127  }
128  } else {
130  << "[PedsFullNoiseHistograms::" << __func__ << "]"
131  << " No histograms to analyze!";
132  }
133 
134 }
135 
136 // -----------------------------------------------------------------------------
139  Analyses::iterator ianal = data().begin();
140  Analyses::iterator janal = data().end();
141  for ( ; ianal != janal; ++ianal ) {
142  if ( ianal->second ) {
143  std::stringstream ss;
144  ianal->second->print( ss, 1 );
145  ianal->second->print( ss, 2 );
146  if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str();
147  } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
148  }
149  }
150 }
void analysis(const std::vector< TH1 * > &)
Analyses & data(bool getMaskedData=false)
const edm::ParameterSet & pset() const
static const char mlDqmClient_[]
Histogram-based analysis for pedestal run.
sistrip classes
Histogram-based analysis for pedestal run.
PedsFullNoiseHistograms(const edm::ParameterSet &pset, DQMStore *)
#define LogTrace(id)
ii
Definition: cuy.py:590
int extract(std::vector< int > *output, const std::string &dati)
#define debug
Definition: HDRShower.cc:19
std::unique_ptr< Factory > factory_
#define begin
Definition: vmac.h:32
HLT enums.
const VString & getErrorCodes() const
bool isValid() const override
const HistosMap & histos() const
void histoAnalysis(bool debug) override