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