/* 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 "Utils/Squeak.hh"
#include "src/map/MapCppReconCuts/ReconMiscCuts.hh"
namespace MAUS {
ReconMiscCuts::~ReconMiscCuts() {
}
ReconMiscCuts::ReconMiscCuts(Json::Value cutParams) {
if (!cutParams.isNull()) {
// set parameters from config
_good_particle = JsonWrapper::GetProperty(
cutParams, "good_particle", JsonWrapper::arrayValue);
} else {
// Good particle cut is true if following cuts are true
// TOF0, TOF1, TOFDT
// Single_track, TKU_hits, TKU_mom_cut
// Mom_loss_cut, Mass_cut, Track_p_value
_good_particle[0] = "TOF0";
_good_particle[1] = "TOF1";
_good_particle[2] = "TOFDT";
_good_particle[3] = "Single_track";
_good_particle[4] = "TKU_hits";
_good_particle[5] = "TKU_mom_cut";
_good_particle[6] = "Mom_loss_cut";
_good_particle[7] = "Mass_cut";
_good_particle[8] = "Track_p_value";
}
// Squeak::mout(Squeak::warning)
// << "in ReconMiscCuts::ReconMiscCuts _good_particle type is "
// << _good_particle.type() << std::endl;
}
/** Copy constructor */
ReconMiscCuts::ReconMiscCuts(ReconMiscCuts& copy) {
_good_particle = copy._good_particle;
}
/** operator = */
ReconMiscCuts& ReconMiscCuts::operator=(ReconMiscCuts& rhs) {
_good_particle = rhs._good_particle;
return *this;
}
void ReconMiscCuts::DoCuts(ReconEvent* anEvent) {
// Good particle cut
bool good_particle_cut = true;
ReconCutDataBasePArray* theCutsData = anEvent->GetCutsList();
for (size_t i = 0;i < _good_particle.size();i++) {
// Squeak::mout(Squeak::warning)
// << "ReconMiscCuts::DoCuts _good_particle element is "
// << JsonWrapper::GetItem(_good_particle,i,JsonWrapper::stringValue).asString() << std::endl;
// Find cut in cuts list and and with good_particle_cut
bool found = false;
for(size_t j = 0;j < theCutsData->size();j++) {
if(theCutsData->at(j)->GetCutName().compare(
_good_particle[Json::Value::ArrayIndex(i)].asString()) == 0) {
found = true;
good_particle_cut = good_particle_cut&theCutsData->at(j)->GetCutPass();
break;
}
}
// Error cut not found
if(!found) {
Squeak::mout(Squeak::warning)
<< "ReconMiscCuts::DoCuts good_particle cut "
<< _good_particle[Json::Value::ArrayIndex(i)].asString()
<< " not found" << std::endl;
good_particle_cut = false;
}
if(!good_particle_cut) break;
}
// Add cut objects to the event
anEvent->GetCutsList()->push_back(new ReconCutDataBase("good_particle",
"good_particle==true", good_particle_cut, good_particle_cut));
}
} // namespace MAUS