]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSegFactory.cxx
Updated comments for Doxygen - corrected warnings
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSegFactory.cxx
CommitLineData
cf9a1555 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
490da820 16// $Id$
13985652 17// $MpId: AliMpSegFactory.cxx,v 1.7 2006/05/24 13:58:34 ivana Exp $
490da820 18// Category: management
700013f0 19
490da820 20// -----------------------
21// Class AliMpSegFactory
22// -----------------------
23// The factory for building mapping segmentations
24// Authors: Ivana Hrivnacova, IPN Orsay
2c605e66 25// Laurent Aphecetche, SUBATECH
cf9a1555 26
27#include "AliMpSegFactory.h"
b802839b 28
cf9a1555 29#include "AliMpDEManager.h"
b802839b 30#include "AliMpExMap.h"
cf9a1555 31#include "AliMpSector.h"
32#include "AliMpSectorReader.h"
33#include "AliMpSectorSegmentation.h"
34#include "AliMpSlat.h"
cf9a1555 35#include "AliMpSlatSegmentation.h"
b802839b 36#include "AliMpSt345Reader.h"
cf9a1555 37#include "AliMpTrigger.h"
38#include "AliMpTriggerReader.h"
39#include "AliMpTriggerSegmentation.h"
2c605e66 40
41#include "AliLog.h"
42
cf9a1555 43#include <Riostream.h>
cf9a1555 44#include <TMap.h>
b802839b 45#include <TObjString.h>
46#include <TSystem.h>
cf9a1555 47
13985652 48/// \cond CLASSIMP
cf9a1555 49ClassImp(AliMpSegFactory)
13985652 50/// \endcond
cf9a1555 51
52//______________________________________________________________________________
53AliMpSegFactory::AliMpSegFactory()
b802839b 54: TObject(),
55 fMpSegmentations(),
56 fMpMap(new AliMpExMap(true))
cf9a1555 57{
b802839b 58 /// Standard constructor
59 AliDebug(1,"");
60 fMpMap->SetOwner(true);
cf9a1555 61}
62
63//______________________________________________________________________________
64AliMpSegFactory::AliMpSegFactory(const AliMpSegFactory& rhs)
65 : TObject(rhs)
66{
67/// Protected copy constructor
68
69 AliFatal("Not implemented.");
70}
71
72//______________________________________________________________________________
73
74AliMpSegFactory::~AliMpSegFactory()
75{
76/// Destructor
77
78 // The segmentations is supposed to be deleted in the client code
b802839b 79 AliDebug(1,"");
cf9a1555 80}
81
82//______________________________________________________________________________
83AliMpSegFactory& AliMpSegFactory::operator=(const AliMpSegFactory& rhs)
84{
85 // Protected assignement operator
86
87 if (this == &rhs) return *this;
88
89 AliFatal("Not implemented.");
90
91 return *this;
92}
93
490da820 94//
95// private methods
96//
97
98//_____________________________________________________________________________
99AliMpExMap*
100AliMpSegFactory::FillMpMap(Int_t detElemId)
101{
102/// Fill the map of electronic cards IDs to segmentations for
103/// given detElemId
104
105 AliDebug(1,Form("detElemId=%d",detElemId));
106
107 AliMpExMap* mde = new AliMpExMap(true);
108 mde->SetOwner(kFALSE);
109 fMpMap->Add(detElemId,mde);
110
111 AliMpVSegmentation* seg[2];
112 TArrayI ecn[2];
113
114 // Do it in 2 steps to be able to set the AliMpExMap size once for all,
115 // to avoid annoying warning message in case of dynamical resizing.
116 // (not critical).
117 for ( Int_t cathode = 0; cathode < 2; ++cathode )
118 {
119 seg[cathode] = CreateMpSegmentation(detElemId,cathode);
120 seg[cathode]->GetAllElectronicCardIDs(ecn[cathode]);
121 }
122
123 mde->SetSize(ecn[0].GetSize()+ecn[1].GetSize());
124
125 for ( Int_t cathode = 0; cathode < 2; ++ cathode )
126 {
127 for ( Int_t i = 0; i < ecn[cathode].GetSize(); ++i )
128 {
129 mde->Add(ecn[cathode][i],const_cast<AliMpVSegmentation*>(seg[cathode]));
130 }
131 }
132
133 return mde;
134}
135
cf9a1555 136//
137// public methods
138//
139
140//______________________________________________________________________________
141AliMpVSegmentation*
142AliMpSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath)
143{
144/// Create mapping segmentation for given detElemId and cath
145/// or return it if it was already built
146
147 // Check detElemId & cath
148 if ( ! AliMpDEManager::IsValid(detElemId, cath, true) ) return 0;
149
150 // If segmentation is already built, just return it
151 //
152 TString deName = AliMpDEManager::GetDEName(detElemId, cath);
153 TObject* object = fMpSegmentations.Get(deName);
154 if ( object ) return (AliMpVSegmentation*)object;
155
b802839b 156 AliDebug(1,Form("Creating segmentation for detElemId=%d cath=%d",
157 detElemId,cath));
158
cf9a1555 159 // Read mapping data and create segmentation
160 //
161 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
162 AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath);
163 TString deTypeName = AliMpDEManager::GetDETypeName(detElemId, cath);
164
165 AliMpVSegmentation* mpSegmentation = 0;
166
167 if ( stationType == kStation1 || stationType == kStation2 ) {
168 AliMpSectorReader reader(stationType, planeType);
169 AliMpSector* sector = reader.BuildSector();
170 mpSegmentation = new AliMpSectorSegmentation(sector);
171 }
172 else if ( stationType == kStation345 ) {
173 AliMpSlat* slat = AliMpSt345Reader::ReadSlat(deTypeName, planeType);
174 mpSegmentation = new AliMpSlatSegmentation(slat);
175 }
176 else if ( stationType == kStationTrigger ) {
177 AliMpTrigger* trigger = AliMpTriggerReader::ReadSlat(deTypeName, planeType);
178 mpSegmentation = new AliMpTriggerSegmentation(trigger);
179 }
180 else
181 AliErrorStream() << "Unknown station type" << endl;
182
183 fMpSegmentations.Add(deName, mpSegmentation);
184 return mpSegmentation;
185}
b802839b 186
187//_____________________________________________________________________________
188AliMpVSegmentation*
189AliMpSegFactory::CreateMpSegmentationByElectronics(Int_t detElemId,
490da820 190 Int_t ecId)
b802839b 191{
490da820 192/// Create mapping segmentation for given detElemId and electronic card Id
193/// (motif position Id) or return it if it was already built
194
b802839b 195 AliMpExMap* m = static_cast<AliMpExMap*>(fMpMap->GetValue(detElemId));
196
197 if (!m)
198 {
199 m = FillMpMap(detElemId);
200 }
201
490da820 202 return static_cast<AliMpVSegmentation*>(m->GetValue(ecId));
b802839b 203}
cf9a1555 204
205//______________________________________________________________________________
744ae0cb 206void AliMpSegFactory::DeleteSegmentations()
cf9a1555 207{
208/// Delete all segmentations created with this manager
490da820 209
b802839b 210 AliDebug(1,"deleting mpSegmentations");
cf9a1555 211 fMpSegmentations.Clear();
b802839b 212 AliDebug(1,"deleting mpMap");
213 delete fMpMap;
214 fMpMap = 0;
215 AliDebug(1,"done");
cf9a1555 216}
217