1 |
|
// $Id$ |
2 |
|
|
3 |
– |
#include <boost/property_tree/ptree.hpp> |
4 |
– |
#include <boost/property_tree/json_parser.hpp> |
5 |
– |
#include <boost/lexical_cast.hpp> |
3 |
|
#include "MitAna/PhysicsMod/interface/RunLumiSelectionMod.h" |
7 |
– |
#include <TFile.h> |
4 |
|
#include <TTree.h> |
5 |
|
#include "MitAna/DataTree/interface/Names.h" |
6 |
|
|
51 |
|
fAcceptCurrentRunLumi = kTRUE; |
52 |
|
} |
53 |
|
else { |
54 |
< |
//check if run is included |
59 |
< |
MapType::const_iterator it = fAcceptedRunsLumis.find(runLumi.first); |
60 |
< |
if (it!=fAcceptedRunsLumis.end()) { |
61 |
< |
//check lumis |
62 |
< |
const MapType::mapped_type &lumiPairList = it->second; |
63 |
< |
for (MapType::mapped_type::const_iterator jt = lumiPairList.begin(); jt<lumiPairList.end(); ++jt) { |
64 |
< |
if (runLumi.second >= jt->first && runLumi.second <= jt->second) { |
65 |
< |
//found lumi in accepted range |
66 |
< |
fAcceptCurrentRunLumi = kTRUE; |
67 |
< |
} |
68 |
< |
} |
69 |
< |
} |
70 |
< |
else { |
71 |
< |
//run not in JSON file, reject it |
72 |
< |
fAcceptCurrentRunLumi = kFALSE; |
73 |
< |
} |
54 |
> |
fAcceptCurrentRunLumi = fAcceptedRunsLumis.HasRunLumi(runLumi); |
55 |
|
} |
56 |
|
fCurrentRunLumi = runLumi; |
57 |
|
if (0) { |
92 |
|
//-------------------------------------------------------------------------------------------------- |
93 |
|
void RunLumiSelectionMod::AddJSONFile(const std::string &filepath) |
94 |
|
{ |
95 |
< |
|
96 |
< |
//read json file into boost property tree |
116 |
< |
boost::property_tree::ptree jsonTree; |
117 |
< |
boost::property_tree::read_json(filepath,jsonTree); |
118 |
< |
|
119 |
< |
//loop through boost property tree and fill the MapType structure with the list of good lumi |
120 |
< |
//ranges for each run |
121 |
< |
for (boost::property_tree::ptree::const_iterator it = jsonTree.begin(); it!=jsonTree.end(); ++it) { |
122 |
< |
UInt_t runNumber = boost::lexical_cast<UInt_t>(it->first); |
123 |
< |
MapType::mapped_type &lumiPairList = fAcceptedRunsLumis[runNumber]; |
124 |
< |
boost::property_tree::ptree lumiPairListTree = it->second; |
125 |
< |
for (boost::property_tree::ptree::const_iterator jt = lumiPairListTree.begin(); jt!=lumiPairListTree.end(); ++jt) { |
126 |
< |
boost::property_tree::ptree lumiPairTree = jt->second; |
127 |
< |
if (lumiPairTree.size()==2) { |
128 |
< |
UInt_t firstLumi = boost::lexical_cast<UInt_t>(lumiPairTree.begin()->second.data()); |
129 |
< |
UInt_t lastLumi = boost::lexical_cast<UInt_t>((++lumiPairTree.begin())->second.data()); |
130 |
< |
lumiPairList.push_back(std::pair<UInt_t,UInt_t>(firstLumi,lastLumi)); |
131 |
< |
} |
132 |
< |
} |
133 |
< |
} |
134 |
< |
|
135 |
< |
//dump run and lumi ranges from MapType structure to verify correct json parsing |
136 |
< |
if (0) { |
137 |
< |
printf("Iterating over parsed JSON:\n"); |
138 |
< |
for (MapType::const_iterator it = fAcceptedRunsLumis.begin(); it != fAcceptedRunsLumis.end(); ++it) { |
139 |
< |
printf(" Run %u:\n",it->first); |
140 |
< |
for (MapType::mapped_type::const_iterator jt = it->second.begin(); jt < it->second.end(); ++jt) { |
141 |
< |
printf(" Lumis %u - %u\n",jt->first,jt->second); |
142 |
< |
} |
143 |
< |
} |
144 |
< |
|
145 |
< |
} |
146 |
< |
|
95 |
> |
//pass JSON file to map object |
96 |
> |
fAcceptedRunsLumis.AddJSONFile(filepath); |
97 |
|
} |