]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpManuGeo.cxx
Using Min and Max from TMath
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpManuGeo.cxx
CommitLineData
91740e1f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// $Id$
17// $MpId: AliMpManuGeo.cxx,v 1.5 2006/05/24 13:58:34 ivana Exp $
18// Category: management
19
20// Class AliMpManuGeo
21// ---------------
22// Class that manages the maps manuId<>manuSerial#<>DE
23// Needed for geometrical calibration gain for manu
24// Author: Ch. Finck; Subatech Nantes
25
26#include <TString.h>
27
28#include "AliMpManuGeo.h"
29#include "AliMpFiles.h"
30#include "AliMpHelper.h"
31#include "AliMpExMap.h"
32#include "AliMpStationType.h"
33#include "AliMpDEManager.h"
34#include "AliMpIntPair.h"
35#include "AliMpDEIterator.h"
36
37#include "AliLog.h"
38
39#include "Riostream.h"
40
41/// \cond CLASSIMP
42ClassImp(AliMpManuGeo)
43/// \endcond
44
45
46//_____________________________________________________________________________
47AliMpManuGeo::AliMpManuGeo()
48 : TObject(),
49 fDeManuToSerialNb(17000),
50 fSerialNbToDeManu(17000)
51{
52/// Default constructor
53}
54
55//_____________________________________________________________________________
56AliMpManuGeo::~AliMpManuGeo()
57{
58/// Destructor
59
60 fDeManuToSerialNb.Delete();
61 fSerialNbToDeManu.Delete();
62
63}
64
65//____________________________________________________________________
5246421c 66AliMpIntPair AliMpManuGeo::GetDetElemManu(Int_t manuSerial)
91740e1f 67{
68 /// getting (DE, manuId) from manu serial number
5246421c 69 return * (AliMpIntPair*) fSerialNbToDeManu.GetValue(manuSerial);
91740e1f 70
71}
72
73//____________________________________________________________________
74Int_t AliMpManuGeo::GetManuSerial(AliMpIntPair& pair)
75{
76/// getting manu serial number from (DE, manuId)
77
78 if ( ! AliMpDEManager::IsValidDetElemId(pair.GetFirst(), true) ) return -1;
79
80 Long_t it = fDeManuToSerialNb.GetValue(AliMpExMap::GetIndex(pair));
81
82 if ( it )
83 return (Int_t)it;
84 else
85 return -1;
86}
87
88//____________________________________________________________________
89void AliMpManuGeo::ReadGeomManuFiles()
90{
91/// Read manu serial numbers for all detection elements
92
93 AliMpDEIterator it;
94 for ( it.First(); ! it.IsDone(); it.Next() ) {
95 ReadGeomManuFile(it.CurrentDE());
96 }
97}
98
99
100//____________________________________________________________________
101void AliMpManuGeo::ReadGeomManuFile(Int_t idDE)
102{
103/// Read manu serial numbers for the given detection elements
104
105 AliMpStationType stationType = AliMpDEManager::GetStationType(idDE);
106 TString detFileName = AliMpDEManager::GetDEName(idDE);
107 TString infile = AliMpFiles::ManuToSerialPath(detFileName, stationType);
108
109 ifstream in(infile, ios::in);
110 if (!in) AliError(Form("File %s not found.", infile.Data()));
111
112 char line[80];
113
114 while ( in.getline(line,80) ) {
115
116 if ( line[0] == '#' ) continue;
117
118 TString tmp(AliMpHelper::Normalize(line));
119
120 Int_t blankPos = tmp.First(' ');
121
122 TString sManuId(tmp(0, blankPos));
123
124 Int_t manuId = atoi(sManuId.Data());
125
126 TString sManuSerial(tmp(blankPos + 1, tmp.Length()-blankPos));
127
128 Int_t manuSerial = atoi(sManuSerial.Data());
129
130
131 // filling (idDE, manuId) <> manuSerial
132 fDeManuToSerialNb.Add(AliMpExMap::GetIndex(AliMpIntPair(idDE, manuId)), (Long_t)manuSerial);
133 fSerialNbToDeManu.Add((Long_t)manuSerial, (Long_t)new AliMpIntPair(idDE, manuId));
134
135 }
136
137 in.close();
138
139}