]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITS.cxx
Correct HitsToFastRecPoints
[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$
e3b819ce 18Revision 1.60 2001/10/04 22:38:10 nilsen
19Changes made to support PreDigits (SDigits) plus other helpful changes.
20
2aea926d 21Revision 1.59 2001/08/30 09:56:18 hristov
22The operator[] is replaced by At() or AddAt() in case of TObjArray.
23
2682e810 24Revision 1.58 2001/07/26 15:05:29 hristov
25Use global gRandom generator (M.Ivanov)
26
63147407 27Revision 1.57 2001/07/24 14:26:11 mariana
28Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
29
828e06c7 30Revision 1.56 2001/07/05 12:49:49 mariana
31Temporary patches required by root.v3.01.05
32
cb26748d 33Revision 1.55 2001/06/14 14:59:00 barbera
34Tracking V1 decoupled from AliITS
35
27a043b1 36Revision 1.54 2001/05/31 20:37:56 barbera
37Bari/Salerno model set as defaault SPD simulation
38
21b825a4 39Revision 1.53 2001/05/31 18:52:24 barbera
40Bari model becomes the default
41
42Revision 1.53 2001/05/30 07:52:24 hristov
43TPC and CONTAINERS included in the search path
44
71574c3c 45Revision 1.52 2001/05/30 06:04:58 hristov
46Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
47
1633a7ac 48Revision 1.51 2001/05/16 14:57:15 alibrary
49New files for folders and Stack
50
9e1a0ddb 51Revision 1.50 2001/05/11 09:15:21 barbera
52Corrected to make fast point creation working with PPR geometry
53
34980f24 54Revision 1.49 2001/05/11 07:37:49 hristov
55Legacy lines commented
56
f1d439d9 57Revision 1.48 2001/05/10 18:14:25 barbera
58A typo corrected
59
04f91b7e 60Revision 1.47 2001/05/10 17:55:59 barbera
61Modified to create rec points also for PPR geometries
62
c44604f4 63Revision 1.46 2001/05/10 00:05:28 nilsen
64Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
65should probably be cleaned up to only check to make sure that fITSgeom has
66been properly defined.
67
72de14c6 68Revision 1.45 2001/05/01 22:35:48 nilsen
69Remove/commented a number of cout<< statements. and made change needed by
70SSD code.
71
a3ec5900 72Revision 1.44 2001/04/26 22:44:01 nilsen
73Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
74done properly in AliITSv???.cxx via SetDefaults.
75
686b2f43 76Revision 1.43 2001/04/26 13:22:52 barbera
77TMatrix and TVector elimininated to speed up the code
78
53e7090a 79Revision 1.42 2001/04/25 21:55:12 barbera
80Updated version to be compatible with actual verion of STEER and TPC
81
8ab89103 82Revision 1.41 2001/04/21 15:16:51 barbera
83Updated with the new SSD reconstruction code
84
fd61217e 85Revision 1.40 2001/03/17 15:07:06 mariana
86Update SDD response parameters
87
37de990d 88Revision 1.39 2001/03/12 17:45:32 hristov
89Changes needed on Sun with CC 5.0
90
5cf7bbad 91Revision 1.38 2001/03/07 14:04:51 barbera
92Some vector dimensions increased to cope with full events
93
54fcea18 94Revision 1.37 2001/03/07 12:36:35 barbera
95A change added in the tracking part to manage delta rays
96
4f06a953 97Revision 1.36 2001/03/02 19:44:11 barbera
98 modified to taking into account new version tracking v1
99
8af13b4b 100Revision 1.35 2001/02/28 18:16:46 mariana
101Make the code compatible with the new AliRun
102
340cd0d8 103Revision 1.34 2001/02/11 15:51:39 mariana
104Set protection in MakeBranch
105
c34b4885 106Revision 1.33 2001/02/10 22:26:39 mariana
107Move the initialization of the containers for raw clusters in MakeTreeC()
108
caf37aec 109Revision 1.32 2001/02/08 23:55:31 nilsen
110Removed fMajor/MinorVersion variables in favor of variables in derived classes.
111Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
112
04874c1a 113Revision 1.31 2001/02/02 23:57:28 nilsen
114Added include file that are no londer included in AliITSgeom.h
115
d953664a 116Revision 1.30 2001/01/30 09:23:13 hristov
117Streamers removed (R.Brun)
118
a8a6107b 119Revision 1.29 2001/01/26 20:01:09 hristov
120Major upgrade of AliRoot code
121
2ab0c725 122Revision 1.28 2000/12/18 14:02:00 barbera
123new version of the ITS tracking to take into account the new TPC track parametrization
124
cc6e75dd 125Revision 1.27 2000/12/08 13:49:27 barbera
126Hidden declaration in a for loop removed to be compliant with HP-UX compiler
127
c5b22044 128Revision 1.26 2000/11/27 13:12:13 barbera
129New version containing the files for tracking
130
55b5a0b3 131Revision 1.25 2000/11/12 22:38:05 barbera
132Added header file for the SPD Bari model
133
dfe2a93f 134Revision 1.24 2000/10/09 22:18:12 barbera
135Bug fixes from MAriana to le AliITStest.C run correctly
136
65d4384f 137Revision 1.23 2000/10/05 20:47:42 nilsen
138fixed dependencies of include files. Tryed but failed to get a root automaticly
139generates streamer function to work. Modified SetDefaults.
140
143d1056 141Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
142Needed to include stdlib.h
143
144=======
145Revision 1.22 2000/10/04 19:45:52 barbera
146Corrected by F. Carminati for v3.04
147
114da3a4 148Revision 1.21 2000/10/02 21:28:08 fca
149Removal of useless dependecies via forward declarations
150
94de3818 151Revision 1.20 2000/10/02 16:31:39 barbera
152General code clean-up
153
d5da1ecf 154Revision 1.9.2.14 2000/10/02 15:43:51 barbera
155General code clean-up (e.g., printf -> cout)
156
157Revision 1.19 2000/09/22 12:13:25 nilsen
158Patches and updates for fixes to this and other routines.
159
9c74c52b 160Revision 1.18 2000/07/12 05:32:20 fca
161Correcting several syntax problem with static members
162
b669392e 163Revision 1.17 2000/07/10 16:07:18 fca
164Release version of ITS code
165
3bd79107 166Revision 1.9.2.3 2000/02/02 13:42:09 barbera
167fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
168
169Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
170//fixed FillModule. Removed fi(fabs(xl)<dx....
171
172Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
173This is the version of the files after the merging done in December 1999.
174See the ReadMe110100.txt file for details
c9a71be1 175
1cedd08a 176Revision 1.9 1999/11/14 14:33:25 fca
177Correct problems with distructors and pointers, thanks to I.Hrivnacova
178
6c854497 179Revision 1.8 1999/09/29 09:24:19 fca
180Introduction of the Copyright and cvs Log
181
4c039060 182*/
183
fe4da5cc 184///////////////////////////////////////////////////////////////////////////////
58005f18 185//
186// An overview of the basic philosophy of the ITS code development
187// and analysis is show in the figure below.
fe4da5cc 188//Begin_Html
189/*
a92b2b7d 190<img src="picts/ITS/ITS_Analysis_schema.gif">
fe4da5cc 191</pre>
192<br clear=left>
193<font size=+2 color=red>
58005f18 194<p>Roberto Barbera is in charge of the ITS Offline code (1999).
fe4da5cc 195<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
196</font>
197<pre>
198*/
199//End_Html
58005f18 200//
201// AliITS. Inner Traking System base class.
202// This class contains the base procedures for the Inner Tracking System
203//
204//Begin_Html
205/*
a92b2b7d 206<img src="picts/ITS/AliITS_Class_Diagram.gif">
58005f18 207</pre>
208<br clear=left>
209<font size=+2 color=red>
210<p>This show the class diagram of the different elements that are part of
211the AliITS class.
212</font>
213<pre>
214*/
215//End_Html
216//
217// Version: 0
218// Written by Rene Brun, Federico Carminati, and Roberto Barbera
219//
220// Version: 1
221// Modified and documented by Bjorn S. Nilsen
222// July 11 1999
223//
3bd79107 224// Version: 2
225// Modified and documented by A. Bologna
226// October 18 1999
227//
58005f18 228// AliITS is the general base class for the ITS. Also see AliDetector for
229// futher information.
230//
fe4da5cc 231///////////////////////////////////////////////////////////////////////////////
d953664a 232#include <iostream.h>
233#include <iomanip.h>
234#include <fstream.h>
143d1056 235#include <stdlib.h>
fe4da5cc 236#include <TMath.h>
237#include <TRandom.h>
9c74c52b 238#include <TBranch.h>
fe4da5cc 239#include <TVector.h>
caf37aec 240#include <TClonesArray.h>
3bd79107 241#include <TROOT.h>
242#include <TObjectTable.h>
9c74c52b 243#include <TFile.h>
244#include <TTree.h>
d5da1ecf 245#include <TString.h>
3bd79107 246
828e06c7 247#include "AliMC.h"
fe4da5cc 248#include "AliRun.h"
828e06c7 249#include "AliHeader.h"
250
3bd79107 251#include "AliITS.h"
e8189707 252#include "AliITSDetType.h"
3bd79107 253#include "AliITSresponseSPD.h"
3bd79107 254#include "AliITSresponseSDD.h"
3bd79107 255#include "AliITSresponseSSD.h"
828e06c7 256#include "AliITSsegmentationSPD.h"
257#include "AliITSsegmentationSDD.h"
258#include "AliITSsegmentationSSD.h"
259#include "AliITSsimulationSPD.h"
260#include "AliITSsimulationSDD.h"
261#include "AliITSsimulationSSD.h"
262#include "AliITSClusterFinderSPD.h"
263#include "AliITSClusterFinderSDD.h"
264#include "AliITSClusterFinderSSD.h"
9c74c52b 265#include "AliITShit.h"
266#include "AliITSgeom.h"
2aea926d 267#include "AliITSpList.h"
9c74c52b 268#include "AliITSdigit.h"
269#include "AliITSmodule.h"
270#include "AliITSRecPoint.h"
271#include "AliITSRawCluster.h"
828e06c7 272
3bd79107 273ClassImp(AliITS)
3bd79107 274
2aea926d 275//______________________________________________________________________
276AliITS::AliITS() : AliDetector() {
277 // Default initialiser for ITS
278 // The default constructor of the AliITS class. In addition to
279 // creating the AliITS class it zeros the variables fIshunt (a member
280 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
281 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
282 // is also called.
3bd79107 283
2aea926d 284 fIshunt = 0; // not zeroed in AliDetector.
3bd79107 285
2aea926d 286 // AliITS variables.
287 fEuclidOut = 0;
288 fITSgeom = 0;
289 fITSmodules = 0;
cb26748d 290
2aea926d 291 fIdN = 0;
292 fIdName = 0;
293 fIdSens = 0;
3bd79107 294
2aea926d 295 fNDetTypes = kNTYPES;
296 fDetTypes = 0;
3bd79107 297
2aea926d 298 fSDigits = 0;
299 fNSDigits = 0;
58005f18 300
2aea926d 301 fNdtype = 0;
302 fDtype = 0;
3bd79107 303
2aea926d 304 fCtype = 0;
305 fNctype = 0;
306 fTreeC = 0;
58005f18 307
2aea926d 308 fRecPoints = 0;
309 fNRecPoints = 0;
58005f18 310
2aea926d 311 SetMarkerColor(kRed);
fe4da5cc 312}
2aea926d 313//______________________________________________________________________
314AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
315 // Default initialiser for ITS
316 // The constructor of the AliITS class. In addition to creating the
317 // AliITS class, it allocates memory for the TClonesArrays fHits and
318 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
319 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
320 // the pointers fIdSens and fIdName. To help in displaying hits via the
321 // ROOT macro display.C AliITS also sets the marker color to red. The
322 // variables passes with this constructor, const char *name and *title,
323 // are used by the constructor of AliDetector class. See AliDetector
324 // class for a description of these parameters and its constructor
325 // functions.
326
327 fIshunt = 0; // not zeroed in AliDetector
328 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
329 gAlice->AddHitList(fHits); // Not done in AliDetector.
330
331 fEuclidOut = 0;
332 fITSgeom = 0;
333 fITSmodules = 0;
334
335 fIdN = 0;
336 fIdName = 0;
337 fIdSens = 0;
338
339 fNDetTypes = kNTYPES;
340 fDetTypes = new TObjArray(fNDetTypes);
341
342// fSDigits = new TObjArray(1000);
343 fSDigits = new TClonesArray("AliITSpListItem",1000);
344 fNSDigits = 0;
345
346 fNdtype = new Int_t[fNDetTypes];
347 fDtype = new TObjArray(fNDetTypes);
348
349 fCtype = new TObjArray(fNDetTypes);
350 fNctype = new Int_t[fNDetTypes];
351 fTreeC = 0;
352
353 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
354 fNRecPoints = 0;
3bd79107 355
2aea926d 356 Int_t i;
357 for(i=0;i<fNDetTypes;i++) {
358 fDetTypes->AddAt(new AliITSDetType(),i);
359 fNdtype[i] = 0;
360 fNctype[i] = 0;
361 } // end for i
fe4da5cc 362
2aea926d 363 SetMarkerColor(kRed);
3bd79107 364}
2aea926d 365//______________________________________________________________________
58005f18 366AliITS::~AliITS(){
2aea926d 367 // Default distructor for ITS
368 // The default destructor of the AliITS class. In addition to deleting
369 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
370 // fIdSens, fIdName, and fITSpoints.
371
372 delete fHits;
373 delete fSDigits;
374 delete fDigits;
375 delete fRecPoints;
143d1056 376// delete fIdName; // TObjArray of TObjStrings
2aea926d 377 if(fIdName!=0) delete[] fIdName; // Array of TStrings
378 if(fIdSens!=0) delete[] fIdSens;
379 if(fITSmodules!=0) {
380 this->ClearModules();
381 delete fITSmodules;
382 }// end if fITSmodules!=0
383
384 if(fDtype) {
385 fDtype->Delete();
386 delete fDtype;
387 } // end if fDtype
388 delete [] fNdtype;
389 if (fCtype) {
390 fCtype->Delete();
391 delete fCtype;
392 } // end if fCtype
393 delete [] fNctype;
394
395 if (fDetTypes) {
396 fDetTypes->Delete();
397 delete fDetTypes;
398 } // end if fDetTypes
399
400 if (fTreeC) delete fTreeC;
401
402 if (fITSgeom) delete fITSgeom;
3bd79107 403}
2aea926d 404//______________________________________________________________________
405AliITS::AliITS(AliITS &source){
406 // copy constructor
3bd79107 407
2aea926d 408 if(this==&source) return;
409 Error("AliITS::Copy constructor",
410 "You are not allowed to make a copy of the AliITS");
411 exit(1);
3bd79107 412}
2aea926d 413//______________________________________________________________________
414AliITS& AliITS::operator=(AliITS &source){
415 // assignment operator
3bd79107 416
2aea926d 417 if(this==&source) return *this;
418 Error("AliITS::operator=",
419 "You are not allowed to make a copy of the AliITS");
420 exit(1);
421 return *this; //fake return
3bd79107 422}
2aea926d 423//______________________________________________________________________
424Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
425 // Distance from mouse to ITS on the screen. Dummy routine
426 // A dummy routine used by the ROOT macro display.C to allow for the
427 // use of the mouse (pointing device) in the macro. In general this should
428 // never be called. If it is it returns the number 9999 for any value of
429 // x and y.
3bd79107 430
2aea926d 431 return 9999;
3bd79107 432}
2aea926d 433//______________________________________________________________________
434void AliITS::Init(){
435 // Initialise ITS after it has been built
436 // This routine initializes the AliITS class. It is intended to be
437 // called from the Init function in AliITSv?. Besides displaying a banner
438 // indicating that it has been called it initializes the array fIdSens
439 // and sets the default segmentation, response, digit and raw cluster
440 // classes therefore it should be called after a call to CreateGeometry.
3bd79107 441 Int_t i;
3bd79107 442
2aea926d 443 SetDefaults();
444 // Array of TStrings
445 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
3bd79107 446}
2aea926d 447//______________________________________________________________________
448void AliITS::SetDefaults(){
449 // sets the default segmentation, response, digit and raw cluster classes
450
451 if(fDebug) printf("%s: SetDefaults\n",ClassName());
452
453 AliITSDetType *iDetType;
454
455 //SPD
456 iDetType=DetType(0);
457 if (!iDetType->GetSegmentationModel()) {
458 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
459 SetSegmentationModel(0,seg0);
460 } // end if
461 if (!iDetType->GetResponseModel()) {
462 SetResponseModel(0,new AliITSresponseSPD());
463 } // end if
464 // set digit and raw cluster classes to be used
465
466 const char *kData0=(iDetType->GetResponseModel())->DataType();
467 if (strstr(kData0,"real")) {
468 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
469 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
470
471 // SDD
472 iDetType=DetType(1);
473 if (!iDetType->GetResponseModel()) {
474 SetResponseModel(1,new AliITSresponseSDD());
475 } // end if
476 AliITSresponse *resp1=iDetType->GetResponseModel();
477 if (!iDetType->GetSegmentationModel()) {
478 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
479 SetSegmentationModel(1,seg1);
480 } // end if
481 const char *kData1=(iDetType->GetResponseModel())->DataType();
482 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
483 if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
484 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
485 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
486
487 // SSD
488 iDetType=DetType(2);
489 if (!iDetType->GetSegmentationModel()) {
490 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
491 SetSegmentationModel(2,seg2);
492 } // end if
493 if (!iDetType->GetResponseModel()) {
494 SetResponseModel(2,new AliITSresponseSSD());
495 } // end if
496 const char *kData2=(iDetType->GetResponseModel())->DataType();
497 if (strstr(kData2,"real")) {
498 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
499 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
500
501 if (kNTYPES>3) {
502 Warning("SetDefaults",
503 "Only the three basic detector types are initialised!");
504 } // end if
3bd79107 505}
2aea926d 506//______________________________________________________________________
507void AliITS::SetDefaultSimulation(){
508 // sets the default simulation
509
510 AliITSDetType *iDetType;
511 iDetType=DetType(0);
512 if (!iDetType->GetSimulationModel()) {
513 AliITSsegmentation *seg0=
514 (AliITSsegmentation*)iDetType->GetSegmentationModel();
515 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
516 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
517 SetSimulationModel(0,sim0);
518 } // end if
519 iDetType=DetType(1);
520 if (!iDetType->GetSimulationModel()) {
521 AliITSsegmentation *seg1=
522 (AliITSsegmentation*)iDetType->GetSegmentationModel();
523 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
524 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
525 SetSimulationModel(1,sim1);
526 } //end if
527 iDetType=DetType(2);
528 if (!iDetType->GetSimulationModel()) {
529 AliITSsegmentation *seg2=
530 (AliITSsegmentation*)iDetType->GetSegmentationModel();
531 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
532 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
533 SetSimulationModel(2,sim2);
534 } // end if
3bd79107 535}
2aea926d 536//______________________________________________________________________
537void AliITS::SetDefaultClusterFinders(){
538 // sets the default cluster finders
539
540 MakeTreeC();
541 AliITSDetType *iDetType;
542
543 // SPD
544 iDetType=DetType(0);
545 if (!iDetType->GetReconstructionModel()) {
546 AliITSsegmentation *seg0 =
547 (AliITSsegmentation*)iDetType->GetSegmentationModel();
548 TClonesArray *dig0=DigitsAddress(0);
549 TClonesArray *recp0=ClustersAddress(0);
550 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
551 recp0);
552 SetReconstructionModel(0,rec0);
553 } // end if
554
555 // SDD
556 iDetType=DetType(1);
557 if (!iDetType->GetReconstructionModel()) {
558 AliITSsegmentation *seg1 =
559 (AliITSsegmentation*)iDetType->GetSegmentationModel();
560 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
561 TClonesArray *dig1=DigitsAddress(1);
562 TClonesArray *recp1=ClustersAddress(1);
563 AliITSClusterFinderSDD *rec1 =
564 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
565 SetReconstructionModel(1,rec1);
566 } // end if
567
568 // SSD
569 iDetType=DetType(2);
570 if (!iDetType->GetReconstructionModel()) {
571 AliITSsegmentation *seg2=
572 (AliITSsegmentation*)iDetType->GetSegmentationModel();
573 TClonesArray *dig2=DigitsAddress(2);
574 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
575 SetReconstructionModel(2,rec2);
576 } // end if
3bd79107 577}
2aea926d 578//______________________________________________________________________
579void AliITS::MakeBranch(Option_t* option, const char *file){
580 // Creates Tree branches for the ITS.
581 const char *cS = strstr(option,"S");
582 const char *cD = strstr(option,"D");
583 const char *cR = strstr(option,"R");
584
585 AliDetector::MakeBranch(option,file);
586
587 if(cS) MakeBranchS(file);
588 if(cD) MakeBranchD(file);
589 if(cR) MakeBranchR(file);
fe4da5cc 590}
2aea926d 591//______________________________________________________________________
592void AliITS::SetTreeAddress(){
593 // Set branch address for the Trees.
594 TTree *treeS = gAlice->TreeS();
595 TTree *treeD = gAlice->TreeD();
596 TTree *treeR = gAlice->TreeR();
597
598 AliDetector::SetTreeAddress();
599
600 SetTreeAddressS(treeS);
601 SetTreeAddressD(treeD);
602 SetTreeAddressR(treeR);
fe4da5cc 603}
2aea926d 604//______________________________________________________________________
605AliITSDetType* AliITS::DetType(Int_t id){
606 //return pointer to id detector type
fe4da5cc 607
2aea926d 608 return ((AliITSDetType*) fDetTypes->At(id));
3bd79107 609}
2aea926d 610//______________________________________________________________________
611void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
612 //set the response model for the id detector type
e8189707 613
2aea926d 614 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
e8189707 615}
2aea926d 616//______________________________________________________________________
617void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
618 //set the segmentation model for the id detector type
e8189707 619
2aea926d 620 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
e8189707 621}
2aea926d 622//______________________________________________________________________
623void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
624 //set the simulation model for the id detector type
3bd79107 625
2aea926d 626 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
3bd79107 627
628}
2aea926d 629//______________________________________________________________________
630void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
631 //set the cluster finder model for the id detector type
3bd79107 632
2aea926d 633 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
3bd79107 634}
2aea926d 635//______________________________________________________________________
636void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
637 //set the digit and cluster classes to be used for the id detector type
3bd79107 638
2aea926d 639 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
3bd79107 640}
2aea926d 641//______________________________________________________________________
642void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
643 // Add an ITS hit
644 // The function to add information to the AliITShit class. See the
645 // AliITShit class for a full description. This function allocates the
646 // necessary new space for the hit information and passes the variable
647 // track, and the pointers *vol and *hits to the AliITShit constructor
648 // function.
649
650 TClonesArray &lhits = *fHits;
651 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
3bd79107 652}
2aea926d 653//______________________________________________________________________
3bd79107 654void AliITS::InitModules(Int_t size,Int_t &nmodules){
2aea926d 655 //initialize the modules array
3bd79107 656
2aea926d 657 if(fITSmodules){
658 fITSmodules->Delete();
659 delete fITSmodules;
660 } // end fir fITSmoudles
e8189707 661
3bd79107 662 Int_t nl,indexMAX,index;
3bd79107 663
664 if(size<=0){ // default to using data stored in AliITSgeom
665 if(fITSgeom==0) {
d5da1ecf 666 Error("AliITS::InitModules",
2aea926d 667 "in AliITS::InitModule fITSgeom not defined\n");
3bd79107 668 return;
669 } // end if fITSgeom==0
670 nl = fITSgeom->GetNlayers();
671 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
672 fITSgeom->GetNdetectors(nl))+1;
673 nmodules = indexMAX;
674 fITSmodules = new TObjArray(indexMAX);
3bd79107 675 for(index=0;index<indexMAX;index++){
2aea926d 676 fITSmodules->AddAt( new AliITSmodule(index),index);
3bd79107 677 } // end for index
678 }else{
679 fITSmodules = new TObjArray(size);
9c74c52b 680 for(index=0;index<size;index++) {
681 fITSmodules->AddAt( new AliITSmodule(index),index);
2aea926d 682 } // end for index
9c74c52b 683
3bd79107 684 nmodules = size;
685 } // end i size<=0
686}
2aea926d 687//______________________________________________________________________
688void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
689 Option_t *option,Text_t *filename){
690 // fill the modules with the sorted by module hits; add hits from
691 // background if option=Add
3bd79107 692 static TTree *trH1; //Tree with background hits
693 static TClonesArray *fHits2; //List of hits for one track only
3bd79107 694 static Bool_t first=kTRUE;
695 static TFile *file;
5cf7bbad 696 const char *addBgr = strstr(option,"Add");
3bd79107 697
e8189707 698 if (addBgr ) {
3bd79107 699 if(first) {
3bd79107 700 file=new TFile(filename);
3bd79107 701 fHits2 = new TClonesArray("AliITShit",1000 );
2aea926d 702 } // end if first
3bd79107 703 first=kFALSE;
704 file->cd();
705 file->ls();
706 // Get Hits Tree header from file
707 if(fHits2) fHits2->Clear();
708 if(trH1) delete trH1;
709 trH1=0;
2aea926d 710
3bd79107 711 char treeName[20];
712 sprintf(treeName,"TreeH%d",bgrev);
713 trH1 = (TTree*)gDirectory->Get(treeName);
3bd79107 714 if (!trH1) {
2aea926d 715 Error("AliITS::FillModules","cannot find Hits Tree for event:%d\n",
716 bgrev);
717 } // end if !trH1
3bd79107 718 // Set branch addresses
719 TBranch *branch;
720 char branchname[20];
721 sprintf(branchname,"%s",GetName());
722 if (trH1 && fHits2) {
723 branch = trH1->GetBranch(branchname);
724 if (branch) branch->SetAddress(&fHits2);
2aea926d 725 } // end if trH1 && fHits
726 } // end if addBgr
3bd79107 727
3bd79107 728 TClonesArray *itsHits = this->Hits();
729 Int_t lay,lad,det,index;
730 AliITShit *itsHit=0;
731 AliITSmodule *mod=0;
3bd79107 732 TTree *iTH = gAlice->TreeH();
733 Int_t ntracks =(Int_t) iTH->GetEntries();
3bd79107 734 Int_t t,h;
735 for(t=0; t<ntracks; t++){
736 gAlice->ResetHits();
737 iTH->GetEvent(t);
738 Int_t nhits = itsHits->GetEntriesFast();
739 if (!nhits) continue;
3bd79107 740 for(h=0; h<nhits; h++){
741 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
742 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 743 // temporarily index=det-1 !!!
744 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
745 else index=det-1;
746 //
3bd79107 747 mod = this->GetModule(index);
9c74c52b 748 mod->AddHit(itsHit,t,h);
3bd79107 749 } // end loop over hits
750 } // end loop over tracks
751
752 // open the file with background
753
e8189707 754 if (addBgr ) {
2aea926d 755 Int_t track,i;
756 ntracks =(Int_t)trH1->GetEntries();
757 // Loop over tracks
758 for (track=0; track<ntracks; track++) {
759 if (fHits2) fHits2->Clear();
760 trH1->GetEvent(track);
761 // Loop over hits
762 for(i=0;i<fHits2->GetEntriesFast();++i) {
763 itsHit=(AliITShit*) (*fHits2)[i];
764 itsHit->GetDetectorID(lay,lad,det);
765 // temporarily index=det-1 !!!
766 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
767 else index=det-1;
768 //
769 mod = this->GetModule(index);
770 mod->AddHit(itsHit,track,i);
771 } // end loop over hits
772 } // end loop over tracks
773 TTree *fAli=gAlice->TreeK();
774 TFile *fileAli=0;
775 if (fAli) fileAli =fAli->GetCurrentFile();
776 fileAli->cd();
3bd79107 777 } // end if add
3bd79107 778}
2aea926d 779//______________________________________________________________________
780void AliITS::ClearModules(){
781 //clear the modules TObjArray
3bd79107 782
2aea926d 783 if(fITSmodules) fITSmodules->Delete();
784}
785//______________________________________________________________________
786void AliITS::MakeBranchS(const char *file){
787 // Creates Tree branche for the ITS summable digits.
788 Int_t buffersize = 4000;
789 char branchname[30];
2ab0c725 790
2aea926d 791 // only one branch for SDigits.
792 sprintf(branchname,"%s",GetName());
793 if(fSDigits && gAlice->TreeS()){
794 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,file);
795 } // end if
796}
797//______________________________________________________________________
798void AliITS::SetTreeAddressS(TTree *treeS){
799 // Set branch address for the ITS summable digits Trees.
800 char branchname[30];
828e06c7 801
2aea926d 802 if(!treeS) return;
803 TBranch *branch;
804 sprintf(branchname,"%s",GetName());
805 branch = treeS->GetBranch(branchname);
806 if (branch) branch->SetAddress(&fSDigits);
807}
808//______________________________________________________________________
809void AliITS::MakeBranchD(const char *file){
810 // Creates Tree branches for the ITS.
811 Int_t buffersize = 4000;
812 char branchname[30];
2ab0c725 813
2aea926d 814 sprintf(branchname,"%s",GetName());
815 // one branch for digits per type of detector
816 const char *det[3] = {"SPD","SDD","SSD"};
817 char digclass[40];
818 char clclass[40];
819 Int_t i;
820 for (i=0; i<kNTYPES ;i++) {
821 DetType(i)->GetClassNames(digclass,clclass);
822 // digits
823 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
824 else ResetDigits(i);
825 } // end for i
826 for (i=0; i<kNTYPES ;i++) {
827 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
828 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
829 if (fDtype && gAlice->TreeD()) {
830 MakeBranchInTree(gAlice->TreeD(),
831 branchname, &((*fDtype)[i]),buffersize,file);
832 } // end if
833 } // end for i
2ab0c725 834}
2aea926d 835//______________________________________________________________________
836void AliITS::SetTreeAddressD(TTree *treeD){
837 // Set branch address for the Trees.
838 char branchname[30];
839 const char *det[3] = {"SPD","SDD","SSD"};
840 TBranch *branch;
841 char digclass[40];
842 char clclass[40];
843 Int_t i;
2ab0c725 844
2aea926d 845 if(!treeD) return;
846 for (i=0; i<kNTYPES; i++) {
847 DetType(i)->GetClassNames(digclass,clclass);
848 // digits
849 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
850 else ResetDigits(i);
851 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
852 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
853 if (fDtype) {
854 branch = treeD->GetBranch(branchname);
855 if (branch) branch->SetAddress(&((*fDtype)[i]));
856 } // end if fDtype
857 } // end for i
858}
859//______________________________________________________________________
860void AliITS::Hits2SDigits(){
861 // Standard Hits to summable Digits function.
862
863 return; // Using Hits inplace of the larger sDigits.
864 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
865 // Do the Hits to Digits operation. Use Standard input values.
866 // Event number from file, no background hit merging , use size from
867 // AliITSgeom class, option="All", input from this file only.
868 HitsToSDigits(header->GetEvent(),0,-1," ","All"," ");
869}
870//______________________________________________________________________
871void AliITS::Hits2PreDigits(){
872 // Standard Hits to summable Digits function.
873
874 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
875 // Do the Hits to Digits operation. Use Standard input values.
876 // Event number from file, no background hit merging , use size from
877 // AliITSgeom class, option="All", input from this file only.
878 HitsToPreDigits(header->GetEvent(),0,-1," ","All"," ");
879}
880//______________________________________________________________________
881void AliITS::SDigits2Digits(){
882 // Standard Summable digits to Digits function.
3bd79107 883
2aea926d 884 Hits2Digits();
885}
886//______________________________________________________________________
887void AliITS::Hits2Digits(){
888 // Standard Hits to Digits function.
889
890 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
891 // Do the Hits to Digits operation. Use Standard input values.
892 // Event number from file, no background hit merging , use size from
893 // AliITSgeom class, option="All", input from this file only.
894 HitsToDigits(header->GetEvent(),0,-1," ","All"," ");
895}
896//______________________________________________________________________
897void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
898 Option_t *option, Option_t *opt,Text_t *filename){
3bd79107 899 // keep galice.root for signal and name differently the file for
900 // background when add! otherwise the track info for signal will be lost !
2aea926d 901 // the condition below will disappear when the geom class will be
902 // initialised for all versions - for the moment it is only for v5 !
903 // 7 is the SDD beam test version
904 return; // using Hits instead of the larger sdigits.
905}
906//______________________________________________________________________
907void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
908 Option_t *option, Option_t *opt,Text_t *filename){
909 // keep galice.root for signal and name differently the file for
910 // background when add! otherwise the track info for signal will be lost !
911 // the condition below will disappear when the geom class will be
912 // initialised for all versions - for the moment it is only for v5 !
913 // 7 is the SDD beam test version
914
915 if(!GetITSgeom()) return; // need transformations to do digitization.
916 AliITSgeom *geom = GetITSgeom();
917
918 const char *all = strstr(opt,"All");
919 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
920 strstr(opt,"SSD")};
921 static Bool_t setDef=kTRUE;
922 if (setDef) SetDefaultSimulation();
923 setDef=kFALSE;
924
925 Int_t nmodules;
926 InitModules(size,nmodules);
927 FillModules(evNumber,bgrev,nmodules,option,filename);
928
929 AliITSsimulation *sim = 0;
930 AliITSDetType *iDetType = 0;
931 AliITSmodule *mod = 0;
932 Int_t id,module;
933 for(module=0;module<geom->GetIndexMax();module++){
934 id = geom->GetModuleType(module);
935 if (!all && !det[id]) continue;
936 iDetType = DetType(id);
937 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
938 if (!sim) {
939 Error("HitsToSDigits",
940 "The simulation class was not instantiated!");
941 exit(1);
942 } // end if !sim
943 mod = (AliITSmodule *)fITSmodules->At(module);
944 sim->SDigitiseModule(mod,module,evNumber);
945 // fills all branches - wasted disk space
946 gAlice->TreeS()->Fill();
947 ResetSDigits();
948 } // end for module
949
950 ClearModules();
951
952 gAlice->TreeS()->GetEntries();
953
954 char hname[30];
955 sprintf(hname,"TreeS%d",evNumber);
956 gAlice->TreeS()->Write(hname,TObject::kOverwrite);
957 // reset tree
958 gAlice->TreeS()->Reset();
959}
960//______________________________________________________________________
961void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
962 Option_t *option, Option_t *opt,Text_t *filename){
963 // keep galice.root for signal and name differently the file for
964 // background when add! otherwise the track info for signal will be lost !
965 // the condition below will disappear when the geom class will be
966 // initialised for all versions - for the moment it is only for v5 !
967 // 7 is the SDD beam test version
968/* Int_t ver = this->IsVersion();
969 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
970*/
971 if(!GetITSgeom()) return; // need transformations to do digitization.
972 AliITSgeom *geom = GetITSgeom();
973
974 const char *all = strstr(opt,"All");
975 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
976 strstr(opt,"SSD")};
977 static Bool_t setDef=kTRUE;
978 if (setDef) SetDefaultSimulation();
979 setDef=kFALSE;
980
981 Int_t nmodules;
982 InitModules(size,nmodules);
983 FillModules(evNumber,bgrev,nmodules,option,filename);
984
985 AliITSsimulation *sim = 0;
986 AliITSDetType *iDetType = 0;
987 AliITSmodule *mod = 0;
988 Int_t id,module;
989 for(module=0;module<geom->GetIndexMax();module++){
990 id = geom->GetModuleType(module);
991 if (!all && !det[id]) continue;
992 iDetType = DetType(id);
993 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
994 if (!sim) {
995 Error("HitsToDigits",
996 "The simulation class was not instantiated!");
997 exit(1);
998 } // end if !sim
999 mod = (AliITSmodule *)fITSmodules->At(module);
1000 sim->DigitiseModule(mod,module,evNumber);
1001 // fills all branches - wasted disk space
1002 gAlice->TreeD()->Fill();
1003 ResetDigits();
1004 } // end for module
1005/*
1006 Int_t id,module;
1007 Int_t first,last;
1008 for (id=0;id<kNTYPES;id++) {
3bd79107 1009 if (!all && !det[id]) continue;
3bd79107 1010 AliITSDetType *iDetType=DetType(id);
1011 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
9c74c52b 1012 if(geom) {
2aea926d 1013 first = geom->GetStartDet(id);
1014 last = geom->GetLastDet(id);
9c74c52b 1015 } else first=last=0;
3bd79107 1016 for(module=first;module<=last;module++) {
1017 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1018 sim->DigitiseModule(mod,module,evNumber);
1019 // fills all branches - wasted disk space
1020 gAlice->TreeD()->Fill();
1021 ResetDigits();
3bd79107 1022 } // loop over modules
2aea926d 1023 } // loop over detector types
1024*/
1025 ClearModules();
3bd79107 1026
2aea926d 1027 gAlice->TreeD()->GetEntries();
3bd79107 1028
2aea926d 1029 char hname[30];
1030 sprintf(hname,"TreeD%d",evNumber);
1031 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1032 // reset tree
1033 gAlice->TreeD()->Reset();
1034}
1035//______________________________________________________________________
1036void AliITS::ResetSDigits(){
1037 // Reset the Summable Digits array
3bd79107 1038
2aea926d 1039 if (fSDigits) fSDigits->Clear();
1040 fNSDigits = 0;
3bd79107 1041}
2aea926d 1042//______________________________________________________________________
1043void AliITS::ResetDigits(){
1044 // Reset number of digits and the digits array for the ITS detector
3bd79107 1045
2aea926d 1046 if (!fDtype) return;
3bd79107 1047
2aea926d 1048 Int_t i;
1049 for (i=0;i<kNTYPES;i++ ) {
1050 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1051 if (fNdtype) fNdtype[i]=0;
1052 } // end for i
1053}
1054//______________________________________________________________________
1055void AliITS::ResetDigits(Int_t i){
1056 // Reset number of digits and the digits array for this branch
828e06c7 1057
2aea926d 1058 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1059 if (fNdtype) fNdtype[i]=0;
1060}
1061//______________________________________________________________________
1062void AliITS::AddSumDigit(AliITSpListItem &sdig){
1063 // adds the a module full of summable digits to the summable digits tree.
828e06c7 1064
2aea926d 1065 TClonesArray &lsdig = *fSDigits;
1066 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
828e06c7 1067}
2aea926d 1068//______________________________________________________________________
1069void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1070 // add a real digit - as coming from data
9c74c52b 1071
2aea926d 1072 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1073 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1074}
1075//______________________________________________________________________
1076void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1077 // add a simulated digit
1078
1079 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1080
1081 switch(id){
1082 case 0:
1083 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1084 break;
1085 case 1:
1086 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1087 break;
1088 case 2:
1089 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1090 break;
1091 } // end switch id
1092}
1093//______________________________________________________________________
1094void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1095 Int_t *hits,Float_t *charges){
1096 // add a simulated digit to the list
1097
1098 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1099 switch(id){
1100 case 0:
1101 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1102 break;
1103 case 1:
1104 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1105 hits,charges);
1106 break;
1107 case 2:
1108 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1109 break;
1110 } // end switch id
1111}
1112//______________________________________________________________________
1113void AliITS::MakeTreeC(Option_t *option){
1114 // create a separate tree to store the clusters
3bd79107 1115
2aea926d 1116 const char *optC = strstr(option,"C");
1117 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
1118 else return;
828e06c7 1119
2aea926d 1120 Int_t buffersize = 4000;
1121 char branchname[30];
1122 const char *det[3] = {"SPD","SDD","SSD"};
1123 char digclass[40];
1124 char clclass[40];
caf37aec 1125
2aea926d 1126 // one branch for Clusters per type of detector
1127 Int_t i;
1128 for (i=0; i<kNTYPES ;i++) {
1129 AliITSDetType *iDetType=DetType(i);
1130 iDetType->GetClassNames(digclass,clclass);
1131 // clusters
1132 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1133 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1134 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1135 if (fCtype && fTreeC) {
1136 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1137 } // end if fCtype && fTreeC
1138 } // end for i
1139}
1140//______________________________________________________________________
1141void AliITS::GetTreeC(Int_t event){
1142 // get the clusters tree for this event and set the branch address
1143 char treeName[20];
1144 char branchname[30];
1145 const char *det[3] = {"SPD","SDD","SSD"};
9c74c52b 1146
2aea926d 1147 ResetClusters();
1148 if (fTreeC) {
1149 delete fTreeC;
1150 } // end if fTreeC
3bd79107 1151
2aea926d 1152 sprintf(treeName,"TreeC%d",event);
1153 fTreeC = (TTree*)gDirectory->Get(treeName);
3bd79107 1154
2aea926d 1155 TBranch *branch;
1156
1157 if (fTreeC) {
1158 Int_t i;
1159 char digclass[40];
1160 char clclass[40];
1161 for (i=0; i<kNTYPES; i++) {
1162 AliITSDetType *iDetType=DetType(i);
1163 iDetType->GetClassNames(digclass,clclass);
1164 // clusters
1165 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1166 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1167 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1168 if (fCtype) {
1169 branch = fTreeC->GetBranch(branchname);
1170 if (branch) branch->SetAddress(&((*fCtype)[i]));
1171 } // end if fCtype
1172 } // end for i
1173 } else {
1174 Error("AliITS::GetTreeC",
1175 "cannot find Clusters Tree for event:%d\n",event);
1176 } // end if fTreeC
1177}
1178//______________________________________________________________________
1179void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1180 // add a cluster to the list
1181
1182 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1183
1184 switch(id){
1185 case 0:
1186 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1187 break;
1188 case 1:
1189 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1190 break;
1191 case 2:
1192 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1193 break;
1194 } // end switch id
1195}
1196//______________________________________________________________________
1197void AliITS::ResetClusters(){
1198 // Reset number of clusters and the clusters array for ITS
1199
1200 Int_t i;
1201 for (i=0;i<kNTYPES;i++ ) {
1202 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1203 if (fNctype) fNctype[i]=0;
1204 } // end for i
1205}
1206//______________________________________________________________________
1207void AliITS::ResetClusters(Int_t i){
1208 // Reset number of clusters and the clusters array for this branch
3bd79107 1209
2aea926d 1210 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1211 if (fNctype) fNctype[i]=0;
1212}
1213//______________________________________________________________________
1214void AliITS::MakeBranchR(const char *file){
1215 // Creates Tree branches for the ITS Reconstructed points.
1216 Int_t buffersize = 4000;
1217 char branchname[30];
3bd79107 1218
2aea926d 1219// sprintf(branchname,"%s",GetName());
1220 // only one branch for rec points for all detector types
1221 sprintf(branchname,"%sRecPoints",GetName());
1222 if (fRecPoints && gAlice->TreeR()) {
1223 MakeBranchInTree(gAlice->TreeR(),branchname, &fRecPoints,
1224 buffersize,file) ;
1225 } // end if
1226}
1227//______________________________________________________________________
1228void AliITS::SetTreeAddressR(TTree *treeR){
1229 // Set branch address for the Reconstructed points Trees.
1230 char branchname[30];
3bd79107 1231
2aea926d 1232 if(!treeR) return;
1233 TBranch *branch;
1234// sprintf(branchname,"%s",GetName());
1235 sprintf(branchname,"%sRecPoints",GetName());
1236 branch = treeR->GetBranch(branchname);
1237 if (branch) branch->SetAddress(&fRecPoints);
1238}
1239//______________________________________________________________________
1240void AliITS::AddRecPoint(const AliITSRecPoint &r){
1241 // Add a reconstructed space point to the list
3bd79107 1242
2aea926d 1243 TClonesArray &lrecp = *fRecPoints;
1244 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
3bd79107 1245}
2aea926d 1246//______________________________________________________________________
e8189707 1247void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
2aea926d 1248 Option_t *opt0,Option_t *opt1,Text_t *flnm){
3bd79107 1249 // keep galice.root for signal and name differently the file for
1250 // background when add! otherwise the track info for signal will be lost !
2aea926d 1251 // the condition below will disappear when the geom class will be
1252 // initialised for all versions - for the moment it is only for v5 !
1253/* Int_t ver = this->IsVersion();
1254 if(ver!=5 && ver!=8 && ver!=9) return;
1255*/
1256 if(!GetITSgeom()) return;
1257 AliITSgeom *geom = GetITSgeom();
1258
1259 const char *all = strstr(opt1,"All");
1260 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1261 strstr(opt1,"SSD")};
1262 Int_t nmodules;
1263 InitModules(size,nmodules);
1264 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1265
1266 AliITSsimulation *sim = 0;
1267 AliITSDetType *iDetType = 0;
1268 AliITSmodule *mod = 0;
1269 Int_t id,module;
e3b819ce 1270
1271 //m.b. : this change is nothing but a nice way to make sure
1272 //the CPU goes up !
2aea926d 1273 for(module=0;module<geom->GetIndexMax();module++){
1274 id = geom->GetModuleType(module);
1275 if (!all && !det[id]) continue;
1276 iDetType = DetType(id);
1277 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1278 if (!sim) {
1279 Error("HitsToFastPoints",
1280 "The simulation class was not instantiated!");
1281 exit(1);
1282 } // end if !sim
1283 mod = (AliITSmodule *)fITSmodules->At(module);
1284 sim->CreateFastRecPoints(mod,module,gRandom);
e3b819ce 1285 gAlice->TreeR()->Fill();
1286 ResetRecPoints();
2aea926d 1287 } // end for module
1288/*
1289 Int_t id,module;
1290 for (id=0;id<kNTYPES;id++) {
3bd79107 1291 if (!all && !det[id]) continue;
e8189707 1292 AliITSDetType *iDetType=DetType(id);
1293 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1294 if (!sim) {
2aea926d 1295 Error("HitsToFastPoints",
1296 "The simulation class was not instantiated!");
1297 exit(1);
1298 } // end if !sim
34980f24 1299 Int_t first,last;
1300 if(geom) {
2aea926d 1301 first = geom->GetStartDet(id);
1302 last = geom->GetLastDet(id);
34980f24 1303 } else first=last=0;
3bd79107 1304 for(module=first;module<=last;module++) {
1305 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
2aea926d 1306 sim->CreateFastRecPoints(mod,module,gRandom);
3bd79107 1307 gAlice->TreeR()->Fill();
1308 ResetRecPoints();
1309 } // loop over modules
2aea926d 1310 } // loop over detector types
1311*/
1312 ClearModules();
e8189707 1313
2aea926d 1314 char hname[30];
1315 sprintf(hname,"TreeR%d",evNumber);
1316 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1317 // reset tree
1318 gAlice->TreeR()->Reset();
1319}
1320//______________________________________________________________________
1321void AliITS::Digits2Reco(){
1322 // find clusters and reconstruct space points
1323
1324 AliHeader *header=gAlice->GetHeader();
1325 // to Digits to RecPoints for event in file, all digits in file, and
1326 // all ITS detectors.
1327 DigitsToRecPoints(header->GetEvent(),0,"All");
1328}
1329//______________________________________________________________________
1330void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1331 // cluster finding and reconstruction of space points
1332 // the condition below will disappear when the geom class will be
1333 // initialised for all versions - for the moment it is only for v5 !
1334 // 7 is the SDD beam test version
1335/* Int_t ver = this->IsVersion();
1336 if(ver!=5 && ver!=8 && ver!=9) return;
1337*/
1338 if(!GetITSgeom()) return;
1339 AliITSgeom *geom = GetITSgeom();
1340
1341 const char *all = strstr(opt,"All");
1342 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1343 strstr(opt,"SSD")};
1344 static Bool_t setRec=kTRUE;
1345 if (setRec) SetDefaultClusterFinders();
1346 setRec=kFALSE;
1347
1348 TTree *treeC=TreeC();
1349
1350 AliITSClusterFinder *rec = 0;
1351 AliITSDetType *iDetType = 0;
1352 Int_t id,module,first=0;
1353 for(module=0;module<geom->GetIndexMax();module++){
1354 id = geom->GetModuleType(module);
1355 if (!all && !det[id]) continue;
1356 if(det[id]) first = geom->GetStartDet(id);
1357 iDetType = DetType(id);
1358 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1359 TClonesArray *itsDigits = this->DigitsAddress(id);
1360 if (!rec) {
1361 Error("DigitsToRecPoints",
1362 "The reconstruction class was not instantiated!");
1363 exit(1);
1364 } // end if !rec
1365 this->ResetDigits();
1366 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1367 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1368 Int_t ndigits = itsDigits->GetEntriesFast();
1369 if (ndigits) rec->FindRawClusters(module);
1370 gAlice->TreeR()->Fill();
1371 ResetRecPoints();
1372 treeC->Fill();
1373 ResetClusters();
1374 } // end for module
828e06c7 1375
2aea926d 1376/*
1377 Int_t id,module;
1378 for (id=0;id<kNTYPES;id++) {
1379 if (!all && !det[id]) continue;
1380 AliITSDetType *iDetType=DetType(id);
1381 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1382 TClonesArray *itsDigits = this->DigitsAddress(id);
1383 Int_t first,last;
1384 if(geom) {
1385 first = geom->GetStartDet(id);
1386 last = geom->GetLastDet(id);
1387 } else first=last=0;
1388 printf("first module - last module %d %d\n",first,last);
1389 for(module=first;module<=last;module++) {
1390 this->ResetDigits();
1391 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1392 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1393 Int_t ndigits = itsDigits->GetEntriesFast();
1394 if (ndigits) rec->FindRawClusters(module);
1395 gAlice->TreeR()->Fill();
1396 ResetRecPoints();
1397 treeC->Fill();
1398 ResetClusters();
1399 } // loop over modules
1400 } // loop over detector types
1401*/
1402 gAlice->TreeR()->GetEntries();
1403 treeC->GetEntries();
1404
1405 char hname[30];
1406 sprintf(hname,"TreeR%d",evNumber);
1407 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1408 // reset tree
1409 gAlice->TreeR()->Reset();
1410
1411 sprintf(hname,"TreeC%d",evNumber);
1412 treeC->Write(hname,TObject::kOverwrite);
1413 treeC->Reset();
fe4da5cc 1414}
2aea926d 1415//______________________________________________________________________
1416void AliITS::ResetRecPoints(){
1417 // Reset number of rec points and the rec points array
63147407 1418
2aea926d 1419 if (fRecPoints) fRecPoints->Clear();
1420 fNRecPoints = 0;
1421}