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