]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
OADB Classes for the physics selection and filling scheme
authormfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Apr 2011 09:17:42 +0000 (09:17 +0000)
committermfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Apr 2011 09:17:42 +0000 (09:17 +0000)
OADB/AliOADBFillingScheme.cxx [new file with mode: 0644]
OADB/AliOADBFillingScheme.h [new file with mode: 0644]
OADB/AliOADBPhysicsSelection.cxx [new file with mode: 0644]
OADB/AliOADBPhysicsSelection.h [new file with mode: 0644]

diff --git a/OADB/AliOADBFillingScheme.cxx b/OADB/AliOADBFillingScheme.cxx
new file mode 100644 (file)
index 0000000..bade3c0
--- /dev/null
@@ -0,0 +1,112 @@
+//-------------------------------------------------------------------------
+//     OADB container for filling scheme information (BX ids, name ...)
+//     Author: Michele Floris, CERN
+//-------------------------------------------------------------------------
+
+#include "AliOADBFillingScheme.h"
+#include "TMap.h"
+#include "AliLog.h"
+#include "TBrowser.h"
+#include "TFolder.h"
+#include <iostream>
+
+using namespace std;
+
+ClassImp(AliOADBFillingScheme)
+
+
+AliOADBFillingScheme::AliOADBFillingScheme() : TNamed("AliOADBFillingScheme", "OADB object storing filling scheme infos"), fFSName(""), fBXIds(0){
+  // default ctor
+
+  
+}
+AliOADBFillingScheme::AliOADBFillingScheme(char* name) : TNamed(name, "OADB object storing filling scheme infos"), fFSName(""), fBXIds(0){
+  // ctor
+  Init();
+}
+
+void AliOADBFillingScheme::Init() {
+  // initialize pointers
+  fBXIds = new TMap();
+  fFSName = "";
+
+}
+
+AliOADBFillingScheme::~AliOADBFillingScheme(){
+  // dtor
+
+  if(fBXIds)           delete fBXIds;
+
+}
+
+AliOADBFillingScheme::AliOADBFillingScheme(const AliOADBFillingScheme& cont) {
+  // Copy ctor
+  AliError("To be implemented");
+}
+
+AliOADBFillingScheme& AliOADBFillingScheme::operator=(const AliOADBFillingScheme& cont) {
+  //Assignment operator
+  AliError("To be implemented");
+}
+  
+// Getters
+
+const char *  AliOADBFillingScheme::GetBXIDs(const char * beamSide) const 
+{
+  //  Returns the bunch crossing numbers for the different beam classes. By default this is empty
+
+  if (!strcmp(beamSide, "AC")) {
+
+    TString  bxa =  ((TObjString*)fBXIds->GetValue("A"))->String(); 
+    TString  bxc =  ((TObjString*)fBXIds->GetValue("C"))->String();
+    if(!bxa && !bxc) return "";
+    if(!bxc)         return bxa.Data();
+    if(!bxa)         return bxa.Data();
+    TString bxBoth = bxa.Data();
+    bxBoth += bxc.Data();
+    return bxBoth.Data();
+
+  } 
+
+  TString  bx =  ((TObjString*)fBXIds->GetValue(beamSide))->String(); 
+  if(!bx) return "";
+  return bx.Data();
+  
+}
+
+void AliOADBFillingScheme::Browse(TBrowser *b)
+{
+   // Browse this object.
+   // If b=0, there is no Browse call TObject::Browse(0) instead.
+   //         This means TObject::Inspect() will be invoked indirectly
+
+
+  if (b) {
+    // Creates a folder for each beam type containing the list of corresponding bx ids
+    b->Add(new TObjString(Form("Filling Scheme %s",GetFillingSchemeName())));
+    TIterator * mapIter = fBXIds->MakeIterator();
+    TObjString * key = 0;
+    while ((key = (TObjString*) mapIter->Next())) {
+      TFolder * folder = new TFolder(key->String().Data(), "beam side");
+      TObjString * value = (TObjString*) fBXIds->GetValue(key);
+      TObjArray * tokens = value->String().Tokenize(" ");
+      TIterator * tokIter = tokens->MakeIterator();
+      TObjString * bxNum = 0;
+      while ((bxNum = (TObjString*) tokIter->Next())){
+       folder->Add(bxNum);
+      }
+      b->Add(folder);
+      delete tokIter;
+    }
+    delete mapIter;    
+  }     
+  else
+    TObject::Browse(b);
+}
+
+void AliOADBFillingScheme::Print(Option_t* option) const {
+  // Print Class contents
+  // Option is passed to TMap::Print
+  cout << "Filling scheme Name " <<  fFSName.Data() << endl;
+  fBXIds->Print(option);
+}
diff --git a/OADB/AliOADBFillingScheme.h b/OADB/AliOADBFillingScheme.h
new file mode 100644 (file)
index 0000000..7c6e778
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef AliOADBFillingScheme_H
+#define AliOADBFillingScheme_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//     OADB container for filling scheme information (BX ids, name ...)
+//     Author: Michele Floris, CERN
+//-------------------------------------------------------------------------
+
+#include <TNamed.h>
+#include "TMap.h"
+#include "TObjString.h"
+
+
+class AliOADBFillingScheme : public TNamed {
+
+ public :
+  AliOADBFillingScheme();
+  AliOADBFillingScheme(char* name);
+  virtual ~AliOADBFillingScheme();
+  AliOADBFillingScheme(const AliOADBFillingScheme& cont); 
+  AliOADBFillingScheme& operator=(const AliOADBFillingScheme& cont);
+  void Init();
+  
+  // Getters
+  const char * GetBXIDs(const char * beamSide) const; 
+  const char * GetFillingSchemeName() const { return fFSName; } 
+  // Setters
+  void SetBXIDs(const char * beamSide, const char * bxids) { fBXIds->Add(new TObjString(beamSide), new TObjString(bxids)); }
+  void SetFillingSchemeName(const char * name) { fFSName = name; }
+  // Browse
+  virtual Bool_t       IsFolder() const { return kTRUE; }
+  void Browse(TBrowser *b);
+  // Print
+  virtual void Print(Option_t* option = "") const;
+
+ private :
+  
+  TString fFSName               ; // Name of the filling scheme 
+  TMap * fBXIds              ; // Map from the beam side bunch crossing number. Beam side is "B", "A", "C", "E".
+
+  ClassDef(AliOADBFillingScheme, 1);
+};
+
+#endif
diff --git a/OADB/AliOADBPhysicsSelection.cxx b/OADB/AliOADBPhysicsSelection.cxx
new file mode 100644 (file)
index 0000000..05f22bf
--- /dev/null
@@ -0,0 +1,250 @@
+#include "AliOADBPhysicsSelection.h"
+#include "TList.h"
+#include "TString.h"
+#include "TObjString.h"
+#include "AliLog.h"
+#include "TBrowser.h"
+#include "TFolder.h"
+#include "TIterator.h"
+#include <iostream>
+
+using namespace std;
+
+ClassImp(AliOADBPhysicsSelection)
+
+
+AliOADBPhysicsSelection::AliOADBPhysicsSelection() : 
+TNamed("AliOADBPhysicsSelection", "OADB object for the physics selection"), fNtriggerBits(NTRIGGERBITS), fNtriggerLogics(NTRIGGERLOGICS),fCollTrigClasses(0),fBGTrigClasses(0),fHardwareTrigger(0),fOfflineTrigger(0),fBeamSide(0)
+{
+  // default ctor
+  
+}
+AliOADBPhysicsSelection::AliOADBPhysicsSelection(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
+  Init();
+}
+
+void AliOADBPhysicsSelection::Init() {
+  //Initialization of pointers
+
+  if(fCollTrigClasses) {
+    AliInfo("Already initialized");
+    return;
+  }
+
+  fNtriggerBits = NTRIGGERBITS;
+  fCollTrigClasses = new TList*[fNtriggerBits];
+  fBGTrigClasses   = new TList*[fNtriggerBits];
+  fHardwareTrigger = new TObjString[fNtriggerLogics];
+  fOfflineTrigger  = new TObjString[fNtriggerLogics];  
+  fBeamSide = new TMap;
+  for(UInt_t ibit = 0; ibit < fNtriggerBits; ibit++){
+    fCollTrigClasses[ibit] = new TList;
+    fBGTrigClasses  [ibit] = new TList;
+  }
+  for(UInt_t ilogic = 0; ilogic < fNtriggerLogics; ilogic++){
+    fHardwareTrigger[ilogic] = "";
+    fOfflineTrigger [ilogic] = "";
+  }
+  
+
+}
+
+AliOADBPhysicsSelection::~AliOADBPhysicsSelection(){
+  // dtor
+
+  if(fHardwareTrigger) delete [] fHardwareTrigger;
+  if(fOfflineTrigger)  delete [] fOfflineTrigger ;
+  
+  for(Int_t ibit = 0; ibit < NTRIGGERBITS; ibit++){
+    
+    if(fCollTrigClasses)
+      if(fCollTrigClasses[ibit]) delete fCollTrigClasses[ibit];
+    if(fBGTrigClasses)
+      if(fBGTrigClasses  [ibit]) delete fBGTrigClasses  [ibit];
+  }
+
+}
+
+AliOADBPhysicsSelection::AliOADBPhysicsSelection(const AliOADBPhysicsSelection& cont) :TNamed("AliOADBPhysicsSelection", "OADB object for the physics selection"), fNtriggerBits(NTRIGGERBITS), fNtriggerLogics(NTRIGGERLOGICS),fCollTrigClasses(0),fBGTrigClasses(0),fHardwareTrigger(0),fOfflineTrigger(0),fBeamSide(0) {
+  // Copy ctor
+  fCollTrigClasses = cont.fCollTrigClasses;
+  fBGTrigClasses = cont.fBGTrigClasses;
+  fHardwareTrigger = cont.fHardwareTrigger;
+  fOfflineTrigger = cont.fOfflineTrigger;
+  fBeamSide = cont.fBeamSide;
+  
+}
+
+AliOADBPhysicsSelection& AliOADBPhysicsSelection::operator=(const AliOADBPhysicsSelection& other)  {
+  //Assignment operator
+  TNamed::operator=(other);
+
+  fCollTrigClasses = other.fCollTrigClasses;
+  fBGTrigClasses = other.fBGTrigClasses;
+  fHardwareTrigger = other.fHardwareTrigger;
+  fOfflineTrigger = other.fOfflineTrigger;
+  fBeamSide = other.fBeamSide;
+  
+
+  return *this;
+}
+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));
+  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));
+  fBGTrigClasses  [GetActiveBit(triggerMask)]->Add(tclass);
+  SetBeamSide(tclass->String().Data(),beamSide);
+}
+
+const TString AliOADBPhysicsSelection::GetBeamSide (const char * trigger)  {
+  // Associate beam site to trigger class name
+  TObjString * cname = new TObjString(trigger);
+  CleanKey(cname->String());  
+  static TString retValue="";
+  retValue = ((TObjString*)fBeamSide->GetValue(cname->String().Data())) ?  
+    ((TObjString*)fBeamSide->GetValue(cname->String().Data()))->String() : "" ;
+  delete cname;
+  return retValue;
+}
+void AliOADBPhysicsSelection::SetBeamSide (const char * className, const char * side)
+{ 
+  // return beam side
+  TObjString * cname = new TObjString(className);
+  CleanKey(cname->String());
+  fBeamSide->Add(new TObjString(cname->String().Data()), new TObjString(side));
+  delete cname;
+}
+
+void AliOADBPhysicsSelection::CleanKey(TString & str) {
+
+  //  Remove all wite spacese 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)
+    str.Remove(str.Index("#")); // keep only the class name (no bx, offline trigger...)   
+  if(str.Index("&")>0)
+    str.Remove(str.Index("&")); // keep only the class name (no bx, offline trigger...)   
+  str.ReplaceAll(" ","");
+
+}
+// Getters
+
+// FIXME: decide about these getters
+// TList * AliOADBPhysicsSelection::GetCollTrigClass(AliVEvent::EOfflineTriggerTypes trig) const { 
+//   // Returns list of collision trigger classes for the requested bits
+//   return GetTrigClass(trig,fCollTrigClasses);
+// }
+
+// TList * AliOADBPhysicsSelection::GetBGTrigClass(AliVEvent::EOfflineTriggerTypes trig) const { 
+//   // Returns list of background trigger classes for the requested bits
+//   return GetTrigClass(trig,fBGTrigClasses);
+// }
+
+// TList * AliOADBPhysicsSelection::GetTrigClass(AliVEvent::EOfflineTriggerTypes trig, TList ** listClasses) const { 
+//   // Returns list of trigger classes for the requested bits
+
+//   TList * list= new TList;  
+//   // Check which bits are on and build the final list
+//   for(UInt_t ibit = 0; ibit < fNtriggerBits; ibit++){
+//     if ((trig&(0x1<<ibit))) {
+//       if(listClasses[ibit]) list->AddAll(listClasses[ibit]);
+//       else AliError(Form("List %d not initialized?",ibit));
+//     }
+//   }
+  
+//   return list;
+// }
+
+void AliOADBPhysicsSelection::Print(Option_t* option) const {
+
+  for(UInt_t ibit = 0; ibit < fNtriggerBits; ibit++){
+    cout << "Bit " << ibit << endl;
+    
+    fCollTrigClasses[ibit]->Print(option);
+    fBGTrigClasses[ibit]->Print(option);
+    cout << "HW trig " << fHardwareTrigger[ibit].String().Data() << endl;
+    cout << "Offline trig " << fHardwareTrigger[ibit].String().Data() << endl;
+    
+  }
+  cout << "Beams: " << endl;
+  fBeamSide->Print();
+
+}
+
+
+void AliOADBPhysicsSelection::Browse(TBrowser *b)
+{
+   // Browse this object.
+   // If b=0, there is no Browse call TObject::Browse(0) instead.
+   //         This means TObject::Inspect() will be invoked indirectly
+
+  TFolder  ** bitFolders = new TFolder*[fNtriggerBits];
+
+  if (b) {
+    for(UInt_t ibit = 0; ibit < fNtriggerBits; ibit++){
+      //      if(bitFolders[ibit]) delete bitFolders[ibit];
+      bitFolders[ibit] = new TFolder (Form("Bit %2.2d", ibit), "Trigger bit folder");
+      for(UInt_t ilogic = 0; ilogic < fNtriggerLogics; ilogic++){
+       if(GetHardwareTrigger(ilogic) != "" ||  GetOfflineTrigger(ilogic) != "")  {
+         bitFolders[ibit]->Add(new TObjString(Form("Hardware Trig    [*%d][%s]",ilogic,GetHardwareTrigger(ilogic).Data())));
+         bitFolders[ibit]->Add(new TObjString(Form("Offline  Trig    [*%d][%s]",ilogic,GetOfflineTrigger(ilogic).Data())));      
+       }
+      }
+      
+      TIterator *itColl = fCollTrigClasses[ibit]->MakeIterator();
+      TObjString * coll = 0;
+
+      while ((coll = (TObjString*)itColl->Next())) {
+       bitFolders[ibit]->Add(new TObjString(Form("Collision Class  [%s] [%s]", coll->String().Data(), 
+                                                 GetBeamSide(coll->String().Data()).Data())));
+      }
+
+      TIterator *itBG = fBGTrigClasses[ibit]->MakeIterator();
+      TObjString * bg = 0;
+      while ((bg = (TObjString*)itBG->Next())) {
+       bitFolders[ibit]->Add(new TObjString(Form("Background Class [%s] [%s]", bg->String().Data(), 
+                                                 GetBeamSide(bg->String().Data()).Data())));
+      }
+
+
+      b->Add(bitFolders[ibit]);
+
+    }    
+  }     
+   else
+      TObject::Browse(b);
+}
+
+const 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.
+  // If no bit is on, prints an error and returns 0
+
+  Int_t nbit = sizeof(mask)*8;
+  Int_t activeBit = -1;
+  for(Int_t ibit = 0; ibit < nbit; ibit++){
+    if ( mask & (0x1 << ibit) ) {
+      if (activeBit == -1) activeBit = ibit;
+      else Printf("ERROR (AliTriggerAnalysis::GetActiveBit): More than one bit is on in this mask 0x%x", mask);
+    }
+  }
+  if (activeBit == -1) {
+    Printf("ERROR (AliTriggerAnalysis::GetActiveBit): No bit is on");
+    activeBit=0;
+  }
+
+  return activeBit;
+
+}
diff --git a/OADB/AliOADBPhysicsSelection.h b/OADB/AliOADBPhysicsSelection.h
new file mode 100644 (file)
index 0000000..4e218fc
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef AliOADBPhysicsSelection_H
+#define AliOADBPhysicsSelection_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//     OADB interface for the physics selection
+//     Author: Michele Floris, CERN
+//    
+// This class contains the parameters needed to configure the physics
+// selection. The online trigger class must be associated to an
+// offline trigger mask, as defined in
+// AliVEvent::EOfflineTriggerTypes.  The offline condition, even for
+// the same trigger mask, can be different for every different online
+// trigger, so it must be given as a parameter in the Add...Class
+// methods.  It's up to the user to set the appropriate offline
+// conditions when filling the class.
+// -------------------------------------------------------------------------
+
+#include <TNamed.h>
+#include "AliVEvent.h"
+#include "TList.h"
+#include "TMap.h"
+
+class TObjArray;
+class TArrayI;
+
+
+#define NTRIGGERBITS   32
+#define NTRIGGERLOGICS 64
+
+class AliOADBPhysicsSelection : public TNamed {
+
+ public :
+  AliOADBPhysicsSelection();
+  AliOADBPhysicsSelection(char* name);
+  virtual ~AliOADBPhysicsSelection();
+  AliOADBPhysicsSelection(const AliOADBPhysicsSelection& cont); 
+  AliOADBPhysicsSelection& operator=(const AliOADBPhysicsSelection& cont);
+  void Init();
+  // Getters
+  // These take a mask of trigger bits, because you can activate several triggers at once
+  // TList * GetCollTrigClass(AliVEvent::EOfflineTriggerTypes trig) const; 
+  // TList * GetBGTrigClass(AliVEvent::EOfflineTriggerTypes trig) const;    
+  // TList * GetTrigClass(AliVEvent::EOfflineTriggerTypes trig, TList ** listClasses) const ; 
+
+  TList * GetCollTrigClass(UInt_t triggerBit) { return fCollTrigClasses[triggerBit];}
+  TList * GetBGTrigClass(UInt_t triggerBit)   { return fBGTrigClasses[triggerBit];  }
+  const TString GetBeamSide (const char * trigger) ;
+  TMap * Debug() { return fBeamSide; }
+  // Thess take a single trigger bit, as the HW/offline conditions are mapped 1 <-> 1 to a single EOfflineTriggerTypes bit
+  const TString  GetHardwareTrigger(UInt_t triggerLogic) const { return triggerLogic >= NTRIGGERLOGICS ? "" : fHardwareTrigger[triggerLogic].String(); }
+  const TString  GetOfflineTrigger (UInt_t triggerLogic) const { return triggerLogic >= NTRIGGERLOGICS ? "" : fOfflineTrigger [triggerLogic].String(); }
+  const UInt_t GetNTriggerBits()  const { return fNtriggerBits; }
+  // Setters 
+  void AddCollisionTriggerClass(AliVEvent::EOfflineTriggerTypes triggerMask, const char* className,const char * beamSide, UInt_t triggerLogic);
+  void AddBGTriggerClass       (AliVEvent::EOfflineTriggerTypes triggerMask, const char* className,const char * beamSide, UInt_t triggerLogic);
+
+
+  void SetHardwareTrigger      (UInt_t triggerLogic, const char * trigger)  { fHardwareTrigger [triggerLogic].SetString(trigger);     }
+  void SetOfflineTrigger       (UInt_t triggerLogic, const char * trigger)  { fOfflineTrigger  [triggerLogic].SetString(trigger);     }
+  void SetBeamSide             (const char * className, const char * side);
+  // MISC
+  virtual Bool_t       IsFolder() const { return kTRUE; }
+  void Browse(TBrowser *b);
+  virtual void Print(Option_t* option = "") const;
+
+protected:
+  void CleanKey(TString & str) ;
+  static const UInt_t GetActiveBit(UInt_t mask) ;
+ private :
+  
+  UInt_t fNtriggerBits; // Size of the arrays below. Initialized using NTRIGGERBITS
+  UInt_t fNtriggerLogics; // number of possible trigger logics, initialized using NTRIGGERLOGICS. To be increased if needed.
+
+  TList ** fCollTrigClasses  ; //[fNtriggerBits] Array of collision trigger classes, corresponding to the different trigger bits defined in AliVEvent
+  TList ** fBGTrigClasses    ; //[fNtriggerBits] Array of background trigger classes, corresponding to the different trigger bits defined in AliVEvent
+  TObjString * fHardwareTrigger ; //[fNtriggerLogics] Array of online trigger condition, corresponding to the different trigger logics set in Add...TriggerClass
+  TObjString * fOfflineTrigger  ; //[fNtriggerLogics] Array of offline trigger condition, corresponding to the different trigger logics set in Add...TriggerClass
+  TMap * fBeamSide;             // Map from the trigger classname to the beam side ("B", "A", "C", "E", "AC")
+  ClassDef(AliOADBPhysicsSelection, 1);
+};
+
+#endif