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.44 2001/04/26 22:44:01 nilsen
19 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
20 done properly in AliITSv???.cxx via SetDefaults.
22 Revision 1.43 2001/04/26 13:22:52 barbera
23 TMatrix and TVector elimininated to speed up the code
25 Revision 1.42 2001/04/25 21:55:12 barbera
26 Updated version to be compatible with actual verion of STEER and TPC
28 Revision 1.41 2001/04/21 15:16:51 barbera
29 Updated with the new SSD reconstruction code
31 Revision 1.40 2001/03/17 15:07:06 mariana
32 Update SDD response parameters
34 Revision 1.39 2001/03/12 17:45:32 hristov
35 Changes needed on Sun with CC 5.0
37 Revision 1.38 2001/03/07 14:04:51 barbera
38 Some vector dimensions increased to cope with full events
40 Revision 1.37 2001/03/07 12:36:35 barbera
41 A change added in the tracking part to manage delta rays
43 Revision 1.36 2001/03/02 19:44:11 barbera
44 modified to taking into account new version tracking v1
46 Revision 1.35 2001/02/28 18:16:46 mariana
47 Make the code compatible with the new AliRun
49 Revision 1.34 2001/02/11 15:51:39 mariana
50 Set protection in MakeBranch
52 Revision 1.33 2001/02/10 22:26:39 mariana
53 Move the initialization of the containers for raw clusters in MakeTreeC()
55 Revision 1.32 2001/02/08 23:55:31 nilsen
56 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
57 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
59 Revision 1.31 2001/02/02 23:57:28 nilsen
60 Added include file that are no londer included in AliITSgeom.h
62 Revision 1.30 2001/01/30 09:23:13 hristov
63 Streamers removed (R.Brun)
65 Revision 1.29 2001/01/26 20:01:09 hristov
66 Major upgrade of AliRoot code
68 Revision 1.28 2000/12/18 14:02:00 barbera
69 new version of the ITS tracking to take into account the new TPC track parametrization
71 Revision 1.27 2000/12/08 13:49:27 barbera
72 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
74 Revision 1.26 2000/11/27 13:12:13 barbera
75 New version containing the files for tracking
77 Revision 1.25 2000/11/12 22:38:05 barbera
78 Added header file for the SPD Bari model
80 Revision 1.24 2000/10/09 22:18:12 barbera
81 Bug fixes from MAriana to le AliITStest.C run correctly
83 Revision 1.23 2000/10/05 20:47:42 nilsen
84 fixed dependencies of include files. Tryed but failed to get a root automaticly
85 generates streamer function to work. Modified SetDefaults.
87 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
88 Needed to include stdlib.h
91 Revision 1.22 2000/10/04 19:45:52 barbera
92 Corrected by F. Carminati for v3.04
94 Revision 1.21 2000/10/02 21:28:08 fca
95 Removal of useless dependecies via forward declarations
97 Revision 1.20 2000/10/02 16:31:39 barbera
100 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
101 General code clean-up (e.g., printf -> cout)
103 Revision 1.19 2000/09/22 12:13:25 nilsen
104 Patches and updates for fixes to this and other routines.
106 Revision 1.18 2000/07/12 05:32:20 fca
107 Correcting several syntax problem with static members
109 Revision 1.17 2000/07/10 16:07:18 fca
110 Release version of ITS code
112 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
113 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
115 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
116 //fixed FillModule. Removed fi(fabs(xl)<dx....
118 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
119 This is the version of the files after the merging done in December 1999.
120 See the ReadMe110100.txt file for details
122 Revision 1.9 1999/11/14 14:33:25 fca
123 Correct problems with distructors and pointers, thanks to I.Hrivnacova
125 Revision 1.8 1999/09/29 09:24:19 fca
126 Introduction of the Copyright and cvs Log
130 ///////////////////////////////////////////////////////////////////////////////
132 // An overview of the basic philosophy of the ITS code development
133 // and analysis is show in the figure below.
136 <img src="picts/ITS/ITS_Analysis_schema.gif">
139 <font size=+2 color=red>
140 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
141 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
147 // AliITS. Inner Traking System base class.
148 // This class contains the base procedures for the Inner Tracking System
152 <img src="picts/ITS/AliITS_Class_Diagram.gif">
155 <font size=+2 color=red>
156 <p>This show the class diagram of the different elements that are part of
164 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
167 // Modified and documented by Bjorn S. Nilsen
171 // Modified and documented by A. Bologna
174 // AliITS is the general base class for the ITS. Also see AliDetector for
175 // futher information.
177 ///////////////////////////////////////////////////////////////////////////////
178 #include <iostream.h>
186 #include <TClonesArray.h>
188 #include <TObjectTable.h>
192 #include <TParticle.h>
197 #include "AliITSMap.h"
198 #include "AliITSDetType.h"
199 #include "AliITSClusterFinder.h"
200 //#include "AliITSsimulation.h"
201 #include "AliITSsimulationSPD.h"
202 #include "AliITSsimulationSDD.h"
203 #include "AliITSsimulationSSD.h"
204 #include "AliITSresponse.h"
205 #include "AliITSsegmentationSPD.h"
206 #include "AliITSresponseSPD.h"
207 #include "AliITSresponseSPDbari.h"
208 #include "AliITSsegmentationSDD.h"
209 #include "AliITSresponseSDD.h"
210 #include "AliITSsegmentationSSD.h"
211 #include "AliITSresponseSSD.h"
212 #include "AliITShit.h"
213 #include "AliITSgeom.h"
214 #include "AliITSdigit.h"
215 #include "AliITSmodule.h"
216 #include "AliITSRecPoint.h"
217 #include "AliITSRawCluster.h"
220 #include "AliKalmanTrack.h"
223 #include "AliITStrack.h"
224 #include "AliITSiotrack.h"
225 #include "AliITStracking.h"
226 #include "AliITSRad.h"
227 #include "../TPC/AliTPC.h"
228 #include "../TPC/AliTPCParam.h"
233 //_____________________________________________________________________________
234 AliITS::AliITS() : AliDetector() {
236 // Default initialiser for ITS
237 // The default constructor of the AliITS class. In addition to
238 // creating the AliITS class it zeros the variables fIshunt (a member
239 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
240 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
248 fNDetTypes = kNTYPES;
267 //_____________________________________________________________________________
268 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
270 // Default initialiser for ITS
271 // The constructor of the AliITS class. In addition to creating the
272 // AliITS class, it allocates memory for the TClonesArrays fHits and
273 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
274 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
275 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
276 // macro display.C AliITS also sets the marker color to red. The variables
277 // passes with this constructor, const char *name and *title, are used by
278 // the constructor of AliDetector class. See AliDetector class for a
279 // description of these parameters and its constructor functions.
283 fHits = new TClonesArray("AliITShit", 1560);
284 gAlice->AddHitList(fHits);
286 fNDetTypes = kNTYPES;
288 fNdtype = new Int_t[kNTYPES];
289 fDtype = new TObjArray(kNTYPES);
291 fNctype = new Int_t[kNTYPES];
292 fCtype = new TObjArray(kNTYPES);
308 fDetTypes = new TObjArray(kNTYPES);
311 for(i=0;i<kNTYPES;i++) {
312 (*fDetTypes)[i]=new AliITSDetType();
318 SetMarkerColor(kRed);
322 //___________________________________________________________________________
323 AliITS::AliITS(AliITS &source){
325 if(this==&source) return;
326 Error("AliITS::Copy constructor",
327 "You are not allowed to make a copy of the AliITS");
330 //____________________________________________________________________________
331 AliITS& AliITS::operator=(AliITS &source){
332 // assignment operator
333 if(this==&source) return *this;
334 Error("AliITS::operator=",
335 "You are not allowed to make a copy of the AliITS");
337 return *this; //fake return
339 //____________________________________________________________________________
340 void AliITS::ClearModules(){
341 //clear the modules TObjArray
343 if(fITSmodules) fITSmodules->Delete();
346 //_____________________________________________________________________________
349 // Default distructor for ITS
350 // The default destructor of the AliITS class. In addition to deleting
351 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
352 // fIdSens, fIdName, and fITSpoints.
359 // delete fIdName; // TObjArray of TObjStrings
360 if(fIdName!=0) delete[] fIdName; // Array of TStrings
361 if(fIdSens!=0) delete[] fIdSens;
363 this->ClearModules();
365 }// end if fITSmodules!=0
385 if (fTreeC) delete fTreeC;
387 if (fITSgeom) delete fITSgeom;
391 //___________________________________________
392 AliITSDetType* AliITS::DetType(Int_t id)
394 //return pointer to id detector type
395 return ((AliITSDetType*) (*fDetTypes)[id]);
398 //___________________________________________
399 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
401 //set the digit and cluster classes to be used for the id detector type
402 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
405 //___________________________________________
406 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
408 //set the response model for the id detector type
410 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
414 //___________________________________________
415 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
417 //set the segmentation model for the id detector type
419 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
423 //___________________________________________
424 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
426 //set the simulation model for the id detector type
428 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
431 //___________________________________________
432 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
434 //set the cluster finder model for the id detector type
436 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
440 //_____________________________________________________________________________
441 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
444 // The function to add information to the AliITShit class. See the
445 // AliITShit class for a full description. This function allocates the
446 // necessary new space for the hit information and passes the variable
447 // track, and the pointers *vol and *hits to the AliITShit constructor
450 TClonesArray &lhits = *fHits;
451 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
453 //_____________________________________________________________________________
454 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
456 // add a real digit - as coming from data
458 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
459 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
462 //_____________________________________________________________________________
463 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
466 // add a simulated digit
468 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
473 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
476 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
479 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
485 //_____________________________________________________________________________
486 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
488 // add a simulated digit to the list
490 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
494 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
497 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
500 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
506 //_____________________________________________________________________________
507 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
510 // add a cluster to the list
512 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
517 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
520 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
523 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
530 //_____________________________________________________________________________
531 void AliITS::AddRecPoint(const AliITSRecPoint &r)
534 // Add a reconstructed space point to the list
536 TClonesArray &lrecp = *fRecPoints;
537 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
541 //____________________________________________
542 void AliITS::ResetDigits()
545 // Reset number of digits and the digits array for the ITS detector
551 for (i=0;i<kNTYPES;i++ ) {
552 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
553 if (fNdtype) fNdtype[i]=0;
557 //____________________________________________
558 void AliITS::ResetDigits(Int_t i)
561 // Reset number of digits and the digits array for this branch
563 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
564 if (fNdtype) fNdtype[i]=0;
568 //____________________________________________
569 void AliITS::ResetClusters()
572 // Reset number of clusters and the clusters array for ITS
576 for (i=0;i<kNTYPES;i++ ) {
577 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
578 if (fNctype) fNctype[i]=0;
583 //____________________________________________
584 void AliITS::ResetClusters(Int_t i)
587 // Reset number of clusters and the clusters array for this branch
589 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
590 if (fNctype) fNctype[i]=0;
595 //____________________________________________
596 void AliITS::ResetRecPoints()
599 // Reset number of rec points and the rec points array
601 if (fRecPoints) fRecPoints->Clear();
606 //_____________________________________________________________________________
607 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
609 // Distance from mouse to ITS on the screen. Dummy routine
610 // A dummy routine used by the ROOT macro display.C to allow for the
611 // use of the mouse (pointing device) in the macro. In general this should
612 // never be called. If it is it returns the number 9999 for any value of
618 //_____________________________________________________________________________
621 // Initialise ITS after it has been built
622 // This routine initializes the AliITS class. It is intended to be called
623 // from the Init function in AliITSv?. Besides displaying a banner
624 // indicating that it has been called it initializes the array fIdSens
625 // and sets the default segmentation, response, digit and raw cluster classes
626 // Therefore it should be called after a call to CreateGeometry.
633 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
637 //_____________________________________________________________________________
638 void AliITS::SetDefaults()
640 // sets the default segmentation, response, digit and raw cluster classes
642 printf("SetDefaults\n");
644 AliITSDetType *iDetType;
650 if (!iDetType->GetSegmentationModel()) {
651 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
652 SetSegmentationModel(0,seg0);
654 if (!iDetType->GetResponseModel()) {
655 SetResponseModel(0,new AliITSresponseSPD());
657 // set digit and raw cluster classes to be used
659 const char *kData0=(iDetType->GetResponseModel())->DataType();
660 if (strstr(kData0,"real")) {
661 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
662 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
666 if (!iDetType->GetResponseModel()) {
667 SetResponseModel(1,new AliITSresponseSDD());
669 AliITSresponse *resp1=iDetType->GetResponseModel();
670 if (!iDetType->GetSegmentationModel()) {
671 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
672 SetSegmentationModel(1,seg1);
674 const char *kData1=(iDetType->GetResponseModel())->DataType();
675 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
676 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
677 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
678 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
682 if (!iDetType->GetSegmentationModel()) {
683 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
684 SetSegmentationModel(2,seg2);
686 if (!iDetType->GetResponseModel()) {
687 SetResponseModel(2,new AliITSresponseSSD());
689 const char *kData2=(iDetType->GetResponseModel())->DataType();
690 if (strstr(kData2,"real")) {
691 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
692 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
695 Warning("SetDefaults","Only the three basic detector types are initialised!");
702 //_____________________________________________________________________________
703 void AliITS::SetDefaultSimulation()
708 //_____________________________________________________________________________
709 void AliITS::SetDefaultClusterFinders()
714 //_____________________________________________________________________________
716 void AliITS::MakeTreeC(Option_t *option)
718 // create a separate tree to store the clusters
720 // cout << "AliITS::MakeTreeC" << endl;
722 const char *optC = strstr(option,"C");
723 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
726 Int_t buffersize = 4000;
729 const char *det[3] = {"SPD","SDD","SSD"};
734 // one branch for Clusters per type of detector
736 for (i=0; i<kNTYPES ;i++) {
737 AliITSDetType *iDetType=DetType(i);
738 iDetType->GetClassNames(digclass,clclass);
740 (*fCtype)[i] = new TClonesArray(clclass,10000);
741 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
742 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
743 if (fCtype && fTreeC) {
744 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
745 // cout << "Making Branch " << branchname;
746 // cout << " for Clusters of detector type " << i+1 << endl;
752 //_____________________________________________________________________________
753 void AliITS::GetTreeC(Int_t event)
756 // cout << "AliITS::GetTreeC" << endl;
758 // get the clusters tree for this event and set the branch address
762 const char *det[3] = {"SPD","SDD","SSD"};
769 sprintf(treeName,"TreeC%d",event);
770 fTreeC = (TTree*)gDirectory->Get(treeName);
775 for (i=0; i<kNTYPES; i++) {
776 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
777 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
779 branch = fTreeC->GetBranch(branchname);
780 if (branch) branch->SetAddress(&((*fCtype)[i]));
784 Error("AliITS::GetTreeC",
785 "cannot find Clusters Tree for event:%d\n",event);
789 //_____________________________________________________________________________
790 void AliITS::MakeBranch(Option_t* option, char *file)
793 // Creates Tree branches for the ITS.
796 Int_t buffersize = 4000;
798 sprintf(branchname,"%s",GetName());
800 AliDetector::MakeBranch(option,file);
802 const char *cD = strstr(option,"D");
803 const char *cR = strstr(option,"R");
807 // one branch for digits per type of detector
809 const char *det[3] = {"SPD","SDD","SSD"};
815 for (i=0; i<kNTYPES ;i++) {
816 AliITSDetType *iDetType=DetType(i);
817 iDetType->GetClassNames(digclass,clclass);
819 if(!((*fDtype)[i])) (*fDtype)[i] = new TClonesArray(digclass,10000);
823 for (i=0; i<kNTYPES ;i++) {
824 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
825 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
826 if (fDtype && gAlice->TreeD()) {
827 gAlice->MakeBranchInTree(gAlice->TreeD(),
828 branchname, &((*fDtype)[i]), buffersize, file);
829 // cout << "Making Branch " << branchname;
830 // cout << " for digits of type "<< i+1 << endl;
837 // only one branch for rec points for all detector types
839 sprintf(branchname,"%sRecPoints",GetName());
841 if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",10000);
843 if (fRecPoints && gAlice->TreeR()) {
844 gAlice->MakeBranchInTree(gAlice->TreeR(),
845 branchname, &fRecPoints, buffersize, file) ;
846 // cout << "Making Branch " << branchname;
847 // cout << " for reconstructed space points" << endl;
852 //___________________________________________
853 void AliITS::SetTreeAddress()
856 // Set branch address for the Trees.
859 AliDetector::SetTreeAddress();
861 const char *det[3] = {"SPD","SDD","SSD"};
864 TTree *treeD = gAlice->TreeD();
865 TTree *treeR = gAlice->TreeR();
869 for (i=0; i<kNTYPES; i++) {
870 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
871 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
873 branch = treeD->GetBranch(branchname);
874 if (branch) branch->SetAddress(&((*fDtype)[i]));
881 sprintf(branchname,"%sRecPoints",GetName());
882 branch = treeR->GetBranch(branchname);
883 if (branch) branch->SetAddress(&fRecPoints);
889 //____________________________________________________________________________
890 void AliITS::InitModules(Int_t size,Int_t &nmodules){
892 //initialize the modules array
895 fITSmodules->Delete();
899 Int_t nl,indexMAX,index;
901 if(size<=0){ // default to using data stored in AliITSgeom
903 Error("AliITS::InitModules",
904 "in AliITS::InitModule fITSgeom not defined\n");
906 } // end if fITSgeom==0
907 nl = fITSgeom->GetNlayers();
908 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
909 fITSgeom->GetNdetectors(nl))+1;
911 fITSmodules = new TObjArray(indexMAX);
912 for(index=0;index<indexMAX;index++){
913 fITSmodules->AddAt( new AliITSmodule(index),index);
916 fITSmodules = new TObjArray(size);
917 for(index=0;index<size;index++) {
918 fITSmodules->AddAt( new AliITSmodule(index),index);
925 //____________________________________________________________________________
926 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
928 // fill the modules with the sorted by module hits; add hits from background
932 static TTree *trH1; //Tree with background hits
933 static TClonesArray *fHits2; //List of hits for one track only
935 static Bool_t first=kTRUE;
937 const char *addBgr = strstr(option,"Add");
942 // cout<<"filename "<<filename<<endl;
943 file=new TFile(filename);
944 // cout<<"I have opened "<<filename<<" file "<<endl;
945 fHits2 = new TClonesArray("AliITShit",1000 );
950 // Get Hits Tree header from file
951 if(fHits2) fHits2->Clear();
952 if(trH1) delete trH1;
956 sprintf(treeName,"TreeH%d",bgrev);
957 trH1 = (TTree*)gDirectory->Get(treeName);
958 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
961 Error("AliITS::FillModules",
962 "cannot find Hits Tree for event:%d\n",bgrev);
964 // Set branch addresses
967 sprintf(branchname,"%s",GetName());
968 if (trH1 && fHits2) {
969 branch = trH1->GetBranch(branchname);
970 if (branch) branch->SetAddress(&fHits2);
974 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
975 //printf("background - ntracks1 - %d\n",ntracks1);
978 //Int_t npart = gAlice->GetEvent(evnt);
979 //if(npart<=0) return;
980 TClonesArray *itsHits = this->Hits();
981 Int_t lay,lad,det,index;
985 TTree *iTH = gAlice->TreeH();
986 Int_t ntracks =(Int_t) iTH->GetEntries();
989 for(t=0; t<ntracks; t++){
992 Int_t nhits = itsHits->GetEntriesFast();
993 //printf("nhits %d\n",nhits);
994 if (!nhits) continue;
995 for(h=0; h<nhits; h++){
996 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
997 itsHit->GetDetectorID(lay,lad,det);
998 // temporarily index=det-1 !!!
999 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1002 mod = this->GetModule(index);
1003 mod->AddHit(itsHit,t,h);
1004 } // end loop over hits
1005 } // end loop over tracks
1007 // open the file with background
1011 ntracks =(Int_t)trH1->GetEntries();
1012 //printf("background - ntracks1 %d\n",ntracks);
1013 //printf("background - Start loop over tracks \n");
1016 for (track=0; track<ntracks; track++) {
1018 if (fHits2) fHits2->Clear();
1019 trH1->GetEvent(track);
1021 for(i=0;i<fHits2->GetEntriesFast();++i) {
1023 itsHit=(AliITShit*) (*fHits2)[i];
1024 itsHit->GetDetectorID(lay,lad,det);
1025 // temporarily index=det-1 !!!
1026 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1029 mod = this->GetModule(index);
1030 mod->AddHit(itsHit,track,i);
1031 } // end loop over hits
1032 } // end loop over tracks
1034 TTree *fAli=gAlice->TreeK();
1037 if (fAli) fileAli =fAli->GetCurrentFile();
1042 //gObjectTable->Print();
1046 //____________________________________________________________________________
1048 void AliITS::SDigits2Digits()
1051 AliITSgeom *geom = GetITSgeom();
1054 AliITSDetType *iDetType;
1055 iDetType=DetType(0);
1056 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
1057 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
1058 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
1059 SetSimulationModel(0,sim0);
1061 // printf("SPD dimensions %f %f \n",seg0->Dx(),seg0->Dz());
1062 // printf("SPD npixels %d %d \n",seg0->Npz(),seg0->Npx());
1063 // printf("SPD pitches %d %d \n",seg0->Dpz(0),seg0->Dpx(0));
1067 //Set response functions
1068 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
1070 iDetType=DetType(1);
1071 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
1073 res1=new AliITSresponseSDD();
1074 SetResponseModel(1,res1);
1076 Float_t noise, baseline;
1077 res1->GetNoiseParam(noise,baseline);
1078 Float_t noise_after_el = res1->GetNoiseAfterElectronics();
1079 Float_t fCutAmp = baseline + 2.*noise_after_el;
1080 Int_t cp[8]={0,0,(int)fCutAmp,(int)fCutAmp,0,0,0,0}; //1D
1081 res1->SetCompressParam(cp);
1082 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
1084 seg1 = new AliITSsegmentationSDD(geom,res1);
1085 SetSegmentationModel(1,seg1);
1087 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
1088 SetSimulationModel(1,sim1);
1091 iDetType=DetType(2);
1092 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
1093 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
1094 res2->SetSigmaSpread(3.,2.);
1095 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
1096 SetSimulationModel(2,sim2);
1098 cerr<<"Digitizing ITS...\n";
1102 HitsToDigits(0,0,-1," ","All"," ");
1103 timer.Stop(); timer.Print();
1111 //____________________________________________________________________________
1112 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
1114 // keep galice.root for signal and name differently the file for
1115 // background when add! otherwise the track info for signal will be lost !
1117 // the condition below will disappear when the geom class will be
1118 // initialised for all versions - for the moment it is only for v5 !
1119 // 7 is the SDD beam test version
1120 Int_t ver = this->IsVersion();
1121 if(ver!=5 && ver!=7) return;
1123 const char *all = strstr(opt,"All");
1124 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1125 // cout<<" 1 AliITS "<<endl;
1127 InitModules(size,nmodules);
1128 // cout<<" 2 AliITS "<<endl;
1129 FillModules(evNumber,bgrev,nmodules,option,filename);
1130 // cout<<" 3 AliITS "<<endl;
1133 AliITSsimulation* sim;
1134 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
1135 AliITSgeom *geom = GetITSgeom();
1138 // Int_t lay, lad, detect;
1140 for (id=0;id<kNTYPES;id++) {
1141 if (!all && !det[id]) continue;
1142 //branch = (TBranch*)branches->UncheckedAt(id);
1143 AliITSDetType *iDetType=DetType(id);
1144 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1147 Error("HitsToDigits","The simulation class was not instantiated!");
1149 // or SetDefaultSimulation();
1153 first = geom->GetStartDet(id);
1154 last = geom->GetLastDet(id);
1155 } else first=last=0;
1156 // cout << "det type " << id << " first, last "<< first << last << endl;
1157 for(module=first;module<=last;module++) {
1158 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1160 geom->GetModuleId(module,lay, lad, detect);
1162 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(6);
1164 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(5);
1166 sim->DigitiseModule(mod,module,evNumber);
1167 // fills all branches - wasted disk space
1168 gAlice->TreeD()->Fill();
1170 // try and fill only the branch
1173 } // loop over modules
1174 } // loop over detector types
1178 // Int_t nentries=(Int_t)
1179 gAlice->TreeD()->GetEntries();
1180 // cout << "nentries in TreeD" << nentries << endl;
1183 sprintf(hname,"TreeD%d",evNumber);
1184 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1186 gAlice->TreeD()->Reset();
1191 //____________________________________________________________________________
1192 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1194 // cluster finding and reconstruction of space points
1196 // the condition below will disappear when the geom class will be
1197 // initialised for all versions - for the moment it is only for v5 !
1198 // 7 is the SDD beam test version
1199 Int_t ver = this->IsVersion();
1202 const char *all = strstr(opt,"All");
1203 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1205 static Bool_t first=kTRUE;
1206 if (!TreeC() && first) {
1211 TTree *treeC=TreeC();
1215 AliITSClusterFinder* rec;
1217 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1218 AliITSgeom *geom = GetITSgeom();
1221 for (id=0;id<kNTYPES;id++) {
1222 if (!all && !det[id]) continue;
1223 //branch = (TBranch*)branches->UncheckedAt(id);
1224 AliITSDetType *iDetType=DetType(id);
1225 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1227 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1229 // or SetDefaultClusterFinders();
1231 TClonesArray *itsDigits = this->DigitsAddress(id);
1235 first = geom->GetStartDet(id);
1236 last = geom->GetLastDet(id);
1237 } else first=last=0;
1238 //printf("first last %d %d\n",first,last);
1239 for(module=first;module<=last;module++) {
1240 this->ResetDigits();
1241 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1242 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1243 Int_t ndigits = itsDigits->GetEntriesFast();
1244 if (ndigits) rec->FindRawClusters(module);
1245 gAlice->TreeR()->Fill();
1249 // try and fill only the branch
1251 //ResetRecPoints(id);
1252 } // loop over modules
1253 } // loop over detector types
1256 // Int_t nentries=(Int_t)
1257 gAlice->TreeR()->GetEntries();
1258 // Int_t ncentries=(Int_t)
1259 treeC->GetEntries();
1260 // cout << " nentries ncentries " << nentries << ncentries << endl;
1263 sprintf(hname,"TreeR%d",evNumber);
1264 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1266 gAlice->TreeR()->Reset();
1268 sprintf(hname,"TreeC%d",evNumber);
1269 treeC->Write(hname,TObject::kOverwrite);
1274 //____________________________________________________________________________
1275 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1276 Option_t *option,Option_t *opt,Text_t *filename)
1278 // keep galice.root for signal and name differently the file for
1279 // background when add! otherwise the track info for signal will be lost !
1282 // the condition below will disappear when the geom class will be
1283 // initialised for all versions - for the moment it is only for v5 !
1284 Int_t ver = this->IsVersion();
1287 const char *all = strstr(opt,"All");
1288 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1291 InitModules(size,nmodules);
1292 FillModules(evNumber,bgrev,nmodules,option,filename);
1295 AliITSsimulation* sim;
1296 AliITSgeom *geom = GetITSgeom();
1298 TRandom *random=new TRandom[9];
1299 random[0].SetSeed(111);
1300 random[1].SetSeed(222);
1301 random[2].SetSeed(333);
1302 random[3].SetSeed(444);
1303 random[4].SetSeed(555);
1304 random[5].SetSeed(666);
1305 random[6].SetSeed(777);
1306 random[7].SetSeed(888);
1307 random[8].SetSeed(999);
1311 for (id=0;id<kNTYPES;id++) {
1312 if (!all && !det[id]) continue;
1313 AliITSDetType *iDetType=DetType(id);
1314 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1316 Error("HitsToFastPoints","The simulation class was not instantiated!");
1318 // or SetDefaultSimulation();
1320 Int_t first = geom->GetStartDet(id);
1321 Int_t last = geom->GetLastDet(id);
1322 for(module=first;module<=last;module++) {
1323 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1324 sim->CreateFastRecPoints(mod,module,random);
1325 gAlice->TreeR()->Fill();
1327 } // loop over modules
1328 } // loop over detector types
1333 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1336 sprintf(hname,"TreeR%d",evNumber);
1337 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1339 gAlice->TreeR()->Reset();
1345 //________________________________________________________________
1346 AliITStrack AliITS::Tracking(AliITStrack &track, AliITStrack *reference,TObjArray *fastpoints, Int_t
1347 **vettid, Bool_t flagvert, AliITSRad *rl ) {
1349 //Origin A. Badala' and G.S. Pappalardo: e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1352 TList *list= new TList();
1354 AliITStrack tr(track);
1358 Double_t Pt=(tr).GetPt();
1359 // cout << "\n Pt = " << Pt <<"\n"; //stampa
1361 AliITStracking obj(list, reference, this, fastpoints,TMath::Abs(Pt),vettid, flagvert, rl);
1366 TVector VecTotLabref(18);
1368 for(lay=5; lay>=0; lay--) {
1369 TVector VecLabref(3);
1370 VecLabref=(*reference).GetLabTrack(lay);
1371 Float_t ClustZ=(*reference).GetZclusterTrack( lay); //aggiunta il 5-3-2001
1372 for(k=0; k<3; k++){ //{itot++; VecTotLabref(itot)=VecLabref(k);} //cambiata il 5-3-2001
1373 Int_t lpp=(Int_t)VecLabref(k);
1375 TParticle *p=(TParticle*) gAlice->Particle(lpp);
1376 Int_t pcode=p->GetPdgCode();
1377 if(pcode==11) VecLabref(k)=p->GetFirstMother();
1379 itot++; VecTotLabref(itot)=VecLabref(k);
1380 if(VecLabref(k)==0. && ClustZ == 0.) VecTotLabref(itot) =-3.; }
1384 (*reference).Search(VecTotLabref, labref, freq);
1386 //if(freq < 4) labref=-labref;
1387 //if(freq < 6) labref=-labref; // cinque - sei
1388 if(freq < 5) labref=-labref; // cinque - sei
1389 (*reference).SetLabel(labref);
1397 //________________________________________________________________
1401 void AliITS::DoTracking(Int_t evNumber, Int_t min_t, Int_t max_t, TFile *file, Bool_t flagvert) {
1403 // ex macro for tracking ITS
1405 printf("begin DoTracking - file %p\n",file);
1407 //const char *pname="75x40_100x60";
1409 Int_t imax=200,jmax=450;
1410 AliITSRad *rl = new AliITSRad(imax,jmax);
1411 //cout<<" dopo costruttore AliITSRad\n"; getchar();
1415 Float_t px,py,pz,x,y,z,pxg,pyg,pzg,ptg;
1420 gAlice->GetEvent(0);
1422 AliKalmanTrack *kkprov;
1423 kkprov->SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
1425 /* //modificato il 26-4-2001
1426 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
1427 AliTPCParam *digp = (AliTPCParam*)file->Get(pname);
1428 if (digp!=0) TPC->SetParam(digp);
1430 TFile *cf=TFile::Open("AliTPCclusters.root");
1431 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
1432 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
1435 GoodTrack gt[15000];
1437 ifstream in("itsgood_tracks");
1439 cerr<<"Reading itsgood tracks...\n";
1440 while (in>>gt[ngood].lab>>gt[ngood].code
1441 >>gt[ngood].px >>gt[ngood].py>>gt[ngood].pz
1442 >>gt[ngood].x >>gt[ngood].y >>gt[ngood].z
1443 >>gt[ngood].pxg >>gt[ngood].pyg >>gt[ngood].pzg
1444 >>gt[ngood].ptg >>gt[ngood].flag) {
1448 cerr<<"Too many good tracks !\n";
1452 if (!in.eof()) cerr<<"Read error (itsgood_tracks) !\n";
1456 // TFile *tf=TFile::Open("tpctracks.root"); //commentato 26-4-2001
1457 TFile *tf=TFile::Open("AliTPCtracks.root");
1458 if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return ;}
1459 TObjArray tracks(200000);
1460 TTree *tracktree=(TTree*)tf->Get("TreeT");
1461 TBranch *tbranch=tracktree->GetBranch("tracks");
1462 Int_t nentr=(Int_t)tracktree->GetEntries();
1464 /* commentato il 26-4-2001
1465 for (kk=0; kk<nentr; kk++) {
1466 AliTPCtrack *iotrack=new AliTPCtrack;
1467 tbranch->SetAddress(&iotrack);
1468 tracktree->GetEvent(kk);
1469 tracks.AddLast(iotrack);
1472 AliTPCtrack *iotracktpc=0;
1473 for (kk=0; kk<nentr; kk++) {
1474 iotracktpc=new AliTPCtrack;
1475 tbranch->SetAddress(&iotracktpc);
1476 tracktree->GetEvent(kk);
1477 tracks.AddLast(iotracktpc);
1482 Int_t nt = tracks.GetEntriesFast();
1483 cerr<<"Number of found tracks "<<nt<<endl;
1488 Double_t ptg=0.,pxg=0.,pyg=0.,pzg=0.;
1490 ////////////////////////////// good tracks definition in TPC ////////////////////////////////
1492 ofstream out1 ("AliITSTrag.out");
1494 for (i=0; i<ngood; i++) out1 << gt[i].ptg << "\n";
1499 TTree *TR=gAlice->TreeR();
1500 Int_t nent=(Int_t)TR->GetEntries();
1501 TClonesArray *recPoints = RecPoints();
1503 Int_t totalpoints=0;
1504 Int_t *np = new Int_t[nent];
1505 Int_t **vettid = new Int_t* [nent];
1507 for (mod=0; mod<nent; mod++) {
1509 this->ResetRecPoints();
1510 //gAlice->TreeR()->GetEvent(mod+1); //first entry in TreeR is empty
1511 gAlice->TreeR()->GetEvent(mod); //first entry in TreeR is empty
1512 numbpoints = recPoints->GetEntries();
1513 totalpoints+=numbpoints;
1514 np[mod] = numbpoints;
1515 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n"; getchar();
1516 vettid[mod] = new Int_t[numbpoints];
1518 for (ii=0;ii<numbpoints; ii++) *(vettid[mod]+ii)=0;
1521 AliTPCtrack *track=0;
1524 if(min_t < 0) {min_t = 0; max_t = nt-1;}
1527 ///////////////////////////////// Definition of vertex end its error ////////////////////////////
1528 ////////////////////////// In the future it will be given by a method ///////////////////////////
1533 Float_t sigmavx=0.0050; // 50 microns
1534 Float_t sigmavy=0.0050; // 50 microns
1535 Float_t sigmavz=0.010; // 100 microns
1537 //Vx+=gRandom->Gaus(0,sigmavx); Vy+=gRandom->Gaus(0,sigmavy); Vz+=gRandom->Gaus(0,sigmavz);
1538 TVector vertex(3), ervertex(3)
1539 vertex(0)=Vx; vertex(1)=Vy; vertex(2)=Vz;
1540 ervertex(0)=sigmavx; ervertex(1)=sigmavy; ervertex(2)=sigmavz;
1541 /////////////////////////////////////////////////////////////////////////////////////////////////
1545 TTree tracktree1("TreeT","Tree with ITS tracks");
1546 AliITSiotrack *iotrack=0;
1547 tracktree1.Branch("ITStracks","AliITSiotrack",&iotrack,32000,0);
1549 ofstream out ("AliITSTra.out");
1550 //ofstream outprova ("AliITSprova.out"); //commentato il 26-4-2001
1553 for (j=min_t; j<=max_t; j++) {
1554 track=(AliTPCtrack*)tracks.UncheckedAt(j);
1556 if (!track) continue;
1557 ////// elimination of not good tracks ////////////
1558 Int_t ilab=TMath::Abs(track->GetLabel());
1560 for (iii=0;iii<ngood;iii++) {
1561 //cout<<" ilab, gt[iii].lab = "<<ilab<<" "<<gt[iii].lab<<"\n"; getchar();
1562 if (ilab==gt[iii].lab) {
1571 //cout<<" j flaglab = " <<j<<" "<<flaglab<<"\n"; getchar();
1572 if (!flaglab) continue;
1573 //cout<<" j = " <<j<<"\n"; getchar();
1575 ////// old propagation to the end of TPC //////////////
1577 track->PropagateTo(xk);
1579 track->PropagateTo(xk,42.7,2.27); //C
1581 track->PropagateTo(xk,36.2,1.98e-3); //C02
1583 track->PropagateTo(xk,42.7,2.27); //C
1584 ///////////////////////////////////////////////////
1587 ////// new propagation to the end of TPC //////////////
1589 track->PropagateTo(xk, 28.94, 1.204e-3); //Ne
1591 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1593 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1595 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1597 track->PropagateTo(xk,36.2,1.98e-3); //C02
1599 track->PropagateTo(xk, 24.01, 2.7); //Al
1601 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1603 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1605 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1607 ///////////////////////////////////////////////////////////////
1609 ///////////////////////////////////////////////////////////////
1610 AliITStrack trackITS(*track);
1611 AliITStrack result(*track);
1612 AliITStrack primarytrack(*track);
1614 ///////////////////////////////////////////////////////////////////////////////////////////////
1616 Vgeant=result.GetVertex();
1618 // Definition of Dv and Zv for vertex constraint
1619 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
1620 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
1621 Double_t uniform= gRandom->Uniform();
1623 if(uniform<=0.5) signdv=-1.;
1627 Double_t Vr=TMath::Sqrt(Vgeant(0)*Vgeant(0)+ Vgeant(1)*Vgeant(1));
1628 Double_t Dv=gRandom->Gaus(signdv*Vr,(Float_t)sigmaDv);
1629 Double_t Zv=gRandom->Gaus(Vgeant(2),(Float_t)sigmaZv);
1631 //cout<<" Dv e Zv = "<<Dv<<" "<<Zv<<"\n";
1632 trackITS.SetDv(Dv); trackITS.SetZv(Zv);
1633 trackITS.SetsigmaDv(sigmaDv); trackITS.SetsigmaZv(sigmaZv);
1634 result.SetDv(Dv); result.SetZv(Zv);
1635 result.SetsigmaDv(sigmaDv); result.SetsigmaZv(sigmaZv);
1636 primarytrack.SetDv(Dv); primarytrack.SetZv(Zv);
1637 primarytrack.SetsigmaDv(sigmaDv); primarytrack.SetsigmaZv(sigmaZv);
1639 /////////////////////////////////////////////////////////////////////////////////////////////////
1641 primarytrack.PrimaryTrack(rl);
1642 TVector d2=primarytrack.Getd2();
1643 TVector tgl2=primarytrack.Gettgl2();
1644 TVector dtgl=primarytrack.Getdtgl();
1645 trackITS.Setd2(d2); trackITS.Settgl2(tgl2); trackITS.Setdtgl(dtgl);
1646 result.Setd2(d2); result.Settgl2(tgl2); result.Setdtgl(dtgl);
1648 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
1649 result.SetVertex(vertex); result.SetErrorVertex(ervertex);
1652 Tracking(trackITS,&result,recPoints,vettid, flagvert,rl);
1654 // cout<<" progressive track number = "<<j<<"\r";
1656 Int_t NumofCluster=result.GetNumClust();
1657 // cout<<" progressive track number = "<<j<<"\n"; // stampa
1658 Long_t labITS=result.GetLabel();
1659 // cout << " ITS track label = " << labITS << "\n"; // stampa
1660 int lab=track->GetLabel();
1661 // cout << " TPC track label = " << lab <<"\n"; // stampa
1664 //propagation to vertex
1668 result.Propagation(rbeam);
1670 Double_t C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44;
1671 result.GetCElements(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
1673 Double_t pt=TMath::Abs(result.GetPt());
1674 Double_t Dr=result.GetD();
1675 Double_t Z=result.GetZ();
1676 Double_t tgl=result.GetTgl();
1677 Double_t C=result.GetC();
1679 Double_t Dz=Z-(tgl/Cy)*TMath::ASin(result.arga(rbeam));
1682 // cout<<" Dr e dz alla fine = "<<Dr<<" "<<Dz<<"\n"; getchar();
1683 Double_t phi=result.Getphi();
1684 Double_t phivertex = phi - TMath::ASin(result.argA(rbeam));
1685 Double_t duepi=2.*TMath::Pi();
1686 if(phivertex>duepi) phivertex-=duepi;
1687 if(phivertex<0.) phivertex+=duepi;
1688 Double_t Dtot=TMath::Sqrt(Dr*Dr+Dz*Dz);
1690 //////////////////////////////////////////////////////////////////////////////////////////
1692 Int_t idmodule,idpoint;
1693 if(NumofCluster >=5) { // cinque - sei
1694 //if(NumofCluster ==6) { // cinque - sei
1697 AliITSiotrack outtrack;
1701 iotrack->SetStatePhi(phi);
1702 iotrack->SetStateZ(Z);
1703 iotrack->SetStateD(Dr);
1704 iotrack->SetStateTgl(tgl);
1705 iotrack->SetStateC(C);
1706 Double_t radius=result.Getrtrack();
1707 iotrack->SetRadius(radius);
1709 if(C>0.) charge=-1; else charge=1;
1710 iotrack->SetCharge(charge);
1714 iotrack->SetCovMatrix(C00,C10,C11,C20,C21,C22,C30,C31,C32,C33,C40,C41,C42,C43,C44);
1716 Double_t px=pt*TMath::Cos(phivertex);
1717 Double_t py=pt*TMath::Sin(phivertex);
1720 Double_t xtrack=Dr*TMath::Sin(phivertex);
1721 Double_t ytrack=Dr*TMath::Cos(phivertex);
1722 Double_t ztrack=Dz+Vgeant(2);
1728 iotrack->SetX(xtrack);
1729 iotrack->SetY(ytrack);
1730 iotrack->SetZ(ztrack);
1731 iotrack->SetLabel(labITS);
1734 for(il=0;il<6; il++){
1735 iotrack->SetIdPoint(il,result.GetIdPoint(il));
1736 iotrack->SetIdModule(il,result.GetIdModule(il));
1740 //cout<<" labITS = "<<labITS<<"\n";
1741 //cout<<" phi z Dr tgl C = "<<phi<<" "<<Z<<" "<<Dr<<" "<<tgl<<" "<<C<<"\n"; getchar();
1743 DataOut(kkk) = ptg; kkk++; DataOut(kkk)=labITS; kkk++; DataOut(kkk)=lab; kkk++;
1745 for (il=0;il<6;il++) {
1746 idpoint=result.GetIdPoint(il);
1747 idmodule=result.GetIdModule(il);
1748 *(vettid[idmodule]+idpoint)=1;
1749 iotrack->SetIdPoint(il,idpoint);
1750 iotrack->SetIdModule(il,idmodule);
1753 // cout<<" +++++++++++++ pt e ptg = "<<pt<<" "<<ptg<<" ++++++++++\n";
1754 Double_t difpt= (pt-ptg)/ptg*100.;
1755 DataOut(kkk)=difpt; kkk++;
1756 Double_t lambdag=TMath::ATan(pzg/ptg);
1757 Double_t lam=TMath::ATan(tgl);
1758 Double_t diflam = (lam - lambdag)*1000.;
1759 DataOut(kkk) = diflam; kkk++;
1760 Double_t phig=TMath::ATan2(pyg,pxg); if(phig<0) phig=2.*TMath::Pi()+phig;
1761 Double_t phi=phivertex;
1763 Double_t difphi = (phi - phig)*1000.;
1764 DataOut(kkk)=difphi; kkk++;
1765 DataOut(kkk)=Dtot*1.e4; kkk++;
1766 DataOut(kkk)=Dr*1.e4; kkk++;
1767 DataOut(kkk)=Dz*1.e4; kkk++;
1769 for (r=0; r<9; r++) { out<<DataOut(r)<<" ";}
1774 } // end if on NumofCluster
1775 //gObjectTable->Print(); // stampa memoria
1776 } // end for (int j=min_t; j<=max_t; j++)
1781 static Bool_t first=kTRUE;
1782 static TFile *tfile;
1785 tfile=new TFile("itstracks.root","RECREATE");
1786 //cout<<"I have opened itstracks.root file "<<endl;
1793 sprintf(hname,"TreeT%d",evNumber);
1795 tracktree1.Write(hname);
1799 TTree *fAli=gAlice->TreeK();
1802 if (fAli) fileAli =fAli->GetCurrentFile();
1805 ////////////////////////////////////////////////////////////////////////////////////////////////
1807 printf("delete vectors\n");
1808 if(np) delete [] np;
1809 if(vettid) delete [] vettid;