/* 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/ReconTOFCuts.hh"
namespace MAUS {
ReconTOFCuts::~ReconTOFCuts() {
}
ReconTOFCuts::ReconTOFCuts(Json::Value cutParams) {
if (!cutParams.isNull()) {
SetMin(cutParams["dt_min"].asFloat());
SetMax(cutParams["dt_max"].asFloat());
} else {
SetMin(-FLT_MAX);
SetMax(FLT_MAX);
}
}
void ReconTOFCuts::DoCuts(ReconEvent* anEvent) {
// Squeak::mout(Squeak::warning) << "in ReconTOFCuts::DoCuts" << std::endl;
TOFEvent * MyEvent = anEvent->GetTOFEvent();
if (MyEvent == NULL) {
return;
}
TOFEventSpacePoint SpacePoint = MyEvent->GetTOFEventSpacePoint();
bool cutPassed = false;
// TOF0 cut
if (SpacePoint.GetTOF0SpacePointArray().size() == 1) {
cutPassed = true;
} else {
cutPassed = false;
}
anEvent->GetCutsList()->push_back(new ReconCutDataBase("TOF0",
"TOF0SpacePoints==1", cutPassed, SpacePoint.GetTOF0SpacePointArray().size()));
// TOF1 cut
if (SpacePoint.GetTOF1SpacePointArray().size() == 1) {
cutPassed = true;
} else {
cutPassed = false;
}
anEvent->GetCutsList()->push_back(new ReconCutDataBase("TOF1",
"TOF1SpacePoints==1", cutPassed, SpacePoint.GetTOF1SpacePointArray().size()));
// TOF hit times cut
cutPassed = false;
double dt = 0;
if (SpacePoint.GetTOF0SpacePointArray().size() == 1 &&
SpacePoint.GetTOF1SpacePointArray().size() == 1) {
TOFSpacePoint TOF0_sp = SpacePoint.GetTOF0SpacePointArray()[0];
TOFSpacePoint TOF1_sp = SpacePoint.GetTOF1SpacePointArray()[0];
dt = TOF1_sp.GetTime() - TOF0_sp.GetTime();
if ( dt >= GetMin() && dt <= GetMax() ) {
cutPassed = true;
}
}
std::stringstream cutDesc;
cutDesc << "TOFDT>=" << GetMin() << " && TOFDT <=" << GetMax();
anEvent->GetCutsList()->push_back(new ReconCutDataBase("TOFDT", cutDesc.str(),
cutPassed, dt));
}
} // namespace MAUS