]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/trigger/AliHLTTriggerBarrelGeomMultiplicity.cxx
- synchronized the overlay macro to the changes of the drawing one
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerBarrelGeomMultiplicity.cxx
index ab42b9f9999d5d726e0b808b01eb7c4f793b5224..f0b5be8e19cb7c5948074ca99b3ebd4290c20302 100644 (file)
@@ -1,8 +1,9 @@
+// $Id$
 //**************************************************************************
 //* This file is property of and copyright by the ALICE HLT Project        * 
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //*                                                                        *
-//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//* Primary Authors: Oystein Djuvsland                                     *
 //*                  for The ALICE HLT Project.                            *
 //*                                                                        *
 //* Permission to use, copy, modify and distribute this software and its   *
@@ -35,8 +36,6 @@
 #include "AliHLTGlobalBarrelTrack.h"
 #include "TObjArray.h"
 #include "TObjString.h"
-#include "TObjArray.h"
-#include "TVector3.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
 #include "TFile.h"
@@ -50,12 +49,16 @@ AliHLTTriggerBarrelGeomMultiplicity::AliHLTTriggerBarrelGeomMultiplicity()
   , fSolenoidBz(0)
   , fMinTracks(1)
   , fDetectorArray(0)
+  , fTriggerDecisionPars(0)
+  , fTriggerName(0)
+  , fOCDBEntry(0)
 {
   // see header file for class documentation
   // or
   // refer to README to build package
   // or
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
   fDetectorArray = new TObjArray;
 
 }
@@ -63,13 +66,14 @@ AliHLTTriggerBarrelGeomMultiplicity::AliHLTTriggerBarrelGeomMultiplicity()
 AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
 {
   // see header file for class documentation
+
+  if (fDetectorArray != NULL) delete fDetectorArray;
 }
 
 const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const 
 {
   // see header file for class documentation
-  //  const char* name = fTriggerName;
-  //  if(name) return name;
+
   return "BarrelGeomMultiplicityTrigger";
 }
 
@@ -101,15 +105,19 @@ int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
   int iResult=0;
   int numberOfTracks=-1;
 
+  if (!fTriggerDecisionPars) {
+    iResult=-ENODEV;
+  }
+
   // try the ESD as input
   const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
   AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
   TString description;
+
   if (esd != NULL) 
     {
       numberOfTracks=0;
       esd->GetStdContent();
-    
       for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) 
        {
          if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
@@ -139,27 +147,36 @@ int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
            }
        }
     }
+
+  bool condition=false;
+  description="Geometrical conditions not matched";
+  AliHLTReadoutList readout;
+
   if (numberOfTracks>=fMinTracks) 
     {
-
-      SetDescription(fTriggerDecisionPars->GetDescription());
-      AliHLTReadoutList readout(fTriggerDecisionPars->GetReadoutListParameter());
-      AliHLTTriggerDecision decision(
-                                    true,
-                                    fTriggerDecisionPars->GetTriggerName().Data(),
-                                    AliHLTTriggerDomain(readout),
-                                    fTriggerDecisionPars->GetDescription()
-                                    );
-      TriggerEvent(&decision);
+      condition=true;
+      description=fTriggerDecisionPars->GetDescription();
+      readout=fTriggerDecisionPars->GetReadoutListParameter();
+      HLTDebug("Geometrical acceptance trigger %s triggered", fTriggerDecisionPars->GetTriggerName().Data());
     }
-  
+
+  AliHLTTriggerDecision decision(
+                                condition,
+                                fTriggerDecisionPars->GetTriggerName().Data(),
+                                AliHLTTriggerDomain(readout),
+                                description.Data()
+                                );
+  TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
+
   return iResult;
 
 }
 
+
 template<class T>
 bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
 {
+
   bool ret = false;
 
   // see header file for class documentation
@@ -178,12 +195,19 @@ bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
   for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
     {
       AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
+
       Double_t trackPoint[3];
-      
+      Double_t normVector[3];
+
       det->GetInitialPoint(trackPoint);
-      
-      bool ret = track->Intersect(trackPoint, det->NormVector(), b);
+      det->GetNormVector(normVector);
+
+      bool ret = track->Intersect(trackPoint, normVector, b);
 
+      if(ret)
+       {
+         if(det->IsInDetector(trackPoint)) return true;
+       }
     }
   return false;
 }
@@ -195,35 +219,56 @@ int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
   // first configure the default
   int iResult=0;
 
+  // Matthias 05.04.2011 code audit
+  // looks like somebody has to commission this component
+  HLTWarning("this component is not tested and needs most likely a major revision!");
+
   if (iResult>=0 && argc>0)
     iResult=ConfigureFromArgumentString(argc, argv);
 
-  HLTWarning("TEST");
+  if (!fTriggerDecisionPars) {
+    HLTError("decision parameter not initialized");
+    iResult=-ENODEV;
+  }
+  fSolenoidBz=GetBz();
+
   return iResult;
 }
 
 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
  {
   // see header file for class documentation
+   if (fTriggerName) delete fTriggerName;
+   fTriggerName=NULL;
   return 0;
 }
 
 int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
 {
-  // see header file for class documentation
+    // see header file for function documentation
 
-  // TODO 2009-10-10: implementation
-  // for the moment very quick, just reload the magnetic field
-  return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
+  // nothing to do for the moment
+  return 0;
 }
 
 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
 {
     // see header file for function documentation
   int nDetectorGeoms=0;
+
+  if(fDetectorArray)
+    {
+      fDetectorArray->Clear();
+    }
+  else
+    {
+      fDetectorArray = new TObjArray();
+    }
+  
   const char *path = cdbEntry;
-  if(!path) path = fOCDBEntry;
 
+  if(!path) path = fOCDBEntry;
+  
   if(path)
     {
       //     const char* chainId=GetChainId();
@@ -237,19 +282,19 @@ int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const cha
 
              for(int i = 0; i < pArr->GetEntries(); i++)
                {
-                 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecision"))
+                 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
                    {
                      fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
                    }
-                 else if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDetectorGeom"))
+                 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
                    {
                      fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
                      nDetectorGeoms++;
-                     HLTWarning("received TObjArray of %d detector geometries", nDetectorGeoms);
+                     HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
                    }
                  else
                    {
-                     HLTWarning("Unknown object in configuration object");
+                     HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
                    }
                }
            } 
@@ -265,6 +310,9 @@ int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const cha
          nDetectorGeoms=-ENOENT;
        }
     }
+
+  HLTInfo("received %d detector geometries", nDetectorGeoms);
+
   return nDetectorGeoms;
 }
 
@@ -273,13 +321,22 @@ int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *fi
     // see header file for function documentation
   int nDetectorGeoms=0;
 
+  if(fDetectorArray)
+    {
+      fDetectorArray->Clear();
+    }
+  else
+    {
+      fDetectorArray = new TObjArray();
+    }
+  
+
   if (filename) 
     {
       TFile *geomfile = TFile::Open(filename, "READ");
       
       if(geomfile)
        {
-         
          HLTInfo("configure from file \"%s\"", filename);
          TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
          if (pArr) 
@@ -295,7 +352,7 @@ int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *fi
                    {
                      fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
                      nDetectorGeoms++;
-                     HLTWarning("received detector geometry of type %s", pArr->At(i)->ClassName());
+                     HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
                    }
                  else
                    {
@@ -315,7 +372,11 @@ int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *fi
          nDetectorGeoms=-ENOENT;
        }
     }
-  HLTWarning("received TObjArray with %d detector geometries", nDetectorGeoms);
+  else
+    {
+      HLTError("ROOT file name not specified");
+    }
+  HLTInfo("received %d detector geometries", nDetectorGeoms);
 
   return nDetectorGeoms;
 }
@@ -327,7 +388,6 @@ int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, con
   int i=0;
   TString argument=argv[i];
 
-  // -maxpt
   if (argument.CompareTo("-geomfile")==0) 
     {
       if (++i>=argc) return -EPROTO;
@@ -337,15 +397,19 @@ int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, con
       return 2;
     }    
 
-  if (argument.CompareTo("-trgname")==0) 
+  if (argument.CompareTo("-triggername")==0) 
     {
-      if (++i>=argc) return -EPROTO;
-      
-      fTriggerName = new char[128];
-      sprintf(fTriggerName, argv[i]);
+      if (++i>=argc || argv[i]==NULL) return -EPROTO;
+
+      int namelen=strlen(argv[i])+1;
+      fTriggerName = new char[namelen];
+      if (!fTriggerName) return -ENOMEM;
+      snprintf(fTriggerName, namelen, "%s", argv[i]);
       
       fOCDBEntry = fTriggerName;
 
       return 2;
   }    
+  return 0;
 }
+