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