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.54 2001/05/31 20:37:56 barbera
19 Bari/Salerno model set as defaault SPD simulation
21 Revision 1.53 2001/05/31 18:52:24 barbera
22 Bari model becomes the default
24 Revision 1.53 2001/05/30 07:52:24 hristov
25 TPC and CONTAINERS included in the search path
27 Revision 1.52 2001/05/30 06:04:58 hristov
28 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
30 Revision 1.51 2001/05/16 14:57:15 alibrary
31 New files for folders and Stack
33 Revision 1.50 2001/05/11 09:15:21 barbera
34 Corrected to make fast point creation working with PPR geometry
36 Revision 1.49 2001/05/11 07:37:49 hristov
37 Legacy lines commented
39 Revision 1.48 2001/05/10 18:14:25 barbera
42 Revision 1.47 2001/05/10 17:55:59 barbera
43 Modified to create rec points also for PPR geometries
45 Revision 1.46 2001/05/10 00:05:28 nilsen
46 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
47 should probably be cleaned up to only check to make sure that fITSgeom has
48 been properly defined.
50 Revision 1.45 2001/05/01 22:35:48 nilsen
51 Remove/commented a number of cout<< statements. and made change needed by
54 Revision 1.44 2001/04/26 22:44:01 nilsen
55 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
56 done properly in AliITSv???.cxx via SetDefaults.
58 Revision 1.43 2001/04/26 13:22:52 barbera
59 TMatrix and TVector elimininated to speed up the code
61 Revision 1.42 2001/04/25 21:55:12 barbera
62 Updated version to be compatible with actual verion of STEER and TPC
64 Revision 1.41 2001/04/21 15:16:51 barbera
65 Updated with the new SSD reconstruction code
67 Revision 1.40 2001/03/17 15:07:06 mariana
68 Update SDD response parameters
70 Revision 1.39 2001/03/12 17:45:32 hristov
71 Changes needed on Sun with CC 5.0
73 Revision 1.38 2001/03/07 14:04:51 barbera
74 Some vector dimensions increased to cope with full events
76 Revision 1.37 2001/03/07 12:36:35 barbera
77 A change added in the tracking part to manage delta rays
79 Revision 1.36 2001/03/02 19:44:11 barbera
80 modified to taking into account new version tracking v1
82 Revision 1.35 2001/02/28 18:16:46 mariana
83 Make the code compatible with the new AliRun
85 Revision 1.34 2001/02/11 15:51:39 mariana
86 Set protection in MakeBranch
88 Revision 1.33 2001/02/10 22:26:39 mariana
89 Move the initialization of the containers for raw clusters in MakeTreeC()
91 Revision 1.32 2001/02/08 23:55:31 nilsen
92 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
93 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
95 Revision 1.31 2001/02/02 23:57:28 nilsen
96 Added include file that are no londer included in AliITSgeom.h
98 Revision 1.30 2001/01/30 09:23:13 hristov
99 Streamers removed (R.Brun)
101 Revision 1.29 2001/01/26 20:01:09 hristov
102 Major upgrade of AliRoot code
104 Revision 1.28 2000/12/18 14:02:00 barbera
105 new version of the ITS tracking to take into account the new TPC track parametrization
107 Revision 1.27 2000/12/08 13:49:27 barbera
108 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
110 Revision 1.26 2000/11/27 13:12:13 barbera
111 New version containing the files for tracking
113 Revision 1.25 2000/11/12 22:38:05 barbera
114 Added header file for the SPD Bari model
116 Revision 1.24 2000/10/09 22:18:12 barbera
117 Bug fixes from MAriana to le AliITStest.C run correctly
119 Revision 1.23 2000/10/05 20:47:42 nilsen
120 fixed dependencies of include files. Tryed but failed to get a root automaticly
121 generates streamer function to work. Modified SetDefaults.
123 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
124 Needed to include stdlib.h
127 Revision 1.22 2000/10/04 19:45:52 barbera
128 Corrected by F. Carminati for v3.04
130 Revision 1.21 2000/10/02 21:28:08 fca
131 Removal of useless dependecies via forward declarations
133 Revision 1.20 2000/10/02 16:31:39 barbera
134 General code clean-up
136 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
137 General code clean-up (e.g., printf -> cout)
139 Revision 1.19 2000/09/22 12:13:25 nilsen
140 Patches and updates for fixes to this and other routines.
142 Revision 1.18 2000/07/12 05:32:20 fca
143 Correcting several syntax problem with static members
145 Revision 1.17 2000/07/10 16:07:18 fca
146 Release version of ITS code
148 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
149 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
151 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
152 //fixed FillModule. Removed fi(fabs(xl)<dx....
154 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
155 This is the version of the files after the merging done in December 1999.
156 See the ReadMe110100.txt file for details
158 Revision 1.9 1999/11/14 14:33:25 fca
159 Correct problems with distructors and pointers, thanks to I.Hrivnacova
161 Revision 1.8 1999/09/29 09:24:19 fca
162 Introduction of the Copyright and cvs Log
166 ///////////////////////////////////////////////////////////////////////////////
168 // An overview of the basic philosophy of the ITS code development
169 // and analysis is show in the figure below.
172 <img src="picts/ITS/ITS_Analysis_schema.gif">
175 <font size=+2 color=red>
176 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
177 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
183 // AliITS. Inner Traking System base class.
184 // This class contains the base procedures for the Inner Tracking System
188 <img src="picts/ITS/AliITS_Class_Diagram.gif">
191 <font size=+2 color=red>
192 <p>This show the class diagram of the different elements that are part of
200 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
203 // Modified and documented by Bjorn S. Nilsen
207 // Modified and documented by A. Bologna
210 // AliITS is the general base class for the ITS. Also see AliDetector for
211 // futher information.
213 ///////////////////////////////////////////////////////////////////////////////
214 #include <iostream.h>
222 #include <TClonesArray.h>
224 #include <TObjectTable.h>
228 //#include <TParticle.h>
233 #include "AliITSMap.h"
234 #include "AliITSDetType.h"
235 #include "AliITSClusterFinder.h"
236 #include "AliITSsimulationSPD.h"
237 #include "AliITSsimulationSDD.h"
238 #include "AliITSsimulationSSD.h"
239 #include "AliITSresponse.h"
240 #include "AliITSsegmentationSPD.h"
241 #include "AliITSresponseSPD.h"
242 #include "AliITSresponseSPDdubna.h"
243 #include "AliITSsegmentationSDD.h"
244 #include "AliITSresponseSDD.h"
245 #include "AliITSsegmentationSSD.h"
246 #include "AliITSresponseSSD.h"
247 #include "AliITShit.h"
248 #include "AliITSgeom.h"
249 #include "AliITSdigit.h"
250 #include "AliITSmodule.h"
251 #include "AliITSRecPoint.h"
252 #include "AliITSRawCluster.h"
256 //#include "AliKalmanTrack.h"
257 //#include "AliMagF.h"
258 //#include "AliITStrack.h"
259 //#include "AliITSiotrack.h"
260 //#include "AliITStracking.h"
261 //#include "AliITSRad.h"
262 //#include "AliTPC.h"
263 //#include "AliTPCParam.h"
264 //#include "AliTPCtracker.h"
268 //_____________________________________________________________________________
269 AliITS::AliITS() : AliDetector() {
271 // Default initialiser for ITS
272 // The default constructor of the AliITS class. In addition to
273 // creating the AliITS class it zeros the variables fIshunt (a member
274 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
275 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
283 fNDetTypes = kNTYPES;
302 //_____________________________________________________________________________
303 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
305 // Default initialiser for ITS
306 // The constructor of the AliITS class. In addition to creating the
307 // AliITS class, it allocates memory for the TClonesArrays fHits and
308 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
309 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
310 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
311 // macro display.C AliITS also sets the marker color to red. The variables
312 // passes with this constructor, const char *name and *title, are used by
313 // the constructor of AliDetector class. See AliDetector class for a
314 // description of these parameters and its constructor functions.
318 fHits = new TClonesArray("AliITShit", 1560);
319 gAlice->AddHitList(fHits);
321 fNDetTypes = kNTYPES;
323 fNdtype = new Int_t[kNTYPES];
324 fDtype = new TObjArray(kNTYPES);
326 fNctype = new Int_t[kNTYPES];
327 fCtype = new TObjArray(kNTYPES);
343 fDetTypes = new TObjArray(kNTYPES);
346 for(i=0;i<kNTYPES;i++) {
347 fDetTypes->AddAt(new AliITSDetType(),i);
353 SetMarkerColor(kRed);
357 //___________________________________________________________________________
358 AliITS::AliITS(AliITS &source){
360 if(this==&source) return;
361 Error("AliITS::Copy constructor",
362 "You are not allowed to make a copy of the AliITS");
365 //____________________________________________________________________________
366 AliITS& AliITS::operator=(AliITS &source){
367 // assignment operator
368 if(this==&source) return *this;
369 Error("AliITS::operator=",
370 "You are not allowed to make a copy of the AliITS");
372 return *this; //fake return
374 //____________________________________________________________________________
375 void AliITS::ClearModules(){
376 //clear the modules TObjArray
378 if(fITSmodules) fITSmodules->Delete();
381 //_____________________________________________________________________________
384 // Default distructor for ITS
385 // The default destructor of the AliITS class. In addition to deleting
386 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
387 // fIdSens, fIdName, and fITSpoints.
394 // delete fIdName; // TObjArray of TObjStrings
395 if(fIdName!=0) delete[] fIdName; // Array of TStrings
396 if(fIdSens!=0) delete[] fIdSens;
398 this->ClearModules();
400 }// end if fITSmodules!=0
420 if (fTreeC) delete fTreeC;
422 if (fITSgeom) delete fITSgeom;
426 //___________________________________________
427 AliITSDetType* AliITS::DetType(Int_t id)
429 //return pointer to id detector type
430 return ((AliITSDetType*) (*fDetTypes)[id]);
433 //___________________________________________
434 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
436 //set the digit and cluster classes to be used for the id detector type
437 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
440 //___________________________________________
441 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
443 //set the response model for the id detector type
445 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
449 //___________________________________________
450 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
452 //set the segmentation model for the id detector type
454 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
458 //___________________________________________
459 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
461 //set the simulation model for the id detector type
463 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
466 //___________________________________________
467 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
469 //set the cluster finder model for the id detector type
471 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
475 //_____________________________________________________________________________
476 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
479 // The function to add information to the AliITShit class. See the
480 // AliITShit class for a full description. This function allocates the
481 // necessary new space for the hit information and passes the variable
482 // track, and the pointers *vol and *hits to the AliITShit constructor
485 TClonesArray &lhits = *fHits;
486 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
488 //_____________________________________________________________________________
489 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
491 // add a real digit - as coming from data
493 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
494 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
497 //_____________________________________________________________________________
498 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
501 // add a simulated digit
503 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
508 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
511 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
514 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
520 //_____________________________________________________________________________
521 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
523 // add a simulated digit to the list
525 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
529 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
532 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
535 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
541 //_____________________________________________________________________________
542 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
545 // add a cluster to the list
547 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
552 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
555 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
558 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
565 //_____________________________________________________________________________
566 void AliITS::AddRecPoint(const AliITSRecPoint &r)
569 // Add a reconstructed space point to the list
571 TClonesArray &lrecp = *fRecPoints;
572 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
576 //____________________________________________
577 void AliITS::ResetDigits()
580 // Reset number of digits and the digits array for the ITS detector
586 for (i=0;i<kNTYPES;i++ ) {
587 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
588 if (fNdtype) fNdtype[i]=0;
592 //____________________________________________
593 void AliITS::ResetDigits(Int_t i)
596 // Reset number of digits and the digits array for this branch
598 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
599 if (fNdtype) fNdtype[i]=0;
603 //____________________________________________
604 void AliITS::ResetClusters()
607 // Reset number of clusters and the clusters array for ITS
611 for (i=0;i<kNTYPES;i++ ) {
612 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
613 if (fNctype) fNctype[i]=0;
618 //____________________________________________
619 void AliITS::ResetClusters(Int_t i)
622 // Reset number of clusters and the clusters array for this branch
624 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
625 if (fNctype) fNctype[i]=0;
630 //____________________________________________
631 void AliITS::ResetRecPoints()
634 // Reset number of rec points and the rec points array
636 if (fRecPoints) fRecPoints->Clear();
641 //_____________________________________________________________________________
642 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
644 // Distance from mouse to ITS on the screen. Dummy routine
645 // A dummy routine used by the ROOT macro display.C to allow for the
646 // use of the mouse (pointing device) in the macro. In general this should
647 // never be called. If it is it returns the number 9999 for any value of
653 //_____________________________________________________________________________
656 // Initialise ITS after it has been built
657 // This routine initializes the AliITS class. It is intended to be called
658 // from the Init function in AliITSv?. Besides displaying a banner
659 // indicating that it has been called it initializes the array fIdSens
660 // and sets the default segmentation, response, digit and raw cluster classes
661 // Therefore it should be called after a call to CreateGeometry.
668 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
672 //_____________________________________________________________________________
673 void AliITS::SetDefaults()
675 // sets the default segmentation, response, digit and raw cluster classes
677 if(fDebug) printf("%s: SetDefaults\n",ClassName());
679 AliITSDetType *iDetType;
685 if (!iDetType->GetSegmentationModel()) {
686 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
687 SetSegmentationModel(0,seg0);
689 if (!iDetType->GetResponseModel()) {
690 SetResponseModel(0,new AliITSresponseSPD());
692 // set digit and raw cluster classes to be used
694 const char *kData0=(iDetType->GetResponseModel())->DataType();
695 if (strstr(kData0,"real")) {
696 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
697 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
701 if (!iDetType->GetResponseModel()) {
702 SetResponseModel(1,new AliITSresponseSDD());
704 AliITSresponse *resp1=iDetType->GetResponseModel();
705 if (!iDetType->GetSegmentationModel()) {
706 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
707 SetSegmentationModel(1,seg1);
709 const char *kData1=(iDetType->GetResponseModel())->DataType();
710 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
711 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
712 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
713 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
717 if (!iDetType->GetSegmentationModel()) {
718 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
719 SetSegmentationModel(2,seg2);
721 if (!iDetType->GetResponseModel()) {
722 SetResponseModel(2,new AliITSresponseSSD());
724 const char *kData2=(iDetType->GetResponseModel())->DataType();
725 if (strstr(kData2,"real")) {
726 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
727 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
730 Warning("SetDefaults","Only the three basic detector types are initialised!");
734 //_____________________________________________________________________________
735 void AliITS::SetDefaultSimulation()
740 //_____________________________________________________________________________
741 void AliITS::SetDefaultClusterFinders()
746 //_____________________________________________________________________________
748 void AliITS::MakeTreeC(Option_t *option)
750 // create a separate tree to store the clusters
752 // cout << "AliITS::MakeTreeC" << endl;
754 const char *optC = strstr(option,"C");
755 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
758 Int_t buffersize = 4000;
761 const char *det[3] = {"SPD","SDD","SSD"};
766 // one branch for Clusters per type of detector
768 for (i=0; i<kNTYPES ;i++) {
769 AliITSDetType *iDetType=DetType(i);
770 iDetType->GetClassNames(digclass,clclass);
772 (*fCtype)[i] = new TClonesArray(clclass,10000);
773 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
774 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
775 if (fCtype && fTreeC) {
776 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
777 // cout << "Making Branch " << branchname;
778 // cout << " for Clusters of detector type " << i+1 << endl;
784 //_____________________________________________________________________________
785 void AliITS::GetTreeC(Int_t event)
788 // cout << "AliITS::GetTreeC" << endl;
790 // get the clusters tree for this event and set the branch address
794 const char *det[3] = {"SPD","SDD","SSD"};
801 sprintf(treeName,"TreeC%d",event);
802 fTreeC = (TTree*)gDirectory->Get(treeName);
807 for (i=0; i<kNTYPES; i++) {
808 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
809 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
811 branch = fTreeC->GetBranch(branchname);
812 if (branch) branch->SetAddress(&((*fCtype)[i]));
816 Error("AliITS::GetTreeC",
817 "cannot find Clusters Tree for event:%d\n",event);
821 //_____________________________________________________________________________
822 void AliITS::MakeBranch(Option_t* option, const char *file)
825 // Creates Tree branches for the ITS.
828 Int_t buffersize = 4000;
830 sprintf(branchname,"%s",GetName());
832 AliDetector::MakeBranch(option,file);
834 const char *cD = strstr(option,"D");
835 const char *cR = strstr(option,"R");
839 // one branch for digits per type of detector
841 const char *det[3] = {"SPD","SDD","SSD"};
847 for (i=0; i<kNTYPES ;i++) {
848 AliITSDetType *iDetType=DetType(i);
849 iDetType->GetClassNames(digclass,clclass);
851 if(!((*fDtype)[i])) (*fDtype)[i] = new TClonesArray(digclass,10000);
855 for (i=0; i<kNTYPES ;i++) {
856 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
857 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
858 if (fDtype && gAlice->TreeD()) {
859 MakeBranchInTree(gAlice->TreeD(),
860 branchname, &((*fDtype)[i]), buffersize, file);
861 // cout << "Making Branch " << branchname;
862 // cout << " for digits of type "<< i+1 << endl;
869 // only one branch for rec points for all detector types
871 sprintf(branchname,"%sRecPoints",GetName());
873 if(!fRecPoints) fRecPoints=new TClonesArray("AliITSRecPoint",10000);
875 if (fRecPoints && gAlice->TreeR()) {
876 MakeBranchInTree(gAlice->TreeR(),
877 branchname, &fRecPoints, buffersize, file) ;
878 // cout << "Making Branch " << branchname;
879 // cout << " for reconstructed space points" << endl;
884 //___________________________________________
885 void AliITS::SetTreeAddress()
888 // Set branch address for the Trees.
891 AliDetector::SetTreeAddress();
893 const char *det[3] = {"SPD","SDD","SSD"};
896 TTree *treeD = gAlice->TreeD();
897 TTree *treeR = gAlice->TreeR();
901 for (i=0; i<kNTYPES; i++) {
902 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
903 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
905 branch = treeD->GetBranch(branchname);
906 if (branch) branch->SetAddress(&((*fDtype)[i]));
913 sprintf(branchname,"%sRecPoints",GetName());
914 branch = treeR->GetBranch(branchname);
915 if (branch) branch->SetAddress(&fRecPoints);
921 //____________________________________________________________________________
922 void AliITS::InitModules(Int_t size,Int_t &nmodules){
924 //initialize the modules array
927 fITSmodules->Delete();
931 Int_t nl,indexMAX,index;
933 if(size<=0){ // default to using data stored in AliITSgeom
935 Error("AliITS::InitModules",
936 "in AliITS::InitModule fITSgeom not defined\n");
938 } // end if fITSgeom==0
939 nl = fITSgeom->GetNlayers();
940 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
941 fITSgeom->GetNdetectors(nl))+1;
943 fITSmodules = new TObjArray(indexMAX);
944 for(index=0;index<indexMAX;index++){
945 fITSmodules->AddAt( new AliITSmodule(index),index);
948 fITSmodules = new TObjArray(size);
949 for(index=0;index<size;index++) {
950 fITSmodules->AddAt( new AliITSmodule(index),index);
957 //____________________________________________________________________________
958 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
960 // fill the modules with the sorted by module hits; add hits from background
964 static TTree *trH1; //Tree with background hits
965 static TClonesArray *fHits2; //List of hits for one track only
967 static Bool_t first=kTRUE;
969 const char *addBgr = strstr(option,"Add");
974 // cout<<"filename "<<filename<<endl;
975 file=new TFile(filename);
976 // cout<<"I have opened "<<filename<<" file "<<endl;
977 fHits2 = new TClonesArray("AliITShit",1000 );
982 // Get Hits Tree header from file
983 if(fHits2) fHits2->Clear();
984 if(trH1) delete trH1;
988 sprintf(treeName,"TreeH%d",bgrev);
989 trH1 = (TTree*)gDirectory->Get(treeName);
990 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
993 Error("AliITS::FillModules",
994 "cannot find Hits Tree for event:%d\n",bgrev);
996 // Set branch addresses
999 sprintf(branchname,"%s",GetName());
1000 if (trH1 && fHits2) {
1001 branch = trH1->GetBranch(branchname);
1002 if (branch) branch->SetAddress(&fHits2);
1006 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
1007 //printf("background - ntracks1 - %d\n",ntracks1);
1010 //Int_t npart = gAlice->GetEvent(evnt);
1011 //if(npart<=0) return;
1012 TClonesArray *itsHits = this->Hits();
1013 Int_t lay,lad,det,index;
1014 AliITShit *itsHit=0;
1015 AliITSmodule *mod=0;
1017 TTree *iTH = gAlice->TreeH();
1018 Int_t ntracks =(Int_t) iTH->GetEntries();
1021 for(t=0; t<ntracks; t++){
1022 gAlice->ResetHits();
1024 Int_t nhits = itsHits->GetEntriesFast();
1025 //printf("nhits %d\n",nhits);
1026 if (!nhits) continue;
1027 for(h=0; h<nhits; h++){
1028 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
1029 itsHit->GetDetectorID(lay,lad,det);
1030 // temporarily index=det-1 !!!
1031 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1034 mod = this->GetModule(index);
1035 mod->AddHit(itsHit,t,h);
1036 } // end loop over hits
1037 } // end loop over tracks
1039 // open the file with background
1043 ntracks =(Int_t)trH1->GetEntries();
1044 //printf("background - ntracks1 %d\n",ntracks);
1045 //printf("background - Start loop over tracks \n");
1048 for (track=0; track<ntracks; track++) {
1050 if (fHits2) fHits2->Clear();
1051 trH1->GetEvent(track);
1053 for(i=0;i<fHits2->GetEntriesFast();++i) {
1055 itsHit=(AliITShit*) (*fHits2)[i];
1056 itsHit->GetDetectorID(lay,lad,det);
1057 // temporarily index=det-1 !!!
1058 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1061 mod = this->GetModule(index);
1062 mod->AddHit(itsHit,track,i);
1063 } // end loop over hits
1064 } // end loop over tracks
1066 TTree *fAli=gAlice->TreeK();
1069 if (fAli) fileAli =fAli->GetCurrentFile();
1074 //gObjectTable->Print();
1078 //____________________________________________________________________________
1080 void AliITS::SDigits2Digits()
1083 AliITSgeom *geom = GetITSgeom();
1086 AliITSDetType *iDetType;
1087 iDetType=DetType(0);
1088 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
1089 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
1090 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
1091 SetSimulationModel(0,sim0);
1093 // printf("SPD dimensions %f %f \n",seg0->Dx(),seg0->Dz());
1094 // printf("SPD npixels %d %d \n",seg0->Npz(),seg0->Npx());
1095 // printf("SPD pitches %d %d \n",seg0->Dpz(0),seg0->Dpx(0));
1099 //Set response functions
1100 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
1102 iDetType=DetType(1);
1103 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
1105 res1=new AliITSresponseSDD();
1106 SetResponseModel(1,res1);
1108 Float_t noise, baseline;
1109 res1->GetNoiseParam(noise,baseline);
1110 Float_t noise_after_el = res1->GetNoiseAfterElectronics();
1111 Float_t fCutAmp = baseline + 2.*noise_after_el;
1112 Int_t cp[8]={0,0,(int)fCutAmp,(int)fCutAmp,0,0,0,0}; //1D
1113 res1->SetCompressParam(cp);
1114 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
1116 seg1 = new AliITSsegmentationSDD(geom,res1);
1117 SetSegmentationModel(1,seg1);
1119 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
1120 SetSimulationModel(1,sim1);
1123 iDetType=DetType(2);
1124 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
1125 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
1126 res2->SetSigmaSpread(3.,2.);
1127 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
1128 SetSimulationModel(2,sim2);
1130 cerr<<"Digitizing ITS...\n";
1134 HitsToDigits(gAlice->GetEvNumber(),0,-1," ","All"," ");
1135 timer.Stop(); timer.Print();
1143 //____________________________________________________________________________
1144 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
1146 // keep galice.root for signal and name differently the file for
1147 // background when add! otherwise the track info for signal will be lost !
1149 // the condition below will disappear when the geom class will be
1150 // initialised for all versions - for the moment it is only for v5 !
1151 // 7 is the SDD beam test version
1152 Int_t ver = this->IsVersion();
1153 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
1155 const char *all = strstr(opt,"All");
1156 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1157 // cout<<" 1 AliITS "<<endl;
1159 InitModules(size,nmodules);
1160 // cout<<" 2 AliITS "<<endl;
1161 FillModules(evNumber,bgrev,nmodules,option,filename);
1162 // cout<<" 3 AliITS "<<endl;
1165 AliITSsimulation* sim;
1166 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
1167 AliITSgeom *geom = GetITSgeom();
1170 // Int_t lay, lad, detect;
1172 for (id=0;id<kNTYPES;id++) {
1173 if (!all && !det[id]) continue;
1174 //branch = (TBranch*)branches->UncheckedAt(id);
1175 AliITSDetType *iDetType=DetType(id);
1176 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1179 Error("HitsToDigits","The simulation class was not instantiated!");
1181 // or SetDefaultSimulation();
1185 first = geom->GetStartDet(id);
1186 last = geom->GetLastDet(id);
1187 } else first=last=0;
1188 // cout << "det type " << id << " first, last "<< first << last << endl;
1189 for(module=first;module<=last;module++) {
1190 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1192 geom->GetModuleId(module,lay, lad, detect);
1194 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(6);
1196 ((AliITSsegmentationSSD*)(((AliITSsimulationSSD*)sim)->GetSegmentation()))->SetLayer(5);
1198 sim->DigitiseModule(mod,module,evNumber);
1199 // fills all branches - wasted disk space
1200 gAlice->TreeD()->Fill();
1202 // try and fill only the branch
1205 } // loop over modules
1206 } // loop over detector types
1210 // Int_t nentries=(Int_t)
1211 gAlice->TreeD()->GetEntries();
1212 // cout << "nentries in TreeD" << nentries << endl;
1215 sprintf(hname,"TreeD%d",evNumber);
1216 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1218 gAlice->TreeD()->Reset();
1223 //____________________________________________________________________________
1224 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1226 // cluster finding and reconstruction of space points
1228 // the condition below will disappear when the geom class will be
1229 // initialised for all versions - for the moment it is only for v5 !
1230 // 7 is the SDD beam test version
1231 Int_t ver = this->IsVersion();
1232 if(ver!=5 && ver!=8 && ver!=9) return;
1234 const char *all = strstr(opt,"All");
1235 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1237 static Bool_t first=kTRUE;
1238 if (!TreeC() && first) {
1243 TTree *treeC=TreeC();
1247 AliITSClusterFinder* rec;
1249 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1250 AliITSgeom *geom = GetITSgeom();
1253 for (id=0;id<kNTYPES;id++) {
1254 if (!all && !det[id]) continue;
1255 //branch = (TBranch*)branches->UncheckedAt(id);
1256 AliITSDetType *iDetType=DetType(id);
1257 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1259 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1261 // or SetDefaultClusterFinders();
1263 TClonesArray *itsDigits = this->DigitsAddress(id);
1267 first = geom->GetStartDet(id);
1268 last = geom->GetLastDet(id);
1269 } else first=last=0;
1270 printf("first module - last module %d %d\n",first,last);
1271 for(module=first;module<=last;module++) {
1272 this->ResetDigits();
1273 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1274 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1275 Int_t ndigits = itsDigits->GetEntriesFast();
1276 if (ndigits) rec->FindRawClusters(module);
1277 gAlice->TreeR()->Fill();
1281 // try and fill only the branch
1283 //ResetRecPoints(id);
1284 } // loop over modules
1285 } // loop over detector types
1288 // Int_t nentries=(Int_t)
1289 gAlice->TreeR()->GetEntries();
1290 // Int_t ncentries=(Int_t)
1291 treeC->GetEntries();
1292 // cout << " nentries ncentries " << nentries << ncentries << endl;
1295 sprintf(hname,"TreeR%d",evNumber);
1296 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1298 gAlice->TreeR()->Reset();
1300 sprintf(hname,"TreeC%d",evNumber);
1301 treeC->Write(hname,TObject::kOverwrite);
1304 //____________________________________________________________________________
1305 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1306 Option_t *option,Option_t *opt,Text_t *filename)
1308 // keep galice.root for signal and name differently the file for
1309 // background when add! otherwise the track info for signal will be lost !
1312 // the condition below will disappear when the geom class will be
1313 // initialised for all versions - for the moment it is only for v5 !
1314 Int_t ver = this->IsVersion();
1315 if(ver!=5 && ver!=8 && ver!=9) return;
1316 //if(ver!=5) return;
1318 const char *all = strstr(opt,"All");
1319 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1322 InitModules(size,nmodules);
1323 FillModules(evNumber,bgrev,nmodules,option,filename);
1326 AliITSsimulation* sim;
1327 AliITSgeom *geom = GetITSgeom();
1329 TRandom *random=new TRandom[9];
1330 random[0].SetSeed(111);
1331 random[1].SetSeed(222);
1332 random[2].SetSeed(333);
1333 random[3].SetSeed(444);
1334 random[4].SetSeed(555);
1335 random[5].SetSeed(666);
1336 random[6].SetSeed(777);
1337 random[7].SetSeed(888);
1338 random[8].SetSeed(999);
1342 for (id=0;id<kNTYPES;id++) {
1343 if (!all && !det[id]) continue;
1344 AliITSDetType *iDetType=DetType(id);
1345 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1347 Error("HitsToFastPoints",
1348 "The simulation class was not instantiated!");
1350 // or SetDefaultSimulation();
1355 first = geom->GetStartDet(id);
1356 last = geom->GetLastDet(id);
1357 } else first=last=0;
1358 printf("first module - last module %d %d\n",first,last);
1359 for(module=first;module<=last;module++) {
1360 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1361 sim->CreateFastRecPoints(mod,module,random);
1362 gAlice->TreeR()->Fill();
1364 } // loop over modules
1365 } // loop over detector types
1370 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1373 sprintf(hname,"TreeR%d",evNumber);
1374 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1376 gAlice->TreeR()->Reset();