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.24 2000/10/09 22:18:12 barbera
19 Bug fixes from MAriana to le AliITStest.C run correctly
21 Revision 1.23 2000/10/05 20:47:42 nilsen
22 fixed dependencies of include files. Tryed but failed to get a root automaticly
23 generates streamer function to work. Modified SetDefaults.
25 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
26 Needed to include stdlib.h
29 Revision 1.22 2000/10/04 19:45:52 barbera
30 Corrected by F. Carminati for v3.04
32 Revision 1.21 2000/10/02 21:28:08 fca
33 Removal of useless dependecies via forward declarations
35 Revision 1.20 2000/10/02 16:31:39 barbera
38 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
39 General code clean-up (e.g., printf -> cout)
41 Revision 1.19 2000/09/22 12:13:25 nilsen
42 Patches and updates for fixes to this and other routines.
44 Revision 1.18 2000/07/12 05:32:20 fca
45 Correcting several syntax problem with static members
47 Revision 1.17 2000/07/10 16:07:18 fca
48 Release version of ITS code
50 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
51 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
53 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
54 //fixed FillModule. Removed fi(fabs(xl)<dx....
56 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
57 This is the version of the files after the merging done in December 1999.
58 See the ReadMe110100.txt file for details
60 Revision 1.9 1999/11/14 14:33:25 fca
61 Correct problems with distructors and pointers, thanks to I.Hrivnacova
63 Revision 1.8 1999/09/29 09:24:19 fca
64 Introduction of the Copyright and cvs Log
68 ///////////////////////////////////////////////////////////////////////////////
70 // An overview of the basic philosophy of the ITS code development
71 // and analysis is show in the figure below.
74 <img src="picts/ITS/ITS_Analysis_schema.gif">
77 <font size=+2 color=red>
78 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
79 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
85 // AliITS. Inner Traking System base class.
86 // This class contains the base procedures for the Inner Tracking System
90 <img src="picts/ITS/AliITS_Class_Diagram.gif">
93 <font size=+2 color=red>
94 <p>This show the class diagram of the different elements that are part of
102 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
105 // Modified and documented by Bjorn S. Nilsen
109 // Modified and documented by A. Bologna
112 // AliITS is the general base class for the ITS. Also see AliDetector for
113 // futher information.
115 ///////////////////////////////////////////////////////////////////////////////
121 #include <TObjArray.h>
123 #include <TObjectTable.h>
132 #include "AliITSMap.h"
133 #include "AliITSDetType.h"
134 #include "AliITSClusterFinder.h"
135 #include "AliITSsimulation.h"
136 #include "AliITSresponse.h"
137 #include "AliITSsegmentationSPD.h"
138 #include "AliITSresponseSPD.h"
139 #include "AliITSresponseSPDbari.h"
140 #include "AliITSsegmentationSDD.h"
141 #include "AliITSresponseSDD.h"
142 #include "AliITSsegmentationSSD.h"
143 #include "AliITSresponseSSD.h"
144 #include "AliITShit.h"
145 #include "AliITSgeom.h"
146 #include "AliITSdigit.h"
147 #include "AliITSmodule.h"
148 #include "AliITSRecPoint.h"
149 #include "AliITSRawCluster.h"
153 const Int_t AliITS::fgkNTYPES=3;
157 //_____________________________________________________________________________
158 AliITS::AliITS() : AliDetector() {
160 // Default initialiser for ITS
161 // The default constructor of the AliITS class. In addition to
162 // creating the AliITS class it zeros the variables fIshunt (a member
163 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
164 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
172 //fNDetTypes = fgkNTYPES;
191 //_____________________________________________________________________________
192 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
194 // Default initialiser for ITS
195 // The constructor of the AliITS class. In addition to creating the
196 // AliITS class, it allocates memory for the TClonesArrays fHits and
197 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
198 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
199 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
200 // macro display.C AliITS also sets the marker color to red. The variables
201 // passes with this constructor, const char *name and *title, are used by
202 // the constructor of AliDetector class. See AliDetector class for a
203 // description of these parameters and its constructor functions.
207 fHits = new TClonesArray("AliITShit", 1560);
208 gAlice->AddHitList(fHits);
210 //fNDetTypes = fgkNTYPES;
212 fNdtype = new Int_t[fgkNTYPES];
213 fDtype = new TObjArray(fgkNTYPES);
215 fNctype = new Int_t[fgkNTYPES];
216 fCtype = new TObjArray(fgkNTYPES);
232 fDetTypes = new TObjArray(fgkNTYPES);
235 for(i=0;i<fgkNTYPES;i++) {
236 (*fDetTypes)[i]=new AliITSDetType();
242 SetMarkerColor(kRed);
246 //___________________________________________________________________________
247 AliITS::AliITS(AliITS &source){
249 if(this==&source) return;
250 Error("AliITS::Copy constructor",
251 "You are not allowed to make a copy of the AliITS");
254 //____________________________________________________________________________
255 AliITS& AliITS::operator=(AliITS &source){
256 // assignment operator
257 if(this==&source) return *this;
258 Error("AliITS::operator=",
259 "You are not allowed to make a copy of the AliITS");
261 return *this; //fake return
263 //____________________________________________________________________________
264 void AliITS::ClearModules(){
265 //clear the modules TObjArray
267 if(fITSmodules) fITSmodules->Delete();
270 //_____________________________________________________________________________
273 // Default distructor for ITS
274 // The default destructor of the AliITS class. In addition to deleting
275 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
276 // fIdSens, fIdName, and fITSpoints.
283 // delete fIdName; // TObjArray of TObjStrings
284 if(fIdName!=0) delete[] fIdName; // Array of TStrings
285 if(fIdSens!=0) delete[] fIdSens;
287 this->ClearModules();
289 }// end if fITSmodules!=0
309 if (fTreeC) delete fTreeC;
311 if (fITSgeom) delete fITSgeom;
315 //___________________________________________
316 AliITSDetType* AliITS::DetType(Int_t id)
318 //return pointer to id detector type
319 return ((AliITSDetType*) (*fDetTypes)[id]);
322 //___________________________________________
323 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster)
325 //set the digit and cluster classes to be used for the id detector type
326 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
329 //___________________________________________
330 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
332 //set the response model for the id detector type
334 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
338 //___________________________________________
339 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
341 //set the segmentation model for the id detector type
343 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
347 //___________________________________________
348 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
350 //set the simulation model for the id detector type
352 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
355 //___________________________________________
356 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
358 //set the cluster finder model for the id detector type
360 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
364 //_____________________________________________________________________________
365 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
368 // The function to add information to the AliITShit class. See the
369 // AliITShit class for a full description. This function allocates the
370 // necessary new space for the hit information and passes the variable
371 // track, and the pointers *vol and *hits to the AliITShit constructor
374 TClonesArray &lhits = *fHits;
375 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
377 //_____________________________________________________________________________
378 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
380 // add a real digit - as coming from data
382 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
383 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
386 //_____________________________________________________________________________
387 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d)
390 // add a simulated digit
392 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
397 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
400 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
403 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
409 //_____________________________________________________________________________
410 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Int_t *hits,Float_t *charges){
412 // add a simulated digit to the list
414 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
418 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
421 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,hits,charges);
424 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
430 //_____________________________________________________________________________
431 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
434 // add a cluster to the list
436 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
441 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
444 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
447 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
454 //_____________________________________________________________________________
455 void AliITS::AddRecPoint(const AliITSRecPoint &r)
458 // Add a reconstructed space point to the list
460 TClonesArray &lrecp = *fRecPoints;
461 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
465 //____________________________________________
466 void AliITS::ResetDigits()
469 // Reset number of digits and the digits array for the ITS detector
475 for (i=0;i<fgkNTYPES;i++ ) {
476 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
477 if (fNdtype) fNdtype[i]=0;
481 //____________________________________________
482 void AliITS::ResetDigits(Int_t i)
485 // Reset number of digits and the digits array for this branch
487 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
488 if (fNdtype) fNdtype[i]=0;
492 //____________________________________________
493 void AliITS::ResetClusters()
496 // Reset number of clusters and the clusters array for ITS
500 for (i=0;i<fgkNTYPES;i++ ) {
501 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
502 if (fNctype) fNctype[i]=0;
507 //____________________________________________
508 void AliITS::ResetClusters(Int_t i)
511 // Reset number of clusters and the clusters array for this branch
513 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
514 if (fNctype) fNctype[i]=0;
519 //____________________________________________
520 void AliITS::ResetRecPoints()
523 // Reset number of rec points and the rec points array
525 if (fRecPoints) fRecPoints->Clear();
530 //_____________________________________________________________________________
531 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
533 // Distance from mouse to ITS on the screen. Dummy routine
534 // A dummy routine used by the ROOT macro display.C to allow for the
535 // use of the mouse (pointing device) in the macro. In general this should
536 // never be called. If it is it returns the number 9999 for any value of
542 //_____________________________________________________________________________
545 // Initialise ITS after it has been built
546 // This routine initializes the AliITS class. It is intended to be called
547 // from the Init function in AliITSv?. Besides displaying a banner
548 // indicating that it has been called it initializes the array fIdSens
549 // and sets the default segmentation, response, digit and raw cluster classes
550 // Therefore it should be called after a call to CreateGeometry.
555 for(i=0;i<30;i++) cout << "*";cout << " ITS_INIT ";
556 for(i=0;i<30;i++) cout << "*";cout << endl;
559 // TObjArray of TObjStrings
560 // for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId((fIdName->At(i))->GetName());
562 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
564 for(i=0;i<70;i++) cout << "*";
568 //_____________________________________________________________________________
569 void AliITS::SetDefaults()
571 // sets the default segmentation, response, digit and raw cluster classes
573 printf("SetDefaults\n");
575 AliITSDetType *iDetType;
581 if (!iDetType->GetSegmentationModel()) {
582 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
583 SetSegmentationModel(0,seg0);
585 if (!iDetType->GetResponseModel()) {
586 SetResponseModel(0,new AliITSresponseSPD());
588 // set digit and raw cluster classes to be used
590 const char *kData0=(iDetType->GetResponseModel())->DataType();
591 if (strstr(kData0,"real")) {
592 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
593 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
597 if (!iDetType->GetResponseModel()) {
598 SetResponseModel(1,new AliITSresponseSDD());
600 AliITSresponse *resp1=iDetType->GetResponseModel();
601 if (!iDetType->GetSegmentationModel()) {
602 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
603 SetSegmentationModel(1,seg1);
605 const char *kData1=(iDetType->GetResponseModel())->DataType();
606 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
607 if ((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ) {
608 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
609 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
613 if (!iDetType->GetSegmentationModel()) {
614 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
615 SetSegmentationModel(2,seg2);
617 if (!iDetType->GetResponseModel()) {
618 SetResponseModel(2,new AliITSresponseSSD());
620 const char *kData2=(iDetType->GetResponseModel())->DataType();
621 if (strstr(kData2,"real")) {
622 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
623 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
626 Warning("SetDefaults","Only the three basic detector types are initialised!");
633 //_____________________________________________________________________________
634 void AliITS::SetDefaultSimulation()
639 //_____________________________________________________________________________
640 void AliITS::SetDefaultClusterFinders()
645 //_____________________________________________________________________________
647 void AliITS::MakeTreeC(Option_t *option)
649 // create a separate tree to store the clusters
651 cout << "AliITS::MakeTreeC" << endl;
653 char *optC = strstr(option,"C");
654 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
657 Int_t buffersize = 4000;
660 char *det[3] = {"SPD","SDD","SSD"};
662 // one branch for Clusters per type of detector
664 for (i=0; i<fgkNTYPES ;i++) {
665 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
666 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
667 if (fCtype && fTreeC) {
668 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
669 cout << "Making Branch " << branchname;
670 cout << " for Clusters of detector type " << i+1 << endl;
676 //_____________________________________________________________________________
677 void AliITS::GetTreeC(Int_t event)
680 cout << "AliITS::GetTreeC" << endl;
682 // get the clusters tree for this event and set the branch address
686 char *det[3] = {"SPD","SDD","SSD"};
693 sprintf(treeName,"TreeC%d",event);
694 fTreeC = (TTree*)gDirectory->Get(treeName);
700 for (i=0; i<fgkNTYPES; i++) {
701 if (fgkNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
702 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
704 branch = fTreeC->GetBranch(branchname);
705 if (branch) branch->SetAddress(&((*fCtype)[i]));
709 Error("AliITS::GetTreeC",
710 "cannot find Clusters Tree for event:%d\n",event);
714 //_____________________________________________________________________________
715 void AliITS::MakeBranch(Option_t* option){
717 // Creates Tree branches for the ITS.
721 Int_t buffersize = 4000;
723 sprintf(branchname,"%s",GetName());
725 AliDetector::MakeBranch(option);
728 // one branch for digits per type of detector
730 char *det[3] = {"SPD","SDD","SSD"};
736 for (i=0; i<fgkNTYPES ;i++) {
737 AliITSDetType *iDetType=DetType(i);
738 iDetType->GetClassNames(digclass,clclass);
739 //printf("i, digclass, recclass %d %s %s\n",i,digclass,clclass);
741 (*fDtype)[i] = new TClonesArray(digclass,10000);
743 (*fCtype)[i] = new TClonesArray(clclass,10000);
747 for (i=0; i<fgkNTYPES ;i++) {
748 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
749 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
751 if (fDtype && gAlice->TreeD()) {
752 gAlice->TreeD()->Branch(branchname,&((*fDtype)[i]), buffersize);
753 cout << "Making Branch " << branchname;
754 cout << " for digits of type "<< i+1 << endl;
758 // only one branch for rec points for all detector types
759 sprintf(branchname,"%sRecPoints",GetName());
761 fRecPoints=new TClonesArray("AliITSRecPoint",10000);
763 if (fRecPoints && gAlice->TreeR()) {
764 gAlice->TreeR()->Branch(branchname,&fRecPoints, buffersize);
765 cout << "Making Branch " << branchname;
766 cout << " for reconstructed space points" << endl;
772 //___________________________________________
773 void AliITS::SetTreeAddress()
776 // Set branch address for the Trees.
779 AliDetector::SetTreeAddress();
781 char *det[3] = {"SPD","SDD","SSD"};
784 TTree *treeD = gAlice->TreeD();
785 TTree *treeR = gAlice->TreeR();
789 for (i=0; i<fgkNTYPES; i++) {
790 if (fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
791 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
793 branch = treeD->GetBranch(branchname);
794 if (branch) branch->SetAddress(&((*fDtype)[i]));
801 sprintf(branchname,"%sRecPoints",GetName());
803 branch = treeR->GetBranch(branchname);
804 if (branch) branch->SetAddress(&fRecPoints);
811 //____________________________________________________________________________
812 void AliITS::InitModules(Int_t size,Int_t &nmodules){
814 //initialize the modules array
817 fITSmodules->Delete();
821 Int_t nl,indexMAX,index;
823 if(size<=0){ // default to using data stored in AliITSgeom
825 Error("AliITS::InitModules",
826 "in AliITS::InitModule fITSgeom not defined\n");
828 } // end if fITSgeom==0
829 nl = fITSgeom->GetNlayers();
830 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
831 fITSgeom->GetNdetectors(nl))+1;
833 fITSmodules = new TObjArray(indexMAX);
834 for(index=0;index<indexMAX;index++){
835 fITSmodules->AddAt( new AliITSmodule(index),index);
838 fITSmodules = new TObjArray(size);
839 for(index=0;index<size;index++) {
840 fITSmodules->AddAt( new AliITSmodule(index),index);
847 //____________________________________________________________________________
848 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,Option_t *option,Text_t *filename){
850 // fill the modules with the sorted by module hits; add hits from background
854 static TTree *trH1; //Tree with background hits
855 static TClonesArray *fHits2; //List of hits for one track only
857 static Bool_t first=kTRUE;
859 char *addBgr = strstr(option,"Add");
864 cout<<"filename "<<filename<<endl;
865 file=new TFile(filename);
866 cout<<"I have opened "<<filename<<" file "<<endl;
867 fHits2 = new TClonesArray("AliITShit",1000 );
872 // Get Hits Tree header from file
873 if(fHits2) fHits2->Clear();
874 if(trH1) delete trH1;
878 sprintf(treeName,"TreeH%d",bgrev);
879 trH1 = (TTree*)gDirectory->Get(treeName);
880 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
883 Error("AliITS::FillModules",
884 "cannot find Hits Tree for event:%d\n",bgrev);
886 // Set branch addresses
889 sprintf(branchname,"%s",GetName());
890 if (trH1 && fHits2) {
891 branch = trH1->GetBranch(branchname);
892 if (branch) branch->SetAddress(&fHits2);
896 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
897 //printf("background - ntracks1 - %d\n",ntracks1);
900 Int_t npart = gAlice->GetEvent(evnt);
902 TClonesArray *itsHits = this->Hits();
903 Int_t lay,lad,det,index;
907 TTree *iTH = gAlice->TreeH();
908 Int_t ntracks =(Int_t) iTH->GetEntries();
911 for(t=0; t<ntracks; t++){
914 Int_t nhits = itsHits->GetEntriesFast();
915 //printf("nhits %d\n",nhits);
916 if (!nhits) continue;
917 for(h=0; h<nhits; h++){
918 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
919 itsHit->GetDetectorID(lay,lad,det);
920 // temporarily index=det-1 !!!
921 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
924 mod = this->GetModule(index);
925 mod->AddHit(itsHit,t,h);
926 } // end loop over hits
927 } // end loop over tracks
929 // open the file with background
933 ntracks =(Int_t)trH1->GetEntries();
934 //printf("background - ntracks1 %d\n",ntracks);
935 //printf("background - Start loop over tracks \n");
938 for (track=0; track<ntracks; track++) {
940 if (fHits2) fHits2->Clear();
941 trH1->GetEvent(track);
943 for(i=0;i<fHits2->GetEntriesFast();++i) {
945 itsHit=(AliITShit*) (*fHits2)[i];
946 itsHit->GetDetectorID(lay,lad,det);
947 // temporarily index=det-1 !!!
948 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
951 mod = this->GetModule(index);
952 mod->AddHit(itsHit,track,i);
953 } // end loop over hits
954 } // end loop over tracks
956 TTree *fAli=gAlice->TreeK();
959 if (fAli) fileAli =fAli->GetCurrentFile();
964 //gObjectTable->Print();
969 //____________________________________________________________________________
970 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *option, Option_t *opt,Text_t *filename)
972 // keep galice.root for signal and name differently the file for
973 // background when add! otherwise the track info for signal will be lost !
975 // the condition below will disappear when the geom class will be
976 // initialised for all versions - for the moment it is only for v5 !
977 // 7 is the SDD beam test version
978 Int_t ver = this->IsVersion();
979 if(ver!=5 && ver!=7) return;
981 char *all = strstr(opt,"All");
982 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
985 InitModules(size,nmodules);
986 FillModules(evNumber,bgrev,nmodules,option,filename);
989 AliITSsimulation* sim;
990 //TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
991 AliITSgeom *geom = GetITSgeom();
995 for (id=0;id<fgkNTYPES;id++) {
996 if (!all && !det[id]) continue;
997 //branch = (TBranch*)branches->UncheckedAt(id);
998 AliITSDetType *iDetType=DetType(id);
999 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1001 Error("HitsToDigits","The simulation class was not instantiated!");
1003 // or SetDefaultSimulation();
1006 first = geom->GetStartDet(id);
1007 last = geom->GetLastDet(id);
1008 } else first=last=0;
1009 cout << "det type " << id << " first, last "<< first << last << endl;
1010 for(module=first;module<=last;module++) {
1011 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1012 sim->DigitiseModule(mod,module,evNumber);
1013 // fills all branches - wasted disk space
1014 gAlice->TreeD()->Fill();
1016 // try and fill only the branch
1019 } // loop over modules
1020 } // loop over detector types
1024 Int_t nentries=(Int_t)gAlice->TreeD()->GetEntries();
1025 cout << "nentries in TreeD" << nentries << endl;
1028 sprintf(hname,"TreeD%d",evNumber);
1029 gAlice->TreeD()->Write(hname);
1031 gAlice->TreeD()->Reset();
1036 //____________________________________________________________________________
1037 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1039 // cluster finding and reconstruction of space points
1041 // the condition below will disappear when the geom class will be
1042 // initialised for all versions - for the moment it is only for v5 !
1043 // 7 is the SDD beam test version
1044 Int_t ver = this->IsVersion();
1045 if(ver!=5 && ver!=7) return;
1047 char *all = strstr(opt,"All");
1048 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1050 static Bool_t first=kTRUE;
1059 AliITSClusterFinder* rec;
1061 //TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1062 AliITSgeom *geom = GetITSgeom();
1065 for (id=0;id<fgkNTYPES;id++) {
1066 if (!all && !det[id]) continue;
1067 //branch = (TBranch*)branches->UncheckedAt(id);
1068 AliITSDetType *iDetType=DetType(id);
1069 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1071 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1073 // or SetDefaultClusterFinders();
1075 TClonesArray *itsDigits = this->DigitsAddress(id);
1079 first = geom->GetStartDet(id);
1080 last = geom->GetLastDet(id);
1081 } else first=last=0;
1082 //printf("first last %d %d\n",first,last);
1083 for(module=first;module<=last;module++) {
1084 this->ResetDigits();
1085 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1086 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1087 Int_t ndigits = itsDigits->GetEntriesFast();
1088 if (ndigits) rec->FindRawClusters();
1089 gAlice->TreeR()->Fill();
1093 // try and fill only the branch
1095 //ResetRecPoints(id);
1096 } // loop over modules
1097 } // loop over detector types
1100 Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1101 Int_t ncentries=(Int_t)iTC->GetEntries();
1102 cout << " nentries ncentries " << nentries << ncentries << endl;
1105 sprintf(hname,"TreeR%d",evNumber);
1106 gAlice->TreeR()->Write(hname);
1108 gAlice->TreeR()->Reset();
1110 sprintf(hname,"TreeC%d",evNumber);
1116 //____________________________________________________________________________
1117 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1118 Option_t *option,Option_t *opt,Text_t *filename)
1120 // keep galice.root for signal and name differently the file for
1121 // background when add! otherwise the track info for signal will be lost !
1124 // the condition below will disappear when the geom class will be
1125 // initialised for all versions - for the moment it is only for v5 !
1126 Int_t ver = this->IsVersion();
1129 char *all = strstr(opt,"All");
1130 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1133 InitModules(size,nmodules);
1134 FillModules(evNumber,bgrev,nmodules,option,filename);
1137 AliITSsimulation* sim;
1138 AliITSgeom *geom = GetITSgeom();
1140 TRandom *random=new TRandom[9];
1141 random[0].SetSeed(111);
1142 random[1].SetSeed(222);
1143 random[2].SetSeed(333);
1144 random[3].SetSeed(444);
1145 random[4].SetSeed(555);
1146 random[5].SetSeed(666);
1147 random[6].SetSeed(777);
1148 random[7].SetSeed(888);
1149 random[8].SetSeed(999);
1153 for (id=0;id<fgkNTYPES;id++) {
1154 if (!all && !det[id]) continue;
1155 AliITSDetType *iDetType=DetType(id);
1156 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1158 Error("HitsToFastPoints","The simulation class was not instantiated!");
1160 // or SetDefaultSimulation();
1162 Int_t first = geom->GetStartDet(id);
1163 Int_t last = geom->GetLastDet(id);
1164 for(module=first;module<=last;module++) {
1165 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1166 sim->CreateFastRecPoints(mod,module,random);
1167 gAlice->TreeR()->Fill();
1169 } // loop over modules
1170 } // loop over detector types
1175 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1178 sprintf(hname,"TreeR%d",evNumber);
1179 gAlice->TreeR()->Write(hname);
1181 gAlice->TreeR()->Reset();
1188 //____________________________________________________________________________
1189 void AliITS::Streamer(TBuffer &R__b){
1190 // Stream an object of class AliITS.
1194 if (R__b.IsReading()) {
1195 Version_t R__v = R__b.ReadVersion();
1197 AliDetector::Streamer(R__b);
1199 R__b.ReadArray(fIdSens);
1200 if(fIdName!=0) delete[] fIdName; // Array of TStrings
1201 fIdName = new TString[fIdN];
1202 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
1204 R__b >> fITSmodules;
1206 R__b >> fMajorVersion;
1207 R__b >> fMinorVersion;
1211 fNdtype = new Int_t[fgkNTYPES];
1212 R__b.ReadFastArray(fNdtype,fgkNTYPES);
1215 fNctype = new Int_t[fgkNTYPES];
1216 R__b.ReadFastArray(fNctype,fgkNTYPES);
1218 R__b >> fNRecPoints;
1222 R__b.WriteVersion(AliITS::IsA());
1223 AliDetector::Streamer(R__b);
1225 R__b.WriteArray(fIdSens,fIdN);
1226 for(i=0;i<fIdN;i++) fIdName[i].Streamer(R__b);
1228 R__b << fITSmodules;
1230 R__b << fMajorVersion;
1231 R__b << fMinorVersion;
1234 R__b.WriteFastArray(fNdtype,fgkNTYPES);
1236 R__b.WriteFastArray(fNctype,fgkNTYPES);
1238 R__b << fNRecPoints;