]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - OADB/AliOADBPhysicsSelection.cxx
Bringing CMakeLists under svn maintenance
[u/mrichter/AliRoot.git] / OADB / AliOADBPhysicsSelection.cxx
index c5ef84eb2b55dc1244d6a77ed0819e38f1ee8ad9..6aa685c99c1340cd7178afd63c8853f6108c60b8 100644 (file)
@@ -19,7 +19,7 @@ TNamed("AliOADBPhysicsSelection", "OADB object for the physics selection"), fNtr
   // default ctor
   
 }
-AliOADBPhysicsSelection::AliOADBPhysicsSelection(char* name) : 
+AliOADBPhysicsSelection::AliOADBPhysicsSelection(const char* name) : 
   TNamed(name, "OADB object for the physics selection"), fNtriggerBits(NTRIGGERBITS), fNtriggerLogics(NTRIGGERLOGICS),fCollTrigClasses(0),fBGTrigClasses(0),fHardwareTrigger(0),fOfflineTrigger(0),fBeamSide(0)
 {
   // ctor, better use this one
@@ -80,6 +80,7 @@ AliOADBPhysicsSelection::AliOADBPhysicsSelection(const AliOADBPhysicsSelection&
 
 AliOADBPhysicsSelection& AliOADBPhysicsSelection::operator=(const AliOADBPhysicsSelection& other)  {
   //Assignment operator
+  if(&other == this) return *this;
   TNamed::operator=(other);
 
   fCollTrigClasses = other.fCollTrigClasses;
@@ -94,20 +95,20 @@ AliOADBPhysicsSelection& AliOADBPhysicsSelection::operator=(const AliOADBPhysics
  
 void AliOADBPhysicsSelection::AddCollisionTriggerClass(AliVEvent::EOfflineTriggerTypes triggerMask, const char* className,const char * beamSide, UInt_t triggerLogic) {
   // add collision trigger class
-  TObjString * tclass = new TObjString(Form("%s &%u *%u",className,triggerMask, triggerLogic));
+  TObjString * tclass = new TObjString(Form("%s &%u *%u",ExpandTriggerString(className),triggerMask, triggerLogic));
   fCollTrigClasses[GetActiveBit(triggerMask)]->Add(tclass); 
   SetBeamSide(tclass->String().Data(),beamSide);
 }
 void AliOADBPhysicsSelection::AddBGTriggerClass       (AliVEvent::EOfflineTriggerTypes triggerMask, const char* className,const char * beamSide, UInt_t triggerLogic) 
 { 
-  // add bg gtrigger class
-  TObjString * tclass = new TObjString(Form("%s &%u *%u",className,triggerMask, triggerLogic));
+  // add bg trigger class
+  TObjString * tclass = new TObjString(Form("%s &%u *%u",ExpandTriggerString(className),triggerMask, triggerLogic));
   fBGTrigClasses  [GetActiveBit(triggerMask)]->Add(tclass);
   SetBeamSide(tclass->String().Data(),beamSide);
 }
 
 const TString AliOADBPhysicsSelection::GetBeamSide (const char * trigger)  {
-  // Associate beam site to trigger class name
+  // Associate beam side to trigger class name
   TObjString * cname = new TObjString(trigger);
   CleanKey(cname->String());  
   static TString retValue="";
@@ -127,7 +128,7 @@ void AliOADBPhysicsSelection::SetBeamSide (const char * className, const char *
 
 void AliOADBPhysicsSelection::CleanKey(TString & str) {
 
-  //  Remove all wite spacese and "goodies" of the trigger class string (bx ids, trigger logic...)
+  //  Remove all wite spaces and "goodies" of the trigger class string (bx ids, trigger logic...)
   if(str.Index("*")>0)
     str.Remove(str.Index("*")); // keep only the class name (no bx, offline trigger...)   
   if(str.Index("#")>0)
@@ -234,7 +235,7 @@ void AliOADBPhysicsSelection::Browse(TBrowser *b)
       TObject::Browse(b);
 }
 
-const UInt_t AliOADBPhysicsSelection::GetActiveBit(UInt_t mask) {
+UInt_t AliOADBPhysicsSelection::GetActiveBit(UInt_t mask) {
   // Returns the active bit index in the mask
   // Assumes only one bit is on.
   // If more than one bit is lit, prints an error and returns the first.
@@ -259,3 +260,83 @@ const UInt_t AliOADBPhysicsSelection::GetActiveBit(UInt_t mask) {
   return activeBit;
 
 }
+
+const char* AliOADBPhysicsSelection::ExpandTriggerString(const char* className)
+{
+  // expands [] syntax
+  // E.g. +CVHN-B-[NOPF|PF]-[ALL|CENT]NOTRD goes to +CVHN-B-NOPF-ALLNOTRD,CVHN-B-NOPF-CENTNOTRD,CVHN-B-PF-ALLNOTRD,CVHN-B-PF-CENTNOTRD
+  
+  static TString str;
+  str = className;
+  TObjArray* triggers = str.Tokenize(" ");
+  for (Int_t j=0; j<triggers->GetEntries(); j++)
+  {
+    str = triggers->At(j)->GetName();
+    str = str(1, str.Length());
+    
+    TList list;
+    list.SetOwner();
+
+    TObjArray* triggers2 = str.Tokenize(",");
+    for (Int_t k=0; k<triggers2->GetEntries(); k++)
+      list.Add(new TObjString(triggers2->At(k)->GetName()));
+    delete triggers2;
+    
+//     list.Print();
+    
+    while (1)
+    {
+      Int_t i=0;
+      for (i=0; i<list.GetEntries(); i++)
+      {
+       str = list.At(i)->GetName();
+      
+       Int_t begin = str.Index("[");
+       Int_t end = str.Index("]");
+       if (begin >= 0 && end >= 0)
+       {
+         TString before = str(0, begin);
+         TString after = str(end+1, str.Length());
+         TString tokens = str(begin+1, end-begin-1);
+  //   Printf("%s %s %s", before.Data(), tokens.Data(), after.Data());
+         Int_t pos = 0;
+         while (tokens.Index("|", pos) >= 0)
+         {
+           list.Add(new TObjString(before + tokens(pos, tokens.Index("|", pos) - pos) + after));
+           pos = tokens.Index("|", pos) + 1;
+         }
+         list.Add(new TObjString(before + tokens(pos, tokens.Length()) + after));
+         delete list.RemoveAt(i);
+         
+  //   list.Print();
+         i=-1;
+       }
+      }
+
+      str = "";
+      for (i=0; i<list.GetEntries(); i++)
+      {
+       str += list.At(i)->GetName();
+       str += ",";
+      }
+      str = str(0, str.Length() - 1);
+      break;
+    }
+      
+    TString& target = ((TObjString*) triggers->At(j))->String();
+    target.Form("%c%s", target[0], str.Data());
+  }
+  
+  str = "";
+  for (Int_t j=0; j<triggers->GetEntries(); j++)
+  {
+    str += triggers->At(j)->GetName();
+    str += " ";
+  }
+  str = str(0, str.Length() - 1);
+
+  delete triggers;
+  if (strcmp(className, str.Data()))
+    Printf("AliOADBPhysicsSelection::ExpandTriggerString: In: <%s> Out: <%s>", className, str.Data());
+  return str;
+}