]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITS.cxx
New Fastpoint merger added.
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
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 purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.71  2002/05/13 14:27:56  hristov
19 TreeC created once per event (M.Masera)
20
21 Revision 1.70  2002/05/10 22:28:30  nilsen
22 Changes by Massimo Masera to allow the TTree of clusters to be written to a
23 file otherthan the one with digits in it.
24
25 Revision 1.69  2002/05/05 21:06:55  nilsen
26 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
27 proper initilization when a simulation has already been defined.
28
29 Revision 1.68  2002/05/02 18:51:53  nilsen
30 AliITS.h
31    Method MakeBranchR has now a second argument, with a default value:
32        Option_t *opt=" ". Opt="Fast" is to create a separate branch
33        for fast points in TreeR
34    New method MakeBranchRF: it a separate branch in TreeR for Fast Points
35
36 AliITS.cxx
37 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
38    TreeR
39 2) Changes in MakeBranchR to allow the creation of a special branch
40    for fast points
41
42 Revision 1.67  2002/03/15 17:22:51  nilsen
43 Intoduced SDigits2Digits and SDigitsToDigits functions.
44
45 Revision 1.66  2001/11/28 01:35:45  nilsen
46 Using standard constructors instead of default constructors for Clusterfinder,
47 Response, and FastSimulator.
48
49 Revision 1.65  2001/11/27 16:27:28  nilsen
50 Adding AliITSDigitizer class to do merging and digitization . Based on the
51 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
52 file. The following files required minor changes. AliITS, added functions
53 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
54 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
55 the original Root Directory in function Compress1D. Now it uses gDirectory.
56
57 Revision 1.64  2001/11/19 16:17:02  nilsen
58 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
59 bugs found by Rene require more work to fix. Will be fixed soon.
60
61 Revision 1.63  2001/10/24 21:16:34  nilsen
62 Removed some dead code and improved comments/documntation.
63
64 Revision 1.62  2001/10/21 19:23:21  nilsen
65 Added function to allow to limit which detectors to digitize and reconstruct.
66 The default is All. This change makes no changes to any root file.
67
68 Revision 1.61  2001/10/11 15:26:07  mariana
69 Correct HitsToFastRecPoints
70
71 Revision 1.60  2001/10/04 22:38:10  nilsen
72 Changes made to support PreDigits (SDigits) plus other helpful changes.
73
74 Revision 1.59  2001/08/30 09:56:18  hristov
75 The operator[] is replaced by At() or AddAt() in case of TObjArray.
76
77 Revision 1.58  2001/07/26 15:05:29  hristov
78 Use global gRandom generator (M.Ivanov)
79
80 Revision 1.57  2001/07/24 14:26:11  mariana
81 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
82
83 Revision 1.56  2001/07/05 12:49:49  mariana
84 Temporary patches required by root.v3.01.05
85
86 Revision 1.55  2001/06/14 14:59:00  barbera
87 Tracking V1 decoupled from AliITS
88
89 Revision 1.54  2001/05/31 20:37:56  barbera
90 Bari/Salerno model set as defaault SPD simulation
91
92 Revision 1.53  2001/05/31 18:52:24 barbera 
93 Bari model becomes the default
94
95 Revision 1.53  2001/05/30 07:52:24  hristov
96 TPC and CONTAINERS included in the search path
97
98 Revision 1.52  2001/05/30 06:04:58  hristov
99 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
100
101 Revision 1.51  2001/05/16 14:57:15  alibrary
102 New files for folders and Stack
103
104 Revision 1.50  2001/05/11 09:15:21  barbera
105 Corrected to make fast point creation working with PPR geometry
106
107 Revision 1.49  2001/05/11 07:37:49  hristov
108 Legacy lines commented
109
110 Revision 1.48  2001/05/10 18:14:25  barbera
111 A typo corrected
112
113 Revision 1.47  2001/05/10 17:55:59  barbera
114 Modified to create rec points also for PPR geometries
115
116 Revision 1.46  2001/05/10 00:05:28  nilsen
117 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
118 should probably be cleaned up to only check to make sure that fITSgeom has
119 been properly defined.
120
121 Revision 1.45  2001/05/01 22:35:48  nilsen
122 Remove/commented a number of cout<< statements. and made change needed by
123 SSD code.
124
125 Revision 1.44  2001/04/26 22:44:01  nilsen
126 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
127 done properly in AliITSv???.cxx via SetDefaults.
128
129 Revision 1.43  2001/04/26 13:22:52  barbera
130 TMatrix and TVector elimininated to speed up the code
131
132 Revision 1.42  2001/04/25 21:55:12  barbera
133 Updated version to be compatible with actual verion of STEER and TPC
134
135 Revision 1.41  2001/04/21 15:16:51  barbera
136 Updated with the new SSD reconstruction code
137
138 Revision 1.40  2001/03/17 15:07:06  mariana
139 Update SDD response parameters
140
141 Revision 1.39  2001/03/12 17:45:32  hristov
142 Changes needed on Sun with CC 5.0
143
144 Revision 1.38  2001/03/07 14:04:51  barbera
145 Some vector dimensions increased to cope with full events
146
147 Revision 1.37  2001/03/07 12:36:35  barbera
148 A change added in the tracking part to manage delta rays
149
150 Revision 1.36  2001/03/02 19:44:11  barbera
151  modified to taking into account new version tracking v1
152
153 Revision 1.35  2001/02/28 18:16:46  mariana
154 Make the code compatible with the new AliRun
155
156 Revision 1.34  2001/02/11 15:51:39  mariana
157 Set protection in MakeBranch
158
159 Revision 1.33  2001/02/10 22:26:39  mariana
160 Move the initialization of the containers for raw clusters in MakeTreeC()
161
162 Revision 1.32  2001/02/08 23:55:31  nilsen
163 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
164 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
165
166 Revision 1.31  2001/02/02 23:57:28  nilsen
167 Added include file that are no londer included in AliITSgeom.h
168
169 Revision 1.30  2001/01/30 09:23:13  hristov
170 Streamers removed (R.Brun)
171
172 Revision 1.29  2001/01/26 20:01:09  hristov
173 Major upgrade of AliRoot code
174
175 Revision 1.28  2000/12/18 14:02:00  barbera
176 new version of the ITS tracking to take into account the new TPC track parametrization
177
178 Revision 1.27  2000/12/08 13:49:27  barbera
179 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
180
181 Revision 1.26  2000/11/27 13:12:13  barbera
182 New version containing the files for tracking
183
184 Revision 1.25  2000/11/12 22:38:05  barbera
185 Added header file for the SPD Bari model
186
187 Revision 1.24  2000/10/09 22:18:12  barbera
188 Bug fixes from MAriana to le AliITStest.C run correctly
189
190 Revision 1.23  2000/10/05 20:47:42  nilsen
191 fixed dependencies of include files. Tryed but failed to get a root automaticly
192 generates streamer function to work. Modified SetDefaults.
193
194 Revision 1.9.2.15  2000/10/04 16:56:40  nilsen
195 Needed to include stdlib.h
196
197 =======
198 Revision 1.22  2000/10/04 19:45:52  barbera
199 Corrected by F. Carminati for v3.04
200
201 Revision 1.21  2000/10/02 21:28:08  fca
202 Removal of useless dependecies via forward declarations
203
204 Revision 1.20  2000/10/02 16:31:39  barbera
205 General code clean-up
206
207 Revision 1.9.2.14  2000/10/02 15:43:51  barbera
208 General code clean-up (e.g., printf -> cout)
209
210 Revision 1.19  2000/09/22 12:13:25  nilsen
211 Patches and updates for fixes to this and other routines.
212
213 Revision 1.18  2000/07/12 05:32:20  fca
214 Correcting several syntax problem with static members
215
216 Revision 1.17  2000/07/10 16:07:18  fca
217 Release version of ITS code
218
219 Revision 1.9.2.3  2000/02/02 13:42:09  barbera
220 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
221
222 Revision 1.9.2.2  2000/01/23 03:03:13  nilsen
223 //fixed FillModule. Removed fi(fabs(xl)<dx....
224
225 Revision 1.9.2.1  2000/01/12 19:03:32  nilsen
226 This is the version of the files after the merging done in December 1999.
227 See the ReadMe110100.txt file for details
228
229 Revision 1.9  1999/11/14 14:33:25  fca
230 Correct problems with distructors and pointers, thanks to I.Hrivnacova
231
232 Revision 1.8  1999/09/29 09:24:19  fca
233 Introduction of the Copyright and cvs Log
234
235 */
236
237 ///////////////////////////////////////////////////////////////////////////////
238 //
239 //      An overview of the basic philosophy of the ITS code development
240 // and analysis is show in the figure below.
241 //Begin_Html
242 /*
243 <img src="picts/ITS/ITS_Analysis_schema.gif">
244 </pre>
245 <br clear=left>
246 <font size=+2 color=red>
247 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
248 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
249 </font>
250 <pre>
251 */
252 //End_Html
253 //
254 //  AliITS. Inner Traking System base class.
255 //  This class contains the base procedures for the Inner Tracking System
256 //
257 //Begin_Html
258 /*
259 <img src="picts/ITS/AliITS_Class_Diagram.gif">
260 </pre>
261 <br clear=left>
262 <font size=+2 color=red>
263 <p>This show the class diagram of the different elements that are part of
264 the AliITS class.
265 </font>
266 <pre>
267 */
268 //End_Html
269 //
270 // Version: 0
271 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
272 //
273 // Version: 1
274 // Modified and documented by Bjorn S. Nilsen
275 // July 11 1999
276 //
277 // Version: 2
278 // Modified and documented by A. Bologna
279 // October 18 1999
280 //
281 // AliITS is the general base class for the ITS. Also see AliDetector for
282 // futher information.
283 //
284 ///////////////////////////////////////////////////////////////////////////////
285 #include <iostream.h>
286 #include <iomanip.h>
287 #include <fstream.h>
288 #include <stdlib.h>
289 #include <TMath.h>
290 #include <TRandom.h>
291 #include <TBranch.h>
292 #include <TVector.h>
293 #include <TClonesArray.h>
294 #include <TROOT.h>
295 #include <TObjectTable.h>
296 #include <TFile.h>
297 #include <TTree.h>
298 #include <TString.h>
299
300 #include "AliMC.h"
301 #include "AliHeader.h"
302
303 #include "AliITS.h"
304 #include "AliITSDetType.h"
305 #include "AliITSresponseSPD.h"
306 #include "AliITSresponseSDD.h"
307 #include "AliITSresponseSSD.h"
308 #include "AliITSsegmentationSPD.h"
309 #include "AliITSsegmentationSDD.h"
310 #include "AliITSsegmentationSSD.h"
311 #include "AliITSsimulationSPD.h"
312 #include "AliITSsimulationSDD.h"
313 #include "AliITSsimulationSSD.h"
314 #include "AliITSClusterFinderSPD.h"
315 #include "AliITSClusterFinderSDD.h"
316 #include "AliITSClusterFinderSSD.h"
317 #include "AliITShit.h"
318 #include "AliITSgeom.h"
319 #include "AliITSpList.h"
320 #include "AliITSdigit.h"
321 #include "AliITSmodule.h"
322 #include "AliITSRecPoint.h"
323 #include "AliITSRawCluster.h"
324
325 ClassImp(AliITS)
326
327 //______________________________________________________________________
328 AliITS::AliITS() : AliDetector() {
329     // Default initializer for ITS
330     //      The default constructor of the AliITS class. In addition to
331     // creating the AliITS class it zeros the variables fIshunt (a member
332     // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
333     // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
334     // is also called.
335     // Inputs:
336     //      none.
337     // Outputs:
338     //      none.
339     // Return:
340     //      Blank ITS class.
341
342     fIshunt     = 0;   // not zeroed in AliDetector.
343
344     // AliITS variables.
345     fEuclidOut  = 0;
346     fITSgeom    = 0;
347     fITSmodules = 0;
348     fOpt        = "All";
349 //    SetDetectors(); // default to fOpt="All". This variable not written out.
350
351     fIdN        = 0;
352     fIdName     = 0;
353     fIdSens     = 0;
354
355     fNDetTypes  = kNTYPES;
356     fDetTypes   = 0;
357
358     fSDigits    = 0;
359     fNSDigits   = 0;
360
361     fNdtype     = 0;
362     fDtype      = 0;
363
364     fCtype      = 0;
365     fNctype     = 0;
366     fTreeC      = 0;
367
368     fRecPoints  = 0;
369     fNRecPoints = 0;
370
371     SetMarkerColor(kRed);
372 }
373 //______________________________________________________________________
374 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
375     //     The standard Constructor for the ITS class. In addition to 
376     // creating the AliITS class, it allocates memory for the TClonesArrays 
377     // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype 
378     // (clusters). It also zeros the variables
379     // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
380     // the pointers fIdSens and fIdName. To help in displaying hits via the
381     // ROOT macro display.C AliITS also sets the marker color to red. The
382     // variables passes with this constructor, const char *name and *title,
383     // are used by the constructor of AliDetector class. See AliDetector
384     // class for a description of these parameters and its constructor
385     // functions.
386     // Inputs:
387     //      const char *name      Detector name. Should always be "ITS"
388     //      const char *title     Detector title.
389     // Outputs:
390     //      none.
391     // Return:
392     //      An ITS class.
393
394     fIshunt     = 0;  // not zeroed in AliDetector
395     fHits       = new TClonesArray("AliITShit", 1560);//not done in AliDetector
396     gAlice->AddHitList(fHits);  // Not done in AliDetector.
397
398     fEuclidOut  = 0;
399     fITSgeom    = 0;
400     fITSmodules = 0;
401     SetDetectors(); // default to fOpt="All". This variable not written out.
402
403     fIdN        = 0;
404     fIdName     = 0;
405     fIdSens     = 0;
406
407     fNDetTypes  = kNTYPES;
408     fDetTypes   = new TObjArray(fNDetTypes);
409
410     fSDigits    = new TClonesArray("AliITSpListItem",1000);
411     fNSDigits   = 0;
412
413     fNdtype     = new Int_t[fNDetTypes];
414     fDtype      = new TObjArray(fNDetTypes);
415
416     fCtype      = new TObjArray(fNDetTypes);
417     fNctype     = new Int_t[fNDetTypes];
418     fTreeC      = 0;
419
420     fRecPoints  = new TClonesArray("AliITSRecPoint",1000);
421     fNRecPoints = 0;
422
423     Int_t i;
424     for(i=0;i<fNDetTypes;i++) {
425         fDetTypes->AddAt(new AliITSDetType(),i); 
426         fNdtype[i] = 0;
427         fNctype[i] = 0;
428     } // end for i
429
430     SetMarkerColor(kRed);
431 }
432 //______________________________________________________________________
433 AliITS::~AliITS(){
434     // Default destructor for ITS.
435     //     The default destructor of the AliITS class. In addition to deleting
436     // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
437     // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName, 
438     // fITSpoints, fDetType and it's contents.
439     // Inputs:
440     //      none.
441     // Outputs:
442     //      none.
443     // Return:
444     //      none.
445
446     delete fHits; fHits=0;
447     delete fSDigits; fSDigits=0;
448 //    delete fDigits; fDigits=0;
449     delete fRecPoints; fRecPoints=0;
450     if(fIdName!=0) delete[] fIdName;  // Array of TStrings
451     if(fIdSens!=0) delete[] fIdSens;
452     if(fITSmodules!=0) {
453         this->ClearModules();
454         delete fITSmodules;
455     }// end if fITSmodules!=0
456
457     if(fDtype) {
458         fDtype->Delete();
459         delete fDtype;
460     } // end if fDtype
461     delete [] fNdtype;
462     if (fCtype) {
463         fCtype->Delete();
464         delete fCtype;
465     } // end if fCtype
466     delete [] fNctype;
467
468     if (fDetTypes) {
469         fDetTypes->Delete();
470         delete fDetTypes;
471     } // end if fDetTypes
472
473     if (fTreeC) delete fTreeC;
474
475     if (fITSgeom) delete fITSgeom;
476 }
477 //______________________________________________________________________
478 AliITS::AliITS(AliITS &source){
479     // Copy constructor. This is a function which is not allowed to be
480     // done to the ITS. It exits with an error.
481     // Inputs:
482     //      AliITS &source  An AliITS class.
483     // Outputs:
484     //      none.
485     // Return:
486     //      none.
487
488     if(this==&source) return;
489     Error("Copy constructor",
490           "You are not allowed to make a copy of the AliITS");
491     exit(1);
492 }
493 //______________________________________________________________________
494 AliITS& AliITS::operator=(AliITS &source){
495     // Assignment operator. This is a function which is not allowed to be
496     // done to the ITS. It exits with an error.
497     // Inputs:
498     //      AliITS &source  An AliITS class.
499     // Outputs:
500     //      none.
501     // Return:
502     //      none.
503
504     if(this==&source) return *this;
505     Error("operator=","You are not allowed to make a copy of the AliITS");
506     exit(1);
507     return *this; //fake return
508 }
509 //______________________________________________________________________
510 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
511     // Distance from mouse to ITS on the screen. Dummy routine
512     //     A dummy routine used by the ROOT macro display.C to allow for the
513     // use of the mouse (pointing device) in the macro. In general this should
514     // never be called. If it is it returns the number 9999 for any value of
515     // x and y.
516     // Inputs:
517     //      Int_t     Dummy screen coordinate.
518     //      Int_t     Dummy screen coordinate.
519     // Outputs:
520     //      none.
521     // Return:
522     //      Int_t     Dummy = 9999 distance to ITS.
523
524     return 9999;
525 }
526 //______________________________________________________________________
527 void AliITS::Init(){
528     // Initializer ITS after it has been built
529     //     This routine initializes the AliITS class. It is intended to be
530     // called from the Init function in AliITSv?. Besides displaying a banner
531     // indicating that it has been called it initializes the array fIdSens
532     // and sets the default segmentation, response, digit and raw cluster
533     // classes therefore it should be called after a call to CreateGeometry.
534     // Inputs:
535     //      none.
536     // Outputs:
537     //      none.
538     // Return:
539     //      none.
540     Int_t i;
541
542     SetDefaults();
543     // Array of TStrings
544     for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
545 }
546 //______________________________________________________________________
547 void AliITS::SetDefaults(){
548     // sets the default segmentation, response, digit and raw cluster classes.
549     // Inputs:
550     //      none.
551     // Outputs:
552     //      none.
553     // Return:
554     //      none.
555
556     if(fDebug) printf("%s: SetDefaults\n",ClassName());
557
558     AliITSDetType *iDetType;
559
560     //SPD
561     iDetType=DetType(0); 
562     if (!iDetType->GetSegmentationModel()) {
563         AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
564         SetSegmentationModel(0,seg0); 
565     } // end if
566     if (!iDetType->GetResponseModel()) {
567         SetResponseModel(0,new AliITSresponseSPD()); 
568     } // end if
569     // set digit and raw cluster classes to be used
570
571     const char *kData0=(iDetType->GetResponseModel())->DataType();
572     if (strstr(kData0,"real")) {
573         iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
574     } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
575
576     // SDD
577     iDetType=DetType(1); 
578     if (!iDetType->GetResponseModel()) {
579         SetResponseModel(1,new AliITSresponseSDD("simulated")); 
580     } // end if
581     AliITSresponse *resp1=iDetType->GetResponseModel();
582     if (!iDetType->GetSegmentationModel()) {
583         AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
584         SetSegmentationModel(1,seg1); 
585     } // end if
586     const char *kData1=(iDetType->GetResponseModel())->DataType();
587     const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
588     if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
589         iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
590     } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
591
592     // SSD
593     iDetType=DetType(2); 
594     if (!iDetType->GetSegmentationModel()) {
595         AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
596         SetSegmentationModel(2,seg2); 
597     } // end if
598     if (!iDetType->GetResponseModel()) {
599         SetResponseModel(2,new AliITSresponseSSD("simulated"));
600     } // end if
601     const char *kData2=(iDetType->GetResponseModel())->DataType();
602     if (strstr(kData2,"real")) {
603         iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
604     } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
605
606     if (kNTYPES>3) {
607         Warning("SetDefaults",
608                 "Only the three basic detector types are initialized!");
609     }  // end if
610 }
611 //______________________________________________________________________
612 void AliITS::SetDefaultSimulation(){
613     // sets the default simulation.
614     // Inputs:
615     //      none.
616     // Outputs:
617     //      none.
618     // Return:
619     //      none.
620
621     AliITSDetType *iDetType;
622     AliITSsimulation *sim;
623     iDetType=DetType(0);
624     sim = iDetType->GetSimulationModel();
625     if (!sim) {
626         AliITSsegmentation *seg0=
627             (AliITSsegmentation*)iDetType->GetSegmentationModel();
628         AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
629         AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
630         SetSimulationModel(0,sim0);
631     }else{ // simulation exists, make sure it is set up properly.
632         ((AliITSsimulationSPD*)sim)->Init(
633             (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
634             (AliITSresponseSPD*) iDetType->GetResponseModel());
635 //      if(sim->GetResponseModel()==0) sim->SetResponseModel(
636 //          (AliITSresponse*)iDetType->GetResponseModel());
637 //      if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
638 //          (AliITSsegmentation*)iDetType->GetSegmentationModel());
639     } // end if
640     iDetType=DetType(1);
641     sim = iDetType->GetSimulationModel();
642     if (!sim) {
643         AliITSsegmentation *seg1=
644             (AliITSsegmentation*)iDetType->GetSegmentationModel();
645         AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
646         AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
647         SetSimulationModel(1,sim1);
648     }else{ // simulation exists, make sure it is set up properly.
649         ((AliITSsimulationSDD*)sim)->Init(
650             (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
651             (AliITSresponseSDD*) iDetType->GetResponseModel());
652 //      if(sim->GetResponseModel()==0) sim->SetResponseModel(
653 //          (AliITSresponse*)iDetType->GetResponseModel());
654 //      if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
655 //          (AliITSsegmentation*)iDetType->GetSegmentationModel());
656     } //end if
657     iDetType=DetType(2);
658     sim = iDetType->GetSimulationModel();
659     if (!sim) {
660         AliITSsegmentation *seg2=
661             (AliITSsegmentation*)iDetType->GetSegmentationModel();
662         AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
663         AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
664         SetSimulationModel(2,sim2);
665     }else{ // simulation exists, make sure it is set up properly.
666         ((AliITSsimulationSSD*)sim)->Init(
667             (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
668             (AliITSresponseSSD*) iDetType->GetResponseModel());
669 //      if(sim->GetResponseModel()==0) sim->SetResponseModel(
670 //          (AliITSresponse*)iDetType->GetResponseModel());
671 //      if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
672 //          (AliITSsegmentation*)iDetType->GetSegmentationModel());
673     } // end if
674 }
675 //______________________________________________________________________
676 void AliITS::SetDefaultClusterFinders(){
677     // Sets the default cluster finders. Used in finding RecPoints.
678     // Inputs:
679     //      none.
680     // Outputs:
681     //      none.
682     // Return:
683     //      none.
684
685     MakeTreeC();
686     AliITSDetType *iDetType;
687
688     // SPD
689     iDetType=DetType(0);
690     if (!iDetType->GetReconstructionModel()) {
691         AliITSsegmentation *seg0 =
692             (AliITSsegmentation*)iDetType->GetSegmentationModel();
693         TClonesArray *dig0=DigitsAddress(0);
694         TClonesArray *recp0=ClustersAddress(0);
695         AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
696                                                                   recp0);
697         SetReconstructionModel(0,rec0);
698     } // end if
699
700     // SDD
701     iDetType=DetType(1);
702     if (!iDetType->GetReconstructionModel()) {
703         AliITSsegmentation *seg1 =
704             (AliITSsegmentation*)iDetType->GetSegmentationModel();
705         AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
706         TClonesArray *dig1=DigitsAddress(1);
707         TClonesArray *recp1=ClustersAddress(1);
708         AliITSClusterFinderSDD *rec1 =
709             new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
710       SetReconstructionModel(1,rec1);
711     } // end if
712
713     // SSD
714     iDetType=DetType(2);
715     if (!iDetType->GetReconstructionModel()) {
716         AliITSsegmentation *seg2=
717             (AliITSsegmentation*)iDetType->GetSegmentationModel();
718         TClonesArray *dig2=DigitsAddress(2);
719         AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
720         SetReconstructionModel(2,rec2);
721     } // end if
722 }
723 //______________________________________________________________________
724 void AliITS::MakeBranch(Option_t* option, const char *file){
725     // Creates Tree branches for the ITS.
726     // Inputs:
727     //      Option_t *option    String of Tree types S,D, and/or R.
728     //      const char *file    String of the file name where these branches
729     //                          are to be stored. If blank then these branches
730     //                          are written to the same tree as the Hits were
731     //                          read from.
732     // Outputs:
733     //      none.
734     // Return:
735     //      none.
736     Bool_t cS = (strstr(option,"S")!=0);
737     Bool_t cD = (strstr(option,"D")!=0);
738     Bool_t cR = (strstr(option,"R")!=0);
739     Bool_t cRF = (strstr(option,"RF")!=0);
740     if(cRF)cR = kFALSE;
741
742     AliDetector::MakeBranch(option,file);
743
744     if(cS) MakeBranchS(file);
745     if(cD) MakeBranchD(file);
746     if(cR) MakeBranchR(file);
747     if(cRF) MakeBranchRF(file);
748 }
749 //______________________________________________________________________
750 void AliITS::SetTreeAddress(){
751     // Set branch address for the Trees.
752     // Inputs:
753     //      none.
754     // Outputs:
755     //      none.
756     // Return:
757     //      none.
758     TTree *treeS = gAlice->TreeS();
759     TTree *treeD = gAlice->TreeD();
760     TTree *treeR = gAlice->TreeR();
761
762     AliDetector::SetTreeAddress();
763
764     SetTreeAddressS(treeS);
765     SetTreeAddressD(treeD);
766     SetTreeAddressR(treeR);
767 }
768 //______________________________________________________________________
769 AliITSDetType* AliITS::DetType(Int_t id){
770     // Return pointer to id detector type.
771     // Inputs:
772     //      Int_t id   detector id number.
773     // Outputs:
774     //      none.
775     // Return:
776     //      returned, a pointer to a AliITSDetType.
777
778     return ((AliITSDetType*) fDetTypes->At(id));
779 }
780 //______________________________________________________________________
781 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
782     // Set the response model for the id detector type.
783     // Inputs:
784     //      Int_t id        detector id number.
785     //      AliITSresponse* a pointer containing an instance of AliITSresponse
786     //                      to be stored/owned b y AliITSDetType.
787     // Outputs:
788     //      none.
789     // Return:
790     //      none.
791
792     ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
793 }
794 //______________________________________________________________________
795 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
796     // Set the segmentation model for the id detector type.
797     // Inputs:
798     //      Int_t id            detector id number.
799     //      AliITSsegmentation* a pointer containing an instance of 
800     //                          AliITSsegmentation to be stored/owned b y 
801     //                          AliITSDetType.
802     // Outputs:
803     //      none.
804     // Return:
805     //      none.
806
807     ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
808 }
809 //______________________________________________________________________
810 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
811     // Set the simulation model for the id detector type.
812     // Inputs:
813     //      Int_t id        detector id number.
814     //      AliITSresponse* a pointer containing an instance of AliITSresponse
815     //                      to be stored/owned b y AliITSDetType.
816     // Outputs:
817     //      none.
818     // Return:
819     //      none.
820
821    ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
822
823 }
824 //______________________________________________________________________
825 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
826     // Set the cluster finder model for the id detector type.
827     // Inputs:
828     //      Int_t id             detector id number.
829     //      AliITSClusterFinder* a pointer containing an instance of 
830     //                           AliITSClusterFinder to be stored/owned b y 
831     //                           AliITSDetType.
832     // Outputs:
833     //      none.
834     // Return:
835     //      none.
836
837     ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
838 }
839 //______________________________________________________________________
840 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
841     // Set the digit and cluster classes name to be used for the id detector
842     // type.
843     // Inputs:
844     //      Int_t id            detector id number.
845     //      const char *digit   Digit class name for detector id.
846     //      const char *cluster Cluster class name for detector id.
847     // Outputs:
848     //      none.
849     // Return:
850     //      none.
851
852     ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
853 }
854 //______________________________________________________________________
855 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
856     // Add an ITS hit
857     //     The function to add information to the AliITShit class. See the
858     // AliITShit class for a full description. This function allocates the
859     // necessary new space for the hit information and passes the variable
860     // track, and the pointers *vol and *hits to the AliITShit constructor
861     // function.
862     // Inputs:
863     //      Int_t   track   Track number which produced this hit.
864     //      Int_t   *vol    Array of Integer Hit information. See AliITShit.h
865     //      Float_t *hits   Array of Floating Hit information.  see AliITShit.h
866     // Outputs:
867     //      none.
868     // Return:
869     //      none.
870
871     TClonesArray &lhits = *fHits;
872     new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
873 }
874 //______________________________________________________________________
875 void AliITS::InitModules(Int_t size,Int_t &nmodules){
876     // Initialize the modules array.
877     // Inputs:
878     //      Int_t size  Size of array of the number of modules to be
879     //                  created. If size <=0 then the number of modules
880     //                  is gotten from AliITSgeom class kept in fITSgeom.
881     // Outputs:
882     //      Int_t &nmodules The number of modules existing.
883     // Return:
884     //      none.
885
886     if(fITSmodules){ 
887         fITSmodules->Delete();
888         delete fITSmodules;
889     } // end fir fITSmoudles
890
891     Int_t nl,indexMAX,index;
892
893     if(size<=0){ // default to using data stored in AliITSgeom
894         if(fITSgeom==0) {
895             Error("InitModules","fITSgeom not defined");
896             return;
897         } // end if fITSgeom==0
898         nl = fITSgeom->GetNlayers();
899         indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
900                                             fITSgeom->GetNdetectors(nl))+1;
901         nmodules = indexMAX;
902         fITSmodules = new TObjArray(indexMAX);
903         for(index=0;index<indexMAX;index++){
904             fITSmodules->AddAt( new AliITSmodule(index),index);
905         } // end for index
906     }else{
907         fITSmodules = new TObjArray(size);
908         for(index=0;index<size;index++) {
909             fITSmodules->AddAt( new AliITSmodule(index),index);
910         } // end for index
911
912         nmodules = size;
913     } // end i size<=0
914 }
915 //______________________________________________________________________
916 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
917                          Option_t *option,Text_t *filename){
918     // fill the modules with the sorted by module hits; add hits from
919     // background if option=Add.
920     // Inputs:
921     //      Int_t evnt       Event to be processed.
922     //      Int_t bgrev      Background Hit tree number.
923     //      Int_t nmodules   Not used.
924     //      Option_t *option String indicating if merging hits or not. To
925     //                       merge hits set equal to "Add". Otherwise no
926     //                       background hits are considered.
927     //      Test_t *filename File name containing the background hits..
928     // Outputs:
929     //      none.
930     // Return:
931     //      none.
932     static TTree *trH1;                 //Tree with background hits
933 //    static TClonesArray *fHits2;        //List of hits for one track only
934     static Bool_t first=kTRUE;
935     static TFile *file;
936     const char *addBgr = strstr(option,"Add");
937
938     if (addBgr ) {
939         if(first) {
940             file=new TFile(filename);
941 //          fHits2     = new TClonesArray("AliITShit",1000  );
942         } // end if first
943         first=kFALSE;
944         file->cd();
945         file->ls();
946         // Get Hits Tree header from file
947 //      if(fHits2) fHits2->Clear();
948         if(trH1) delete trH1;
949         trH1=0;
950
951         char treeName[20];
952         sprintf(treeName,"TreeH%d",bgrev);
953         trH1 = (TTree*)gDirectory->Get(treeName);
954         if (!trH1) {
955             Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
956         } // end if !trH1
957         // Set branch addresses
958 /*
959         TBranch *branch;
960         char branchname[20];
961         sprintf(branchname,"%s",GetName());
962         if (trH1 && fHits2) {
963             branch = trH1->GetBranch(branchname);
964             if (branch) branch->SetAddress(&fHits2);
965         } // end if trH1 && fHits
966 */
967     } // end if addBgr
968
969     FillModules(gAlice->TreeH(),0); // fill from this file's tree.
970 /*
971     TClonesArray *itsHits = this->Hits();
972     Int_t lay,lad,det,index;
973     AliITShit *itsHit=0;
974     AliITSmodule *mod=0;
975     TTree *iTH = gAlice->TreeH();
976     Int_t ntracks =(Int_t) iTH->GetEntries();
977     Int_t t,h;
978     for(t=0; t<ntracks; t++){
979         gAlice->ResetHits();
980         iTH->GetEvent(t);
981         Int_t nhits = itsHits->GetEntriesFast();
982         if (!nhits) continue;
983         for(h=0; h<nhits; h++){
984             itsHit = (AliITShit *)itsHits->UncheckedAt(h);
985             itsHit->GetDetectorID(lay,lad,det);
986             // temporarily index=det-1 !!!
987             if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
988             else index=det-1;
989             //
990             mod = this->GetModule(index);
991             mod->AddHit(itsHit,t,h);
992         } // end loop over hits 
993     } // end loop over tracks
994 */
995     // open the file with background
996     
997     if (addBgr ) {
998         FillModules(trH1,10000000); // Default mask 10M.
999 /*
1000         Int_t track,i;
1001         ntracks =(Int_t)trH1->GetEntries();     
1002         // Loop over tracks
1003         for (track=0; track<ntracks; track++) {
1004             if (fHits2)       fHits2->Clear();
1005             trH1->GetEvent(track);
1006             //   Loop over hits
1007             for(i=0;i<fHits2->GetEntriesFast();++i) {
1008                 itsHit=(AliITShit*) (*fHits2)[i];
1009                 itsHit->GetDetectorID(lay,lad,det);
1010                 // temporarily index=det-1 !!!
1011                 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1012                 else index=det-1;
1013                 //
1014                 mod = this->GetModule(index);
1015                 mod->AddHit(itsHit,track,i);
1016             }  // end loop over hits
1017         } // end loop over tracks
1018 */
1019         TTree *fAli=gAlice->TreeK();
1020         TFile *fileAli=0;
1021         if (fAli) fileAli =fAli->GetCurrentFile();
1022         fileAli->cd();
1023     } // end if add
1024 }
1025 //______________________________________________________________________
1026 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1027     // fill the modules with the sorted by module hits; 
1028     // can be called many times to do a merging
1029     // Inputs:
1030     //      TTree *treeH  The tree containing the hits to be copied into
1031     //                    the modules.
1032     //      Int_t mask    The track number mask to indecate which file
1033     //                    this hits came from.
1034     // Outputs:
1035     //      none.
1036     // Return:
1037     //      none.
1038
1039     Int_t lay,lad,det,index;
1040     AliITShit *itsHit=0;
1041     AliITSmodule *mod=0;
1042     char branchname[20];
1043     sprintf(branchname,"%s",GetName());
1044     TBranch *branch = treeH->GetBranch(branchname);
1045     if (!branch) {
1046         Error("FillModules","%s branch in TreeH not found",branchname);
1047         return;
1048     } // end if !branch
1049     branch->SetAddress(&fHits);
1050     Int_t nTracks =(Int_t) treeH->GetEntries();
1051     Int_t iPrimTrack,h;
1052     for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1053         ResetHits();
1054         Int_t nBytes = treeH->GetEvent(iPrimTrack);
1055         if (nBytes <= 0) continue;
1056         Int_t nHits = fHits->GetEntriesFast();
1057         for(h=0; h<nHits; h++){
1058             itsHit = (AliITShit *)fHits->UncheckedAt(h);
1059             itsHit->GetDetectorID(lay,lad,det);
1060             if (fITSgeom) {
1061                 index = fITSgeom->GetModuleIndex(lay,lad,det);
1062             } else {
1063                 index=det-1; // This should not be used.
1064             } // end if [You must have fITSgeom for this to work!]
1065             mod = GetModule(index);
1066             itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1067             mod->AddHit(itsHit,iPrimTrack,h);
1068         } // end loop over hits 
1069     } // end loop over tracks
1070 }
1071 //______________________________________________________________________
1072 void AliITS::ClearModules(){
1073     // Clear the modules TObjArray.
1074     // Inputs:
1075     //      none.
1076     // Outputs:
1077     //      none.
1078
1079     if(fITSmodules) fITSmodules->Delete();
1080 }
1081 //______________________________________________________________________
1082 void AliITS::MakeBranchS(const char *fl){
1083     // Creates Tree Branch for the ITS summable digits.
1084     // Inputs:
1085     //      cont char *fl  File name where SDigits branch is to be written
1086     //                     to. If blank it write the SDigits to the same
1087     //                     file in which the Hits were found.
1088     // Outputs:
1089     //      none.
1090     // Return:
1091     //      none.
1092     Int_t buffersize = 4000;
1093     char branchname[30];
1094
1095     // only one branch for SDigits.
1096     sprintf(branchname,"%s",GetName());
1097     if(fSDigits && gAlice->TreeS()){
1098         MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1099     } // end if
1100 }
1101 //______________________________________________________________________
1102 void AliITS::SetTreeAddressS(TTree *treeS){
1103     // Set branch address for the ITS summable digits Trees.
1104     // Inputs:
1105     //      TTree *treeS   Tree containing the SDigits.
1106     // Outputs:
1107     //      none.
1108     // Return:
1109     //      none.
1110     char branchname[30];
1111
1112     if(!treeS) return;
1113     TBranch *branch;
1114     sprintf(branchname,"%s",GetName());
1115     branch = treeS->GetBranch(branchname);
1116     if (branch) branch->SetAddress(&fSDigits);
1117 }
1118 //______________________________________________________________________
1119 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1120     // Creates Tree branches for the ITS.
1121     // Inputs:
1122     //      TTree     *treeD Pointer to the Digits Tree.
1123     //      cont char *file  File name where Digits branch is to be written
1124     //                       to. If blank it write the SDigits to the same
1125     //                       file in which the Hits were found.
1126     // Outputs:
1127     //      none.
1128     // Return:
1129     //      none.
1130     Int_t buffersize = 4000;
1131     char branchname[30];
1132
1133     sprintf(branchname,"%s",GetName());
1134     // one branch for digits per type of detector
1135     const char *det[3] = {"SPD","SDD","SSD"};
1136     char digclass[40];
1137     char clclass[40];
1138     Int_t i;
1139     for (i=0; i<kNTYPES ;i++) {
1140         DetType(i)->GetClassNames(digclass,clclass);
1141         // digits
1142         if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1143         else ResetDigits(i);
1144     } // end for i
1145     for (i=0; i<kNTYPES ;i++) {
1146         if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1147         else  sprintf(branchname,"%sDigits%d",GetName(),i+1);      
1148         if (fDtype && treeD) {
1149             MakeBranchInTree(treeD, 
1150                              branchname, &((*fDtype)[i]),buffersize,file);
1151         } // end if
1152     } // end for i
1153 }
1154 //______________________________________________________________________
1155 void AliITS::SetTreeAddressD(TTree *treeD){
1156     // Set branch address for the Trees.
1157     // Inputs:
1158     //      TTree *treeD   Tree containing the Digits.
1159     // Outputs:
1160     //      none.
1161     // Return:
1162     //      none.
1163     char branchname[30];
1164     const char *det[3] = {"SPD","SDD","SSD"};
1165     TBranch *branch;
1166     char digclass[40];
1167     char clclass[40];
1168     Int_t i;
1169
1170     if(!treeD) return;
1171     for (i=0; i<kNTYPES; i++) {
1172         DetType(i)->GetClassNames(digclass,clclass);
1173         // digits
1174         if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1175         else ResetDigits(i);
1176         if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1177         else  sprintf(branchname,"%sDigits%d",GetName(),i+1);
1178         if (fDtype) {
1179             branch = treeD->GetBranch(branchname);
1180             if (branch) branch->SetAddress(&((*fDtype)[i]));
1181         } // end if fDtype
1182     } // end for i
1183 }
1184 //______________________________________________________________________
1185 void AliITS::Hits2SDigits(){
1186     // Standard Hits to summable Digits function.
1187     // Inputs:
1188     //      none.
1189     // Outputs:
1190     //      none.
1191
1192 //    return; // Using Hits in place of the larger sDigits.
1193     AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1194     // Do the Hits to Digits operation. Use Standard input values.
1195     // Event number from file, no background hit merging , use size from
1196     // AliITSgeom class, option="All", input from this file only.
1197     HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1198 }
1199 //______________________________________________________________________
1200 void AliITS::Hits2PreDigits(){
1201     // Standard Hits to summable Digits function.
1202     // Inputs:
1203     //      none.
1204     // Outputs:
1205     //      none.
1206
1207     AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1208     // Do the Hits to Digits operation. Use Standard input values.
1209     // Event number from file, no background hit merging , use size from
1210     // AliITSgeom class, option="All", input from this file only.
1211     HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1212 }
1213 //______________________________________________________________________
1214 void AliITS::SDigitsToDigits(Option_t *opt){
1215     // Standard Summable digits to Digits function.
1216     // Inputs:
1217     //      none.
1218     // Outputs:
1219     //      none.
1220     char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1221
1222     if(!GetITSgeom()) return; // need transformations to do digitization.
1223     AliITSgeom *geom = GetITSgeom();
1224
1225     const char *all = strstr(opt,"All");
1226     const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1227                           strstr(opt,"SSD")};
1228     if( !det[0] && !det[1] && !det[2] ) all = "All";
1229     else all = 0;
1230     static Bool_t setDef=kTRUE;
1231     if (setDef) SetDefaultSimulation();
1232     setDef=kFALSE;
1233
1234     AliITSsimulation *sim      = 0;
1235     AliITSDetType    *iDetType = 0;
1236     TTree            *trees    = gAlice->TreeS();
1237     if( !(trees && this->GetSDigits()) ){
1238         Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1239         return;
1240     } // end if
1241     sprintf( name, "%s", this->GetName() );
1242     TBranch *brchSDigits = trees->GetBranch( name );
1243     
1244     Int_t id,module;
1245     for(module=0;module<geom->GetIndexMax();module++){
1246         id       = geom->GetModuleType(module);
1247         if (!all && !det[id]) continue;
1248         iDetType = DetType(id);
1249         sim      = (AliITSsimulation*)iDetType->GetSimulationModel();
1250         if (!sim) {
1251             Error("SDigit2Digits",
1252                   "The simulation class was not instanciated!");
1253             exit(1);
1254         } // end if !sim
1255         sim->InitSimulationModule(module,gAlice->GetEvNumber());
1256 //
1257         // add summable digits to module
1258         this->GetSDigits()->Clear();
1259         brchSDigits->GetEvent(module);
1260         sim->AddSDigitsToModule(GetSDigits(),0);
1261 //
1262         // Digitise current module sum(SDigits)->Digits
1263         sim->FinishSDigitiseModule();
1264
1265         // fills all branches - wasted disk space
1266         gAlice->TreeD()->Fill();
1267         this->ResetDigits();
1268     } // end for module
1269
1270     gAlice->TreeD()->GetEntries();
1271
1272     gAlice->TreeD()->AutoSave();
1273     // reset tree
1274     gAlice->TreeD()->Reset();
1275     
1276 }
1277 //______________________________________________________________________
1278 void AliITS::Hits2Digits(){
1279     // Standard Hits to Digits function.
1280     // Inputs:
1281     //      none.
1282     // Outputs:
1283     //      none.
1284
1285     AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1286     // Do the Hits to Digits operation. Use Standard input values.
1287     // Event number from file, no background hit merging , use size from
1288     // AliITSgeom class, option="All", input from this file only.
1289     HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1290 }
1291 //______________________________________________________________________
1292 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1293                           Option_t *option, Option_t *opt,Text_t *filename){
1294     // keep galice.root for signal and name differently the file for 
1295     // background when add! otherwise the track info for signal will be lost !
1296     // the condition below will disappear when the geom class will be
1297     // initialized for all versions - for the moment it is only for v5 !
1298     // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1299     // Digits.
1300     // Inputs:
1301     //      Int_t evnt       Event to be processed.
1302     //      Int_t bgrev      Background Hit tree number.
1303     //      Int_t nmodules   Not used.
1304     //      Option_t *option String indicating if merging hits or not. To
1305     //                       merge hits set equal to "Add". Otherwise no
1306     //                       background hits are considered.
1307     //      Test_t *filename File name containing the background hits..
1308     // Outputs:
1309     //      none.
1310     // Return:
1311     //      none.
1312 //    return; // using Hits instead of the larger sdigits.
1313
1314     HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1315 }
1316 //______________________________________________________________________
1317 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1318                           Option_t *option, Option_t *opt,Text_t *filename){
1319     //   Keep galice.root for signal and name differently the file for 
1320     // background when add! otherwise the track info for signal will be lost !
1321     // the condition below will disappear when the geom class will be
1322     // initialized for all versions - for the moment it is only for v5 !
1323     // 7 is the SDD beam test version.
1324     // Inputs:
1325     //      Int_t evnt       Event to be processed.
1326     //      Int_t bgrev      Background Hit tree number.
1327     //      Int_t nmodules   Not used.
1328     //      Option_t *option String indicating if merging hits or not. To
1329     //                       merge hits set equal to "Add". Otherwise no
1330     //                       background hits are considered.
1331     //      Test_t *filename File name containing the background hits..
1332     // Outputs:
1333     //      none.
1334     // Return:
1335     //      none.
1336
1337     if(!GetITSgeom()) return; // need transformations to do digitization.
1338     AliITSgeom *geom = GetITSgeom();
1339
1340     const char *all = strstr(opt,"All");
1341     const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1342                           strstr(opt,"SSD")};
1343     static Bool_t setDef=kTRUE;
1344     if (setDef) SetDefaultSimulation();
1345     setDef=kFALSE;
1346
1347     Int_t nmodules;
1348     InitModules(size,nmodules);
1349     FillModules(evNumber,bgrev,nmodules,option,filename);
1350
1351     AliITSsimulation *sim      = 0;
1352     AliITSDetType    *iDetType = 0;
1353     AliITSmodule     *mod      = 0;
1354     Int_t id,module;
1355     for(module=0;module<geom->GetIndexMax();module++){
1356         id       = geom->GetModuleType(module);
1357         if (!all && !det[id]) continue;
1358         iDetType = DetType(id);
1359         sim      = (AliITSsimulation*)iDetType->GetSimulationModel();
1360         if (!sim) {
1361             Error("HitsToSDigits",
1362                   "The simulation class was not instanciated!");
1363             exit(1);
1364         } // end if !sim
1365         mod      = (AliITSmodule *)fITSmodules->At(module);
1366         sim->SDigitiseModule(mod,module,evNumber);
1367         // fills all branches - wasted disk space
1368         gAlice->TreeS()->Fill(); 
1369         ResetSDigits();
1370     } // end for module
1371
1372     ClearModules();
1373
1374     gAlice->TreeS()->GetEntries();
1375     gAlice->TreeS()->AutoSave();
1376     // reset tree
1377     gAlice->TreeS()->Reset();
1378 }
1379 //______________________________________________________________________
1380 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1381                           Option_t *option, Option_t *opt,Text_t *filename){
1382     //   Keep galice.root for signal and name differently the file for 
1383     // background when add! otherwise the track info for signal will be lost !
1384     // the condition below will disappear when the geom class will be
1385     // initialized for all versions - for the moment it is only for v5 !
1386     // 7 is the SDD beam test version.
1387     // Inputs:
1388     //      Int_t evnt       Event to be processed.
1389     //      Int_t bgrev      Background Hit tree number.
1390     //      Int_t nmodules   Not used.
1391     //      Option_t *option String indicating if merging hits or not. To
1392     //                       merge hits set equal to "Add". Otherwise no
1393     //                       background hits are considered.
1394     //      Test_t *filename File name containing the background hits..
1395     // Outputs:
1396     //      none.
1397     // Return:
1398     //      none.
1399
1400     if(!GetITSgeom()) return; // need transformations to do digitization.
1401     AliITSgeom *geom = GetITSgeom();
1402
1403     const char *all = strstr(opt,"All");
1404     const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1405                           strstr(opt,"SSD")};
1406     static Bool_t setDef=kTRUE;
1407     if (setDef) SetDefaultSimulation();
1408     setDef=kFALSE;
1409
1410     Int_t nmodules;
1411     InitModules(size,nmodules);
1412     FillModules(evNumber,bgrev,nmodules,option,filename);
1413
1414     AliITSsimulation *sim      = 0;
1415     AliITSDetType    *iDetType = 0;
1416     AliITSmodule     *mod      = 0;
1417     Int_t id,module;
1418     for(module=0;module<geom->GetIndexMax();module++){
1419         id       = geom->GetModuleType(module);
1420         if (!all && !det[id]) continue;
1421         iDetType = DetType(id);
1422         sim      = (AliITSsimulation*)iDetType->GetSimulationModel();
1423         if (!sim) {
1424             Error("HitsToDigits",
1425                   "The simulation class was not instanciated!");
1426             exit(1);
1427         } // end if !sim
1428         mod      = (AliITSmodule *)fITSmodules->At(module);
1429         sim->DigitiseModule(mod,module,evNumber);
1430         // fills all branches - wasted disk space
1431         gAlice->TreeD()->Fill(); 
1432         ResetDigits();
1433     } // end for module
1434
1435     ClearModules();
1436
1437     gAlice->TreeD()->GetEntries();
1438     gAlice->TreeD()->AutoSave();
1439     // reset tree
1440     gAlice->TreeD()->Reset();
1441 }
1442 //______________________________________________________________________
1443 void AliITS::ResetSDigits(){
1444     // Reset the Summable Digits array.
1445     // Inputs:
1446     //      none.
1447     // Outputs:
1448     //      none.
1449
1450     if (fSDigits) fSDigits->Clear();
1451     fNSDigits = 0;
1452 }
1453 //______________________________________________________________________
1454 void AliITS::ResetDigits(){
1455     // Reset number of digits and the digits array for the ITS detector.
1456     // Inputs:
1457     //      none.
1458     // Outputs:
1459     //      none.
1460
1461     if (!fDtype) return;
1462
1463     Int_t i;
1464     for (i=0;i<kNTYPES;i++ ) {
1465         if (fDtype->At(i))    ((TClonesArray*)fDtype->At(i))->Clear();
1466         if (fNdtype)  fNdtype[i]=0;
1467     } // end for i
1468 }
1469 //______________________________________________________________________
1470 void AliITS::ResetDigits(Int_t i){
1471     // Reset number of digits and the digits array for this branch.
1472     // Inputs:
1473     //      none.
1474     // Outputs:
1475     //      none.
1476
1477     if (fDtype->At(i))    ((TClonesArray*)fDtype->At(i))->Clear();
1478     if (fNdtype)  fNdtype[i]=0;
1479 }
1480 //______________________________________________________________________
1481 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1482     // Adds the a module full of summable digits to the summable digits tree.
1483     // Inputs:
1484     //      AliITSpListItem &sdig   SDigit to be added to SDigits tree.
1485     // Outputs:
1486     //      none.
1487     // Return:
1488     //      none.
1489
1490     TClonesArray &lsdig = *fSDigits;
1491     new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1492 }
1493 //______________________________________________________________________
1494 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1495     //   Add a real digit - as coming from data.
1496     // Inputs:
1497     //      Int_t id        Detector type number.
1498     //      Int_t *digits   Integer array containing the digits info. See 
1499     //                      AliITSdigit.h
1500     // Outputs:
1501     //      none.
1502     // Return:
1503     //      none.
1504
1505     TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1506     new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1507 }
1508 //______________________________________________________________________
1509 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1510     //    Add a simulated digit.
1511     // Inputs:
1512     //      Int_t id        Detector type number.
1513     //      AliITSdigit *d  Digit to be added to the Digits Tree. See 
1514     //                      AliITSdigit.h
1515     // Outputs:
1516     //      none.
1517     // Return:
1518     //      none.
1519
1520     TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1521
1522     switch(id){
1523     case 0:
1524         new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1525         break;
1526     case 1:
1527         new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1528         break;
1529     case 2:
1530         new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1531         break;
1532     } // end switch id
1533 }
1534 //______________________________________________________________________
1535 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1536                          Int_t *hits,Float_t *charges){
1537     //   Add a simulated digit to the list.
1538     // Inputs:
1539     //      Int_t id        Detector type number.
1540     //      Float_t phys    Physics indicator. See AliITSdigits.h
1541     //      Int_t *digits   Integer array containing the digits info. See 
1542     //                      AliITSdigit.h
1543     //      Int_t *tracks   Integer array [3] containing the track numbers that
1544     //                      contributed to this digit.
1545     //      Int_t *hits     Integer array [3] containing the hit numbers that
1546     //                      contributed to this digit.
1547     //      Float_t *charge Floating point array of the signals contributed
1548     //                      to this digit by each track.
1549     // Outputs:
1550     //      none.
1551     // Return:
1552     //      none.
1553
1554     TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1555     switch(id){
1556     case 0:
1557         new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1558         break;
1559     case 1:
1560         new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1561                                                    hits,charges);
1562         break;
1563     case 2:
1564         new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1565         break;
1566     } // end switch id
1567 }
1568 //______________________________________________________________________
1569 void AliITS::MakeTreeC(Option_t *option){
1570     //   Create a separate tree to store the clusters.
1571     // Inputs:
1572     //      Option_t *option  string which must contain "C" otherwise
1573     //                        no Cluster Tree is created.
1574     // Outputs:
1575     //      none.
1576     // Return:
1577     //      none.
1578   TDirectory *cwd = gDirectory;
1579   TFile *fileRecPoints = gAlice->GetTreeRFile();
1580   if(fileRecPoints)fileRecPoints->cd();
1581     const char *optC = strstr(option,"C");
1582     char hname[30];
1583     Int_t cureve = gAlice->GetEvNumber();
1584     sprintf(hname,"TreeC%d",cureve);
1585     if(fTreeC){
1586       const char *curname = fTreeC->GetName();
1587       char *exists = strstr(hname,curname);
1588       if(!exists){
1589         delete fTreeC; 
1590         fTreeC=0;
1591       }
1592     }
1593     if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1594     else return;
1595
1596     Int_t buffersize = 4000;
1597     char branchname[30];
1598     const char *det[3] = {"SPD","SDD","SSD"};
1599     char digclass[40];
1600     char clclass[40];
1601
1602     // one branch for Clusters per type of detector
1603     Int_t i;   
1604     for (i=0; i<kNTYPES ;i++) {
1605         AliITSDetType *iDetType=DetType(i); 
1606         iDetType->GetClassNames(digclass,clclass);
1607         // clusters
1608         if(!ClustersAddress(i)){
1609           fCtype->AddAt(new TClonesArray(clclass,1000),i);
1610         }
1611         if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1612         else  sprintf(branchname,"%sClusters%d",GetName(),i+1);
1613         if (fCtype   && fTreeC) {
1614             TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1615         } // end if fCtype && fTreeC
1616     } // end for i
1617     cwd->cd();
1618 }
1619 //______________________________________________________________________
1620 void AliITS::GetTreeC(Int_t event){
1621     //    Get the clusters tree for this event and set the branch address.
1622     // Inputs:
1623     //      Int_t event    Event number for the cluster tree.
1624     // Outputs:
1625     //      none.
1626     // Return:
1627     //      none.
1628     char treeName[20];
1629     char branchname[30];
1630     const char *det[3] = {"SPD","SDD","SSD"};
1631
1632     ResetClusters();
1633     if (fTreeC) {
1634         delete fTreeC;
1635     } // end if fTreeC
1636
1637     sprintf(treeName,"TreeC%d",event);
1638     TFile *fileRecPoints = gAlice->GetTreeRFile();
1639     if(!fileRecPoints){
1640       fTreeC = (TTree*)gDirectory->Get(treeName);
1641     }
1642     else {
1643       fTreeC = (TTree*)fileRecPoints->Get(treeName);
1644     }
1645
1646     TBranch *branch;
1647
1648     if (fTreeC) {
1649         Int_t i;
1650         char digclass[40];
1651         char clclass[40];
1652         for (i=0; i<kNTYPES; i++) {
1653             AliITSDetType *iDetType=DetType(i); 
1654             iDetType->GetClassNames(digclass,clclass);
1655             // clusters
1656             if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1657             if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1658             else  sprintf(branchname,"%sClusters%d",GetName(),i+1);
1659             if (fCtype) {
1660                 branch = fTreeC->GetBranch(branchname);
1661                 if (branch) branch->SetAddress(&((*fCtype)[i]));
1662             } // end if fCtype
1663         } // end for i
1664     } else {
1665         Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1666     } // end if fTreeC
1667 }
1668 //______________________________________________________________________
1669 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1670     //   Add a cluster to the list.
1671     // Inputs:
1672     //      Int_t id             Detector type number.
1673     //      AliITSRawCluster *c  Cluster class to be added to the tree of
1674     //                           clusters.
1675     // Outputs:
1676     //      none.
1677     // Return:
1678     //      none.
1679
1680     TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1681
1682     switch(id){
1683     case 0:
1684         new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1685         break;
1686     case 1:
1687         new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1688         break;
1689     case 2:
1690         new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1691         break;
1692     } // end switch id
1693 }
1694 //______________________________________________________________________
1695 void AliITS::ResetClusters(){
1696     // Reset number of clusters and the clusters array for ITS.
1697     // Inputs:
1698     //      none.
1699     // Outputs:
1700     //      none.
1701
1702     Int_t i;
1703     for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1704 }
1705 //______________________________________________________________________
1706 void AliITS::ResetClusters(Int_t i){
1707     //    Reset number of clusters and the clusters array for this branch.
1708     // Inputs:
1709     //      Int_t i        Detector type number.
1710     // Outputs:
1711     //      none.
1712     // Return:
1713     //      none.
1714
1715     if (fCtype->At(i))    ((TClonesArray*)fCtype->At(i))->Clear();
1716     if (fNctype)  fNctype[i]=0;
1717 }
1718 //______________________________________________________________________
1719 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1720     // Creates Tree branches for the ITS Reconstructed points.
1721     // Inputs:
1722     //      cont char *file  File name where RecPoints branch is to be written
1723     //                       to. If blank it write the SDigits to the same
1724     //                       file in which the Hits were found.
1725     // Outputs:
1726     //      none.
1727     // Return:
1728     //      none.
1729     Int_t buffsz = 4000;
1730     char branchname[30];
1731
1732     // only one branch for rec points for all detector types
1733     Bool_t oFast= (strstr(opt,"Fast")!=0);
1734     if(oFast){
1735       sprintf(branchname,"%sRecPointsF",GetName());
1736     } else {
1737       sprintf(branchname,"%sRecPoints",GetName());
1738     }
1739     if (fRecPoints && gAlice->TreeR()) {
1740         MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1741     } // end if
1742 }
1743 //______________________________________________________________________
1744 void AliITS::SetTreeAddressR(TTree *treeR){
1745     // Set branch address for the Reconstructed points Trees.
1746     // Inputs:
1747     //      TTree *treeR   Tree containing the RecPoints.
1748     // Outputs:
1749     //      none.
1750     // Return:
1751     //      none.
1752     char branchname[30];
1753
1754     if(!treeR) return;
1755     TBranch *branch;
1756     sprintf(branchname,"%sRecPoints",GetName());
1757     branch = treeR->GetBranch(branchname);
1758     if (branch) {
1759       branch->SetAddress(&fRecPoints);
1760     }
1761     else {
1762       sprintf(branchname,"%sRecPointsF",GetName());
1763       branch = treeR->GetBranch(branchname);
1764       if (branch) {
1765         branch->SetAddress(&fRecPoints);
1766       }
1767     }
1768 }
1769 //______________________________________________________________________
1770 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1771     // Add a reconstructed space point to the list
1772     // Inputs:
1773     //      const AliITSRecPoint &r RecPoint class to be added to the tree
1774     //                              of reconstructed points TreeR.
1775     // Outputs:
1776     //      none.
1777     // Return:
1778     //      none.
1779
1780     TClonesArray &lrecp = *fRecPoints;
1781     new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1782 }
1783 //______________________________________________________________________
1784 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1785                                  Option_t *opt0,Option_t *opt1,Text_t *flnm){
1786     // keep galice.root for signal and name differently the file for 
1787     // background when add! otherwise the track info for signal will be lost !
1788     // the condition below will disappear when the geom class will be
1789     // initialized for all versions - for the moment it is only for v5 !
1790     // Inputs:
1791     //      Int_t evnt       Event to be processed.
1792     //      Int_t bgrev      Background Hit tree number.
1793     //      Int_t size       Size used by InitModules. See InitModules.
1794     //      Option_t *opt0   Option passed to FillModules. See FillModules.
1795     //      Option_t *opt1   String indicating if merging hits or not. To
1796     //                       merge hits set equal to "Add". Otherwise no
1797     //                       background hits are considered.
1798     //      Test_t *flnm     File name containing the background hits..
1799     // Outputs:
1800     //      none.
1801     // Return:
1802     //      none.
1803
1804     if(!GetITSgeom()) return;
1805     AliITSgeom *geom = GetITSgeom();
1806
1807     const char *all = strstr(opt1,"All");
1808     const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1809                          strstr(opt1,"SSD")};
1810     Int_t nmodules;
1811     InitModules(size,nmodules);
1812     FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1813
1814     AliITSsimulation *sim      = 0;
1815     AliITSDetType    *iDetType = 0;
1816     AliITSmodule     *mod      = 0;
1817     Int_t id,module;
1818
1819     //m.b. : this change is nothing but a nice way to make sure
1820     //the CPU goes up !
1821     for(module=0;module<geom->GetIndexMax();module++){
1822         id       = geom->GetModuleType(module);
1823         if (!all && !det[id]) continue;
1824         iDetType = DetType(id);
1825         sim      = (AliITSsimulation*)iDetType->GetSimulationModel();
1826         if (!sim) {
1827             Error("HitsToFastPoints",
1828                   "The simulation class was not instanciated!");
1829             exit(1);
1830         } // end if !sim
1831         mod      = (AliITSmodule *)fITSmodules->At(module);
1832         sim->CreateFastRecPoints(mod,module,gRandom);
1833     //  gAlice->TreeR()->Fill(); 
1834     TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1835     br->Fill();
1836         ResetRecPoints();
1837     } // end for module
1838
1839     ClearModules();
1840
1841     gAlice->TreeR()->AutoSave();
1842     // reset tree
1843     gAlice->TreeR()->Reset();
1844 }
1845 //______________________________________________________________________
1846 void AliITS::Digits2Reco(){
1847     // Find clusters and reconstruct space points.
1848     // Inputs:
1849     //      none.
1850     // Outputs:
1851     //      none.
1852
1853     AliHeader *header=gAlice->GetHeader();
1854     // to Digits to RecPoints for event in file, all digits in file, and
1855     // all ITS detectors.
1856     DigitsToRecPoints(header->GetEvent(),0,fOpt);
1857 }
1858 //______________________________________________________________________
1859 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1860     // cluster finding and reconstruction of space points
1861     // the condition below will disappear when the geom class will be
1862     // initialized for all versions - for the moment it is only for v5 !
1863     // 7 is the SDD beam test version
1864     // Inputs:
1865     //      Int_t evNumber   Event number to be processed.
1866     //      Int_t lastentry  Offset for module when not all of the modules
1867     //                       are processed.
1868     //      Option_t *opt    String indicating which ITS sub-detectors should
1869     //                       be processed. If ="All" then all of the ITS
1870     //                       sub detectors are processed.
1871     // Outputs:
1872     //      none.
1873     // Return:
1874     //      none.
1875
1876     if(!GetITSgeom()) return;
1877     AliITSgeom *geom = GetITSgeom();
1878     
1879     const char *all = strstr(opt,"All");
1880     const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1881                           strstr(opt,"SSD")};
1882     static Bool_t setRec=kTRUE;
1883     if (setRec) SetDefaultClusterFinders();
1884     setRec=kFALSE;
1885
1886     TTree *treeC=TreeC();
1887     AliITSClusterFinder *rec     = 0;
1888     AliITSDetType      *iDetType = 0;
1889     Int_t id,module,first=0;
1890     for(module=0;module<geom->GetIndexMax();module++){
1891         id       = geom->GetModuleType(module);
1892         if (!all && !det[id]) continue;
1893         if(det[id]) first = geom->GetStartDet(id);
1894         iDetType = DetType(id);
1895         rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1896         TClonesArray *itsDigits  = this->DigitsAddress(id);
1897         if (!rec) {
1898             Error("DigitsToRecPoints",
1899                   "The reconstruction class was not instanciated!");
1900             exit(1);
1901         } // end if !rec
1902         this->ResetDigits();
1903         if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1904         else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1905         Int_t ndigits = itsDigits->GetEntriesFast();
1906         if (ndigits) rec->FindRawClusters(module);
1907     gAlice->TreeR()->Fill(); 
1908         ResetRecPoints();
1909         treeC->Fill();
1910         ResetClusters();
1911     } // end for module
1912
1913     gAlice->TreeR()->GetEntries();
1914     treeC->GetEntries();
1915     gAlice->TreeR()->AutoSave();
1916     // reset tree
1917     gAlice->TreeR()->Reset();
1918
1919     treeC->AutoSave();
1920     treeC->Reset();
1921 }
1922 //______________________________________________________________________
1923 void AliITS::ResetRecPoints(){
1924     // Reset number of rec points and the rec points array.
1925     // Inputs:
1926     //      none.
1927     // Outputs:
1928     //      none.
1929
1930     if (fRecPoints) fRecPoints->Clear();
1931     fNRecPoints = 0;
1932 }