-
Notifications
You must be signed in to change notification settings - Fork 1
/
populate_BadEventRegistry.C
57 lines (47 loc) · 2.33 KB
/
populate_BadEventRegistry.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef populate_BadEventRegistry_C
#define populate_BadEventRegistry_C
#include <iostream>
#include <fstream>
#include <sstream>
#include <time.h>
#include "eventRegistry.C"
using namespace std;
void populate_BadEventRegistry(eventRegistry* BadEventRegistry, bool verbose=false);
void populate_from_file(eventRegistry* BadEventRegistry, string filename, bool verbose=false);
void populate_BadEventRegistry(eventRegistry* BadEventRegistry, bool verbose){
//populates the bad event registry using known bad events from file.
//File lists retreived Jan 27, 2016 from https://twiki.cern.ch/twiki/bin/viewauth/CMS/MissingETOptionalFiltersRun2#Event_Lists
//This is the main script to interface with.
clock_t startfor = clock();
populate_from_file(BadEventRegistry, "/uscms_data/d2/abarker/area2/CMSSW_7_4_7/src/LJMet/Com/BadEvents/badResolutionTrack_Jan13.txt", verbose);
populate_from_file(BadEventRegistry, "/uscms_data/d2/abarker/area2/CMSSW_7_4_7/src/LJMet/Com/BadEvents/csc2015_Dec01.txt", verbose);
populate_from_file(BadEventRegistry, "/uscms_data/d2/abarker/area2/CMSSW_7_4_7/src/LJMet/Com/BadEvents/ecalscn1043093_Dec01.txt", verbose);
populate_from_file(BadEventRegistry, "/uscms_data/d2/abarker/area2/CMSSW_7_4_7/src/LJMet/Com/BadEvents/muonBadTrack_Jan13.txt", verbose);
clock_t endfor = clock();
if(verbose) cout << "Populated the BadEventRegistry in "<<((float) (endfor - startfor))/CLOCKS_PER_SEC<<" seconds"<<endl;
}//populate_BadEventRegistry
void populate_from_file(eventRegistry* BadEventRegistry, string filename, bool verbose){
if(verbose) cout << "Reading CSC file" << std::endl;
long int nEventsRead = 0;
ifstream infile( filename );
while (infile)
{
string thisline;
if (!getline( infile, thisline )) break;
istringstream thisline_stringstream( thisline );
vector <string> line;
while (thisline_stringstream)
{
string thenumber;
if (!getline( thisline_stringstream, thenumber, ':' )) break;
line.push_back( thenumber );
}
int run= std::atoi(line[0].c_str());
int lumi = std::atoi(line[1].c_str());
int event= std::atoi(line[2].c_str());
RegisterEvent(run, lumi, event, BadEventRegistry);
}
if (!infile.eof()) cerr << "Error while reading bad event file!";
if(verbose) cout << "Done reading Bad Evetns file, read in "<<nEventsRead << " events"<<std::endl;
}//end populate_from_file
#endif