From 735e167ee7ee111c9bdd25224403f4dddf6b33b5 Mon Sep 17 00:00:00 2001 From: vestbo Date: Fri, 25 Jan 2002 17:19:40 +0000 Subject: [PATCH] Started classes for modeling and compression --- HLT/comp/AliL3CompLinkDef.h | 11 ++ HLT/comp/AliL3ModelTrack.cxx | 65 ++++++++ HLT/comp/AliL3ModelTrack.h | 48 ++++++ HLT/comp/AliL3Modeller.cxx | 293 +++++++++++++++++++++++++++++++++++ HLT/comp/AliL3Modeller.h | 62 ++++++++ HLT/comp/Makefile | 50 ++++++ HLT/comp/rootlogon.C | 27 ++++ 7 files changed, 556 insertions(+) create mode 100644 HLT/comp/AliL3CompLinkDef.h create mode 100644 HLT/comp/AliL3ModelTrack.cxx create mode 100644 HLT/comp/AliL3ModelTrack.h create mode 100644 HLT/comp/AliL3Modeller.cxx create mode 100644 HLT/comp/AliL3Modeller.h create mode 100644 HLT/comp/Makefile create mode 100644 HLT/comp/rootlogon.C diff --git a/HLT/comp/AliL3CompLinkDef.h b/HLT/comp/AliL3CompLinkDef.h new file mode 100644 index 00000000000..eadd58ec8b4 --- /dev/null +++ b/HLT/comp/AliL3CompLinkDef.h @@ -0,0 +1,11 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AliL3Modeller; +#pragma link C++ class AliL3ModelTrack; + +#endif + diff --git a/HLT/comp/AliL3ModelTrack.cxx b/HLT/comp/AliL3ModelTrack.cxx new file mode 100644 index 00000000000..cf3e3d80c9a --- /dev/null +++ b/HLT/comp/AliL3ModelTrack.cxx @@ -0,0 +1,65 @@ +//$Id$ + +// Author: Anders Vestbo +//*-- Copyright © ASV + +#include +#include + +#include "AliL3ModelTrack.h" +#include "AliL3Defs.h" + +ClassImp(AliL3ModelTrack) + +AliL3ModelTrack::AliL3ModelTrack() +{ + fNClusters = 0; + fClusters = 0; + fOverlap = -1; + fPad=0; + fTime=0; + fClusterCharge=0; +} + + +AliL3ModelTrack::~AliL3ModelTrack() +{ + if(fClusters) + delete [] fClusters; + if(fPad) + delete [] fPad; + if(fTime) + delete [] fTime; +} + +void AliL3ModelTrack::Init(Int_t slice,Int_t patch) +{ + fNClusters = 0; + Int_t nrows = NumRows[patch]; + fClusters = new ClusterComp[nrows]; + memset((void*)fClusters,0,nrows*sizeof(ClusterComp)); + + fPad = new Float_t[NRowsSlice]; + fTime = new Float_t[NRowsSlice]; + + fClusterCharge = 100; + +} + + +void AliL3ModelTrack::SetCluster(Float_t fpad,Float_t ftime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2) +{ + ClusterComp *cl = &fClusters[fNClusters]; + if(!charge) + cl->fEmpty = kTRUE; + else + { + cl->fEmpty = kFALSE; + cl->fDTime = ftime - GetTimeHit(fNClusters); + cl->fDPad = fpad - GetPadHit(fNClusters); + cl->fDCharge = charge - fClusterCharge; + } + cout<<"DPad "< +//*-- Copyright © ASV + +#include +#include +#include + +#include "AliL3Modeller.h" +#include "AliL3MemHandler.h" +#include "AliL3TrackArray.h" +#include "AliL3ModelTrack.h" +#include "AliL3DigitData.h" +#include "AliL3Transform.h" + +#include "AliL3Defs.h" + +ClassImp(AliL3Modeller) + +AliL3Modeller::AliL3Modeller() +{ + fMemHandler=0; + fTracks=0; + fTransform=0; +} + + +AliL3Modeller::~AliL3Modeller() +{ + if(fMemHandler) + delete fMemHandler; + if(fTracks) + delete fTracks; + if(fTransform) + delete fTransform; + +} + +void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *path) +{ + fSlice = slice; + fPatch = patch; + fPadOverlap=4; + fTimeOverlap=4; + fTransform = new AliL3Transform(); + fTracks = new AliL3TrackArray("AliL3ModelTrack"); + + AliL3MemHandler *file = new AliL3MemHandler(); + if(!file->SetBinaryInput("tracks.raw")) + { + cerr<<"AliL3Modeller::Init : Error opening trackfile"<Binary2TrackArray(fTracks); + file->CloseBinaryInput(); + delete file; + + fTracks->QSort(); + for(Int_t i=0; iGetNTracks(); i++) + { + AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i); + if(!track) continue; + track->Init(fSlice,fPatch); + track->Rotate(fSlice,kTRUE); + track->CalculateHelix(); + } + + CalculateCrossingPoints(); + CheckForOverlaps(); + + fMemHandler = new AliL3MemHandler(); + Char_t fname[100]; + sprintf(fname,"%s/digits_%d_%d.raw",path,fSlice,fPatch); + if(!fMemHandler->SetBinaryInput(fname)) + { + cerr<<"AliL3Modeller::Init : Error opening file "<CompBinary2Memory(ndigits); + + SetInputData(digits); +} + +void AliL3Modeller::Process() +{ + + if(!fTracks) + { + cerr<<"AliL3Modeller::Process : No tracks"<GetNTimeBins()+1; + Int_t npads = fTransform->GetNPads(NRows[fPatch][1])+1;//Max num of pads. + Digit *row = new Digit[(ntimes)*(npads)]; + + Int_t seq_charge; + Int_t pad,time; + Short_t charge; + Cluster cluster; + + for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++) + { + memset((void*)row,0,ntimes*npads*sizeof(Digit)); + digPt = (AliL3DigitData*)rowPt->fDigitData; + for(UInt_t j=0; jfNDigit; j++) + { + pad = digPt[j].fPad; + time = digPt[j].fTime; + charge = digPt[j].fCharge; + row[ntimes*pad+time].fCharge = charge; + row[ntimes*pad+time].fUsed = kFALSE; + } + + for(Int_t k=0; kGetNTracks(); k++) + { + AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(k); + if(!track) continue; + if(track->GetOverlap()>=0) continue;//Track is overlapping + + Int_t hitpad = (Int_t)rint(track->GetPadHit(i)); + Int_t hittime = (Int_t)rint(track->GetTimeHit(i)); + cout<<"Checking track with pad "<SetCluster(fpad,ftime,fcharge,sigmaY2,sigmaZ2); + break; + } + } + // pad += padsign; + } + } + fMemHandler->UpdateRowPointer(rowPt); + + } + delete [] row; + +} + +void AliL3Modeller::CalculateCrossingPoints() +{ + cout<<"Calculating crossing points on "<GetNTracks()<<" tracks"<GetNTracks(); j++) + { + AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(j); + if(!track) continue; + //if(!track->GetCrossingPoint(i,hit)) + // fTracks->Remove(j); //Track is bending out. + track->CalculatePoint(fTransform->Row2X(i)); + if(!track->IsPoint()) + { + fTracks->Remove(j); + continue; + } + hit[1]=track->GetPointY(); + hit[2]=track->GetPointZ(); + fTransform->Local2Raw(hit,fSlice,i); + track->SetPadHit(i,hit[1]); + track->SetTimeHit(i,hit[2]); + //if(hit[1]<0 || hit[2]>445) + cout<<"pad "<GetPt()<<" psi "<GetPsi()<<" tgl "<GetTgl()<<" firstpoint "<GetFirstPointX()<<" "<GetFirstPointY()<<" "<GetFirstPointZ()<Compress(); + cout<<"And there are "<GetNTracks()<<" tracks remaining"<GetNTracks(); i++) + { + AliL3ModelTrack *track1 = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i); + if(!track1) continue; + for(Int_t j=i+1; jGetNTracks(); j++) + { + AliL3ModelTrack *track2 = (AliL3ModelTrack*)fTracks->GetCheckedTrack(j); + if(!track2) continue; + for(Int_t k=NRows[fPatch][0]; kGetPadHit(k)-track2->GetPadHit(k)) < fPadOverlap && + fabs(track1->GetTimeHit(k)-track2->GetTimeHit(k)) < fTimeOverlap) + { + track1->SetOverlap(j); + track2->SetOverlap(i); + } + } + } + } + +} + + +void AliL3Modeller::CalcClusterWidth(Cluster *cl,Float_t &sigmaY2,Float_t &sigmaZ2) +{ + + Float_t padw,timew; + if(fPatch < 3) + padw = fTransform->GetPadPitchWidthLow(); + else + padw = fTransform->GetPadPitchWidthUp(); + Float_t charge = (Float_t)cl->fCharge; + Float_t pad = (Float_t)cl->fPad/charge; + Float_t time = (Float_t)cl->fTime/charge; + Float_t s2 = (Float_t)cl->fSigmaY2/charge - pad*pad; + sigmaY2 = (s2 + 1./12)*padw*padw; + + if(s2 != 0) + { + sigmaY2 = sigmaY2*0.108; + if(fPatch<3) + sigmaY2 = sigmaY2*2.07; + } + + s2 = (Float_t)cl->fSigmaZ2/charge - time*time; + timew = fTransform->GetZWidth(); + sigmaZ2 = (s2 +1./12)*timew*timew; + if(s2 != 0) + { + sigmaZ2 = sigmaZ2*0.169; + if(fPatch < 3) + sigmaZ2 = sigmaZ2*1.77; + } + +} diff --git a/HLT/comp/AliL3Modeller.h b/HLT/comp/AliL3Modeller.h new file mode 100644 index 00000000000..86ef7c000d2 --- /dev/null +++ b/HLT/comp/AliL3Modeller.h @@ -0,0 +1,62 @@ +#ifndef AliL3_Modeller +#define AliL3_Modeller + + +#include "AliL3RootTypes.h" + +class AliL3TrackArray; +class AliL3MemHandler; +class AliL3DigitRowData; +class AliL3Transform; + +struct Cluster { + UInt_t fCharge; + UInt_t fPad; + UInt_t fTime; + UInt_t fSigmaY2; + UInt_t fSigmaZ2; +}; + +struct Digit { + Short_t fCharge; + Bool_t fUsed; +}; + +class AliL3Modeller { + + private: + + AliL3TrackArray *fTracks; //! + AliL3MemHandler *fMemHandler; //! + AliL3DigitRowData *fRowData;//! + + AliL3Transform *fTransform; //! + Int_t fNClusters; + Int_t fMaxClusters; + + Float_t fPadOverlap; + Float_t fTimeOverlap; + + Int_t fSlice; + Int_t fPatch; + + void CalcClusterWidth(Cluster *cl,Float_t &sigmaY2,Float_t &sigmaZ2); + + public: + + AliL3Modeller(); + virtual ~AliL3Modeller(); + + void Init(Int_t slice,Int_t patch,Char_t *path); + void Process(); + void CheckForOverlaps(); + void CalculateCrossingPoints(); + + void SetInputData(AliL3DigitRowData *digits) {fRowData = digits;} + + + ClassDef(AliL3Modeller,1) //Modeller class + +}; + +#endif diff --git a/HLT/comp/Makefile b/HLT/comp/Makefile new file mode 100644 index 00000000000..41a5384caa8 --- /dev/null +++ b/HLT/comp/Makefile @@ -0,0 +1,50 @@ +# +# Makefile for ROOT version of HLT code. +# +# Author: Anders Vestbo +# + +CXX = g++ +LD = g++ +CXXFLAGS = -O2 -Wall -fPIC -Woverloaded-virtual +LDFLAGS = -O2 +SOFLAGS = -shared + +TOPDIR = $(HOME)/level3code +OBJDIR = tgt_Linux + +SRCS = AliL3Modeller.cxx AliL3ModelTrack.cxx + +DICT = AliL3CompCint.cxx +DICTH = AliL3CompCint.h +DICTO = $(OBJDIR)/AliL3CompCint.o + +HDRS = $(SRCS:.cxx=.h) AliL3CompLinkDef.h + +OBJS = $(patsubst %.cxx,$(OBJDIR)/%.o,$(SRCS)) $(DICTO) + +LEVELSO = $(LEVEL3)/lib_$(USERNAME)/libAliL3Comp.so + +all : $(OBJDIR) $(LEVELSO) + + +$(LEVELSO) : $(OBJS) + $(LD) $(SOFLAGS) $(LDFLAGS) $^ -o $@ + +$(DICT) : $(HDRS) + @echo "Generating dictionary..." + @rootcint -f $(DICT) -c -I$(ROOTSYS) -I$(TOPDIR)/src/ $(HDRS) + + +$(OBJDIR)/%.o : %.cxx + $(CXX) $(CXXFLAGS) -c -I$(ROOTSYS)/include -I$(TOPDIR)/src -I$(TOPDIR)/hough -o $@ $< + +$(OBJDIR) : + test ! -e $(OBJDIR) && mkdir -p $(OBJDIR) + +clean : + rm -f $(OBJDIR)/*.o + rm -f $(LEVEL3)/lib_$(USERNAME)/libAliL3Comp.so + rm $(DICT) $(DICTH) +so : + rm -f $(LEVEL3)/lib_$(USERNAME)/libAliL3Comp.so \ No newline at end of file diff --git a/HLT/comp/rootlogon.C b/HLT/comp/rootlogon.C new file mode 100644 index 00000000000..0a4a8f998d7 --- /dev/null +++ b/HLT/comp/rootlogon.C @@ -0,0 +1,27 @@ + +{ + printf("\nWELCOME to the magic world of Level3\n\n"); + + gSystem->Load("$(ROOTSYS)/lib/libPhysics"); + gSystem->Load("$(ROOTSYS)/lib/libEG"); + + if(0) + { + gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libSTEER"); + gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libCONTAINERS"); + gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTPC"); + cout<<"TPC libraries loaded"<Load("$(LEVEL3)/kip/MLUC/lib/linux-i386/libMLUC.so"); + gSystem->Load("$(LEVEL3)/lib_$(USERNAME)/libAliL3"); + gSystem->Load("$(LEVEL3)/lib_$(USERNAME)/libAliL3Hough"); + gSystem->Load("$(LEVEL3)/lib_$(USERNAME)/libAliL3Comp"); + cout<<"HLT libraries loaded"<LoadMacro("$(HOME)/alirootcode/XFunct.C"); + gStyle->SetStatBorderSize(1); + gStyle->SetTitleBorderSize(0); + +} -- 2.31.1