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