ProduceBadRunsByFailureMode.C
Go to the documentation of this file.
2 
3  TFile file("MetricsTree_All.root","read");
4  TTree *tree = (TTree*)file.Get("mytree");
5 
6  int run, subrun;
8 
9  tree->SetBranchAddress("run",&run);
10  tree->SetBranchAddress("subrun",&subrun);
11  tree->SetBranchAddress("ngooddb",&ngooddb);
12  tree->SetBranchAddress("ngoodcdb",&ngoodcdb);
13  tree->SetBranchAddress("pass_all",&pass_all);
14  tree->SetBranchAddress("pass_hits",&pass_hits);
15  tree->SetBranchAddress("pass_db",&pass_db);
16  tree->SetBranchAddress("pass_time",&pass_time);
17  tree->SetBranchAddress("pass_slc",&pass_slc);
18  tree->SetBranchAddress("pass_trk",&pass_trk);
19  tree->SetBranchAddress("pass_runlen",&pass_runlen);
20  tree->SetBranchAddress("pass_empty",&pass_empty);
21 
22  ofstream procfile;
23  procfile.open("FD_BRL_v0.txt");
24 
25  int nentries = tree->GetEntries();
26 
27  TString rowstr;
28 
29  ifstream fileListItr("ManBadSubruns.txt");
30 
32  //int removedreason;
33  set<int> cleanruns;
34  set<int> alreadyused;
35  while(fileListItr >> badrun >> badsubrun){
36  cleanruns.insert((100*badrun)+badsubrun);
37  cout << "Manually added Run/Subrun: " << badrun <<"/"<< badsubrun<< endl;
38  }
39 
40  for(int i = 0; i < nentries; i++){
41 
42  if(i%(nentries/10)==0) cout << int(100.0*i/nentries+0.5) << "% done" << endl;
43  int removedreason = 0;
44  tree->GetEntry(i);
45  //putting in run numbers is optional, mostly used to conform to epoch periolds.
46  if(cleanruns.count((run*100)+subrun)){
47  removedreason = 8;
48  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
49  procfile << rowstr.Data() << endl;
50  alreadyused.insert((run*100)+subrun);
51  }
52  if(!pass_all){
53  if(!pass_hits){
54  removedreason = 1;
55  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
56  procfile << rowstr.Data() << endl;
57  }
58  if(!pass_db || ngoodcdb < 4){
59  removedreason = 2;
60  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
61  procfile << rowstr.Data() << endl;
62  }
63  if(!pass_time){
64  removedreason = 3;
65  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
66  procfile << rowstr.Data() << endl;
67  }
68  if(!pass_slc){
69  removedreason = 4;
70  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
71  procfile << rowstr.Data() << endl;
72  }
73  if(!pass_trk){
74  removedreason = 5;
75  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
76  procfile << rowstr.Data() << endl;
77  }
78  if(!pass_runlen){
79  removedreason = 6;
80  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
81  procfile << rowstr.Data() << endl;
82  }
83  if(!pass_empty){
84  removedreason = 7;
85  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
86  procfile << rowstr.Data() << endl;
87  }
88  //if(cleanruns.count((run*100)+subrun)){
89  // removedreason = 9;
90  // rowstr = TString::Format("%d %d %d", run, subrun, removedreason);
91  // procfile << rowstr.Data() << endl;
92  // }
93  }
94  if(pass_all && ngooddb < 14 && ngoodcdb > 3){
95  removedreason = 0;
96  rowstr = TString::Format("%d %d %d %d", run, subrun, removedreason, ngooddb);
97  procfile << rowstr.Data() << endl;
98  }
99  }
100 
101  set<int>::iterator it;
102  for(it = cleanruns.begin(); it != cleanruns.end(); it++){
103  int runsubrun = *it;
104  if(!alreadyused.count(runsubrun)){
105  std::cout <<"Manual run not in regular dataset... adding... " << std::endl;
106  int temprun = runsubrun/100;
107  int tempsubrun = runsubrun%100;
108  rowstr = TString::Format("%d %d %d %d", temprun, tempsubrun, 8, -1);
109  procfile << rowstr.Data() << endl;
110  }
111  }
112  procfile.close();
113 
114 }
set< int >::iterator it
TTree * tree
TString rowstr
set< int > alreadyused
OStream cout
Definition: OStream.cxx:6
ifstream fileListItr("ManBadSubruns.txt")
ofstream procfile
TFile * file
Definition: cellShifts.C:17
void ProduceBadRunsByFailureMode
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
set< int > cleanruns