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