/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
*
* MAUS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MAUS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MAUS. If not, see .
*
*/
#include
#include
#include
#include "src/legacy/Interface/STLUtils.hh"
#include "Utils/Squeak.hh"
#include "src/reduce/ReduceCppEVExport/ReduceCppEVExport.hh"
namespace MAUS {
PyMODINIT_FUNC init_ReduceCppEVExport(void) {
PyWrapReduceBase::PyWrapReduceBaseModInit(
"ReduceCppEVExport", "", "", "", "");
}
ReduceCppEVExport::ReduceCppEVExport()
: ReduceBase("ReduceCppEVExport") {}
ReduceCppEVExport::~ReduceCppEVExport() {}
void ReduceCppEVExport::_birth(const std::string& argJsonConfigDocument) {
if (!_output) {
throw MAUS::Exceptions::Exception(Exceptions::nonRecoverable,
"The output is disconnected.",
"ReduceCppEVExport::_birth");
}
if (!_output->GetImage())
_output->SetImage(new MAUS::Image());
// JsonCpp setup
Json::Value configJSON;
configJSON = JsonWrapper::StringToJson(argJsonConfigDocument);
// Fetch variables
_spill_step = configJSON["EVOnlineSpillStep"].asInt();
}
void ReduceCppEVExport::_death() {}
void ReduceCppEVExport::_process(MAUS::Data* data) {
if ( !data )
throw MAUS::Exceptions::Exception(Exceptions::recoverable, "Data was NULL",
"ReduceCppEVExport::_process");
if ( !data->GetSpill() )
throw MAUS::Exceptions::Exception(Exceptions::recoverable, "Spill was NULL",
"ReduceCppEVExport::_process");
std::string evType = data->GetSpill()->GetDaqEventType();
if ( evType != "physics_event" )
return;
if ( !data->GetSpill()->GetReconEvents() )
throw MAUS::Exceptions::Exception(Exceptions::recoverable, "ReconEvents were NULL",
"ReduceCppEVExport::_process");
MAUS::Spill *spill = data->GetSpill();
int spillNumber = spill->GetSpillNumber();
const char* outputDir = std::getenv("EV_DEST_DIR");
if (spillNumber % _spill_step == 0 && spillNumber != 0) {
std::cerr << "Exporting spill no: " << spillNumber << std::endl;
exp = new EventViewer::EVExporter(spill);
exp->ReadAllEvents(0, true);
}
}
} // MAUS