1 /**************************************************************************
2 * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 * Class defining a range in which a value to be checked is valid. Can be used
18 * as a cut. In case a negative comparison (value valid only outside this range)
19 * is desired, this is handled when setting the object to negate (function Negate()).
20 * The class is a template, expecting the comparison operators to be overloaded.
22 * Author: Markus Fasel
25 #include "AliCutValueRange.h"
27 templateClassImp(EMCalTriggerPtAnalysis::AliCutValueRange)
29 namespace EMCalTriggerPtAnalysis {
31 //______________________________________________________________________________
33 AliCutValueRange<t>::AliCutValueRange():
37 * Dummy constructor, producing a range open to both sides
39 fHasLimit[0] = fHasLimit[1] = false;
42 //______________________________________________________________________________
44 AliCutValueRange<t>::AliCutValueRange(t min, t max):
48 * Constructor, producing a range closed to both sides
50 * @param min: lower limit
51 * @param max: upper limit
55 fHasLimit[0] = fHasLimit[1] = true;
58 //______________________________________________________________________________
60 AliCutValueRange<t>::AliCutValueRange(t limit, bool isUpper):
64 * Constructor, producing a range closed to both sides
66 * @param limit: the limit to be set
67 * @param isUpper: defining whether the limit is the upper (case true) or lower limit
80 //______________________________________________________________________________
82 bool AliCutValueRange<t>::IsInRange(t value) const {
84 * Check whether value is within a given range
86 * @param value: value to be checked
87 * @return: comparison result
90 if(fHasLimit[0] && fHasLimit[1]){
91 // Double-sided limited
92 result = fNegate ? (value < fLimits[0] || value > fLimits[1]) : (value > fLimits[0] && value < fLimits[1]);
93 } else if(fHasLimit[1]) {
95 result = fNegate ? (value > fLimits[1]) : (value < fLimits[1]);
96 } else if(fHasLimit[0]){
98 result = fNegate ? (value < fLimits[0]) : (value > fLimits[0]);
103 template class AliCutValueRange<int>;
104 template class AliCutValueRange<double>;
105 template class AliCutValueRange<float>;