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"
23 #include "AliMpDEManager.h"
24 #include "AliMpSector.h"
25 #include "AliMpSectorReader.h"
26 #include "AliMpSectorSegmentation.h"
27 #include "AliMpSlat.h"
28 #include "AliMpSt345Reader.h"
29 #include "AliMpSlatSegmentation.h"
30 #include "AliMpTrigger.h"
31 #include "AliMpTriggerReader.h"
32 #include "AliMpTriggerSegmentation.h"
36 #include <Riostream.h>
38 #include <TObjString.h>
41 ClassImp(AliMpSegFactory)
43 //______________________________________________________________________________
44 AliMpSegFactory::AliMpSegFactory()
48 /// Standard constructor
51 //______________________________________________________________________________
52 AliMpSegFactory::AliMpSegFactory(const AliMpSegFactory& rhs)
55 /// Protected copy constructor
57 AliFatal("Not implemented.");
60 //______________________________________________________________________________
62 AliMpSegFactory::~AliMpSegFactory()
66 // The segmentations is supposed to be deleted in the client code
69 //______________________________________________________________________________
70 AliMpSegFactory& AliMpSegFactory::operator=(const AliMpSegFactory& rhs)
72 // Protected assignement operator
74 if (this == &rhs) return *this;
76 AliFatal("Not implemented.");
85 //______________________________________________________________________________
87 AliMpSegFactory::CreateMpSegmentation(Int_t detElemId, Int_t cath)
89 /// Create mapping segmentation for given detElemId and cath
90 /// or return it if it was already built
92 // Check detElemId & cath
93 if ( ! AliMpDEManager::IsValid(detElemId, cath, true) ) return 0;
95 // If segmentation is already built, just return it
97 TString deName = AliMpDEManager::GetDEName(detElemId, cath);
98 TObject* object = fMpSegmentations.Get(deName);
99 if ( object ) return (AliMpVSegmentation*)object;
101 // Read mapping data and create segmentation
103 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
104 AliMpPlaneType planeType = AliMpDEManager::GetPlaneType(detElemId, cath);
105 TString deTypeName = AliMpDEManager::GetDETypeName(detElemId, cath);
107 AliMpVSegmentation* mpSegmentation = 0;
109 if ( stationType == kStation1 || stationType == kStation2 ) {
110 AliMpSectorReader reader(stationType, planeType);
111 AliMpSector* sector = reader.BuildSector();
112 mpSegmentation = new AliMpSectorSegmentation(sector);
114 else if ( stationType == kStation345 ) {
115 AliMpSlat* slat = AliMpSt345Reader::ReadSlat(deTypeName, planeType);
116 mpSegmentation = new AliMpSlatSegmentation(slat);
118 else if ( stationType == kStationTrigger ) {
119 AliMpTrigger* trigger = AliMpTriggerReader::ReadSlat(deTypeName, planeType);
120 mpSegmentation = new AliMpTriggerSegmentation(trigger);
123 AliErrorStream() << "Unknown station type" << endl;
125 fMpSegmentations.Add(deName, mpSegmentation);
126 return mpSegmentation;
129 //______________________________________________________________________________
130 void AliMpSegFactory::Delete(const Option_t* /*opt*/)
132 /// Delete all segmentations created with this manager
134 fMpSegmentations.Clear();