Introduce the function Digits2Reco() and write the defaults for simulation and recons...
[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$
828e06c7 18Revision 1.56 2001/07/05 12:49:49 mariana
19Temporary patches required by root.v3.01.05
20
cb26748d 21Revision 1.55 2001/06/14 14:59:00 barbera
22Tracking V1 decoupled from AliITS
23
27a043b1 24Revision 1.54 2001/05/31 20:37:56 barbera
25Bari/Salerno model set as defaault SPD simulation
26
21b825a4 27Revision 1.53 2001/05/31 18:52:24 barbera
28Bari model becomes the default
29
30Revision 1.53 2001/05/30 07:52:24 hristov
31TPC and CONTAINERS included in the search path
32
71574c3c 33Revision 1.52 2001/05/30 06:04:58 hristov
34Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
35
1633a7ac 36Revision 1.51 2001/05/16 14:57:15 alibrary
37New files for folders and Stack
38
9e1a0ddb 39Revision 1.50 2001/05/11 09:15:21 barbera
40Corrected to make fast point creation working with PPR geometry
41
34980f24 42Revision 1.49 2001/05/11 07:37:49 hristov
43Legacy lines commented
44
f1d439d9 45Revision 1.48 2001/05/10 18:14:25 barbera
46A typo corrected
47
04f91b7e 48Revision 1.47 2001/05/10 17:55:59 barbera
49Modified to create rec points also for PPR geometries
50
c44604f4 51Revision 1.46 2001/05/10 00:05:28 nilsen
52Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
53should probably be cleaned up to only check to make sure that fITSgeom has
54been properly defined.
55
72de14c6 56Revision 1.45 2001/05/01 22:35:48 nilsen
57Remove/commented a number of cout<< statements. and made change needed by
58SSD code.
59
a3ec5900 60Revision 1.44 2001/04/26 22:44:01 nilsen
61Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
62done properly in AliITSv???.cxx via SetDefaults.
63
686b2f43 64Revision 1.43 2001/04/26 13:22:52 barbera
65TMatrix and TVector elimininated to speed up the code
66
53e7090a 67Revision 1.42 2001/04/25 21:55:12 barbera
68Updated version to be compatible with actual verion of STEER and TPC
69
8ab89103 70Revision 1.41 2001/04/21 15:16:51 barbera
71Updated with the new SSD reconstruction code
72
fd61217e 73Revision 1.40 2001/03/17 15:07:06 mariana
74Update SDD response parameters
75
37de990d 76Revision 1.39 2001/03/12 17:45:32 hristov
77Changes needed on Sun with CC 5.0
78
5cf7bbad 79Revision 1.38 2001/03/07 14:04:51 barbera
80Some vector dimensions increased to cope with full events
81
54fcea18 82Revision 1.37 2001/03/07 12:36:35 barbera
83A change added in the tracking part to manage delta rays
84
4f06a953 85Revision 1.36 2001/03/02 19:44:11 barbera
86 modified to taking into account new version tracking v1
87
8af13b4b 88Revision 1.35 2001/02/28 18:16:46 mariana
89Make the code compatible with the new AliRun
90
340cd0d8 91Revision 1.34 2001/02/11 15:51:39 mariana
92Set protection in MakeBranch
93
c34b4885 94Revision 1.33 2001/02/10 22:26:39 mariana
95Move the initialization of the containers for raw clusters in MakeTreeC()
96
caf37aec 97Revision 1.32 2001/02/08 23:55:31 nilsen
98Removed fMajor/MinorVersion variables in favor of variables in derived classes.
99Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
100
04874c1a 101Revision 1.31 2001/02/02 23:57:28 nilsen
102Added include file that are no londer included in AliITSgeom.h
103
d953664a 104Revision 1.30 2001/01/30 09:23:13 hristov
105Streamers removed (R.Brun)
106
a8a6107b 107Revision 1.29 2001/01/26 20:01:09 hristov
108Major upgrade of AliRoot code
109
2ab0c725 110Revision 1.28 2000/12/18 14:02:00 barbera
111new version of the ITS tracking to take into account the new TPC track parametrization
112
cc6e75dd 113Revision 1.27 2000/12/08 13:49:27 barbera
114Hidden declaration in a for loop removed to be compliant with HP-UX compiler
115
c5b22044 116Revision 1.26 2000/11/27 13:12:13 barbera
117New version containing the files for tracking
118
55b5a0b3 119Revision 1.25 2000/11/12 22:38:05 barbera
120Added header file for the SPD Bari model
121
dfe2a93f 122Revision 1.24 2000/10/09 22:18:12 barbera
123Bug fixes from MAriana to le AliITStest.C run correctly
124
65d4384f 125Revision 1.23 2000/10/05 20:47:42 nilsen
126fixed dependencies of include files. Tryed but failed to get a root automaticly
127generates streamer function to work. Modified SetDefaults.
128
143d1056 129Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
130Needed to include stdlib.h
131
132=======
133Revision 1.22 2000/10/04 19:45:52 barbera
134Corrected by F. Carminati for v3.04
135
114da3a4 136Revision 1.21 2000/10/02 21:28:08 fca
137Removal of useless dependecies via forward declarations
138
94de3818 139Revision 1.20 2000/10/02 16:31:39 barbera
140General code clean-up
141
d5da1ecf 142Revision 1.9.2.14 2000/10/02 15:43:51 barbera
143General code clean-up (e.g., printf -> cout)
144
145Revision 1.19 2000/09/22 12:13:25 nilsen
146Patches and updates for fixes to this and other routines.
147
9c74c52b 148Revision 1.18 2000/07/12 05:32:20 fca
149Correcting several syntax problem with static members
150
b669392e 151Revision 1.17 2000/07/10 16:07:18 fca
152Release version of ITS code
153
3bd79107 154Revision 1.9.2.3 2000/02/02 13:42:09 barbera
155fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
156
157Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
158//fixed FillModule. Removed fi(fabs(xl)<dx....
159
160Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
161This is the version of the files after the merging done in December 1999.
162See the ReadMe110100.txt file for details
c9a71be1 163
1cedd08a 164Revision 1.9 1999/11/14 14:33:25 fca
165Correct problems with distructors and pointers, thanks to I.Hrivnacova
166
6c854497 167Revision 1.8 1999/09/29 09:24:19 fca
168Introduction of the Copyright and cvs Log
169
4c039060 170*/
171
fe4da5cc 172///////////////////////////////////////////////////////////////////////////////
58005f18 173//
174// An overview of the basic philosophy of the ITS code development
175// and analysis is show in the figure below.
fe4da5cc 176//Begin_Html
177/*
a92b2b7d 178<img src="picts/ITS/ITS_Analysis_schema.gif">
fe4da5cc 179</pre>
180<br clear=left>
181<font size=+2 color=red>
58005f18 182<p>Roberto Barbera is in charge of the ITS Offline code (1999).
fe4da5cc 183<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
184</font>
185<pre>
186*/
187//End_Html
58005f18 188//
189// AliITS. Inner Traking System base class.
190// This class contains the base procedures for the Inner Tracking System
191//
192//Begin_Html
193/*
a92b2b7d 194<img src="picts/ITS/AliITS_Class_Diagram.gif">
58005f18 195</pre>
196<br clear=left>
197<font size=+2 color=red>
198<p>This show the class diagram of the different elements that are part of
199the AliITS class.
200</font>
201<pre>
202*/
203//End_Html
204//
205// Version: 0
206// Written by Rene Brun, Federico Carminati, and Roberto Barbera
207//
208// Version: 1
209// Modified and documented by Bjorn S. Nilsen
210// July 11 1999
211//
3bd79107 212// Version: 2
213// Modified and documented by A. Bologna
214// October 18 1999
215//
58005f18 216// AliITS is the general base class for the ITS. Also see AliDetector for
217// futher information.
218//
fe4da5cc 219///////////////////////////////////////////////////////////////////////////////
d953664a 220#include <iostream.h>
221#include <iomanip.h>
222#include <fstream.h>
143d1056 223#include <stdlib.h>
fe4da5cc 224#include <TMath.h>
225#include <TRandom.h>
9c74c52b 226#include <TBranch.h>
fe4da5cc 227#include <TVector.h>
caf37aec 228#include <TClonesArray.h>
3bd79107 229#include <TROOT.h>
230#include <TObjectTable.h>
9c74c52b 231#include <TFile.h>
232#include <TTree.h>
d5da1ecf 233#include <TString.h>
3bd79107 234
bb8ac1e0 235
828e06c7 236
237#include "AliMC.h"
fe4da5cc 238#include "AliRun.h"
828e06c7 239#include "AliHeader.h"
240
3bd79107 241#include "AliITS.h"
e8189707 242#include "AliITSDetType.h"
3bd79107 243#include "AliITSresponseSPD.h"
3bd79107 244#include "AliITSresponseSDD.h"
3bd79107 245#include "AliITSresponseSSD.h"
828e06c7 246#include "AliITSsegmentationSPD.h"
247#include "AliITSsegmentationSDD.h"
248#include "AliITSsegmentationSSD.h"
249#include "AliITSsimulationSPD.h"
250#include "AliITSsimulationSDD.h"
251#include "AliITSsimulationSSD.h"
252#include "AliITSClusterFinderSPD.h"
253#include "AliITSClusterFinderSDD.h"
254#include "AliITSClusterFinderSSD.h"
255
9c74c52b 256#include "AliITShit.h"
257#include "AliITSgeom.h"
258#include "AliITSdigit.h"
259#include "AliITSmodule.h"
260#include "AliITSRecPoint.h"
261#include "AliITSRawCluster.h"
828e06c7 262
c9a71be1 263
3bd79107 264ClassImp(AliITS)
265
fe4da5cc 266//_____________________________________________________________________________
3bd79107 267AliITS::AliITS() : AliDetector() {
fe4da5cc 268 //
269 // Default initialiser for ITS
58005f18 270 // The default constructor of the AliITS class. In addition to
271 // creating the AliITS class it zeros the variables fIshunt (a member
272 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
3bd79107 273 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
274 // is also called.
fe4da5cc 275 //
3bd79107 276
9c74c52b 277
58005f18 278 fIshunt = 0;
279 fEuclidOut = 0;
e8189707 280
a8a6107b 281 fNDetTypes = kNTYPES;
58005f18 282 fIdN = 0;
283 fIdName = 0;
284 fIdSens = 0;
6c854497 285 fITSmodules = 0;
3bd79107 286 //
287 fDetTypes = 0;
3bd79107 288 //
289 fDtype = 0;
290 fNdtype = 0;
291 fCtype = 0;
292 fNctype = 0;
293 fRecPoints = 0;
294 fNRecPoints = 0;
e8189707 295 fTreeC = 0;
3bd79107 296 //
297 fITSgeom=0;
fe4da5cc 298}
3bd79107 299
fe4da5cc 300//_____________________________________________________________________________
58005f18 301AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
fe4da5cc 302 //
303 // Default initialiser for ITS
58005f18 304 // The constructor of the AliITS class. In addition to creating the
305 // AliITS class, it allocates memory for the TClonesArrays fHits and
306 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
307 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
308 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
309 // macro display.C AliITS also sets the marker color to red. The variables
310 // passes with this constructor, const char *name and *title, are used by
311 // the constructor of AliDetector class. See AliDetector class for a
312 // description of these parameters and its constructor functions.
fe4da5cc 313 //
58005f18 314
9c74c52b 315
58005f18 316 fHits = new TClonesArray("AliITShit", 1560);
1cedd08a 317 gAlice->AddHitList(fHits);
3bd79107 318
a8a6107b 319 fNDetTypes = kNTYPES;
e8189707 320
a8a6107b 321 fNdtype = new Int_t[kNTYPES];
322 fDtype = new TObjArray(kNTYPES);
e8189707 323
a8a6107b 324 fNctype = new Int_t[kNTYPES];
325 fCtype = new TObjArray(kNTYPES);
3bd79107 326
3bd79107 327
cb26748d 328
329 fRecPoints=new TClonesArray("AliITSRecPoint",1000);
3bd79107 330 fNRecPoints = 0;
331
e8189707 332 fTreeC = 0;
3bd79107 333
334 fITSmodules = 0;
58005f18 335
336 fIshunt = 0;
337 fEuclidOut = 0;
338 fIdN = 0;
339 fIdName = 0;
340 fIdSens = 0;
3bd79107 341
a8a6107b 342 fDetTypes = new TObjArray(kNTYPES);
3bd79107 343
344 Int_t i;
a8a6107b 345 for(i=0;i<kNTYPES;i++) {
9e1a0ddb 346 fDetTypes->AddAt(new AliITSDetType(),i);
e8189707 347 fNdtype[i]=0;
348 fNctype[i]=0;
3bd79107 349 }
350 //
58005f18 351
fe4da5cc 352 SetMarkerColor(kRed);
58005f18 353
3bd79107 354 fITSgeom=0;
355}
356//___________________________________________________________________________
357AliITS::AliITS(AliITS &source){
e8189707 358 // copy constructor
3bd79107 359 if(this==&source) return;
d5da1ecf 360 Error("AliITS::Copy constructor",
361 "You are not allowed to make a copy of the AliITS");
3bd79107 362 exit(1);
fe4da5cc 363}
3bd79107 364//____________________________________________________________________________
365AliITS& AliITS::operator=(AliITS &source){
e8189707 366 // assignment operator
3bd79107 367 if(this==&source) return *this;
d5da1ecf 368 Error("AliITS::operator=",
369 "You are not allowed to make a copy of the AliITS");
3bd79107 370 exit(1);
e8189707 371 return *this; //fake return
3bd79107 372}
373//____________________________________________________________________________
374void AliITS::ClearModules(){
375 //clear the modules TObjArray
3bd79107 376
9c74c52b 377 if(fITSmodules) fITSmodules->Delete();
fe4da5cc 378
3bd79107 379}
fe4da5cc 380//_____________________________________________________________________________
58005f18 381AliITS::~AliITS(){
fe4da5cc 382 //
383 // Default distructor for ITS
58005f18 384 // The default destructor of the AliITS class. In addition to deleting
385 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
386 // fIdSens, fIdName, and fITSpoints.
fe4da5cc 387 //
3bd79107 388
389
fe4da5cc 390 delete fHits;
391 delete fDigits;
3bd79107 392 delete fRecPoints;
143d1056 393// delete fIdName; // TObjArray of TObjStrings
394 if(fIdName!=0) delete[] fIdName; // Array of TStrings
58005f18 395 if(fIdSens!=0) delete[] fIdSens;
3bd79107 396 if(fITSmodules!=0) {
397 this->ClearModules();
398 delete fITSmodules;
399 }// end if fITSmodules!=0
fe4da5cc 400
fe4da5cc 401 //
3bd79107 402 if(fDtype) {
9c74c52b 403 fDtype->Delete();
404 delete fDtype;
3bd79107 405 }
9c74c52b 406 delete [] fNdtype;
407 if (fCtype) {
408 fCtype->Delete();
409 delete fCtype;
3bd79107 410 }
9c74c52b 411 delete [] fNctype;
fe4da5cc 412 //
3bd79107 413
414 if (fDetTypes) {
415 fDetTypes->Delete();
416 delete fDetTypes;
417 }
418
419 if (fTreeC) delete fTreeC;
e8189707 420
9c74c52b 421 if (fITSgeom) delete fITSgeom;
422
3bd79107 423}
424
425//___________________________________________
426AliITSDetType* AliITS::DetType(Int_t id)
427{
428 //return pointer to id detector type
429 return ((AliITSDetType*) (*fDetTypes)[id]);
430
431}
432//___________________________________________
e8189707 433void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
3bd79107 434{
435 //set the digit and cluster classes to be used for the id detector type
436 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
437
438}
439//___________________________________________
440void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
441{
442 //set the response model for the id detector type
443
444 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
445
fe4da5cc 446}
447
3bd79107 448//___________________________________________
449void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
450{
451 //set the segmentation model for the id detector type
452
453 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
454
455}
456
457//___________________________________________
458void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
459{
460 //set the simulation model for the id detector type
461
462 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
463
464}
465//___________________________________________
466void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
467{
468 //set the cluster finder model for the id detector type
469
470 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
58005f18 471
58005f18 472}
473
fe4da5cc 474//_____________________________________________________________________________
58005f18 475void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
fe4da5cc 476 //
477 // Add an ITS hit
58005f18 478 // The function to add information to the AliITShit class. See the
479 // AliITShit class for a full description. This function allocates the
480 // necessary new space for the hit information and passes the variable
481 // track, and the pointers *vol and *hits to the AliITShit constructor
482 // function.
fe4da5cc 483 //
484 TClonesArray &lhits = *fHits;
485 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
486}
fe4da5cc 487//_____________________________________________________________________________
3bd79107 488void AliITS::AddRealDigit(Int_t id, Int_t *digits)
489{
490 // add a real digit - as coming from data
491
492 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
493 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
494
495}
496//_____________________________________________________________________________
e8189707 497void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
3bd79107 498{
499
500 // add a simulated digit
501
3bd79107 502 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
503
504 switch(id)
505 {
506 case 0:
507 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
508 break;
509 case 1:
510 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
511 break;
512 case 2:
513 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
514 break;
515 }
516
517}
518
519//_____________________________________________________________________________
e8189707 520void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
3bd79107 521
522 // add a simulated digit to the list
523
524 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
525 switch(id)
526 {
527 case 0:
e8189707 528 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
3bd79107 529 break;
530 case 1:
e8189707 531 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
3bd79107 532 break;
533 case 2:
e8189707 534 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
3bd79107 535 break;
536 }
537
538}
539
540//_____________________________________________________________________________
541void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
542{
543
544 // add a cluster to the list
545
3bd79107 546 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
547
548 switch(id)
549 {
550 case 0:
551 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
552 break;
553 case 1:
554 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
555 break;
556 case 2:
557 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
558 break;
559 }
560
561}
562
563
564//_____________________________________________________________________________
565void AliITS::AddRecPoint(const AliITSRecPoint &r)
566{
567 //
568 // Add a reconstructed space point to the list
569 //
570 TClonesArray &lrecp = *fRecPoints;
571 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
572}
573
574
575//____________________________________________
576void AliITS::ResetDigits()
577{
578 //
9c74c52b 579 // Reset number of digits and the digits array for the ITS detector
3bd79107 580 //
581
582 if (!fDtype) return;
583
584 Int_t i;
a8a6107b 585 for (i=0;i<kNTYPES;i++ ) {
3bd79107 586 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
587 if (fNdtype) fNdtype[i]=0;
588 }
589}
590
591//____________________________________________
592void AliITS::ResetDigits(Int_t i)
593{
594 //
595 // Reset number of digits and the digits array for this branch
596 //
e8189707 597 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
598 if (fNdtype) fNdtype[i]=0;
3bd79107 599}
e8189707 600
601
3bd79107 602//____________________________________________
603void AliITS::ResetClusters()
604{
605 //
606 // Reset number of clusters and the clusters array for ITS
607 //
608
609 Int_t i;
a8a6107b 610 for (i=0;i<kNTYPES;i++ ) {
3bd79107 611 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
612 if (fNctype) fNctype[i]=0;
613 }
614
615}
e8189707 616
3bd79107 617//____________________________________________
618void AliITS::ResetClusters(Int_t i)
619{
620 //
621 // Reset number of clusters and the clusters array for this branch
622 //
623 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
624 if (fNctype) fNctype[i]=0;
625
626}
627
628
629//____________________________________________
630void AliITS::ResetRecPoints()
631{
632 //
633 // Reset number of rec points and the rec points array
634 //
3bd79107 635 if (fRecPoints) fRecPoints->Clear();
9c74c52b 636 fNRecPoints = 0;
3bd79107 637
638}
639
640//_____________________________________________________________________________
58005f18 641Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
fe4da5cc 642 //
643 // Distance from mouse to ITS on the screen. Dummy routine
58005f18 644 // A dummy routine used by the ROOT macro display.C to allow for the
645 // use of the mouse (pointing device) in the macro. In general this should
646 // never be called. If it is it returns the number 9999 for any value of
647 // x and y.
fe4da5cc 648 //
649 return 9999;
650}
651
652//_____________________________________________________________________________
58005f18 653void AliITS::Init(){
fe4da5cc 654 //
655 // Initialise ITS after it has been built
58005f18 656 // This routine initializes the AliITS class. It is intended to be called
657 // from the Init function in AliITSv?. Besides displaying a banner
3bd79107 658 // indicating that it has been called it initializes the array fIdSens
659 // and sets the default segmentation, response, digit and raw cluster classes
58005f18 660 // Therefore it should be called after a call to CreateGeometry.
fe4da5cc 661 //
662 Int_t i;
143d1056 663
143d1056 664//
665 SetDefaults();
143d1056 666// Array of TStrings
58005f18 667 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
143d1056 668//
fe4da5cc 669}
670
671//_____________________________________________________________________________
3bd79107 672void AliITS::SetDefaults()
673{
674 // sets the default segmentation, response, digit and raw cluster classes
675
9e1a0ddb 676 if(fDebug) printf("%s: SetDefaults\n",ClassName());
3bd79107 677
678 AliITSDetType *iDetType;
679
65d4384f 680
3bd79107 681 //SPD
682
65d4384f 683 iDetType=DetType(0);
143d1056 684 if (!iDetType->GetSegmentationModel()) {
65d4384f 685 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
686 SetSegmentationModel(0,seg0);
687 }
688 if (!iDetType->GetResponseModel()) {
689 SetResponseModel(0,new AliITSresponseSPD());
690 }
3bd79107 691 // set digit and raw cluster classes to be used
65d4384f 692
693 const char *kData0=(iDetType->GetResponseModel())->DataType();
e8189707 694 if (strstr(kData0,"real")) {
3bd79107 695 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
696 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
697
65d4384f 698 // SDD //
699 iDetType=DetType(1);
700 if (!iDetType->GetResponseModel()) {
701 SetResponseModel(1,new AliITSresponseSDD());
702 }
703 AliITSresponse *resp1=iDetType->GetResponseModel();
143d1056 704 if (!iDetType->GetSegmentationModel()) {
65d4384f 705 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
143d1056 706 SetSegmentationModel(1,seg1);
143d1056 707 }
65d4384f 708 const char *kData1=(iDetType->GetResponseModel())->DataType();
709 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
e8189707 710 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
3bd79107 711 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
712 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
713
714 // SSD
65d4384f 715 iDetType=DetType(2);
143d1056 716 if (!iDetType->GetSegmentationModel()) {
65d4384f 717 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
143d1056 718 SetSegmentationModel(2,seg2);
65d4384f 719 }
720 if (!iDetType->GetResponseModel()) {
721 SetResponseModel(2,new AliITSresponseSSD());
722 }
723 const char *kData2=(iDetType->GetResponseModel())->DataType();
e8189707 724 if (strstr(kData2,"real")) {
3bd79107 725 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
726 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
727
a8a6107b 728 if (kNTYPES>3) {
3bd79107 729 Warning("SetDefaults","Only the three basic detector types are initialised!");
65d4384f 730 }
3bd79107 731
732}
3bd79107 733//_____________________________________________________________________________
e8189707 734void AliITS::SetDefaultSimulation()
735{
828e06c7 736 // sets the default simulation
737
738
739 AliITSDetType *iDetType;
740 iDetType=DetType(0);
741 if (!iDetType->GetSimulationModel()) {
742 AliITSsegmentation *seg0=
743 (AliITSsegmentation*)iDetType->GetSegmentationModel();
744 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
745 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
746 SetSimulationModel(0,sim0);
747 }
748 iDetType=DetType(1);
749 if (!iDetType->GetSimulationModel()) {
750 AliITSsegmentation *seg1=
751 (AliITSsegmentation*)iDetType->GetSegmentationModel();
752 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
753 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
754 SetSimulationModel(1,sim1);
755 }
756 iDetType=DetType(2);
757 if (!iDetType->GetSimulationModel()) {
758 AliITSsegmentation *seg2=
759 (AliITSsegmentation*)iDetType->GetSegmentationModel();
760 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
761 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
762 SetSimulationModel(2,sim2);
763 }
764
e8189707 765
766}
767//_____________________________________________________________________________
768void AliITS::SetDefaultClusterFinders()
769{
828e06c7 770 // sets the default cluster finders
771
772 MakeTreeC();
773 AliITSDetType *iDetType;
774 iDetType=DetType(0);
775 if (!iDetType->GetReconstructionModel()) {
776 AliITSsegmentation *seg0=
777 (AliITSsegmentation*)iDetType->GetSegmentationModel();
778 TClonesArray *dig0=DigitsAddress(0);
779 TClonesArray *recp0=ClustersAddress(0);
780 AliITSClusterFinderSPD *rec0=new AliITSClusterFinderSPD(seg0,dig0,recp0);
781 SetReconstructionModel(0,rec0);
782 }
783 iDetType=DetType(1);
784 if (!iDetType->GetReconstructionModel()) {
785 AliITSsegmentation *seg1=
786 (AliITSsegmentation*)iDetType->GetSegmentationModel();
787 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
788 TClonesArray *dig1=DigitsAddress(1);
789 TClonesArray *recp1=ClustersAddress(1);
790 AliITSClusterFinderSDD *rec1=
791 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
792
793 SetReconstructionModel(1,rec1);
794 }
795 iDetType=DetType(2);
796 if (!iDetType->GetReconstructionModel()) {
797 AliITSsegmentation *seg2=
798 (AliITSsegmentation*)iDetType->GetSegmentationModel();
799
800 TClonesArray *dig2=DigitsAddress(2);
801 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
802 SetReconstructionModel(2,rec2);
803 }
e8189707 804
805}
806//_____________________________________________________________________________
3bd79107 807
808void AliITS::MakeTreeC(Option_t *option)
809{
810 // create a separate tree to store the clusters
811
a3ec5900 812// cout << "AliITS::MakeTreeC" << endl;
9c74c52b 813
5cf7bbad 814 const char *optC = strstr(option,"C");
3bd79107 815 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
9c74c52b 816 else return;
3bd79107 817
828e06c7 818
3bd79107 819 Int_t buffersize = 4000;
820 char branchname[30];
821
04874c1a 822 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 823
caf37aec 824 char digclass[40];
825 char clclass[40];
826
3bd79107 827 // one branch for Clusters per type of detector
828 Int_t i;
a8a6107b 829 for (i=0; i<kNTYPES ;i++) {
cb26748d 830 AliITSDetType *iDetType=DetType(i);
831 iDetType->GetClassNames(digclass,clclass);
832 // clusters
833 fCtype->AddAt(new TClonesArray(clclass,1000),i);
a8a6107b 834 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
3bd79107 835 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
836 if (fCtype && fTreeC) {
837 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
a3ec5900 838// cout << "Making Branch " << branchname;
839// cout << " for Clusters of detector type " << i+1 << endl;
3bd79107 840 }
841 }
842
843}
844
845//_____________________________________________________________________________
846void AliITS::GetTreeC(Int_t event)
847{
848
a3ec5900 849// cout << "AliITS::GetTreeC" << endl;
9c74c52b 850
3bd79107 851 // get the clusters tree for this event and set the branch address
852 char treeName[20];
853 char branchname[30];
854
04874c1a 855 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 856
857 ResetClusters();
858 if (fTreeC) {
859 delete fTreeC;
860 }
861
862 sprintf(treeName,"TreeC%d",event);
863 fTreeC = (TTree*)gDirectory->Get(treeName);
864
3bd79107 865 TBranch *branch;
cb26748d 866
3bd79107 867 if (fTreeC) {
868 Int_t i;
cb26748d 869 char digclass[40];
870 char clclass[40];
a8a6107b 871 for (i=0; i<kNTYPES; i++) {
cb26748d 872
873 AliITSDetType *iDetType=DetType(i);
874 iDetType->GetClassNames(digclass,clclass);
875 // clusters
876 if(!(*fCtype)[i]) fCtype->AddAt(new TClonesArray(clclass,1000),i);
a8a6107b 877 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
e8189707 878 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
879 if (fCtype) {
3bd79107 880 branch = fTreeC->GetBranch(branchname);
881 if (branch) branch->SetAddress(&((*fCtype)[i]));
882 }
883 }
884 } else {
d5da1ecf 885 Error("AliITS::GetTreeC",
886 "cannot find Clusters Tree for event:%d\n",event);
3bd79107 887 }
888
889}
890//_____________________________________________________________________________
9e1a0ddb 891void AliITS::MakeBranch(Option_t* option, const char *file)
2ab0c725 892{
fe4da5cc 893 //
3bd79107 894 // Creates Tree branches for the ITS.
fe4da5cc 895 //
2ab0c725 896 //
fe4da5cc 897 Int_t buffersize = 4000;
3bd79107 898 char branchname[30];
fe4da5cc 899 sprintf(branchname,"%s",GetName());
900
2ab0c725 901 AliDetector::MakeBranch(option,file);
fe4da5cc 902
5cf7bbad 903 const char *cD = strstr(option,"D");
904 const char *cR = strstr(option,"R");
fe4da5cc 905
2ab0c725 906 if (cD) {
907 //
908 // one branch for digits per type of detector
909 //
04874c1a 910 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 911
e8189707 912 char digclass[40];
913 char clclass[40];
3bd79107 914
915 Int_t i;
a8a6107b 916 for (i=0; i<kNTYPES ;i++) {
cb26748d 917 DetType(i)->GetClassNames(digclass,clclass);
3bd79107 918 // digits
cb26748d 919 if(!((*fDtype)[i])) fDtype->AddAt(new TClonesArray(digclass,1000),i);
c34b4885 920 else ResetDigits(i);
3bd79107 921 }
922
a8a6107b 923 for (i=0; i<kNTYPES ;i++) {
924 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
2ab0c725 925 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
926 if (fDtype && gAlice->TreeD()) {
9e1a0ddb 927 MakeBranchInTree(gAlice->TreeD(),
c34b4885 928 branchname, &((*fDtype)[i]), buffersize, file);
a3ec5900 929// cout << "Making Branch " << branchname;
930// cout << " for digits of type "<< i+1 << endl;
3bd79107 931 }
2ab0c725 932 }
3bd79107 933 }
934
2ab0c725 935 if (cR) {
936 //
3bd79107 937 // only one branch for rec points for all detector types
2ab0c725 938 //
939 sprintf(branchname,"%sRecPoints",GetName());
940
cb26748d 941 //if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",1000);
3bd79107 942
2ab0c725 943 if (fRecPoints && gAlice->TreeR()) {
9e1a0ddb 944 MakeBranchInTree(gAlice->TreeR(),
2ab0c725 945 branchname, &fRecPoints, buffersize, file) ;
a3ec5900 946// cout << "Making Branch " << branchname;
947// cout << " for reconstructed space points" << endl;
2ab0c725 948 }
3bd79107 949 }
3bd79107 950}
951
952//___________________________________________
953void AliITS::SetTreeAddress()
954{
955
956 // Set branch address for the Trees.
957
cb26748d 958
3bd79107 959 char branchname[30];
960 AliDetector::SetTreeAddress();
961
04874c1a 962 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 963
964 TBranch *branch;
965 TTree *treeD = gAlice->TreeD();
966 TTree *treeR = gAlice->TreeR();
967
cb26748d 968 char digclass[40];
969 char clclass[40];
970
3bd79107 971 Int_t i;
972 if (treeD) {
a8a6107b 973 for (i=0; i<kNTYPES; i++) {
cb26748d 974 DetType(i)->GetClassNames(digclass,clclass);
975 // digits
976 if(!((*fDtype)[i])) fDtype->AddAt(new TClonesArray(digclass,1000),i);
977 else ResetDigits(i);
978
979 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
980 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
981 if (fDtype) {
982 branch = treeD->GetBranch(branchname);
983 if (branch) branch->SetAddress(&((*fDtype)[i]));
984 }
3bd79107 985 }
986 }
987
988
989 if (treeR) {
990 sprintf(branchname,"%sRecPoints",GetName());
3bd79107 991 branch = treeR->GetBranch(branchname);
992 if (branch) branch->SetAddress(&fRecPoints);
3bd79107 993 }
994
995
996}
997
998//____________________________________________________________________________
999void AliITS::InitModules(Int_t size,Int_t &nmodules){
1000
1001 //initialize the modules array
1002
e8189707 1003 if(fITSmodules){
9c74c52b 1004 fITSmodules->Delete();
e8189707 1005 delete fITSmodules;
1006 }
1007
3bd79107 1008 Int_t nl,indexMAX,index;
3bd79107 1009
1010 if(size<=0){ // default to using data stored in AliITSgeom
1011 if(fITSgeom==0) {
d5da1ecf 1012 Error("AliITS::InitModules",
1013 "in AliITS::InitModule fITSgeom not defined\n");
3bd79107 1014 return;
1015 } // end if fITSgeom==0
1016 nl = fITSgeom->GetNlayers();
1017 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
1018 fITSgeom->GetNdetectors(nl))+1;
1019 nmodules = indexMAX;
1020 fITSmodules = new TObjArray(indexMAX);
3bd79107 1021 for(index=0;index<indexMAX;index++){
3bd79107 1022 fITSmodules->AddAt( new AliITSmodule(index),index);
3bd79107 1023 } // end for index
1024 }else{
1025 fITSmodules = new TObjArray(size);
9c74c52b 1026 for(index=0;index<size;index++) {
1027 fITSmodules->AddAt( new AliITSmodule(index),index);
1028 }
1029
3bd79107 1030 nmodules = size;
1031 } // end i size<=0
1032}
1033
1034//____________________________________________________________________________
e8189707 1035void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
3bd79107 1036
1037 // fill the modules with the sorted by module hits; add hits from background
1038 // if option=Add
1039
9c74c52b 1040
3bd79107 1041 static TTree *trH1; //Tree with background hits
1042 static TClonesArray *fHits2; //List of hits for one track only
1043
1044 static Bool_t first=kTRUE;
1045 static TFile *file;
5cf7bbad 1046 const char *addBgr = strstr(option,"Add");
3bd79107 1047
1048
e8189707 1049 if (addBgr ) {
3bd79107 1050 if(first) {
a3ec5900 1051// cout<<"filename "<<filename<<endl;
3bd79107 1052 file=new TFile(filename);
a3ec5900 1053// cout<<"I have opened "<<filename<<" file "<<endl;
3bd79107 1054 fHits2 = new TClonesArray("AliITShit",1000 );
1055 }
1056 first=kFALSE;
1057 file->cd();
1058 file->ls();
1059 // Get Hits Tree header from file
1060 if(fHits2) fHits2->Clear();
1061 if(trH1) delete trH1;
1062 trH1=0;
1063
1064 char treeName[20];
1065 sprintf(treeName,"TreeH%d",bgrev);
1066 trH1 = (TTree*)gDirectory->Get(treeName);
1067 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
1068
1069 if (!trH1) {
d5da1ecf 1070 Error("AliITS::FillModules",
1071 "cannot find Hits Tree for event:%d\n",bgrev);
3bd79107 1072 }
1073 // Set branch addresses
1074 TBranch *branch;
1075 char branchname[20];
1076 sprintf(branchname,"%s",GetName());
1077 if (trH1 && fHits2) {
1078 branch = trH1->GetBranch(branchname);
1079 if (branch) branch->SetAddress(&fHits2);
1080 }
1081
1082 // test
1083 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
1084 //printf("background - ntracks1 - %d\n",ntracks1);
1085 }
1086
2ab0c725 1087 //Int_t npart = gAlice->GetEvent(evnt);
1088 //if(npart<=0) return;
3bd79107 1089 TClonesArray *itsHits = this->Hits();
1090 Int_t lay,lad,det,index;
1091 AliITShit *itsHit=0;
1092 AliITSmodule *mod=0;
1093
1094 TTree *iTH = gAlice->TreeH();
1095 Int_t ntracks =(Int_t) iTH->GetEntries();
1096
1097 Int_t t,h;
1098 for(t=0; t<ntracks; t++){
1099 gAlice->ResetHits();
1100 iTH->GetEvent(t);
1101 Int_t nhits = itsHits->GetEntriesFast();
9c74c52b 1102 //printf("nhits %d\n",nhits);
3bd79107 1103 if (!nhits) continue;
3bd79107 1104 for(h=0; h<nhits; h++){
1105 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
1106 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 1107 // temporarily index=det-1 !!!
1108 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1109 else index=det-1;
1110 //
3bd79107 1111 mod = this->GetModule(index);
9c74c52b 1112 mod->AddHit(itsHit,t,h);
3bd79107 1113 } // end loop over hits
1114 } // end loop over tracks
1115
1116 // open the file with background
1117
e8189707 1118 if (addBgr ) {
1119 Int_t track,i;
3bd79107 1120 ntracks =(Int_t)trH1->GetEntries();
1121 //printf("background - ntracks1 %d\n",ntracks);
1122 //printf("background - Start loop over tracks \n");
1123 // Loop over tracks
1124
e8189707 1125 for (track=0; track<ntracks; track++) {
3bd79107 1126
1127 if (fHits2) fHits2->Clear();
1128 trH1->GetEvent(track);
1129 // Loop over hits
1130 for(i=0;i<fHits2->GetEntriesFast();++i) {
1131
1132 itsHit=(AliITShit*) (*fHits2)[i];
1133 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 1134 // temporarily index=det-1 !!!
1135 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1136 else index=det-1;
1137 //
3bd79107 1138 mod = this->GetModule(index);
9c74c52b 1139 mod->AddHit(itsHit,track,i);
3bd79107 1140 } // end loop over hits
1141 } // end loop over tracks
1142
1143 TTree *fAli=gAlice->TreeK();
1144 TFile *fileAli=0;
1145
1146 if (fAli) fileAli =fAli->GetCurrentFile();
9c74c52b 1147 fileAli->cd();
3bd79107 1148
1149 } // end if add
1150
3bd79107 1151 //gObjectTable->Print();
1152
1153}
1154
2ab0c725 1155//____________________________________________________________________________
1156
1157void AliITS::SDigits2Digits()
1158{
2ab0c725 1159
2ab0c725 1160 cerr<<"Digitizing ITS...\n";
828e06c7 1161
2ab0c725 1162 TStopwatch timer;
1163 timer.Start();
828e06c7 1164 AliHeader *header=gAlice->GetHeader();
1165 HitsToDigits(header->GetEvent(),0,-1," ","All"," ");
2ab0c725 1166 timer.Stop(); timer.Print();
1167
2ab0c725 1168}
1169
3bd79107 1170
1171//____________________________________________________________________________
e8189707 1172void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
3bd79107 1173{
1174 // keep galice.root for signal and name differently the file for
1175 // background when add! otherwise the track info for signal will be lost !
1176
9c74c52b 1177 // the condition below will disappear when the geom class will be
1178 // initialised for all versions - for the moment it is only for v5 !
1179 // 7 is the SDD beam test version
1180 Int_t ver = this->IsVersion();
72de14c6 1181 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
9c74c52b 1182
5cf7bbad 1183 const char *all = strstr(opt,"All");
1184 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
828e06c7 1185
1186 static Bool_t setDef=kTRUE;
1187 if (setDef) SetDefaultSimulation();
1188 setDef=kFALSE;
1189
1190
a3ec5900 1191// cout<<" 1 AliITS "<<endl;
3bd79107 1192 Int_t nmodules;
1193 InitModules(size,nmodules);
a3ec5900 1194// cout<<" 2 AliITS "<<endl;
e8189707 1195 FillModules(evNumber,bgrev,nmodules,option,filename);
a3ec5900 1196// cout<<" 3 AliITS "<<endl;
3bd79107 1197
9c74c52b 1198 //TBranch *branch;
3bd79107 1199 AliITSsimulation* sim;
9c74c52b 1200 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
3bd79107 1201 AliITSgeom *geom = GetITSgeom();
1202
1203 Int_t id,module;
a3ec5900 1204// Int_t lay, lad, detect;
9c74c52b 1205 Int_t first,last;
a8a6107b 1206 for (id=0;id<kNTYPES;id++) {
3bd79107 1207 if (!all && !det[id]) continue;
9c74c52b 1208 //branch = (TBranch*)branches->UncheckedAt(id);
3bd79107 1209 AliITSDetType *iDetType=DetType(id);
1210 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
9c74c52b 1211 if(geom) {
1212 first = geom->GetStartDet(id);
1213 last = geom->GetLastDet(id);
1214 } else first=last=0;
828e06c7 1215 printf("first module - last module %d %d\n",first,last);
3bd79107 1216 for(module=first;module<=last;module++) {
1217 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1218 sim->DigitiseModule(mod,module,evNumber);
1219 // fills all branches - wasted disk space
1220 gAlice->TreeD()->Fill();
1221 ResetDigits();
1222 // try and fill only the branch
1223 //branch->Fill();
1224 //ResetDigits(id);
1225 } // loop over modules
1226 } // loop over detector types
1227
3bd79107 1228 ClearModules();
1229
a3ec5900 1230// Int_t nentries=(Int_t)
1231 gAlice->TreeD()->GetEntries();
1232// cout << "nentries in TreeD" << nentries << endl;
3bd79107 1233
1234 char hname[30];
1235 sprintf(hname,"TreeD%d",evNumber);
2ab0c725 1236 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
3bd79107 1237 // reset tree
1238 gAlice->TreeD()->Reset();
1239
1240}
1241
1242
828e06c7 1243//_____________________________________________________________________________
1244void AliITS::Digits2Reco()
1245{
1246 // find clusters and reconstruct space points
1247
1248 AliHeader *header=gAlice->GetHeader();
1249 printf("header->GetEvent() %d\n",header->GetEvent());
1250 DigitsToRecPoints(header->GetEvent(),0,"All");
1251
1252}
3bd79107 1253//____________________________________________________________________________
1254void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1255{
e8189707 1256 // cluster finding and reconstruction of space points
3bd79107 1257
9c74c52b 1258 // the condition below will disappear when the geom class will be
1259 // initialised for all versions - for the moment it is only for v5 !
1260 // 7 is the SDD beam test version
1261 Int_t ver = this->IsVersion();
04f91b7e 1262 if(ver!=5 && ver!=8 && ver!=9) return;
9c74c52b 1263
5cf7bbad 1264 const char *all = strstr(opt,"All");
1265 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
3bd79107 1266
828e06c7 1267 static Bool_t setRec=kTRUE;
1268 if (setRec) SetDefaultClusterFinders();
1269 setRec=kFALSE;
1270
caf37aec 1271
1272 TTree *treeC=TreeC();
3bd79107 1273
9c74c52b 1274
1275 //TBranch *branch;
3bd79107 1276 AliITSClusterFinder* rec;
1277
9c74c52b 1278 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
3bd79107 1279 AliITSgeom *geom = GetITSgeom();
1280
1281 Int_t id,module;
a8a6107b 1282 for (id=0;id<kNTYPES;id++) {
3bd79107 1283 if (!all && !det[id]) continue;
9c74c52b 1284 //branch = (TBranch*)branches->UncheckedAt(id);
3bd79107 1285 AliITSDetType *iDetType=DetType(id);
1286 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
3bd79107 1287 TClonesArray *itsDigits = this->DigitsAddress(id);
9c74c52b 1288 Int_t first,last;
1289 if(geom) {
1290 first = geom->GetStartDet(id);
1291 last = geom->GetLastDet(id);
1292 } else first=last=0;
34980f24 1293 printf("first module - last module %d %d\n",first,last);
3bd79107 1294 for(module=first;module<=last;module++) {
3bd79107 1295 this->ResetDigits();
1296 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1297 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1298 Int_t ndigits = itsDigits->GetEntriesFast();
a3ec5900 1299 if (ndigits) rec->FindRawClusters(module);
3bd79107 1300 gAlice->TreeR()->Fill();
1301 ResetRecPoints();
caf37aec 1302 treeC->Fill();
3bd79107 1303 ResetClusters();
1304 // try and fill only the branch
1305 //branch->Fill();
1306 //ResetRecPoints(id);
1307 } // loop over modules
1308 } // loop over detector types
1309
1310
a3ec5900 1311// Int_t nentries=(Int_t)
1312 gAlice->TreeR()->GetEntries();
1313// Int_t ncentries=(Int_t)
1314 treeC->GetEntries();
1315// cout << " nentries ncentries " << nentries << ncentries << endl;
3bd79107 1316
1317 char hname[30];
1318 sprintf(hname,"TreeR%d",evNumber);
2ab0c725 1319 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
3bd79107 1320 // reset tree
1321 gAlice->TreeR()->Reset();
1322
1323 sprintf(hname,"TreeC%d",evNumber);
caf37aec 1324 treeC->Write(hname,TObject::kOverwrite);
1325 treeC->Reset();
3bd79107 1326}
3bd79107 1327//____________________________________________________________________________
e8189707 1328void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
3bd79107 1329Option_t *option,Option_t *opt,Text_t *filename)
1330{
1331 // keep galice.root for signal and name differently the file for
1332 // background when add! otherwise the track info for signal will be lost !
1333
9c74c52b 1334
1335 // the condition below will disappear when the geom class will be
1336 // initialised for all versions - for the moment it is only for v5 !
1337 Int_t ver = this->IsVersion();
04f91b7e 1338 if(ver!=5 && ver!=8 && ver!=9) return;
828e06c7 1339
9c74c52b 1340
5cf7bbad 1341 const char *all = strstr(opt,"All");
1633a7ac 1342 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
3bd79107 1343
1344 Int_t nmodules;
e8189707 1345 InitModules(size,nmodules);
1346 FillModules(evNumber,bgrev,nmodules,option,filename);
3bd79107 1347
1348
e8189707 1349 AliITSsimulation* sim;
3bd79107 1350 AliITSgeom *geom = GetITSgeom();
1351
e8189707 1352 TRandom *random=new TRandom[9];
1353 random[0].SetSeed(111);
1354 random[1].SetSeed(222);
1355 random[2].SetSeed(333);
1356 random[3].SetSeed(444);
1357 random[4].SetSeed(555);
1358 random[5].SetSeed(666);
1359 random[6].SetSeed(777);
1360 random[7].SetSeed(888);
1361 random[8].SetSeed(999);
1362
1363
3bd79107 1364 Int_t id,module;
a8a6107b 1365 for (id=0;id<kNTYPES;id++) {
3bd79107 1366 if (!all && !det[id]) continue;
e8189707 1367 AliITSDetType *iDetType=DetType(id);
1368 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1369 if (!sim) {
1633a7ac 1370 Error("HitsToFastPoints",
1371 "The simulation class was not instantiated!");
e8189707 1372 exit(1);
1373 // or SetDefaultSimulation();
1374 }
34980f24 1375
1376 Int_t first,last;
1377 if(geom) {
1378 first = geom->GetStartDet(id);
1379 last = geom->GetLastDet(id);
1380 } else first=last=0;
1381 printf("first module - last module %d %d\n",first,last);
3bd79107 1382 for(module=first;module<=last;module++) {
1383 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
e8189707 1384 sim->CreateFastRecPoints(mod,module,random);
3bd79107 1385 gAlice->TreeR()->Fill();
1386 ResetRecPoints();
1387 } // loop over modules
1388 } // loop over detector types
1389
1390
1391 ClearModules();
1392
1393 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1394
1395 char hname[30];
1396 sprintf(hname,"TreeR%d",evNumber);
2ab0c725 1397 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
3bd79107 1398 // reset tree
1399 gAlice->TreeR()->Reset();
1400
e8189707 1401 delete [] random;
1402
828e06c7 1403
fe4da5cc 1404}