]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/trigger/AliHLTTriggerBarrelMultiplicity.cxx
Pileup histograms, asymmetry for pi0 and eta corrected.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerBarrelMultiplicity.cxx
index 784f2d325d9e582b1674d9180e544a1b201e8057..680e3f7429aebfb202ada7fc207740a97890f1c2 100644 (file)
@@ -4,6 +4,7 @@
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //*                                                                        *
 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  Jochen Thaeder <jochen@thaeder.de>                    *
 //*                  for The ALICE HLT Project.                            *
 //*                                                                        *
 //* Permission to use, copy, modify and distribute this software and its   *
@@ -16,7 +17,7 @@
 //**************************************************************************
 
 /// @file   AliHLTTriggerBarrelMultiplicity.cxx
-/// @author Matthias Richter
+/// @author Matthias Richter, Jochen Thaeder
 /// @date   2009-06-30
 /// @brief  HLT trigger component for charged particle multiplicity in
 ///         the central barrel.
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 
 #include "AliHLTTriggerBarrelMultiplicity.h"
+#include "AliHLTESDTrackCuts.h"
+#include "AliESDtrack.h"
 #include "AliESDEvent.h"
 #include "AliHLTTriggerDecision.h"
 #include "AliHLTDomainEntry.h"
 #include "AliHLTGlobalBarrelTrack.h"
+#include "AliHLTErrorGuard.h"
 #include "TObjArray.h"
 #include "TObjString.h"
 
@@ -40,26 +44,18 @@ ClassImp(AliHLTTriggerBarrelMultiplicity)
 
 AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
   : AliHLTTrigger()
-  , fPtMin(0.0)
-  , fPtMax(0.0)
+  , fHLTESDTrackCuts(NULL)
   , fMinTracks(1)
-  , fDCAReference()
-  , fMinLDca(-1.)
-  , fMaxLDca(-1.)
-  , fMinTDca(-1.)
-  , fMaxTDca(-1.)
-  , fSolenoidBz(0.0)
+  , fName()
 {
   // see header file for class documentation
   // or
   // refer to README to build package
   // or
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
-  for (int i=0; i<fgkDCAReferenceSize; i++) fDCAReference[i]=0.0;
 }
 
-const char* AliHLTTriggerBarrelMultiplicity::fgkOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
+const char* AliHLTTriggerBarrelMultiplicity::fgkDefaultOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
 
 AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
 {
@@ -69,7 +65,11 @@ AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
 const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
 {
   // see header file for class documentation
-  return "BarrelMultiplicityTrigger";
+
+  if (!fName.IsNull())
+    return fName.Data();
+  else
+    return "BarrelMultiplicityTrigger";
 }
 
 AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
@@ -81,24 +81,39 @@ AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
 int AliHLTTriggerBarrelMultiplicity::DoTrigger()
 {
   // see header file for class documentation
+
+  if (!IsDataEvent()) {
+    IgnoreEvent();  // dont generate any trigger decision.
+  }
+
   int iResult=0;
   int numberOfTracks=-1;
 
   // try the ESD as input
   const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
   AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
-  TString description;
-  TString ptcut,tdca,ldca,dcaref,op1st,op2nd;
+  
   if (esd != NULL) {
     numberOfTracks=0;
     esd->GetStdContent();
     
     for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
-      if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
+      AliESDtrack *esdTrack = esd->GetTrack(i);
+      if ( !esdTrack )
+       continue;
+
+      if ( fHLTESDTrackCuts->IsSelected(esdTrack) )
+       numberOfTracks++;
     }
   }
 
   // try the AliHLTExternal track data as input
+  // TODO: 2010-08-27
+  // AliHLTTrackCuts needs an AliESDtrack object and not just AliExternalTrackParam
+  // this part needs to be revised to work correctly with the track array as input
+  // - think about specific conversion method in AliHLTGlobalBarrelTrack
+  // - make sure that all necessary parameters are set
+  // - clarify what to do about the track flags
   if (iResult>=0 && numberOfTracks<0) {
     for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
         pBlock!=NULL; pBlock=GetNextInputBlock()) {
@@ -107,7 +122,8 @@ int AliHLTTriggerBarrelMultiplicity::DoTrigger()
       if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
        for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
             element!=tracks.end(); element++) {
-         if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
+         ALIHLTERRORGUARD(1, "component needs to be revised to work with track array as input");
+         // TODO CHECK CONDITION HERE
        }
       } else if (iResult<0) {
        HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", 
@@ -116,130 +132,101 @@ int AliHLTTriggerBarrelMultiplicity::DoTrigger()
     }
   }
 
-  if (iResult>=0 && numberOfTracks>=0) {
-    if (fPtMax>fPtMin) {
-      ptcut.Form(" %.02f GeV/c <= pt < %.02f GeV/c", fPtMin, fPtMax);
-    } else {
-      ptcut.Form(" pt >= %.02f GeV/c", fPtMin);
-    }
-
-    if (fMinTDca>=0.0) {
-      if (fMaxTDca>=0.0) {
-       tdca.Form(", %.02f<=transverse_dca<=%.02f", fMinTDca, fMaxTDca);
-      } else {
-       tdca.Form(" transverse_dca >= %.02f", fMinTDca);
-      }
-    } else if (fMaxTDca>=0.0) {
-       tdca.Form(" transverse_dca<=%.02f", fMaxTDca);
-    }
-    if (!tdca.IsNull()) {
-      if (op1st.IsNull()) op1st=" && ";
-      else op2nd=" && ";
-    }
-
-    if (fMinLDca>=0.0) {
-      if (fMaxLDca>=0.0) {
-       ldca.Form(" %.02f<=longitudinal_dca<=%.02f", fMinLDca, fMaxLDca);
-      } else {
-       ldca.Form(" longitudinal_dca >= %.02f", fMinLDca);
-      }
-    } else if (fMaxLDca>=0.0) {
-       ldca.Form(" longitudinal_dca<=%.02f", fMaxLDca);
-    }
-    if (!ldca.IsNull()) {
-      if (op1st.IsNull()) op1st=" && ";
-      else op2nd=" && ";
-    }
-
-    if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
-      dcaref.Form(" (%.01f,%.01f,%.01f)", fDCAReference[0], fDCAReference[1], fDCAReference[2]);
-    }
+  bool condition=false;
+  TString description;
 
+  if (iResult>=0 && numberOfTracks>=0) {
     if (numberOfTracks>=fMinTracks) {
-      description.Form("Event contains %d track(s) with ", numberOfTracks);
-      description+=ptcut;
-      description+=op1st;
-      description+=ldca;
-      description+=op2nd;
-      description+=tdca;
-      description+=dcaref;
-      SetDescription(description.Data());
-      // Enable the central detectors for readout.
-      GetReadoutList().Enable(
-                             AliHLTReadoutList::kITSSPD |
-                             AliHLTReadoutList::kITSSDD |
-                             AliHLTReadoutList::kITSSSD |
-                             AliHLTReadoutList::kTPC |
-                             AliHLTReadoutList::kTRD |
-                             AliHLTReadoutList::kTOF |
-                             AliHLTReadoutList::kHMPID |
-                             AliHLTReadoutList::kPHOS
-                             );
-      // Add the available HLT information for readout too.
-      GetTriggerDomain().Add("CLUSTERS", "TPC ");
-      TriggerEvent(true);
-      return 0;
+      description.Form("Event contains %d track(s) with : ", numberOfTracks);
+      description += fHLTESDTrackCuts->GetTitle();
+      condition=true;
+    } else {
+      description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d) with : ", fMinTracks);
+      description += fHLTESDTrackCuts->GetTitle();
     }
-    description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d, ", fMinTracks);
-    description+=ptcut;
-    description+=op1st;
-    description+=ldca;
-    description+=op2nd;
-    description+=tdca;
-    description+=dcaref;
-    description+=")";
   } else {
-    description.Form("No input blocks found");
+    if(IsDataEvent()) {
+      description.Form("No input blocks found");
+    } else {
+      description.Form("No DataEvent found");
+    }
   }
+  
   SetDescription(description.Data());
-  TriggerEvent(false);
+
+  // add a specific trigger decision object with initialized name
+  // the readout list however is fixed 
+  AliHLTTriggerDecision decision(
+                                condition,
+                                GetTriggerName(),
+                                GetReadoutList(),
+                                GetDescription()
+                                );
+  TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
+
   return iResult;
 }
 
-template<class T>
-bool AliHLTTriggerBarrelMultiplicity::CheckCondition(T* track, float b)
+int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
 {
   // see header file for class documentation
-  if (!track) return false;
+  int iResult=0;
 
-  // check on ptransverse momentum
-  if (TMath::Abs(track->Pt()) < fPtMin || (fPtMax>fPtMin && TMath::Abs(track->Pt()) > fPtMax)) {
-    return false;
+  // check if the -triggername argument is used
+  // the name of the trigger determines the following initialization
+  vector<const char*> remainingArgs;
+  for (int i=0; i<argc; i++) {
+    if (strcmp(argv[i], "-triggername")==0) {
+      if (++i<argc) fName=argv[i];
+      else {
+       HLTError("invalid parameter for argument '-triggername', string expected");
+       return -EINVAL;
+      }
+      continue;
+    }
+    remainingArgs.push_back(argv[i]);
   }
 
-  // check on transverse and longitudinal DCA
-  if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
-    Float_t dz[2]={0.0,0.0};
-    track->GetDZ(fDCAReference[0], fDCAReference[1], fDCAReference[2], b, dz);
-    HLTDebug("checking dca condition: transversal %f logitudinal %f", dz[0], dz[1]);
-    if (fMinTDca>=0 && TMath::Abs(dz[0])<fMinTDca) return false;
-    if (fMaxTDca>=0 && TMath::Abs(dz[0])>fMaxTDca) return false;
-    if (fMinLDca>=0 && TMath::Abs(dz[1])<fMinLDca) return false;
-    if (fMaxLDca>=0 && TMath::Abs(dz[1])>fMaxLDca) return false;
+  // get path from triggername, use default object otherwise
+  TString cdbPath;
+  if (!fName.IsNull()) {
+    cdbPath="HLT/ConfigHLT/";
+    cdbPath+=fName;
+  } else {
+    cdbPath=fgkDefaultOCDBEntry;
   }
 
-  return true;
-}
+  // -- Check if CDB object is AliHLTESDTrackCuts or TObjString 
+  //    and configure from it. Replace "-" by "_._" if needed in the cdbPath
+  iResult = ConfigureFromCDBObject(cdbPath);
 
-int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
-{
-  // see header file for class documentation
+  // -- Configure from the command line parameters if specified
+  if (iResult>=0 && argc>0)
+    iResult=ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0]));
 
-  // first configure the default
-  int iResult=0;
-  iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
+  // -- Check if we have the track cuts for triggering
+  if (!fHLTESDTrackCuts) {
+    HLTError("No AliHLTESDTrackCuts object has been created as basis for triggering.");
+    iResult=-ENOENT;
+  }
+  else {
+    if (!fName.IsNull()) {
+      if (fName.Contains("Barrel_pT_Single"))
+       fMinTracks = 1;
+    }
+  }
 
-  // configure from the command line parameters if specified
-  if (iResult>=0 && argc>0)
-    iResult=ConfigureFromArgumentString(argc, argv);
   return iResult;
-
-  fSolenoidBz=GetBz();
 }
 
 int AliHLTTriggerBarrelMultiplicity::DoDeinit()
 {
   // see header file for class documentation
+
+  if (fHLTESDTrackCuts)
+    delete fHLTESDTrackCuts;
+  fHLTESDTrackCuts = NULL;
+
   return 0;
 }
 
@@ -248,12 +235,19 @@ int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const cha
   // see header file for class documentation
 
   // configure from the specified antry or the default one
-  const char* entry=cdbEntry;
-  if (!entry || entry[0]==0) {
-    entry=fgkOCDBEntry;
+  TString cdbPath;
+  if (!cdbEntry || cdbEntry[0]==0) {
+    if (!fName.IsNull()) {
+      cdbPath="HLT/ConfigHLT/";
+      cdbPath+=fName;
+    } else {
+      cdbPath=fgkDefaultOCDBEntry;
+    }
+  } else {
+    cdbPath=cdbEntry;
   }
 
-  return ConfigureFromCDBTObjString(entry);
+  return ConfigureFromCDBObject(cdbPath);
 }
 
 int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
@@ -264,6 +258,50 @@ int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*module
   return 0;
 }
 
+Int_t AliHLTTriggerBarrelMultiplicity::ConfigureFromCDBObject(TString cdbPath)
+{
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+  TString arguments;
+
+  // -- check for "-" and replace by "_._" in the path name
+  cdbPath.ReplaceAll("-",1,"_._",3);
+
+  TObject* pCDBObject = LoadAndExtractOCDBObject(cdbPath);
+  if (pCDBObject) {
+    AliHLTESDTrackCuts *pCuts = dynamic_cast<AliHLTESDTrackCuts*>(pCDBObject);
+    if (pCuts) {
+      HLTInfo("Received AliHLTESDTrackCuts configuration object : \'%s\'", pCuts->GetTitle());
+      if (fHLTESDTrackCuts)
+       delete fHLTESDTrackCuts;
+      fHLTESDTrackCuts = pCuts;
+    }
+    else {
+      TObjString* pString = dynamic_cast<TObjString*>(pCDBObject);
+      if (pString) {
+       HLTInfo("Received configuration object string: \'%s\'", pString->GetString().Data());
+       arguments+=pString->GetString().Data();
+      } 
+      else {
+       HLTError("Configuration object \"%s\" has wrong type, required AliHLTESDTrackCuts or TObjString", cdbPath.Data());
+       iResult=-EINVAL;
+      }
+    }
+  } 
+  else {
+    HLTError("Can not fetch object \"%s\" from CDB", cdbPath.Data());
+    iResult=-ENOENT;
+  }
+  
+  if ( iResult>=0 && !arguments.IsNull() ) {
+    const Char_t* array = arguments.Data();
+    iResult = ConfigureFromArgumentString(1, &array);
+  }
+
+  return iResult;
+}
+
 int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
 {
   // see header file for class documentation
@@ -271,11 +309,24 @@ int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const c
   int i=0;
   TString argument=argv[i];
 
+  if (!fHLTESDTrackCuts)
+    fHLTESDTrackCuts = new AliHLTESDTrackCuts("AliHLTESDTrackCuts","No track cuts");
+
   // -maxpt
   if (argument.CompareTo("-maxpt")==0) {
     if (++i>=argc) return -EPROTO;
     argument=argv[i];
-    fPtMax=argument.Atof();
+
+    Float_t minPt, maxPt;
+    fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
+    maxPt = argument.Atof(); 
+    fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString title = fHLTESDTrackCuts->GetTitle();
+    if (!title.CompareTo("No track cuts")) title = "";
+    else title += " && ";
+    title += Form("p_t < %f", maxPt);
+    fHLTESDTrackCuts->SetTitle(title);
     return 2;
   }    
 
@@ -283,7 +334,17 @@ int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const c
   if (argument.CompareTo("-minpt")==0) {
     if (++i>=argc) return -EPROTO;
     argument=argv[i];
-    fPtMin=argument.Atof();
+
+    Float_t minPt, maxPt;
+    fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
+    minPt = argument.Atof(); 
+    fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
+
+    TString title = fHLTESDTrackCuts->GetTitle();
+    if (!title.CompareTo("No track cuts")) title = "";
+    else title += " && ";
+    title += Form("p_t > %f", minPt);
+    fHLTESDTrackCuts->SetTitle(title);
     return 2;
   }    
 
@@ -295,56 +356,73 @@ int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const c
     return 2;
   }    
 
-  // -dca-reference
-  // reference point for the transverse and longitudinal dca cut
-  if (argument.CompareTo("-dca-reference")==0) {
-    if (++i>=argc) return -EPROTO;
-    argument=argv[i];
-    // scan x,y,z
-    TObjArray* pTokens=argument.Tokenize("'");
-    if (pTokens) {
-      for (int c=0; c<pTokens->GetEntriesFast() && c<fgkDCAReferenceSize; c++) {
-       argument=((TObjString*)pTokens->At(c))->GetString();
-       fDCAReference[i]=argument.Atof();
-      }
-      delete pTokens;
-    }
-    return 2;
-  }
-
   // -min-ldca
-  // minimum longitudinal dca to reference point
+  // minimum longitudinal dca to vertex
   if (argument.CompareTo("-min-ldca")==0) {
     if (++i>=argc) return -EPROTO;
     argument=argv[i];
-    fMinLDca=argument.Atof();
+
+    fHLTESDTrackCuts->SetMinDCAToVertexZ(argument.Atof());
+    TString title = fHLTESDTrackCuts->GetTitle();
+    if (!title.CompareTo("No track cuts")) title = "";
+    else title += " && ";
+    title += Form("DCAz > %f", argument.Atof());
+    fHLTESDTrackCuts->SetTitle(title);
     return 2;
   }
   
   // -max-ldca
-  // maximum longitudinal dca to reference point
+  // maximum longitudinal dca to vertex
   if (argument.CompareTo("-max-ldca")==0) {
     if (++i>=argc) return -EPROTO;
     argument=argv[i];
-    fMaxLDca=argument.Atof();
+
+    fHLTESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof());
+    TString title = fHLTESDTrackCuts->GetTitle();
+    if (!title.CompareTo("No track cuts")) title = "";
+    else title += " && ";
+    title += Form("DCAz < %f", argument.Atof());
+    fHLTESDTrackCuts->SetTitle(title);
     return 2;
   }
 
   // -min-tdca
-  // minimum transverse dca to reference point
+  // minimum transverse dca to vertex
   if (argument.CompareTo("-min-tdca")==0) {
     if (++i>=argc) return -EPROTO;
     argument=argv[i];
-    fMinTDca=argument.Atof();
+
+    fHLTESDTrackCuts->SetMinDCAToVertexXY(argument.Atof());
+    TString title = fHLTESDTrackCuts->GetTitle();
+    if (!title.CompareTo("No track cuts")) title = "";
+    else title += " && ";
+    title += Form("DCAr > %f", argument.Atof());
+    fHLTESDTrackCuts->SetTitle(title);
     return 2;
   }
   
   // -max-tdca
-  // maximum transverse dca to reference point
+  // maximum transverse dca to vertex
   if (argument.CompareTo("-max-tdca")==0) {
     if (++i>=argc) return -EPROTO;
     argument=argv[i];
-    fMaxTDca=argument.Atof();
+
+    fHLTESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof());
+    TString title = fHLTESDTrackCuts->GetTitle();
+    if (!title.CompareTo("No track cuts")) title = "";
+    else title += " && ";
+    title += Form("DCAr < %f", argument.Atof());
+    fHLTESDTrackCuts->SetTitle(title);
+    return 2;
+  }
+
+  // -- deprecated
+
+  // -dca-reference
+  // reference point for the transverse and longitudinal dca cut
+  if (argument.CompareTo("-dca-reference")==0) {
+    if (++i>=argc) return -EPROTO;
+    HLTWarning("argument -dca-reference deprecated, ESDTrackCuts only allow for DCA to vertex");
     return 2;
   }