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