From d08b5461bbbd89372fc17344e62c7a9dfca1c607 Mon Sep 17 00:00:00 2001 From: ivana Date: Tue, 27 Nov 2007 17:20:01 +0000 Subject: [PATCH] Adding new classes to revive the combined tracking (Laurent) --- MUON/AliMUONSimpleClusterServer.cxx | 388 ++++++++++++++++++++++++++++ MUON/AliMUONSimpleClusterServer.h | 61 +++++ MUON/AliMUONVClusterServer.cxx | 55 ++++ MUON/AliMUONVClusterServer.h | 40 +++ MUON/MUONrecLinkDef.h | 4 +- MUON/libMUONrec.pkg | 7 +- 6 files changed, 551 insertions(+), 4 deletions(-) create mode 100644 MUON/AliMUONSimpleClusterServer.cxx create mode 100644 MUON/AliMUONSimpleClusterServer.h create mode 100644 MUON/AliMUONVClusterServer.cxx create mode 100644 MUON/AliMUONVClusterServer.h diff --git a/MUON/AliMUONSimpleClusterServer.cxx b/MUON/AliMUONSimpleClusterServer.cxx new file mode 100644 index 00000000000..1006c960845 --- /dev/null +++ b/MUON/AliMUONSimpleClusterServer.cxx @@ -0,0 +1,388 @@ +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* 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. * +**************************************************************************/ + +// $Id$ + +#include "AliMUONSimpleClusterServer.h" + +#include "AliMUONConstants.h" +#include "AliMUONCluster.h" +#include "AliMUONGeometryTransformer.h" +#include "AliMUONPad.h" +#include "AliMUONVCluster.h" +#include "AliMUONVClusterFinder.h" +#include "AliMUONVClusterStore.h" +#include "AliMUONVDigitStore.h" +#include "AliMpArea.h" +#include "AliMpDEIterator.h" +#include "AliMpDEManager.h" +#include "AliMpExMap.h" +#include "AliMpSegmentation.h" +#include "AliMpVSegmentation.h" +#include "AliLog.h" +#include +#include +#include + +/// \class AliMUONSimpleClusterServer +/// +/// Implementation of AliMUONVClusterServer interface +/// +/// +/// \author Laurent Aphecetche, Subatech + +/// \cond CLASSIMP +ClassImp(AliMUONSimpleClusterServer) +/// \endcond + +namespace +{ + TString AsString(const AliMpArea& area) + { + return Form("(X,Y)=(%7.3f,%7.3f) (DX,DY)=(%7.3f,%7.3f)", + area.Position().X(), + area.Position().Y(), + area.Dimensions().Y(), + area.Dimensions().Y()); + } +} + +//_____________________________________________________________________________ +AliMUONSimpleClusterServer::AliMUONSimpleClusterServer(AliMUONVClusterFinder& clusterFinder, + const AliMUONGeometryTransformer& transformer) +: AliMUONVClusterServer(), + fClusterFinder(clusterFinder), + fTransformer(transformer), + fPads(), + fDEAreas(new AliMpExMap(true)) +{ + /// Ctor + + AliMpDEIterator it; + + it.First(); + + /// Generate the DE areas in global coordinates + + while ( !it.IsDone() ) + { + Int_t detElemId = it.CurrentDEId(); + + const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0); + + Double_t xg,yg,zg; + + AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); + + Double_t xl(0.0), yl(0.0), zl(0.0); + Double_t dx(seg->Dimensions().X()); + Double_t dy(seg->Dimensions().Y()); + + if ( stationType == AliMp::kStation1 || stationType == AliMp::kStation2 ) + { + /// mind your steps : dimensions are full sizes for St12, but half-sizes + /// for St345... + + xl = dx; + yl = dy; + + fTransformer.Local2Global(detElemId,xl,yl,zl,xg,yg,zg); + } + else + { + fTransformer.Local2Global(detElemId,xl,yl,zl,xg,yg,zg); + } + + fDEAreas->Add(detElemId,new AliMpArea(TVector2(xg,yg),TVector2(dx,dy))); + + it.Next(); + } +} + +//_____________________________________________________________________________ +AliMUONSimpleClusterServer::~AliMUONSimpleClusterServer() +{ + /// Dtor + delete fPads[0]; + delete fPads[1]; + delete fDEAreas; +} + +//_____________________________________________________________________________ +Int_t +AliMUONSimpleClusterServer::Clusterize(Int_t chamberId, + AliMUONVClusterStore& clusterStore, + const AliMpArea& area) +{ + /// Area is in absolute coordinate. If not valid, means clusterize all + /// the chamber. + /// + /// We first find out the list of DE that have a non-zero overlap with area, + /// and then use the clusterfinder to find clusters in those areas (and DE). + + AliMpDEIterator it; + + it.First(chamberId); + + Int_t nofAddedClusters(0); + Int_t fNCluster = clusterStore.GetSize(); + + AliDebug(1,Form("chamberId = %2d NofClusters before = %d searchArea=%s", + chamberId,fNCluster,AsString(area).Data())); + + while ( !it.IsDone() ) + { + Int_t detElemId = it.CurrentDEId(); + + TClonesArray* pads[2] = + { + static_cast(fPads[0]->GetValue(detElemId)), + static_cast(fPads[1]->GetValue(detElemId)) + }; + + if ( ( pads[0] && pads[0]->GetLast()>=0 ) || + ( pads[1] && pads[1]->GetLast()>=0 ) ) + { + AliMpArea deArea; // area in DE-local-coordinates + Bool_t ok(kTRUE); + + if ( area.IsValid() ) + { + ok = Overlap(detElemId,area,deArea); + } + + if ( ok ) + { + if ( fClusterFinder.NeedSegmentation() ) + { + const AliMpVSegmentation* seg[2] = + { AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0), + AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath1) + }; + fClusterFinder.Prepare(detElemId,pads,deArea,seg); + } + else + { + fClusterFinder.Prepare(detElemId,pads,deArea); + } + + AliDebug(1,Form("Clusterizing DE %04d with %3d pads (cath0) and %3d pads (cath1)", + detElemId, + (pads[0] ? pads[0]->GetLast()+1 : 0), + (pads[1] ? pads[1]->GetLast()+1 : 0))); + + AliMUONCluster* cluster; + + while ( ( cluster = fClusterFinder.NextCluster() ) ) + { + // add new cluster to the store with information to build its ID + // increment the number of clusters into the store + AliMUONVCluster* rawCluster = clusterStore.Add(AliMpDEManager::GetChamberId(detElemId), detElemId, fNCluster++); + + ++nofAddedClusters; + + // fill array of Id of digits attached to this cluster + Int_t nPad = cluster->Multiplicity(); + if (nPad < 1) AliWarning("no pad attached to the cluster"); + + for (Int_t iPad=0; iPadPad(iPad); + rawCluster->AddDigitId(pad->GetUniqueID()); + } + + // fill charge and other cluster informations + rawCluster->SetCharge(cluster->Charge()); + + Double_t xg, yg, zg; + fTransformer.Local2Global(detElemId, + cluster->Position().X(), cluster->Position().Y(), + 0, xg, yg, zg); + rawCluster->SetXYZ(xg, yg, zg); + + AliDebug(1,Form("Adding RawCluster detElemId %4d mult %2d charge %e (xl,yl,zl)=(%e,%e,%e) (xg,yg,zg)=(%e,%e,%e)", + detElemId,nPad,cluster->Charge(), + cluster->Position().X(),cluster->Position().Y(),0.0, + xg,yg,zg)); + } + } + } + it.Next(); + } + + AliDebug(1,Form("chamberId = %2d NofClusters after = %d",chamberId,fNCluster)); + + return nofAddedClusters; +} + +//_____________________________________________________________________________ +void +AliMUONSimpleClusterServer::Global2Local(Int_t detElemId, const AliMpArea& globalArea, + AliMpArea& localArea) const +{ + /// Convert a global area in local area for a given DE + + Double_t xl,yl,zl; + + Double_t zg = AliMUONConstants::DefaultChamberZ(AliMpDEManager::GetChamberId(detElemId)); + + fTransformer.Global2Local(detElemId, + globalArea.Position().X(),globalArea.Position().Y(),zg, + xl,yl,zl); + + localArea = AliMpArea(TVector2(xl,yl), globalArea.Dimensions()); +} + +//_____________________________________________________________________________ +Bool_t +AliMUONSimpleClusterServer::Overlap(Int_t detElemId, + const AliMpArea& area, + AliMpArea& deArea) const +{ + /// Check whether (global) area overlaps with the given DE. + /// If it is, set deArea to the overlap region and convert it + /// in the local coordinate system of that DE. + + Bool_t overlap(kFALSE); + + AliMpArea* globalDEArea = static_cast(fDEAreas->GetValue(detElemId)); + + AliMpArea overlapArea; + + if ( area.Overlap(*globalDEArea) ) + { + overlapArea = area.Intersect(*globalDEArea); + Global2Local(detElemId,overlapArea,deArea); + overlap = kTRUE; + } + else + { + deArea = AliMpArea(); + } + + AliDebug(1,Form("DE %04d area %s globalDEArea %s overlapArea %s deArea %s overlap=%d", + detElemId, + AsString(area).Data(), + AsString(*globalDEArea).Data(), + AsString(overlapArea).Data(), + AsString(deArea).Data(), + overlap)); + + return overlap; +} + +//_____________________________________________________________________________ +TClonesArray* +AliMUONSimpleClusterServer::PadArray(Int_t detElemId, Int_t cathode) const +{ + /// Return array for given cathode of given DE + + return static_cast(fPads[cathode]->GetValue(detElemId)); +} + +//_____________________________________________________________________________ +void +AliMUONSimpleClusterServer::UseDigitStore(const AliMUONVDigitStore& digitStore) +{ + /// Convert digitStore into two arrays of AliMUONPads + + delete fPads[0]; + delete fPads[1]; + + fPads[0] = new AliMpExMap(true); + fPads[1] = new AliMpExMap(true); + + TIter next(digitStore.CreateIterator()); + AliMUONVDigit* d; + + while ( ( d = static_cast(next()) ) ) + { + if ( ! d->Charge() > 0 ) continue; // skip void digits. + Int_t ix = d->PadX(); + Int_t iy = d->PadY(); + Int_t cathode = d->Cathode(); + Int_t detElemId = d->DetElemId(); + const AliMpVSegmentation* seg = AliMpSegmentation::Instance()-> + GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode)); + AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy)); + + TClonesArray* padArray = PadArray(detElemId,cathode); + if (!padArray) + { + padArray = new TClonesArray("AliMUONPad",100); + fPads[cathode]->Add(detElemId,padArray); + } + + AliMUONPad mpad(detElemId,cathode, + ix,iy,pad.Position().X(),pad.Position().Y(), + pad.Dimensions().X(),pad.Dimensions().Y(), + d->Charge()); + if ( d->IsSaturated() ) mpad.SetSaturated(kTRUE); + mpad.SetUniqueID(d->GetUniqueID()); + new ((*padArray)[padArray->GetLast()+1]) AliMUONPad(mpad); + } +} + +//_____________________________________________________________________________ +void +AliMUONSimpleClusterServer::Print(Option_t*) const +{ + /// Printout for debug only + + AliMpDEIterator it; + + it.First(); + + while ( !it.IsDone() ) + { + Int_t detElemId = it.CurrentDEId(); + + // printout the number of pads / de, and number of used pads / de + + if ( ( PadArray(detElemId,0) && PadArray(detElemId,0)->GetLast() >= 0 ) || + ( PadArray(detElemId,1) && PadArray(detElemId,1)->GetLast() >= 0 ) ) + { + cout << Form("---- DE %04d",detElemId) << endl; + + for ( Int_t cathode = 0; cathode < 2; ++cathode ) + { + cout << Form(" -- Cathode %1d",cathode) << endl; + + TClonesArray* padArray = PadArray(detElemId,cathode); + + if (!padArray) + { + cout << "no pad array" << endl; + } + else if ( padArray->GetLast() < 0 ) + { + cout << "no pads" << endl; + } + else + { + TIter next(padArray); + AliMUONPad* pad; + while ( ( pad = static_cast(next()) ) ) + { + pad->Print("full"); + } + } + } + } + it.Next(); + } +} + + diff --git a/MUON/AliMUONSimpleClusterServer.h b/MUON/AliMUONSimpleClusterServer.h new file mode 100644 index 00000000000..33be8834923 --- /dev/null +++ b/MUON/AliMUONSimpleClusterServer.h @@ -0,0 +1,61 @@ +#ifndef ALIMUONSIMPLECLUSTERSERVER_H +#define ALIMUONSIMPLECLUSTERSERVER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup reco +/// \class AliMUONSimpleClusterServer +/// \brief Implementation of AliMUONVClusterServer interface +/// +// Author Laurent Aphecetche, Subatech + +#ifndef ALIMUONVCLUSTERSERVER_H +# include "AliMUONVClusterServer.h" +#endif + +class AliMUONVClusterFinder; +class AliMUONGeometryTransformer; +class TClonesArray; +class AliMpExMap; + +class AliMUONSimpleClusterServer : public AliMUONVClusterServer +{ +public: + AliMUONSimpleClusterServer(AliMUONVClusterFinder& clusterFinder, + const AliMUONGeometryTransformer& transformer); + + virtual ~AliMUONSimpleClusterServer(); + + Int_t Clusterize(Int_t chamberId, + AliMUONVClusterStore& clusterStore, + const AliMpArea& area); + + void UseDigitStore(const AliMUONVDigitStore& digitStore); + + void Print(Option_t* opt="") const; + +private: + /// Not implemented + AliMUONSimpleClusterServer(const AliMUONSimpleClusterServer& rhs); + /// Not implemented + AliMUONSimpleClusterServer& operator=(const AliMUONSimpleClusterServer& rhs); + + Bool_t Overlap(Int_t detElemId, const AliMpArea& area, AliMpArea& deArea) const; + + void Global2Local(Int_t detElemId, const AliMpArea& globalArea, AliMpArea& localArea) const; + + TClonesArray* PadArray(Int_t detElemId, Int_t cathode) const; + +private: + AliMUONVClusterFinder& fClusterFinder; //!< the cluster finder + const AliMUONGeometryTransformer& fTransformer; //!< the geometry transformer + AliMpExMap* fPads[2]; ///< map of TClonesArray of AliMUONPads + AliMpExMap* fDEAreas; ///< map of detection element areas in global coordinates + + ClassDef(AliMUONSimpleClusterServer,0) // Cluster server +}; + +#endif diff --git a/MUON/AliMUONVClusterServer.cxx b/MUON/AliMUONVClusterServer.cxx new file mode 100644 index 00000000000..da56c172e74 --- /dev/null +++ b/MUON/AliMUONVClusterServer.cxx @@ -0,0 +1,55 @@ +/************************************************************************** +* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* * +* Author: The ALICE Off-line Project. * +* Contributors are mentioned in the code where appropriate. * +* * +* 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. * +**************************************************************************/ + +// $Id$ + +/// \class AliMUONVClusterServer +/// +/// Interface of a cluster finder for combined tracking +/// +/// The tracking, when in needs for clusters, will ask the cluster server +/// to add clusters, from a given region in a given chamber, to an existing +/// clusterstore, using the +/// +/// Clusterize(Int_t chamberId, AliMUONVClusterStore& clusterStore, const AliMpArea& area) +/// +/// method +/// +/// Cluster server must be instructed (at the beginning of each event) +/// about which digits to use, using the +/// +/// UseDigitStore(const AliMUONVDigitStore& digitStore) +/// +/// method. +/// +/// \author Laurent Aphecetche, Subatech + +#include "AliMUONVClusterServer.h" + +/// \cond CLASSIMP +ClassImp(AliMUONVClusterServer) +/// \endcond + +//_____________________________________________________________________________ +AliMUONVClusterServer::AliMUONVClusterServer() +{ + /// ctor +} + +//_____________________________________________________________________________ +AliMUONVClusterServer::~AliMUONVClusterServer() +{ + /// dtor +} diff --git a/MUON/AliMUONVClusterServer.h b/MUON/AliMUONVClusterServer.h new file mode 100644 index 00000000000..e79972d2a5d --- /dev/null +++ b/MUON/AliMUONVClusterServer.h @@ -0,0 +1,40 @@ +#ifndef ALIMUONVCLUSTERSERVER_H +#define ALIMUONVCLUSTERSERVER_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +* See cxx source for full Copyright notice */ + +// $Id$ + +/// \ingroup reco +/// \class AliMUONVClusterServer +/// \brief Interface of a cluster finder for combined tracking +/// +// Author Laurent Aphecetche, Subatech + +#ifndef ROOT_TObject +# include "TObject.h" +#endif + +class AliMUONVClusterStore; +class AliMUONVDigitStore; +class AliMpArea; + +class AliMUONVClusterServer : public TObject +{ +public: + AliMUONVClusterServer(); + virtual ~AliMUONVClusterServer(); + + /// Find and add clusters from a given region of a given chamber to the store. + virtual Int_t Clusterize(Int_t chamberId, + AliMUONVClusterStore& clusterStore, + const AliMpArea& area) = 0; + + /// Use digits from the given digitstore to perform our job. + virtual void UseDigitStore(const AliMUONVDigitStore& digitStore) = 0; + + ClassDef(AliMUONVClusterServer,1) // Cluster server interface +}; + +#endif diff --git a/MUON/MUONrecLinkDef.h b/MUON/MUONrecLinkDef.h index 7f30c14b7dd..ff1f9932cc6 100644 --- a/MUON/MUONrecLinkDef.h +++ b/MUON/MUONrecLinkDef.h @@ -9,7 +9,6 @@ #pragma link off all functions; // reconstruction -#pragma link C++ class AliMUONClusterReconstructor+; #pragma link C++ class AliMUONPixel+; #pragma link C++ class AliMUONReconstructor+; #pragma link C++ class AliMUONVTrackReconstructor+; @@ -46,6 +45,9 @@ #pragma link C++ class AliMUONRecoParam+; +#pragma link C++ class AliMUONVClusterServer+; +#pragma link C++ class AliMUONSimpleClusterServer+; + // calibration #pragma link C++ class AliMUONDigitCalibrator+; #pragma link C++ class AliMUONPadStatusMaker+; diff --git a/MUON/libMUONrec.pkg b/MUON/libMUONrec.pkg index fe2a0934f77..b0fa2daf35e 100644 --- a/MUON/libMUONrec.pkg +++ b/MUON/libMUONrec.pkg @@ -1,7 +1,6 @@ # $Id$ -SRCS:= AliMUONClusterReconstructor.cxx \ - AliMUONPixel.cxx \ +SRCS:= AliMUONPixel.cxx \ AliMUONReconstructor.cxx \ AliMUONVTrackReconstructor.cxx \ AliMUONTrackReconstructor.cxx \ @@ -36,7 +35,9 @@ SRCS:= AliMUONClusterReconstructor.cxx \ AliMUONClusterStoreV2Iterator.cxx \ AliMUONVTrackStore.cxx \ AliMUONTrackStoreV1.cxx \ - AliMUONRecoParam.cxx + AliMUONRecoParam.cxx \ + AliMUONVClusterServer.cxx \ + AliMUONSimpleClusterServer.cxx HDRS:= $(SRCS:.cxx=.h) -- 2.43.0