]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDetectorTagCuts.cxx
Swapped the names AliMagFCheb and AliMagWrapCheb. The former should be used
[u/mrichter/AliRoot.git] / STEER / AliDetectorTagCuts.cxx
1 /**************************************************************************
2  * Author: Panos Christakoglou.                                           *
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 /* $Id$ */
15
16 //-----------------------------------------------------------------
17 //                   AliDetectorTagCuts class
18 //   This is the class to deal with the Detector tag level cuts
19 //   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
21
22 class AliLog;
23
24 #include "AliDetectorTag.h"
25 #include "AliDetectorTagCuts.h"
26
27 #include "TObjString.h"
28 #include "TString.h"
29
30 ClassImp(AliDetectorTagCuts)
31
32 //___________________________________________________________________________
33 AliDetectorTagCuts::AliDetectorTagCuts() :
34   TObject(),
35   fDetectors(0), 
36   fDetectorsFlag(kFALSE)
37 {
38   //Default constructor which calls the Reset method.
39 }
40
41 //___________________________________________________________________________
42 AliDetectorTagCuts::~AliDetectorTagCuts() {  
43   //Defaut destructor.
44 }
45
46 //___________________________________________________________________________
47 Bool_t AliDetectorTagCuts::IsAccepted(AliDetectorTag *detTag) const {
48   //Returns true if the event is accepted otherwise false.
49   TString detStr = fDetectors;
50   TObjArray *activeDetectors = detTag->GetDetectorMask();
51   TString listOfDetectors[15];
52   for (Int_t iDet = 0; iDet < activeDetectors->GetEntries(); iDet++) {
53     TObjString *detectorString = (TObjString *)activeDetectors->At(iDet);
54     listOfDetectors[iDet] = detectorString->GetString();
55   }
56   if(fDetectorsFlag) {
57     for (Int_t iDet = 0; iDet < activeDetectors->GetEntries(); iDet++) {
58       if (!IsSelected(listOfDetectors[iDet], detStr)) return kFALSE; }
59   }
60   return kTRUE;
61 }
62
63 //___________________________________________________________________________
64 Bool_t AliDetectorTagCuts::IsSelected(TString detName, TString& detectors) const {
65   //Returns true if the detector is included
66   if ((detectors.CompareTo("ALL") == 0) ||
67       detectors.BeginsWith("ALL ") ||
68       detectors.EndsWith(" ALL") ||
69       detectors.Contains(" ALL ")) {
70     detectors = "ALL";
71     return kTRUE;
72   }
73   
74   // search for the given detector
75   Bool_t result = kFALSE;
76   if ((detectors.CompareTo(detName) == 0) ||
77       detectors.BeginsWith(detName+" ") ||
78       detectors.EndsWith(" "+detName) ||
79       detectors.Contains(" "+detName+" ")) {
80     detectors.ReplaceAll(detName, "");
81     result = kTRUE;
82   }
83
84   // clean up the detectors string
85   while (detectors.Contains("  ")) detectors.ReplaceAll("  ", " ");
86   while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
87   while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
88  
89   return result;
90 }