33 outfile_.open(
"badHcalLaserList_eventfilter.txt");
36 minRunInFile=999999; maxRunInFile=1;
37 string eventFileName0=ps.
getParameter<
string>(
"eventFileName");
40 if (verbose_)
edm::LogInfo(
"HcalLaserEventFilter2012") <<
"HCAL laser event list from file "<<eventFileName;
41 readEventListFile(eventFileName);
42 std::sort(EventList_.begin(), EventList_.end());
43 if (verbose_)
edm::LogInfo(
"HcalLaserEventFilter2012")<<
" A total of "<<EventList_.size()<<
" listed HCAL laser events found in given run range";
44 if (minrun_==-1 || minrun_<minRunInFile) minrun_=minRunInFile;
45 if (maxrun_==-1 || maxrun_>maxRunInFile) maxrun_=maxRunInFile;
55 size_t found = eventString.find(
":");
56 if (found!=std::string::npos)
57 run=atoi((eventString.substr(0,found)).c_str());
60 edm::LogError(
"HcalLaserEventFilter2012")<<
" Unable to parse Event list input '"<<eventString<<
"' for run number!";
63 size_t found2 = eventString.find(
":",found+1);
64 if (found2!=std::string::npos)
67 ls=atoi((eventString.substr(found+1,(found2-found-1))).c_str());
68 event=atoi((eventString.substr(found2+1)).c_str());
70 if (ls==0 ||
event==0)
edm::LogWarning(
"HcalLaserEventFilter2012")<<
" Strange lumi, event numbers for input '"<<eventString<<
"'";
74 edm::LogError(
"HcalLaserEventFilter2012")<<
"Unable to parse Event list input '"<<eventString<<
"' for run number!";
78 if (minrun_>-1 && run<minrun_)
80 if (verbose_)
edm::LogInfo(
"HcalLaserEventFilter2012") <<
"Skipping Event list input '"<<eventString<<
"' because it is less than minimum run # "<<minrun_;
83 if (maxrun_>-1 && run>maxrun_)
85 if (verbose_)
edm::LogInfo(
"HcalLaserEventFilter2012") <<
"Skipping Event list input '"<<eventString<<
"' because it is greater than maximum run # "<<maxrun_;
88 if (minRunInFile>run) minRunInFile=
run;
89 if (maxRunInFile<run) maxRunInFile=
run;
91 EventList_.push_back(eventString);
98 gzFile
file = gzopen (eventFileName.c_str(),
"r");
100 edm::LogError(
"HcalLaserEventFilter2012")<<
" Unable to open event list file "<<eventFileName;
111 bytes_read = gzread (file, buffer,
LENGTH - 1);
112 buffer[bytes_read] =
'\0';
115 pch = strtok_r (buffer,
"\n",&saveptr);
116 if (buffer[0] ==
'\n' ) {
121 while (pch !=
nullptr)
124 if (i>b2.size()) b2= pch;
126 if ((buffer[
LENGTH-2] ==
'\n' )|| (buffer[
LENGTH-2] ==
'\0' )){
133 pch = strtok_r (
nullptr,
"\n", &saveptr);
135 if (bytes_read <
LENGTH - 1) {
136 if (gzeof (file))
break;
138 const char * error_string;
139 error_string = gzerror (file, & err);
141 edm::LogError(
"HcalLaserEventFilter2012")<<
"Error while reading gzipped file: "<<error_string;
171 if (minrun_>-1 && run<minrun_)
return true;
172 if (maxrun_>-1 && run>maxrun_)
return true;
175 std::stringstream thisevent;
180 if (it == EventList_.end() || thisevent.str() < *it)
return true;
184 if (verbose_)
std::cout <<prefix_<<thisevent.str()<<std::endl;
192 if (forceFilterTrue_)
return true;
199 if (WriteBadToFile_) outfile_.close();
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
HcalLaserEventFilter2012(const edm::ParameterSet &)
edm::LuminosityBlockNumber_t luminosityBlock() const
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
void addEventString(const std::string &eventString)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~HcalLaserEventFilter2012() override
bool filter(edm::Event &, const edm::EventSetup &) override
std::string fullPath() const
void readEventListFile(const std::string &eventFileName)
std::vector< std::string >::iterator strVecI