ATLAS Offline Software
Loading...
Searching...
No Matches
makeHIRunIndex.cxx File Reference
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <memory>
#include <vector>
#include "TFile.h"
#include "TH1I.h"
Include dependency graph for makeHIRunIndex.cxx:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 14 of file makeHIRunIndex.cxx.

14 {
15 if (argc != 2) {
16 std::cout << "Syntax: " << argv[0] << " GoodRunList.xml" << std::endl;
17 return -1;
18 }
19
20 // get rid of everything except that one line with all the run numbers
21 FILE *runList =
22 popen(Form("grep '<Metadata Name=\"RunList\">' %s | sed -e 's/<Metadata "
23 "Name=\"RunList\">//' -e 's/<\\/Metadata>//' | sed 's/,/ /g' ",
24 argv[1]),
25 "r");
26
27 if (!runList) {
28 return -1;
29 }
30
31 int run;
32 std::vector<int> runs;
33 while (fscanf(runList, "%d", &run) != EOF) {
34 runs.push_back(run);
35 }
36 pclose(runList);
37
38 std::sort(runs.begin(), runs.end());
39 unsigned int size = runs.size();
40
41 std::unique_ptr<TFile> f(TFile::Open("cluster.geo.RUNINDEX.root", "recreate"));
42 auto h=std::make_unique<TH1I>("h1_run_index", "h1_run_index", size, 0, size);
43 for (unsigned int i = 0; i < size; i++) {
44 h->SetBinContent(i + 1, runs.at(i));
45 }
46 h->Write();
47
48 std::cout << "Created output file cluster.geo.RUNINDEX.root" << std::endl;
49 return 0;
50}
Header file for AthHistogramAlgorithm.
Definition run.py:1
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.