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