/*
 * TofPatternCut.h
 *
 *  Created on: 10-mar-2009
 *      Author: Elena Vannuccini
 */

/*! @file TofPatternCut.h The ToFPatternCut class definition file */

#ifndef TOFPATTERNCUT_H_
#define TOFPATTERNCUT_H_

#include "../../PamCutBase/PamCutBase.h"

/*! @brief The Tof-pattern cut.
 *
 * Requirements:
 * - (1) no more than 1 hit paddle on S11 S12 S21 S22;
 * - (2) at least 1 hit paddle on S1 and S2;
 * - (3) less than 3 hit PMTs (only TDC hits with tdc<4095) outside track on S11 and S12;
 * - (4) if there is a hit paddle, it must be associated to the track.
 */
class TofPatternCut: public PamCut {

public:
  /*! @brief Constructor.
   *
   * @param cutName The cut's name.
   * @param standalone If true, the standalone track will be used; otherwise, track
   *                   from tracker will be used.
   * @param notrk The number of the physical track to use.
   */
  TofPatternCut(const char *cutName, bool standalone = false, int notrk = 0) :
    PamCut(cutName), _standalone(standalone), _notrk(notrk) {
  }
  /*! @brief Destructor. */
  ~TofPatternCut() {
  }

  /*! @brief The ToF-pattern check.
   *
   * @param event The event to analyze.
   * @return #CUTOK if the event pattern matches the required characteristics.
   */
  int Check(PamLevel2 *event);

  /*! @brief Counts the number of hit PMTs (with tdc signal) outside track
   *
   * @param event The event to analyze.
   * @param plane Plane number (0-5 = S11-S32).
   */
  int GetNHitPMTsOutsideTrack(PamLevel2 *event, int plane);

  /*! @brief Set standalone ToF track. */
  inline void SetStandalone(int yes) {
    if (yes)
      _standalone = true;
    else
      _standalone = false;
  }

  /*! @brief Set (physical) track number (0,1,...). Default is 0 (the first).   */
  inline void SetTrackNumber(int n) {
    _notrk = n;
  }


private:

  bool _standalone;
  int _notrk;

};
#endif /* TOFPATTERNCUT_H_ */
