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.26 2000/11/27 13:12:13 barbera
19 New version containing the files for tracking
21 Revision 1.25 2000/11/12 22:38:05 barbera
22 Added header file for the SPD Bari model
24 Revision 1.24 2000/10/09 22:18:12 barbera
25 Bug fixes from MAriana to le AliITStest.C run correctly
27 Revision 1.23 2000/10/05 20:47:42 nilsen
28 fixed dependencies of include files. Tryed but failed to get a root automaticly
29 generates streamer function to work. Modified SetDefaults.
31 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
32 Needed to include stdlib.h
35 Revision 1.22 2000/10/04 19:45:52 barbera
36 Corrected by F. Carminati for v3.04
38 Revision 1.21 2000/10/02 21:28:08 fca
39 Removal of useless dependecies via forward declarations
41 Revision 1.20 2000/10/02 16:31:39 barbera
44 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
45 General code clean-up (e.g., printf -> cout)
47 Revision 1.19 2000/09/22 12:13:25 nilsen
48 Patches and updates for fixes to this and other routines.
50 Revision 1.18 2000/07/12 05:32:20 fca
51 Correcting several syntax problem with static members
53 Revision 1.17 2000/07/10 16:07:18 fca
54 Release version of ITS code
56 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
57 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
59 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
60 //fixed FillModule. Removed fi(fabs(xl)<dx....
62 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
63 This is the version of the files after the merging done in December 1999.
64 See the ReadMe110100.txt file for details
66 Revision 1.9 1999/11/14 14:33:25 fca
67 Correct problems with distructors and pointers, thanks to I.Hrivnacova
69 Revision 1.8 1999/09/29 09:24:19 fca
70 Introduction of the Copyright and cvs Log
74 ///////////////////////////////////////////////////////////////////////////////
76 // An overview of the basic philosophy of the ITS code development
77 // and analysis is show in the figure below.
80 <img src="picts/ITS/ITS_Analysis_schema.gif">
83 <font size=+2 color=red>
84 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
85 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
91 // AliITS. Inner Traking System base class.
92 // This class contains the base procedures for the Inner Tracking System
96 <img src="picts/ITS/AliITS_Class_Diagram.gif">
99 <font size=+2 color=red>
100 <p>This show the class diagram of the different elements that are part of
108 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
111 // Modified and documented by Bjorn S. Nilsen
115 // Modified and documented by A. Bologna
118 // AliITS is the general base class for the ITS. Also see AliDetector for
119 // futher information.
121 ///////////////////////////////////////////////////////////////////////////////
127 #include <TObjArray.h>
129 #include <TObjectTable.h>
138 #include "AliITSMap.h"
139 #include "AliITSDetType.h"
140 #include "AliITSClusterFinder.h"
141 #include "AliITSsimulation.h"
142 #include "AliITSresponse.h"
143 #include "AliITSsegmentationSPD.h"
144 #include "AliITSresponseSPD.h"
145 #include "AliITSresponseSPDbari.h"
146 #include "AliITSsegmentationSDD.h"
147 #include "AliITSresponseSDD.h"
148 #include "AliITSsegmentationSSD.h"
149 #include "AliITSresponseSSD.h"
150 #include "AliITShit.h"
151 #include "AliITSgeom.h"
152 #include "AliITSdigit.h"
153 #include "AliITSmodule.h"
154 #include "AliITSRecPoint.h"
155 #include "AliITSRawCluster.h"
159 #include "AliITStrack.h"
160 #include "AliITSiotrack.h"
161 #include "AliITStracking.h"
162 #include "../TPC/AliTPC.h"
163 #include "../TPC/AliTPCParam.h"
165 const Int_t AliITS::fgkNTYPES=3;
169 //_____________________________________________________________________________
170 AliITS::AliITS() : AliDetector() {
172 // Default initialiser for ITS
173 // The default constructor of the AliITS class. In addition to
174 // creating the AliITS class it zeros the variables fIshunt (a member
175 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
176 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
184 //fNDetTypes = fgkNTYPES;
203 //_____________________________________________________________________________
204 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
206 // Default initialiser for ITS
207 // The constructor of the AliITS class. In addition to creating the
208 // AliITS class, it allocates memory for the TClonesArrays fHits and
209 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
210 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
211 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
212 // macro display.C AliITS also sets the marker color to red. The variables
213 // passes with this constructor, const char *name and *title, are used by
214 // the constructor of AliDetector class. See AliDetector class for a
215 // description of these parameters and its constructor functions.
219 fHits = new TClonesArray("AliITShit", 1560);
220 gAlice->AddHitList(fHits);
222 //fNDetTypes = fgkNTYPES;
224 fNdtype = new Int_t[fgkNTYPES];
225 fDtype = new TObjArray(fgkNTYPES);
227 fNctype = new Int_t[fgkNTYPES];
228 fCtype = new TObjArray(fgkNTYPES);
244 fDetTypes = new TObjArray(fgkNTYPES);
247 for(i=0;i<fgkNTYPES;i++) {
248 (*fDetTypes)[i]=new AliITSDetType();
254 SetMarkerColor(kRed);
258 //___________________________________________________________________________
259 AliITS::AliITS(AliITS &source){
261 if(this==&source) return;
262 Error("AliITS::Copy constructor",
263 "You are not allowed to make a copy of the AliITS");
266 //____________________________________________________________________________
267 AliITS& AliITS::operator=(AliITS &source){
268 // assignment operator
269 if(this==&source) return *this;
270 Error("AliITS::operator=",
271 "You are not allowed to make a copy of the AliITS");
273 return *this; //fake return
275 //____________________________________________________________________________
276 void AliITS::ClearModules(){
277 //clear the modules TObjArray
279 if(fITSmodules) fITSmodules->Delete();
282 //_____________________________________________________________________________
285 // Default distructor for ITS
286 // The default destructor of the AliITS class. In addition to deleting
287 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
288 // fIdSens, fIdName, and fITSpoints.
295 // delete fIdName; // TObjArray of TObjStrings
296 if(fIdName!=0) delete[] fIdName; // Array of TStrings
297 if(fIdSens!=0) delete[] fIdSens;
299 this->ClearModules();
301 }// end if fITSmodules!=0
321 if (fTreeC) delete fTreeC;
323 if (fITSgeom) delete fITSgeom;
327 //___________________________________________
328 AliITSDetType* AliITS::DetType(Int_t id)
330 //return pointer to id detector type
331 return ((AliITSDetType*) (*fDetTypes)[id]);
334 //___________________________________________
335 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
337 //set the digit and cluster classes to be used for the id detector type
338 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
341 //___________________________________________
342 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
344 //set the response model for the id detector type
346 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
350 //___________________________________________
351 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
353 //set the segmentation model for the id detector type
355 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
359 //___________________________________________
360 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
362 //set the simulation model for the id detector type
364 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
367 //___________________________________________
368 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
370 //set the cluster finder model for the id detector type
372 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
376 //_____________________________________________________________________________
377 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
380 // The function to add information to the AliITShit class. See the
381 // AliITShit class for a full description. This function allocates the
382 // necessary new space for the hit information and passes the variable
383 // track, and the pointers *vol and *hits to the AliITShit constructor
386 TClonesArray &lhits = *fHits;
387 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
389 //_____________________________________________________________________________
390 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
392 // add a real digit - as coming from data
394 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
395 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
398 //_____________________________________________________________________________
399 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
402 // add a simulated digit
404 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
409 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
412 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
415 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
421 //_____________________________________________________________________________
422 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
424 // add a simulated digit to the list
426 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
430 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
433 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
436 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
442 //_____________________________________________________________________________
443 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
446 // add a cluster to the list
448 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
453 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
456 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
459 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
466 //_____________________________________________________________________________
467 void AliITS::AddRecPoint(const AliITSRecPoint &r)
470 // Add a reconstructed space point to the list
472 TClonesArray &lrecp = *fRecPoints;
473 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
477 //____________________________________________
478 void AliITS::ResetDigits()
481 // Reset number of digits and the digits array for the ITS detector
487 for (i=0;i<fgkNTYPES;i++ ) {
488 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
489 if (fNdtype) fNdtype[i]=0;
493 //____________________________________________
494 void AliITS::ResetDigits(Int_t i)
497 // Reset number of digits and the digits array for this branch
499 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
500 if (fNdtype) fNdtype[i]=0;
504 //____________________________________________
505 void AliITS::ResetClusters()
508 // Reset number of clusters and the clusters array for ITS
512 for (i=0;i<fgkNTYPES;i++ ) {
513 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
514 if (fNctype) fNctype[i]=0;
519 //____________________________________________
520 void AliITS::ResetClusters(Int_t i)
523 // Reset number of clusters and the clusters array for this branch
525 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
526 if (fNctype) fNctype[i]=0;
531 //____________________________________________
532 void AliITS::ResetRecPoints()
535 // Reset number of rec points and the rec points array
537 if (fRecPoints) fRecPoints->Clear();
542 //_____________________________________________________________________________
543 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
545 // Distance from mouse to ITS on the screen. Dummy routine
546 // A dummy routine used by the ROOT macro display.C to allow for the
547 // use of the mouse (pointing device) in the macro. In general this should
548 // never be called. If it is it returns the number 9999 for any value of
554 //_____________________________________________________________________________
557 // Initialise ITS after it has been built
558 // This routine initializes the AliITS class. It is intended to be called
559 // from the Init function in AliITSv?. Besides displaying a banner
560 // indicating that it has been called it initializes the array fIdSens
561 // and sets the default segmentation, response, digit and raw cluster classes
562 // Therefore it should be called after a call to CreateGeometry.
567 for(i=0;i<30;i++) cout << "*";cout << " ITS_INIT ";
568 for(i=0;i<30;i++) cout << "*";cout << endl;
571 // TObjArray of TObjStrings
572 // for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId((fIdName->At(i))->GetName());
574 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
576 for(i=0;i<70;i++) cout << "*";
580 //_____________________________________________________________________________
581 void AliITS::SetDefaults()
583 // sets the default segmentation, response, digit and raw cluster classes
585 printf("SetDefaults\n");
587 AliITSDetType *iDetType;
593 if (!iDetType->GetSegmentationModel()) {
594 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
595 SetSegmentationModel(0,seg0);
597 if (!iDetType->GetResponseModel()) {
598 SetResponseModel(0,new AliITSresponseSPD());
600 // set digit and raw cluster classes to be used
602 const char *kData0=(iDetType->GetResponseModel())->DataType();
603 if (strstr(kData0,"real")) {
604 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
605 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
609 if (!iDetType->GetResponseModel()) {
610 SetResponseModel(1,new AliITSresponseSDD());
612 AliITSresponse *resp1=iDetType->GetResponseModel();
613 if (!iDetType->GetSegmentationModel()) {
614 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
615 SetSegmentationModel(1,seg1);
617 const char *kData1=(iDetType->GetResponseModel())->DataType();
618 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
619 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
620 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
621 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
625 if (!iDetType->GetSegmentationModel()) {
626 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
627 SetSegmentationModel(2,seg2);
629 if (!iDetType->GetResponseModel()) {
630 SetResponseModel(2,new AliITSresponseSSD());
632 const char *kData2=(iDetType->GetResponseModel())->DataType();
633 if (strstr(kData2,"real")) {
634 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
635 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
638 Warning("SetDefaults","Only the three basic detector types are initialised!");
645 //_____________________________________________________________________________
646 void AliITS::SetDefaultSimulation()
651 //_____________________________________________________________________________
652 void AliITS::SetDefaultClusterFinders()
657 //_____________________________________________________________________________
659 void AliITS::MakeTreeC(Option_t *option)
661 // create a separate tree to store the clusters
663 cout << "AliITS::MakeTreeC" << endl;
665 char *optC = strstr(option,"C");
666 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
669 Int_t buffersize = 4000;
672 char *det[3] = {"SPD","SDD","SSD"};
674 // one branch for Clusters per type of detector
676 for (i=0; i<fgkNTYPES ;i++) {
677 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
678 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
679 if (fCtype && fTreeC) {
680 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
681 cout << "Making Branch " << branchname;
682 cout << " for Clusters of detector type " << i+1 << endl;
688 //_____________________________________________________________________________
689 void AliITS::GetTreeC(Int_t event)
692 cout << "AliITS::GetTreeC" << endl;
694 // get the clusters tree for this event and set the branch address
698 char *det[3] = {"SPD","SDD","SSD"};
705 sprintf(treeName,"TreeC%d",event);
706 fTreeC = (TTree*)gDirectory->Get(treeName);
712 for (i=0; i<fgkNTYPES; i++) {
713 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
714 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
716 branch = fTreeC->GetBranch(branchname);
717 if (branch) branch->SetAddress(&((*fCtype)[i]));
721 Error("AliITS::GetTreeC",
722 "cannot find Clusters Tree for event:%d\n",event);
726 //_____________________________________________________________________________
727 void AliITS::MakeBranch(Option_t* option){
729 // Creates Tree branches for the ITS.
733 Int_t buffersize = 4000;
735 sprintf(branchname,"%s",GetName());
737 AliDetector::MakeBranch(option);
740 // one branch for digits per type of detector
742 char *det[3] = {"SPD","SDD","SSD"};
748 for (i=0; i<fgkNTYPES ;i++) {
749 AliITSDetType *iDetType=DetType(i);
750 iDetType->GetClassNames(digclass,clclass);
751 //printf("i, digclass, recclass %d %s %s\n",i,digclass,clclass);
753 (*fDtype)[i] = new TClonesArray(digclass,10000);
755 (*fCtype)[i] = new TClonesArray(clclass,10000);
759 for (i=0; i<fgkNTYPES ;i++) {
760 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
761 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
763 if (fDtype && gAlice->TreeD()) {
764 gAlice->TreeD()->Branch(branchname,&((*fDtype)[i]), buffersize);
765 cout << "Making Branch " << branchname;
766 cout << " for digits of type "<< i+1 << endl;
770 // only one branch for rec points for all detector types
771 sprintf(branchname,"%sRecPoints",GetName());
773 fRecPoints=new TClonesArray("AliITSRecPoint",10000);
775 if (fRecPoints && gAlice->TreeR()) {
776 gAlice->TreeR()->Branch(branchname,&fRecPoints, buffersize);
777 cout << "Making Branch " << branchname;
778 cout << " for reconstructed space points" << endl;
784 //___________________________________________
785 void AliITS::SetTreeAddress()
788 // Set branch address for the Trees.
791 AliDetector::SetTreeAddress();
793 char *det[3] = {"SPD","SDD","SSD"};
796 TTree *treeD = gAlice->TreeD();
797 TTree *treeR = gAlice->TreeR();
801 for (i=0; i<fgkNTYPES; i++) {
802 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
803 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
805 branch = treeD->GetBranch(branchname);
806 if (branch) branch->SetAddress(&((*fDtype)[i]));
813 sprintf(branchname,"%sRecPoints",GetName());
815 branch = treeR->GetBranch(branchname);
816 if (branch) branch->SetAddress(&fRecPoints);
823 //____________________________________________________________________________
824 void AliITS::InitModules(Int_t size,Int_t &nmodules){
826 //initialize the modules array
829 fITSmodules->Delete();
833 Int_t nl,indexMAX,index;
835 if(size<=0){ // default to using data stored in AliITSgeom
837 Error("AliITS::InitModules",
838 "in AliITS::InitModule fITSgeom not defined\n");
840 } // end if fITSgeom==0
841 nl = fITSgeom->GetNlayers();
842 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
843 fITSgeom->GetNdetectors(nl))+1;
845 fITSmodules = new TObjArray(indexMAX);
846 for(index=0;index<indexMAX;index++){
847 fITSmodules->AddAt( new AliITSmodule(index),index);
850 fITSmodules = new TObjArray(size);
851 for(index=0;index<size;index++) {
852 fITSmodules->AddAt( new AliITSmodule(index),index);
859 //____________________________________________________________________________
860 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
862 // fill the modules with the sorted by module hits; add hits from background
866 static TTree *trH1; //Tree with background hits
867 static TClonesArray *fHits2; //List of hits for one track only
869 static Bool_t first=kTRUE;
871 char *addBgr = strstr(option,"Add");
876 cout<<"filename "<<filename<<endl;
877 file=new TFile(filename);
878 cout<<"I have opened "<<filename<<" file "<<endl;
879 fHits2 = new TClonesArray("AliITShit",1000 );
884 // Get Hits Tree header from file
885 if(fHits2) fHits2->Clear();
886 if(trH1) delete trH1;
890 sprintf(treeName,"TreeH%d",bgrev);
891 trH1 = (TTree*)gDirectory->Get(treeName);
892 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
895 Error("AliITS::FillModules",
896 "cannot find Hits Tree for event:%d\n",bgrev);
898 // Set branch addresses
901 sprintf(branchname,"%s",GetName());
902 if (trH1 && fHits2) {
903 branch = trH1->GetBranch(branchname);
904 if (branch) branch->SetAddress(&fHits2);
908 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
909 //printf("background - ntracks1 - %d\n",ntracks1);
912 Int_t npart = gAlice->GetEvent(evnt);
914 TClonesArray *itsHits = this->Hits();
915 Int_t lay,lad,det,index;
919 TTree *iTH = gAlice->TreeH();
920 Int_t ntracks =(Int_t) iTH->GetEntries();
923 for(t=0; t<ntracks; t++){
926 Int_t nhits = itsHits->GetEntriesFast();
927 //printf("nhits %d\n",nhits);
928 if (!nhits) continue;
929 for(h=0; h<nhits; h++){
930 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
931 itsHit->GetDetectorID(lay,lad,det);
932 // temporarily index=det-1 !!!
933 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
936 mod = this->GetModule(index);
937 mod->AddHit(itsHit,t,h);
938 } // end loop over hits
939 } // end loop over tracks
941 // open the file with background
945 ntracks =(Int_t)trH1->GetEntries();
946 //printf("background - ntracks1 %d\n",ntracks);
947 //printf("background - Start loop over tracks \n");
950 for (track=0; track<ntracks; track++) {
952 if (fHits2) fHits2->Clear();
953 trH1->GetEvent(track);
955 for(i=0;i<fHits2->GetEntriesFast();++i) {
957 itsHit=(AliITShit*) (*fHits2)[i];
958 itsHit->GetDetectorID(lay,lad,det);
959 // temporarily index=det-1 !!!
960 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
963 mod = this->GetModule(index);
964 mod->AddHit(itsHit,track,i);
965 } // end loop over hits
966 } // end loop over tracks
968 TTree *fAli=gAlice->TreeK();
971 if (fAli) fileAli =fAli->GetCurrentFile();
976 //gObjectTable->Print();
981 //____________________________________________________________________________
982 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
984 // keep galice.root for signal and name differently the file for
985 // background when add! otherwise the track info for signal will be lost !
987 // the condition below will disappear when the geom class will be
988 // initialised for all versions - for the moment it is only for v5 !
989 // 7 is the SDD beam test version
990 Int_t ver = this->IsVersion();
991 if(ver!=5 && ver!=7) return;
993 char *all = strstr(opt,"All");
994 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
997 InitModules(size,nmodules);
998 FillModules(evNumber,bgrev,nmodules,option,filename);
1001 AliITSsimulation* sim;
1002 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
1003 AliITSgeom *geom = GetITSgeom();
1007 for (id=0;id<fgkNTYPES;id++) {
1008 if (!all && !det[id]) continue;
1009 //branch = (TBranch*)branches->UncheckedAt(id);
1010 AliITSDetType *iDetType=DetType(id);
1011 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1013 Error("HitsToDigits","The simulation class was not instantiated!");
1015 // or SetDefaultSimulation();
1018 first = geom->GetStartDet(id);
1019 last = geom->GetLastDet(id);
1020 } else first=last=0;
1021 cout << "det type " << id << " first, last "<< first << last << endl;
1022 for(module=first;module<=last;module++) {
1023 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1024 sim->DigitiseModule(mod,module,evNumber);
1025 // fills all branches - wasted disk space
1026 gAlice->TreeD()->Fill();
1028 // try and fill only the branch
1031 } // loop over modules
1032 } // loop over detector types
1036 Int_t nentries=(Int_t)gAlice->TreeD()->GetEntries();
1037 cout << "nentries in TreeD" << nentries << endl;
1040 sprintf(hname,"TreeD%d",evNumber);
1041 gAlice->TreeD()->Write(hname);
1043 gAlice->TreeD()->Reset();
1048 //____________________________________________________________________________
1049 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1051 // cluster finding and reconstruction of space points
1053 // the condition below will disappear when the geom class will be
1054 // initialised for all versions - for the moment it is only for v5 !
1055 // 7 is the SDD beam test version
1056 Int_t ver = this->IsVersion();
1057 if(ver!=5 && ver!=7) return;
1059 char *all = strstr(opt,"All");
1060 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1062 static Bool_t first=kTRUE;
1071 AliITSClusterFinder* rec;
1073 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1074 AliITSgeom *geom = GetITSgeom();
1077 for (id=0;id<fgkNTYPES;id++) {
1078 if (!all && !det[id]) continue;
1079 //branch = (TBranch*)branches->UncheckedAt(id);
1080 AliITSDetType *iDetType=DetType(id);
1081 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1083 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1085 // or SetDefaultClusterFinders();
1087 TClonesArray *itsDigits = this->DigitsAddress(id);
1091 first = geom->GetStartDet(id);
1092 last = geom->GetLastDet(id);
1093 } else first=last=0;
1094 //printf("first last %d %d\n",first,last);
1095 for(module=first;module<=last;module++) {
1096 this->ResetDigits();
1097 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1098 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1099 Int_t ndigits = itsDigits->GetEntriesFast();
1100 if (ndigits) rec->FindRawClusters();
1101 gAlice->TreeR()->Fill();
1105 // try and fill only the branch
1107 //ResetRecPoints(id);
1108 } // loop over modules
1109 } // loop over detector types
1112 Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1113 Int_t ncentries=(Int_t)iTC->GetEntries();
1114 cout << " nentries ncentries " << nentries << ncentries << endl;
1117 sprintf(hname,"TreeR%d",evNumber);
1118 gAlice->TreeR()->Write(hname);
1120 gAlice->TreeR()->Reset();
1122 sprintf(hname,"TreeC%d",evNumber);
1128 //____________________________________________________________________________
1129 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1130 Option_t *option,Option_t *opt,Text_t *filename)
1132 // keep galice.root for signal and name differently the file for
1133 // background when add! otherwise the track info for signal will be lost !
1136 // the condition below will disappear when the geom class will be
1137 // initialised for all versions - for the moment it is only for v5 !
1138 Int_t ver = this->IsVersion();
1141 char *all = strstr(opt,"All");
1142 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1145 InitModules(size,nmodules);
1146 FillModules(evNumber,bgrev,nmodules,option,filename);
1149 AliITSsimulation* sim;
1150 AliITSgeom *geom = GetITSgeom();
1152 TRandom *random=new TRandom[9];
1153 random[0].SetSeed(111);
1154 random[1].SetSeed(222);
1155 random[2].SetSeed(333);
1156 random[3].SetSeed(444);
1157 random[4].SetSeed(555);
1158 random[5].SetSeed(666);
1159 random[6].SetSeed(777);
1160 random[7].SetSeed(888);
1161 random[8].SetSeed(999);
1165 for (id=0;id<fgkNTYPES;id++) {
1166 if (!all && !det[id]) continue;
1167 AliITSDetType *iDetType=DetType(id);
1168 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1170 Error("HitsToFastPoints","The simulation class was not instantiated!");
1172 // or SetDefaultSimulation();
1174 Int_t first = geom->GetStartDet(id);
1175 Int_t last = geom->GetLastDet(id);
1176 for(module=first;module<=last;module++) {
1177 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1178 sim->CreateFastRecPoints(mod,module,random);
1179 gAlice->TreeR()->Fill();
1181 } // loop over modules
1182 } // loop over detector types
1187 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1190 sprintf(hname,"TreeR%d",evNumber);
1191 gAlice->TreeR()->Write(hname);
1193 gAlice->TreeR()->Reset();
1200 //____________________________________________________________________________
1201 void AliITS::Streamer(TBuffer &R__b){
1202 // Stream an object of class AliITS.
1206 if (R__b.IsReading()) {
1207 Version_t R__v = R__b.ReadVersion();
1209 AliDetector::Streamer(R__b);
1211 R__b.ReadArray(fIdSens);
1212 if(fIdName!=0) delete[] fIdName; // Array of TStrings
1213 fIdName = new TString[fIdN];
1214 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
1216 R__b >> fITSmodules;
1218 R__b >> fMajorVersion;
1219 R__b >> fMinorVersion;
1223 fNdtype = new Int_t[fgkNTYPES];
1224 R__b.ReadFastArray(fNdtype,fgkNTYPES);
1227 fNctype = new Int_t[fgkNTYPES];
1228 R__b.ReadFastArray(fNctype,fgkNTYPES);
1230 R__b >> fNRecPoints;
1234 R__b.WriteVersion(AliITS::IsA());
1235 AliDetector::Streamer(R__b);
1237 R__b.WriteArray(fIdSens,fIdN);
1238 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
1240 R__b << fITSmodules;
1242 R__b << fMajorVersion;
1243 R__b << fMinorVersion;
1246 R__b.WriteFastArray(fNdtype,fgkNTYPES);
1248 R__b.WriteFastArray(fNctype,fgkNTYPES);
1250 R__b << fNRecPoints;
1256 //________________________________________________________________
1258 AliITStrack AliITS::Tracking(AliITStrack &track, AliITStrack *reference,TObjArray *fastpoints, Int_t
1259 **vettid, Bool_t flagvert ) {
1261 //Origin A. Badala' and G.S. Pappalardo: e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1264 TList *list= new TList();
1266 AliITStrack tr(track);
1270 Double_t Pt=(tr).GetPt();
1271 //cout << "\n Pt = " << Pt <<"\n";
1274 AliITStracking obj(list, reference, this, fastpoints,TMath::Abs(Pt),vettid, flagvert);
1279 TVector VecTotLabref(18);
1280 for(Int_t lay=5; lay>=0; lay--) {
1281 TVector VecLabref(3);
1282 VecLabref=(*reference).GetLabTrack(lay);
1283 for(Int_t k=0; k<3; k++) {itot++; VecTotLabref(itot)=VecLabref(k);}
1287 (*reference).Search(VecTotLabref, labref, freq);
1289 if(freq < 5) labref=-labref;
1290 (*reference).SetLabel(labref);
1298 //________________________________________________________________
1302 void AliITS::DoTracking(Int_t evNumber, Int_t min_t, Int_t max_t, TFile *file, Bool_t flagvert) {
1304 // ex macro for tracking ITS
1306 printf("begin DoTracking - file %p\n",file);
1308 const char *pname="75x40_100x60";
1312 Float_t px,py,pz,x,y,z,pxg,pyg,pzg,ptg;
1317 gAlice->GetEvent(0);
1319 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
1320 AliTPCParam *digp = (AliTPCParam*)file->Get(pname);
1321 if (digp!=0) TPC->SetParam(digp);
1325 ifstream in("good_tracks");
1327 cerr<<"Reading good tracks...\n";
1328 while (in>>gt[ngood].lab>>gt[ngood].code
1329 >>gt[ngood].px >>gt[ngood].py>>gt[ngood].pz
1330 >>gt[ngood].x >>gt[ngood].y >>gt[ngood].z
1331 >>gt[ngood].pxg >>gt[ngood].pyg >>gt[ngood].pzg
1332 >>gt[ngood].ptg >>gt[ngood].flag) {
1336 cerr<<"Too many good tracks !\n";
1340 if (!in.eof()) cerr<<"Read error (good_tracks) !\n";
1344 TFile *tf=TFile::Open("tpctracks.root");
1345 if (!tf->IsOpen()) {cerr<<"Can't open tpctracks.root !\n"; return ;}
1346 TObjArray tracks(200000);
1347 TTree *tracktree=(TTree*)tf->Get("TreeT");
1348 TBranch *tbranch=tracktree->GetBranch("tracks");
1349 Int_t nentr=(Int_t)tracktree->GetEntries();
1350 for (Int_t k=0; k<nentr; k++) {
1351 AliTPCtrack *iotrack=new AliTPCtrack;
1352 tbranch->SetAddress(&iotrack);
1353 tracktree->GetEvent(k);
1354 tracks.AddLast(iotrack);
1359 Int_t nt = tracks.GetEntriesFast();
1360 cerr<<"Number of found tracks "<<nt<<endl;
1365 Double_t ptg=0.,pxg=0.,pyg=0.,pzg=0.;
1367 ////////////////////////////// good tracks definition in TPC ////////////////////////////////
1369 ofstream out1 ("AliITSTrag.out");
1370 for (Int_t i=0; i<ngood; i++) out1 << gt[i].ptg << "\n";
1375 TTree *TR=gAlice->TreeR();
1376 Int_t nent=(Int_t)TR->GetEntries();
1377 TClonesArray *recPoints = RecPoints();
1379 Int_t totalpoints=0;
1380 Int_t *np = new Int_t[nent];
1381 Int_t **vettid = new Int_t* [nent];
1382 for (Int_t mod=0; mod<nent; mod++) {
1384 this->ResetRecPoints();
1385 gAlice->TreeR()->GetEvent(mod+1); //first entry in TreeR is empty
1386 numbpoints = recPoints->GetEntries();
1387 totalpoints+=numbpoints;
1388 np[mod] = numbpoints;
1389 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n"; getchar();
1390 vettid[mod] = new Int_t[numbpoints];
1391 for (Int_t i=0;i<numbpoints; i++) *(vettid[mod]+i)=0;
1397 if(min_t < 0) {min_t = 0; max_t = nt-1;}
1400 ///////////////////////////////// Definition of vertex end its error ////////////////////////////
1401 ////////////////////////// In the future it will be given by a method ///////////////////////////
1406 Float_t sigmavx=0.0050; // 50 microns
1407 Float_t sigmavy=0.0050; // 50 microns
1408 Float_t sigmavz=0.010; // 100 microns
1410 //Vx+=gRandom->Gaus(0,sigmavx); Vy+=gRandom->Gaus(0,sigmavy); Vz+=gRandom->Gaus(0,sigmavz);
1411 TVector vertex(3), ervertex(3)
1412 vertex(0)=Vx; vertex(1)=Vy; vertex(2)=Vz;
1413 ervertex(0)=sigmavx; ervertex(1)=sigmavy; ervertex(2)=sigmavz;
1414 /////////////////////////////////////////////////////////////////////////////////////////////////
1417 //TDirectory *savedir=gDirectory;
1419 TTree tracktree1("TreeT","Tree with ITS tracks");
1420 AliITSiotrack *iotrack=0;
1421 tracktree1.Branch("ITStracks","AliITSiotrack",&iotrack,32000,0);
1423 ofstream out ("AliITSTra.out");
1425 for (int j=min_t; j<=max_t; j++) {
1426 track=(AliTPCtrack*)tracks.UncheckedAt(j);
1428 if (!track) continue;
1429 ////// elimination of not good tracks ////////////
1430 Int_t ilab=TMath::Abs(track->GetLabel());
1432 for (Int_t i=0;i<ngood;i++) {
1433 //cout<<" ilab, gt[i].lab = "<<ilab<<" "<<gt[i].lab<<"\n"; getchar();
1434 if (ilab==gt[i].lab) {
1443 //cout<<" j flaglab = " <<j<<" "<<flaglab<<"\n"; getchar();
1444 if (!flaglab) continue;
1445 //cout<<" j = " <<j<<"\n"; getchar();
1447 ////// old propagation to the end of TPC //////////////
1449 track->PropagateTo(xk);
1451 track->PropagateTo(xk,42.7,2.27); //C
1453 track->PropagateTo(xk,36.2,1.98e-3); //C02
1455 track->PropagateTo(xk,42.7,2.27); //C
1456 ///////////////////////////////////////////////////
1459 ////// new propagation to the end of TPC //////////////
1461 track->PropagateTo(xk, 28.94, 1.204e-3); //Ne
1463 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1465 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1467 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1469 track->PropagateTo(xk,36.2,1.98e-3); //C02
1471 track->PropagateTo(xk, 24.01, 2.7); //Al
1473 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
1475 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
1477 track->PropagateTo(xk, 41.28, 0.029); //Nomex
1479 ///////////////////////////////////////////////////////////////
1481 ///////////////////////////////////////////////////////////////
1482 AliITStrack trackITS(*track);
1483 AliITStrack result(*track);
1484 AliITStrack primarytrack(*track);
1486 ///////////////////////////////////////////////////////////////////////////////////////////////
1488 Vgeant=result.GetVertex();
1490 // Definition of Dv and Zv for vertex constraint
1491 // Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
1492 Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
1493 Double_t uniform= gRandom->Uniform();
1495 if(uniform<=0.5) signdv=-1.;
1499 Double_t Vr=TMath::Sqrt(Vgeant(0)*Vgeant(0)+ Vgeant(1)*Vgeant(1));
1500 Double_t Dv=gRandom->Gaus(signdv*Vr,(Float_t)sigmaDv);
1501 Double_t Zv=gRandom->Gaus(Vgeant(2),(Float_t)sigmaZv);
1503 //cout<<" Dv e Zv = "<<Dv<<" "<<Zv<<"\n";
1504 trackITS.SetDv(Dv); trackITS.SetZv(Zv);
1505 trackITS.SetsigmaDv(sigmaDv); trackITS.SetsigmaZv(sigmaZv);
1506 result.SetDv(Dv); result.SetZv(Zv);
1507 result.SetsigmaDv(sigmaDv); result.SetsigmaZv(sigmaZv);
1508 primarytrack.SetDv(Dv); primarytrack.SetZv(Zv);
1509 primarytrack.SetsigmaDv(sigmaDv); primarytrack.SetsigmaZv(sigmaZv);
1511 /////////////////////////////////////////////////////////////////////////////////////////////////
1513 primarytrack.PrimaryTrack();
1514 TVector d2=primarytrack.Getd2();
1515 TVector tgl2=primarytrack.Gettgl2();
1516 TVector dtgl=primarytrack.Getdtgl();
1517 trackITS.Setd2(d2); trackITS.Settgl2(tgl2); trackITS.Setdtgl(dtgl);
1518 result.Setd2(d2); result.Settgl2(tgl2); result.Setdtgl(dtgl);
1520 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
1521 result.SetVertex(vertex); result.SetErrorVertex(ervertex);
1523 Tracking(trackITS,&result,recPoints,vettid, flagvert);
1525 cout<<" progressive track number = "<<j<<"\r";
1526 // cout<<" progressive track number = "<<j<<"\n";
1527 Long_t labITS=result.GetLabel();
1528 // cout << " ITS track label = " << labITS << "\n";
1529 int lab=track->GetLabel();
1530 //cout << " TPC track label = " << lab <<"\n";
1531 //result.GetClusters(); getchar(); //to print the cluster matrix
1533 //propagation to vertex
1536 result.Propagation(rbeam);
1538 cov=&result.GetCMatrix();
1539 Double_t pt=TMath::Abs(result.GetPt());
1540 Double_t Dr=result.GetD();
1541 Double_t Z=result.GetZ();
1542 Double_t tgl=result.GetTgl();
1543 Double_t C=result.GetC();
1545 Double_t Dz=Z-(tgl/Cy)*TMath::ASin(result.arga(rbeam));
1547 // cout<<" Dr e dz alla fine = "<<Dr<<" "<<Dz<<"\n"; getchar();
1548 Double_t phi=result.Getphi();
1549 Double_t phivertex = phi - TMath::ASin(result.argA(rbeam));
1550 Double_t duepi=2.*TMath::Pi();
1551 if(phivertex>duepi) phivertex-=duepi;
1552 if(phivertex<0.) phivertex+=duepi;
1553 Double_t Dtot=TMath::Sqrt(Dr*Dr+Dz*Dz);
1554 //////////////////////////////////////////////////////////////////////////////////////////
1555 Int_t NumofCluster, idmodule,idpoint;
1556 NumofCluster=result.GetNumClust();
1557 if(NumofCluster >=5) {
1560 AliITSiotrack outtrack;
1564 iotrack->SetStatePhi(phi);
1565 iotrack->SetStateZ(Z);
1566 iotrack->SetStateD(Dr);
1567 iotrack->SetStateTgl(tgl);
1568 iotrack->SetStateC(C);
1569 Double_t radius=result.Getrtrack();
1570 iotrack->SetRadius(radius);
1572 if(C>0.) charge=-1; else charge=1;
1573 iotrack->SetCharge(charge);
1577 iotrack->SetCovMatrix(cov);
1579 Double_t px=pt*TMath::Cos(phi);
1580 Double_t py=pt*TMath::Sin(phi);
1583 Double_t xtrack=Dr*TMath::Sin(phi);
1584 Double_t ytrack=Dr*TMath::Cos(phi);
1585 Double_t ztrack=Dz+Vgeant(2);
1591 iotrack->SetX(xtrack);
1592 iotrack->SetY(ytrack);
1593 iotrack->SetZ(ztrack);
1594 iotrack->SetLabel(labITS);
1597 for(il=0;il<6; il++){
1598 iotrack->SetIdPoint(il,result.GetIdPoint(il));
1599 iotrack->SetIdModule(il,result.GetIdModule(il));
1603 //cout<<" labITS = "<<labITS<<"\n";
1604 //cout<<" phi z Dr tgl C = "<<phi<<" "<<Z<<" "<<Dr<<" "<<tgl<<" "<<C<<"\n"; getchar();
1606 DataOut(kkk) = ptg; kkk++; DataOut(kkk)=labITS; kkk++; DataOut(kkk)=lab; kkk++;
1608 for (il=0;il<6;il++) {
1609 idpoint=result.GetIdPoint(il);
1610 idmodule=result.GetIdModule(il);
1611 *(vettid[idmodule]+idpoint)=1;
1612 iotrack->SetIdPoint(il,idpoint);
1613 iotrack->SetIdModule(il,idmodule);
1616 Double_t difpt= (pt-ptg)/ptg*100.;
1617 DataOut(kkk)=difpt; kkk++;
1618 Double_t lambdag=TMath::ATan(pzg/ptg);
1619 Double_t lam=TMath::ATan(tgl);
1620 Double_t diflam = (lam - lambdag)*1000.;
1621 DataOut(kkk) = diflam; kkk++;
1622 Double_t phig=TMath::ATan(pyg/pxg);
1623 Double_t phi=phivertex;
1624 Double_t difphi = (phi - phig)*1000.;
1625 DataOut(kkk)=difphi; kkk++;
1626 DataOut(kkk)=Dtot*1.e4; kkk++;
1627 DataOut(kkk)=Dr*1.e4; kkk++;
1628 DataOut(kkk)=Dz*1.e4; kkk++;
1629 for (int r=0; r<9; r++) { out<<DataOut(r)<<" ";}
1634 } // end if on NumofCluster
1635 //gObjectTable->Print(); // stampa memoria
1636 } // end for (int j=min_t; j<=max_t; j++)
1641 static Bool_t first=kTRUE;
1642 static TFile *tfile;
1645 tfile=new TFile("itstracks.root","RECREATE");
1646 //cout<<"I have opened itstracks.root file "<<endl;
1653 sprintf(hname,"TreeT%d",evNumber);
1655 tracktree1.Write(hname);
1659 TTree *fAli=gAlice->TreeK();
1662 if (fAli) fileAli =fAli->GetCurrentFile();
1665 ////////////////////////////////////////////////////////////////////////////////////////////////
1667 printf("delete vectors\n");
1668 if(np) delete [] np;
1669 if(vettid) delete [] vettid;