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