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 **************************************************************************/
18 Revision 1.10 2000/01/19 17:16:51 fca
19 Introducing a list of lists of hits -- more hits allowed for detector now
21 Revision 1.9 1999/11/14 14:33:25 fca
22 Correct problems with distructors and pointers, thanks to I.Hrivnacova
24 Revision 1.8 1999/09/29 09:24:19 fca
25 Introduction of the Copyright and cvs Log
29 ///////////////////////////////////////////////////////////////////////////////
31 // An overview of the basic philosophy of the ITS code development
32 // and analysis is show in the figure below.
35 <img src="picts/ITS/ITS_Analysis_schema.gif">
38 <font size=+2 color=red>
39 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
40 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
46 // AliITS. Inner Traking System base class.
47 // This class contains the base procedures for the Inner Tracking System
51 <img src="picts/ITS/AliITS_Class_Diagram.gif">
54 <font size=+2 color=red>
55 <p>This show the class diagram of the different elements that are part of
63 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
66 // Modified and documented by Bjorn S. Nilsen
69 // AliITS is the general base class for the ITS. Also see AliDetector for
70 // futher information.
72 ///////////////////////////////////////////////////////////////////////////////
77 #include <TGeometry.h>
81 #include "AliITSmodule.h"
82 #include "AliDetector.h"
84 #include "TClonesArray.h"
85 #include "TObjArray.h"
86 #include "AliITShit.h"
87 #include "AliITSdigit.h"
92 ////////////////////////////////////////////////////////////////////////
94 // An overview of the basic philosophy of the ITS code development
95 // and analysis is show in the figure below.
98 <img src="picts/ITS/ITS_Analysis_schema.gif">
101 <font size=+2 color=red>
102 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
103 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
110 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
113 // Modified and documented by Bjorn S. Nilsen
116 // AliITS is the general base class for the ITS. Also see AliDetector for
117 // futher information.
121 // AliITSgeom *fITSgeom
122 // All of the geometry information about the active volumes that
123 // make up the ITS are described in the AliITSgeom class. This includes
124 // the transformation functions between the local and global coordinate
125 // systems and the like. See the full description found in the AliITSgeom
126 // class. Here in the AliITS class is kept the pointer to the geometry
127 // used in the simulations or that thought to be the correct one for the
128 // data. Until a more general class is define and a more appropriate
129 // place is found to keep this geometry information, it is kept here in
132 // TObjArray *fITSpoints
133 // This is a pointer to the points, to be used by the tracking algorithms
134 // for example, found in the detectors of the ITS. To allow for the most
135 // general points structure it is defined to be a pointer to a TObjArray where
136 // each array element would be one point found in the ITS detectors. An
137 // Addpoints function is defined below. By default an array of 16 TObjects are
138 // defined during the initialization of AliITS. This is automatically expanded
139 // when necessary by the Addpoints function.
142 // This is a flag used to indicate that an Euclid compatible CAD
143 // file will be created upon the creation of the ITS Monte Carlo
144 // geometry definition, in the function CreatGeometry. If fEuclidOut is
145 // true, then a file called ITSgeometry.euc will be created.
148 // This variable contains the number of layers defined in the ITS
149 // geometry. It is primarily used as a size indicator for fIdSens and
150 // fIdName described below. In general the number of layers, ladders, or
151 // detectors should be gotten from the AliITSgeom functions. Upon
152 // creating the AliITS object it is set to zero.
155 // This is a pointer to an array containing the Monte Carlo volume
156 // numbers for the different layers of the ITS. These numbers are needed
157 // by the StepManager function to determine what layer a hit was on. It
158 // is sized and initialized in the Init function and the AliITSv? Init
159 // function, called after a call to CreateGeometry. Upon creating the
160 // AliITS object it points to zero. This variable is made a pointer
161 // in order to keep the maximum flexibility at this level of the code.
164 // This is a pointer to an array of characters containing the names of
165 // the different ITS layers as defined in the Monte Carlo geometry data-
166 // base. It is sized and filled in the AliITSv? Init function, called
167 // after a call to CreatGeometry. Upon creating the AliITS object it
168 // points to zero. This variable is make a pointer in order to keep the
169 // maximum flexibility at this level of the code.
174 // The default constructor of the AliITS class. In addition to
175 // creating the AliITS class it zeros the variables fIshunt (a member
176 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
177 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
180 // AliITS(const char *name, const char *title)
181 // The constructor of the AliITS class. In addition to creating the
182 // AliITS class, it allocates memory for the TClonesArrays fHits and
183 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
184 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
185 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
186 // macro display.C AliITS also sets the marker color to red. The variables
187 // passes with this constructor, const char *name and *title, are used by
188 // the constructor of AliDetector class. See AliDetector class for a
189 // description of these parameters and its constructor functions.
192 // The default destructor of the AliITS class. In addition to deleting
193 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
194 // fIdSens, fIdName, and fITSpoints.
196 // AddHit(Int_t track, Int_t *vol, Float_t *hits)
197 // The function to add information to the AliITShit class. See the
198 // AliITShit class for a full description. This function allocates the
199 // necessary new space for the hit information and passes the variable
200 // track, and the pointers *vol and *hits to the AliITShit constructor
203 // AddDigit(Int_t *track, Int_t *digits)
204 // The function to add information to the AliITSdigits class. See the
205 // AliITSdigits class for a full description. This function allocates the
206 // necessary new space for the digits information and passes the pointers
207 // *track and *digits to the AliITSdigits constructor function.
210 // This function builds a simple ITS geometry used by the ROOT macro
211 // display.C. In general the geometry as coded is wrong.
214 // This function builds the detailed geometry used by the Geant
215 // Monte Carlo. As defined here it is a dummy routine to be replaced
216 // by the version coded up in AliITSv? where the specific geometry to
217 // be used by the simulation is defined. See the definition of AliITSv5
218 // or the other routines for a complete definition.
221 // This function defines the default materials used in the Geant
222 // Monte Carlo simulations. In general it is automatically replaced by
223 // the CreatMaterials routine defined in AliITSv?. Should the function
224 // CreateMaterials not exist for the geometry version you are using this
225 // one is used. See the definition found in AliITSv5 or the other routine
226 // for a complete definition.
229 // Returns the version number of the AliITS class. At present it is
232 // DistancetoPrimitive(Int_t x, Int_t y)
233 // A dummy routine used by the ROOT macro display.C to allow for the
234 // use of the mouse (pointing device) in the macro. In general this should
235 // never be called. If it is it returns the number 9999 for any value of
239 // This routine initializes the AliITS class. It is intended to be called
240 // from the Init function in AliITSv?. Besides displaying a banner
241 // indicating that it has been called it initializes the array fIdSens.
242 // Therefore it should be called after a call to CreateGeometry.
244 // MakeBranch(Option_t *Opt=" ")
245 // Creates the TTree branch where the class AliITS is kept.
247 // SetEUCLID(bool_t euclid=1)
248 // Sets the flag fEuclidOut to true (default) of false (euclid=0).
249 // By setting or clearing the fEuclidOut flag you can controls whether
250 // or not a euclid formatted output file of the ITS geometry is written.
251 // If fEuclidOut is set true then a file called ITSgeometry.euc will be
252 // written after the ITS geometry is defined in the Monte Carlo. If
253 // fEuclidOut is set false then no file is created.
256 // Dummy routine which is replaced by the routine StepManager() defined
257 // in AliITSv?. If no such routine exist then this routine returns zero.
258 // See AliITSv? for a detailed description of the step manager routines.
261 // Returns the value of the pointer fITSgeom. This is used to get
262 // access to the ITS geometry stored in the file. See AliITSgeom for a
263 // full description of the geometry package.
266 // Returns the value of the pointer fITSpoints. This is used to get
267 // access to the ITS cluster objects, if filled, stored in the file. See
268 // AliITSCluster for a full description of the cluster data.
269 ////////////////////////////////////////////////////////////////////////
270 //_____________________________________________________________________________
273 // Default initialiser for ITS
274 // The default constructor of the AliITS class. In addition to
275 // creating the AliITS class it zeros the variables fIshunt (a member
276 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
277 // fITSpoints, fIdSens, and fIdName.
288 //_____________________________________________________________________________
289 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
291 // Default initialiser for ITS
292 // The constructor of the AliITS class. In addition to creating the
293 // AliITS class, it allocates memory for the TClonesArrays fHits and
294 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
295 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
296 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
297 // macro display.C AliITS also sets the marker color to red. The variables
298 // passes with this constructor, const char *name and *title, are used by
299 // the constructor of AliDetector class. See AliDetector class for a
300 // description of these parameters and its constructor functions.
303 fHits = new TClonesArray("AliITShit", 1560);
304 gAlice->AddHitList(fHits);
305 fDigits = new TClonesArray("AliITSdigit",1000);
306 fITSpoints = new TObjArray();
307 fITSmodules = 0; //new AliITSmodules();
315 SetMarkerColor(kRed);
319 //_____________________________________________________________________________
322 // Default distructor for ITS
323 // The default destructor of the AliITS class. In addition to deleting
324 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
325 // fIdSens, fIdName, and fITSpoints.
329 if(fIdName!=0) delete[] fIdName;
330 if(fIdSens!=0) delete[] fIdSens;
332 if(fITSpoints!=0) delete fITSpoints;
335 //_____________________________________________________________________________
336 void AliITS::AddDigit(Int_t *tracks, Int_t *digits){
339 // The function to add information to the AliITSdigits class. See the
340 // AliITSdigits class for a full description. This function allocates the
341 // necessary new space for the digits information and passes the pointers
342 // *track and *digits to the AliITSdigits constructor function.
344 TClonesArray &ldigits = *fDigits;
345 new(ldigits[fNdigits++]) AliITSdigit(tracks,digits);
348 Int_t AliITS::AddDigit(AliITSdigit* d) {
351 fNdigits = fDigits->GetEntriesFast();
355 //_____________________________________________________________________________
356 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
359 // The function to add information to the AliITShit class. See the
360 // AliITShit class for a full description. This function allocates the
361 // necessary new space for the hit information and passes the variable
362 // track, and the pointers *vol and *hits to the AliITShit constructor
365 TClonesArray &lhits = *fHits;
366 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
368 //_____________________________________________________________________________
369 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
371 // Distance from mouse to ITS on the screen. Dummy routine
372 // A dummy routine used by the ROOT macro display.C to allow for the
373 // use of the mouse (pointing device) in the macro. In general this should
374 // never be called. If it is it returns the number 9999 for any value of
380 //_____________________________________________________________________________
383 // Initialise ITS after it has been built
384 // This routine initializes the AliITS class. It is intended to be called
385 // from the Init function in AliITSv?. Besides displaying a banner
386 // indicating that it has been called it initializes the array fIdSens.
387 // Therefore it should be called after a call to CreateGeometry.
392 for(i=0;i<35;i++) printf("*");
393 printf(" ITS_INIT ");
394 for(i=0;i<35;i++) printf("*");
398 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
400 for(i=0;i<80;i++) printf("*");
404 //_____________________________________________________________________________
405 void AliITS::MakeBranch(Option_t* option){
407 // Create Tree branches for the ITS.
408 // Creates the TTree branch where the class AliITS is kept.
410 Int_t buffersize = 4000;
412 sprintf(branchname,"%s",GetName());
414 AliDetector::MakeBranch(option);
416 char *D = strstr(option,"D");
418 if (fDigits && gAlice->TreeD() && D) {
419 gAlice->TreeD()->Branch(branchname,&fDigits, buffersize);
420 printf("Making Branch %s for digits\n",branchname);
424 //____________________________________________________________________________
425 void AliITS::Streamer(TBuffer &R__b){
426 // Stream an object of class AliITS.
429 if (R__b.IsReading()) {
430 Version_t R__v = R__b.ReadVersion();
432 AliDetector::Streamer(R__b);
434 // R__b >> fITSmodules; //We do not write out modules so don't read them
438 if(fIdSens!=0) delete[] fIdSens;
439 if(fIdName!=0) delete[] fIdName;
440 fIdSens = new Int_t[fIdN];
441 fIdName = new char*[fIdN];
442 for(i=0;i<fIdN;i++) R__b >> fIdSens[i];
445 fIdName[i] = new char[l+1]; // add room for null character.
446 for(j=0;j<l;j++) R__b >> fIdName[i][j];
447 fIdName[i][l] = '\0'; // Null terminate this string.
449 R__b >> fMajorVersion;
450 R__b >> fMinorVersion;
453 R__b.WriteVersion(AliITS::IsA());
454 AliDetector::Streamer(R__b);
456 // R__b << fITSmodules; //We don't want to write out the modules class.
460 for(i=0;i<fIdN;i++) R__b <<fIdSens[i];
462 l = strlen(fIdName[i]);
464 for(j=0;j<l;j++) R__b << fIdName[i][j];
466 R__b << fMajorVersion;
467 R__b << fMinorVersion;