Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:32

0001 #include "DQM/SiStripCommissioningClients/interface/SamplingHistograms.h"
0002 #include "CondFormats/SiStripObjects/interface/SamplingAnalysis.h"
0003 #include "DQM/SiStripCommissioningAnalysis/interface/SamplingAlgorithm.h"
0004 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
0005 #include "DQM/SiStripCommon/interface/ExtractTObject.h"
0006 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0007 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include <iostream>
0010 #include <memory>
0011 
0012 #include <sstream>
0013 #include <iomanip>
0014 #include "TProfile.h"
0015 
0016 using namespace std;
0017 using namespace sistrip;
0018 
0019 // -----------------------------------------------------------------------------
0020 /** */
0021 SamplingHistograms::SamplingHistograms(const edm::ParameterSet& pset, DQMStore* bei, const sistrip::RunType& task)
0022     : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("SamplingParameters"), bei, task), sOnCut_(3) {
0023   LogTrace(mlDqmClient_) << "[SamplingHistograms::" << __func__ << "]"
0024                          << " Constructing object...";
0025   factory_ = std::make_unique<SamplingSummaryFactory>();
0026   // retreive the latency code from the root file
0027   std::string dataPath = std::string(sistrip::collate_) + "/" + sistrip::root_ + "/latencyCode";
0028   MonitorElement* codeElement = bei->get(dataPath);
0029   if (codeElement)
0030     latencyCode_ = codeElement->getIntValue();
0031   else
0032     latencyCode_ = 0;
0033 }
0034 
0035 // -----------------------------------------------------------------------------
0036 /** */
0037 SamplingHistograms::~SamplingHistograms() {
0038   LogTrace(mlDqmClient_) << "[SamplingHistograms::" << __func__ << "]"
0039                          << " Deleting object...";
0040 }
0041 
0042 // -----------------------------------------------------------------------------
0043 /** */
0044 void SamplingHistograms::histoAnalysis(bool debug) {
0045   // Clear map holding analysis objects
0046   Analyses::iterator ianal;
0047   for (ianal = data().begin(); ianal != data().end(); ianal++) {
0048     if (ianal->second) {
0049       delete ianal->second;
0050     }
0051   }
0052   data().clear();
0053 
0054   // Iterate through map containing vectors of profile histograms
0055   HistosMap::const_iterator iter = histos().begin();
0056   for (; iter != histos().end(); iter++) {
0057     // Check vector of histos is not empty (should be 1 histo)
0058     if (iter->second.empty()) {
0059       edm::LogWarning(mlDqmClient_) << "[SamplingHistograms::" << __func__ << "]"
0060                                     << " Zero collation histograms found!";
0061       continue;
0062     }
0063 
0064     // Retrieve pointers to profile histos for this FED channel
0065     vector<TH1*> profs;
0066     Histos::const_iterator ihis = iter->second.begin();
0067     for (; ihis != iter->second.end(); ihis++) {
0068       TProfile* prof = ExtractTObject<TProfile>().extract((*ihis)->me_);
0069       if (prof) {
0070         profs.push_back(prof);
0071       }
0072     }
0073 
0074     // Perform histo analysis
0075     SamplingAnalysis* anal = new SamplingAnalysis(iter->first);
0076     anal->setSoNcut(sOnCut_);
0077     SamplingAlgorithm algo(this->pset(), anal, latencyCode_);
0078     algo.analysis(profs);
0079     data()[iter->first] = anal;
0080   }
0081 }
0082 
0083 void SamplingHistograms::configure(const edm::ParameterSet& pset, const edm::EventSetup&) {
0084   //TODO: should use the parameter set. Why is this crashing ???
0085   //  sOnCut_ = pset.getParameter<double>("SignalToNoiseCut");
0086   sOnCut_ = 3.;
0087 }