1 //____________________________________________________________________
5 // Script to make a class derived from AliFMDMap.
16 void MakeMap(const Char_t* type="Int_t", const Char_t* name=0)
20 if (ttype.EndsWith("_t")) {
21 Ssiz_t undert = ttype.Index("_t");
25 base = Form("AliFMD%sMap", ttype.Data());
29 cout << "Base name is " << base << endl;
31 TString decl_name(Form("%s.h", base.Data()));
32 TString impl_name(Form("%s.cxx", base.Data()));
33 ofstream decl(decl_name.Data());
34 ofstream impl(impl_name.Data());
37 cerr << "Cannot open declaration file " << decl_name << endl;
41 cerr << "Cannot open implementation file " << impl_name << endl;
46 cout << "The time is now " << now.AsString() << endl;
47 UserGroup_t* uinfo = gSystem->GetUserInfo();
48 TString uname(uinfo->fRealName);
49 Ssiz_t comma = uname.Index(",");
50 if (comma != kNPOS) uname.Remove(comma);
51 cout << "User's name is " << uname << endl;
56 cout << "Writing declaration file " << decl_name << " ... "
58 decl << "#ifndef " << guard << "\n";
59 decl << "#define " << guard << "\n";
60 decl << "/* Copyright (c) " << now.GetYear() ;
61 decl << ", ALICE Experiment @ CERN.\n" ;
62 decl << " * All rights reserved\n";
63 decl << " * See " << impl_name << " for full copyright notice\n";
65 decl << " * Created " << now.AsString() << " by " << uname << "\n";
67 decl << "/* $Id$ */\n";
68 decl << "//__________________________________________________________\n";
70 decl << "// Map of " << type << " for each FMD strip\n" ;
72 decl << "#ifndef ALIFMDMAP_H\n";
73 decl << "# include <AliFMDMap.h>\n";
75 decl << "class " << base << " : public AliFMDMap\n";
78 decl << " " << base << "(const " << base << "& other);\n";
79 decl << " " << base << "(size_t maxDet = kMaxDetectors,\n";
80 decl << " size_t maxRing = kMaxRings,\n";
81 decl << " size_t maxSec = kMaxSectors,\n";
82 decl << " size_t maxStr = kMaxStrips);\n";
83 decl << " virtual ~" << base << "() { delete [] fData; }\n";
84 decl << " " << base << "& operator=(const " << base << "& other);\n";
85 decl << " virtual void Clear(const " << type << "& v=" << type << "());\n";
86 decl << " virtual " << type << "& operator()(UShort_t det,\n";
87 decl << " Char_t ring,\n";
88 decl << " UShort_t sec,\n";
89 decl << " UShort_t str);\n";
90 decl << " virtual const " << type << "& operator()(UShort_t det,\n";
91 decl << " Char_t ring,\n";
92 decl << " UShort_t sec,\n";
93 decl << " UShort_t str) const;\n";
94 decl << "protected:\n";
95 decl << " " << type << "* fData; // The Data\n";
96 decl << " ClassDef(" << base << ",1) // Map of " << type ;
97 decl << " data per strip\n" ;
100 decl << "//__________________________________________________________\n";
102 decl << "// Local Variables:\n";
103 decl << "// mode: C++\n";
105 decl << "//" << endl;;
107 cout << "done" << endl;
109 cout << "Writing implementation file " << impl_name << " ... "
111 impl << "/**************************************************************\n";
112 impl << " * Copyright(c) 1998-1999, ALICE Experiment at CERN. *\n";
113 impl << " * All rights reserved. *\n";
115 impl << " * Author: The ALICE Off-line Project. *\n";
116 impl << " * Contributors are mentioned in the code where appropriate. *\n";
118 impl << " * Permission to use, copy, modify and distribute this *\n";
119 impl << " * software and its documentation strictly for non-commercial *\n";
120 impl << " * purposes is hereby granted without fee, provided that the *\n";
121 impl << " * above copyright notice appears in all copies and that both *\n";
122 impl << " * the copyright notice and this permission notice appear in *\n";
123 impl << " * the supporting documentation. The authors make no claims *\n";
124 impl << " * about the suitability of this software for any purpose. It *\n";
125 impl << " * is provided \"as is\" without express or implied warranty. *\n";
126 impl << " **************************************************************/\n";
127 impl << "/* $Id$ */\n";
128 impl << "//__________________________________________________________\n";
130 impl << "// Map of per strip " << type << " information\n";
132 impl << "// Created " << now.AsString() << " by " << uname << "\n";
134 impl << "#include \"" << decl_name << "\"\t//" << guard << "\n";
135 impl << "//__________________________________________________________\n";
136 impl << "ClassImp(" << base << ");\n";
137 impl << "//__________________________________________________________\n";
138 impl << base << "::" << base << "(const " << base << "& other)\n";
139 impl << " : AliFMDMap(other.fMaxDetectors,\n";
140 impl << " other.fMaxRings,\n";
141 impl << " other.fMaxSectors,\n";
142 impl << " other.fMaxStrips),\n";
143 impl << " fData(0)\n";
145 impl << " // Copy constructor\n";
146 impl << " fData = new " << type << "[fMaxDetectors * fMaxRings ";
147 impl << "* fMaxSectors * fMaxStrips];\n" ;
148 impl << " for (size_t i = 0; i < fMaxDetectors * fMaxRings ";
149 impl << "* fMaxSectors * fMaxStrips; i++)\n";
150 impl << " fData[i] = other.fData[i];\n";
152 impl << "//__________________________________________________________\n";
153 impl << base << "::" << base << "(size_t maxDet,\n";
154 impl << " size_t maxRing,\n";
155 impl << " size_t maxSec,\n";
156 impl << " size_t maxStr)\n";
157 impl << " : AliFMDMap(maxDet, maxRing, maxSec, maxStr),\n";
158 impl << " fData(0)\n";
160 impl << " // Constructor.\n";
161 impl << " // Parameters:\n";
162 impl << " //\tmaxDet\tMaximum number of detectors\n";
163 impl << " //\tmaxRing\tMaximum number of rings per detector\n";
164 impl << " //\tmaxSec\tMaximum number of sectors per ring\n";
165 impl << " //\tmaxStr\tMaximum number of strips per sector\n";
166 impl << " fData = new " << type << "[fMaxDetectors * fMaxRings ";
167 impl << "* fMaxSectors * fMaxStrips];\n" ;
168 impl << " Clear();\n";
170 impl << "//__________________________________________________________\n";
171 impl << base << "&\n";
172 impl << base << "::operator=(const " << base << "& other)\n";
174 impl << " // Assignment operator \n";
175 impl << " fMaxDetectors = other.fMaxDetectors;\n";
176 impl << " fMaxRings = other.fMaxRings;\n";
177 impl << " fMaxSectors = other.fMaxSectors;\n";
178 impl << " fMaxStrips = other.fMaxStrips;\n";
179 impl << " if (fData) delete [] fData;\n";
180 impl << " fData = new " << type << "[fMaxDetectors * fMaxRings ";
181 impl << "* fMaxSectors * fMaxStrips];\n" ;
182 impl << " for (size_t i = 0; i < fMaxDetectors * fMaxRings ";
183 impl << "* fMaxSectors * fMaxStrips; i++)\n";
184 impl << " fData[i] = other.fData[i];\n";
186 impl << "//__________________________________________________________\n";
188 impl << base << "::Clear(const " << type << "& val)\n";
190 impl << " // Reset map to val\n";
191 impl << " for (size_t i = 0; i < fMaxDetectors * fMaxRings ";
192 impl << "* fMaxSectors * fMaxStrips; i++)\n";
193 impl << " fData[i] = val;\n";
195 impl << "//__________________________________________________________\n";
196 impl << type << "&\n";
197 impl << base << "::operator()(UShort_t det, Char_t ring, UShort_t sec, " ;
198 impl << "UShort_t str)\n" ;
200 impl << " // Get data\n";
201 impl << " // Parameters:\n";
202 impl << " //\tdet\tDetector #\n";
203 impl << " //\tring\tRing ID\n";
204 impl << " //\tsec\tSector #\n";
205 impl << " //\tstr\tStrip #\n" ;
206 impl << " // Returns appropriate data\n";
207 impl << " return fData[CalcIndex(det, ring, sec, str)];\n";
209 impl << "//__________________________________________________________\n";
210 impl << "const " << type << "&\n";
211 impl << base << "::operator()(UShort_t det, Char_t ring, UShort_t sec, " ;
212 impl << "UShort_t str) const\n" ;
214 impl << " // Get data\n";
215 impl << " // Parameters:\n";
216 impl << " //\tdet\tDetector #\n";
217 impl << " //\tring\tRing ID\n";
218 impl << " //\tsec\tSector #\n";
219 impl << " //\tstr\tStrip #\n" ;
220 impl << " // Returns appropriate data\n";
221 impl << " return fData[CalcIndex(det, ring, sec, str)];\n";
223 impl << "//__________________________________________________________\n";
229 cout << "done" << endl;
243 //____________________________________________________________________