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