**************************************************************************/
// $Id$
-// $MpId: AliMpSt345Reader.cxx,v 1.9 2006/03/02 16:36:23 ivana Exp $
+// $MpId: AliMpSt345Reader.cxx,v 1.11 2006/05/24 13:58:50 ivana Exp $
#include "AliMpSt345Reader.h"
#include "AliLog.h"
+#include "AliMpSlatMotifMap.h"
#include "AliMpMotifReader.h"
#include "AliMpFiles.h"
#include "AliMpMotifType.h"
#include "AliMpPCB.h"
#include "AliMpSlat.h"
-#include "AliMpMotifMap.h"
#include "AliMpMotifPosition.h"
#include "AliMpMotif.h"
#include "AliMpHelper.h"
#include "TString.h"
#include <sstream>
-#include <assert.h>
-TMap AliMpSt345Reader::fgPCBMap;
+///
+/// \class AliMpSt345Reader
+//
+/// Read slat and pcb ASCII files.
+///
+/// Basically this class provides two methods :
+/// - AliMpSlat* ReadSlat()
+/// - AliMpPCB ReadPCB()
+///
+/// \author Laurent Aphecetche
+/// \cond CLASSIMP
ClassImp(AliMpSt345Reader)
+/// \endcond
//_____________________________________________________________________________
-AliMpSt345Reader::AliMpSt345Reader() : TObject()
+AliMpSt345Reader::AliMpSt345Reader(AliMpSlatMotifMap& motifMap)
+:
+TObject(),
+fMotifMap(motifMap)
{
//
// Default ctor.
//
// Dtor.
//
- fgPCBMap.Delete();
-}
-
-//_____________________________________________________________________________
-AliMpPCB*
-AliMpSt345Reader::PCB(const char* pcbType)
-{
- //
- // Get access to an AliMpPCB object, given its type (e.g. N1, SB2, etc...)
- //
- // Note that the returned object is either a new one (read from file) or a
- // reused one if it is already present in the internal map.
- //
-
- TPair* pair = (TPair*)fgPCBMap.FindObject(pcbType);
- if ( pair )
- {
- AliDebugClass(1,Form("Getting pcb %s from internal map",pcbType));
- return (AliMpPCB*)pair->Value();
- }
- else
- {
- AliDebugClass(1,Form("Reading pcb %s from file",pcbType));
- return ReadPCB(pcbType);
- }
}
//_____________________________________________________________________________
AliMpPCB*
AliMpSt345Reader::ReadPCB(const char* pcbType)
{
- //
- // Create a new AliMpPCB object, by reading it from file.
- //
+ ///
+ /// Create a new AliMpPCB object, by reading it from file.
+ /// The returned object must be deleted by the client
- std::ifstream in(AliMpFiles::SlatPCBFilePath(kStation345,pcbType).Data());
+ std::ifstream in(AliMpFiles::SlatPCBFilePath(AliMp::kStation345,pcbType).Data());
if (!in.good())
{
AliErrorClass(Form("Cannot open file for PCB %s",pcbType));
return 0;
}
- AliMpMotifReader reader(kStation345,kNonBendingPlane);
+ AliMpMotifReader reader(AliMp::kStation345,AliMp::kNonBendingPlane);
// note that the nonbending
// parameter is of no use for station345, as far as reading motif is
// concerned, as all motifs are supposed to be in the same directory
{
std::istringstream sin(sline(kSizeKeyword.Length(),
sline.Length()-kSizeKeyword.Length()).Data());
- float padSizeX = 0.0;
- float padSizeY = 0.0;
- float pcbSizeX = 0.0;
- float pcbSizeY = 0.0;
+ double padSizeX = 0.0;
+ double padSizeY = 0.0;
+ double pcbSizeX = 0.0;
+ double pcbSizeY = 0.0;
sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY;
- assert(pcb==0);
- pcb = new AliMpPCB(pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
+ if (pcb)
+ {
+ AliError("pcb not null as expected");
+ }
+ pcb = new AliMpPCB(&fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
}
if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
int iy;
sin >> sMotifType >> ix >> iy;
- AliMpMotifType* motifType =
- reader.BuildMotifType(sMotifType.Data());
+ AliMpMotifType* motifType = fMotifMap.FindMotifType(sMotifType);
+ if (!motifType)
+ {
+ AliDebug(1,Form("Reading motifType %s from file",sMotifType.Data()));
+ motifType = reader.BuildMotifType(sMotifType.Data());
+ fMotifMap.AddMotifType(motifType);
+ }
+ else
+ {
+ AliDebug(1,Form("Got motifType %s from motifMap",sMotifType.Data()));
+ }
- assert(pcb!=0);
pcb->Add(motifType,ix,iy);
}
}
in.close();
- fgPCBMap.Add(new TObjString(pcbType),pcb);
return pcb;
}
//_____________________________________________________________________________
AliMpSlat*
-AliMpSt345Reader::ReadSlat(const char* slatType, AliMpPlaneType planeType)
+AliMpSt345Reader::ReadSlat(const char* slatType, AliMp::PlaneType planeType)
{
- //
- // Create a new AliMpSlat object, by reading it from file.
- //
+ ///
+ /// Create a new AliMpSlat object, by reading it from file.
+ /// The returned object must be deleted by the client.
- std::ifstream in(AliMpFiles::SlatFilePath(kStation345,slatType,
+ std::ifstream in(AliMpFiles::SlatFilePath(AliMp::kStation345,slatType,
planeType).Data());
if (!in.good())
{
AliErrorClass(Form("Cannot read slat from %s",
- AliMpFiles::SlatFilePath(kStation345,slatType,planeType).Data()));
+ AliMpFiles::SlatFilePath(AliMp::kStation345,slatType,planeType).Data()));
return 0;
}
TString pcbName(tmp(0,blankPos));
TString manus(tmp(blankPos+1,tmp.Length()-blankPos));
- AliMpPCB* pcbType = PCB(pcbName.Data());
+ AliMpPCB* pcbType = ReadPCB(pcbName.Data());
if (!pcbType)
{
AliErrorClass(Form("Cannot read pcbType=%s",pcbName.Data()));
AliErrorClass(Form("Wrong number of manu ids for this PCB ("
"%s) : %d out of %d",pcbName.Data(),
manuList.GetSize(),pcbType->GetSize()));
+ delete pcbType;
delete slat;
return 0;
}
{
manuList[i] |= AliMpConstants::ManuMask(planeType);
}
- slat->Add(pcbType,manuList);
+ slat->Add(*pcbType,manuList);
+ delete pcbType;
}
}