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.9.2.15 2000/10/04 16:56:40 nilsen
19 Needed to include stdlib.h
22 Revision 1.22 2000/10/04 19:45:52 barbera
23 Corrected by F. Carminati for v3.04
25 Revision 1.21 2000/10/02 21:28:08 fca
26 Removal of useless dependecies via forward declarations
28 Revision 1.20 2000/10/02 16:31:39 barbera
31 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
32 General code clean-up (e.g., printf -> cout)
34 Revision 1.19 2000/09/22 12:13:25 nilsen
35 Patches and updates for fixes to this and other routines.
37 Revision 1.18 2000/07/12 05:32:20 fca
38 Correcting several syntax problem with static members
40 Revision 1.17 2000/07/10 16:07:18 fca
41 Release version of ITS code
43 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
44 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
46 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
47 //fixed FillModule. Removed fi(fabs(xl)<dx....
49 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
50 This is the version of the files after the merging done in December 1999.
51 See the ReadMe110100.txt file for details
53 Revision 1.9 1999/11/14 14:33:25 fca
54 Correct problems with distructors and pointers, thanks to I.Hrivnacova
56 Revision 1.8 1999/09/29 09:24:19 fca
57 Introduction of the Copyright and cvs Log
61 ///////////////////////////////////////////////////////////////////////////////
63 // An overview of the basic philosophy of the ITS code development
64 // and analysis is show in the figure below.
67 <img src="picts/ITS/ITS_Analysis_schema.gif">
70 <font size=+2 color=red>
71 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
72 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
78 // AliITS. Inner Traking System base class.
79 // This class contains the base procedures for the Inner Tracking System
83 <img src="picts/ITS/AliITS_Class_Diagram.gif">
86 <font size=+2 color=red>
87 <p>This show the class diagram of the different elements that are part of
95 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
98 // Modified and documented by Bjorn S. Nilsen
102 // Modified and documented by A. Bologna
105 // AliITS is the general base class for the ITS. Also see AliDetector for
106 // futher information.
108 ///////////////////////////////////////////////////////////////////////////////
114 #include <TObjArray.h>
116 #include <TObjectTable.h>
125 #include "AliITSMap.h"
126 #include "AliITSDetType.h"
127 #include "AliITSClusterFinder.h"
128 #include "AliITSsimulation.h"
129 #include "AliITSresponse.h"
130 #include "AliITSsegmentationSPD.h"
131 #include "AliITSresponseSPD.h"
132 #include "AliITSsegmentationSDD.h"
133 #include "AliITSresponseSDD.h"
134 #include "AliITSsegmentationSSD.h"
135 #include "AliITSresponseSSD.h"
136 #include "AliITShit.h"
137 #include "AliITSgeom.h"
138 #include "AliITSdigit.h"
139 #include "AliITSmodule.h"
140 #include "AliITSRecPoint.h"
141 #include "AliITSRawCluster.h"
145 const Int_t AliITS::fgkNTYPES=3;
149 //_____________________________________________________________________________
150 AliITS::AliITS() : AliDetector() {
152 // Default initialiser for ITS
153 // The default constructor of the AliITS class. In addition to
154 // creating the AliITS class it zeros the variables fIshunt (a member
155 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
156 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
164 //fNDetTypes = fgkNTYPES;
183 //_____________________________________________________________________________
184 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
186 // Default initialiser for ITS
187 // The constructor of the AliITS class. In addition to creating the
188 // AliITS class, it allocates memory for the TClonesArrays fHits and
189 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
190 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
191 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
192 // macro display.C AliITS also sets the marker color to red. The variables
193 // passes with this constructor, const char *name and *title, are used by
194 // the constructor of AliDetector class. See AliDetector class for a
195 // description of these parameters and its constructor functions.
199 fHits = new TClonesArray("AliITShit", 1560);
200 gAlice->AddHitList(fHits);
202 //fNDetTypes = fgkNTYPES;
204 fNdtype = new Int_t[fgkNTYPES];
205 fDtype = new TObjArray(fgkNTYPES);
207 fNctype = new Int_t[fgkNTYPES];
208 fCtype = new TObjArray(fgkNTYPES);
224 fDetTypes = new TObjArray(fgkNTYPES);
227 for(i=0;i<fgkNTYPES;i++) {
228 (*fDetTypes)[i]=new AliITSDetType();
234 SetMarkerColor(kRed);
238 //___________________________________________________________________________
239 AliITS::AliITS(AliITS &source){
241 if(this==&source) return;
242 Error("AliITS::Copy constructor",
243 "You are not allowed to make a copy of the AliITS");
246 //____________________________________________________________________________
247 AliITS& AliITS::operator=(AliITS &source){
248 // assignment operator
249 if(this==&source) return *this;
250 Error("AliITS::operator=",
251 "You are not allowed to make a copy of the AliITS");
253 return *this; //fake return
255 //____________________________________________________________________________
256 void AliITS::ClearModules(){
257 //clear the modules TObjArray
259 if(fITSmodules) fITSmodules->Delete();
262 //_____________________________________________________________________________
265 // Default distructor for ITS
266 // The default destructor of the AliITS class. In addition to deleting
267 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
268 // fIdSens, fIdName, and fITSpoints.
275 // delete fIdName; // TObjArray of TObjStrings
276 if(fIdName!=0) delete[] fIdName; // Array of TStrings
277 if(fIdSens!=0) delete[] fIdSens;
279 this->ClearModules();
281 }// end if fITSmodules!=0
301 if (fTreeC) delete fTreeC;
303 if (fITSgeom) delete fITSgeom;
307 //___________________________________________
308 AliITSDetType* AliITS::DetType(Int_t id)
310 //return pointer to id detector type
311 return ((AliITSDetType*) (*fDetTypes)[id]);
314 //___________________________________________
315 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
317 //set the digit and cluster classes to be used for the id detector type
318 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
321 //___________________________________________
322 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
324 //set the response model for the id detector type
326 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
330 //___________________________________________
331 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
333 //set the segmentation model for the id detector type
335 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
339 //___________________________________________
340 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
342 //set the simulation model for the id detector type
344 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
347 //___________________________________________
348 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
350 //set the cluster finder model for the id detector type
352 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
356 //_____________________________________________________________________________
357 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
360 // The function to add information to the AliITShit class. See the
361 // AliITShit class for a full description. This function allocates the
362 // necessary new space for the hit information and passes the variable
363 // track, and the pointers *vol and *hits to the AliITShit constructor
366 TClonesArray &lhits = *fHits;
367 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
369 //_____________________________________________________________________________
370 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
372 // add a real digit - as coming from data
374 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
375 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
378 //_____________________________________________________________________________
379 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
382 // add a simulated digit
384 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
389 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
392 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
395 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
401 //_____________________________________________________________________________
402 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
404 // add a simulated digit to the list
406 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
410 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
413 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
416 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
422 //_____________________________________________________________________________
423 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
426 // add a cluster to the list
428 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
433 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
436 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
439 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
446 //_____________________________________________________________________________
447 void AliITS::AddRecPoint(const AliITSRecPoint &r)
450 // Add a reconstructed space point to the list
452 TClonesArray &lrecp = *fRecPoints;
453 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
457 //____________________________________________
458 void AliITS::ResetDigits()
461 // Reset number of digits and the digits array for the ITS detector
467 for (i=0;i<fgkNTYPES;i++ ) {
468 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
469 if (fNdtype) fNdtype[i]=0;
473 //____________________________________________
474 void AliITS::ResetDigits(Int_t i)
477 // Reset number of digits and the digits array for this branch
479 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
480 if (fNdtype) fNdtype[i]=0;
484 //____________________________________________
485 void AliITS::ResetClusters()
488 // Reset number of clusters and the clusters array for ITS
492 for (i=0;i<fgkNTYPES;i++ ) {
493 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
494 if (fNctype) fNctype[i]=0;
499 //____________________________________________
500 void AliITS::ResetClusters(Int_t i)
503 // Reset number of clusters and the clusters array for this branch
505 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
506 if (fNctype) fNctype[i]=0;
511 //____________________________________________
512 void AliITS::ResetRecPoints()
515 // Reset number of rec points and the rec points array
517 if (fRecPoints) fRecPoints->Clear();
522 //_____________________________________________________________________________
523 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
525 // Distance from mouse to ITS on the screen. Dummy routine
526 // A dummy routine used by the ROOT macro display.C to allow for the
527 // use of the mouse (pointing device) in the macro. In general this should
528 // never be called. If it is it returns the number 9999 for any value of
534 //_____________________________________________________________________________
537 // Initialise ITS after it has been built
538 // This routine initializes the AliITS class. It is intended to be called
539 // from the Init function in AliITSv?. Besides displaying a banner
540 // indicating that it has been called it initializes the array fIdSens
541 // and sets the default segmentation, response, digit and raw cluster classes
542 // Therefore it should be called after a call to CreateGeometry.
547 for(i=0;i<30;i++) cout << "*";cout << " ITS_INIT ";
548 for(i=0;i<30;i++) cout << "*";cout << endl;
551 // TObjArray of TObjStrings
552 // for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId((fIdName->At(i))->GetName());
554 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
556 for(i=0;i<70;i++) cout << "*";
560 //_____________________________________________________________________________
561 void AliITS::SetDefaults()
563 // sets the default segmentation, response, digit and raw cluster classes
565 cout << "AliITS::SetDefaults" << endl;
567 AliITSDetType *iDetType;
571 iDetType = DetType(0);
572 AliITSresponseSPD *resp0 = (AliITSresponseSPD*) iDetType->GetResponseModel();
573 if (!iDetType->GetSegmentationModel()) {
574 AliITSsegmentationSPD *seg0 = new AliITSsegmentationSPD(fITSgeom);
575 SetSegmentationModel(0,seg0);
578 resp0 = new AliITSresponseSPD();
579 SetResponseModel(0,resp0);
581 // set digit and raw cluster classes to be used
583 const char *kData0 = resp0->DataType();
584 if (strstr(kData0,"real")) {
585 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
586 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
589 iDetType = DetType(1);
590 AliITSresponseSDD *resp1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
591 //printf("SetDefaults: iDetType %p\n",iDetType);
592 if (!iDetType->GetSegmentationModel()) {
593 AliITSsegmentationSDD *seg1 = new AliITSsegmentationSDD(fITSgeom,resp1);
594 SetSegmentationModel(1,seg1);
596 //printf("SetDefaults: segm %p\n",iDetType->GetSegmentationModel());
598 resp1 = new AliITSresponseSDD();
599 SetResponseModel(1,resp1);
601 //printf("SetDefaults: resp %p\n",iDetType->GetResponseModel());
602 const char *kData1 = resp1->DataType();
603 const char *kopt = resp1->ZeroSuppOption();
604 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
605 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
606 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
609 iDetType = DetType(2);
610 AliITSresponseSSD *resp2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
611 if (!iDetType->GetSegmentationModel()) {
612 AliITSsegmentationSSD *seg2 = new AliITSsegmentationSSD(fITSgeom);
613 SetSegmentationModel(2,seg2);
616 resp2 = new AliITSresponseSSD();
617 SetResponseModel(2,resp2);
619 const char *kData2 = resp2->DataType();
620 if (strstr(kData2,"real")) {
621 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
622 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
625 Warning("SetDefaults","Only the three basic detector types are initialised!");
629 //_____________________________________________________________________________
630 void AliITS::SetDefaultSimulation()
635 //_____________________________________________________________________________
636 void AliITS::SetDefaultClusterFinders()
641 //_____________________________________________________________________________
643 void AliITS::MakeTreeC(Option_t *option)
645 // create a separate tree to store the clusters
647 cout << "AliITS::MakeTreeC" << endl;
649 char *optC = strstr(option,"C");
650 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
653 Int_t buffersize = 4000;
656 char *det[3] = {"SPD","SDD","SSD"};
658 // one branch for Clusters per type of detector
660 for (i=0; i<fgkNTYPES ;i++) {
661 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
662 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
663 if (fCtype && fTreeC) {
664 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
665 cout << "Making Branch " << branchname;
666 cout << " for Clusters of detector type " << i+1 << endl;
672 //_____________________________________________________________________________
673 void AliITS::GetTreeC(Int_t event)
676 cout << "AliITS::GetTreeC" << endl;
678 // get the clusters tree for this event and set the branch address
682 char *det[3] = {"SPD","SDD","SSD"};
689 sprintf(treeName,"TreeC%d",event);
690 fTreeC = (TTree*)gDirectory->Get(treeName);
696 for (i=0; i<fgkNTYPES; i++) {
697 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
698 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
700 branch = fTreeC->GetBranch(branchname);
701 if (branch) branch->SetAddress(&((*fCtype)[i]));
705 Error("AliITS::GetTreeC",
706 "cannot find Clusters Tree for event:%d\n",event);
710 //_____________________________________________________________________________
711 void AliITS::MakeBranch(Option_t* option){
713 // Creates Tree branches for the ITS.
717 Int_t buffersize = 4000;
719 sprintf(branchname,"%s",GetName());
721 AliDetector::MakeBranch(option);
724 // one branch for digits per type of detector
726 char *det[3] = {"SPD","SDD","SSD"};
732 for (i=0; i<fgkNTYPES ;i++) {
733 AliITSDetType *iDetType=DetType(i);
734 iDetType->GetClassNames(digclass,clclass);
735 //printf("i, digclass, recclass %d %s %s\n",i,digclass,clclass);
737 (*fDtype)[i] = new TClonesArray(digclass,10000);
739 (*fCtype)[i] = new TClonesArray(clclass,10000);
743 for (i=0; i<fgkNTYPES ;i++) {
744 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
745 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
747 if (fDtype && gAlice->TreeD()) {
748 gAlice->TreeD()->Branch(branchname,&((*fDtype)[i]), buffersize);
749 cout << "Making Branch " << branchname;
750 cout << " for digits of type "<< i+1 << endl;
754 // only one branch for rec points for all detector types
755 sprintf(branchname,"%sRecPoints",GetName());
757 fRecPoints=new TClonesArray("AliITSRecPoint",10000);
759 if (fRecPoints && gAlice->TreeR()) {
760 gAlice->TreeR()->Branch(branchname,&fRecPoints, buffersize);
761 cout << "Making Branch " << branchname;
762 cout << " for reconstructed space points" << endl;
768 //___________________________________________
769 void AliITS::SetTreeAddress()
772 // Set branch address for the Trees.
775 AliDetector::SetTreeAddress();
777 char *det[3] = {"SPD","SDD","SSD"};
780 TTree *treeD = gAlice->TreeD();
781 TTree *treeR = gAlice->TreeR();
785 for (i=0; i<fgkNTYPES; i++) {
786 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
787 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
789 branch = treeD->GetBranch(branchname);
790 if (branch) branch->SetAddress(&((*fDtype)[i]));
797 sprintf(branchname,"%sRecPoints",GetName());
799 branch = treeR->GetBranch(branchname);
800 if (branch) branch->SetAddress(&fRecPoints);
807 //____________________________________________________________________________
808 void AliITS::InitModules(Int_t size,Int_t &nmodules){
810 //initialize the modules array
813 fITSmodules->Delete();
817 Int_t nl,indexMAX,index;
819 if(size<=0){ // default to using data stored in AliITSgeom
821 Error("AliITS::InitModules",
822 "in AliITS::InitModule fITSgeom not defined\n");
824 } // end if fITSgeom==0
825 nl = fITSgeom->GetNlayers();
826 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
827 fITSgeom->GetNdetectors(nl))+1;
829 fITSmodules = new TObjArray(indexMAX);
830 for(index=0;index<indexMAX;index++){
831 fITSmodules->AddAt( new AliITSmodule(index),index);
834 fITSmodules = new TObjArray(size);
835 for(index=0;index<size;index++) {
836 fITSmodules->AddAt( new AliITSmodule(index),index);
843 //____________________________________________________________________________
844 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
846 // fill the modules with the sorted by module hits; add hits from background
850 static TTree *trH1; //Tree with background hits
851 static TClonesArray *fHits2; //List of hits for one track only
853 static Bool_t first=kTRUE;
855 char *addBgr = strstr(option,"Add");
860 cout<<"filename "<<filename<<endl;
861 file=new TFile(filename);
862 cout<<"I have opened "<<filename<<" file "<<endl;
863 fHits2 = new TClonesArray("AliITShit",1000 );
868 // Get Hits Tree header from file
869 if(fHits2) fHits2->Clear();
870 if(trH1) delete trH1;
874 sprintf(treeName,"TreeH%d",bgrev);
875 trH1 = (TTree*)gDirectory->Get(treeName);
876 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
879 Error("AliITS::FillModules",
880 "cannot find Hits Tree for event:%d\n",bgrev);
882 // Set branch addresses
885 sprintf(branchname,"%s",GetName());
886 if (trH1 && fHits2) {
887 branch = trH1->GetBranch(branchname);
888 if (branch) branch->SetAddress(&fHits2);
892 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
893 //printf("background - ntracks1 - %d\n",ntracks1);
896 Int_t npart = gAlice->GetEvent(evnt);
898 TClonesArray *itsHits = this->Hits();
899 Int_t lay,lad,det,index;
903 TTree *iTH = gAlice->TreeH();
904 Int_t ntracks =(Int_t) iTH->GetEntries();
907 for(t=0; t<ntracks; t++){
910 Int_t nhits = itsHits->GetEntriesFast();
911 //printf("nhits %d\n",nhits);
912 if (!nhits) continue;
913 for(h=0; h<nhits; h++){
914 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
915 itsHit->GetDetectorID(lay,lad,det);
916 // temporarily index=det-1 !!!
917 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
920 mod = this->GetModule(index);
921 mod->AddHit(itsHit,t,h);
922 } // end loop over hits
923 } // end loop over tracks
925 // open the file with background
929 ntracks =(Int_t)trH1->GetEntries();
930 //printf("background - ntracks1 %d\n",ntracks);
931 //printf("background - Start loop over tracks \n");
934 for (track=0; track<ntracks; track++) {
936 if (fHits2) fHits2->Clear();
937 trH1->GetEvent(track);
939 for(i=0;i<fHits2->GetEntriesFast();++i) {
941 itsHit=(AliITShit*) (*fHits2)[i];
942 itsHit->GetDetectorID(lay,lad,det);
943 // temporarily index=det-1 !!!
944 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
947 mod = this->GetModule(index);
948 mod->AddHit(itsHit,track,i);
949 } // end loop over hits
950 } // end loop over tracks
952 TTree *fAli=gAlice->TreeK();
955 if (fAli) fileAli =fAli->GetCurrentFile();
960 //gObjectTable->Print();
965 //____________________________________________________________________________
966 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
968 // keep galice.root for signal and name differently the file for
969 // background when add! otherwise the track info for signal will be lost !
971 // the condition below will disappear when the geom class will be
972 // initialised for all versions - for the moment it is only for v5 !
973 // 7 is the SDD beam test version
974 Int_t ver = this->IsVersion();
975 if(ver!=5 && ver!=7) return;
977 char *all = strstr(opt,"All");
978 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
981 InitModules(size,nmodules);
982 FillModules(evNumber,bgrev,nmodules,option,filename);
985 AliITSsimulation* sim;
986 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
987 AliITSgeom *geom = GetITSgeom();
991 for (id=0;id<fgkNTYPES;id++) {
992 if (!all && !det[id]) continue;
993 //branch = (TBranch*)branches->UncheckedAt(id);
994 AliITSDetType *iDetType=DetType(id);
995 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
997 Error("HitsToDigits","The simulation class was not instantiated!");
999 // or SetDefaultSimulation();
1002 first = geom->GetStartDet(id);
1003 last = geom->GetLastDet(id);
1004 } else first=last=0;
1005 cout << "det type " << id << " first, last "<< first << last << endl;
1006 for(module=first;module<=last;module++) {
1007 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1008 sim->DigitiseModule(mod,module,evNumber);
1009 // fills all branches - wasted disk space
1010 gAlice->TreeD()->Fill();
1012 // try and fill only the branch
1015 } // loop over modules
1016 } // loop over detector types
1020 Int_t nentries=(Int_t)gAlice->TreeD()->GetEntries();
1021 cout << "nentries in TreeD" << nentries << endl;
1024 sprintf(hname,"TreeD%d",evNumber);
1025 gAlice->TreeD()->Write(hname);
1027 gAlice->TreeD()->Reset();
1032 //____________________________________________________________________________
1033 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1035 // cluster finding and reconstruction of space points
1037 // the condition below will disappear when the geom class will be
1038 // initialised for all versions - for the moment it is only for v5 !
1039 // 7 is the SDD beam test version
1040 Int_t ver = this->IsVersion();
1041 if(ver!=5 && ver!=7) return;
1043 char *all = strstr(opt,"All");
1044 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1046 static Bool_t first=kTRUE;
1055 AliITSClusterFinder* rec;
1057 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1058 AliITSgeom *geom = GetITSgeom();
1061 for (id=0;id<fgkNTYPES;id++) {
1062 if (!all && !det[id]) continue;
1063 //branch = (TBranch*)branches->UncheckedAt(id);
1064 AliITSDetType *iDetType=DetType(id);
1065 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1067 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1069 // or SetDefaultClusterFinders();
1071 TClonesArray *itsDigits = this->DigitsAddress(id);
1075 first = geom->GetStartDet(id);
1076 last = geom->GetLastDet(id);
1077 } else first=last=0;
1078 //printf("first last %d %d\n",first,last);
1079 for(module=first;module<=last;module++) {
1080 this->ResetDigits();
1081 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1082 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1083 Int_t ndigits = itsDigits->GetEntriesFast();
1084 if (ndigits) rec->FindRawClusters();
1085 gAlice->TreeR()->Fill();
1089 // try and fill only the branch
1091 //ResetRecPoints(id);
1092 } // loop over modules
1093 } // loop over detector types
1096 Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1097 Int_t ncentries=(Int_t)iTC->GetEntries();
1098 cout << " nentries ncentries " << nentries << ncentries << endl;
1101 sprintf(hname,"TreeR%d",evNumber);
1102 gAlice->TreeR()->Write(hname);
1104 gAlice->TreeR()->Reset();
1106 sprintf(hname,"TreeC%d",evNumber);
1112 //____________________________________________________________________________
1113 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1114 Option_t *option,Option_t *opt,Text_t *filename)
1116 // keep galice.root for signal and name differently the file for
1117 // background when add! otherwise the track info for signal will be lost !
1120 // the condition below will disappear when the geom class will be
1121 // initialised for all versions - for the moment it is only for v5 !
1122 Int_t ver = this->IsVersion();
1125 char *all = strstr(opt,"All");
1126 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1129 InitModules(size,nmodules);
1130 FillModules(evNumber,bgrev,nmodules,option,filename);
1133 AliITSsimulation* sim;
1134 AliITSgeom *geom = GetITSgeom();
1136 TRandom *random=new TRandom[9];
1137 random[0].SetSeed(111);
1138 random[1].SetSeed(222);
1139 random[2].SetSeed(333);
1140 random[3].SetSeed(444);
1141 random[4].SetSeed(555);
1142 random[5].SetSeed(666);
1143 random[6].SetSeed(777);
1144 random[7].SetSeed(888);
1145 random[8].SetSeed(999);
1149 for (id=0;id<fgkNTYPES;id++) {
1150 if (!all && !det[id]) continue;
1151 AliITSDetType *iDetType=DetType(id);
1152 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1154 Error("HitsToFastPoints","The simulation class was not instantiated!");
1156 // or SetDefaultSimulation();
1158 Int_t first = geom->GetStartDet(id);
1159 Int_t last = geom->GetLastDet(id);
1160 for(module=first;module<=last;module++) {
1161 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1162 sim->CreateFastRecPoints(mod,module,random);
1163 gAlice->TreeR()->Fill();
1165 } // loop over modules
1166 } // loop over detector types
1171 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1174 sprintf(hname,"TreeR%d",evNumber);
1175 gAlice->TreeR()->Write(hname);
1177 gAlice->TreeR()->Reset();
1184 //____________________________________________________________________________
1185 void AliITS::Streamer(TBuffer &R__b){
1186 // Stream an object of class AliITS.
1190 if (R__b.IsReading()) {
1191 Version_t R__v = R__b.ReadVersion();
1193 AliDetector::Streamer(R__b);
1195 R__b.ReadArray(fIdSens);
1196 if(fIdName!=0) delete[] fIdName; // Array of TStrings
1197 fIdName = new TString[fIdN];
1198 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
1200 R__b >> fITSmodules;
1202 R__b >> fMajorVersion;
1203 R__b >> fMinorVersion;
1207 fNdtype = new Int_t[fgkNTYPES];
1208 R__b.ReadFastArray(fNdtype,fgkNTYPES);
1211 fNctype = new Int_t[fgkNTYPES];
1212 R__b.ReadFastArray(fNctype,fgkNTYPES);
1214 R__b >> fNRecPoints;
1218 R__b.WriteVersion(AliITS::IsA());
1219 AliDetector::Streamer(R__b);
1221 R__b.WriteArray(fIdSens,fIdN);
1222 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
1224 R__b << fITSmodules;
1226 R__b << fMajorVersion;
1227 R__b << fMinorVersion;
1230 R__b.WriteFastArray(fNdtype,fgkNTYPES);
1232 R__b.WriteFastArray(fNctype,fgkNTYPES);
1234 R__b << fNRecPoints;