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