connections.
--- /dev/null
+/**************************************************************************
+ * 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$
+// $MpId: AliMpDDL.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
+// Category: management
+//
+// Class AliMpDDL
+// --------------------
+// The class defines electronics properties of DDL
+// Authors: Ivana Hrivnacova, IPN Orsay
+// Christian Finck, SUBATECH Nantes
+
+#include "AliMpDDL.h"
+#include "AliMpDEManager.h"
+#include "AliMpDetElement.h"
+
+#include "AliLog.h"
+
+#include <Riostream.h>
+
+
+/// \cond CLASSIMP
+ClassImp(AliMpDDL)
+/// \endcond
+
+//______________________________________________________________________________
+AliMpDDL::AliMpDDL(Int_t id)
+ : TObject(),
+ fId(id),
+ fDEIds(),
+ fBusPatchIds()
+{
+/// Standard constructor
+}
+
+//______________________________________________________________________________
+AliMpDDL::AliMpDDL(TRootIOCtor* /*ioCtor*/)
+ : TObject(),
+ fId(0),
+ fDEIds(),
+ fBusPatchIds()
+{
+/// Root IO constructor
+}
+
+//______________________________________________________________________________
+AliMpDDL::~AliMpDDL()
+{
+/// Destructor
+}
+
+//
+// private methods
+//
+
+//______________________________________________________________________________
+void AliMpDDL::FillBusPatchIds()
+{
+/// Fill array with bus patch Ids
+
+ for ( Int_t i=0; i<GetNofDEs(); i++ ) {
+ AliMpDetElement* detElement
+ = AliMpDEManager::GetDetElement(GetDEId(i));
+
+ for ( Int_t j=0; j<detElement->GetNofBusPatches(); j++ )
+ fBusPatchIds.Add(detElement->GetBusPatchId(j));
+ }
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+Bool_t AliMpDDL::AddDE(Int_t detElemId)
+{
+/// Add detection element with given detElemId.
+/// Return true if the detection element was added
+
+ if ( ! AliMpDEManager::IsValidDetElemId(detElemId) ) return false;
+
+ if ( HasDEId(detElemId) ) {
+ AliWarningStream()
+ << "Detection element Id = " << detElemId << " already present."
+ << endl;
+ return false;
+ }
+
+ AliDebugStream(3) << "Adding detElemId " << detElemId << endl;
+
+ fDEIds.Add(detElemId);
+ return true;
+}
+
+//______________________________________________________________________________
+Int_t AliMpDDL::GetNofDEs() const
+{
+/// Return the number of detection elements connected to this DDL
+
+ return fDEIds.GetSize();
+}
+
+//______________________________________________________________________________
+Int_t AliMpDDL::GetDEId(Int_t index) const
+{
+/// Return the detection element by index (in loop)
+
+ return fDEIds.GetValue(index);
+}
+
+//______________________________________________________________________________
+Bool_t AliMpDDL::HasDEId(Int_t detElemId) const
+{
+/// Return true if the detection element Id is present
+
+ return fDEIds.HasValue(detElemId);;
+}
+
+//______________________________________________________________________________
+Int_t AliMpDDL::GetNofBusPatches() const
+{
+/// Return the number of detection elements connected to this DDL
+
+ return fBusPatchIds.GetSize();
+}
+
+//______________________________________________________________________________
+Int_t AliMpDDL::GetBusPatchId(Int_t index) const
+{
+/// Return the detection element by index (in loop)
+
+ return fBusPatchIds.GetValue(index);
+}
+
+//______________________________________________________________________________
+Bool_t AliMpDDL::HasBusPatchId(Int_t busPatchId) const
+{
+/// Return true if the detection element Id is present
+
+ return fBusPatchIds.HasValue(busPatchId);;
+}
+
+//____________________________________________________________________
+Int_t AliMpDDL::GetMaxDsp() const
+{
+/// calculates the number of DSP
+
+ Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
+
+ Int_t iDspMax = iBusPerBlk/5; //number max of DSP per block
+ if (iBusPerBlk % 5 != 0)
+ iDspMax += 1;
+
+ return iDspMax;
+}
+
+//____________________________________________________________________
+void AliMpDDL::GetBusPerDsp(Int_t* iBusPerDSP)
+const
+{
+/// calculates buspatch per block
+
+ Int_t iBusPerBlk = fBusPatchIds.GetSize()/2; //per block
+
+ for (Int_t i = 0; i < GetMaxDsp(); i++) {
+ if ((iBusPerBlk -= 5) > 0)
+ iBusPerDSP[i] = 5;
+ else
+ iBusPerDSP[i] = iBusPerBlk + 5;
+ }
+}
+
--- /dev/null
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $Id$
+// $MpId: AliMpDDL.h,v 1.6 2006/05/24 13:58:16 ivana Exp $
+
+/// \ingroup management
+/// \class AliMpDDL
+/// \brief The class defined electronics properties of DDL
+///
+/// \author Ivana Hrivnacova, IPN Orsay
+
+#ifndef ALI_MP_DDL_H
+#define ALI_MP_DDL_H
+
+#include <TObject.h>
+
+#include "AliMpArrayI.h"
+
+class AliMpDDL : public TObject {
+
+ public:
+ AliMpDDL(Int_t id);
+ AliMpDDL(TRootIOCtor* /*ioCtor*/);
+ virtual ~AliMpDDL();
+
+ // methods
+ Bool_t AddDE(Int_t detElemId);
+ void FillBusPatchIds();
+
+ // get methods
+ Int_t GetId() const;
+
+ // DEs
+ Int_t GetNofDEs() const;
+ Int_t GetDEId(Int_t index) const;
+ Bool_t HasDEId(Int_t detElemId) const;
+
+ // Bus patches
+ Int_t GetNofBusPatches() const;
+ Int_t GetBusPatchId(Int_t index) const;
+ Bool_t HasBusPatchId(Int_t busPatchId) const;
+
+ // Dsp info
+ Int_t GetMaxDsp() const;
+ void GetBusPerDsp(Int_t* iBusPerDSP) const;
+
+ private:
+ AliMpDDL();
+ AliMpDDL(const AliMpDDL& rhs);
+ AliMpDDL& operator=(const AliMpDDL& rhs);
+
+ // data members
+ Int_t fId; ///< Identifier (unique)
+ AliMpArrayI fDEIds; ///< Detection element Ids connected to this DDL
+ AliMpArrayI fBusPatchIds; ///< Bus patch Ids connected to this DDL
+
+
+ ClassDef(AliMpDDL,1) // The class collectiong electronics properties of DDL
+};
+
+// inline functions
+
+/// Return the unique Id
+inline Int_t AliMpDDL::GetId() const
+{ return fId; }
+
+#endif //ALI_MP_MANAGER_H
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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$
+// $MpId: AliMpDDLStore.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
+// Category: management
+//
+// Class AliMpDDLStore
+// --------------------
+// The top container class for DDLs, det elements and bus patched
+// It provides acces to DDL, det element and bus patches objects
+// via various characteristics.
+// Authors: Ivana Hrivnacova, IPN Orsay
+// Christian Finck, SUBATECH Nantes
+
+#include "AliMpDDLStore.h"
+#include "AliMpDEStore.h"
+#include "AliMpDDL.h"
+#include "AliMpFiles.h"
+#include "AliMpHelper.h"
+#include "AliMpDEManager.h"
+#include "AliMpDetElement.h"
+#include "AliMpBusPatch.h"
+
+#include "AliLog.h"
+
+#include <Riostream.h>
+
+/// \cond CLASSIMP
+ClassImp(AliMpDDLStore)
+/// \endcond
+
+AliMpDDLStore* AliMpDDLStore::fgInstance = 0;
+const Int_t AliMpDDLStore::fgkNofDDLs = 20;
+
+//
+// static methods
+//
+
+//______________________________________________________________________________
+AliMpDDLStore* AliMpDDLStore::Instance()
+{
+/// Create the DDL store if it does not yet exist
+/// and return its instance
+
+ if ( ! fgInstance )
+ fgInstance = new AliMpDDLStore();
+
+ return fgInstance;
+}
+
+//
+// ctors, dtor
+//
+
+//______________________________________________________________________________
+AliMpDDLStore::AliMpDDLStore()
+: TObject(),
+ fDDLs(fgkNofDDLs),
+ fDetElements(AliMpDEStore::Instance()),
+ fBusPatches(true)
+{
+/// Standard constructor
+
+ AliDebug(1,"");
+ fDDLs.SetOwner(true);
+ fBusPatches.SetOwner(true);
+ fBusPatches.SetSize(900);
+
+ // Create all detection elements
+ ReadDDLs();
+}
+
+//______________________________________________________________________________
+AliMpDDLStore::AliMpDDLStore(TRootIOCtor* /*ioCtor*/)
+: TObject(),
+ fDDLs(),
+ fDetElements(0),
+ fBusPatches()
+{
+/// Constructor for IO
+
+ AliDebug(1,"");
+
+ fgInstance = this;
+}
+
+
+//______________________________________________________________________________
+AliMpDDLStore::~AliMpDDLStore()
+{
+/// Destructor
+
+ AliDebug(1,"");
+
+ delete fDetElements;
+
+ // DDL objects are deleted with fDDLs
+ // Bus patches objects are deleted with fBusPatches
+
+ fgInstance = 0;
+}
+
+//
+// private methods
+//
+
+//______________________________________________________________________________
+Bool_t AliMpDDLStore::ReadDDLs()
+{
+/// Read ddl <-> bus patch file
+
+ TString infile = AliMpFiles::BusPatchFilePath();
+
+ ifstream in(infile, ios::in);
+ if (!in) {
+ AliErrorStream() << "Data file " << infile << " not found.";
+ return false;
+ }
+
+ char line[80];
+
+ while ( in.getline(line,80) ) {
+
+ if ( line[0] == '#' ) continue;
+
+ TString tmp(AliMpHelper::Normalize(line));
+
+ Int_t blankPos = tmp.First(' ');
+ Int_t blankPos1 = tmp.Last(' ');
+
+ TString sDE(tmp(0, blankPos));
+
+ Int_t idDE = atoi(sDE.Data());
+
+ TString sDDL(tmp(blankPos1 + 1, tmp.Length()-blankPos1));
+
+ Int_t iDDL = atoi(sDDL.Data());
+
+ // always working local DDL number... for the moment.
+
+ // not really needed remove for stand alone purpose (Ch.F)
+ // if (iDDL >= AliDAQ::DdlIDOffset("MUONTRK"))
+ // iDDL -= AliDAQ::DdlIDOffset("MUONTRK");
+
+
+ TString busPatch(tmp(blankPos + 1,blankPos1-blankPos-1));
+ AliDebugStream(3)
+ << "idDE " << idDE << " buspatch " << busPatch.Data() << " iDDL " << iDDL
+ << endl;
+
+ if ( iDDL < 0 || iDDL >= fgkNofDDLs ) {
+ AliErrorStream() << "DDL id "<< iDDL << " outside limits." << endl;
+ return false;
+ }
+
+ if ( ! AliMpDEManager::IsValidDetElemId(idDE, false) ) {
+ AliErrorStream() << "DetElemId "<< idDE << " not valid." << endl;
+ return false;
+ }
+
+
+ AliMpDDL* ddl = GetDDL(iDDL, false);
+ if ( !ddl) {
+ ddl = new AliMpDDL(iDDL);
+ fDDLs.AddAt(ddl, iDDL);
+ }
+ ddl->AddDE(idDE);
+
+
+ TArrayI busPatchList;
+ // decoding range of buspatch
+ AliMpHelper::DecodeName(busPatch,';',busPatchList);
+
+ // Update DE
+ AliMpDetElement* de = AliMpDEManager::GetDetElement(idDE);
+ de->SetDdlId(iDDL);
+ // filling buspatch -> idDE
+ for (Int_t i = 0; i < busPatchList.GetSize(); i++) {
+ fBusPatches.Add(busPatchList[i],
+ new AliMpBusPatch(busPatchList[i], idDE, iDDL));
+ de->AddBusPatch(busPatchList[i]);
+ }
+ }
+
+ // Fill bus patch Ids array in DDLs now
+ for ( Int_t i=0; i<fDDLs.GetEntriesFast(); i++ ) {
+ AliMpDDL* ddl = (AliMpDDL*) fDDLs.At(i);
+ ddl->FillBusPatchIds();
+ }
+
+ in.close();
+ return true;
+}
+
+//
+// public methods
+//
+
+
+//______________________________________________________________________________
+AliMpDDL* AliMpDDLStore::GetDDL(Int_t ddlId, Bool_t warn) const
+{
+/// Return DDL for given ddlId
+
+ AliMpDDL* ddl
+ = (AliMpDDL*)fDDLs.At(ddlId);
+
+ if ( ! ddl && warn ) {
+ AliErrorStream()
+ << "DDL with Id = " << ddlId << " not defined." << endl;
+ }
+
+ return ddl;
+}
+
+//______________________________________________________________________________
+AliMpDetElement* AliMpDDLStore::GetDetElement(Int_t detElemId, Bool_t warn) const
+{
+/// Return detection element with given detElemId
+
+ return fDetElements->GetDetElement(detElemId, warn);
+}
+
+//______________________________________________________________________________
+AliMpBusPatch* AliMpDDLStore::GetBusPatch(Int_t busPatchId, Bool_t warn) const
+{
+/// Return bus patch with given Id
+
+ AliMpBusPatch* busPatch
+ = (AliMpBusPatch*) fBusPatches.GetValue(busPatchId);
+
+ if ( ! busPatch && warn ) {
+ AliErrorStream()
+ << "Bus patch with Id = " << busPatchId << " not defined." << endl;
+ }
+
+ return busPatch;
+}
+
+//______________________________________________________________________________
+Int_t AliMpDDLStore::GetDEfromBus(Int_t busPatchId) const
+{
+/// Return detection element Id for given busPatchId
+
+ AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
+
+ if ( ! busPatch ) {
+ AliErrorStream()
+ << "Bus patch with Id = " << busPatchId << " not defined." << endl;
+ return 0;
+ }
+
+ return busPatch->GetDEId();
+}
+
+//______________________________________________________________________________
+Int_t AliMpDDLStore::GetDDLfromBus(Int_t busPatchId) const
+{
+/// Return DDL Id for given busPatchId
+
+ AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
+
+ if ( ! busPatch ) {
+ AliErrorStream()
+ << "Bus patch with Id = " << busPatchId << " not defined." << endl;
+ return 0;
+ }
+
+ return busPatch->GetDdlId();
+}
+
+//______________________________________________________________________________
+AliMpIntPair AliMpDDLStore::GetDetElemIdManu(Int_t manuSerial) const
+{
+/// Return the detElemId and manuId for given serial manu number
+
+ return fDetElements->GetDetElemIdManu(manuSerial);
+}
--- /dev/null
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $Id$
+// $MpId: AliMpDDLStore.h,v 1.6 2006/05/24 13:58:16 ivana Exp $
+
+/// \ingroup management
+/// \class AliMpDDLStore
+/// \brief The top container class for DDLs, det elements and bus patched
+///
+/// It provides acces to DDL, det element and bus patches objects
+/// via various characteristics.
+///
+/// \author Ivana Hrivnacova, IPN Orsay;
+/// Christian Finck, SUBATECH Nantes
+
+#ifndef ALI_MP_DDL_STORE_H
+#define ALI_MP_DDL_STORE_H
+
+#include <TObject.h>
+#include <TObjArray.h>
+
+#include "AliMpExMap.h"
+#include "AliMpIntPair.h"
+
+class AliMpDDL;
+class AliMpDetElement;
+class AliMpBusPatch;
+class AliMpDEStore;
+
+class AliMpDDLStore : public TObject {
+
+ public:
+ AliMpDDLStore(TRootIOCtor* /*ioCtor*/);
+ virtual ~AliMpDDLStore();
+
+ // static access method
+ static AliMpDDLStore* Instance();
+
+ // methods
+ AliMpDDL* GetDDL(Int_t ddlId, Bool_t warn = true) const;
+ AliMpDetElement* GetDetElement(Int_t detElemId, Bool_t warn = true) const;
+ AliMpBusPatch* GetBusPatch(Int_t busPatchId, Bool_t warn = true) const;
+
+ Int_t GetDEfromBus(Int_t busPatchId) const;
+ Int_t GetDDLfromBus(Int_t busPatchId) const;
+ //void GetDspInfo(Int_t iDDL, Int_t& iDspMax, Int_t* iBusPerDSP) const;
+
+ AliMpIntPair GetDetElemIdManu(Int_t manuSerial) const;
+
+ private:
+ AliMpDDLStore();
+ AliMpDDLStore(const AliMpDDLStore& rhs);
+ AliMpDDLStore& operator=(const AliMpDDLStore& rhs);
+
+ // methods
+ Bool_t ReadDDLs();
+
+ // static data members
+ static AliMpDDLStore* fgInstance; ///< Singleton instance
+ static const Int_t fgkNofDDLs; ///< Total number of DDLs
+
+ // data members
+ TObjArray fDDLs; ///< Array of DDL objects
+ AliMpDEStore* fDetElements; ///< Detection element store
+ AliMpExMap fBusPatches; ///< The map of bus patches per their IDs
+
+ ClassDef(AliMpDDLStore,1) // The manager class for definition of detection element types
+};
+
+#endif //ALI_MP_DDL_STORE_H
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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$
+// $MpId: AliMpDEStore.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
+// Category: management
+//
+// Class AliMpDEStore
+// --------------------
+// The container class for detection element objects
+// Authors: Ivana Hrivnacova, IPN Orsay
+// Laurent Aphecetche, Christian Finck, SUBATECH Nantes
+
+#include "AliMpDEStore.h"
+#include "AliMpDEManager.h"
+#include "AliMpDetElement.h"
+#include "AliMpConstants.h"
+#include "AliMpFiles.h"
+#include "AliMpHelper.h"
+#include "AliMpIntPair.h"
+#include "AliMpConstants.h"
+
+#include "AliLog.h"
+
+#include <Riostream.h>
+#include <TSystem.h>
+#include <TObjString.h>
+#include <TMap.h>
+
+/// \cond CLASSIMP
+ClassImp(AliMpDEStore)
+/// \endcond
+
+AliMpDEStore* AliMpDEStore::fgInstance = 0;
+const char AliMpDEStore::fgkCommentPrefix = '#';
+
+//
+// static methods
+//
+
+//______________________________________________________________________________
+AliMpDEStore* AliMpDEStore::Instance()
+{
+/// Create the DE store if it does not yet exist
+/// and return its instance
+
+ if ( ! fgInstance )
+ fgInstance = new AliMpDEStore();
+
+ return fgInstance;
+}
+
+//
+// ctors, dtor
+//
+
+//______________________________________________________________________________
+AliMpDEStore::AliMpDEStore()
+: TObject(),
+ fDetElements(true)
+{
+/// Standard constructor
+
+ AliDebug(1,"");
+ fDetElements.SetOwner(true);
+
+ // Create all detection elements
+ FillDEs();
+}
+
+//______________________________________________________________________________
+AliMpDEStore::AliMpDEStore(TRootIOCtor* /*ioCtor*/)
+: TObject(),
+ fDetElements()
+{
+/// Constructor for IO
+
+ AliDebug(1,"");
+
+ fgInstance = this;
+}
+
+
+//______________________________________________________________________________
+AliMpDEStore::~AliMpDEStore()
+{
+/// Destructor
+
+ AliDebug(1,"");
+
+ // Segmentations are deleted with fMpSegmentations
+ // El cards arrays are deleted with fElCardsMap
+
+ fgInstance = 0;
+}
+
+//
+// private methods
+//
+
+//______________________________________________________________________________
+Bool_t AliMpDEStore::IsPlaneType(const TString& planeTypeName)
+{
+/// Return true if the planeTypeName corresponds to a valid plane type
+
+ if ( planeTypeName == PlaneTypeName(AliMp::kBendingPlane) ||
+ planeTypeName == PlaneTypeName(AliMp::kNonBendingPlane) )
+ return true;
+
+ return false;
+}
+
+//______________________________________________________________________________
+AliMp::PlaneType AliMpDEStore::PlaneType(const TString& planeTypeName)
+{
+/// Return plane type for the given planeTypeName \n
+/// Fatal error if planeTypeName is wrong
+
+ if ( planeTypeName == PlaneTypeName(AliMp::kBendingPlane) )
+ return AliMp::kBendingPlane;
+
+ if ( planeTypeName == PlaneTypeName(AliMp::kNonBendingPlane) )
+ return AliMp::kNonBendingPlane;
+
+ // Should never reach this line
+ AliFatalClass(Form("No plane type defined for %s", planeTypeName.Data()));
+ return AliMp::kBendingPlane;
+}
+
+//______________________________________________________________________________
+AliMp::StationType AliMpDEStore::StationType(const TString& stationTypeName)
+{
+/// Return station type for the given stationTypeName \n
+/// Fatal error if stationTypeName is wrong
+
+ if ( stationTypeName == StationTypeName(AliMp::kStation1) )
+ return AliMp::kStation1;
+
+ if ( stationTypeName == StationTypeName(AliMp::kStation2) )
+ return AliMp::kStation2;
+
+ if ( stationTypeName == StationTypeName(AliMp::kStation345) )
+ return AliMp::kStation345;
+
+ if ( stationTypeName == StationTypeName(AliMp::kStationTrigger) )
+ return AliMp::kStationTrigger;
+
+ // Should never reach this line
+ AliFatalClass(Form("No station type defined for ", stationTypeName.Data()));
+ return AliMp::kStation1;
+}
+
+//______________________________________________________________________________
+Bool_t AliMpDEStore::ReadManuToSerialNbs(AliMpDetElement* detElement,
+ AliMp::StationType stationType)
+{
+/// Read manu serial numbers for the given detection element
+
+ TString deName = detElement->GetDEName();
+
+ TString infile = AliMpFiles::ManuToSerialPath(deName, stationType);
+ ifstream in(infile, ios::in);
+
+ // Change to Error when all files available
+ //if ( !in.is_open() && stationType == AliMp::kStation345 ) {
+ // AliWarningStream() << "File " << infile << " not found." << endl;
+ // return false;
+ //}
+
+ char line[80];
+
+ while ( in.getline(line,80) ) {
+
+ if ( line[0] == '#' ) continue;
+
+ TString tmp(AliMpHelper::Normalize(line));
+
+ Int_t blankPos = tmp.First(' ');
+
+ TString sManuId(tmp(0, blankPos));
+
+ Int_t manuId = atoi(sManuId.Data());
+
+ TString sManuSerial(tmp(blankPos + 1, tmp.Length()-blankPos));
+
+ Int_t manuSerial = atoi(sManuSerial.Data());
+
+ // filling manuId <> manuSerial
+ detElement->AddManuSerial(manuId, manuSerial);
+ }
+
+ in.close();
+ return true;
+}
+
+//______________________________________________________________________________
+Bool_t
+AliMpDEStore::ReadDENames(AliMp::StationType station)
+{
+/// Read det element names for cath = 0 from the file specified by name
+/// and fill the map
+
+ // Open file
+ TString filePath = AliMpFiles::DENamesFilePath(station);
+ std::ifstream in(filePath);
+ if (!in.good()) {
+ AliErrorClassStream() << "Cannot open file " << filePath << endl;;
+ return false;
+ }
+
+ // Read plane types per cathods
+ //
+ char line[80];
+ TString word;
+ TString cathName1, cathName2;
+ in >> word;
+ while ( ! in.eof() && cathName1.Length() == 0 ) {
+ if ( word[0] == '#' )
+ in.getline(line, 80);
+ else {
+ cathName1 = word;
+ in >> cathName2;
+ }
+ in >> word;
+ }
+
+ Bool_t isCathNameDefined = false;
+ if ( IsPlaneType(cathName1) && IsPlaneType(cathName2) )
+ isCathNameDefined = true;
+
+ // Read DE names
+ //
+ Int_t detElemId;
+ TString name, name0, name1, name2;
+ AliMp::PlaneType planeForCathode[2];
+
+ while ( ! in.eof() )
+ {
+ if ( word[0] == '#' )
+ {
+ in.getline(line, 80);
+ }
+ else
+ {
+ detElemId = word.Atoi();
+ in >> name;
+ in >> name0;
+ // warning : important to check non bending first (=nbp),
+ // as bp is contained within nbp...
+ if ( name0.Contains(PlaneTypeName(AliMp::kNonBendingPlane)) )
+ {
+ planeForCathode[0] = AliMp::kNonBendingPlane;
+ }
+ else
+ {
+ planeForCathode[0] = AliMp::kBendingPlane;
+ }
+
+ if ( !isCathNameDefined )
+ {
+ in >> name2;
+ name1 = name0;
+ Ssiz_t pos = name1.First(AliMpDetElement::GetNameSeparator());
+ name0 = name1(0,pos);
+
+ // Other cathode is other plane...
+ planeForCathode[1] = OtherPlaneType(planeForCathode[0]);
+ }
+ else
+ {
+ name1 = name0 + AliMpDetElement::GetNameSeparator() + cathName1;
+ name2 = name0 + AliMpDetElement::GetNameSeparator() + cathName2;
+ if ( name2.Contains(PlaneTypeName(AliMp::kNonBendingPlane)) )
+ {
+ planeForCathode[1] = AliMp::kNonBendingPlane;
+ }
+ else
+ {
+ planeForCathode[1] = AliMp::kBendingPlane;
+ }
+ }
+
+ if ( planeForCathode[0]==planeForCathode[1] )
+ {
+ AliFatalClass(Form("Got the same cathode type for both planes"
+ " of DetElemId %d",detElemId));
+ }
+
+ AliMpDetElement* detElement
+ = new AliMpDetElement(detElemId, name, name0, planeForCathode[0]);
+ if ( ! fDetElements.GetValue(detElemId) )
+ {
+ AliDebugClassStream(3)
+ << "Adding DE name " << detElemId << " " << name << endl;
+ fDetElements.Add(detElemId, detElement);
+
+ // Read manu serial numbers for this det element
+ ReadManuToSerialNbs(detElement, station);
+ }
+ else
+ {
+ AliWarningClassStream()
+ << "Det element " << detElemId << " " << name << " already defined." << endl;
+ }
+ }
+ in >> word;
+ }
+
+ // Close file
+ in.close();
+
+ return true;
+}
+
+//______________________________________________________________________________
+void AliMpDEStore::FillDEs()
+{
+/// Fill DE names from files
+ AliDebugClass(2,"");
+ Bool_t result1 = ReadDENames(AliMp::kStation1);
+ Bool_t result2 = ReadDENames(AliMp::kStation2);
+ Bool_t result3 = ReadDENames(AliMp::kStation345);
+ Bool_t result4 = ReadDENames(AliMp::kStationTrigger);
+
+ Bool_t result = result1 && result2 && result3 && result4;
+ if ( ! result ) {
+ AliErrorClassStream() << "Error in reading DE names files" << endl;
+ }
+}
+
+//
+// public methods
+//
+
+
+//______________________________________________________________________________
+AliMpDetElement* AliMpDEStore::GetDetElement(Int_t detElemId, Bool_t warn) const
+{
+/// Return det element for given detElemId
+
+ AliMpDetElement* detElement
+ = (AliMpDetElement*)fDetElements.GetValue(detElemId);
+
+ if ( ! detElement && warn ) {
+ AliErrorClassStream()
+ << "Detection element " << detElemId << " not defined." << endl;
+ }
+
+ return detElement;
+}
+
+//______________________________________________________________________________
+AliMpIntPair AliMpDEStore::GetDetElemIdManu(Int_t manuSerial) const
+{
+/// Return the detElemId and manuId for given serial manu number
+
+ for ( Int_t i = 0; i < fDetElements.GetSize(); i++ ) {
+
+ AliMpDetElement* detElement
+ = (AliMpDetElement*)fDetElements.GetObject(i);
+
+ Int_t manuId = detElement->GetManuIdFromSerial(manuSerial);
+ if ( manuId ) return AliMpIntPair(detElement->GetId(), manuId);
+ }
+
+ // manu with this serial number does not exist
+ return AliMpIntPair::Invalid();
+}
--- /dev/null
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $Id$
+// $MpId: AliMpDEStore.h,v 1.6 2006/05/24 13:58:16 ivana Exp $
+
+/// \ingroup management
+/// \class AliMpDEStore
+/// \brief The container class for detection element objects
+///
+/// \author Ivana Hrivnacova, IPN Orsay;
+/// Laurent Aphecetche, Christian Finck, SUBATECH Nantes
+
+#ifndef ALI_MP_DE_STORE_H
+#define ALI_MP_DE_STORE_H
+
+#include <TObject.h>
+#include <TArrayI.h>
+
+#include "AliMpExMap.h"
+#include "AliMpPlaneType.h"
+#include "AliMpStationType.h"
+#include "AliMpIntPair.h"
+
+class AliMpDetElement;
+
+class AliMpDEStore : public TObject {
+
+ friend class AliMpDEIterator;
+
+ public:
+ AliMpDEStore(TRootIOCtor* /*ioCtor*/);
+ virtual ~AliMpDEStore();
+
+ // static access method
+ static AliMpDEStore* Instance();
+
+ // methods
+ AliMpDetElement* GetDetElement(Int_t detElemId, Bool_t warn = true) const;
+ AliMpIntPair GetDetElemIdManu(Int_t manuSerial) const;
+
+ private:
+ AliMpDEStore();
+ AliMpDEStore(const AliMpDEStore& rhs);
+ AliMpDEStore& operator=(const AliMpDEStore& rhs);
+
+ // methods
+ Bool_t IsPlaneType(const TString& planeTypeName);
+ AliMp::PlaneType PlaneType(const TString& planeTypeName);
+ AliMp::StationType StationType(const TString& stationTypeName);
+
+ Bool_t ReadManuToSerialNbs(AliMpDetElement* detElement,
+ AliMp::StationType stationType);
+ Bool_t ReadDENames(AliMp::StationType stationType);
+ void FillDEs();
+
+ // static data members
+ static AliMpDEStore* fgInstance; ///< Singleton instance
+ static const char fgkCommentPrefix; ///< Comment prefix in DE names file
+
+ // data members
+ AliMpExMap fDetElements; ///< Map between DE Ids and DE objects
+
+ ClassDef(AliMpDEStore,1) // The manager class for definition of detection element types
+};
+
+#endif //ALI_MP_MANAGER_H
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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$
+// $MpId: AliMpDetElement.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
+// Category: management
+//
+// Class AliMpDetElement
+// --------------------
+// The class defines the electronics properties of detection element
+// Authors: Ivana Hrivnacova, IPN Orsay
+// Laurent Aphecetche, Christian Finck, SUBATECH Nantes
+
+#include "AliMpDetElement.h"
+#include "AliMpDEManager.h"
+
+#include "AliLog.h"
+
+#include <TObjString.h>
+#include <Riostream.h>
+
+/// \cond CLASSIMP
+ClassImp(AliMpDetElement)
+/// \endcond
+
+const char AliMpDetElement::fgkNameSeparator = '_';
+
+//______________________________________________________________________________
+AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
+ const TString& segType, AliMp::PlaneType planeType)
+ : TObject(),
+ fId(id),
+ fDdlId(-1),
+ fName(name),
+ fSegType(segType),
+ fPlaneType(planeType),
+ fBusPatchIds(),
+ fManuToSerialNbs(1700),
+ fSerialNbToManus(1700)
+{
+/// Standard constructor
+
+}
+
+//______________________________________________________________________________
+AliMpDetElement::AliMpDetElement(TRootIOCtor* /*ioCtor*/)
+ : TObject(),
+ fId(0),
+ fDdlId(-1),
+ fName(),
+ fSegType(),
+ fPlaneType(),
+ fBusPatchIds(),
+ fManuToSerialNbs(),
+ fSerialNbToManus()
+{
+/// Root IO constructor
+}
+
+//______________________________________________________________________________
+AliMpDetElement::~AliMpDetElement()
+{
+/// Destructor
+}
+
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
+{
+/// Add bus patch Id if a bus patch with the same Id is not yet present;
+/// return false if bus patch was not added
+
+ if ( HasBusPatchId(busPatchId) ) {
+ AliWarningStream()
+ << "Bus patch Id = " << busPatchId << " already present."
+ << endl;
+ return false;
+ }
+
+ fBusPatchIds.Add(busPatchId);
+ return true;
+}
+
+//______________________________________________________________________________
+void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb)
+{
+/// Map the serial manu number
+/// (Eventually add check if the given pair already present)
+
+ fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb));
+ fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId));
+}
+
+//______________________________________________________________________________
+TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
+{
+/// Return the segmentation name for the given catod type
+
+ return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
+}
+
+//______________________________________________________________________________
+AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
+{
+/// Return plane type \n
+
+ if ( cath == AliMp::kCath0 ) return fPlaneType;
+ else return AliMp::OtherPlaneType(fPlaneType);
+}
+
+//______________________________________________________________________________
+AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
+{
+/// Return cathod type for given planeType
+
+ if ( fPlaneType == planeType ) return AliMp::kCath0;
+ else return AliMp::kCath1;
+}
+
+//______________________________________________________________________________
+AliMp::StationType AliMpDetElement::GetStationType() const
+{
+/// Return station type \n
+/// Failure causes Fatal error - as AliMp::StationType has no possibility
+/// to return undefined value
+
+ Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
+ if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
+ AliFatal("Cannot return AliMp::StationType value.");
+ return AliMp::kStation1;
+ }
+
+ if ( chamberId == 0 || chamberId == 1 ) return AliMp::kStation1;
+ if ( chamberId == 2 || chamberId == 3 ) return AliMp::kStation2;
+ if ( chamberId >= 4 && chamberId <= 9 ) return AliMp::kStation345;
+ if ( chamberId >= 10 && chamberId <= 13 ) return AliMp::kStationTrigger;
+
+ // Should never get to this line
+ AliFatal("Cannot return AliMp::StationType value.");
+ return AliMp::kStation1;
+}
+
+//______________________________________________________________________________
+Int_t AliMpDetElement::GetNofBusPatches() const
+{
+/// Return the number of bus patches in this detection element
+
+ return fBusPatchIds.GetSize();
+}
+
+//______________________________________________________________________________
+Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
+{
+/// Return the index-th bus patch
+
+ if ( index < 0 || index > GetNofBusPatches() ) {
+ AliErrorStream()
+ << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
+ return 0;
+ }
+
+ return fBusPatchIds.GetValue(index);
+}
+
+
+//______________________________________________________________________________
+Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
+{
+/// Return true if the bus patch Id is present
+
+ return fBusPatchIds.HasValue(busPatchId);;
+}
+
+//______________________________________________________________________________
+Int_t AliMpDetElement::GetNofManus() const
+{
+/// Return the number of manus in this detection element
+
+ return fManuToSerialNbs.GetSize();
+}
+
+//______________________________________________________________________________
+Int_t AliMpDetElement::GetManuSerialFromId(Int_t manuId) const
+{
+/// Return manu serial number from manuId
+
+ return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId));
+}
+
+//______________________________________________________________________________
+Int_t AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const
+{
+/// Return manuId from manu serial number
+
+ return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb));
+}
+
--- /dev/null
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $Id$
+// $MpId: AliMpDetElement.h,v 1.6 2006/05/24 13:58:16 ivana Exp $
+
+/// \ingroup management
+/// \class AliMpDetElement
+/// \brief The class defines the electronics properties of detection element
+///
+/// \author Ivana Hrivnacova, IPN Orsay;
+/// Laurent Aphecetche, Ch. Finck, Subatech Nantes
+
+#ifndef ALI_MP_DET_ELEMENT_H
+#define ALI_MP_DET_ELEMENT_H
+
+#include <TObject.h>
+#include <TArrayI.h>
+#include <TExMap.h>
+
+#include "AliMpArrayI.h"
+#include "AliMpStationType.h"
+#include "AliMpPlaneType.h"
+#include "AliMpCathodType.h"
+
+class AliMpVSegmentation;
+
+class AliMpDetElement : public TObject {
+
+ public:
+ AliMpDetElement(Int_t id, const TString& name,
+ const TString& segType, AliMp::PlaneType planeType);
+ AliMpDetElement(TRootIOCtor* /*ioCtor*/);
+ virtual ~AliMpDetElement();
+
+ // static methods
+ static char GetNameSeparator();
+
+ // methods
+ Bool_t AddBusPatch(Int_t busPatchId);
+ void AddManuSerial(Int_t manuId, Int_t serialNb);
+ void SetDdlId(Int_t ddlId);
+
+ // get methods
+ Int_t GetId() const;
+ Int_t GetDdlId() const;
+ TString GetDEName() const;
+ TString GetSegType() const;
+ TString GetSegName(AliMp::CathodType cath) const;
+
+ AliMp::PlaneType GetPlaneType(AliMp::CathodType cath) const;
+ AliMp::CathodType GetCathodType(AliMp::PlaneType planeType) const;
+ AliMp::StationType GetStationType() const;
+
+ Int_t GetNofBusPatches() const;
+ Int_t GetBusPatchId(Int_t index) const;
+ Bool_t HasBusPatchId(Int_t busPatchId) const;
+
+ Int_t GetNofManus() const;
+ Int_t GetManuSerialFromId(Int_t manuId) const;
+ Int_t GetManuIdFromSerial(Int_t serialNb) const;
+
+ private:
+ AliMpDetElement();
+ AliMpDetElement(const AliMpDetElement& rhs);
+ AliMpDetElement& operator=(const AliMpDetElement& rhs);
+
+ // static data members
+ static const char fgkNameSeparator; ///< Separator character used in DE names
+
+ // data members
+ Int_t fId; ///< Identifier (unique)
+ Int_t fDdlId; ///< DDL Id to which this DE is connected
+ TString fName; ///< Name unique
+ TString fSegType; ///< Segmentation type name
+ AliMp::PlaneType fPlaneType; ///< Plane type on cathod0
+ //AliMpExMap fBusPatches; ///< Bus patches connected to this detection element
+ AliMpArrayI fBusPatchIds; ///< Bus patches connected to this detection element
+ mutable TExMap fManuToSerialNbs; //< Map from manuId to serial #
+ mutable TExMap fSerialNbToManus; //< Map manu serial # to manuId
+
+ ClassDef(AliMpDetElement,1) // The manager class for definition of detection element types
+};
+
+// inline function
+
+/// Return the name separator
+inline char AliMpDetElement::GetNameSeparator()
+{ return fgkNameSeparator; }
+
+/// Set DDL Id
+inline void AliMpDetElement::SetDdlId(Int_t ddlId)
+{ fDdlId = ddlId; }
+
+/// Return Id
+inline Int_t AliMpDetElement::GetId() const
+{ return fId; }
+
+/// Return DDL Id
+inline Int_t AliMpDetElement::GetDdlId() const
+{ return fDdlId; }
+
+/// Return name
+inline TString AliMpDetElement::GetDEName() const
+{ return fName; }
+
+/// Return segmentation type name
+inline TString AliMpDetElement::GetSegType() const
+{ return fSegType; }
+
+#endif //ALI_MP_MANAGER_H
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+