1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.53 2001/05/31 18:52:24 barbera
19 Bari model becomes the default
21 Revision 1.53 2001/05/30 07:52:24 hristov
22 TPC and CONTAINERS included in the search path
24 Revision 1.52 2001/05/30 06:04:58 hristov
25 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
27 Revision 1.51 2001/05/16 14:57:15 alibrary
28 New files for folders and Stack
30 Revision 1.50 2001/05/11 09:15:21 barbera
31 Corrected to make fast point creation working with PPR geometry
33 Revision 1.49 2001/05/11 07:37:49 hristov
34 Legacy lines commented
36 Revision 1.48 2001/05/10 18:14:25 barbera
39 Revision 1.47 2001/05/10 17:55:59 barbera
40 Modified to create rec points also for PPR geometries
42 Revision 1.46 2001/05/10 00:05:28 nilsen
43 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
44 should probably be cleaned up to only check to make sure that fITSgeom has
45 been properly defined.
47 Revision 1.45 2001/05/01 22:35:48 nilsen
48 Remove/commented a number of cout<< statements. and made change needed by
51 Revision 1.44 2001/04/26 22:44:01 nilsen
52 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
53 done properly in AliITSv???.cxx via SetDefaults.
55 Revision 1.43 2001/04/26 13:22:52 barbera
56 TMatrix and TVector elimininated to speed up the code
58 Revision 1.42 2001/04/25 21:55:12 barbera
59 Updated version to be compatible with actual verion of STEER and TPC
61 Revision 1.41 2001/04/21 15:16:51 barbera
62 Updated with the new SSD reconstruction code
64 Revision 1.40 2001/03/17 15:07:06 mariana
65 Update SDD response parameters
67 Revision 1.39 2001/03/12 17:45:32 hristov
68 Changes needed on Sun with CC 5.0
70 Revision 1.38 2001/03/07 14:04:51 barbera
71 Some vector dimensions increased to cope with full events
73 Revision 1.37 2001/03/07 12:36:35 barbera
74 A change added in the tracking part to manage delta rays
76 Revision 1.36 2001/03/02 19:44:11 barbera
77 modified to taking into account new version tracking v1
79 Revision 1.35 2001/02/28 18:16:46 mariana
80 Make the code compatible with the new AliRun
82 Revision 1.34 2001/02/11 15:51:39 mariana
83 Set protection in MakeBranch
85 Revision 1.33 2001/02/10 22:26:39 mariana
86 Move the initialization of the containers for raw clusters in MakeTreeC()
88 Revision 1.32 2001/02/08 23:55:31 nilsen
89 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
90 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
92 Revision 1.31 2001/02/02 23:57:28 nilsen
93 Added include file that are no londer included in AliITSgeom.h
95 Revision 1.30 2001/01/30 09:23:13 hristov
96 Streamers removed (R.Brun)
98 Revision 1.29 2001/01/26 20:01:09 hristov
99 Major upgrade of AliRoot code
101 Revision 1.28 2000/12/18 14:02:00 barbera
102 new version of the ITS tracking to take into account the new TPC track parametrization
104 Revision 1.27 2000/12/08 13:49:27 barbera
105 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
107 Revision 1.26 2000/11/27 13:12:13 barbera
108 New version containing the files for tracking
110 Revision 1.25 2000/11/12 22:38:05 barbera
111 Added header file for the SPD Bari model
113 Revision 1.24 2000/10/09 22:18:12 barbera
114 Bug fixes from MAriana to le AliITStest.C run correctly
116 Revision 1.23 2000/10/05 20:47:42 nilsen
117 fixed dependencies of include files. Tryed but failed to get a root automaticly
118 generates streamer function to work. Modified SetDefaults.
120 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
121 Needed to include stdlib.h
124 Revision 1.22 2000/10/04 19:45:52 barbera
125 Corrected by F. Carminati for v3.04
127 Revision 1.21 2000/10/02 21:28:08 fca
128 Removal of useless dependecies via forward declarations
130 Revision 1.20 2000/10/02 16:31:39 barbera
131 General code clean-up
133 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
134 General code clean-up (e.g., printf -> cout)
136 Revision 1.19 2000/09/22 12:13:25 nilsen
137 Patches and updates for fixes to this and other routines.
139 Revision 1.18 2000/07/12 05:32:20 fca
140 Correcting several syntax problem with static members
142 Revision 1.17 2000/07/10 16:07:18 fca
143 Release version of ITS code
145 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
146 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
148 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
149 //fixed FillModule. Removed fi(fabs(xl)<dx....
151 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
152 This is the version of the files after the merging done in December 1999.
153 See the ReadMe110100.txt file for details
155 Revision 1.9 1999/11/14 14:33:25 fca
156 Correct problems with distructors and pointers, thanks to I.Hrivnacova
158 Revision 1.8 1999/09/29 09:24:19 fca
159 Introduction of the Copyright and cvs Log
163 ///////////////////////////////////////////////////////////////////////////////
165 // An overview of the basic philosophy of the ITS code development
166 // and analysis is show in the figure below.
169 <img src="picts/ITS/ITS_Analysis_schema.gif">
172 <font size=+2 color=red>
173 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
174 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
180 // AliITS. Inner Traking System base class.
181 // This class contains the base procedures for the Inner Tracking System
185 <img src="picts/ITS/AliITS_Class_Diagram.gif">
188 <font size=+2 color=red>
189 <p>This show the class diagram of the different elements that are part of
197 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
200 // Modified and documented by Bjorn S. Nilsen
204 // Modified and documented by A. Bologna
207 // AliITS is the general base class for the ITS. Also see AliDetector for
208 // futher information.
210 ///////////////////////////////////////////////////////////////////////////////
211 #include <iostream.h>
219 #include <TClonesArray.h>
221 #include <TObjectTable.h>
225 #include <TParticle.h>
230 #include "AliITSMap.h"
231 #include "AliITSDetType.h"
232 #include "AliITSClusterFinder.h"
233 //#include "AliITSsimulation.h"
234 #include "AliITSsimulationSPD.h"
235 #include "AliITSsimulationSDD.h"
236 #include "AliITSsimulationSSD.h"
237 #include "AliITSresponse.h"
238 #include "AliITSsegmentationSPD.h"
239 #include "AliITSresponseSPD.h"
240 #include "AliITSresponseSPDdubna.h"
241 #include "AliITSsegmentationSDD.h"
242 #include "AliITSresponseSDD.h"
243 #include "AliITSsegmentationSSD.h"
244 #include "AliITSresponseSSD.h"
245 #include "AliITShit.h"
246 #include "AliITSgeom.h"
247 #include "AliITSdigit.h"
248 #include "AliITSmodule.h"
249 #include "AliITSRecPoint.h"
250 #include "AliITSRawCluster.h"
253 #include "AliKalmanTrack.h"
256 #include "AliITStrack.h"
257 #include "AliITSiotrack.h"
258 #include "AliITStracking.h"
259 #include "AliITSRad.h"
261 #include "AliTPCParam.h"
262 #include "AliTPCtracker.h"
266 //_____________________________________________________________________________
267 AliITS::AliITS() : AliDetector() {
269 // Default initialiser for ITS
270 // The default constructor of the AliITS class. In addition to
271 // creating the AliITS class it zeros the variables fIshunt (a member
272 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
273 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
281 fNDetTypes = kNTYPES;
300 //_____________________________________________________________________________
301 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
303 // Default initialiser for ITS
304 // The constructor of the AliITS class. In addition to creating the
305 // AliITS class, it allocates memory for the TClonesArrays fHits and
306 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
307 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
308 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
309 // macro display.C AliITS also sets the marker color to red. The variables
310 // passes with this constructor, const char *name and *title, are used by
311 // the constructor of AliDetector class. See AliDetector class for a
312 // description of these parameters and its constructor functions.
316 fHits = new TClonesArray("AliITShit", 1560);
317 gAlice->AddHitList(fHits);
319 fNDetTypes = kNTYPES;
321 fNdtype = new Int_t[kNTYPES];
322 fDtype = new TObjArray(kNTYPES);
324 fNctype = new Int_t[kNTYPES];
325 fCtype = new TObjArray(kNTYPES);
341 fDetTypes = new TObjArray(kNTYPES);
344 for(i=0;i<kNTYPES;i++) {
345 fDetTypes->AddAt(new AliITSDetType(),i);
351 SetMarkerColor(kRed);
355 //___________________________________________________________________________
356 AliITS::AliITS(AliITS &source){
358 if(this==&source) return;
359 Error("AliITS::Copy constructor",
360 "You are not allowed to make a copy of the AliITS");
363 //____________________________________________________________________________
364 AliITS& AliITS::operator=(AliITS &source){
365 // assignment operator
366 if(this==&source) return *this;
367 Error("AliITS::operator=",
368 "You are not allowed to make a copy of the AliITS");
370 return *this; //fake return
372 //____________________________________________________________________________
373 void AliITS::ClearModules(){
374 //clear the modules TObjArray
376 if(fITSmodules) fITSmodules->Delete();
379 //_____________________________________________________________________________
382 // Default distructor for ITS
383 // The default destructor of the AliITS class. In addition to deleting
384 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
385 // fIdSens, fIdName, and fITSpoints.
392 // delete fIdName; // TObjArray of TObjStrings
393 if(fIdName!=0) delete[] fIdName; // Array of TStrings
394 if(fIdSens!=0) delete[] fIdSens;
396 this->ClearModules();
398 }// end if fITSmodules!=0
418 if (fTreeC) delete fTreeC;
420 if (fITSgeom) delete fITSgeom;
424 //___________________________________________
425 AliITSDetType* AliITS::DetType(Int_t id)
427 //return pointer to id detector type
428 return ((AliITSDetType*) (*fDetTypes)[id]);
431 //___________________________________________
432 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
434 //set the digit and cluster classes to be used for the id detector type
435 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
438 //___________________________________________
439 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
441 //set the response model for the id detector type
443 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
447 //___________________________________________
448 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
450 //set the segmentation model for the id detector type
452 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
456 //___________________________________________
457 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
459 //set the simulation model for the id detector type
461 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
464 //___________________________________________
465 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
467 //set the cluster finder model for the id detector type
469 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
473 //_____________________________________________________________________________
474 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
477 // The function to add information to the AliITShit class. See the
478 // AliITShit class for a full description. This function allocates the
479 // necessary new space for the hit information and passes the variable
480 // track, and the pointers *vol and *hits to the AliITShit constructor
483 TClonesArray &lhits = *fHits;
484 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
486 //_____________________________________________________________________________
487 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
489 // add a real digit - as coming from data
491 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
492 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
495 //_____________________________________________________________________________
496 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
499 // add a simulated digit
501 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
506 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
509 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
512 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
518 //_____________________________________________________________________________
519 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
521 // add a simulated digit to the list
523 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
527 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
530 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
533 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
539 //_____________________________________________________________________________
540 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
543 // add a cluster to the list
545 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
550 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
553 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
556 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
563 //_____________________________________________________________________________
564 void AliITS::AddRecPoint(const AliITSRecPoint &r)
567 // Add a reconstructed space point to the list
569 TClonesArray &lrecp = *fRecPoints;
570 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
574 //____________________________________________
575 void AliITS::ResetDigits()
578 // Reset number of digits and the digits array for the ITS detector
584 for (i=0;i<kNTYPES;i++ ) {
585 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
586 if (fNdtype) fNdtype[i]=0;
590 //____________________________________________
591 void AliITS::ResetDigits(Int_t i)
594 // Reset number of digits and the digits array for this branch
596 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
597 if (fNdtype) fNdtype[i]=0;
601 //____________________________________________
602 void AliITS::ResetClusters()
605 // Reset number of clusters and the clusters array for ITS
609 for (i=0;i<kNTYPES;i++ ) {
610 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
611 if (fNctype) fNctype[i]=0;
616 //____________________________________________
617 void AliITS::ResetClusters(Int_t i)
620 // Reset number of clusters and the clusters array for this branch
622 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
623 if (fNctype) fNctype[i]=0;
628 //____________________________________________
629 void AliITS::ResetRecPoints()
632 // Reset number of rec points and the rec points array
634 if (fRecPoints) fRecPoints->Clear();
639 //_____________________________________________________________________________
640 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
642 // Distance from mouse to ITS on the screen. Dummy routine
643 // A dummy routine used by the ROOT macro display.C to allow for the
644 // use of the mouse (pointing device) in the macro. In general this should
645 // never be called. If it is it returns the number 9999 for any value of
651 //_____________________________________________________________________________
654 // Initialise ITS after it has been built
655 // This routine initializes the AliITS class. It is intended to be called
656 // from the Init function in AliITSv?. Besides displaying a banner
657 // indicating that it has been called it initializes the array fIdSens
658 // and sets the default segmentation, response, digit and raw cluster classes
659 // Therefore it should be called after a call to CreateGeometry.
666 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
670 //_____________________________________________________________________________
671 void AliITS::SetDefaults()
673 // sets the default segmentation, response, digit and raw cluster classes
675 if(fDebug) printf("%s: SetDefaults\n",ClassName());
677 AliITSDetType *iDetType;
683 if (!iDetType->GetSegmentationModel()) {
684 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
685 SetSegmentationModel(0,seg0);
687 if (!iDetType->GetResponseModel()) {
688 SetResponseModel(0,new AliITSresponseSPD());
690 // set digit and raw cluster classes to be used
692 const char *kData0=(iDetType->GetResponseModel())->DataType();
693 if (strstr(kData0,"real")) {
694 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
695 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
699 if (!iDetType->GetResponseModel()) {
700 SetResponseModel(1,new AliITSresponseSDD());
702 AliITSresponse *resp1=iDetType->GetResponseModel();
703 if (!iDetType->GetSegmentationModel()) {
704 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
705 SetSegmentationModel(1,seg1);
707 const char *kData1=(iDetType->GetResponseModel())->DataType();
708 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
709 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
710 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
711 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
715 if (!iDetType->GetSegmentationModel()) {
716 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
717 SetSegmentationModel(2,seg2);
719 if (!iDetType->GetResponseModel()) {
720 SetResponseModel(2,new AliITSresponseSSD());
722 const char *kData2=(iDetType->GetResponseModel())->DataType();
723 if (strstr(kData2,"real")) {
724 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
725 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
728 Warning("SetDefaults","Only the three basic detector types are initialised!");
732 //_____________________________________________________________________________
733 void AliITS::SetDefaultSimulation()
738 //_____________________________________________________________________________
739 void AliITS::SetDefaultClusterFinders()
744 //_____________________________________________________________________________
746 void AliITS::MakeTreeC(Option_t *option)
748 // create a separate tree to store the clusters
750 // cout << "AliITS::MakeTreeC" << endl;
752 const char *optC = strstr(option,"C");
753 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
756 Int_t buffersize = 4000;
759 const char *det[3] = {"SPD","SDD","SSD"};
764 // one branch for Clusters per type of detector
766 for (i=0; i<kNTYPES ;i++) {
767 AliITSDetType *iDetType=DetType(i);
768 iDetType->GetClassNames(digclass,clclass);
770 (*fCtype)[i] = new TClonesArray(clclass,10000);
771 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
772 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
773 if (fCtype && fTreeC) {
774 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
775 // cout << "Making Branch " << branchname;
776 // cout << " for Clusters of detector type " << i+1 << endl;
782 //_____________________________________________________________________________
783 void AliITS::GetTreeC(Int_t event)
786 // cout << "AliITS::GetTreeC" << endl;
788 // get the clusters tree for this event and set the branch address
792 const char *det[3] = {"SPD","SDD","SSD"};
799 sprintf(treeName,"TreeC%d",event);
800 fTreeC = (TTree*)gDirectory->Get(treeName);
805 for (i=0; i<kNTYPES; i++) {
806 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
807 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
809 branch = fTreeC->GetBranch(branchname);
810 if (branch) branch->SetAddress(&((*fCtype)[i]));
814 Error("AliITS::GetTreeC",
815 "cannot find Clusters Tree for event:%d\n",event);
819 //_____________________________________________________________________________
820 void AliITS::MakeBranch(Option_t* option, const char *file)
823 // Creates Tree branches for the ITS.
826 Int_t buffersize = 4000;
828 sprintf(branchname,"%s",GetName());
830 AliDetector::MakeBranch(option,file);
832 const char *cD = strstr(option,"D");
833 const char *cR = strstr(option,"R");
837 // one branch for digits per type of detector
839 const char *det[3] = {"SPD","SDD","SSD"};
845 for (i=0; i<kNTYPES ;i++) {
846 AliITSDetType *iDetType=DetType(i);
847 iDetType->GetClassNames(digclass,clclass);
849 if(!((*fDtype)[i])) (*fDtype)[i] = new TClonesArray(digclass,10000);
853 for (i=0; i<kNTYPES ;i++) {
854 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
855 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
856 if (fDtype && gAlice->TreeD()) {
857 MakeBranchInTree(gAlice->TreeD(),
858 branchname, &((*fDtype)[i]), buffersize, file);
859 // cout << "Making Branch " << branchname;
860 // cout << " for digits of type "<< i+1 << endl;
867 // only one branch for rec points for all detector types
869 sprintf(branchname,"%sRecPoints",GetName());
871 if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",10000);
873 if (fRecPoints && gAlice->TreeR()) {
874 MakeBranchInTree(gAlice->TreeR(),
875 branchname, &fRecPoints, buffersize, file) ;
876 // cout << "Making Branch " << branchname;
877 // cout << " for reconstructed space points" << endl;
882 //___________________________________________
883 void AliITS::SetTreeAddress()
886 // Set branch address for the Trees.
889 AliDetector::SetTreeAddress();
891 const char *det[3] = {"SPD","SDD","SSD"};
894 TTree *treeD = gAlice->TreeD();
895 TTree *treeR = gAlice->TreeR();
899 for (i=0; i<kNTYPES; i++) {
900 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
901 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
903 branch = treeD->GetBranch(branchname);
904 if (branch) branch->SetAddress(&((*fDtype)[i]));
911 sprintf(branchname,"%sRecPoints",GetName());
912 branch = treeR->GetBranch(branchname);
913 if (branch) branch->SetAddress(&fRecPoints);
919 //____________________________________________________________________________
920 void AliITS::InitModules(Int_t size,Int_t &nmodules){
922 //initialize the modules array
925 fITSmodules->Delete();
929 Int_t nl,indexMAX,index;
931 if(size<=0){ // default to using data stored in AliITSgeom
933 Error("AliITS::InitModules",
934 "in AliITS::InitModule fITSgeom not defined\n");
936 } // end if fITSgeom==0
937 nl = fITSgeom->GetNlayers();
938 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
939 fITSgeom->GetNdetectors(nl))+1;
941 fITSmodules = new TObjArray(indexMAX);
942 for(index=0;index<indexMAX;index++){
943 fITSmodules->AddAt( new AliITSmodule(index),index);
946 fITSmodules = new TObjArray(size);
947 for(index=0;index<size;index++) {
948 fITSmodules->AddAt( new AliITSmodule(index),index);
955 //____________________________________________________________________________
956 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
958 // fill the modules with the sorted by module hits; add hits from background
962 static TTree *trH1; //Tree with background hits
963 static TClonesArray *fHits2; //List of hits for one track only
965 static Bool_t first=kTRUE;
967 const char *addBgr = strstr(option,"Add");
972 // cout<<"filename "<<filename<<endl;
973 file=new TFile(filename);
974 // cout<<"I have opened "<<filename<<" file "<<endl;
975 fHits2 = new TClonesArray("AliITShit",1000 );
980 // Get Hits Tree header from file
981 if(fHits2) fHits2->Clear();
982 if(trH1) delete trH1;
986 sprintf(treeName,"TreeH%d",bgrev);
987 trH1 = (TTree*)gDirectory->Get(treeName);
988 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
991 Error("AliITS::FillModules",
992 "cannot find Hits Tree for event:%d\n",bgrev);
994 // Set branch addresses
997 sprintf(branchname,"%s",GetName());
998 if (trH1 && fHits2) {
999 branch = trH1->GetBranch(branchname);
1000 if (branch) branch->SetAddress(&fHits2);
1004 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
1005 //printf("background - ntracks1 - %d\n",ntracks1);
1008 //Int_t npart = gAlice->GetEvent(evnt);
1009 //if(npart<=0) return;
1010 TClonesArray *itsHits = this->Hits();
1011 Int_t lay,lad,det,index;
1012 AliITShit *itsHit=0;
1013 AliITSmodule *mod=0;
1015 TTree *iTH = gAlice->TreeH();
1016 Int_t ntracks =(Int_t) iTH->GetEntries();
1019 for(t=0; t<ntracks; t++){
1020 gAlice->ResetHits();
1022 Int_t nhits = itsHits->GetEntriesFast();
1023 //printf("nhits %d\n",nhits);
1024 if (!nhits) continue;
1025 for(h=0; h<nhits; h++){
1026 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
1027 itsHit->GetDetectorID(lay,lad,det);
1028 // temporarily index=det-1 !!!
1029 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1032 mod = this->GetModule(index);
1033 mod->AddHit(itsHit,t,h);
1034 } // end loop over hits
1035 } // end loop over tracks
1037 // open the file with background
1041 ntracks =(Int_t)trH1->GetEntries();
1042 //printf("background - ntracks1 %d\n",ntracks);
1043 //printf("background - Start loop over tracks \n");
1046 for (track=0; track<ntracks; track++) {
1048 if (fHits2) fHits2->Clear();
1049 trH1->GetEvent(track);
1051 for(i=0;i<fHits2->GetEntriesFast();++i) {
1053 itsHit=(AliITShit*) (*fHits2)[i];
1054 itsHit->GetDetectorID(lay,lad,det);
1055 // temporarily index=det-1 !!!
1056 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1059 mod = this->GetModule(index);
1060 mod->AddHit(itsHit,track,i);
1061 } // end loop over hits
1062 } // end loop over tracks
1064 TTree *fAli=gAlice->TreeK();
1067 if (fAli) fileAli =fAli->GetCurrentFile();
1072 //gObjectTable->Print();
1076 //____________________________________________________________________________
1078 void AliITS::SDigits2Digits()
1081 AliITSgeom *geom = GetITSgeom();
1084 AliITSDetType *iDetType;
1085 iDetType=DetType(0);
1086 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
1087 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
1088 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
1089 SetSimulationModel(0,sim0);
1091 // printf("SPD dimensions %f %f \n",seg0->Dx(),seg0->Dz());
1092 // printf("SPD npixels %d %d \n",seg0->Npz(),seg0->Npx());
1093 // printf("SPD pitches %d %d \n",seg0->Dpz(0),seg0->Dpx(0));
1097 //Set response functions
1098 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
1100 iDetType=DetType(1);
1101 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
1103 res1=new AliITSresponseSDD();
1104 SetResponseModel(1,res1);
1106 Float_t noise, baseline;
1107 res1->GetNoiseParam(noise,baseline);
1108 Float_t noise_after_el = res1->GetNoiseAfterElectronics();
1109 Float_t fCutAmp = baseline + 2.*noise_after_el;
1110 Int_t cp[8]={0,0,(int)fCutAmp,(int)fCutAmp,0,0,0,0}; //1D
1111 res1->SetCompressParam(cp);
1112 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
1114 seg1 = new AliITSsegmentationSDD(geom,res1);
1115 SetSegmentationModel(1,seg1);
1117 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
1118 SetSimulationModel(1,sim1);
1121 iDetType=DetType(2);
1122 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
1123 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
1124 res2->SetSigmaSpread(3.,2.);
1125 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
1126 SetSimulationModel(2,sim2);
1128 cerr<<"Digitizing ITS...\n";
1132 HitsToDigits(gAlice->GetEvNumber(),0,-1," ","All"," ");
1133 timer.Stop(); timer.Print();
1141 //____________________________________________________________________________
1142 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
1144 // keep galice.root for signal and name differently the file for
1145 // background when add! otherwise the track info for signal will be lost !
1147 // the condition below will disappear when the geom class will be
1148 // initialised for all versions - for the moment it is only for v5 !
1149 // 7 is the SDD beam test version
1150 Int_t ver = this->IsVersion();
1151 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
1153 const char *all = strstr(opt,"All");
1154 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1155 // cout<<" 1 AliITS "<<endl;
1157 InitModules(size,nmodules);
1158 // cout<<" 2 AliITS "<<endl;
1159 FillModules(evNumber,bgrev,nmodules,option,filename);
1160 // cout<<" 3 AliITS "<<endl;
1163 AliITSsimulation* sim;
1164 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
1165 AliITSgeom *geom = GetITSgeom();
1168 // Int_t lay, lad, detect;
1170 for (id=0;id<kNTYPES;id++) {
1171 if (!all && !det[id]) continue;
1172 //branch = (TBranch*)branches->UncheckedAt(id);
1173 AliITSDetType *iDetType=DetType(id);
1174 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1177 Error("HitsToDigits","The simulation class was not instantiated!");
1179 // or SetDefaultSimulation();
1183 first = geom->GetStartDet(id);
1184 last = geom->GetLastDet(id);
1185 } else first=last=0;
1186 // cout << "det type " << id << " first, last "<< first << last << endl;
1187 for(module=first;module<=last;module++) {
1188 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1190 geom->GetModuleId(module,lay, lad, detect);
1192 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(6);
1194 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(5);
1196 sim->DigitiseModule(mod,module,evNumber);
1197 // fills all branches - wasted disk space
1198 gAlice->TreeD()->Fill();
1200 // try and fill only the branch
1203 } // loop over modules
1204 } // loop over detector types
1208 // Int_t nentries=(Int_t)
1209 gAlice->TreeD()->GetEntries();
1210 // cout << "nentries in TreeD" << nentries << endl;
1213 sprintf(hname,"TreeD%d",evNumber);
1214 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1216 gAlice->TreeD()->Reset();
1221 //____________________________________________________________________________
1222 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1224 // cluster finding and reconstruction of space points
1226 // the condition below will disappear when the geom class will be
1227 // initialised for all versions - for the moment it is only for v5 !
1228 // 7 is the SDD beam test version
1229 Int_t ver = this->IsVersion();
1230 if(ver!=5 && ver!=8 && ver!=9) return;
1232 const char *all = strstr(opt,"All");
1233 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1235 static Bool_t first=kTRUE;
1236 if (!TreeC() && first) {
1241 TTree *treeC=TreeC();
1245 AliITSClusterFinder* rec;
1247 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1248 AliITSgeom *geom = GetITSgeom();
1251 for (id=0;id<kNTYPES;id++) {
1252 if (!all && !det[id]) continue;
1253 //branch = (TBranch*)branches->UncheckedAt(id);
1254 AliITSDetType *iDetType=DetType(id);
1255 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1257 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1259 // or SetDefaultClusterFinders();
1261 TClonesArray *itsDigits = this->DigitsAddress(id);
1265 first = geom->GetStartDet(id);
1266 last = geom->GetLastDet(id);
1267 } else first=last=0;
1268 printf("first module - last module %d %d\n",first,last);
1269 for(module=first;module<=last;module++) {
1270 this->ResetDigits();
1271 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1272 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1273 Int_t ndigits = itsDigits->GetEntriesFast();
1274 if (ndigits) rec->FindRawClusters(module);
1275 gAlice->TreeR()->Fill();
1279 // try and fill only the branch
1281 //ResetRecPoints(id);
1282 } // loop over modules
1283 } // loop over detector types
1286 // Int_t nentries=(Int_t)
1287 gAlice->TreeR()->GetEntries();
1288 // Int_t ncentries=(Int_t)
1289 treeC->GetEntries();
1290 // cout << " nentries ncentries " << nentries << ncentries << endl;
1293 sprintf(hname,"TreeR%d",evNumber);
1294 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1296 gAlice->TreeR()->Reset();
1298 sprintf(hname,"TreeC%d",evNumber);
1299 treeC->Write(hname,TObject::kOverwrite);
1302 //____________________________________________________________________________
1303 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1304 Option_t *option,Option_t *opt,Text_t *filename)
1306 // keep galice.root for signal and name differently the file for
1307 // background when add! otherwise the track info for signal will be lost !
1310 // the condition below will disappear when the geom class will be
1311 // initialised for all versions - for the moment it is only for v5 !
1312 Int_t ver = this->IsVersion();
1313 if(ver!=5 && ver!=8 && ver!=9) return;
1314 //if(ver!=5) return;
1316 const char *all = strstr(opt,"All");
1317 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1320 InitModules(size,nmodules);
1321 FillModules(evNumber,bgrev,nmodules,option,filename);
1324 AliITSsimulation* sim;
1325 AliITSgeom *geom = GetITSgeom();
1327 TRandom *random=new TRandom[9];
1328 random[0].SetSeed(111);
1329 random[1].SetSeed(222);
1330 random[2].SetSeed(333);
1331 random[3].SetSeed(444);
1332 random[4].SetSeed(555);
1333 random[5].SetSeed(666);
1334 random[6].SetSeed(777);
1335 random[7].SetSeed(888);
1336 random[8].SetSeed(999);
1340 for (id=0;id<kNTYPES;id++) {
1341 if (!all && !det[id]) continue;
1342 AliITSDetType *iDetType=DetType(id);
1343 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1345 Error("HitsToFastPoints",
1346 "The simulation class was not instantiated!");
1348 // or SetDefaultSimulation();
1353 first = geom->GetStartDet(id);
1354 last = geom->GetLastDet(id);
1355 } else first=last=0;
1356 printf("first module - last module %d %d\n",first,last);
1357 for(module=first;module<=last;module++) {
1358 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1359 sim->CreateFastRecPoints(mod,module,random);
1360 gAlice->TreeR()->Fill();
1362 } // loop over modules
1363 } // loop over detector types
1368 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1371 sprintf(hname,"TreeR%d",evNumber);
1372 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1374 gAlice->TreeR()->Reset();
1379 //________________________________________________________________
1380 AliITStrack AliITS::Tracking(AliITStrack &track, AliITStrack *reference,
1381 TObjArray *fastpoints, Int_t **vettid,
1382 Bool_t flagvert, AliITSRad *rl ) {
1383 // Origin A. Badala' and G.S. Pappalardo: e-mail Angela.Badala@ct.infn.it,
1384 // Giuseppe.S.Pappalardo@ct.infn.it
1386 TList *list= new TList();
1388 AliITStrack tr(track);
1392 Double_t Pt=(tr).GetPt();
1393 // cout << "\n Pt = " << Pt <<"\n"; //stampa
1395 AliITStracking obj(list, reference, this, fastpoints,
1396 TMath::Abs(Pt),vettid, flagvert, rl);
1401 TVector VecTotLabref(18);
1403 for(lay=5; lay>=0; lay--) {
1404 TVector VecLabref(3);
1405 VecLabref=(*reference).GetLabTrack(lay);
1406 Float_t ClustZ=(*reference).GetZclusterTrack( lay); //aggiunta il 5-3-2001
1408 //{itot++; VecTotLabref(itot)=VecLabref(k);} //cambiata il 5-3-2001
1409 Int_t lpp=(Int_t)VecLabref(k);
1411 TParticle *p=(TParticle*) gAlice->Particle(lpp);
1412 Int_t pcode=p->GetPdgCode();
1413 if(pcode==11) VecLabref(k)=p->GetFirstMother();
1415 itot++; VecTotLabref(itot)=VecLabref(k);
1416 if(VecLabref(k)==0. && ClustZ == 0.) VecTotLabref(itot) =-3.; }
1420 (*reference).Search(VecTotLabref, labref, freq);
1422 //if(freq < 4) labref=-labref;
1423 //if(freq < 6) labref=-labref; // cinque - sei
1424 if(freq < 5) labref=-labref; // cinque - sei
1425 (*reference).SetLabel(labref);
1430 //________________________________________________________________------
1431 void AliITS::DoTracking(Int_t evNumber, Int_t min_t, Int_t max_t,
1432 TFile *file, Bool_t flagvert) {
1433 // ex macro for tracking ITS
1435 printf("begin DoTracking - file %p\n",file);
1437 //const char *pname="75x40_100x60";
1439 Int_t imax=200,jmax=450;
1440 AliITSRad *rl = new AliITSRad(imax,jmax);
1441 //cout<<" dopo costruttore AliITSRad\n"; getchar();
1445 Float_t px,py,pz,x,y,z,pxg,pyg,pzg,ptg;
1449 gAlice->GetEvent(0);
1451 AliKalmanTrack *kkprov;
1452 kkprov->SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
1454 /* //modificato il 26-4-2001
1455 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
1456 AliTPCParam *digp = (AliTPCParam*)file->Get(pname);
1457 if (digp!=0) TPC->SetParam(digp);
1459 TFile *cf=TFile::Open("AliTPCclusters.root");
1460 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
1461 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
1463 AliTPCtracker *tracker = new AliTPCtracker(digp); //aggiunto il 23-5
1466 tracker->LoadInnerSectors();
1467 tracker->LoadOuterSectors();
1469 GoodTrack gt[15000];
1471 ifstream in("itsgood_tracks");
1473 cerr<<"Reading itsgood tracks...\n";
1474 while (in>>gt[ngood].lab>>gt[ngood].code
1475 >>gt[ngood].px >>gt[ngood].py>>gt[ngood].pz
1476 >>gt[ngood].x >>gt[ngood].y >>gt[ngood].z
1477 >>gt[ngood].pxg >>gt[ngood].pyg >>gt[ngood].pzg
1478 >>gt[ngood].ptg >>gt[ngood].flag) {
1482 cerr<<"Too many good tracks !\n";
1484 } // end if ngood==1500
1486 if (!in.eof()) cerr<<"Read error (itsgood_tracks) !\n";
1489 // TFile *tf=TFile::Open("tpctracks.root"); //commentato 26-4-2001
1490 TFile *tf=TFile::Open("AliTPCtracks.root");
1491 if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return ;}
1492 TObjArray tracks(200000);
1493 //TTree *tracktree=(TTree*)tf->Get("TreeT");
1494 TTree *tracktree=(TTree*)tf->Get("TPCf"); //aggiunto il 23-5
1495 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
1496 TBranch *tbranch=tracktree->GetBranch("tracks");
1497 Int_t nentr=(Int_t)tracktree->GetEntries();
1499 /* commentato il 26-4-2001
1500 for (kk=0; kk<nentr; kk++) {
1501 AliTPCtrack *iotrack=new AliTPCtrack;
1502 tbranch->SetAddress(&iotrack);
1503 tracktree->GetEvent(kk);
1504 tracks.AddLast(iotrack);
1507 AliTPCtrack *iotracktpc=0;
1508 for (kk=0; kk<nentr; kk++) {
1509 iotracktpc=new AliTPCtrack;
1510 tbranch->SetAddress(&iotracktpc);
1511 tracktree->GetEvent(kk);
1512 tracker->CookLabel(iotracktpc,0.1); //aggiunto 23-5
1513 tracks.AddLast(iotracktpc);
1518 Int_t nt = tracks.GetEntriesFast();
1519 cerr<<"Number of found tracks "<<nt<<endl;
1524 Double_t ptg=0.,pxg=0.,pyg=0.,pzg=0.;
1526 ////////////// good tracks definition in TPC ///////////////
1528 ofstream out1 ("AliITSTrag.out");
1530 for (i=0; i<ngood; i++) out1 << gt[i].ptg << "\n";
1535 TTree *TR=gAlice->TreeR();
1536 Int_t nent=(Int_t)TR->GetEntries();
1537 TClonesArray *recPoints = RecPoints();
1539 Int_t totalpoints=0;
1540 Int_t *np = new Int_t[nent];
1541 Int_t **vettid = new Int_t* [nent];
1543 for (mod=0; mod<nent; mod++) {
1545 this->ResetRecPoints();
1546 //gAlice->TreeR()->GetEvent(mod+1); //first entry in TreeR is empty
1547 gAlice->TreeR()->GetEvent(mod); //first entry in TreeR is empty
1548 numbpoints = recPoints->GetEntries();
1549 totalpoints+=numbpoints;
1550 np[mod] = numbpoints;
1551 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
1552 vettid[mod] = new Int_t[numbpoints];
1554 for (ii=0;ii<numbpoints; ii++) *(vettid[mod]+ii)=0;
1557 AliTPCtrack *track=0;
1559 if(min_t < 0) {min_t = 0; max_t = nt-1;}
1562 //////////////////// Definition of vertex end its error ////////////////////
1563 ////////////// In the future it will be given by a method //////////////////
1568 Float_t sigmavx=0.0050; // 50 microns
1569 Float_t sigmavy=0.0050; // 50 microns
1570 Float_t sigmavz=0.010; // 100 microns
1572 //Vx+=gRandom->Gaus(0,sigmavx); Vy+=gRandom->Gaus(0,sigmavy); Vz+=gRandom->Gaus(0,sigmavz);
1573 TVector vertex(3), ervertex(3)
1574 vertex(0)=Vx; vertex(1)=Vy; vertex(2)=Vz;
1575 ervertex(0)=sigmavx; ervertex(1)=sigmavy; ervertex(2)=sigmavz;
1576 //////////////////////////////////////////////////////////////////////////
1579 TTree tracktree1("TreeT","Tree with ITS tracks");
1580 AliITSiotrack *iotrack=0;
1581 tracktree1.Branch("ITStracks","AliITSiotrack",&iotrack,32000,0);
1583 ofstream out ("AliITSTra.out");
1584 //ofstream outprova ("AliITSprova.out"); //commentato il 26-4-2001
1587 for (j=min_t; j<=max_t; j++) {
1588 track=(AliTPCtrack*)tracks.UncheckedAt(j);
1590 if (!track) continue;
1591 ////// elimination of not good tracks ////////////
1592 Int_t ilab=TMath::Abs(track->GetLabel());
1594 for (iii=0;iii<ngood;iii++) {
1595 //cout<<" ilab, gt[iii].lab = "<<ilab<<" "<<gt[iii].lab<<"\n";getchar();
1596 if (ilab==gt[iii].lab) {
1605 //cout<<" j flaglab = " <<j<<" "<<flaglab<<"\n"; getchar();
1606 if (!flaglab) continue;
1607 //cout<<" j = " <<j<<"\n"; getchar();
1609 ////// old propagation to the end of TPC //////////////
1611 track->PropagateTo(xk);
1613 track->PropagateTo(xk,42.7,2.27); //C
1615 track->PropagateTo(xk,36.2,1.98e-3); //C02
1617 track->PropagateTo(xk,42.7,2.27); //C
1618 ///////////////////////////////////////////////////
1620 ////// new propagation to the end of TPC //////////////
1622 track->PropagateTo(xk, 28.94, 1.204e-3); //Ne
1624 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1626 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1628 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1630 track->PropagateTo(xk,36.2,1.98e-3); //C02
1632 track->PropagateTo(xk, 24.01, 2.7); //Al
1634 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1636 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1638 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1639 ///////////////////////////////////////////////////////////////
1641 ///////////////////////////////////////////////////////////////
1642 AliITStrack trackITS(*track);
1643 AliITStrack result(*track);
1644 AliITStrack primarytrack(*track);
1646 /////////////////////////////////////////////////////////////////
1648 Vgeant=result.GetVertex();
1650 // Definition of Dv and Zv for vertex constraint
1651 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
1652 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
1653 Double_t uniform= gRandom->Uniform();
1655 if(uniform<=0.5) signdv=-1.;
1659 Double_t Vr=TMath::Sqrt(Vgeant(0)*Vgeant(0)+ Vgeant(1)*Vgeant(1));
1660 Double_t Dv=gRandom->Gaus(signdv*Vr,(Float_t)sigmaDv);
1661 Double_t Zv=gRandom->Gaus(Vgeant(2),(Float_t)sigmaZv);
1663 //cout<<" Dv e Zv = "<<Dv<<" "<<Zv<<"\n";
1664 trackITS.SetDv(Dv); trackITS.SetZv(Zv);
1665 trackITS.SetsigmaDv(sigmaDv); trackITS.SetsigmaZv(sigmaZv);
1666 result.SetDv(Dv); result.SetZv(Zv);
1667 result.SetsigmaDv(sigmaDv); result.SetsigmaZv(sigmaZv);
1668 primarytrack.SetDv(Dv); primarytrack.SetZv(Zv);
1669 primarytrack.SetsigmaDv(sigmaDv); primarytrack.SetsigmaZv(sigmaZv);
1671 ////////////////////////////////////////////////////////////////
1673 primarytrack.PrimaryTrack(rl);
1674 TVector d2=primarytrack.Getd2();
1675 TVector tgl2=primarytrack.Gettgl2();
1676 TVector dtgl=primarytrack.Getdtgl();
1677 trackITS.Setd2(d2); trackITS.Settgl2(tgl2); trackITS.Setdtgl(dtgl);
1678 result.Setd2(d2); result.Settgl2(tgl2); result.Setdtgl(dtgl);
1680 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
1681 result.SetVertex(vertex); result.SetErrorVertex(ervertex);
1685 Tracking(trackITS,&result,recPoints,vettid, flagvert,rl);
1686 // cout<<" progressive track number = "<<j<<"\r";
1688 Int_t NumofCluster=result.GetNumClust();
1689 // cout<<" progressive track number = "<<j<<"\n"; // stampa
1690 Long_t labITS=result.GetLabel();
1691 // cout << " ITS track label = " << labITS << "\n"; // stampa
1692 int lab=track->GetLabel();
1693 // cout << " TPC track label = " << lab <<"\n"; // stampa
1695 //propagation to vertex
1699 result.Propagation(rbeam);
1701 Double_t C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44;
1702 result.GetCElements(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
1703 Double_t pt=TMath::Abs(result.GetPt());
1704 Double_t Dr=result.GetD();
1705 Double_t Z=result.GetZ();
1706 Double_t tgl=result.GetTgl();
1707 Double_t C=result.GetC();
1709 Double_t Dz=Z-(tgl/Cy)*TMath::ASin(result.arga(rbeam));
1712 // cout<<" Dr e dz alla fine = "<<Dr<<" "<<Dz<<"\n"; getchar();
1713 Double_t phi=result.Getphi();
1714 Double_t phivertex = phi - TMath::ASin(result.argA(rbeam));
1715 Double_t duepi=2.*TMath::Pi();
1716 if(phivertex>duepi) phivertex-=duepi;
1717 if(phivertex<0.) phivertex+=duepi;
1718 Double_t Dtot=TMath::Sqrt(Dr*Dr+Dz*Dz);
1720 /////////////////////////////////////////////////////////////////////
1722 Int_t idmodule,idpoint;
1723 if(NumofCluster >=5) { // cinque - sei
1724 //if(NumofCluster ==6) { // cinque - sei
1726 AliITSiotrack outtrack;
1730 iotrack->SetStatePhi(phi);
1731 iotrack->SetStateZ(Z);
1732 iotrack->SetStateD(Dr);
1733 iotrack->SetStateTgl(tgl);
1734 iotrack->SetStateC(C);
1735 Double_t radius=result.Getrtrack();
1736 iotrack->SetRadius(radius);
1738 if(C>0.) charge=-1; else charge=1;
1739 iotrack->SetCharge(charge);
1742 iotrack->SetCovMatrix(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
1744 Double_t px=pt*TMath::Cos(phivertex);
1745 Double_t py=pt*TMath::Sin(phivertex);
1748 Double_t xtrack=Dr*TMath::Sin(phivertex);
1749 Double_t ytrack=Dr*TMath::Cos(phivertex);
1750 Double_t ztrack=Dz+Vgeant(2);
1756 iotrack->SetX(xtrack);
1757 iotrack->SetY(ytrack);
1758 iotrack->SetZ(ztrack);
1759 iotrack->SetLabel(labITS);
1762 for(il=0;il<6; il++){
1763 iotrack->SetIdPoint(il,result.GetIdPoint(il));
1764 iotrack->SetIdModule(il,result.GetIdModule(il));
1768 //cout<<" labITS = "<<labITS<<"\n";
1769 //cout<<" phi z Dr tgl C = "<<phi<<" "<<Z<<" "<<Dr<<" "<<tgl<<" "<<C<<"\n"; getchar();
1771 DataOut(kkk) = ptg; kkk++; DataOut(kkk)=labITS; kkk++; DataOut(kkk)=lab; kkk++;
1773 for (il=0;il<6;il++) {
1774 idpoint=result.GetIdPoint(il);
1775 idmodule=result.GetIdModule(il);
1776 *(vettid[idmodule]+idpoint)=1;
1777 iotrack->SetIdPoint(il,idpoint);
1778 iotrack->SetIdModule(il,idmodule);
1781 // cout<<" +++++++++++++ pt e ptg = "<<pt<<" "<<ptg<<" ++++++++++\n";
1782 /* /// provvisorio il 23-5-2001
1783 Double_t pg=TMath::Sqrt(pxg*pxg+pyg*pyg+pzg*pzg);
1784 Double_t cosl=TMath::Sqrt(1./(1.+tgl*tgl));
1785 Double_t ptot=pt/cosl;
1786 cout<<"ptot e pg = "<<ptot<<" "<<pg<<"\n";
1787 Double_t difpt= (ptot-pg)/pg*100.;
1789 ///////////////////////////////
1790 Double_t difpt= (pt-ptg)/ptg*100.; //coomentato prov il 23-5-2001
1791 DataOut(kkk)=difpt; kkk++;
1792 Double_t lambdag=TMath::ATan(pzg/ptg);
1793 Double_t lam=TMath::ATan(tgl);
1794 Double_t diflam = (lam - lambdag)*1000.;
1795 DataOut(kkk) = diflam; kkk++;
1796 Double_t phig=TMath::ATan2(pyg,pxg);
1797 if(phig<0) phig=2.*TMath::Pi()+phig;
1798 Double_t phi=phivertex;
1800 Double_t difphi = (phi - phig)*1000.;
1801 DataOut(kkk)=difphi; kkk++;
1802 DataOut(kkk)=Dtot*1.e4; kkk++;
1803 DataOut(kkk)=Dr*1.e4; kkk++;
1804 DataOut(kkk)=Dz*1.e4; kkk++;
1806 for (r=0; r<9; r++) { out<<DataOut(r)<<" ";}
1810 } // end if on NumofCluster
1811 //gObjectTable->Print(); // stampa memoria
1812 } // end for (int j=min_t; j<=max_t; j++)
1817 static Bool_t first=kTRUE;
1818 static TFile *tfile;
1821 tfile=new TFile("itstracks.root","RECREATE");
1822 //cout<<"I have opened itstracks.root file "<<endl;
1829 sprintf(hname,"TreeT%d",evNumber);
1831 tracktree1.Write(hname);
1835 TTree *fAli=gAlice->TreeK();
1838 if (fAli) fileAli =fAli->GetCurrentFile();
1841 ///////////////////////////////////////////////////////////////////
1843 printf("delete vectors\n");
1844 if(np) delete [] np;
1845 if(vettid) delete [] vettid;