1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ////////////////////////////////////////////////////////////
17 // Factory for muon chambers, segmentations and response //
18 ////////////////////////////////////////////////////////////
22 #include "AliMpSegFactory.h"
25 #include "AliMpDEManager.h"
26 #include "AliMpExMap.h"
27 #include "AliMpSector.h"
28 #include "AliMpSectorReader.h"
29 #include "AliMpSectorSegmentation.h"
30 #include "AliMpSlat.h"
31 #include "AliMpSlatSegmentation.h"
32 #include "AliMpSt345Reader.h"
33 #include "AliMpTrigger.h"
34 #include "AliMpTriggerReader.h"
35 #include "AliMpTriggerSegmentation.h"
36 #include <Riostream.h>
38 #include <TObjString.h>
41 ClassImp(AliMpSegFactory)
43 //______________________________________________________________________________
44 AliMpSegFactory::AliMpSegFactory()
47 fMpMap(new AliMpExMap(true))
49 /// Standard constructor
51 fMpMap->SetOwner(true);
54 //______________________________________________________________________________
55 AliMpSegFactory::AliMpSegFactory(const AliMpSegFactory& rhs)
58 /// Protected copy constructor
60 AliFatal("Not implemented.");
63 //______________________________________________________________________________
65 AliMpSegFactory::~AliMpSegFactory()
69 // The segmentations is supposed to be deleted in the client code
73 //______________________________________________________________________________
74 AliMpSegFactory& AliMpSegFactory::operator=(const AliMpSegFactory& rhs)
76 // Protected assignement operator
78 if (this == &rhs) return *this;
80 AliFatal("Not implemented.");
89 //______________________________________________________________________________
91 AliMpSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath)
93 /// Create mapping segmentation for given detElemId and cath
94 /// or return it if it was already built
96 // Check detElemId & cath
97 if ( ! AliMpDEManager::IsValid(detElemId, cath, true) ) return 0;
99 // If segmentation is already built, just return it
101 TString deName = AliMpDEManager::GetDEName(detElemId, cath);
102 TObject* object = fMpSegmentations.Get(deName);
103 if ( object ) return (AliMpVSegmentation*)object;
105 AliDebug(1,Form("Creating segmentation for detElemId=%d cath=%d",
108 // Read mapping data and create segmentation
110 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
111 AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath);
112 TString deTypeName = AliMpDEManager::GetDETypeName(detElemId, cath);
114 AliMpVSegmentation* mpSegmentation = 0;
116 if ( stationType == kStation1 || stationType == kStation2 ) {
117 AliMpSectorReader reader(stationType, planeType);
118 AliMpSector* sector = reader.BuildSector();
119 mpSegmentation = new AliMpSectorSegmentation(sector);
121 else if ( stationType == kStation345 ) {
122 AliMpSlat* slat = AliMpSt345Reader::ReadSlat(deTypeName, planeType);
123 mpSegmentation = new AliMpSlatSegmentation(slat);
125 else if ( stationType == kStationTrigger ) {
126 AliMpTrigger* trigger = AliMpTriggerReader::ReadSlat(deTypeName, planeType);
127 mpSegmentation = new AliMpTriggerSegmentation(trigger);
130 AliErrorStream() << "Unknown station type" << endl;
132 fMpSegmentations.Add(deName, mpSegmentation);
133 return mpSegmentation;
136 //_____________________________________________________________________________
138 AliMpSegFactory::CreateMpSegmentationByElectronics(Int_t detElemId,
141 AliMpExMap* m = static_cast<AliMpExMap*>(fMpMap->GetValue(detElemId));
145 m = FillMpMap(detElemId);
148 return static_cast<AliMpVSegmentation*>(m->GetValue(FEMId));
151 //______________________________________________________________________________
152 void AliMpSegFactory::DeleteSegmentations()
154 /// Delete all segmentations created with this manager
155 AliDebug(1,"deleting mpSegmentations");
156 fMpSegmentations.Clear();
157 AliDebug(1,"deleting mpMap");
163 //_____________________________________________________________________________
165 AliMpSegFactory::FillMpMap(Int_t detElemId)
167 AliDebug(1,Form("detElemId=%d",detElemId));
169 AliMpExMap* mde = new AliMpExMap(true);
170 mde->SetOwner(kFALSE);
171 fMpMap->Add(detElemId,mde);
173 AliMpVSegmentation* seg[2];
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.
179 for ( Int_t cathode = 0; cathode < 2; ++cathode )
181 seg[cathode] = CreateMpSegmentation(detElemId,cathode);
182 seg[cathode]->GetAllElectronicCardIDs(ecn[cathode]);
185 mde->SetSize(ecn[0].GetSize()+ecn[1].GetSize());
187 for ( Int_t cathode = 0; cathode < 2; ++ cathode )
189 for ( Int_t i = 0; i < ecn[cathode].GetSize(); ++i )
191 mde->Add(ecn[cathode][i],const_cast<AliMpVSegmentation*>(seg[cathode]));