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