]>
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 | ||
16 | //////////////////////////////////////////////////////////// | |
17 | // Factory for muon chambers, segmentations and response // | |
18 | //////////////////////////////////////////////////////////// | |
19 | ||
20 | /* $Id$ */ | |
21 | ||
22 | #include "AliMpSegFactory.h" | |
b802839b | 23 | |
24 | #include "AliLog.h" | |
cf9a1555 | 25 | #include "AliMpDEManager.h" |
b802839b | 26 | #include "AliMpExMap.h" |
cf9a1555 | 27 | #include "AliMpSector.h" |
28 | #include "AliMpSectorReader.h" | |
29 | #include "AliMpSectorSegmentation.h" | |
30 | #include "AliMpSlat.h" | |
cf9a1555 | 31 | #include "AliMpSlatSegmentation.h" |
b802839b | 32 | #include "AliMpSt345Reader.h" |
cf9a1555 | 33 | #include "AliMpTrigger.h" |
34 | #include "AliMpTriggerReader.h" | |
35 | #include "AliMpTriggerSegmentation.h" | |
cf9a1555 | 36 | #include <Riostream.h> |
cf9a1555 | 37 | #include <TMap.h> |
b802839b | 38 | #include <TObjString.h> |
39 | #include <TSystem.h> | |
cf9a1555 | 40 | |
41 | ClassImp(AliMpSegFactory) | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliMpSegFactory::AliMpSegFactory() | |
b802839b | 45 | : TObject(), |
46 | fMpSegmentations(), | |
47 | fMpMap(new AliMpExMap(true)) | |
cf9a1555 | 48 | { |
b802839b | 49 | /// Standard constructor |
50 | AliDebug(1,""); | |
51 | fMpMap->SetOwner(true); | |
cf9a1555 | 52 | } |
53 | ||
54 | //______________________________________________________________________________ | |
55 | AliMpSegFactory::AliMpSegFactory(const AliMpSegFactory& rhs) | |
56 | : TObject(rhs) | |
57 | { | |
58 | /// Protected copy constructor | |
59 | ||
60 | AliFatal("Not implemented."); | |
61 | } | |
62 | ||
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 | ||
73 | //______________________________________________________________________________ | |
74 | AliMpSegFactory& AliMpSegFactory::operator=(const AliMpSegFactory& rhs) | |
75 | { | |
76 | // Protected assignement operator | |
77 | ||
78 | if (this == &rhs) return *this; | |
79 | ||
80 | AliFatal("Not implemented."); | |
81 | ||
82 | return *this; | |
83 | } | |
84 | ||
85 | // | |
86 | // public methods | |
87 | // | |
88 | ||
89 | //______________________________________________________________________________ | |
90 | AliMpVSegmentation* | |
91 | AliMpSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath) | |
92 | { | |
93 | /// Create mapping segmentation for given detElemId and cath | |
94 | /// or return it if it was already built | |
95 | ||
96 | // Check detElemId & cath | |
97 | if ( ! AliMpDEManager::IsValid(detElemId, cath, true) ) return 0; | |
98 | ||
99 | // If segmentation is already built, just return it | |
100 | // | |
101 | TString deName = AliMpDEManager::GetDEName(detElemId, cath); | |
102 | TObject* object = fMpSegmentations.Get(deName); | |
103 | if ( object ) return (AliMpVSegmentation*)object; | |
104 | ||
b802839b | 105 | AliDebug(1,Form("Creating segmentation for detElemId=%d cath=%d", |
106 | detElemId,cath)); | |
107 | ||
cf9a1555 | 108 | // Read mapping data and create segmentation |
109 | // | |
110 | AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId); | |
111 | AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath); | |
112 | TString deTypeName = AliMpDEManager::GetDETypeName(detElemId, cath); | |
113 | ||
114 | AliMpVSegmentation* mpSegmentation = 0; | |
115 | ||
116 | if ( stationType == kStation1 || stationType == kStation2 ) { | |
117 | AliMpSectorReader reader(stationType, planeType); | |
118 | AliMpSector* sector = reader.BuildSector(); | |
119 | mpSegmentation = new AliMpSectorSegmentation(sector); | |
120 | } | |
121 | else if ( stationType == kStation345 ) { | |
122 | AliMpSlat* slat = AliMpSt345Reader::ReadSlat(deTypeName, planeType); | |
123 | mpSegmentation = new AliMpSlatSegmentation(slat); | |
124 | } | |
125 | else if ( stationType == kStationTrigger ) { | |
126 | AliMpTrigger* trigger = AliMpTriggerReader::ReadSlat(deTypeName, planeType); | |
127 | mpSegmentation = new AliMpTriggerSegmentation(trigger); | |
128 | } | |
129 | else | |
130 | AliErrorStream() << "Unknown station type" << endl; | |
131 | ||
132 | fMpSegmentations.Add(deName, mpSegmentation); | |
133 | return mpSegmentation; | |
134 | } | |
b802839b | 135 | |
136 | //_____________________________________________________________________________ | |
137 | AliMpVSegmentation* | |
138 | AliMpSegFactory::CreateMpSegmentationByElectronics(Int_t detElemId, | |
139 | Int_t FEMId) | |
140 | { | |
141 | AliMpExMap* m = static_cast<AliMpExMap*>(fMpMap->GetValue(detElemId)); | |
142 | ||
143 | if (!m) | |
144 | { | |
145 | m = FillMpMap(detElemId); | |
146 | } | |
147 | ||
148 | return static_cast<AliMpVSegmentation*>(m->GetValue(FEMId)); | |
149 | } | |
cf9a1555 | 150 | |
151 | //______________________________________________________________________________ | |
744ae0cb | 152 | void AliMpSegFactory::DeleteSegmentations() |
cf9a1555 | 153 | { |
154 | /// Delete all segmentations created with this manager | |
b802839b | 155 | AliDebug(1,"deleting mpSegmentations"); |
cf9a1555 | 156 | fMpSegmentations.Clear(); |
b802839b | 157 | AliDebug(1,"deleting mpMap"); |
158 | delete fMpMap; | |
159 | fMpMap = 0; | |
160 | AliDebug(1,"done"); | |
cf9a1555 | 161 | } |
162 | ||
b802839b | 163 | //_____________________________________________________________________________ |
164 | AliMpExMap* | |
165 | AliMpSegFactory::FillMpMap(Int_t detElemId) | |
166 | { | |
167 | AliDebug(1,Form("detElemId=%d",detElemId)); | |
168 | ||
169 | AliMpExMap* mde = new AliMpExMap(true); | |
170 | mde->SetOwner(kFALSE); | |
171 | fMpMap->Add(detElemId,mde); | |
172 | ||
173 | AliMpVSegmentation* seg[2]; | |
174 | TArrayI ecn[2]; | |
175 | ||
176 | // Do it in 2 steps to be able to set the AliMpExMap size once for all, | |
177 | // to avoid annoying warning message in case of dynamical resizing. | |
178 | // (not critical). | |
179 | for ( Int_t cathode = 0; cathode < 2; ++cathode ) | |
180 | { | |
181 | seg[cathode] = CreateMpSegmentation(detElemId,cathode); | |
182 | seg[cathode]->GetAllElectronicCardIDs(ecn[cathode]); | |
183 | } | |
184 | ||
185 | mde->SetSize(ecn[0].GetSize()+ecn[1].GetSize()); | |
186 | ||
187 | for ( Int_t cathode = 0; cathode < 2; ++ cathode ) | |
188 | { | |
189 | for ( Int_t i = 0; i < ecn[cathode].GetSize(); ++i ) | |
190 | { | |
191 | mde->Add(ecn[cathode][i],const_cast<AliMpVSegmentation*>(seg[cathode])); | |
192 | } | |
193 | } | |
194 | ||
195 | return mde; | |
196 | } |