#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JAAnet/JHead.hh" #include "JAAnet/JAAnetToolkit.hh" #include "JAAnet/JVolume.hh" #include "JDAQ/JDAQEventIO.hh" #include "JTools/JRange.hh" #include "JSupport/JTriggeredFileScanner.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" #include "JSupport/JSupport.hh" #include "JGeometry3D/JCylinder3D.hh" #include "JReconstruction/JEvt.hh" #include "JReconstruction/JEvtToolkit.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to histogram fit efficiency. * \author lquinn */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; typedef JTriggeredFileScanner JTriggeredFileScanner_t; typedef JTriggeredFileScanner_t::multi_pointer_type multi_pointer_type; JTriggeredFileScanner_t inputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string outputFile; string detectorFile; size_t numberOfPrefits; JRange E_GeV; double quality; bool logx; bool containment; int debug; try { JParser<> zap("Example program to histogram fit results."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "fitefficiency.root"; zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['N'] = make_field(numberOfPrefits) = 1; zap['E'] = make_field(E_GeV) = JRange(1.0, -1.0); zap['Q'] = make_field(quality) = numeric_limits::min(); zap['X'] = make_field(logx); zap['C'] = make_field(containment); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } Head head; try { head = getHeader(inputFile); } catch(const JException& error) { FATAL(error); } JHead buffer(head); JVolume volume(head, logx); const double Xmax = E_GeV.is_valid() ? volume.getX(E_GeV.getMaximum()) : volume.getXmax(); const double Xmin = E_GeV.is_valid() ? volume.getX(E_GeV.getMinimum()) : volume.getXmin(); TFile out(outputFile.c_str(), "recreate"); TH1D* hN = new TH1D("hN", NULL, 25, Xmin, Xmax); TH1D* he = new TH1D("he", NULL, 25, Xmin, Xmax); hN->Sumw2(); he->Sumw2(); JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } JCylinder3D cylinder(detector.begin(), detector.end()); STATUS("Detector Geometry:" << endl); STATUS("Zmin: " << cylinder.getZmin() << endl); STATUS("Zmax: " << cylinder.getZmax() << endl); STATUS("Z origin: " << 0.5 * (cylinder.getZmax() + cylinder.getZmin()) << endl); STATUS("Radius: " << cylinder.getRadius() << endl); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); multi_pointer_type ps = inputFile.next(); //JDAQEvent* tev = ps; JEvt* evt = ps; Evt* event = ps; if (has_neutrino(*event)) { Trk neutrino = get_neutrino(*event); const double X = volume.getX(neutrino.E); hN->Fill(X); if (!evt->empty()) { JEvt::iterator __end = evt->end(); if (numberOfPrefits > 0) { advance(__end = evt->begin(), min(numberOfPrefits, evt->size())); partial_sort(evt->begin(), __end, evt->end(), qualitySorter); } for(JEvt::const_iterator track = evt->begin(); track != __end; ++track) { JPosition3D pos = getPosition(*track); const double R = sqrt(pos.getX() * pos.getX() + pos.getY() * pos.getY()); if ((pos.getZ() > cylinder.getZmin() && pos.getZ() < cylinder.getZmax() && R < cylinder.getRadius()) || !containment) { double Q = 0.0; if(track->hasW(JGANDALF_CHI2) && track->hasW(JGANDALF_NUMBER_OF_HITS)) { Q = -track->getW(JGANDALF_CHI2)/track->getW(JGANDALF_NUMBER_OF_HITS); } else { Q = track->getQ(); } if (Q > quality) { he->Fill(X); } } } } } else { WARNING("No neutrino." << endl); } } STATUS(endl); he->Divide(hN); out.Write(); out.Close(); }