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