MakeRunList.C
Go to the documentation of this file.
1 void MakeRunList(){
2 
3  //Retrieve MetricsTree root file
4  TFile file("../MetricsTree_All.root","read");
5  TTree *tree = (TTree*)file.Get("mytree");
6 
7 
8  //Define vars for reading the Metrics' tree relevant branches
9  int nentries = tree->GetEntries();
10 
11  int run, subrun, par, nevents;
12  int pass_all;
13  int firstsec, lastsec;
14 
15  tree->SetBranchAddress("par",&par);
16  tree->SetBranchAddress("run",&run);
17  tree->SetBranchAddress("subrun",&subrun);
18  tree->SetBranchAddress("nevents",&nevents);
19  tree->SetBranchAddress("pass_all",&pass_all);
20  tree->SetBranchAddress("firstsec",&firstsec);
21  tree->SetBranchAddress("lastsec",&lastsec);
22 
23 
24 
25  //Set an output file to write the Good Runs List
26  //This file will undergo additional processing later
27  ofstream procfile;
28  procfile.open("NuMIList.txt");
29 
30  TString rowstr;
31 
32 
33 
34 
35 
36  //Retreive Manual Bad Runs from file
37  ifstream fileListItr("../SAMScripts/ManBadRuns.txt");
38 
39  //Store all runs to be removed in a set
40  int badrun;
41  set<int> badRunsToRemove;
42 
43  while(fileListItr >> badrun){
44  badRunsToRemove.insert(badrun);
45  cout << "Mark for removal: "
46  << badrun
47  << std::endl;
48  }
49 
50 
51 
52 
53 
54 
55  //Loop over the Metrics Tree, and write the temporary Good Runs List
56  //by skipping runs manually marked bad
57  for(int i = 0; i < nentries; i++){
58 
59  //Print progress percentage...
60  if(i%(nentries/10)==0) cout << int(100.0*i/nentries+0.5) << "% done" << endl;
61 
62  //Retrieve next subrun
63  tree->GetEntry(i);
64 
65  //Skip runs not in partition 1
66  if(par != 1) continue;
67 
68  //Skip runs manually marked bad
69  if(badRunsToRemove.count(run) != 0){
70  std::cout << "Removed: "
71  << run
72  << std::endl;
73  continue;
74  }
75 
76 
77 
78  //Optional: Run only over runs from definite periods
79  //RHC Periods: 4,6,7,8
80  bool is_RHC_period = false
81  || (23420 <= run && run <= 24613) //period 4
82  || (25413 <= run && run <= 28036) //period 6
83  || (28037 <= run && run <= 31167) //period 7
84  || (31168 <= run && run <= 32397) //period 8
85  ;
86 
87  //FHC Periods: 1,2,3,5,9
88  bool is_FHC_period = false
89  //|| (12942 <= run && run <= 17139) //period 1
90  //|| (17891 <= run && run <= 20752) //period 2
91  //|| (20753 <= run && run <= 23419) //period 3
92  //|| (24614 <= run && run <= 25412) //period 5
93  //|| (32398 <= run && run <= 34573) //period 9
94  || (34574 <= run && run <= 35922) //period 10 - up to 10d, update upper limit when period actually ends
95  ;
96 
97  if(!is_FHC_period) continue;
98 
99 
100  //Write a row to output file
101  rowstr = TString::Format("%d\t%02d\t%d\t%d\t%d\t%d", run, subrun, nevents, pass_all, firstsec, lastsec);
102 
103  procfile << rowstr.Data() << endl;
104 
105  }
106 
107  //Close and leave properly
108  procfile.close();
109 
110 }
Int_t lastsec
Definition: SimpleIterate.C:27
void MakeRunList()
Definition: MakeRunList.C:1
Int_t pass_all
Definition: SimpleIterate.C:42
Int_t par
Definition: SimpleIterate.C:24
Int_t nevents
Definition: SimpleIterate.C:25
Long64_t nentries
TString rowstr
OStream cout
Definition: OStream.cxx:6
Int_t firstsec
Definition: SimpleIterate.C:26
ifstream fileListItr("ManBadSubruns.txt")
ofstream procfile
TFile * file
Definition: cellShifts.C:17
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154