]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITS.cxx
Minor changes (R.Barbera)
[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$
34980f24 18Revision 1.49 2001/05/11 07:37:49 hristov
19Legacy lines commented
20
f1d439d9 21Revision 1.48 2001/05/10 18:14:25 barbera
22A typo corrected
23
04f91b7e 24Revision 1.47 2001/05/10 17:55:59 barbera
25Modified to create rec points also for PPR geometries
26
c44604f4 27Revision 1.46 2001/05/10 00:05:28 nilsen
28Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
29should probably be cleaned up to only check to make sure that fITSgeom has
30been properly defined.
31
72de14c6 32Revision 1.45 2001/05/01 22:35:48 nilsen
33Remove/commented a number of cout<< statements. and made change needed by
34SSD code.
35
a3ec5900 36Revision 1.44 2001/04/26 22:44:01 nilsen
37Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
38done properly in AliITSv???.cxx via SetDefaults.
39
686b2f43 40Revision 1.43 2001/04/26 13:22:52 barbera
41TMatrix and TVector elimininated to speed up the code
42
53e7090a 43Revision 1.42 2001/04/25 21:55:12 barbera
44Updated version to be compatible with actual verion of STEER and TPC
45
8ab89103 46Revision 1.41 2001/04/21 15:16:51 barbera
47Updated with the new SSD reconstruction code
48
fd61217e 49Revision 1.40 2001/03/17 15:07:06 mariana
50Update SDD response parameters
51
37de990d 52Revision 1.39 2001/03/12 17:45:32 hristov
53Changes needed on Sun with CC 5.0
54
5cf7bbad 55Revision 1.38 2001/03/07 14:04:51 barbera
56Some vector dimensions increased to cope with full events
57
54fcea18 58Revision 1.37 2001/03/07 12:36:35 barbera
59A change added in the tracking part to manage delta rays
60
4f06a953 61Revision 1.36 2001/03/02 19:44:11 barbera
62 modified to taking into account new version tracking v1
63
8af13b4b 64Revision 1.35 2001/02/28 18:16:46 mariana
65Make the code compatible with the new AliRun
66
340cd0d8 67Revision 1.34 2001/02/11 15:51:39 mariana
68Set protection in MakeBranch
69
c34b4885 70Revision 1.33 2001/02/10 22:26:39 mariana
71Move the initialization of the containers for raw clusters in MakeTreeC()
72
caf37aec 73Revision 1.32 2001/02/08 23:55:31 nilsen
74Removed fMajor/MinorVersion variables in favor of variables in derived classes.
75Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
76
04874c1a 77Revision 1.31 2001/02/02 23:57:28 nilsen
78Added include file that are no londer included in AliITSgeom.h
79
d953664a 80Revision 1.30 2001/01/30 09:23:13 hristov
81Streamers removed (R.Brun)
82
a8a6107b 83Revision 1.29 2001/01/26 20:01:09 hristov
84Major upgrade of AliRoot code
85
2ab0c725 86Revision 1.28 2000/12/18 14:02:00 barbera
87new version of the ITS tracking to take into account the new TPC track parametrization
88
cc6e75dd 89Revision 1.27 2000/12/08 13:49:27 barbera
90Hidden declaration in a for loop removed to be compliant with HP-UX compiler
91
c5b22044 92Revision 1.26 2000/11/27 13:12:13 barbera
93New version containing the files for tracking
94
55b5a0b3 95Revision 1.25 2000/11/12 22:38:05 barbera
96Added header file for the SPD Bari model
97
dfe2a93f 98Revision 1.24 2000/10/09 22:18:12 barbera
99Bug fixes from MAriana to le AliITStest.C run correctly
100
65d4384f 101Revision 1.23 2000/10/05 20:47:42 nilsen
102fixed dependencies of include files. Tryed but failed to get a root automaticly
103generates streamer function to work. Modified SetDefaults.
104
143d1056 105Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
106Needed to include stdlib.h
107
108=======
109Revision 1.22 2000/10/04 19:45:52 barbera
110Corrected by F. Carminati for v3.04
111
114da3a4 112Revision 1.21 2000/10/02 21:28:08 fca
113Removal of useless dependecies via forward declarations
114
94de3818 115Revision 1.20 2000/10/02 16:31:39 barbera
116General code clean-up
117
d5da1ecf 118Revision 1.9.2.14 2000/10/02 15:43:51 barbera
119General code clean-up (e.g., printf -> cout)
120
121Revision 1.19 2000/09/22 12:13:25 nilsen
122Patches and updates for fixes to this and other routines.
123
9c74c52b 124Revision 1.18 2000/07/12 05:32:20 fca
125Correcting several syntax problem with static members
126
b669392e 127Revision 1.17 2000/07/10 16:07:18 fca
128Release version of ITS code
129
3bd79107 130Revision 1.9.2.3 2000/02/02 13:42:09 barbera
131fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
132
133Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
134//fixed FillModule. Removed fi(fabs(xl)<dx....
135
136Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
137This is the version of the files after the merging done in December 1999.
138See the ReadMe110100.txt file for details
c9a71be1 139
1cedd08a 140Revision 1.9 1999/11/14 14:33:25 fca
141Correct problems with distructors and pointers, thanks to I.Hrivnacova
142
6c854497 143Revision 1.8 1999/09/29 09:24:19 fca
144Introduction of the Copyright and cvs Log
145
4c039060 146*/
147
fe4da5cc 148///////////////////////////////////////////////////////////////////////////////
58005f18 149//
150// An overview of the basic philosophy of the ITS code development
151// and analysis is show in the figure below.
fe4da5cc 152//Begin_Html
153/*
a92b2b7d 154<img src="picts/ITS/ITS_Analysis_schema.gif">
fe4da5cc 155</pre>
156<br clear=left>
157<font size=+2 color=red>
58005f18 158<p>Roberto Barbera is in charge of the ITS Offline code (1999).
fe4da5cc 159<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
160</font>
161<pre>
162*/
163//End_Html
58005f18 164//
165// AliITS. Inner Traking System base class.
166// This class contains the base procedures for the Inner Tracking System
167//
168//Begin_Html
169/*
a92b2b7d 170<img src="picts/ITS/AliITS_Class_Diagram.gif">
58005f18 171</pre>
172<br clear=left>
173<font size=+2 color=red>
174<p>This show the class diagram of the different elements that are part of
175the AliITS class.
176</font>
177<pre>
178*/
179//End_Html
180//
181// Version: 0
182// Written by Rene Brun, Federico Carminati, and Roberto Barbera
183//
184// Version: 1
185// Modified and documented by Bjorn S. Nilsen
186// July 11 1999
187//
3bd79107 188// Version: 2
189// Modified and documented by A. Bologna
190// October 18 1999
191//
58005f18 192// AliITS is the general base class for the ITS. Also see AliDetector for
193// futher information.
194//
fe4da5cc 195///////////////////////////////////////////////////////////////////////////////
d953664a 196#include <iostream.h>
197#include <iomanip.h>
198#include <fstream.h>
143d1056 199#include <stdlib.h>
fe4da5cc 200#include <TMath.h>
201#include <TRandom.h>
9c74c52b 202#include <TBranch.h>
fe4da5cc 203#include <TVector.h>
caf37aec 204#include <TClonesArray.h>
3bd79107 205#include <TROOT.h>
206#include <TObjectTable.h>
9c74c52b 207#include <TFile.h>
208#include <TTree.h>
d5da1ecf 209#include <TString.h>
4f06a953 210#include <TParticle.h>
3bd79107 211
bb8ac1e0 212
fe4da5cc 213#include "AliRun.h"
3bd79107 214#include "AliITS.h"
215#include "AliITSMap.h"
e8189707 216#include "AliITSDetType.h"
3bd79107 217#include "AliITSClusterFinder.h"
caf37aec 218//#include "AliITSsimulation.h"
219#include "AliITSsimulationSPD.h"
220#include "AliITSsimulationSDD.h"
221#include "AliITSsimulationSSD.h"
143d1056 222#include "AliITSresponse.h"
3bd79107 223#include "AliITSsegmentationSPD.h"
224#include "AliITSresponseSPD.h"
dfe2a93f 225#include "AliITSresponseSPDbari.h"
3bd79107 226#include "AliITSsegmentationSDD.h"
227#include "AliITSresponseSDD.h"
228#include "AliITSsegmentationSSD.h"
229#include "AliITSresponseSSD.h"
9c74c52b 230#include "AliITShit.h"
231#include "AliITSgeom.h"
232#include "AliITSdigit.h"
233#include "AliITSmodule.h"
234#include "AliITSRecPoint.h"
235#include "AliITSRawCluster.h"
94de3818 236#include "AliMC.h"
114da3a4 237#include "stdlib.h"
8ab89103 238#include "AliKalmanTrack.h"
239#include "AliMagF.h"
e8189707 240
55b5a0b3 241#include "AliITStrack.h"
242#include "AliITSiotrack.h"
8af13b4b 243#include "AliITStracking.h"
244#include "AliITSRad.h"
55b5a0b3 245#include "../TPC/AliTPC.h"
246#include "../TPC/AliTPCParam.h"
247
c9a71be1 248
3bd79107 249ClassImp(AliITS)
250
fe4da5cc 251//_____________________________________________________________________________
3bd79107 252AliITS::AliITS() : AliDetector() {
fe4da5cc 253 //
254 // Default initialiser for ITS
58005f18 255 // The default constructor of the AliITS class. In addition to
256 // creating the AliITS class it zeros the variables fIshunt (a member
257 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
3bd79107 258 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
259 // is also called.
fe4da5cc 260 //
3bd79107 261
9c74c52b 262
58005f18 263 fIshunt = 0;
264 fEuclidOut = 0;
e8189707 265
a8a6107b 266 fNDetTypes = kNTYPES;
58005f18 267 fIdN = 0;
268 fIdName = 0;
269 fIdSens = 0;
6c854497 270 fITSmodules = 0;
3bd79107 271 //
272 fDetTypes = 0;
3bd79107 273 //
274 fDtype = 0;
275 fNdtype = 0;
276 fCtype = 0;
277 fNctype = 0;
278 fRecPoints = 0;
279 fNRecPoints = 0;
e8189707 280 fTreeC = 0;
3bd79107 281 //
282 fITSgeom=0;
fe4da5cc 283}
3bd79107 284
fe4da5cc 285//_____________________________________________________________________________
58005f18 286AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
fe4da5cc 287 //
288 // Default initialiser for ITS
58005f18 289 // The constructor of the AliITS class. In addition to creating the
290 // AliITS class, it allocates memory for the TClonesArrays fHits and
291 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
292 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
293 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
294 // macro display.C AliITS also sets the marker color to red. The variables
295 // passes with this constructor, const char *name and *title, are used by
296 // the constructor of AliDetector class. See AliDetector class for a
297 // description of these parameters and its constructor functions.
fe4da5cc 298 //
58005f18 299
9c74c52b 300
58005f18 301 fHits = new TClonesArray("AliITShit", 1560);
1cedd08a 302 gAlice->AddHitList(fHits);
3bd79107 303
a8a6107b 304 fNDetTypes = kNTYPES;
e8189707 305
a8a6107b 306 fNdtype = new Int_t[kNTYPES];
307 fDtype = new TObjArray(kNTYPES);
e8189707 308
a8a6107b 309 fNctype = new Int_t[kNTYPES];
310 fCtype = new TObjArray(kNTYPES);
3bd79107 311
3bd79107 312
313 fRecPoints = 0;
314 fNRecPoints = 0;
315
e8189707 316 fTreeC = 0;
3bd79107 317
318 fITSmodules = 0;
58005f18 319
320 fIshunt = 0;
321 fEuclidOut = 0;
322 fIdN = 0;
323 fIdName = 0;
324 fIdSens = 0;
3bd79107 325
a8a6107b 326 fDetTypes = new TObjArray(kNTYPES);
3bd79107 327
328 Int_t i;
a8a6107b 329 for(i=0;i<kNTYPES;i++) {
3bd79107 330 (*fDetTypes)[i]=new AliITSDetType();
e8189707 331 fNdtype[i]=0;
332 fNctype[i]=0;
3bd79107 333 }
334 //
58005f18 335
fe4da5cc 336 SetMarkerColor(kRed);
58005f18 337
3bd79107 338 fITSgeom=0;
339}
340//___________________________________________________________________________
341AliITS::AliITS(AliITS &source){
e8189707 342 // copy constructor
3bd79107 343 if(this==&source) return;
d5da1ecf 344 Error("AliITS::Copy constructor",
345 "You are not allowed to make a copy of the AliITS");
3bd79107 346 exit(1);
fe4da5cc 347}
3bd79107 348//____________________________________________________________________________
349AliITS& AliITS::operator=(AliITS &source){
e8189707 350 // assignment operator
3bd79107 351 if(this==&source) return *this;
d5da1ecf 352 Error("AliITS::operator=",
353 "You are not allowed to make a copy of the AliITS");
3bd79107 354 exit(1);
e8189707 355 return *this; //fake return
3bd79107 356}
357//____________________________________________________________________________
358void AliITS::ClearModules(){
359 //clear the modules TObjArray
3bd79107 360
9c74c52b 361 if(fITSmodules) fITSmodules->Delete();
fe4da5cc 362
3bd79107 363}
fe4da5cc 364//_____________________________________________________________________________
58005f18 365AliITS::~AliITS(){
fe4da5cc 366 //
367 // Default distructor for ITS
58005f18 368 // The default destructor of the AliITS class. In addition to deleting
369 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
370 // fIdSens, fIdName, and fITSpoints.
fe4da5cc 371 //
3bd79107 372
373
fe4da5cc 374 delete fHits;
375 delete fDigits;
3bd79107 376 delete fRecPoints;
143d1056 377// delete fIdName; // TObjArray of TObjStrings
378 if(fIdName!=0) delete[] fIdName; // Array of TStrings
58005f18 379 if(fIdSens!=0) delete[] fIdSens;
3bd79107 380 if(fITSmodules!=0) {
381 this->ClearModules();
382 delete fITSmodules;
383 }// end if fITSmodules!=0
fe4da5cc 384
fe4da5cc 385 //
3bd79107 386 if(fDtype) {
9c74c52b 387 fDtype->Delete();
388 delete fDtype;
3bd79107 389 }
9c74c52b 390 delete [] fNdtype;
391 if (fCtype) {
392 fCtype->Delete();
393 delete fCtype;
3bd79107 394 }
9c74c52b 395 delete [] fNctype;
fe4da5cc 396 //
3bd79107 397
398 if (fDetTypes) {
399 fDetTypes->Delete();
400 delete fDetTypes;
401 }
402
403 if (fTreeC) delete fTreeC;
e8189707 404
9c74c52b 405 if (fITSgeom) delete fITSgeom;
406
3bd79107 407}
408
409//___________________________________________
410AliITSDetType* AliITS::DetType(Int_t id)
411{
412 //return pointer to id detector type
413 return ((AliITSDetType*) (*fDetTypes)[id]);
414
415}
416//___________________________________________
e8189707 417void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
3bd79107 418{
419 //set the digit and cluster classes to be used for the id detector type
420 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
421
422}
423//___________________________________________
424void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
425{
426 //set the response model for the id detector type
427
428 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
429
fe4da5cc 430}
431
3bd79107 432//___________________________________________
433void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
434{
435 //set the segmentation model for the id detector type
436
437 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
438
439}
440
441//___________________________________________
442void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
443{
444 //set the simulation model for the id detector type
445
446 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
447
448}
449//___________________________________________
450void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
451{
452 //set the cluster finder model for the id detector type
453
454 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
58005f18 455
58005f18 456}
457
fe4da5cc 458//_____________________________________________________________________________
58005f18 459void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
fe4da5cc 460 //
461 // Add an ITS hit
58005f18 462 // The function to add information to the AliITShit class. See the
463 // AliITShit class for a full description. This function allocates the
464 // necessary new space for the hit information and passes the variable
465 // track, and the pointers *vol and *hits to the AliITShit constructor
466 // function.
fe4da5cc 467 //
468 TClonesArray &lhits = *fHits;
469 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
470}
3bd79107 471//_____________________________________________________________________________
472void AliITS::AddRealDigit(Int_t id, Int_t *digits)
473{
474 // add a real digit - as coming from data
475
476 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
477 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
478
479}
480//_____________________________________________________________________________
e8189707 481void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
3bd79107 482{
483
484 // add a simulated digit
485
3bd79107 486 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
487
488 switch(id)
489 {
490 case 0:
491 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
492 break;
493 case 1:
494 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
495 break;
496 case 2:
497 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
498 break;
499 }
500
501}
502
503//_____________________________________________________________________________
e8189707 504void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
3bd79107 505
506 // add a simulated digit to the list
507
508 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
509 switch(id)
510 {
511 case 0:
e8189707 512 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
3bd79107 513 break;
514 case 1:
e8189707 515 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
3bd79107 516 break;
517 case 2:
e8189707 518 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
3bd79107 519 break;
520 }
521
522}
523
524//_____________________________________________________________________________
525void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
526{
527
528 // add a cluster to the list
529
3bd79107 530 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
531
532 switch(id)
533 {
534 case 0:
535 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
536 break;
537 case 1:
538 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
539 break;
540 case 2:
541 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
542 break;
543 }
544
545}
546
547
548//_____________________________________________________________________________
549void AliITS::AddRecPoint(const AliITSRecPoint &r)
550{
551 //
552 // Add a reconstructed space point to the list
553 //
554 TClonesArray &lrecp = *fRecPoints;
555 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
556}
557
558
559//____________________________________________
560void AliITS::ResetDigits()
561{
562 //
9c74c52b 563 // Reset number of digits and the digits array for the ITS detector
3bd79107 564 //
565
566 if (!fDtype) return;
567
568 Int_t i;
a8a6107b 569 for (i=0;i<kNTYPES;i++ ) {
3bd79107 570 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
571 if (fNdtype) fNdtype[i]=0;
572 }
573}
574
575//____________________________________________
576void AliITS::ResetDigits(Int_t i)
577{
578 //
579 // Reset number of digits and the digits array for this branch
580 //
e8189707 581 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
582 if (fNdtype) fNdtype[i]=0;
3bd79107 583}
e8189707 584
585
3bd79107 586//____________________________________________
587void AliITS::ResetClusters()
588{
589 //
590 // Reset number of clusters and the clusters array for ITS
591 //
592
593 Int_t i;
a8a6107b 594 for (i=0;i<kNTYPES;i++ ) {
3bd79107 595 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
596 if (fNctype) fNctype[i]=0;
597 }
598
599}
e8189707 600
3bd79107 601//____________________________________________
602void AliITS::ResetClusters(Int_t i)
603{
604 //
605 // Reset number of clusters and the clusters array for this branch
606 //
607 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
608 if (fNctype) fNctype[i]=0;
609
610}
611
612
613//____________________________________________
614void AliITS::ResetRecPoints()
615{
616 //
617 // Reset number of rec points and the rec points array
618 //
3bd79107 619 if (fRecPoints) fRecPoints->Clear();
9c74c52b 620 fNRecPoints = 0;
3bd79107 621
622}
623
fe4da5cc 624//_____________________________________________________________________________
58005f18 625Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
fe4da5cc 626 //
627 // Distance from mouse to ITS on the screen. Dummy routine
58005f18 628 // A dummy routine used by the ROOT macro display.C to allow for the
629 // use of the mouse (pointing device) in the macro. In general this should
630 // never be called. If it is it returns the number 9999 for any value of
631 // x and y.
fe4da5cc 632 //
633 return 9999;
634}
635
636//_____________________________________________________________________________
58005f18 637void AliITS::Init(){
fe4da5cc 638 //
639 // Initialise ITS after it has been built
58005f18 640 // This routine initializes the AliITS class. It is intended to be called
641 // from the Init function in AliITSv?. Besides displaying a banner
3bd79107 642 // indicating that it has been called it initializes the array fIdSens
643 // and sets the default segmentation, response, digit and raw cluster classes
58005f18 644 // Therefore it should be called after a call to CreateGeometry.
fe4da5cc 645 //
646 Int_t i;
143d1056 647
143d1056 648//
649 SetDefaults();
143d1056 650// Array of TStrings
58005f18 651 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
143d1056 652//
fe4da5cc 653}
654
3bd79107 655//_____________________________________________________________________________
656void AliITS::SetDefaults()
657{
658 // sets the default segmentation, response, digit and raw cluster classes
659
65d4384f 660 printf("SetDefaults\n");
3bd79107 661
662 AliITSDetType *iDetType;
663
65d4384f 664
3bd79107 665 //SPD
666
65d4384f 667 iDetType=DetType(0);
143d1056 668 if (!iDetType->GetSegmentationModel()) {
65d4384f 669 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
670 SetSegmentationModel(0,seg0);
671 }
672 if (!iDetType->GetResponseModel()) {
673 SetResponseModel(0,new AliITSresponseSPD());
674 }
3bd79107 675 // set digit and raw cluster classes to be used
65d4384f 676
677 const char *kData0=(iDetType->GetResponseModel())->DataType();
e8189707 678 if (strstr(kData0,"real")) {
3bd79107 679 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
680 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
681
65d4384f 682 // SDD //
683 iDetType=DetType(1);
684 if (!iDetType->GetResponseModel()) {
685 SetResponseModel(1,new AliITSresponseSDD());
686 }
687 AliITSresponse *resp1=iDetType->GetResponseModel();
143d1056 688 if (!iDetType->GetSegmentationModel()) {
65d4384f 689 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
143d1056 690 SetSegmentationModel(1,seg1);
143d1056 691 }
65d4384f 692 const char *kData1=(iDetType->GetResponseModel())->DataType();
693 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
e8189707 694 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
3bd79107 695 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
696 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
697
698 // SSD
65d4384f 699 iDetType=DetType(2);
143d1056 700 if (!iDetType->GetSegmentationModel()) {
65d4384f 701 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
143d1056 702 SetSegmentationModel(2,seg2);
65d4384f 703 }
704 if (!iDetType->GetResponseModel()) {
705 SetResponseModel(2,new AliITSresponseSSD());
706 }
707 const char *kData2=(iDetType->GetResponseModel())->DataType();
e8189707 708 if (strstr(kData2,"real")) {
3bd79107 709 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
710 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
711
a8a6107b 712 if (kNTYPES>3) {
3bd79107 713 Warning("SetDefaults","Only the three basic detector types are initialised!");
65d4384f 714 }
3bd79107 715
716}
65d4384f 717
718
719
e8189707 720//_____________________________________________________________________________
721void AliITS::SetDefaultSimulation()
722{
723 // to be written
724
725}
726//_____________________________________________________________________________
727void AliITS::SetDefaultClusterFinders()
728{
729 // to be written
730
731}
3bd79107 732//_____________________________________________________________________________
733
734void AliITS::MakeTreeC(Option_t *option)
735{
736 // create a separate tree to store the clusters
737
a3ec5900 738// cout << "AliITS::MakeTreeC" << endl;
9c74c52b 739
5cf7bbad 740 const char *optC = strstr(option,"C");
3bd79107 741 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
9c74c52b 742 else return;
3bd79107 743
744 Int_t buffersize = 4000;
745 char branchname[30];
746
04874c1a 747 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 748
caf37aec 749 char digclass[40];
750 char clclass[40];
751
3bd79107 752 // one branch for Clusters per type of detector
753 Int_t i;
a8a6107b 754 for (i=0; i<kNTYPES ;i++) {
caf37aec 755 AliITSDetType *iDetType=DetType(i);
756 iDetType->GetClassNames(digclass,clclass);
caf37aec 757 // clusters
758 (*fCtype)[i] = new TClonesArray(clclass,10000);
a8a6107b 759 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
3bd79107 760 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
761 if (fCtype && fTreeC) {
762 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
a3ec5900 763// cout << "Making Branch " << branchname;
764// cout << " for Clusters of detector type " << i+1 << endl;
3bd79107 765 }
766 }
767
768}
769
770//_____________________________________________________________________________
771void AliITS::GetTreeC(Int_t event)
772{
773
a3ec5900 774// cout << "AliITS::GetTreeC" << endl;
9c74c52b 775
3bd79107 776 // get the clusters tree for this event and set the branch address
777 char treeName[20];
778 char branchname[30];
779
04874c1a 780 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 781
782 ResetClusters();
783 if (fTreeC) {
784 delete fTreeC;
785 }
786
787 sprintf(treeName,"TreeC%d",event);
788 fTreeC = (TTree*)gDirectory->Get(treeName);
789
3bd79107 790 TBranch *branch;
791 if (fTreeC) {
792 Int_t i;
a8a6107b 793 for (i=0; i<kNTYPES; i++) {
794 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
e8189707 795 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
796 if (fCtype) {
3bd79107 797 branch = fTreeC->GetBranch(branchname);
798 if (branch) branch->SetAddress(&((*fCtype)[i]));
799 }
800 }
801 } else {
d5da1ecf 802 Error("AliITS::GetTreeC",
803 "cannot find Clusters Tree for event:%d\n",event);
3bd79107 804 }
805
806}
fe4da5cc 807//_____________________________________________________________________________
2ab0c725 808void AliITS::MakeBranch(Option_t* option, char *file)
809{
fe4da5cc 810 //
3bd79107 811 // Creates Tree branches for the ITS.
fe4da5cc 812 //
2ab0c725 813 //
fe4da5cc 814 Int_t buffersize = 4000;
3bd79107 815 char branchname[30];
fe4da5cc 816 sprintf(branchname,"%s",GetName());
817
2ab0c725 818 AliDetector::MakeBranch(option,file);
fe4da5cc 819
5cf7bbad 820 const char *cD = strstr(option,"D");
821 const char *cR = strstr(option,"R");
fe4da5cc 822
2ab0c725 823 if (cD) {
824 //
825 // one branch for digits per type of detector
826 //
04874c1a 827 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 828
e8189707 829 char digclass[40];
830 char clclass[40];
3bd79107 831
832 Int_t i;
a8a6107b 833 for (i=0; i<kNTYPES ;i++) {
3bd79107 834 AliITSDetType *iDetType=DetType(i);
e8189707 835 iDetType->GetClassNames(digclass,clclass);
3bd79107 836 // digits
c34b4885 837 if(!((*fDtype)[i])) (*fDtype)[i] = new TClonesArray(digclass,10000);
838 else ResetDigits(i);
3bd79107 839 }
840
a8a6107b 841 for (i=0; i<kNTYPES ;i++) {
842 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
2ab0c725 843 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
844 if (fDtype && gAlice->TreeD()) {
845 gAlice->MakeBranchInTree(gAlice->TreeD(),
c34b4885 846 branchname, &((*fDtype)[i]), buffersize, file);
a3ec5900 847// cout << "Making Branch " << branchname;
848// cout << " for digits of type "<< i+1 << endl;
3bd79107 849 }
2ab0c725 850 }
3bd79107 851 }
852
2ab0c725 853 if (cR) {
854 //
3bd79107 855 // only one branch for rec points for all detector types
2ab0c725 856 //
857 sprintf(branchname,"%sRecPoints",GetName());
858
340cd0d8 859 if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",10000);
3bd79107 860
2ab0c725 861 if (fRecPoints && gAlice->TreeR()) {
862 gAlice->MakeBranchInTree(gAlice->TreeR(),
863 branchname, &fRecPoints, buffersize, file) ;
a3ec5900 864// cout << "Making Branch " << branchname;
865// cout << " for reconstructed space points" << endl;
2ab0c725 866 }
3bd79107 867 }
3bd79107 868}
869
870//___________________________________________
871void AliITS::SetTreeAddress()
872{
873
874 // Set branch address for the Trees.
875
876 char branchname[30];
877 AliDetector::SetTreeAddress();
878
04874c1a 879 const char *det[3] = {"SPD","SDD","SSD"};
3bd79107 880
881 TBranch *branch;
882 TTree *treeD = gAlice->TreeD();
883 TTree *treeR = gAlice->TreeR();
884
885 Int_t i;
886 if (treeD) {
a8a6107b 887 for (i=0; i<kNTYPES; i++) {
888 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
3bd79107 889 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
890 if (fDtype) {
891 branch = treeD->GetBranch(branchname);
892 if (branch) branch->SetAddress(&((*fDtype)[i]));
893 }
894 }
895 }
896
897
898 if (treeR) {
899 sprintf(branchname,"%sRecPoints",GetName());
3bd79107 900 branch = treeR->GetBranch(branchname);
901 if (branch) branch->SetAddress(&fRecPoints);
3bd79107 902 }
903
904
905}
906
907//____________________________________________________________________________
908void AliITS::InitModules(Int_t size,Int_t &nmodules){
909
910 //initialize the modules array
911
e8189707 912 if(fITSmodules){
9c74c52b 913 fITSmodules->Delete();
e8189707 914 delete fITSmodules;
915 }
916
3bd79107 917 Int_t nl,indexMAX,index;
3bd79107 918
919 if(size<=0){ // default to using data stored in AliITSgeom
920 if(fITSgeom==0) {
d5da1ecf 921 Error("AliITS::InitModules",
922 "in AliITS::InitModule fITSgeom not defined\n");
3bd79107 923 return;
924 } // end if fITSgeom==0
925 nl = fITSgeom->GetNlayers();
926 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
927 fITSgeom->GetNdetectors(nl))+1;
928 nmodules = indexMAX;
929 fITSmodules = new TObjArray(indexMAX);
3bd79107 930 for(index=0;index<indexMAX;index++){
3bd79107 931 fITSmodules->AddAt( new AliITSmodule(index),index);
3bd79107 932 } // end for index
933 }else{
934 fITSmodules = new TObjArray(size);
9c74c52b 935 for(index=0;index<size;index++) {
936 fITSmodules->AddAt( new AliITSmodule(index),index);
937 }
938
3bd79107 939 nmodules = size;
940 } // end i size<=0
941}
942
943//____________________________________________________________________________
e8189707 944void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
3bd79107 945
946 // fill the modules with the sorted by module hits; add hits from background
947 // if option=Add
948
9c74c52b 949
3bd79107 950 static TTree *trH1; //Tree with background hits
951 static TClonesArray *fHits2; //List of hits for one track only
952
953 static Bool_t first=kTRUE;
954 static TFile *file;
5cf7bbad 955 const char *addBgr = strstr(option,"Add");
3bd79107 956
957
e8189707 958 if (addBgr ) {
3bd79107 959 if(first) {
a3ec5900 960// cout<<"filename "<<filename<<endl;
3bd79107 961 file=new TFile(filename);
a3ec5900 962// cout<<"I have opened "<<filename<<" file "<<endl;
3bd79107 963 fHits2 = new TClonesArray("AliITShit",1000 );
964 }
965 first=kFALSE;
966 file->cd();
967 file->ls();
968 // Get Hits Tree header from file
969 if(fHits2) fHits2->Clear();
970 if(trH1) delete trH1;
971 trH1=0;
972
973 char treeName[20];
974 sprintf(treeName,"TreeH%d",bgrev);
975 trH1 = (TTree*)gDirectory->Get(treeName);
976 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
977
978 if (!trH1) {
d5da1ecf 979 Error("AliITS::FillModules",
980 "cannot find Hits Tree for event:%d\n",bgrev);
3bd79107 981 }
982 // Set branch addresses
983 TBranch *branch;
984 char branchname[20];
985 sprintf(branchname,"%s",GetName());
986 if (trH1 && fHits2) {
987 branch = trH1->GetBranch(branchname);
988 if (branch) branch->SetAddress(&fHits2);
989 }
990
991 // test
992 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
993 //printf("background - ntracks1 - %d\n",ntracks1);
994 }
995
2ab0c725 996 //Int_t npart = gAlice->GetEvent(evnt);
997 //if(npart<=0) return;
3bd79107 998 TClonesArray *itsHits = this->Hits();
999 Int_t lay,lad,det,index;
1000 AliITShit *itsHit=0;
1001 AliITSmodule *mod=0;
1002
1003 TTree *iTH = gAlice->TreeH();
1004 Int_t ntracks =(Int_t) iTH->GetEntries();
1005
1006 Int_t t,h;
1007 for(t=0; t<ntracks; t++){
1008 gAlice->ResetHits();
1009 iTH->GetEvent(t);
1010 Int_t nhits = itsHits->GetEntriesFast();
9c74c52b 1011 //printf("nhits %d\n",nhits);
3bd79107 1012 if (!nhits) continue;
3bd79107 1013 for(h=0; h<nhits; h++){
1014 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
1015 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 1016 // temporarily index=det-1 !!!
1017 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1018 else index=det-1;
1019 //
3bd79107 1020 mod = this->GetModule(index);
9c74c52b 1021 mod->AddHit(itsHit,t,h);
3bd79107 1022 } // end loop over hits
1023 } // end loop over tracks
1024
1025 // open the file with background
1026
e8189707 1027 if (addBgr ) {
1028 Int_t track,i;
3bd79107 1029 ntracks =(Int_t)trH1->GetEntries();
1030 //printf("background - ntracks1 %d\n",ntracks);
1031 //printf("background - Start loop over tracks \n");
1032 // Loop over tracks
1033
e8189707 1034 for (track=0; track<ntracks; track++) {
3bd79107 1035
1036 if (fHits2) fHits2->Clear();
1037 trH1->GetEvent(track);
1038 // Loop over hits
1039 for(i=0;i<fHits2->GetEntriesFast();++i) {
1040
1041 itsHit=(AliITShit*) (*fHits2)[i];
1042 itsHit->GetDetectorID(lay,lad,det);
9c74c52b 1043 // temporarily index=det-1 !!!
1044 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1045 else index=det-1;
1046 //
3bd79107 1047 mod = this->GetModule(index);
9c74c52b 1048 mod->AddHit(itsHit,track,i);
3bd79107 1049 } // end loop over hits
1050 } // end loop over tracks
1051
1052 TTree *fAli=gAlice->TreeK();
1053 TFile *fileAli=0;
1054
1055 if (fAli) fileAli =fAli->GetCurrentFile();
9c74c52b 1056 fileAli->cd();
3bd79107 1057
1058 } // end if add
1059
3bd79107 1060 //gObjectTable->Print();
1061
1062}
1063
2ab0c725 1064//____________________________________________________________________________
1065
1066void AliITS::SDigits2Digits()
1067{
1068
1069 AliITSgeom *geom = GetITSgeom();
1070
1071 // SPD
1072 AliITSDetType *iDetType;
1073 iDetType=DetType(0);
1074 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
1075 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
1076 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
1077 SetSimulationModel(0,sim0);
1078 // test
1079 // printf("SPD dimensions %f %f \n",seg0->Dx(),seg0->Dz());
1080 // printf("SPD npixels %d %d \n",seg0->Npz(),seg0->Npx());
1081 // printf("SPD pitches %d %d \n",seg0->Dpz(0),seg0->Dpx(0));
1082 // end test
1083 //
1084 // SDD
1085 //Set response functions
2ab0c725 1086 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
1087
1088 iDetType=DetType(1);
1089 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
1090 if (!res1) {
1091 res1=new AliITSresponseSDD();
1092 SetResponseModel(1,res1);
1093 }
37de990d 1094 Float_t noise, baseline;
1095 res1->GetNoiseParam(noise,baseline);
1096 Float_t noise_after_el = res1->GetNoiseAfterElectronics();
1097 Float_t fCutAmp = baseline + 2.*noise_after_el;
1098 Int_t cp[8]={0,0,(int)fCutAmp,(int)fCutAmp,0,0,0,0}; //1D
2ab0c725 1099 res1->SetCompressParam(cp);
2ab0c725 1100 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
1101 if (!seg1) {
1102 seg1 = new AliITSsegmentationSDD(geom,res1);
1103 SetSegmentationModel(1,seg1);
1104 }
1105 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
2ab0c725 1106 SetSimulationModel(1,sim1);
1107
1108 // SSD
1109 iDetType=DetType(2);
1110 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
1111 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
1112 res2->SetSigmaSpread(3.,2.);
1113 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
1114 SetSimulationModel(2,sim2);
1115
1116 cerr<<"Digitizing ITS...\n";
1117
1118 TStopwatch timer;
1119 timer.Start();
1120 HitsToDigits(0,0,-1," ","All"," ");
1121 timer.Stop(); timer.Print();
1122
1123 delete sim0;
1124 delete sim1;
1125 delete sim2;
1126}
1127
3bd79107 1128
1129//____________________________________________________________________________
e8189707 1130void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
3bd79107 1131{
1132 // keep galice.root for signal and name differently the file for
1133 // background when add! otherwise the track info for signal will be lost !
1134
9c74c52b 1135 // the condition below will disappear when the geom class will be
1136 // initialised for all versions - for the moment it is only for v5 !
1137 // 7 is the SDD beam test version
1138 Int_t ver = this->IsVersion();
72de14c6 1139 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
9c74c52b 1140
5cf7bbad 1141 const char *all = strstr(opt,"All");
1142 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
a3ec5900 1143// cout<<" 1 AliITS "<<endl;
3bd79107 1144 Int_t nmodules;
1145 InitModules(size,nmodules);
a3ec5900 1146// cout<<" 2 AliITS "<<endl;
e8189707 1147 FillModules(evNumber,bgrev,nmodules,option,filename);
a3ec5900 1148// cout<<" 3 AliITS "<<endl;
3bd79107 1149
9c74c52b 1150 //TBranch *branch;
3bd79107 1151 AliITSsimulation* sim;
9c74c52b 1152 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
3bd79107 1153 AliITSgeom *geom = GetITSgeom();
1154
1155 Int_t id,module;
a3ec5900 1156// Int_t lay, lad, detect;
9c74c52b 1157 Int_t first,last;
a8a6107b 1158 for (id=0;id<kNTYPES;id++) {
3bd79107 1159 if (!all && !det[id]) continue;
9c74c52b 1160 //branch = (TBranch*)branches->UncheckedAt(id);
3bd79107 1161 AliITSDetType *iDetType=DetType(id);
1162 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
fd61217e 1163
3bd79107 1164 if (!sim) {
1165 Error("HitsToDigits","The simulation class was not instantiated!");
1166 exit(1);
e8189707 1167 // or SetDefaultSimulation();
3bd79107 1168 }
fd61217e 1169
9c74c52b 1170 if(geom) {
1171 first = geom->GetStartDet(id);
1172 last = geom->GetLastDet(id);
1173 } else first=last=0;
a3ec5900 1174// cout << "det type " << id << " first, last "<< first << last << endl;
3bd79107 1175 for(module=first;module<=last;module++) {
1176 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
a3ec5900 1177/*
fd61217e 1178 geom->GetModuleId(module,lay, lad, detect);
a3ec5900 1179 if ( lay == 6 )
fd61217e 1180 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(6);
1181 if ( lay == 5 )
1182 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(5);
686b2f43 1183*/
3bd79107 1184 sim->DigitiseModule(mod,module,evNumber);
1185 // fills all branches - wasted disk space
1186 gAlice->TreeD()->Fill();
1187 ResetDigits();
1188 // try and fill only the branch
1189 //branch->Fill();
1190 //ResetDigits(id);
1191 } // loop over modules
1192 } // loop over detector types
1193
3bd79107 1194 ClearModules();
1195
a3ec5900 1196// Int_t nentries=(Int_t)
1197 gAlice->TreeD()->GetEntries();
1198// cout << "nentries in TreeD" << nentries << endl;
3bd79107 1199
1200 char hname[30];
1201 sprintf(hname,"TreeD%d",evNumber);
2ab0c725 1202 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
3bd79107 1203 // reset tree
1204 gAlice->TreeD()->Reset();
1205
1206}
1207
1208
1209//____________________________________________________________________________
1210void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1211{
e8189707 1212 // cluster finding and reconstruction of space points
3bd79107 1213
9c74c52b 1214 // the condition below will disappear when the geom class will be
1215 // initialised for all versions - for the moment it is only for v5 !
1216 // 7 is the SDD beam test version
1217 Int_t ver = this->IsVersion();
04f91b7e 1218 if(ver!=5 && ver!=8 && ver!=9) return;
9c74c52b 1219
5cf7bbad 1220 const char *all = strstr(opt,"All");
1221 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
3bd79107 1222
1223 static Bool_t first=kTRUE;
caf37aec 1224 if (!TreeC() && first) {
3bd79107 1225 MakeTreeC("C");
1226 first=kFALSE;
1227 }
caf37aec 1228
1229 TTree *treeC=TreeC();
3bd79107 1230
9c74c52b 1231
1232 //TBranch *branch;
3bd79107 1233 AliITSClusterFinder* rec;
1234
9c74c52b 1235 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
3bd79107 1236 AliITSgeom *geom = GetITSgeom();
1237
1238 Int_t id,module;
a8a6107b 1239 for (id=0;id<kNTYPES;id++) {
3bd79107 1240 if (!all && !det[id]) continue;
9c74c52b 1241 //branch = (TBranch*)branches->UncheckedAt(id);
3bd79107 1242 AliITSDetType *iDetType=DetType(id);
1243 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1244 if (!rec) {
1245 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1246 exit(1);
e8189707 1247 // or SetDefaultClusterFinders();
3bd79107 1248 }
1249 TClonesArray *itsDigits = this->DigitsAddress(id);
1250
9c74c52b 1251 Int_t first,last;
1252 if(geom) {
1253 first = geom->GetStartDet(id);
1254 last = geom->GetLastDet(id);
1255 } else first=last=0;
34980f24 1256 printf("first module - last module %d %d\n",first,last);
3bd79107 1257 for(module=first;module<=last;module++) {
3bd79107 1258 this->ResetDigits();
1259 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1260 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1261 Int_t ndigits = itsDigits->GetEntriesFast();
a3ec5900 1262 if (ndigits) rec->FindRawClusters(module);
3bd79107 1263 gAlice->TreeR()->Fill();
1264 ResetRecPoints();
caf37aec 1265 treeC->Fill();
3bd79107 1266 ResetClusters();
1267 // try and fill only the branch
1268 //branch->Fill();
1269 //ResetRecPoints(id);
1270 } // loop over modules
1271 } // loop over detector types
1272
1273
a3ec5900 1274// Int_t nentries=(Int_t)
1275 gAlice->TreeR()->GetEntries();
1276// Int_t ncentries=(Int_t)
1277 treeC->GetEntries();
1278// cout << " nentries ncentries " << nentries << ncentries << endl;
3bd79107 1279
1280 char hname[30];
1281 sprintf(hname,"TreeR%d",evNumber);
2ab0c725 1282 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
3bd79107 1283 // reset tree
1284 gAlice->TreeR()->Reset();
1285
1286 sprintf(hname,"TreeC%d",evNumber);
caf37aec 1287 treeC->Write(hname,TObject::kOverwrite);
1288 treeC->Reset();
3bd79107 1289}
1290
1291
1292//____________________________________________________________________________
e8189707 1293void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
3bd79107 1294Option_t *option,Option_t *opt,Text_t *filename)
1295{
1296 // keep galice.root for signal and name differently the file for
1297 // background when add! otherwise the track info for signal will be lost !
1298
9c74c52b 1299
1300 // the condition below will disappear when the geom class will be
1301 // initialised for all versions - for the moment it is only for v5 !
1302 Int_t ver = this->IsVersion();
04f91b7e 1303 if(ver!=5 && ver!=8 && ver!=9) return;
c44604f4 1304 //if(ver!=5) return;
9c74c52b 1305
5cf7bbad 1306 const char *all = strstr(opt,"All");
1307 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
3bd79107 1308
1309 Int_t nmodules;
e8189707 1310 InitModules(size,nmodules);
1311 FillModules(evNumber,bgrev,nmodules,option,filename);
3bd79107 1312
1313
e8189707 1314 AliITSsimulation* sim;
3bd79107 1315 AliITSgeom *geom = GetITSgeom();
1316
e8189707 1317 TRandom *random=new TRandom[9];
1318 random[0].SetSeed(111);
1319 random[1].SetSeed(222);
1320 random[2].SetSeed(333);
1321 random[3].SetSeed(444);
1322 random[4].SetSeed(555);
1323 random[5].SetSeed(666);
1324 random[6].SetSeed(777);
1325 random[7].SetSeed(888);
1326 random[8].SetSeed(999);
1327
1328
3bd79107 1329 Int_t id,module;
a8a6107b 1330 for (id=0;id<kNTYPES;id++) {
3bd79107 1331 if (!all && !det[id]) continue;
e8189707 1332 AliITSDetType *iDetType=DetType(id);
1333 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1334 if (!sim) {
1335 Error("HitsToFastPoints","The simulation class was not instantiated!");
1336 exit(1);
1337 // or SetDefaultSimulation();
1338 }
34980f24 1339
1340 Int_t first,last;
1341 if(geom) {
1342 first = geom->GetStartDet(id);
1343 last = geom->GetLastDet(id);
1344 } else first=last=0;
1345 printf("first module - last module %d %d\n",first,last);
3bd79107 1346 for(module=first;module<=last;module++) {
1347 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
e8189707 1348 sim->CreateFastRecPoints(mod,module,random);
3bd79107 1349 gAlice->TreeR()->Fill();
1350 ResetRecPoints();
1351 } // loop over modules
1352 } // loop over detector types
1353
1354
1355 ClearModules();
1356
1357 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1358
1359 char hname[30];
1360 sprintf(hname,"TreeR%d",evNumber);
2ab0c725 1361 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
3bd79107 1362 // reset tree
1363 gAlice->TreeR()->Reset();
1364
e8189707 1365 delete [] random;
1366
fe4da5cc 1367}
1368
55b5a0b3 1369//________________________________________________________________
55b5a0b3 1370AliITStrack AliITS::Tracking(AliITStrack &track, AliITStrack *reference,TObjArray *fastpoints, Int_t
8af13b4b 1371**vettid, Bool_t flagvert, AliITSRad *rl ) {
55b5a0b3 1372
1373//Origin A. Badala' and G.S. Pappalardo: e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1374
cc6e75dd 1375
55b5a0b3 1376 TList *list= new TList();
1377
1378 AliITStrack tr(track);
cc6e75dd 1379
55b5a0b3 1380 list->AddLast(&tr);
1381
1382 Double_t Pt=(tr).GetPt();
a3ec5900 1383// cout << "\n Pt = " << Pt <<"\n"; //stampa
55b5a0b3 1384
8af13b4b 1385 AliITStracking obj(list, reference, this, fastpoints,TMath::Abs(Pt),vettid, flagvert, rl);
55b5a0b3 1386 list->Delete();
1387 delete list;
1388
1389 Int_t itot=-1;
1390 TVector VecTotLabref(18);
cc6e75dd 1391 Int_t lay, k;
1392 for(lay=5; lay>=0; lay--) {
55b5a0b3 1393 TVector VecLabref(3);
1394 VecLabref=(*reference).GetLabTrack(lay);
53e7090a 1395 Float_t ClustZ=(*reference).GetZclusterTrack( lay); //aggiunta il 5-3-2001
1396 for(k=0; k<3; k++){ //{itot++; VecTotLabref(itot)=VecLabref(k);} //cambiata il 5-3-2001
1397 Int_t lpp=(Int_t)VecLabref(k);
1398 if(lpp>=0) {
1399 TParticle *p=(TParticle*) gAlice->Particle(lpp);
1400 Int_t pcode=p->GetPdgCode();
1401 if(pcode==11) VecLabref(k)=p->GetFirstMother();
1402 }
1403 itot++; VecTotLabref(itot)=VecLabref(k);
1404 if(VecLabref(k)==0. && ClustZ == 0.) VecTotLabref(itot) =-3.; }
55b5a0b3 1405 }
1406 Long_t labref;
1407 Int_t freq;
1408 (*reference).Search(VecTotLabref, labref, freq);
1409
53e7090a 1410 //if(freq < 4) labref=-labref;
1411 //if(freq < 6) labref=-labref; // cinque - sei
1412 if(freq < 5) labref=-labref; // cinque - sei
55b5a0b3 1413 (*reference).SetLabel(labref);
1414
1415 return *reference;
1416
1417}
1418
1419
1420
1421//________________________________________________________________
1422
1423
1424
1425void AliITS::DoTracking(Int_t evNumber, Int_t min_t, Int_t max_t, TFile *file, Bool_t flagvert) {
1426
1427// ex macro for tracking ITS
1428
1429 printf("begin DoTracking - file %p\n",file);
1430
53e7090a 1431 //const char *pname="75x40_100x60";
55b5a0b3 1432
8af13b4b 1433 Int_t imax=200,jmax=450;
1434 AliITSRad *rl = new AliITSRad(imax,jmax);
1435 //cout<<" dopo costruttore AliITSRad\n"; getchar();
1436
55b5a0b3 1437 struct GoodTrack {
1438 Int_t lab,code;
1439 Float_t px,py,pz,x,y,z,pxg,pyg,pzg,ptg;
1440 Bool_t flag;
1441 };
1442
1443
1444 gAlice->GetEvent(0);
53e7090a 1445
f1d439d9 1446 // AliKalmanTrack *kkprov;
1447 // kkprov->SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
8ab89103 1448
53e7090a 1449 /* //modificato il 26-4-2001
1450 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
1451 AliTPCParam *digp = (AliTPCParam*)file->Get(pname);
1452 if (digp!=0) TPC->SetParam(digp);
1453 */
8ab89103 1454 TFile *cf=TFile::Open("AliTPCclusters.root");
1455 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
1456 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
53e7090a 1457
1458
54fcea18 1459 GoodTrack gt[15000];
55b5a0b3 1460 Int_t ngood=0;
8af13b4b 1461 ifstream in("itsgood_tracks");
55b5a0b3 1462
8af13b4b 1463 cerr<<"Reading itsgood tracks...\n";
55b5a0b3 1464 while (in>>gt[ngood].lab>>gt[ngood].code
1465 >>gt[ngood].px >>gt[ngood].py>>gt[ngood].pz
1466 >>gt[ngood].x >>gt[ngood].y >>gt[ngood].z
1467 >>gt[ngood].pxg >>gt[ngood].pyg >>gt[ngood].pzg
1468 >>gt[ngood].ptg >>gt[ngood].flag) {
1469 ngood++;
1470 cerr<<ngood<<'\r';
54fcea18 1471 if (ngood==15000) {
55b5a0b3 1472 cerr<<"Too many good tracks !\n";
1473 break;
1474 }
1475 }
8af13b4b 1476 if (!in.eof()) cerr<<"Read error (itsgood_tracks) !\n";
55b5a0b3 1477
1478
1479// Load tracks
53e7090a 1480 // TFile *tf=TFile::Open("tpctracks.root"); //commentato 26-4-2001
1481 TFile *tf=TFile::Open("AliTPCtracks.root");
8ab89103 1482 if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return ;}
53e7090a 1483 TObjArray tracks(200000);
55b5a0b3 1484 TTree *tracktree=(TTree*)tf->Get("TreeT");
1485 TBranch *tbranch=tracktree->GetBranch("tracks");
1486 Int_t nentr=(Int_t)tracktree->GetEntries();
cc6e75dd 1487 Int_t kk;
53e7090a 1488 /* commentato il 26-4-2001
1489 for (kk=0; kk<nentr; kk++) {
1490 AliTPCtrack *iotrack=new AliTPCtrack;
1491 tbranch->SetAddress(&iotrack);
1492 tracktree->GetEvent(kk);
1493 tracks.AddLast(iotrack);
1494 }
1495 */
8ab89103 1496 AliTPCtrack *iotracktpc=0;
cc6e75dd 1497 for (kk=0; kk<nentr; kk++) {
8ab89103 1498 iotracktpc=new AliTPCtrack;
1499 tbranch->SetAddress(&iotracktpc);
cc6e75dd 1500 tracktree->GetEvent(kk);
8ab89103 1501 tracks.AddLast(iotracktpc);
53e7090a 1502 }
55b5a0b3 1503 tf->Close();
1504
1505
1506 Int_t nt = tracks.GetEntriesFast();
1507 cerr<<"Number of found tracks "<<nt<<endl;
1508
1509 TVector DataOut(9);
1510 Int_t kkk=0;
1511
1512 Double_t ptg=0.,pxg=0.,pyg=0.,pzg=0.;
1513
1514 ////////////////////////////// good tracks definition in TPC ////////////////////////////////
1515
1516 ofstream out1 ("AliITSTrag.out");
cc6e75dd 1517 Int_t i;
1518 for (i=0; i<ngood; i++) out1 << gt[i].ptg << "\n";
55b5a0b3 1519 out1.close();
1520
1521
1522 TVector vec(5);
1523 TTree *TR=gAlice->TreeR();
1524 Int_t nent=(Int_t)TR->GetEntries();
1525 TClonesArray *recPoints = RecPoints();
1526 Int_t numbpoints;
1527 Int_t totalpoints=0;
1528 Int_t *np = new Int_t[nent];
1529 Int_t **vettid = new Int_t* [nent];
cc6e75dd 1530 Int_t mod;
1531 for (mod=0; mod<nent; mod++) {
55b5a0b3 1532 vettid[mod]=0;
1533 this->ResetRecPoints();
340cd0d8 1534 //gAlice->TreeR()->GetEvent(mod+1); //first entry in TreeR is empty
1535 gAlice->TreeR()->GetEvent(mod); //first entry in TreeR is empty
55b5a0b3 1536 numbpoints = recPoints->GetEntries();
1537 totalpoints+=numbpoints;
1538 np[mod] = numbpoints;
53e7090a 1539 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n"; getchar();
55b5a0b3 1540 vettid[mod] = new Int_t[numbpoints];
cc6e75dd 1541 Int_t ii;
1542 for (ii=0;ii<numbpoints; ii++) *(vettid[mod]+ii)=0;
55b5a0b3 1543 }
1544
53e7090a 1545 AliTPCtrack *track=0;
1546
55b5a0b3 1547
1548 if(min_t < 0) {min_t = 0; max_t = nt-1;}
1549
1550/*
1551 ///////////////////////////////// Definition of vertex end its error ////////////////////////////
1552 ////////////////////////// In the future it will be given by a method ///////////////////////////
1553 Double_t Vx=0.;
1554 Double_t Vy=0.;
1555 Double_t Vz=0.;
1556
1557 Float_t sigmavx=0.0050; // 50 microns
1558 Float_t sigmavy=0.0050; // 50 microns
1559 Float_t sigmavz=0.010; // 100 microns
1560
1561 //Vx+=gRandom->Gaus(0,sigmavx); Vy+=gRandom->Gaus(0,sigmavy); Vz+=gRandom->Gaus(0,sigmavz);
1562 TVector vertex(3), ervertex(3)
1563 vertex(0)=Vx; vertex(1)=Vy; vertex(2)=Vz;
1564 ervertex(0)=sigmavx; ervertex(1)=sigmavy; ervertex(2)=sigmavz;
1565 /////////////////////////////////////////////////////////////////////////////////////////////////
1566*/
53e7090a 1567
55b5a0b3 1568
1569 TTree tracktree1("TreeT","Tree with ITS tracks");
1570 AliITSiotrack *iotrack=0;
1571 tracktree1.Branch("ITStracks","AliITSiotrack",&iotrack,32000,0);
1572
1573 ofstream out ("AliITSTra.out");
53e7090a 1574 //ofstream outprova ("AliITSprova.out"); //commentato il 26-4-2001
cc6e75dd 1575
1576 Int_t j;
1577 for (j=min_t; j<=max_t; j++) {
53e7090a 1578 track=(AliTPCtrack*)tracks.UncheckedAt(j);
55b5a0b3 1579 Int_t flaglab=0;
1580 if (!track) continue;
1581 ////// elimination of not good tracks ////////////
1582 Int_t ilab=TMath::Abs(track->GetLabel());
cc6e75dd 1583 Int_t iii;
1584 for (iii=0;iii<ngood;iii++) {
1585 //cout<<" ilab, gt[iii].lab = "<<ilab<<" "<<gt[iii].lab<<"\n"; getchar();
1586 if (ilab==gt[iii].lab) {
55b5a0b3 1587 flaglab=1;
cc6e75dd 1588 ptg=gt[iii].ptg;
1589 pxg=gt[iii].pxg;
1590 pyg=gt[iii].pyg;
1591 pzg=gt[iii].pzg;
55b5a0b3 1592 break;
1593 }
1594 }
1595 //cout<<" j flaglab = " <<j<<" "<<flaglab<<"\n"; getchar();
53e7090a 1596 if (!flaglab) continue;
55b5a0b3 1597 //cout<<" j = " <<j<<"\n"; getchar();
1598 /*
1599 ////// old propagation to the end of TPC //////////////
1600 Double_t xk=76.;
1601 track->PropagateTo(xk);
1602 xk-=0.11;
1603 track->PropagateTo(xk,42.7,2.27); //C
1604 xk-=2.6;
1605 track->PropagateTo(xk,36.2,1.98e-3); //C02
1606 xk-=0.051;
1607 track->PropagateTo(xk,42.7,2.27); //C
1608 ///////////////////////////////////////////////////
1609 */
1610
1611 ////// new propagation to the end of TPC //////////////
1612 Double_t xk=77.415;
1613 track->PropagateTo(xk, 28.94, 1.204e-3); //Ne
1614 xk -=0.01;
1615 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1616 xk -=0.04;
1617 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1618 xk -=2.0;
1619 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1620 xk-=16;
1621 track->PropagateTo(xk,36.2,1.98e-3); //C02
1622 xk -=0.01;
1623 track->PropagateTo(xk, 24.01, 2.7); //Al
1624 xk -=0.01;
1625 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1626 xk -=0.04;
1627 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1628 xk -=0.5;
1629 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1630
1631 ///////////////////////////////////////////////////////////////
1632
1633 ///////////////////////////////////////////////////////////////
1634 AliITStrack trackITS(*track);
1635 AliITStrack result(*track);
1636 AliITStrack primarytrack(*track);
1637
1638///////////////////////////////////////////////////////////////////////////////////////////////
1639 TVector Vgeant(3);
1640 Vgeant=result.GetVertex();
1641
1642 // Definition of Dv and Zv for vertex constraint
cc6e75dd 1643 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
1644 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
55b5a0b3 1645 Double_t uniform= gRandom->Uniform();
1646 Double_t signdv;
1647 if(uniform<=0.5) signdv=-1.;
1648 else
1649 signdv=1.;
1650
1651 Double_t Vr=TMath::Sqrt(Vgeant(0)*Vgeant(0)+ Vgeant(1)*Vgeant(1));
1652 Double_t Dv=gRandom->Gaus(signdv*Vr,(Float_t)sigmaDv);
1653 Double_t Zv=gRandom->Gaus(Vgeant(2),(Float_t)sigmaZv);
1654
1655 //cout<<" Dv e Zv = "<<Dv<<" "<<Zv<<"\n";
1656 trackITS.SetDv(Dv); trackITS.SetZv(Zv);
1657 trackITS.SetsigmaDv(sigmaDv); trackITS.SetsigmaZv(sigmaZv);
1658 result.SetDv(Dv); result.SetZv(Zv);
1659 result.SetsigmaDv(sigmaDv); result.SetsigmaZv(sigmaZv);
1660 primarytrack.SetDv(Dv); primarytrack.SetZv(Zv);
1661 primarytrack.SetsigmaDv(sigmaDv); primarytrack.SetsigmaZv(sigmaZv);
1662
1663/////////////////////////////////////////////////////////////////////////////////////////////////
1664
8af13b4b 1665 primarytrack.PrimaryTrack(rl);
55b5a0b3 1666 TVector d2=primarytrack.Getd2();
1667 TVector tgl2=primarytrack.Gettgl2();
1668 TVector dtgl=primarytrack.Getdtgl();
1669 trackITS.Setd2(d2); trackITS.Settgl2(tgl2); trackITS.Setdtgl(dtgl);
1670 result.Setd2(d2); result.Settgl2(tgl2); result.Setdtgl(dtgl);
1671 /*
1672 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
1673 result.SetVertex(vertex); result.SetErrorVertex(ervertex);
53e7090a 1674 */
1675
8af13b4b 1676 Tracking(trackITS,&result,recPoints,vettid, flagvert,rl);
55b5a0b3 1677
8af13b4b 1678 // cout<<" progressive track number = "<<j<<"\r";
cc6e75dd 1679 // cout<<j<<"\r";
53e7090a 1680 Int_t NumofCluster=result.GetNumClust();
a3ec5900 1681// cout<<" progressive track number = "<<j<<"\n"; // stampa
55b5a0b3 1682 Long_t labITS=result.GetLabel();
a3ec5900 1683// cout << " ITS track label = " << labITS << "\n"; // stampa
55b5a0b3 1684 int lab=track->GetLabel();
a3ec5900 1685// cout << " TPC track label = " << lab <<"\n"; // stampa
55b5a0b3 1686
53e7090a 1687
55b5a0b3 1688//propagation to vertex
1689
1690 Double_t rbeam=3.;
cc6e75dd 1691
1692 result.Propagation(rbeam);
53e7090a 1693
1694 Double_t C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44;
1695 result.GetCElements(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
1696
55b5a0b3 1697 Double_t pt=TMath::Abs(result.GetPt());
1698 Double_t Dr=result.GetD();
1699 Double_t Z=result.GetZ();
1700 Double_t tgl=result.GetTgl();
1701 Double_t C=result.GetC();
1702 Double_t Cy=C/2.;
1703 Double_t Dz=Z-(tgl/Cy)*TMath::ASin(result.arga(rbeam));
53e7090a 1704 Dz-=Vgeant(2);
cc6e75dd 1705
55b5a0b3 1706 // cout<<" Dr e dz alla fine = "<<Dr<<" "<<Dz<<"\n"; getchar();
1707 Double_t phi=result.Getphi();
1708 Double_t phivertex = phi - TMath::ASin(result.argA(rbeam));
1709 Double_t duepi=2.*TMath::Pi();
1710 if(phivertex>duepi) phivertex-=duepi;
1711 if(phivertex<0.) phivertex+=duepi;
cc6e75dd 1712 Double_t Dtot=TMath::Sqrt(Dr*Dr+Dz*Dz);
1713
55b5a0b3 1714//////////////////////////////////////////////////////////////////////////////////////////
53e7090a 1715
1716 Int_t idmodule,idpoint;
1717 if(NumofCluster >=5) { // cinque - sei
1718 //if(NumofCluster ==6) { // cinque - sei
55b5a0b3 1719
1720
1721 AliITSiotrack outtrack;
1722
1723 iotrack=&outtrack;
1724
1725 iotrack->SetStatePhi(phi);
1726 iotrack->SetStateZ(Z);
1727 iotrack->SetStateD(Dr);
1728 iotrack->SetStateTgl(tgl);
1729 iotrack->SetStateC(C);
1730 Double_t radius=result.Getrtrack();
1731 iotrack->SetRadius(radius);
1732 Int_t charge;
1733 if(C>0.) charge=-1; else charge=1;
1734 iotrack->SetCharge(charge);
1735
55b5a0b3 1736
53e7090a 1737
686b2f43 1738 iotrack->SetCovMatrix(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
55b5a0b3 1739
8ab89103 1740 Double_t px=pt*TMath::Cos(phivertex);
1741 Double_t py=pt*TMath::Sin(phivertex);
55b5a0b3 1742 Double_t pz=pt*tgl;
1743
8ab89103 1744 Double_t xtrack=Dr*TMath::Sin(phivertex);
1745 Double_t ytrack=Dr*TMath::Cos(phivertex);
55b5a0b3 1746 Double_t ztrack=Dz+Vgeant(2);
1747
1748
1749 iotrack->SetPx(px);
1750 iotrack->SetPy(py);
1751 iotrack->SetPz(pz);
1752 iotrack->SetX(xtrack);
1753 iotrack->SetY(ytrack);
1754 iotrack->SetZ(ztrack);
1755 iotrack->SetLabel(labITS);
1756
c5b22044 1757 Int_t il;
1758 for(il=0;il<6; il++){
55b5a0b3 1759 iotrack->SetIdPoint(il,result.GetIdPoint(il));
1760 iotrack->SetIdModule(il,result.GetIdModule(il));
1761 }
1762 tracktree1.Fill();
1763
1764 //cout<<" labITS = "<<labITS<<"\n";
1765 //cout<<" phi z Dr tgl C = "<<phi<<" "<<Z<<" "<<Dr<<" "<<tgl<<" "<<C<<"\n"; getchar();
1766
1767 DataOut(kkk) = ptg; kkk++; DataOut(kkk)=labITS; kkk++; DataOut(kkk)=lab; kkk++;
1768
c5b22044 1769 for (il=0;il<6;il++) {
55b5a0b3 1770 idpoint=result.GetIdPoint(il);
1771 idmodule=result.GetIdModule(il);
1772 *(vettid[idmodule]+idpoint)=1;
1773 iotrack->SetIdPoint(il,idpoint);
1774 iotrack->SetIdModule(il,idmodule);
1775 }
cc6e75dd 1776
1777 // cout<<" +++++++++++++ pt e ptg = "<<pt<<" "<<ptg<<" ++++++++++\n";
55b5a0b3 1778 Double_t difpt= (pt-ptg)/ptg*100.;
1779 DataOut(kkk)=difpt; kkk++;
1780 Double_t lambdag=TMath::ATan(pzg/ptg);
1781 Double_t lam=TMath::ATan(tgl);
1782 Double_t diflam = (lam - lambdag)*1000.;
1783 DataOut(kkk) = diflam; kkk++;
53e7090a 1784 Double_t phig=TMath::ATan2(pyg,pxg); if(phig<0) phig=2.*TMath::Pi()+phig;
1785 Double_t phi=phivertex;
1786
55b5a0b3 1787 Double_t difphi = (phi - phig)*1000.;
1788 DataOut(kkk)=difphi; kkk++;
1789 DataOut(kkk)=Dtot*1.e4; kkk++;
1790 DataOut(kkk)=Dr*1.e4; kkk++;
53e7090a 1791 DataOut(kkk)=Dz*1.e4; kkk++;
cc6e75dd 1792 Int_t r;
1793 for (r=0; r<9; r++) { out<<DataOut(r)<<" ";}
55b5a0b3 1794 out<<"\n";
1795 kkk=0;
1796
1797
1798 } // end if on NumofCluster
1799 //gObjectTable->Print(); // stampa memoria
1800 } // end for (int j=min_t; j<=max_t; j++)
1801
1802 out.close();
53e7090a 1803 //outprova.close();
cc6e75dd 1804
55b5a0b3 1805 static Bool_t first=kTRUE;
1806 static TFile *tfile;
1807
1808 if(first) {
1809 tfile=new TFile("itstracks.root","RECREATE");
1810 //cout<<"I have opened itstracks.root file "<<endl;
1811 }
1812 first=kFALSE;
1813 tfile->cd();
1814 tfile->ls();
1815
1816 char hname[30];
1817 sprintf(hname,"TreeT%d",evNumber);
1818
1819 tracktree1.Write(hname);
1820
1821
1822
1823 TTree *fAli=gAlice->TreeK();
1824 TFile *fileAli=0;
1825
1826 if (fAli) fileAli =fAli->GetCurrentFile();
1827 fileAli->cd();
1828
1829 ////////////////////////////////////////////////////////////////////////////////////////////////
1830
1831 printf("delete vectors\n");
1832 if(np) delete [] np;
1833 if(vettid) delete [] vettid;
1834
1835}
53e7090a 1836