diff --git a/Projects/ComptonTelescope/online/src/online_dsssd.cpp b/Projects/ComptonTelescope/online/src/online_dsssd.cpp index 7f0b139c811f8163204546606ed1a715258bf431..ee694459a8825afb4b74120e9766c0961ed9e108 100644 --- a/Projects/ComptonTelescope/online/src/online_dsssd.cpp +++ b/Projects/ComptonTelescope/online/src/online_dsssd.cpp @@ -15,12 +15,12 @@ #include <iostream> #include <fstream> #include <string> +#include <cstdlib> using namespace std; //--//--//--//--//--//--//--//--//--//--//--//--//--//--//--// -int main() +int main(int argc, char *argv[]) { - /////////////////////////////////////////////////////////////////////////// // configure option manager // NPOptionManager::getInstance()->Destroy(); @@ -49,16 +49,34 @@ int main() auto ccamPhys = (TComptonTelescopePhysics*) m_NPDetectorManager->GetDetector("ComptonTelescope"); ccamPhys->SetRawDataPointer(ccamData); + // deal with file name and number of events to treat from command line + std::cout << "\n"; + int nevents = -1; + string fileName = "bb7_3309-7_cs137_20210304_14h35_conv.root"; + if (argc == 1) { + std::cout << "Name of file to analyse should be provided as a command line argument\n"; + std::cout << "Default file " << fileName << " is considered\n"; + } + else { + fileName = argv[1]; + if (argc == 3) nevents = std::atoi(argv[2]); + } + // read data file/flux and fill ccamData object - std::cout << "Reading data\n"; + std::cout << "Reading data from " << fileName << "\n"; DecodeD* DD = new DecodeD(true); // Instantiates DecodeD object reading DSSSD(s) data flux newframe_t* event; - DD -> setTree("../data/20200128_10h44_bi207_conv.root"); + fileName = "../data/" + fileName; + DD -> setTree(fileName.c_str()); +// DD -> setTree("../data/20200128_10h44_bi207_conv.root"); +// DD -> setTree("../data/bb7_3309-7_cs137_20210304_14h35_conv.root"); //DD -> setTree("../data/bb7_3309-7_bi207_20210209_12h50_run10_conv.root"); int dlen = DD -> getLength(); + // read a limited number of events + if (nevents > 0) dlen = nevents; + std::cout << "Reading the first " << dlen << " entries\n"; - while (DD -> getCursor() < 49970) - //while (DD -> getCursor() < dlen) + while (DD -> getCursor() < dlen) { // cout number of entries treated if (DD -> getCursor() % 10000 == 0) {