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