1 |
konec |
1.1 |
#include "LinkSynchroMerger.h"
|
2 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
3 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
4 |
|
|
|
5 |
|
|
#include <sstream>
|
6 |
|
|
#include <fstream>
|
7 |
|
|
|
8 |
|
|
using namespace edm;
|
9 |
|
|
using namespace std;
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
LinkSynchroMerger::LinkSynchroMerger(const edm::ParameterSet& cfg)
|
14 |
|
|
: LinkSynchroAnalysis(cfg), isInitialised(false),
|
15 |
|
|
theFileNames( cfg.getUntrackedParameter<std::vector<std::string> >("preFillLinkSynchroFileNames"))
|
16 |
|
|
{}
|
17 |
|
|
|
18 |
|
|
void LinkSynchroMerger::beginJob()
|
19 |
|
|
{ RPCMonitorLinkSynchro::beginJob(); }
|
20 |
|
|
|
21 |
|
|
void LinkSynchroMerger::beginRun(const edm::Run& ev, const edm::EventSetup& es)
|
22 |
|
|
{
|
23 |
|
|
RPCMonitorLinkSynchro::beginRun(ev,es);
|
24 |
|
|
if(!isInitialised) {
|
25 |
|
|
isInitialised = true;
|
26 |
|
|
if (!theFileNames.empty())for (std::vector<std::string>::const_iterator it=theFileNames.begin(); it != theFileNames.end(); ++it) preFillFromFile(*it);
|
27 |
|
|
}
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
void LinkSynchroMerger::preFillFromFile(const std::string & fileName)
|
31 |
|
|
{
|
32 |
|
|
std::ifstream file( fileName.c_str() );
|
33 |
|
|
if ( !file ) {
|
34 |
|
|
edm::LogError(" ** LinkSynchroMerger ** ") << " cant open data file: " << fileName;
|
35 |
|
|
return;
|
36 |
|
|
} else {
|
37 |
|
|
edm::LogInfo("LinkSynchroMerger, read data from: ") <<fileName;
|
38 |
|
|
}
|
39 |
|
|
string line, lbName, tmp;
|
40 |
|
|
unsigned int hits[8];
|
41 |
|
|
while (getline(file,line) ) {
|
42 |
|
|
stringstream str(line);
|
43 |
|
|
str >> lbName
|
44 |
|
|
>>tmp>>tmp>>tmp>>tmp>>tmp
|
45 |
|
|
>>hits[0]>>hits[1]>>hits[2]>>hits[3]>>hits[4]>>hits[5]>>hits[6]>>hits[7];
|
46 |
|
|
if (str.good()) theSynchroStat.add(lbName,hits);
|
47 |
|
|
}
|
48 |
|
|
file.close();
|
49 |
|
|
}
|