]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTTrackGeometry.cxx
HLTcalo module
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTTrackGeometry.cxx
index e5b5c2c78ae99b07c321da13d31cc02fa6e69cc9..dc899c17c9837c1f295b6f63b5600d7d63001f98 100644 (file)
@@ -27,6 +27,7 @@
 #include "TObjArray.h"
 #include "TMarker.h"
 #include "TMath.h"
+#include "TH2.h"
 #include <memory>
 #include <iostream>
 #include <algorithm>
@@ -37,7 +38,9 @@ ClassImp(AliHLTTrackGeometry)
 AliHLTTrackGeometry::AliHLTTrackGeometry()
   : TObject(), AliHLTLogging()
   , fTrackPoints()
+  , fSelectionMasks()
   , fTrackId(-1)
+  , fVerbosity(0)
 {
   /// standard constructor
 }
@@ -45,7 +48,9 @@ AliHLTTrackGeometry::AliHLTTrackGeometry()
 AliHLTTrackGeometry::AliHLTTrackGeometry(const AliHLTTrackGeometry& src)
   : TObject(src), AliHLTLogging()
   , fTrackPoints(src.fTrackPoints)
+  , fSelectionMasks(src.fSelectionMasks)
   , fTrackId(src.fTrackId)
+  , fVerbosity(src.fVerbosity)
 {
   /// copy constructor
 }
@@ -55,7 +60,9 @@ AliHLTTrackGeometry& AliHLTTrackGeometry::operator=(const AliHLTTrackGeometry& s
   /// assignment operator
   if (this!=&src) {
     fTrackPoints.assign(src.fTrackPoints.begin(), src.fTrackPoints.end());
+    fSelectionMasks.assign(src.fSelectionMasks.begin(), src.fSelectionMasks.end());
     fTrackId=src.fTrackId;
+    fVerbosity=src.fVerbosity;
   }
   return *this;
 }
@@ -65,12 +72,15 @@ AliHLTTrackGeometry::~AliHLTTrackGeometry()
   /// destructor
 }
 
-int AliHLTTrackGeometry::AddTrackPoint(const AliHLTTrackPoint& point)
+int AliHLTTrackGeometry::AddTrackPoint(const AliHLTTrackPoint& point, AliHLTUInt32_t selectionMask)
 {
   /// add a track point to the list
   vector<AliHLTTrackPoint>::const_iterator element = find(fTrackPoints.begin(), fTrackPoints.end(), point);
   if (element==fTrackPoints.end()) {
     fTrackPoints.push_back(point);
+    if (std::find(fSelectionMasks.begin(), fSelectionMasks.end(), selectionMask)==fSelectionMasks.end()) {
+      fSelectionMasks.push_back(selectionMask);
+    }
   } else {
     HLTError("track point of id %08x already existing", point.GetId());
     return -EEXIST;
@@ -185,12 +195,12 @@ void AliHLTTrackGeometry::Draw(Option_t *option)
   }
 }
 
-int AliHLTTrackGeometry::SetAssociatedSpacePoint(UInt_t planeId, UInt_t spacepointId, int status)
+int AliHLTTrackGeometry::SetAssociatedSpacePoint(UInt_t planeId, UInt_t spacepointId, int /*status*/, float dU, float dV)
 {
   /// set the spacepoint associated with a track point
   vector<AliHLTTrackPoint>::iterator element = find(fTrackPoints.begin(), fTrackPoints.end(), planeId);
   if (element==fTrackPoints.end()) return -ENOENT;
-  element->SetAssociatedSpacePoint(spacepointId, status);
+  element->AddAssociatedSpacePoint(spacepointId, dU, dV);
   return 0;
 }
 
@@ -201,7 +211,20 @@ int AliHLTTrackGeometry::GetAssociatedSpacePoint(UInt_t planeId, UInt_t& spacepo
   vector<AliHLTTrackPoint>::const_iterator element = find(fTrackPoints.begin(), fTrackPoints.end(), planeId);
   if (element==fTrackPoints.end()) return -ENOENT;
   if (!element->HaveAssociatedSpacePoint()) return -ENODATA;
-  return element->GetAssociatedSpacePoint(spacepointId);
+  spacepointId=(element->GetSpacepoints())[0].fId;
+  return 0;
+}
+
+int AliHLTTrackGeometry::RegisterTrackPoints(AliHLTTrackGrid* /*pGrid*/) const
+{
+  /// default implementation, nothing to do
+  return -ENOSYS;
+}
+
+int AliHLTTrackGeometry::FillTrackPoints(AliHLTTrackGrid* /*pGrid*/) const
+{
+  /// default implementation, nothing to do
+  return -ENOSYS;
 }
 
 const AliHLTTrackGeometry::AliHLTTrackPoint* AliHLTTrackGeometry::GetTrackPoint(AliHLTUInt32_t id) const
@@ -220,7 +243,7 @@ AliHLTTrackGeometry::AliHLTTrackPoint* AliHLTTrackGeometry::GetTrackPoint(AliHLT
   return &(*element);
 }
 
-AliHLTSpacePointContainer* AliHLTTrackGeometry::ConvertToSpacePoints() const
+AliHLTSpacePointContainer* AliHLTTrackGeometry::ConvertToSpacePoints(bool /*bAssociated*/) const
 {
   /// create a collection of all points
   HLTError("implementation of child method missing");
@@ -235,7 +258,7 @@ int AliHLTTrackGeometry::AssociateSpacePoints(AliHLTSpacePointContainer& points)
   if (ids.size()>0) return 0;
   int result=AssociateSpacePoints(&ids[0], ids.size(), points);
   if (result>0) {
-    HLTInfo("associated %d space point(s) to track points", result);
+    HLTInfo("associated %d of %d space point(s) to track points", result, ids.size());
   }
   return result;
 }
@@ -255,13 +278,14 @@ int AliHLTTrackGeometry::AssociateSpacePoints(const AliHLTUInt32_t* trackpoints,
     AliHLTUInt32_t planeId=0;
     int result=FindMatchingTrackPoint(trackpoints[i], xyz, planeId);
     if (result<0) {
-      HLTWarning("no associated track point found for space point id %08x x=%f y=%f z=%f", trackpoints[i], xyz[0], xyz[1], xyz[2]);
+      if (GetVerbosity()>0) HLTWarning("no associated track point found for space point id %08x x=%f y=%f z=%f", trackpoints[i], xyz[0], xyz[1], xyz[2]);
       continue;
     } else if (result==0) {
       HLTWarning("associated track point for space pointid %08x x=%f y=%f z=%f occupied", trackpoints[i], xyz[0], xyz[1], xyz[2]);
       continue;
     }
-    SetAssociatedSpacePoint(planeId, trackpoints[i], 1);
+    vector<AliHLTTrackPoint>::const_iterator element = find(fTrackPoints.begin(), fTrackPoints.end(), planeId);
+    SetAssociatedSpacePoint(planeId, trackpoints[i], 1, xyz[1]-element->GetU(), xyz[2]-element->GetV());
     if (points.GetTrackID(trackpoints[i])<0 && GetTrackId()>=0) {
       points.SetTrackID(GetTrackId(), trackpoints[i]);
       HLTDebug("associating unused cluster %08x with track %d", trackpoints[i], GetTrackId());
@@ -275,30 +299,58 @@ int AliHLTTrackGeometry::AssociateUnusedSpacePoints(AliHLTSpacePointContainer& p
 {
   /// associate the track space points to the calculated track points
   int count=0;
-  vector<AliHLTUInt32_t> ids;
-  points.GetClusterIDs(ids);
-  for (vector<AliHLTUInt32_t>::iterator id=ids.begin();
-       id!=ids.end(); id++) {
-    float xyz[3]={points.GetX(*id), points.GetY(*id), points.GetZ(*id)};
-    AliHLTUInt32_t planeId=0;
-    int result=FindMatchingTrackPoint(*id, xyz, planeId);
-    if (result<0) {
-      //HLTWarning("no associated track point found for space point id %08x x=%f y=%f z=%f", *id, xyz[0], xyz[1], xyz[2]);
-      continue;
-    } else if (result==0) {
-      //HLTWarning("associated track point for space pointid %08x x=%f y=%f z=%f occupied", *id, xyz[0], xyz[1], xyz[2]);
+  for (vector<AliHLTUInt32_t>::iterator mask=fSelectionMasks.begin();
+       mask!=fSelectionMasks.end(); mask++) {
+    int subcount=0;
+    const vector<AliHLTUInt32_t>* selectedPoints=points.GetClusterIDs(*mask);
+    if (!selectedPoints) {
+      HLTWarning("space point collection does not contain data for mask 0x%08x", *mask);
       continue;
     }
-    SetAssociatedSpacePoint(planeId, *id, 1);
-    if (points.GetTrackID(*id)<0 && GetTrackId()>=0) {
-      points.SetTrackID(GetTrackId(), *id);
-      HLTDebug("associating unused cluster %08x with track %d", *id, GetTrackId());
+    for (vector<AliHLTUInt32_t>::const_iterator id=selectedPoints->begin();
+        id!=selectedPoints->end(); id++) {
+      if (points.GetTrackID(*id)>=0) continue;
+      float xyz[3]={points.GetX(*id), points.GetY(*id), points.GetZ(*id)};
+      AliHLTUInt32_t planeId=0;
+      int result=FindMatchingTrackPoint(*id, xyz, planeId);
+      if (result<0) {
+       //HLTWarning("no associated track point found for space point id %08x x=%f y=%f z=%f", *id, xyz[0], xyz[1], xyz[2]);
+       continue;
+      } else if (result==0) {
+       //HLTWarning("associated track point for space pointid %08x x=%f y=%f z=%f occupied", *id, xyz[0], xyz[1], xyz[2]);
+       continue;
+      }
+      SetAssociatedSpacePoint(planeId, *id, 1);
+      if (points.GetTrackID(*id)<0 && GetTrackId()>=0) {
+       points.SetTrackID(GetTrackId(), *id);
+       HLTDebug("associating unused cluster %08x with track %d", *id, GetTrackId());
+      }
+      subcount++;
     }
-    count++;
+    if (fVerbosity>0) {
+      HLTInfo("associated %d of %d spacepoint(s) from selection 0x%08x to track %d",
+             subcount, selectedPoints->size(), *mask, GetTrackId());
+    }
+    count+=subcount;
   }
   return count;
 }
 
+int AliHLTTrackGeometry::FillResidual(int coordinate, TH2* histo) const
+{
+  // fill residual histogram
+  const vector<AliHLTTrackPoint>& trackPoints=TrackPoints();
+  for (vector<AliHLTTrackPoint>::const_iterator trackpoint=trackPoints.begin();
+       trackpoint!=trackPoints.end(); trackpoint++) {
+    if (!trackpoint->HaveAssociatedSpacePoint()) continue;
+    for (vector<AliHLTTrackSpacepoint>::const_iterator sp=(trackpoint->GetSpacepoints()).begin();
+        sp!=(trackpoint->GetSpacepoints()).end(); sp++) {
+      histo->Fill(GetPlaneR(trackpoint->GetId()), sp->GetResidual(coordinate));
+    }
+  }
+  return 0;
+}
+
 ostream& operator<<(ostream &out, const AliHLTTrackGeometry& p)
 {
   p.Print(out);