/* * SmartBlindCollection.cpp * * Created on: 16-mag-2009 * Author: Nicola Mori */ /*! @file SmartCollection.cpp The SmartBlindCollection class implementation file */ #include "SmartBlindCollection.h" int SmartBlindCollection::ApplyCut(PamLevel2 *event) { _nEv++; if (_cuts.size() == 0) { _nGood++; OnGood(event); return CUTOK; } unsigned int bunchEnd = -1; unsigned int nActions = 0; unsigned int firstActionOfBunch = -1; if (_actions.size() > 0) { // Set the bunch end to the position of the first action bunchEnd = _actionsPositions[0]; // Set the position of the first action at the end of the bunch firstActionOfBunch = 0; // Set the number of actions at the end of this bunch of cuts nActions = 1; while (_actionsPositions[nActions] == bunchEnd) nActions++; } int firstFailed = CUTOK; for (unsigned int icut = 0; icut < _cuts.size(); icut++) { if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == CUTOK) { firstFailed = icut; } if (bunchEnd == icut) { if (firstFailed == CUTOK) { for (unsigned int i = 0; i < nActions; i++) { _actions[firstActionOfBunch + i]->OnGood(event); } } else { for (unsigned int i = 0; i < nActions; i++) { _actions[firstActionOfBunch + i]->OnBad(event, icut); } } if (firstActionOfBunch + nActions < _actions.size()) { // Current bunch is done, but actions are not finished yet. Set up the next bunch. // Set the end of the new bunch and the number of actions at this end firstActionOfBunch += nActions; bunchEnd = _actionsPositions[firstActionOfBunch]; nActions = 1; while (_actionsPositions[firstActionOfBunch + nActions] == bunchEnd) nActions++; } } } if (firstFailed == CUTOK) { _nGood++; OnGood(event); } else { OnBad(event, firstFailed); } return firstFailed; }