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.55 2001/06/14 14:59:00 barbera
19 Tracking V1 decoupled from AliITS
21 Revision 1.54 2001/05/31 20:37:56 barbera
22 Bari/Salerno model set as defaault SPD simulation
24 Revision 1.53 2001/05/31 18:52:24 barbera
25 Bari model becomes the default
27 Revision 1.53 2001/05/30 07:52:24 hristov
28 TPC and CONTAINERS included in the search path
30 Revision 1.52 2001/05/30 06:04:58 hristov
31 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
33 Revision 1.51 2001/05/16 14:57:15 alibrary
34 New files for folders and Stack
36 Revision 1.50 2001/05/11 09:15:21 barbera
37 Corrected to make fast point creation working with PPR geometry
39 Revision 1.49 2001/05/11 07:37:49 hristov
40 Legacy lines commented
42 Revision 1.48 2001/05/10 18:14:25 barbera
45 Revision 1.47 2001/05/10 17:55:59 barbera
46 Modified to create rec points also for PPR geometries
48 Revision 1.46 2001/05/10 00:05:28 nilsen
49 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
50 should probably be cleaned up to only check to make sure that fITSgeom has
51 been properly defined.
53 Revision 1.45 2001/05/01 22:35:48 nilsen
54 Remove/commented a number of cout<< statements. and made change needed by
57 Revision 1.44 2001/04/26 22:44:01 nilsen
58 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
59 done properly in AliITSv???.cxx via SetDefaults.
61 Revision 1.43 2001/04/26 13:22:52 barbera
62 TMatrix and TVector elimininated to speed up the code
64 Revision 1.42 2001/04/25 21:55:12 barbera
65 Updated version to be compatible with actual verion of STEER and TPC
67 Revision 1.41 2001/04/21 15:16:51 barbera
68 Updated with the new SSD reconstruction code
70 Revision 1.40 2001/03/17 15:07:06 mariana
71 Update SDD response parameters
73 Revision 1.39 2001/03/12 17:45:32 hristov
74 Changes needed on Sun with CC 5.0
76 Revision 1.38 2001/03/07 14:04:51 barbera
77 Some vector dimensions increased to cope with full events
79 Revision 1.37 2001/03/07 12:36:35 barbera
80 A change added in the tracking part to manage delta rays
82 Revision 1.36 2001/03/02 19:44:11 barbera
83 modified to taking into account new version tracking v1
85 Revision 1.35 2001/02/28 18:16:46 mariana
86 Make the code compatible with the new AliRun
88 Revision 1.34 2001/02/11 15:51:39 mariana
89 Set protection in MakeBranch
91 Revision 1.33 2001/02/10 22:26:39 mariana
92 Move the initialization of the containers for raw clusters in MakeTreeC()
94 Revision 1.32 2001/02/08 23:55:31 nilsen
95 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
96 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
98 Revision 1.31 2001/02/02 23:57:28 nilsen
99 Added include file that are no londer included in AliITSgeom.h
101 Revision 1.30 2001/01/30 09:23:13 hristov
102 Streamers removed (R.Brun)
104 Revision 1.29 2001/01/26 20:01:09 hristov
105 Major upgrade of AliRoot code
107 Revision 1.28 2000/12/18 14:02:00 barbera
108 new version of the ITS tracking to take into account the new TPC track parametrization
110 Revision 1.27 2000/12/08 13:49:27 barbera
111 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
113 Revision 1.26 2000/11/27 13:12:13 barbera
114 New version containing the files for tracking
116 Revision 1.25 2000/11/12 22:38:05 barbera
117 Added header file for the SPD Bari model
119 Revision 1.24 2000/10/09 22:18:12 barbera
120 Bug fixes from MAriana to le AliITStest.C run correctly
122 Revision 1.23 2000/10/05 20:47:42 nilsen
123 fixed dependencies of include files. Tryed but failed to get a root automaticly
124 generates streamer function to work. Modified SetDefaults.
126 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
127 Needed to include stdlib.h
130 Revision 1.22 2000/10/04 19:45:52 barbera
131 Corrected by F. Carminati for v3.04
133 Revision 1.21 2000/10/02 21:28:08 fca
134 Removal of useless dependecies via forward declarations
136 Revision 1.20 2000/10/02 16:31:39 barbera
137 General code clean-up
139 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
140 General code clean-up (e.g., printf -> cout)
142 Revision 1.19 2000/09/22 12:13:25 nilsen
143 Patches and updates for fixes to this and other routines.
145 Revision 1.18 2000/07/12 05:32:20 fca
146 Correcting several syntax problem with static members
148 Revision 1.17 2000/07/10 16:07:18 fca
149 Release version of ITS code
151 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
152 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
154 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
155 //fixed FillModule. Removed fi(fabs(xl)<dx....
157 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
158 This is the version of the files after the merging done in December 1999.
159 See the ReadMe110100.txt file for details
161 Revision 1.9 1999/11/14 14:33:25 fca
162 Correct problems with distructors and pointers, thanks to I.Hrivnacova
164 Revision 1.8 1999/09/29 09:24:19 fca
165 Introduction of the Copyright and cvs Log
169 ///////////////////////////////////////////////////////////////////////////////
171 // An overview of the basic philosophy of the ITS code development
172 // and analysis is show in the figure below.
175 <img src="picts/ITS/ITS_Analysis_schema.gif">
178 <font size=+2 color=red>
179 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
180 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
186 // AliITS. Inner Traking System base class.
187 // This class contains the base procedures for the Inner Tracking System
191 <img src="picts/ITS/AliITS_Class_Diagram.gif">
194 <font size=+2 color=red>
195 <p>This show the class diagram of the different elements that are part of
203 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
206 // Modified and documented by Bjorn S. Nilsen
210 // Modified and documented by A. Bologna
213 // AliITS is the general base class for the ITS. Also see AliDetector for
214 // futher information.
216 ///////////////////////////////////////////////////////////////////////////////
217 #include <iostream.h>
225 #include <TClonesArray.h>
227 #include <TObjectTable.h>
231 //#include <TParticle.h>
236 #include "AliITSMap.h"
237 #include "AliITSDetType.h"
238 #include "AliITSClusterFinder.h"
239 #include "AliITSsimulationSPD.h"
240 #include "AliITSsimulationSDD.h"
241 #include "AliITSsimulationSSD.h"
242 #include "AliITSresponse.h"
243 #include "AliITSsegmentationSPD.h"
244 #include "AliITSresponseSPD.h"
245 #include "AliITSresponseSPDdubna.h"
246 #include "AliITSsegmentationSDD.h"
247 #include "AliITSresponseSDD.h"
248 #include "AliITSsegmentationSSD.h"
249 #include "AliITSresponseSSD.h"
250 #include "AliITShit.h"
251 #include "AliITSgeom.h"
252 #include "AliITSdigit.h"
253 #include "AliITSmodule.h"
254 #include "AliITSRecPoint.h"
255 #include "AliITSRawCluster.h"
259 //#include "AliKalmanTrack.h"
260 //#include "AliMagF.h"
261 //#include "AliITStrack.h"
262 //#include "AliITSiotrack.h"
263 //#include "AliITStracking.h"
264 //#include "AliITSRad.h"
265 //#include "AliTPC.h"
266 //#include "AliTPCParam.h"
267 //#include "AliTPCtracker.h"
271 //_____________________________________________________________________________
272 AliITS::AliITS() : AliDetector() {
274 // Default initialiser for ITS
275 // The default constructor of the AliITS class. In addition to
276 // creating the AliITS class it zeros the variables fIshunt (a member
277 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
278 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
286 fNDetTypes = kNTYPES;
305 //_____________________________________________________________________________
306 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
308 // Default initialiser for ITS
309 // The constructor of the AliITS class. In addition to creating the
310 // AliITS class, it allocates memory for the TClonesArrays fHits and
311 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
312 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
313 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
314 // macro display.C AliITS also sets the marker color to red. The variables
315 // passes with this constructor, const char *name and *title, are used by
316 // the constructor of AliDetector class. See AliDetector class for a
317 // description of these parameters and its constructor functions.
321 fHits = new TClonesArray("AliITShit", 1560);
322 gAlice->AddHitList(fHits);
324 fNDetTypes = kNTYPES;
326 fNdtype = new Int_t[kNTYPES];
327 fDtype = new TObjArray(kNTYPES);
329 fNctype = new Int_t[kNTYPES];
330 fCtype = new TObjArray(kNTYPES);
334 fRecPoints=new TClonesArray("AliITSRecPoint",1000);
347 fDetTypes = new TObjArray(kNTYPES);
350 for(i=0;i<kNTYPES;i++) {
351 fDetTypes->AddAt(new AliITSDetType(),i);
357 SetMarkerColor(kRed);
361 //___________________________________________________________________________
362 AliITS::AliITS(AliITS &source){
364 if(this==&source) return;
365 Error("AliITS::Copy constructor",
366 "You are not allowed to make a copy of the AliITS");
369 //____________________________________________________________________________
370 AliITS& AliITS::operator=(AliITS &source){
371 // assignment operator
372 if(this==&source) return *this;
373 Error("AliITS::operator=",
374 "You are not allowed to make a copy of the AliITS");
376 return *this; //fake return
378 //____________________________________________________________________________
379 void AliITS::ClearModules(){
380 //clear the modules TObjArray
382 if(fITSmodules) fITSmodules->Delete();
385 //_____________________________________________________________________________
388 // Default distructor for ITS
389 // The default destructor of the AliITS class. In addition to deleting
390 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
391 // fIdSens, fIdName, and fITSpoints.
398 // delete fIdName; // TObjArray of TObjStrings
399 if(fIdName!=0) delete[] fIdName; // Array of TStrings
400 if(fIdSens!=0) delete[] fIdSens;
402 this->ClearModules();
404 }// end if fITSmodules!=0
424 if (fTreeC) delete fTreeC;
426 if (fITSgeom) delete fITSgeom;
430 //___________________________________________
431 AliITSDetType* AliITS::DetType(Int_t id)
433 //return pointer to id detector type
434 return ((AliITSDetType*) (*fDetTypes)[id]);
437 //___________________________________________
438 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
440 //set the digit and cluster classes to be used for the id detector type
441 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
444 //___________________________________________
445 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
447 //set the response model for the id detector type
449 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
453 //___________________________________________
454 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
456 //set the segmentation model for the id detector type
458 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
462 //___________________________________________
463 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
465 //set the simulation model for the id detector type
467 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
470 //___________________________________________
471 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
473 //set the cluster finder model for the id detector type
475 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
479 //_____________________________________________________________________________
480 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
483 // The function to add information to the AliITShit class. See the
484 // AliITShit class for a full description. This function allocates the
485 // necessary new space for the hit information and passes the variable
486 // track, and the pointers *vol and *hits to the AliITShit constructor
489 TClonesArray &lhits = *fHits;
490 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
492 //_____________________________________________________________________________
493 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
495 // add a real digit - as coming from data
497 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
498 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
501 //_____________________________________________________________________________
502 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
505 // add a simulated digit
507 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
512 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
515 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
518 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
524 //_____________________________________________________________________________
525 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
527 // add a simulated digit to the list
529 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
533 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
536 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
539 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
545 //_____________________________________________________________________________
546 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
549 // add a cluster to the list
551 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
556 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
559 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
562 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
569 //_____________________________________________________________________________
570 void AliITS::AddRecPoint(const AliITSRecPoint &r)
573 // Add a reconstructed space point to the list
575 TClonesArray &lrecp = *fRecPoints;
576 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
580 //____________________________________________
581 void AliITS::ResetDigits()
584 // Reset number of digits and the digits array for the ITS detector
590 for (i=0;i<kNTYPES;i++ ) {
591 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
592 if (fNdtype) fNdtype[i]=0;
596 //____________________________________________
597 void AliITS::ResetDigits(Int_t i)
600 // Reset number of digits and the digits array for this branch
602 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
603 if (fNdtype) fNdtype[i]=0;
607 //____________________________________________
608 void AliITS::ResetClusters()
611 // Reset number of clusters and the clusters array for ITS
615 for (i=0;i<kNTYPES;i++ ) {
616 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
617 if (fNctype) fNctype[i]=0;
622 //____________________________________________
623 void AliITS::ResetClusters(Int_t i)
626 // Reset number of clusters and the clusters array for this branch
628 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
629 if (fNctype) fNctype[i]=0;
634 //____________________________________________
635 void AliITS::ResetRecPoints()
638 // Reset number of rec points and the rec points array
640 if (fRecPoints) fRecPoints->Clear();
645 //_____________________________________________________________________________
646 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
648 // Distance from mouse to ITS on the screen. Dummy routine
649 // A dummy routine used by the ROOT macro display.C to allow for the
650 // use of the mouse (pointing device) in the macro. In general this should
651 // never be called. If it is it returns the number 9999 for any value of
657 //_____________________________________________________________________________
660 // Initialise ITS after it has been built
661 // This routine initializes the AliITS class. It is intended to be called
662 // from the Init function in AliITSv?. Besides displaying a banner
663 // indicating that it has been called it initializes the array fIdSens
664 // and sets the default segmentation, response, digit and raw cluster classes
665 // Therefore it should be called after a call to CreateGeometry.
672 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
676 //_____________________________________________________________________________
677 void AliITS::SetDefaults()
679 // sets the default segmentation, response, digit and raw cluster classes
681 if(fDebug) printf("%s: SetDefaults\n",ClassName());
683 AliITSDetType *iDetType;
689 if (!iDetType->GetSegmentationModel()) {
690 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
691 SetSegmentationModel(0,seg0);
693 if (!iDetType->GetResponseModel()) {
694 SetResponseModel(0,new AliITSresponseSPD());
696 // set digit and raw cluster classes to be used
698 const char *kData0=(iDetType->GetResponseModel())->DataType();
699 if (strstr(kData0,"real")) {
700 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
701 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
705 if (!iDetType->GetResponseModel()) {
706 SetResponseModel(1,new AliITSresponseSDD());
708 AliITSresponse *resp1=iDetType->GetResponseModel();
709 if (!iDetType->GetSegmentationModel()) {
710 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
711 SetSegmentationModel(1,seg1);
713 const char *kData1=(iDetType->GetResponseModel())->DataType();
714 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
715 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
716 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
717 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
721 if (!iDetType->GetSegmentationModel()) {
722 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
723 SetSegmentationModel(2,seg2);
725 if (!iDetType->GetResponseModel()) {
726 SetResponseModel(2,new AliITSresponseSSD());
728 const char *kData2=(iDetType->GetResponseModel())->DataType();
729 if (strstr(kData2,"real")) {
730 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
731 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
734 Warning("SetDefaults","Only the three basic detector types are initialised!");
738 //_____________________________________________________________________________
739 void AliITS::SetDefaultSimulation()
744 //_____________________________________________________________________________
745 void AliITS::SetDefaultClusterFinders()
750 //_____________________________________________________________________________
752 void AliITS::MakeTreeC(Option_t *option)
754 // create a separate tree to store the clusters
756 // cout << "AliITS::MakeTreeC" << endl;
758 const char *optC = strstr(option,"C");
759 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
762 Int_t buffersize = 4000;
765 const char *det[3] = {"SPD","SDD","SSD"};
770 // one branch for Clusters per type of detector
772 for (i=0; i<kNTYPES ;i++) {
773 AliITSDetType *iDetType=DetType(i);
774 iDetType->GetClassNames(digclass,clclass);
776 fCtype->AddAt(new TClonesArray(clclass,1000),i);
777 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
778 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
779 if (fCtype && fTreeC) {
780 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
781 // cout << "Making Branch " << branchname;
782 // cout << " for Clusters of detector type " << i+1 << endl;
788 //_____________________________________________________________________________
789 void AliITS::GetTreeC(Int_t event)
792 // cout << "AliITS::GetTreeC" << endl;
794 // get the clusters tree for this event and set the branch address
798 const char *det[3] = {"SPD","SDD","SSD"};
805 sprintf(treeName,"TreeC%d",event);
806 fTreeC = (TTree*)gDirectory->Get(treeName);
814 for (i=0; i<kNTYPES; i++) {
816 AliITSDetType *iDetType=DetType(i);
817 iDetType->GetClassNames(digclass,clclass);
819 if(!(*fCtype)[i]) fCtype->AddAt(new TClonesArray(clclass,1000),i);
820 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
821 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
823 branch = fTreeC->GetBranch(branchname);
824 if (branch) branch->SetAddress(&((*fCtype)[i]));
828 Error("AliITS::GetTreeC",
829 "cannot find Clusters Tree for event:%d\n",event);
833 //_____________________________________________________________________________
834 void AliITS::MakeBranch(Option_t* option, const char *file)
837 // Creates Tree branches for the ITS.
840 Int_t buffersize = 4000;
842 sprintf(branchname,"%s",GetName());
844 AliDetector::MakeBranch(option,file);
846 const char *cD = strstr(option,"D");
847 const char *cR = strstr(option,"R");
851 // one branch for digits per type of detector
853 const char *det[3] = {"SPD","SDD","SSD"};
859 for (i=0; i<kNTYPES ;i++) {
860 DetType(i)->GetClassNames(digclass,clclass);
862 if(!((*fDtype)[i])) fDtype->AddAt(new TClonesArray(digclass,1000),i);
866 for (i=0; i<kNTYPES ;i++) {
867 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
868 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
869 if (fDtype && gAlice->TreeD()) {
870 MakeBranchInTree(gAlice->TreeD(),
871 branchname, &((*fDtype)[i]), buffersize, file);
872 // cout << "Making Branch " << branchname;
873 // cout << " for digits of type "<< i+1 << endl;
880 // only one branch for rec points for all detector types
882 sprintf(branchname,"%sRecPoints",GetName());
884 //if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",1000);
886 if (fRecPoints && gAlice->TreeR()) {
887 MakeBranchInTree(gAlice->TreeR(),
888 branchname, &fRecPoints, buffersize, file) ;
889 // cout << "Making Branch " << branchname;
890 // cout << " for reconstructed space points" << endl;
895 //___________________________________________
896 void AliITS::SetTreeAddress()
899 // Set branch address for the Trees.
903 AliDetector::SetTreeAddress();
905 const char *det[3] = {"SPD","SDD","SSD"};
908 TTree *treeD = gAlice->TreeD();
909 TTree *treeR = gAlice->TreeR();
916 for (i=0; i<kNTYPES; i++) {
917 DetType(i)->GetClassNames(digclass,clclass);
919 if(!((*fDtype)[i])) fDtype->AddAt(new TClonesArray(digclass,1000),i);
922 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
923 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
925 branch = treeD->GetBranch(branchname);
926 if (branch) branch->SetAddress(&((*fDtype)[i]));
933 sprintf(branchname,"%sRecPoints",GetName());
934 branch = treeR->GetBranch(branchname);
935 if (branch) branch->SetAddress(&fRecPoints);
941 //____________________________________________________________________________
942 void AliITS::InitModules(Int_t size,Int_t &nmodules){
944 //initialize the modules array
947 fITSmodules->Delete();
951 Int_t nl,indexMAX,index;
953 if(size<=0){ // default to using data stored in AliITSgeom
955 Error("AliITS::InitModules",
956 "in AliITS::InitModule fITSgeom not defined\n");
958 } // end if fITSgeom==0
959 nl = fITSgeom->GetNlayers();
960 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
961 fITSgeom->GetNdetectors(nl))+1;
963 fITSmodules = new TObjArray(indexMAX);
964 for(index=0;index<indexMAX;index++){
965 fITSmodules->AddAt( new AliITSmodule(index),index);
968 fITSmodules = new TObjArray(size);
969 for(index=0;index<size;index++) {
970 fITSmodules->AddAt( new AliITSmodule(index),index);
977 //____________________________________________________________________________
978 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
980 // fill the modules with the sorted by module hits; add hits from background
984 static TTree *trH1; //Tree with background hits
985 static TClonesArray *fHits2; //List of hits for one track only
987 static Bool_t first=kTRUE;
989 const char *addBgr = strstr(option,"Add");
994 // cout<<"filename "<<filename<<endl;
995 file=new TFile(filename);
996 // cout<<"I have opened "<<filename<<" file "<<endl;
997 fHits2 = new TClonesArray("AliITShit",1000 );
1002 // Get Hits Tree header from file
1003 if(fHits2) fHits2->Clear();
1004 if(trH1) delete trH1;
1008 sprintf(treeName,"TreeH%d",bgrev);
1009 trH1 = (TTree*)gDirectory->Get(treeName);
1010 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
1013 Error("AliITS::FillModules",
1014 "cannot find Hits Tree for event:%d\n",bgrev);
1016 // Set branch addresses
1018 char branchname[20];
1019 sprintf(branchname,"%s",GetName());
1020 if (trH1 && fHits2) {
1021 branch = trH1->GetBranch(branchname);
1022 if (branch) branch->SetAddress(&fHits2);
1026 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
1027 //printf("background - ntracks1 - %d\n",ntracks1);
1030 //Int_t npart = gAlice->GetEvent(evnt);
1031 //if(npart<=0) return;
1032 TClonesArray *itsHits = this->Hits();
1033 Int_t lay,lad,det,index;
1034 AliITShit *itsHit=0;
1035 AliITSmodule *mod=0;
1037 TTree *iTH = gAlice->TreeH();
1038 Int_t ntracks =(Int_t) iTH->GetEntries();
1041 for(t=0; t<ntracks; t++){
1042 gAlice->ResetHits();
1044 Int_t nhits = itsHits->GetEntriesFast();
1045 //printf("nhits %d\n",nhits);
1046 if (!nhits) continue;
1047 for(h=0; h<nhits; h++){
1048 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
1049 itsHit->GetDetectorID(lay,lad,det);
1050 // temporarily index=det-1 !!!
1051 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1054 mod = this->GetModule(index);
1055 mod->AddHit(itsHit,t,h);
1056 } // end loop over hits
1057 } // end loop over tracks
1059 // open the file with background
1063 ntracks =(Int_t)trH1->GetEntries();
1064 //printf("background - ntracks1 %d\n",ntracks);
1065 //printf("background - Start loop over tracks \n");
1068 for (track=0; track<ntracks; track++) {
1070 if (fHits2) fHits2->Clear();
1071 trH1->GetEvent(track);
1073 for(i=0;i<fHits2->GetEntriesFast();++i) {
1075 itsHit=(AliITShit*) (*fHits2)[i];
1076 itsHit->GetDetectorID(lay,lad,det);
1077 // temporarily index=det-1 !!!
1078 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1081 mod = this->GetModule(index);
1082 mod->AddHit(itsHit,track,i);
1083 } // end loop over hits
1084 } // end loop over tracks
1086 TTree *fAli=gAlice->TreeK();
1089 if (fAli) fileAli =fAli->GetCurrentFile();
1094 //gObjectTable->Print();
1098 //____________________________________________________________________________
1100 void AliITS::SDigits2Digits()
1103 AliITSgeom *geom = GetITSgeom();
1106 AliITSDetType *iDetType;
1107 iDetType=DetType(0);
1108 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
1109 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
1110 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
1111 SetSimulationModel(0,sim0);
1113 // printf("SPD dimensions %f %f \n",seg0->Dx(),seg0->Dz());
1114 // printf("SPD npixels %d %d \n",seg0->Npz(),seg0->Npx());
1115 // printf("SPD pitches %d %d \n",seg0->Dpz(0),seg0->Dpx(0));
1119 //Set response functions
1120 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
1122 iDetType=DetType(1);
1123 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
1125 res1=new AliITSresponseSDD();
1126 SetResponseModel(1,res1);
1128 Float_t noise, baseline;
1129 res1->GetNoiseParam(noise,baseline);
1130 Float_t noise_after_el = res1->GetNoiseAfterElectronics();
1131 Float_t fCutAmp = baseline + 2.*noise_after_el;
1132 Int_t cp[8]={0,0,(int)fCutAmp,(int)fCutAmp,0,0,0,0}; //1D
1133 res1->SetCompressParam(cp);
1134 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
1136 seg1 = new AliITSsegmentationSDD(geom,res1);
1137 SetSegmentationModel(1,seg1);
1139 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
1140 SetSimulationModel(1,sim1);
1143 iDetType=DetType(2);
1144 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
1145 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
1146 res2->SetSigmaSpread(3.,2.);
1147 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
1148 SetSimulationModel(2,sim2);
1150 cerr<<"Digitizing ITS...\n";
1154 HitsToDigits(gAlice->GetEvNumber(),0,-1," ","All"," ");
1155 timer.Stop(); timer.Print();
1163 //____________________________________________________________________________
1164 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
1166 // keep galice.root for signal and name differently the file for
1167 // background when add! otherwise the track info for signal will be lost !
1169 // the condition below will disappear when the geom class will be
1170 // initialised for all versions - for the moment it is only for v5 !
1171 // 7 is the SDD beam test version
1172 Int_t ver = this->IsVersion();
1173 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
1175 const char *all = strstr(opt,"All");
1176 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1177 // cout<<" 1 AliITS "<<endl;
1179 InitModules(size,nmodules);
1180 // cout<<" 2 AliITS "<<endl;
1181 FillModules(evNumber,bgrev,nmodules,option,filename);
1182 // cout<<" 3 AliITS "<<endl;
1185 AliITSsimulation* sim;
1186 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
1187 AliITSgeom *geom = GetITSgeom();
1190 // Int_t lay, lad, detect;
1192 for (id=0;id<kNTYPES;id++) {
1193 if (!all && !det[id]) continue;
1194 //branch = (TBranch*)branches->UncheckedAt(id);
1195 AliITSDetType *iDetType=DetType(id);
1196 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1199 Error("HitsToDigits","The simulation class was not instantiated!");
1201 // or SetDefaultSimulation();
1205 first = geom->GetStartDet(id);
1206 last = geom->GetLastDet(id);
1207 } else first=last=0;
1208 // cout << "det type " << id << " first, last "<< first << last << endl;
1209 for(module=first;module<=last;module++) {
1210 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1212 geom->GetModuleId(module,lay, lad, detect);
1214 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(6);
1216 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(5);
1218 sim->DigitiseModule(mod,module,evNumber);
1219 // fills all branches - wasted disk space
1220 gAlice->TreeD()->Fill();
1222 // try and fill only the branch
1225 } // loop over modules
1226 } // loop over detector types
1230 // Int_t nentries=(Int_t)
1231 gAlice->TreeD()->GetEntries();
1232 // cout << "nentries in TreeD" << nentries << endl;
1235 sprintf(hname,"TreeD%d",evNumber);
1236 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1238 gAlice->TreeD()->Reset();
1243 //____________________________________________________________________________
1244 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1246 // cluster finding and reconstruction of space points
1248 // the condition below will disappear when the geom class will be
1249 // initialised for all versions - for the moment it is only for v5 !
1250 // 7 is the SDD beam test version
1251 Int_t ver = this->IsVersion();
1252 if(ver!=5 && ver!=8 && ver!=9) return;
1254 const char *all = strstr(opt,"All");
1255 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1257 static Bool_t first=kTRUE;
1258 if (!TreeC() && first) {
1263 TTree *treeC=TreeC();
1267 AliITSClusterFinder* rec;
1269 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1270 AliITSgeom *geom = GetITSgeom();
1273 for (id=0;id<kNTYPES;id++) {
1274 if (!all && !det[id]) continue;
1275 //branch = (TBranch*)branches->UncheckedAt(id);
1276 AliITSDetType *iDetType=DetType(id);
1277 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1279 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1281 // or SetDefaultClusterFinders();
1283 TClonesArray *itsDigits = this->DigitsAddress(id);
1287 first = geom->GetStartDet(id);
1288 last = geom->GetLastDet(id);
1289 } else first=last=0;
1290 printf("first module - last module %d %d\n",first,last);
1291 for(module=first;module<=last;module++) {
1292 this->ResetDigits();
1293 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1294 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1295 Int_t ndigits = itsDigits->GetEntriesFast();
1296 if (ndigits) rec->FindRawClusters(module);
1297 gAlice->TreeR()->Fill();
1301 // try and fill only the branch
1303 //ResetRecPoints(id);
1304 } // loop over modules
1305 } // loop over detector types
1308 // Int_t nentries=(Int_t)
1309 gAlice->TreeR()->GetEntries();
1310 // Int_t ncentries=(Int_t)
1311 treeC->GetEntries();
1312 // cout << " nentries ncentries " << nentries << ncentries << endl;
1315 sprintf(hname,"TreeR%d",evNumber);
1316 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1318 gAlice->TreeR()->Reset();
1320 sprintf(hname,"TreeC%d",evNumber);
1321 treeC->Write(hname,TObject::kOverwrite);
1324 //____________________________________________________________________________
1325 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1326 Option_t *option,Option_t *opt,Text_t *filename)
1328 // keep galice.root for signal and name differently the file for
1329 // background when add! otherwise the track info for signal will be lost !
1332 // the condition below will disappear when the geom class will be
1333 // initialised for all versions - for the moment it is only for v5 !
1334 Int_t ver = this->IsVersion();
1335 if(ver!=5 && ver!=8 && ver!=9) return;
1336 //if(ver!=5) return;
1338 const char *all = strstr(opt,"All");
1339 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1342 InitModules(size,nmodules);
1343 FillModules(evNumber,bgrev,nmodules,option,filename);
1346 AliITSsimulation* sim;
1347 AliITSgeom *geom = GetITSgeom();
1349 TRandom *random=new TRandom[9];
1350 random[0].SetSeed(111);
1351 random[1].SetSeed(222);
1352 random[2].SetSeed(333);
1353 random[3].SetSeed(444);
1354 random[4].SetSeed(555);
1355 random[5].SetSeed(666);
1356 random[6].SetSeed(777);
1357 random[7].SetSeed(888);
1358 random[8].SetSeed(999);
1362 for (id=0;id<kNTYPES;id++) {
1363 if (!all && !det[id]) continue;
1364 AliITSDetType *iDetType=DetType(id);
1365 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1367 Error("HitsToFastPoints",
1368 "The simulation class was not instantiated!");
1370 // or SetDefaultSimulation();
1375 first = geom->GetStartDet(id);
1376 last = geom->GetLastDet(id);
1377 } else first=last=0;
1378 printf("first module - last module %d %d\n",first,last);
1379 for(module=first;module<=last;module++) {
1380 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1381 sim->CreateFastRecPoints(mod,module,random);
1382 gAlice->TreeR()->Fill();
1384 } // loop over modules
1385 } // loop over detector types
1390 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1393 sprintf(hname,"TreeR%d",evNumber);
1394 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1396 gAlice->TreeR()->Reset();