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