23 #include <boost/cstdint.hpp> 28 #include <sys/types.h> 41 outputFileName_( pset.getUntrackedParameter<
std::
string>(
"OutputRootFile",
"" ) ),
42 collateHistos_( !pset.getUntrackedParameter<
bool>(
"UseClientFile",
false ) ),
43 analyzeHistos_( pset.getUntrackedParameter<
bool>(
"AnalyzeHistos",
true ) ),
44 xmlFile_( (pset.getUntrackedParameter<
edm::FileInPath>(
"SummaryXmlFile",
edm::FileInPath() )).fullPath() ),
45 createSummaryPlots_(
false ),
46 clientHistos_(
false ),
50 partitionName_(pset.existsAs<
std::
string>(
"PartitionName") ? pset.getParameter<
std::
string>(
"PartitionName") :
""),
56 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 57 <<
" Constructing object...";
69 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 70 <<
" Destructing object...";
77 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 78 <<
" Analyzing root file(s)...";
83 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 84 <<
" NULL pointer to DQMStore!" 93 std::ifstream root_file;
94 root_file.open( ifile->c_str() );
95 if( !root_file.is_open() ) {
97 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 98 <<
" The input root file \"" << *ifile
99 <<
"\" could not be opened!" 100 <<
" Please check the path and filename!";
106 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 107 <<
" The input root files appear to be a mixture" 108 <<
" of \"Source\" and \"Client\" files!" 112 if ( found != std::string::npos &&
inputFiles_.size() != 1 ) {
114 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 115 <<
" There appear to be multiple input \"Client\" root files!" 124 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 125 <<
" Collated histograms found in input root file \"" 131 std::ifstream xml_file;
133 if( !xml_file.is_open() ) {
135 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 136 <<
" The SummaryPlot XML file \"" <<
xmlFile_ 137 <<
"\" could not be opened!" 138 <<
" Please check the path and filename!" 150 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 151 <<
" No input root files specified!";
156 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 157 <<
" Opening root files. This may take some time!...";
161 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 162 <<
" Opening root file \"" << *jfile
163 <<
"\"... (This may take some time.)";
170 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 171 <<
" Opened root file \"" << *jfile <<
"\"!";
174 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 175 <<
" Opened " <<
inputFiles_.size() <<
" root files!";
179 bei_->getContents( contents );
183 std::vector<std::string>
temp;
184 std::vector<std::string>::iterator istr = contents.begin();
185 for ( ; istr != contents.end(); istr++ ) {
187 temp.push_back( *istr );
196 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 197 <<
" Found " << contents.size()
198 <<
" directories containing MonitorElements";
202 std::stringstream ss;
203 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 204 <<
" Directories found: " << std::endl;
205 std::vector<std::string>::iterator istr = contents.begin();
206 for ( ; istr != contents.end(); istr++ ) { ss <<
" " << *istr << std::endl; }
222 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 223 <<
" Unknown commissioning runType: " 229 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 238 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 239 <<
" Parsing summary plot XML file...";
244 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 245 <<
" Parsed summary plot XML file and found " 246 <<
plots_.size() <<
" plots defined!";
249 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 250 <<
" Null string for SummaryPlotXmlFile!" 251 <<
" No summary plots will be created!";
255 std::stringstream ss;
256 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" << std::endl
257 <<
" Input root files : ";
260 std::vector<std::string>::const_iterator ifile =
inputFiles_.begin();
263 ss << std::setw(25) << std::setfill(
' ') <<
": ";
265 ss <<
"\"" << *ifile <<
"\"" << std::endl;
268 ss <<
" Run type : \"" 270 <<
" Run number : " <<
runNumber_ << std::endl
271 <<
" Summary plot XML file : ";
272 if (
xmlFile_.empty() ) { ss <<
"(none)"; }
273 else { ss <<
"\"" <<
xmlFile_ <<
"\""; }
278 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 279 <<
" Creating CommissioningHistogram object...";
283 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 284 <<
" Created CommissioningHistogram object!";
287 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 288 <<
" NULL pointer to CommissioningHistogram object!" 301 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 302 <<
" Analyzing histograms...";
305 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 306 <<
" Analyzed histograms!";
309 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 310 <<
" No histogram analysis performed!";
316 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 317 <<
" Generating summary plots...";
318 std::vector<SummaryPlot>::const_iterator iplot =
plots_.begin();
319 for ( ; iplot !=
plots_.end(); iplot++ ) {
322 iplot->presentation(),
324 iplot->granularity() );
328 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 329 <<
" Generated summary plots!";
332 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 333 <<
" No summary plots generated!";
353 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 354 <<
" Client file not saved!";
371 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 372 <<
" Finished analyzing root file(s)...";
380 if ( !(event.
id().
event()%10) ) {
382 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 383 <<
" Empty event loop! User can kill job...";
398 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 399 <<
" CommissioningHistogram object already exists!" 407 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 408 <<
" NULL pointer to DQMStore!";
432 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 433 <<
" Undefined run type!";
438 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 439 <<
" Unknown run type!";
451 bool collate_histos ) {
454 std::stringstream ss;
455 ss << std::setfill(
'0') << std::setw(8) << run_number;
459 if ( !collate_histos ) { nameStr =
"SiStripCommissioningClient_"; }
460 else { nameStr =
"SiStripCommissioningSource_"; }
462 LogTrace(
"TEST") <<
" runStr " << runStr;
467 if ( (dp = opendir(path.c_str())) ==
nullptr ) {
469 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 470 <<
" Error locating directory \"" << path
471 <<
"\". No such directory!";
476 while ( (dirp = readdir(dp)) !=
nullptr ) {
478 bool goodName = ( fileName.find(nameStr) != std::string::npos );
479 bool goodRun = ( fileName.find(runStr) != std::string::npos );
480 bool rootFile = ( fileName.find(
".root") != std::string::npos );
481 bool goodPartition =
true;
482 if(not partitionName.empty()){
483 goodPartition = ( fileName.find(partitionName) != std::string::npos );
487 if ( goodName && goodRun && rootFile && goodPartition ){
491 files.push_back(entry);
497 if ( !collate_histos && files.size() > 1 ) {
498 std::stringstream ss;
499 ss <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 500 <<
" Found more than one client file!";
501 std::vector<std::string>::const_iterator
ifile = files.begin();
502 std::vector<std::string>::const_iterator
jfile = files.end();
505 }
else if ( files.empty() ) {
507 <<
"[SiStripCommissioningOfflineClient::" << __func__ <<
"]" 508 <<
" No input files found!" ;
void save(std::string &filename, uint32_t run_number=0, std::string partitionName="")
static const char runNumber_[]
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void save(std::string &filename, uint32_t run_number=0, std::string partitionName="")
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
sistrip::RunType runType_
static const char dqmClientFileName_[]
void parseXML(const std::string &xml_file)
def setup(process, global_tag, zero_tesla=False)
static const char mlDqmClient_[]
virtual void printAnalyses()
std::string outputFileName_
virtual void printSummary()
virtual void configure(const edm::ParameterSet &, const edm::EventSetup &)
static std::string runType(const sistrip::RunType &)
~SiStripCommissioningOfflineClient() override
edm::ParameterSet parameters_
std::string partitionName_
Parses the "summary plot" xml configuration file.
void extractHistograms(const std::vector< std::string > &)
static sistrip::RunType runType(DQMStore *const, const std::vector< std::string > &)
virtual void createHistos(const edm::ParameterSet &, const edm::EventSetup &)
SiStripCommissioningOfflineClient(const edm::ParameterSet &)
static uint32_t runNumber(DQMStore *const, const std::vector< std::string > &)
virtual void uploadToConfigDb()
CommissioningHistograms * histos_
virtual void setInputFiles(std::vector< std::string > &, const std::string, const std::string, uint32_t, bool)
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::vector< SummaryPlot > summaryPlots(const sistrip::RunType &)
std::vector< SummaryPlot > plots_
virtual void createSummaryHisto(const sistrip::Monitorable &, const sistrip::Presentation &, const std::string &top_level_dir, const sistrip::Granularity &)
std::vector< std::string > inputFiles_
static void copyCustomInformation(DQMStore *const, const std::vector< std::string > &)
static const char collate_[]
void remove(std::string pattern="")
void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void histoAnalysis(bool debug)