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