]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTSpacePointContainer.cxx
HLTcalo module
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTSpacePointContainer.cxx
index 0c6080fbcac2a393ff5541f11fc0ace295575012..eda14439f732236cac6f8de2c8b41067d4e4cef4 100644 (file)
 #include "TH2F.h"
 #include "TMath.h"
 #include "TMarker.h"
+#include "TTree.h"
 #include <memory>
 #include <algorithm>
 #include <iostream>
+#include <iomanip>
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTSpacePointContainer)
@@ -172,6 +174,13 @@ AliHLTUInt8_t* AliHLTSpacePointContainer::Alloc(int size)
   return reinterpret_cast<AliHLTUInt8_t*>(buffer->GetArray());
 }
 
+AliHLTSpacePointContainer* AliHLTSpacePointContainer::SelectByMask(AliHLTUInt32_t /*mask*/, bool /*bAlloc*/) const
+{
+  /// create a collection of clusters for a space point mask
+  /// default implementation, nothing to do
+  return NULL;
+}
+
 AliHLTSpacePointContainer* AliHLTSpacePointContainer::SelectByTrack(int /*trackId*/, bool /*bAlloc*/) const
 {
   /// create a collection of clusters for a specific track
@@ -323,6 +332,8 @@ void AliHLTSpacePointContainer::Draw(Option_t *option)
   /// Inherited from TObject, draw clusters
   float scale=250;
   float center[2]={0.5,0.5};
+  int markersize=1;
+  int markercolor=5;
 
   TString strOption(option);
   std::auto_ptr<TObjArray> tokens(strOption.Tokenize(" "));
@@ -347,6 +358,16 @@ void AliHLTSpacePointContainer::Draw(Option_t *option)
       arg.ReplaceAll(key, "");
       center[1]=arg.Atof();
     }
+    key="markersize=";
+    if (arg.BeginsWith(key)) {
+      arg.ReplaceAll(key, "");
+      markersize=arg.Atoi();
+    }
+    key="markercolor=";
+    if (arg.BeginsWith(key)) {
+      arg.ReplaceAll(key, "");
+      markercolor=arg.Atoi();
+    }
   }
 
   vector<AliHLTUInt32_t> clusterIDs;
@@ -359,19 +380,74 @@ void AliHLTSpacePointContainer::Draw(Option_t *option)
     float sinphi=TMath::Sin(clusterphi);
     float clusterx=GetX(*clusterID);
     float clustery=GetY(*clusterID);
-    cout << " " << *clusterID << " " << clusterx << " " << clustery << " " << clusterphi << endl;
+    //cout << " " << *clusterID << " " << clusterx << " " << clustery << " " << clusterphi << endl;
     // rotate
     float pointx= clusterx*sinphi + clustery*cosphi;
     float pointy=-clusterx*cosphi + clustery*sinphi;
 
     TMarker* m=new TMarker(pointx/(2*scale)+center[0], pointy/(2*scale)+center[1], 3);
-    m->SetMarkerColor(5);
+    m->SetMarkerSize(markersize);
+    m->SetMarkerColor(markercolor);
     m->Draw("same");    
   }  
 }
 
+TTree* AliHLTSpacePointContainer::FillTree(const char* name, const char* title)
+{
+  // create tree and fill the space point coordinates
+  TString treename=name;
+  TString treetitle=title;
+  if (treename.IsNull()) treename="spacepoints";
+  if (treetitle.IsNull()) treetitle="HLT space point coordinates";
+  std::auto_ptr<TTree> tree(new TTree(treename, treetitle));
+  if (!tree.get()) return NULL;
+
+  const unsigned dimension=8;
+  float values[dimension];
+  memset(values, 0, sizeof(values));
+  const char* names[dimension]={
+    "x", "y", "z", "sigmaY2", "sigmaZ2", "charge", "qmax", "alpha"
+  };
+
+  for (unsigned i=0; i<dimension; i++) {
+    TString type=names[i]; type+="/F";
+    tree->Branch(names[i], &values[i], type);
+  }
+
+  const vector<AliHLTUInt32_t>* clusterIDs=GetClusterIDs(0xffffffff);
+  for (vector<AliHLTUInt32_t>::const_iterator clusterID=clusterIDs->begin();
+       clusterID!=clusterIDs->end();
+       clusterID++) {
+    unsigned pos=0;
+    values[pos++]=GetX(*clusterID);
+    values[pos++]=GetY(*clusterID);
+    values[pos++]=GetZ(*clusterID);
+    values[pos++]=GetYWidth(*clusterID);
+    values[pos++]=GetZWidth(*clusterID);
+    values[pos++]=GetCharge(*clusterID);
+    values[pos++]=GetMaxSignal(*clusterID);
+    values[pos++]=GetPhi(*clusterID);
+
+    tree->Fill();
+  }
+
+  return tree.release();
+}
+
 ostream& operator<<(ostream &out, const AliHLTSpacePointContainer& c)
 {
   c.Print(out);
   return out;
 }
+
+ostream& operator<<(ostream &out, const AliHLTSpacePointContainer::AliHLTSpacePointProperties& p)
+{
+  // print
+  cout << p.fId;
+  return out;
+}
+
+bool operator==(const AliHLTSpacePointContainer::AliHLTSpacePointProperties& a,
+               const AliHLTSpacePointContainer::AliHLTSpacePointProperties& b) {
+  return a.fId==b.fId;
+}