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