From 91740e1f57a4992a9915fee5755b445858e1a475 Mon Sep 17 00:00:00 2001 From: ivana Date: Mon, 20 Nov 2006 14:29:51 +0000 Subject: [PATCH] A new class that manages the maps manuId<>manuSerial#<>DE (Christian) --- MUON/mapping/AliMpManuGeo.cxx | 139 ++++++++++++++++++++++++++++++++++ MUON/mapping/AliMpManuGeo.h | 52 +++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 MUON/mapping/AliMpManuGeo.cxx create mode 100644 MUON/mapping/AliMpManuGeo.h diff --git a/MUON/mapping/AliMpManuGeo.cxx b/MUON/mapping/AliMpManuGeo.cxx new file mode 100644 index 00000000000..5d37a559f77 --- /dev/null +++ b/MUON/mapping/AliMpManuGeo.cxx @@ -0,0 +1,139 @@ +/************************************************************************** + * 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: AliMpManuGeo.cxx,v 1.5 2006/05/24 13:58:34 ivana Exp $ +// Category: management + +// Class AliMpManuGeo +// --------------- +// Class that manages the maps manuId<>manuSerial#<>DE +// Needed for geometrical calibration gain for manu +// Author: Ch. Finck; Subatech Nantes + +#include + +#include "AliMpManuGeo.h" +#include "AliMpFiles.h" +#include "AliMpHelper.h" +#include "AliMpExMap.h" +#include "AliMpStationType.h" +#include "AliMpDEManager.h" +#include "AliMpIntPair.h" +#include "AliMpDEIterator.h" + +#include "AliLog.h" + +#include "Riostream.h" + +/// \cond CLASSIMP +ClassImp(AliMpManuGeo) +/// \endcond + + +//_____________________________________________________________________________ +AliMpManuGeo::AliMpManuGeo() + : TObject(), + fDeManuToSerialNb(17000), + fSerialNbToDeManu(17000) +{ +/// Default constructor +} + +//_____________________________________________________________________________ +AliMpManuGeo::~AliMpManuGeo() +{ +/// Destructor + + fDeManuToSerialNb.Delete(); + fSerialNbToDeManu.Delete(); + +} + +//____________________________________________________________________ +AliMpIntPair* AliMpManuGeo::GetDetElemManu(Int_t manuSerial) +{ + /// getting (DE, manuId) from manu serial number + return (AliMpIntPair*) fSerialNbToDeManu.GetValue(manuSerial); + +} + +//____________________________________________________________________ +Int_t AliMpManuGeo::GetManuSerial(AliMpIntPair& pair) +{ +/// getting manu serial number from (DE, manuId) + + if ( ! AliMpDEManager::IsValidDetElemId(pair.GetFirst(), true) ) return -1; + + Long_t it = fDeManuToSerialNb.GetValue(AliMpExMap::GetIndex(pair)); + + if ( it ) + return (Int_t)it; + else + return -1; +} + +//____________________________________________________________________ +void AliMpManuGeo::ReadGeomManuFiles() +{ +/// Read manu serial numbers for all detection elements + + AliMpDEIterator it; + for ( it.First(); ! it.IsDone(); it.Next() ) { + ReadGeomManuFile(it.CurrentDE()); + } +} + + +//____________________________________________________________________ +void AliMpManuGeo::ReadGeomManuFile(Int_t idDE) +{ +/// Read manu serial numbers for the given detection elements + + AliMpStationType stationType = AliMpDEManager::GetStationType(idDE); + TString detFileName = AliMpDEManager::GetDEName(idDE); + TString infile = AliMpFiles::ManuToSerialPath(detFileName, stationType); + + ifstream in(infile, ios::in); + if (!in) AliError(Form("File %s not found.", infile.Data())); + + 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 (idDE, manuId) <> manuSerial + fDeManuToSerialNb.Add(AliMpExMap::GetIndex(AliMpIntPair(idDE, manuId)), (Long_t)manuSerial); + fSerialNbToDeManu.Add((Long_t)manuSerial, (Long_t)new AliMpIntPair(idDE, manuId)); + + } + + in.close(); + +} diff --git a/MUON/mapping/AliMpManuGeo.h b/MUON/mapping/AliMpManuGeo.h new file mode 100644 index 00000000000..c2391c406fc --- /dev/null +++ b/MUON/mapping/AliMpManuGeo.h @@ -0,0 +1,52 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +// $Id$ +// $MpId: AliMpManuGeo.h,v 1.5 2006/05/24 13:58:16 ivana Exp $ + +/// \ingroup management +/// \class AliMpManuGeo +/// \brief Class that manages the maps manuId<>manuSerial#<>DE +/// +/// \author Ch. Finck; Subatech Nantes + +#ifndef ALI_MP_MANUGEO_H +#define ALI_MP_MANUGEO_H + +#include + +#include +#include + +class AliMpIntPair; + +class AliMpManuGeo : public TObject +{ + + public: + + AliMpManuGeo(); + virtual ~AliMpManuGeo(); + + + // methods + void ReadGeomManuFiles(); + void ReadGeomManuFile(Int_t idDE); + + AliMpIntPair* GetDetElemManu(Int_t manuSerial); + Int_t GetManuSerial(AliMpIntPair& pair); + + private: + AliMpManuGeo(const AliMpManuGeo& src); + AliMpManuGeo& operator = (const AliMpManuGeo& src) ; + + + TExMap fDeManuToSerialNb; //!< Map from (idDE, manuId) to manu serial # + TExMap fSerialNbToDeManu; //!< Map manu serial # to (idDE, manuId) + + + ClassDef(AliMpManuGeo,1) //utility class for the motif type +}; + + +#endif -- 2.43.0