From: richterm Date: Sun, 23 Nov 2008 11:34:21 +0000 (+0000) Subject: adding AliEVE bindings for the HLT TPC X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=b658d7e48d760c86af5caf12b281a5c4cacf31e8 adding AliEVE bindings for the HLT TPC - separate library libAliHLTTPCEVE - main handler class - macro displaying HLT TPC clusters from HLTOUT - macro displaying Tracks member of HLTesdTree of ESD --- diff --git a/HLT/TPCLib/EVE/AliHLTTPCEVE.cxx b/HLT/TPCLib/EVE/AliHLTTPCEVE.cxx new file mode 100644 index 00000000000..7ec4d42d171 --- /dev/null +++ b/HLT/TPCLib/EVE/AliHLTTPCEVE.cxx @@ -0,0 +1,152 @@ +// $Id$ + +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* for The ALICE HLT Project. * +//* * +//* Permission to use, copy, modify and distribute this software and its * +//* documentation strictly for non-commercial purposes is hereby granted * +//* without fee, provided that the above copyright notice appears in all * +//* copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//************************************************************************** + +/** @file AliHLTTPCEVE.cxx + @author Matthias Richter + @date 2008-11-22 + @brief AliEVE bindings for the HLT TPC. +*/ + +#include +#include +#include "AliHLTTPCEVE.h" +#include "TEvePointSet.h" +#include "TEveElement.h" +#include "AliRawReader.h" +#include "AliHLTOUT.h" +#include "AliHLTTPCDefinitions.h" +#include "AliHLTTPCClusterDataFormat.h" +#include "AliHLTTPCSpacePointData.h" +#include "TSystem.h" +#include "TClass.h" +#include "TString.h" +#include "TMath.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTTPCEVE) + +AliHLTTPCEVE::AliHLTTPCEVE() + : AliHLTLogging() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTTPCEVE::~AliHLTTPCEVE() +{ + // see header file for class documentation +} + +TEvePointSet* AliHLTTPCEVE::MakePointSetFromHLTDigits(const char* /*path*/, int eventNo, TEveElement* cont, Float_t maxR) const +{ + // see header file for class documentation + TTree* pDigitTree=NULL; + AliHLTOUT* pHLTOUT=AliHLTOUT::New(pDigitTree, eventNo); + TEvePointSet* pointSet=MakePointSetFromHLTOUT(pHLTOUT, cont, maxR); + AliHLTOUT::Delete(pHLTOUT); + return pointSet; +} + +TEvePointSet* AliHLTTPCEVE::MakePointSetFromHLTOUT(AliRawReader* pRawReader, TEveElement* cont, Float_t maxR) const +{ + // see header file for class documentation + if (!pRawReader) return NULL; + AliHLTOUT* pHLTOUT=AliHLTOUT::New(pRawReader); + TEvePointSet* pointSet=MakePointSetFromHLTOUT(pHLTOUT, cont, maxR); + AliHLTOUT::Delete(pHLTOUT); + return pointSet; +} + +TEvePointSet* AliHLTTPCEVE::MakePointSetFromHLTOUT(AliHLTOUT* pHLTOUT, TEveElement* /*cont*/, Float_t maxR) const +{ + // see header file for class documentation + if (!pHLTOUT) return NULL; + + const Int_t kMaxCl=100*160; + TEvePointSet* clusters = new TEvePointSet(kMaxCl); + if (clusters) { + clusters->SetOwnIds(kTRUE); + clusters->SetMarkerColor(2); + clusters->SetMarkerStyle(5); + + if (pHLTOUT->Init()>=0) { + for (int idx=pHLTOUT->SelectFirstDataBlock(AliHLTTPCDefinitions::fgkClustersDataType); + idx>=0; + idx=pHLTOUT->SelectNextDataBlock()) { + const AliHLTUInt8_t* pBuffer=NULL; + AliHLTUInt32_t size=0; + AliHLTComponentDataType dt=kAliHLTVoidDataType; + AliHLTUInt32_t spec=kAliHLTVoidDataSpec; + pHLTOUT->GetDataBlockDescription(dt, spec); + + if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) { + int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec); + if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(spec)) { + HLTWarning("cluster data array of multiple TPC slices, can not unambiguously determine phi; skipping data block of specification 0x%08x", spec); + continue; + } + if (size>0 && AddClusters(clusters, reinterpret_cast(pBuffer), size, slice, maxR)<0) { + // action if failed + } + pHLTOUT->ReleaseDataBuffer(pBuffer); + } + } + } else { + HLTError("initialization of HLTOUT handler failed"); + } + TString name="HLT TPC Clusters"; + clusters->SetName(name); + name.Form("N=%d", clusters->Size()); + clusters->SetTitle(name); + } + + return clusters; +} + +int AliHLTTPCEVE::AddClusters(TEvePointSet* clusters, const AliHLTTPCClusterData* data, unsigned int sizeInByte, int slice, Float_t maxR) const +{ + // see header file for class documentation + int iResult=0; + if (!clusters || !data) return -EINVAL; + Float_t phi = ( slice + 0.5 ) * TMath::Pi() / 9.0; + Float_t cos = TMath::Cos( phi ); + Float_t sin = TMath::Sin( phi ); + Float_t maxRsqr = maxR*maxR; // maxR squared for a simple geometrical cut below + + for (iResult=0; iResult<(int)data->fSpacePointCnt && iResult>=0; iResult++) { + if (reinterpret_cast(data->fSpacePoints)+(iResult+1)*sizeof(AliHLTTPCSpacePointData)>reinterpret_cast(data)+sizeInByte) { + HLTError("data missmatch: buffer of size %d does not match size of AliHLTTPCClusterData (%d) + %d tracks x AliHLTTPCSpacePointData (%d)", + sizeInByte, sizeof(AliHLTTPCClusterData), data->fSpacePointCnt, sizeof(AliHLTTPCSpacePointData)); + iResult=-ENOMSG; + break; + } + const AliHLTTPCSpacePointData* sp=&data->fSpacePoints[iResult]; + if (sp->fX*sp->fX+sp->fY*sp->fY<=maxRsqr) { + clusters->SetNextPoint(cos*sp->fX - sin*sp->fY, sin*sp->fX + cos*sp->fY, sp->fZ); + } + } + + if (iResult<0) { + // reset clusters + } + + return iResult; +} diff --git a/HLT/TPCLib/EVE/AliHLTTPCEVE.h b/HLT/TPCLib/EVE/AliHLTTPCEVE.h new file mode 100644 index 00000000000..ce7015eea16 --- /dev/null +++ b/HLT/TPCLib/EVE/AliHLTTPCEVE.h @@ -0,0 +1,87 @@ +//-*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTTPCEVE_H +#define ALIHLTTPCEVE_H +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* See cxx source for full Copyright notice * + +/** @file AliHLTTPCEVE.h + @author Matthias Richter + @date 2008-11-22 + @brief AliEVE bindings for the HLT TPC. +*/ + +#include "AliHLTLogging.h" + +class TEvePointSet; +class TEveElement; +class AliRawReader; +class AliHLTOUT; +class AliHLTTPCClusterData; + +/** + * @class AliHLTTPCEVE + * AliEVE bindings for the HLT TPC. + * The class provides methods to convert HLT TPC proprietary data structures + * to EVE objects. + * + * @ingroup alihlt_tpc + */ +class AliHLTTPCEVE : public AliHLTLogging { + public: + /** standard constructor */ + AliHLTTPCEVE(); + /** standard destructor */ + virtual ~AliHLTTPCEVE(); + + /** + * Create EVE point collection from HLTOUT of HLT.Digits.root + * Calls ::MakePointSetFromHLTOUT(AliHLTOUT*, TEveElement*, Float_t) + * @param path path of the working directory + * @param eventNo event number to be displayed + * @param cont EVE element collection + * @param maxR geometrical cut, maximum radius of clusters + */ + TEvePointSet* MakePointSetFromHLTDigits(const char* path, int eventNo, TEveElement* cont=0, Float_t maxR=270) const; + + /** + * Create EVE point collection from HLTOUT from RawReader. + * Calls ::MakePointSetFromHLTOUT(AliHLTOUT*, TEveElement*, Float_t) + * @param pRawReader the RawReader + * @param cont EVE element collection + * @param maxR geometrical cut, maximum radius of clusters + */ + TEvePointSet* MakePointSetFromHLTOUT(AliRawReader* pRawReader, TEveElement* cont=0, Float_t maxR=270) const; + + /** + * Create EVE point collection from HLTOUT instance. + * Base method to create EVE point list from HLTOUT. + * @param pRawReader the RawReader + * @param cont EVE element collection + * @param maxR geometrical cut, maximum radius of clusters + */ + TEvePointSet* MakePointSetFromHLTOUT(AliHLTOUT* pHLTOUT, TEveElement* cont=0, Float_t maxR=270) const; + + /** + * Add clusters from AliHLTTPCClusterData set to EVE point collection. + * @param clusters EVE point collection + * @param data AliHLTTPCClusterData set + * @param sizeInByte size of the buffer of the data set in byte + * @param slice TPC slice number, determines ratotion of space points + * @param maxR geometrical cut, maximum radius of clusters + */ + int AddClusters(TEvePointSet* clusters, const AliHLTTPCClusterData* data, unsigned int sizeInByte, int slice, Float_t maxR) const; + + protected: + + private: + /** copy constructor prohibited */ + AliHLTTPCEVE(const AliHLTTPCEVE&); + /** assignment operator prohibited */ + AliHLTTPCEVE& operator=(const AliHLTTPCEVE&); + + ClassDef(AliHLTTPCEVE, 0) +}; +#endif diff --git a/HLT/TPCLib/EVE/Makefile.am b/HLT/TPCLib/EVE/Makefile.am new file mode 100644 index 00000000000..ad9d13cb0b9 --- /dev/null +++ b/HLT/TPCLib/EVE/Makefile.am @@ -0,0 +1,63 @@ +# $Id$ +# Makefile template for the AliHLTTPCEVE library. +# EVE bindings for the HLT TPC + +MODULE = AliHLTTPCEVE + +SUBDIRS = . + +EXTRA_DIST = + +# library definition +lib_LTLIBRARIES = libAliHLTTPCEVE.la + +# version info for the library +LIBRARY_VERSION = '0:0:0' + +# MODDIR is set by the AliRoot build system and denotes the topdir +# of the module, we must set it since the package definition libAliHLTTPCEVE.pkg +# includes another common configuration file +MODDIR = $(top_srcdir) +PKGDEF = $(MODDIR)/libAliHLTTPCEVE.pkg +include $(top_srcdir)/libAliHLTTPCEVE.pkg + +# compiler flags +AM_CPPFLAGS = -DMODULE=$(MODULE) \ + $(foreach i, $(EINCLUDE), \ + $(shell echo $(i) | sed -e "/HLT\//!d" -e "s|HLT/|-I$(top_srcdir)/|")) \ + $(foreach i, $(EINCLUDE), \ + $(shell echo $(i) | sed -e "/HLT\//d" -e "s|^|-I$(ALICE_ROOT)/|")) + +# library sources +libAliHLTTPCEVE_la_SOURCES = $(MODULE_SRCS) + +# library headers +pkginclude_HEADERS = $(MODULE_HDRS) + +# linker flags +libAliHLTTPCEVE_la_LIBADD = $(top_builddir)/BASE/libHLTbase.la \ + $(top_builddir)/TPCLib/libAliHLTTPC.la +libAliHLTTPCEVE_la_LDFLAGS = -L@ROOTLIBDIR@ \ + @ROOTLIBS@ \ + @ALIROOT_LDFLAGS@ \ + @ALIROOT_LIBS@ \ + -version-info $(LIBRARY_VERSION) + +# automatic generation of data and time of library build +COMPILE_INFO = AliHLTTPCEVECompileInfo.cxx + +# set the file name for the generated root dictionary +DICTCPP = AliHLTTPCEVE-DICT.cxx +nodist_libAliHLTTPCEVE_la_SOURCES = $(COMPILE_INFO) \ + $(DICTCPP) + +CLEANFILES = $(COMPILE_INFO) + +include $(top_srcdir)/make.dict + +$(COMPILE_INFO): $(libAliHLTTPCEVE_la_SOURCES) $(pkginclude_HEADERS) $(noinst_HEADERS) Makefile.am + @echo '//automatically generated compilation info' > $@ + @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ + @echo '//add changes in Makefile.am' >> $@ + @echo 'extern "C" void CompileInfo(const char*& date, const char*& time)' >> $@ + @echo '{date=__DATE__; time=__TIME__; return;}' >> $@ diff --git a/HLT/TPCLib/EVE/macros/esd_hlt_tracks.C b/HLT/TPCLib/EVE/macros/esd_hlt_tracks.C new file mode 100644 index 00000000000..cf630ce8f9c --- /dev/null +++ b/HLT/TPCLib/EVE/macros/esd_hlt_tracks.C @@ -0,0 +1,97 @@ +// $Id$ +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* for The ALICE HLT Project. * +//* * +//* Permission to use, copy, modify and distribute this software and its * +//* documentation strictly for non-commercial purposes is hereby granted * +//* without fee, provided that the above copyright notice appears in all * +//* copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//************************************************************************** + +/** + * Display ESD Tracks from the HLTesdTree in AliEVE. + * + * Usage: + *
+ *   alieve $ALICE_ROOT/EVE/alice-macros/event_next.C \
+ *          $ALICE_ROOT/EVE/macros/alieve_init.C \
+ *          $ALICE_ROOT/EVE/alice-macros/geom_simple.C \
+ *          $ALICE_ROOT/EVE/alice-macros/esd_tracks.C \
+ *          $ALICE_ROOT/HLT/TPCLib/EVE/macros/esd_hlt_tracks.C
+ * 
+ * Display is changed to next event by executing event_next() + * from the root prompt. + *
+ *   event_next(); esd_tracks(); esd_hlt_tracks();
+ * 
+ * + * @ingroup alihlt_tpc + * @author Matthias.Richter@ift.uib.no + * @date 2008-11-22 + */ +TEveTrackList* esd_hlt_tracks() +{ + if (!TClass::GetClass("AliEveEventManager")) { + Error("hlt_tpc_clusters.C", "EVE library not loaded, please start alieve correctly"); + return NULL; + } + + AliEveEventManager* eveManager=AliEveEventManager::GetMaster(); + if (!eveManager) { + Error("esd_hlt_tracks.C", "EVE manager not initialized"); + return NULL; + } + + int eventId=eveManager->GetEventId(); + TFile* esdFile=eveManager->GetESDFile(); + if (!esdFile) { + Warning("esd_hlt_tracks.C", "can not get esd file from EVE manager"); + return NULL; + } + + TObject* pObj=NULL; + TTree* pHLTTree=NULL; + esdFile->GetObject("HLTesdTree", pObj); + if (!pObj || (pHLTTree=dynamic_cast(pObj))==NULL) { + Info("esd_hlt_tracks.C", "no HLT ESD tree in ESD file"); + return NULL; + } + if (pHLTTree->GetEntries()<=eventId) { + Warning("esd_hlt_tracks.C", "skiping event %d: out of range %d", eventId, pHLTTree->GetEntries()); + return NULL; + } + + AliESDEvent* esd=new AliESDEvent; + esd->ReadFromTree(pHLTTree); + pHLTTree->GetEntry(eventId); + + TEveTrackList* cont = new TEveTrackList("HLT ESD Tracks"); + cont->SetMainColor(7); + TEveTrackPropagator* trkProp = cont->GetPropagator(); + trkProp->SetMagField(0.1*esd->GetMagneticField()); + trkProp->SetMaxR (520); + + eveManager->AddElement(cont); + + Int_t count = 0; + for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n) + { + ++count; + TEveTrack* track = esd_make_track(esd->GetTrack(n), cont); + + cont->AddElement(track); + } + cont->SetTitle(Form("N=%d", count)); + cont->MakeTracks(); + + gEve->Redraw3D(); + + return cont; +} diff --git a/HLT/TPCLib/EVE/macros/hlt_tpc_clusters.C b/HLT/TPCLib/EVE/macros/hlt_tpc_clusters.C new file mode 100644 index 00000000000..16fe4670e84 --- /dev/null +++ b/HLT/TPCLib/EVE/macros/hlt_tpc_clusters.C @@ -0,0 +1,97 @@ +// $Id$ +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Matthias Richter * +//* for The ALICE HLT Project. * +//* * +//* Permission to use, copy, modify and distribute this software and its * +//* documentation strictly for non-commercial purposes is hereby granted * +//* without fee, provided that the above copyright notice appears in all * +//* copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//************************************************************************** + +/** + * Display HLT TPC clusters in AliEVE. + * The cluster data must be stored in an HLTOUT collection originating + * either from an HLT simulation or real run with a chain adding + * HLT TPC cluster structures of type AliHLTTPCDefinitions::fgkClustersDataType + * to the HLTOUT. + * + * The HLTOUT data is read either from the RawReader which AliEve has been + * initialized or the HLT.Digits.root if the RawReader is not available. + * Please note: As of Nov 2008, AliEve can handle raw data noy through + * AliRawReaderFile. It can only open a RawReader on a single file, by default + * raw.root. If the file is not existing, the RawReader is not initialized. + * + * Usage: + *
+ *   alieve $ALICE_ROOT/EVE/alice-macros/event_next.C \
+ *          $ALICE_ROOT/EVE/macros/alieve_init.C \
+ *          $ALICE_ROOT/EVE/alice-macros/geom_simple.C \
+ *          $ALICE_ROOT/HLT/TPCLib/EVE/macros/hlt_tpc_clusters.C
+ * 
+ * Display is changed to next event by executing event_next() + * from the root prompt. + *
+ *   event_next(); hlt_tpc_clusters();
+ * 
+ * + * @ingroup alihlt_tpc + * @author Matthias.Richter@ift.uib.no + * @date 2008-11-22 + */ +TEvePointSet* hlt_tpc_clusters(TEveElement* cont=0, Float_t maxR=270) +{ + if (!TClass::GetClass("AliEveEventManager")) { + Error("hlt_tpc_clusters.C", "EVE library not loaded, please start alieve correctly"); + return NULL; + } + + AliEveEventManager* eveManager=AliEveEventManager::GetMaster(); + if (!eveManager) { + Error("hlt_tpc_clusters.C", "EVE manager not initialized"); + return NULL; + } + + eveManager->AssertGeometry(); + + TClass* pCl=NULL; + int iLibResult=0; + do { + pCl=TClass::GetClass("AliHLTTPDefinitions"); + } while (!pCl && (iLibResult=gSystem->Load("libAliHLTTPC.so"))==0); + do { + pCl=TClass::GetClass("AliHLTTPCEVE"); + } while (!pCl && (iLibResult=gSystem->Load("libAliHLTTPCEVE.so"))==0); + + AliHLTTPCEVE hlttpceve; + TEvePointSet* clusters = NULL; + + AliESDEvent* pESD=eveManager->AssertESD(); + if (eveManager->HasRawReader()) { + AliRawReader* pRawReader=eveManager->AssertRawReader(); + if (pRawReader) { + clusters=hlttpceve.MakePointSetFromHLTOUT(pRawReader, cont, maxR); + } + } else { + clusters=hlttpceve.MakePointSetFromHLTDigits(eveManager->GetTitle(), eveManager->GetEventId(), cont, maxR); + } + if (!clusters) return NULL; + + if (clusters->Size() == 0) { + Info("hlt_tpc_clusters.C", "No TPC clusters"); + } + + //clusters->ApplyVizTag(clusters->GetName()); + + gEve->AddElement(clusters, cont); + + gEve->Redraw3D(); + + return clusters; +} diff --git a/HLT/TPCLib/Makefile.am b/HLT/TPCLib/Makefile.am index 059fa83f106..ddcd1e9d52b 100644 --- a/HLT/TPCLib/Makefile.am +++ b/HLT/TPCLib/Makefile.am @@ -69,7 +69,7 @@ CLEANFILES = $(COMPILE_INFO) \ include $(top_srcdir)/make.dict -SUBDIRS = . test OnlineDisplay +SUBDIRS = . test EVE OnlineDisplay $(TPC_MAPPING_INC): $(TPC_MAPPING_NOINST_PGM) ./$< diff --git a/HLT/configure.ac b/HLT/configure.ac index 34a983528f3..83f80846e95 100644 --- a/HLT/configure.ac +++ b/HLT/configure.ac @@ -1152,6 +1152,7 @@ if test "x$enable_tpc" = "xyes"; then TPCLib/test/Makefile TPCLib/mapping2array.cxx TPCLib/OnlineDisplay/Makefile + TPCLib/EVE/Makefile ]) fi diff --git a/HLT/libAliHLTTPCEVE.pkg b/HLT/libAliHLTTPCEVE.pkg new file mode 100644 index 00000000000..83fc96e6442 --- /dev/null +++ b/HLT/libAliHLTTPCEVE.pkg @@ -0,0 +1,35 @@ +#-*- Mode: Makefile -*- +# $Id$ + +CLASS_HDRS:= AliHLTTPCEVE.h + +MODULE_SRCS= $(CLASS_HDRS:.h=.cxx) + +MODULE_HDRS:= $(CLASS_HDRS) + +MODULE_DHDR:= + +EINCLUDE := HLT/TPCLib \ + HLT/TPCLib/offline \ + HLT/BASE \ + EVE + +LIBRARY_DEP := -lHLTbase -lAliHLTTPC + +############################################################################### +# +# do not change anything below this line +# +include $(MODDIR)/hlt.conf + +SRCS:=$(patsubst %,TPCLib/EVE/%,$(MODULE_SRCS)) +CINTHDRS:=$(patsubst %,TPCLib/EVE/%,$(CLASS_HDRS)) +HDRS:=$(patsubst %,TPCLib/EVE/%,$(MODULE_HDRS)) +DHDR:=$(patsubst %,TPCLib/EVE/%,$(MODULE_DHDR)) +CINTAUTOLINK:= $(shell test "x$(MODULE_DHDR)" = "x" && echo 1) + +EDEFINE := ${HLTDEFS} +PACKCXXFLAGS := ${HLTCXXFLAGS} +PACKCFLAGS := ${HLTCLFAGS} +PACKDCXXFLAGS:= ${HLTDCXXFLAGS} +PACKSOFLAGS := $(HLTSOFLAGS)