CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
22  sistrip::PEDS_FULL_NOISE )
23 {
24  factory_ = auto_ptr<PedsFullNoiseSummaryFactory>( new PedsFullNoiseSummaryFactory );
26  << "[PedsFullNoiseHistograms::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[PedsFullNoiseHistograms::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[PedsFullNoiseHistograms::" << __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  << "[PedsFullNoiseHistograms::" << __func__ << "]"
64  << " Zero histograms found!";
65  continue;
66  }
67 
68  // Retrieve pointers to peds and noise histos
69  std::vector<TH1*> hists;
70  Histos::const_iterator ihis = iter->second.begin();
71  for ( ; ihis != iter->second.end(); ihis++ ) {
72  // pedestal profiles
73  TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
74  if ( prof ) { hists.push_back(prof); }
75  //@@ Common mode histos?...
76  //TH1F* his = ExtractTObject<TH1F>().extract( (*ihis)->me_ );
77  //if ( his ) { profs.push_back(his); }
78  // noise 2D histos
79  TH2S * his2D = ExtractTObject<TH2S>().extract( (*ihis)->me_ );
80  if ( his2D ) { hists.push_back(his2D); }
81  }
82 
83  // Perform histo analysis
84  PedsFullNoiseAnalysis * anal = new PedsFullNoiseAnalysis( iter->first );
85  PedsFullNoiseAlgorithm algo( this->pset(), anal );
86  algo.analysis( hists );
87  data()[iter->first] = anal;
88  if ( anal->isValid() ) { valid++; }
89  if ( !anal->getErrorCodes().empty() ) {
90  errors[anal->getErrorCodes()[0]]++;
91  }
92 
93  }
94 
95  if ( !histos().empty() ) {
97  << "[PedsFullNoiseHistograms::" << __func__ << "]"
98  << " Analyzed histograms for " << histos().size()
99  << " FED channels, of which " << valid
100  << " (" << 100 * valid / histos().size()
101  << "%) are valid.";
102  if ( !errors.empty() ) {
103  uint16_t count = 0;
104  std::stringstream ss;
105  ss << std::endl;
106  std::map<std::string,uint16_t>::const_iterator ii;
107  for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
108  ss << " " << ii->first << ": " << ii->second << std::endl;
109  count += ii->second;
110  }
112  << "[PedsFullNoiseHistograms::" << __func__ << "]"
113  << " Found " << count << " errors ("
114  << 100 * count / histos().size() << "%): "
115  << ss.str();
116  }
117  } else {
119  << "[PedsFullNoiseHistograms::" << __func__ << "]"
120  << " No histograms to analyze!";
121  }
122 
123 }
124 
125 // -----------------------------------------------------------------------------
128  Analyses::iterator ianal = data().begin();
129  Analyses::iterator janal = data().end();
130  for ( ; ianal != janal; ++ianal ) {
131  if ( ianal->second ) {
132  std::stringstream ss;
133  ianal->second->print( ss, 1 );
134  ianal->second->print( ss, 2 );
135  if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str();
136  } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
137  }
138  }
139 }
void analysis(const std::vector< TH1 * > &)
const edm::ParameterSet & pset() const
static const char mlDqmClient_[]
Histogram-based analysis for pedestal run.
int ii
Definition: cuy.py:588
Histogram-based analysis for pedestal run.
PedsFullNoiseHistograms(const edm::ParameterSet &pset, DQMStore *)
#define LogTrace(id)
int extract(std::vector< int > *output, const std::string &dati)
#define debug
Definition: HDRShower.cc:19
std::auto_ptr< Factory > factory_
#define begin
Definition: vmac.h:30
const VString & getErrorCodes() const
const HistosMap & histos() const