ROOT logo
/**************************************************************************
 * Author: Panos Christakoglou.                                           *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */

//-----------------------------------------------------------------
//                   AliDetectorTagCuts class
//   This is the class to deal with the Detector tag level cuts
//   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
//-----------------------------------------------------------------

class AliLog;

#include "AliDetectorTag.h"
#include "AliDetectorTagCuts.h"

#include "TObjString.h"
#include "TString.h"

ClassImp(AliDetectorTagCuts)

//___________________________________________________________________________
AliDetectorTagCuts::AliDetectorTagCuts() :
  TObject(),
  fDetectorsReco(0),
  fDetectorsDAQ(0),
  fDetectorsFlag(kFALSE),
  fDetectorValidityMatch(),
  fDetectorValidityFlag()
{
  //Default constructor which calls the Reset method.
  for (int iter = 0; iter<AliDAQ::kHLTId; iter++) {
    fDetectorValidityMatch[iter] = 0;
    fDetectorValidityFlag[iter] = 0;
  }
}

//___________________________________________________________________________
AliDetectorTagCuts::~AliDetectorTagCuts() {  
  //Defaut destructor.
}

//___________________________________________________________________________
Bool_t AliDetectorTagCuts::IsAccepted(AliDetectorTag *detTag) const {
  //Returns true if the event is accepted otherwise false.
  if (fDetectorsFlag) {
    Bool_t daqsel = (detTag->GetIntDetectorMaskDAQ() & fDetectorsDAQ) > 0;
    Bool_t recsel = (detTag->GetIntDetectorMaskReco() & fDetectorsReco) > 0;
    Bool_t valsel = kTRUE;
    for (int iter=0;  iter<AliDAQ::kHLTId; iter++) {
      if (fDetectorValidityFlag[iter])
	if (!(fDetectorValidityMatch[iter] == detTag->GetDetectorValidityRange(iter)))
	  valsel = kFALSE;
    }
    return (daqsel && recsel && valsel);
  }
  return true;

//   if(fDetectorsFlag){
//     TString detStr = fDetectors;
//     TObjArray *activeDetectors = detTag->GetDetectorMask();
//     for (Int_t iDet = 0; iDet < activeDetectors->GetEntries(); iDet++) {
//       TObjString *detectorString = (TObjString *)activeDetectors->At(iDet);
//       if (!IsSelected(detectorString->GetString(), detStr))return kFALSE;
//     }
//   }
//   return kTRUE;
}
  
void AliDetectorTagCuts::SetDetectorValidityValue(TString det, UShort_t val)
{
  // Set Validity requiement for detector

  Short_t detid = AliDAQ::DetectorID(det.Data());
  if (detid >= 0) {
    fDetectorValidityMatch[detid] = val;
    fDetectorsFlag = kTRUE;
  }
}

//___________________________________________________________________________
// Bool_t AliDetectorTagCuts::IsSelected(TString detName, TString& detectors) const {
//   //Returns true if the detector is included
//   if ((detectors.CompareTo("ALL") == 0) ||
//       detectors.BeginsWith("ALL ") ||
//       detectors.EndsWith(" ALL") ||
//       detectors.Contains(" ALL ")) {
//     detectors = "ALL";
//     return kTRUE;
//   }
  
//   // search for the given detector
//   Bool_t result = kFALSE;
//   if ((detectors.CompareTo(detName) == 0) ||
//       detectors.BeginsWith(detName+" ") ||
//       detectors.EndsWith(" "+detName) ||
//       detectors.Contains(" "+detName+" ")) {
//     detectors.ReplaceAll(detName, "");
//     result = kTRUE;
//   }

//   // clean up the detectors string
//   while (detectors.Contains("  ")) detectors.ReplaceAll("  ", " ");
//   while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
//   while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
 
//   return result;
// }
 AliDetectorTagCuts.cxx:1
 AliDetectorTagCuts.cxx:2
 AliDetectorTagCuts.cxx:3
 AliDetectorTagCuts.cxx:4
 AliDetectorTagCuts.cxx:5
 AliDetectorTagCuts.cxx:6
 AliDetectorTagCuts.cxx:7
 AliDetectorTagCuts.cxx:8
 AliDetectorTagCuts.cxx:9
 AliDetectorTagCuts.cxx:10
 AliDetectorTagCuts.cxx:11
 AliDetectorTagCuts.cxx:12
 AliDetectorTagCuts.cxx:13
 AliDetectorTagCuts.cxx:14
 AliDetectorTagCuts.cxx:15
 AliDetectorTagCuts.cxx:16
 AliDetectorTagCuts.cxx:17
 AliDetectorTagCuts.cxx:18
 AliDetectorTagCuts.cxx:19
 AliDetectorTagCuts.cxx:20
 AliDetectorTagCuts.cxx:21
 AliDetectorTagCuts.cxx:22
 AliDetectorTagCuts.cxx:23
 AliDetectorTagCuts.cxx:24
 AliDetectorTagCuts.cxx:25
 AliDetectorTagCuts.cxx:26
 AliDetectorTagCuts.cxx:27
 AliDetectorTagCuts.cxx:28
 AliDetectorTagCuts.cxx:29
 AliDetectorTagCuts.cxx:30
 AliDetectorTagCuts.cxx:31
 AliDetectorTagCuts.cxx:32
 AliDetectorTagCuts.cxx:33
 AliDetectorTagCuts.cxx:34
 AliDetectorTagCuts.cxx:35
 AliDetectorTagCuts.cxx:36
 AliDetectorTagCuts.cxx:37
 AliDetectorTagCuts.cxx:38
 AliDetectorTagCuts.cxx:39
 AliDetectorTagCuts.cxx:40
 AliDetectorTagCuts.cxx:41
 AliDetectorTagCuts.cxx:42
 AliDetectorTagCuts.cxx:43
 AliDetectorTagCuts.cxx:44
 AliDetectorTagCuts.cxx:45
 AliDetectorTagCuts.cxx:46
 AliDetectorTagCuts.cxx:47
 AliDetectorTagCuts.cxx:48
 AliDetectorTagCuts.cxx:49
 AliDetectorTagCuts.cxx:50
 AliDetectorTagCuts.cxx:51
 AliDetectorTagCuts.cxx:52
 AliDetectorTagCuts.cxx:53
 AliDetectorTagCuts.cxx:54
 AliDetectorTagCuts.cxx:55
 AliDetectorTagCuts.cxx:56
 AliDetectorTagCuts.cxx:57
 AliDetectorTagCuts.cxx:58
 AliDetectorTagCuts.cxx:59
 AliDetectorTagCuts.cxx:60
 AliDetectorTagCuts.cxx:61
 AliDetectorTagCuts.cxx:62
 AliDetectorTagCuts.cxx:63
 AliDetectorTagCuts.cxx:64
 AliDetectorTagCuts.cxx:65
 AliDetectorTagCuts.cxx:66
 AliDetectorTagCuts.cxx:67
 AliDetectorTagCuts.cxx:68
 AliDetectorTagCuts.cxx:69
 AliDetectorTagCuts.cxx:70
 AliDetectorTagCuts.cxx:71
 AliDetectorTagCuts.cxx:72
 AliDetectorTagCuts.cxx:73
 AliDetectorTagCuts.cxx:74
 AliDetectorTagCuts.cxx:75
 AliDetectorTagCuts.cxx:76
 AliDetectorTagCuts.cxx:77
 AliDetectorTagCuts.cxx:78
 AliDetectorTagCuts.cxx:79
 AliDetectorTagCuts.cxx:80
 AliDetectorTagCuts.cxx:81
 AliDetectorTagCuts.cxx:82
 AliDetectorTagCuts.cxx:83
 AliDetectorTagCuts.cxx:84
 AliDetectorTagCuts.cxx:85
 AliDetectorTagCuts.cxx:86
 AliDetectorTagCuts.cxx:87
 AliDetectorTagCuts.cxx:88
 AliDetectorTagCuts.cxx:89
 AliDetectorTagCuts.cxx:90
 AliDetectorTagCuts.cxx:91
 AliDetectorTagCuts.cxx:92
 AliDetectorTagCuts.cxx:93
 AliDetectorTagCuts.cxx:94
 AliDetectorTagCuts.cxx:95
 AliDetectorTagCuts.cxx:96
 AliDetectorTagCuts.cxx:97
 AliDetectorTagCuts.cxx:98
 AliDetectorTagCuts.cxx:99
 AliDetectorTagCuts.cxx:100
 AliDetectorTagCuts.cxx:101
 AliDetectorTagCuts.cxx:102
 AliDetectorTagCuts.cxx:103
 AliDetectorTagCuts.cxx:104
 AliDetectorTagCuts.cxx:105
 AliDetectorTagCuts.cxx:106
 AliDetectorTagCuts.cxx:107
 AliDetectorTagCuts.cxx:108
 AliDetectorTagCuts.cxx:109
 AliDetectorTagCuts.cxx:110
 AliDetectorTagCuts.cxx:111
 AliDetectorTagCuts.cxx:112
 AliDetectorTagCuts.cxx:113
 AliDetectorTagCuts.cxx:114
 AliDetectorTagCuts.cxx:115
 AliDetectorTagCuts.cxx:116
 AliDetectorTagCuts.cxx:117
 AliDetectorTagCuts.cxx:118