AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpSt345Reader.cxx
Go to the documentation of this file.
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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpSt345Reader.cxx,v 1.11 2006/05/24 13:58:50 ivana Exp $
18 
19 #include "AliMpSt345Reader.h"
20 
21 #include "AliLog.h"
22 #include "AliMpSlatMotifMap.h"
23 #include "AliMpMotifReader.h"
24 #include "AliMpFiles.h"
25 #include "AliMpDataStreams.h"
26 #include "AliMpMotifType.h"
27 #include "AliMpPCB.h"
28 #include "AliMpSlat.h"
29 #include "AliMpMotifPosition.h"
30 #include "AliMpMotif.h"
31 #include "AliMpHelper.h"
32 #include "AliMpConstants.h"
33 
34 #include "Riostream.h"
35 #include "TClass.h"
36 #include "TObjString.h"
37 #include "TString.h"
38 
39 #include <sstream>
40 
41 
42 //-----------------------------------------------------------------------------
44 //
52 //-----------------------------------------------------------------------------
53 
57 
58 //_____________________________________________________________________________
60 :
61 TObject(),
62 fMotifMap(motifMap)
63 {
67 }
68 
69 //_____________________________________________________________________________
71 {
75 }
76 
77 //_____________________________________________________________________________
78 AliMpPCB*
80  const char* pcbType)
81 {
85 
86  istream& in
87  = dataStreams.
88  CreateDataStream(AliMpFiles::SlatPCBFilePath(
89  AliMp::kStation345, pcbType));
90 
92  // note that the nonbending
93  // parameter is of no use for station345, as far as reading motif is
94  // concerned, as all motifs are supposed to be in the same directory
95  // (as they are shared by bending/non-bending planes).
96 
97  char line[80];
98 
99  const TString kSizeKeyword("SIZES");
100  const TString kMotifKeyword("MOTIF");
101 
102  AliMpPCB* pcb = 0;
103 
104  while ( in.getline(line,80) )
105  {
106  if ( line[0] == '#' ) continue;
107 
108  TString sline(line);
109 
110  if ( sline(0,kSizeKeyword.Length()) == kSizeKeyword )
111  {
112  std::istringstream sin(sline(kSizeKeyword.Length(),
113  sline.Length()-kSizeKeyword.Length()).Data());
114  double padSizeX = 0.0;
115  double padSizeY = 0.0;
116  double pcbSizeX = 0.0;
117  double pcbSizeY = 0.0;
118  sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY;
119  if (pcb)
120  {
121  AliError("pcb not null as expected");
122  }
123  pcb = new AliMpPCB(fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
124  }
125 
126  if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
127  {
128  std::istringstream sin(sline(kMotifKeyword.Length(),
129  sline.Length()-kMotifKeyword.Length()).Data());
130  TString sMotifType;
131  int ix;
132  int iy;
133  sin >> sMotifType >> ix >> iy;
134 
135  AliMpMotifType* motifType = fMotifMap->FindMotifType(sMotifType);
136  if (!motifType)
137  {
138  AliDebug(1,Form("Reading motifType %s from file",sMotifType.Data()));
139  motifType = reader.BuildMotifType(dataStreams, sMotifType.Data());
140  fMotifMap->AddMotifType(motifType);
141  }
142  else
143  {
144  AliDebug(1,Form("Got motifType %s from motifMap",sMotifType.Data()));
145  }
146 
147  if (pcb) pcb->Add(motifType,ix,iy);
148  }
149  }
150 
151  delete &in;
152 
153  return pcb;
154 }
155 
156 //_____________________________________________________________________________
157 AliMpSlat*
159  const char* slatType, AliMp::PlaneType planeType)
160 {
164 
165  istream& in
166  = dataStreams.
167  CreateDataStream(AliMpFiles::SlatFilePath(
168  AliMp::kStation345, slatType, planeType));
169 
170  char line[80];
171 
172  const TString kpcbKeyword("PCB");
173 
174  AliMpSlat* slat = new AliMpSlat(slatType, planeType);
175 
176  while ( in.getline(line,80) )
177  {
178  if ( line[0] == '#' ) continue;
179 
180  TString sline(AliMpHelper::Normalize(line));
181 
182  if ( sline(0,kpcbKeyword.Length()) == kpcbKeyword )
183  {
184  TString tmp(sline(kpcbKeyword.Length()+1,sline.Length()-kpcbKeyword.Length()));
185  Ssiz_t blankPos = tmp.First(' ');
186  if ( blankPos < 0 )
187  {
188  AliErrorClass("Syntax error in PCB file, should get a list of "
189  "manu ids after the pcbname");
190  delete slat;
191  return 0;
192  }
193 
194  TString pcbName(tmp(0,blankPos));
195  TString manus(tmp(blankPos+1,tmp.Length()-blankPos));
196 
197  AliMpPCB* pcbType = ReadPCB(dataStreams,pcbName.Data());
198  if (!pcbType)
199  {
200  AliErrorClass(Form("Cannot read pcbType=%s",pcbName.Data()));
201  delete slat;
202  return 0;
203  }
204 
205  TArrayI manuList;
206  AliMpHelper::DecodeName(manus,';',manuList);
207  if ( manuList.GetSize() != Int_t(pcbType->GetSize()) )
208  {
209  AliErrorClass(Form("Wrong number of manu ids for this PCB ("
210  "%s) : %d out of %d",pcbName.Data(),
211  manuList.GetSize(),pcbType->GetSize()));
212  delete pcbType;
213  delete slat;
214  return 0;
215  }
216 
217  for ( Int_t i = 0; i < manuList.GetSize(); ++i )
218  {
219  manuList[i] |= AliMpConstants::ManuMask(planeType);
220  }
221  slat->Add(*pcbType,manuList);
222  delete pcbType;
223  }
224  }
225 
226  delete &in;
227 
228  return slat;
229 }
230 
231 
Bool_t AddMotifType(AliMpMotifType *motifType, Bool_t warn=kTRUE)
static TString Normalize(const char *line)
station 3,4,5 (slats)
A PCB for station 3,4 or 5.
Definition: AliMpPCB.h:46
void Add(const AliMpPCB &pcbType, const TArrayI &manuList)
Definition: AliMpSlat.cxx:112
Int_t GetSize() const
The number of motifs, aka manus.
Definition: AliMpPCB.cxx:588
AliMpMotifType * BuildMotifType(const AliMpDataStreams &dataStreams, const TString &motifTypeId)
AliMpSlatMotifMap * fMotifMap
! storage for motifTypes and motifs...
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
A container to keep track of allocated motifs and motifTypes for slats (both St345 and trigger ones)...
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static TString SlatPCBFilePath(AliMp::StationType stationType, const char *pcbType)
Definition: AliMpFiles.cxx:369
AliMpSlat * ReadSlat(const AliMpDataStreams &dataStreams, const char *slatType, AliMp::PlaneType planeType)
void Add(AliMpMotifType *motifType, Int_t ix, Int_t iy)
Definition: AliMpPCB.cxx:231
non-bending plane
AliMpPCB * ReadPCB(const AliMpDataStreams &dataStreams, const char *pcbType)
Read slat and pcb ASCII files.
value for all non sector stations
virtual ~AliMpSt345Reader()
Class that takes care of reading the motifs data.
AliMpMotifType * FindMotifType(const TString &id) const
static TString SlatFilePath(AliMp::StationType stationType, const char *slatType, AliMp::PlaneType plane)
Definition: AliMpFiles.cxx:357
static Int_t ManuMask(AliMp::PlaneType planeType)
Class that defines the motif properties.
Mapping data streams provider.
static void DecodeName(const char *manus, char sep, TArrayI &theList)