95 typedef JRange<int> JRange_t;
106 JSelection_t selection;
113 JParser<> zap(
"Example program to plot quality data from data base.");
118 zap[
'f'] =
make_field(inputFile,
"Optional input file instead of database.") =
"";
119 zap[
'o'] =
make_field(
outputFile,
"Output file containing histograms and n-tuple.") =
"quality.root";
121 zap[
'R'] =
make_field(runs,
"Run range") = JRange_t(1, JRange_t::getMaximum());
122 zap[
'S'] =
make_field(source,
"GIT versions");
123 zap[
'Q'] =
make_field(selection,
"User defined selections");
130 catch(
const exception &error) {
131 FATAL(error.what() << endl);
137 for (JSelection_t::const_iterator i = selection.begin(); i != selection.end(); ++i) {
142 FATAL(
"Invalid total weight: " << W << endl);
149 if (inputFile ==
"") {
160 ID = to_value<int>(detid);
168 ResultSet& rs =
getResultSet(getTable<JRuns>(), getSelector<JRuns>(
ID));
170 for (JRuns parameters; rs >> parameters; ) {
171 if (TString(parameters.RUNSETUPNAME.c_str()).Contains(regexp)) {
172 setup.put(parameters);
185 JSelector selector = getSelector<JRunSummaryNumbers>(detid, runs.getLowerLimit(), runs.getUpperLimit());
187 selector.add(&JRunSummaryNumbers::SOURCE_NAME, *i);
191 ResultSet& rs =
getResultSet(getTable<JRunSummaryNumbers>(), selector);
193 for (JRunSummaryNumbers parameters; rs >> parameters; ) {
194 if (setup.has(parameters.RUN)) {
195 zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE));
199 catch(
const exception& error) {}
201 for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) {
206 quality.detector =
ID;
207 quality.run = run->first;
209 for (data_type::const_iterator p = run->second.begin(); p != run->second.end(); ++p) {
210 quality.put(p->first, p->second);
213 buffer.insert(quality);
217 catch(
const exception& error) {
218 FATAL(error.what() << endl);
223 ifstream in(inputFile.c_str());
225 for (JRunQuality quality; in >> quality; ) {
226 buffer.insert(quality);
232 if (buffer.empty()) {
233 FATAL(
"No data." << endl);
237 runs = JRange_t(buffer.begin()->run, buffer.rbegin()->run);
239 TH1D h0(
"h0", NULL, 1000, 0.0, 1.01);
240 TH1D h1(
"h1", NULL, selection.size(), -0.5, selection.size() + 0.5);
243 h0.SetMaximum(1.1 * (runs.getUpperLimit() - runs.getLowerLimit()));
246 h1.SetMaximum(1.1 * (runs.getUpperLimit() - runs.getLowerLimit()));
249 runs.getLength() + 1,
250 runs.getLowerLimit() - 0.5,
251 runs.getUpperLimit() + 0.5));
255 for (JSelection_t::const_iterator i = selection.begin(); i != selection.end();++i) {
257 const string buffer = i->formula;
259 zmap[buffer]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(buffer <<
":upper"),
MAKE_CSTRING(i->range.getUpperLimit()), runs.getLowerLimit(), runs.getUpperLimit()));
260 zmap[buffer]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(buffer <<
":lower"),
MAKE_CSTRING(i->range.getLowerLimit()), runs.getLowerLimit(), runs.getUpperLimit()));
263 for (JSelection_t::const_iterator i = veto.begin(); i != veto.end();++i) {
265 const string buffer =
MAKE_STRING(
"VETO[" << i->formula <<
"]");
267 zmap[buffer]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(buffer <<
":upper"),
MAKE_CSTRING(i->range.getUpperLimit()), runs.getLowerLimit(), runs.getUpperLimit()));
268 zmap[buffer]->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(buffer <<
":lower"),
MAKE_CSTRING(i->range.getLowerLimit()), runs.getLowerLimit(), runs.getUpperLimit()));
275 for (
size_t i = 0; i != selection.size(); ++i) {
276 os <<
":" << (char) (
'a' + i);
281 TNtuple n1(
"n1",
"quality", os.str().c_str());
284 h0.SetDirectory(NULL);
285 h1.SetDirectory(NULL);
286 n1.SetDirectory(NULL);
295 tuple.push_back((Float_t) quality->run);
299 for (
size_t i = 0; i != selection.size(); ++i) {
301 const JSelection& ps = selection[i];
302 const double y =
getResult(ps.formula, *quality);
304 tuple.push_back((Float_t) y);
306 zmap[ps.formula]->Fill((
double) quality->run, y);
312 h1.AddBinContent(i + 1, ps.range(y) ? 1.0 : 0.0);
315 const double Q =
w/W;
317 tuple.push_back((Float_t) Q);
321 for (
size_t i = 0; i != veto.size(); ++i) {
323 const JSelection& ps = veto[i];
324 const double y =
getResult(ps.formula, *quality);
326 zmap[
MAKE_STRING(
"VETO[" << ps.formula <<
"]")]->Fill((
double) quality->run, ps.range(y) ? 0.0 : 1.0);
333 tuple.push_back((Float_t) V);
334 tuple.push_back((Float_t) setup.get(quality->run));
337 n1.Fill(tuple.data());
339 cout << setw(8) << quality->run <<
' ' <<
FIXED(5,3) << Q <<
' ' << setw(2) << V << endl;
344 for (Int_t i = 0; i <= h0.GetXaxis()->GetNbins(); ++i) {
345 h0.SetBinContent(i, (
w += h0.GetBinContent(i)));
352 out << h0 << h1 << n1 << zmap;