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