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.14 2000/06/15 09:27:52 barbera
19 Problems with the HP compiler fixed
21 Revision 1.13 2000/06/13 15:32:44 nilsen
22 fix compilation error on HP and DEC unix.
24 Revision 1.12 2000/06/12 23:43:16 nilsen
25 New ITS code replacing the old structure and simulations code.
27 Revision 1.9.2.8 2000/06/12 18:05:59 barbera
28 fixed posible compilation errors on HP unix
30 Revision 1.9.2.7 2000/06/11 20:20:18 barbera
31 New AliITS base clase for the new structure.
33 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
34 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
36 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
37 //fixed FillModule. Removed fi(fabs(xl)<dx....
39 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
40 This is the version of the files after the merging done in December 1999.
41 See the ReadMe110100.txt file for details
43 Revision 1.9 1999/11/14 14:33:25 fca
44 Correct problems with distructors and pointers, thanks to I.Hrivnacova
46 Revision 1.8 1999/09/29 09:24:19 fca
47 Introduction of the Copyright and cvs Log
51 ///////////////////////////////////////////////////////////////////////////////
53 // An overview of the basic philosophy of the ITS code development
54 // and analysis is show in the figure below.
57 <img src="picts/ITS/ITS_Analysis_schema.gif">
60 <font size=+2 color=red>
61 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
62 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
68 // AliITS. Inner Traking System base class.
69 // This class contains the base procedures for the Inner Tracking System
73 <img src="picts/ITS/AliITS_Class_Diagram.gif">
76 <font size=+2 color=red>
77 <p>This show the class diagram of the different elements that are part of
85 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
88 // Modified and documented by Bjorn S. Nilsen
92 // Modified and documented by A. Bologna
95 // AliITS is the general base class for the ITS. Also see AliDetector for
96 // futher information.
98 ///////////////////////////////////////////////////////////////////////////////
103 #include <TObjArray.h>
104 #include <TClonesArray.h>
106 #include <TObjectTable.h>
112 #include "AliITSMap.h"
113 #include "AliITSClusterFinder.h"
114 #include "AliITSsimulation.h"
115 #include "AliITSsimulationFastPoints.h"
116 #include "AliITSsegmentationSPD.h"
117 #include "AliITSresponseSPD.h"
118 #include "AliITSsegmentationSDD.h"
119 #include "AliITSresponseSDD.h"
120 #include "AliITSsegmentationSSD.h"
121 #include "AliITSresponseSSD.h"
122 //#include "AliITStrack.h"
127 //_____________________________________________________________________________
128 AliITS::AliITS() : AliDetector() {
130 // Default initialiser for ITS
131 // The default constructor of the AliITS class. In addition to
132 // creating the AliITS class it zeros the variables fIshunt (a member
133 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
134 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
158 //_____________________________________________________________________________
159 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
161 // Default initialiser for ITS
162 // The constructor of the AliITS class. In addition to creating the
163 // AliITS class, it allocates memory for the TClonesArrays fHits and
164 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
165 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
166 // the pointers fIdSens and fIdName. To help in displaying hits via the ROOT
167 // macro display.C AliITS also sets the marker color to red. The variables
168 // passes with this constructor, const char *name and *title, are used by
169 // the constructor of AliDetector class. See AliDetector class for a
170 // description of these parameters and its constructor functions.
173 fHits = new TClonesArray("AliITShit", 1560);
174 gAlice->AddHitList(fHits);
195 fDetTypes = new TObjArray(fNDetTypes);
198 for(i=0;i<fNDetTypes;i++) {
199 (*fDetTypes)[i]=new AliITSDetType();
203 fNdtype = new Int_t[fNDetTypes];
204 fDtype = new TObjArray(fNDetTypes);
206 fNctype = new Int_t[fNDetTypes];
207 fCtype = new TObjArray(fNDetTypes);
209 SetMarkerColor(kRed);
213 //___________________________________________________________________________
214 AliITS::AliITS(AliITS &source){
215 if(this==&source) return;
216 printf("Error: You are not allowed to make a copy of the AliITS\n");
219 //____________________________________________________________________________
220 AliITS& AliITS::operator=(AliITS &source){
221 if(this==&source) return *this;
222 printf("Error: You are not allowed to make a copy of the AliITS\n");
225 //____________________________________________________________________________
226 void AliITS::ClearModules(){
227 //clear the modules TObjArray
231 Int_t indSPD = fITSgeom->GetModuleIndex(2,fITSgeom->GetNladders(2),
232 fITSgeom->GetNdetectors(2));
233 Int_t indSDD = fITSgeom->GetModuleIndex(4,fITSgeom->GetNladders(4),
234 fITSgeom->GetNdetectors(4));
235 for(i=0;i<fITSmodules->GetEntriesFast();i++){
237 delete (AliITSmodule *) fITSmodules->At(i);
239 delete (AliITSmodule *) fITSmodules->At(i);
241 delete (AliITSmodule *) fITSmodules->At(i);
243 }// end if fITSmodules!=0
246 //_____________________________________________________________________________
249 // Default distructor for ITS
250 // The default destructor of the AliITS class. In addition to deleting
251 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
252 // fIdSens, fIdName, and fITSpoints.
259 if(fIdName!=0) delete[] fIdName;
260 if(fIdSens!=0) delete[] fIdSens;
262 this->ClearModules();
264 }// end if fITSmodules!=0
269 for(i=0;i<fNDetTypes;i++) {
275 for(i=0;i<fNDetTypes;i++) {
287 if (fTreeC) delete fTreeC;
291 //___________________________________________
292 AliITSDetType* AliITS::DetType(Int_t id)
294 //return pointer to id detector type
295 return ((AliITSDetType*) (*fDetTypes)[id]);
298 //___________________________________________
299 void AliITS::SetClasses(Int_t id, char* digit, char* cluster)
301 //set the digit and cluster classes to be used for the id detector type
302 ((AliITSDetType*) (*fDetTypes)[id])->ClassNames(digit,cluster);
305 //___________________________________________
306 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response)
308 //set the response model for the id detector type
310 ((AliITSDetType*) (*fDetTypes)[id])->ResponseModel(response);
314 //___________________________________________
315 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg)
317 //set the segmentation model for the id detector type
319 ((AliITSDetType*) (*fDetTypes)[id])->SegmentationModel(seg);
323 //___________________________________________
324 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim)
326 //set the simulation model for the id detector type
328 ((AliITSDetType*) (*fDetTypes)[id])->SimulationModel(sim);
331 //___________________________________________
332 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst)
334 //set the cluster finder model for the id detector type
336 ((AliITSDetType*) (*fDetTypes)[id])->ReconstructionModel(reconst);
340 //_____________________________________________________________________________
341 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
344 // The function to add information to the AliITShit class. See the
345 // AliITShit class for a full description. This function allocates the
346 // necessary new space for the hit information and passes the variable
347 // track, and the pointers *vol and *hits to the AliITShit constructor
350 TClonesArray &lhits = *fHits;
351 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
353 //_____________________________________________________________________________
354 void AliITS::AddRealDigit(Int_t id, Int_t *digits)
356 // add a real digit - as coming from data
358 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
359 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
362 //_____________________________________________________________________________
363 void AliITS::AddDigit(Int_t id, AliITSdigit *d)
366 // add a simulated digit
368 // should have ctors of type AliITSdigitSDD(const AliITSdigitSDD &)
370 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
375 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
378 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
381 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
387 //_____________________________________________________________________________
388 void AliITS::AddDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,Float_t *charges){
390 // add a simulated digit to the list
392 TClonesArray &ldigits = *((TClonesArray*)(*fDtype)[id]);
396 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks);
399 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,charges);
402 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks);
408 //_____________________________________________________________________________
409 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c)
412 // add a cluster to the list
414 // should have ctors of type AliITSRawClusterSDD(const AliITSRawClusterSDD &)
416 TClonesArray &lcl = *((TClonesArray*)(*fCtype)[id]);
421 new(lcl[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
424 new(lcl[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
427 new(lcl[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
434 //_____________________________________________________________________________
435 void AliITS::AddRecPoint(const AliITSRecPoint &r)
438 // Add a reconstructed space point to the list
440 TClonesArray &lrecp = *fRecPoints;
441 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
445 //____________________________________________
446 void AliITS::ResetDigits()
449 // Reset number of digits and the digits array for thE ITS detector
455 for(i=0;i<fNDetTypes;i++ ) {
456 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
457 if (fNdtype) fNdtype[i]=0;
461 //____________________________________________
462 void AliITS::ResetDigits(Int_t i)
465 // Reset number of digits and the digits array for this branch
467 if ((*fDtype)[i]) ((TClonesArray*)(*fDtype)[i])->Clear();
468 if (fNdtype) fNdtype[i]=0;
471 //____________________________________________
472 void AliITS::ResetClusters()
475 // Reset number of clusters and the clusters array for ITS
479 for(i=0;i<fNDetTypes;i++ ) {
480 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
481 if (fNctype) fNctype[i]=0;
485 //____________________________________________
486 void AliITS::ResetClusters(Int_t i)
489 // Reset number of clusters and the clusters array for this branch
491 if ((*fCtype)[i]) ((TClonesArray*)(*fCtype)[i])->Clear();
492 if (fNctype) fNctype[i]=0;
497 //____________________________________________
498 void AliITS::ResetRecPoints()
501 // Reset number of rec points and the rec points array
504 if (fRecPoints) fRecPoints->Clear();
508 //_____________________________________________________________________________
509 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
511 // Distance from mouse to ITS on the screen. Dummy routine
512 // A dummy routine used by the ROOT macro display.C to allow for the
513 // use of the mouse (pointing device) in the macro. In general this should
514 // never be called. If it is it returns the number 9999 for any value of
520 //_____________________________________________________________________________
523 // Initialise ITS after it has been built
524 // This routine initializes the AliITS class. It is intended to be called
525 // from the Init function in AliITSv?. Besides displaying a banner
526 // indicating that it has been called it initializes the array fIdSens
527 // and sets the default segmentation, response, digit and raw cluster classes
528 // Therefore it should be called after a call to CreateGeometry.
537 for(i=0;i<35;i++) printf("*");
538 printf(" ITS_INIT ");
539 for(i=0;i<35;i++) printf("*");
543 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
545 for(i=0;i<80;i++) printf("*");
549 //_____________________________________________________________________________
550 void AliITS::SetDefaults()
552 // sets the default segmentation, response, digit and raw cluster classes
555 AliITSDetType *iDetType;
559 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
560 AliITSresponseSPD *resp0=new AliITSresponseSPD();
562 if (!iDetType->GetSegmentationModel()) SetSegmentationModel(0,seg0);
563 if (!iDetType->GetResponseModel()) SetResponseModel(0,resp0);
564 // set digit and raw cluster classes to be used
565 const char *kData=resp0->DataType();
566 if (strstr(kData,"real")) {
567 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
568 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
571 AliITSresponseSDD *resp1=new AliITSresponseSDD();
572 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
574 if (!iDetType->GetSegmentationModel()) SetSegmentationModel(1,seg1);
575 if (!iDetType->GetResponseModel()) SetResponseModel(1,resp1);
576 kData=resp1->DataType();
577 Option_t *opt=resp1->ZeroSuppOption();
578 if ((!strstr(opt,"2D")) && (!strstr(opt,"1D")) || strstr(kData,"real") ) {
579 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
580 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
583 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
584 AliITSresponseSSD *resp2=new AliITSresponseSSD();
586 if (!iDetType->GetSegmentationModel()) SetSegmentationModel(2,seg2);
587 if (!iDetType->GetResponseModel()) SetResponseModel(2,resp2);
588 kData=resp2->DataType();
589 if (strstr(kData,"real")) {
590 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
591 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
594 Warning("SetDefaults","Only the three basic detector types are initialised!");
600 //_____________________________________________________________________________
602 void AliITS::MakeTreeC(Option_t *option)
604 // create a separate tree to store the clusters
606 char *optC = strstr(option,"C");
607 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
609 Int_t buffersize = 4000;
612 char *det[3] = {"SPD","SDD","SSD"};
614 // one branch for Clusters per type of detector
616 for(i=0; i<fNDetTypes ;i++) {
617 if (fNDetTypes==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
618 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
619 if (fCtype && fTreeC) {
620 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
621 printf("Making Branch %s for Clusters of detector type %d\n",branchname,i+1);
627 //_____________________________________________________________________________
628 void AliITS::GetTreeC(Int_t event)
631 // get the clusters tree for this event and set the branch address
635 char *det[3] = {"SPD","SDD","SSD"};
642 sprintf(treeName,"TreeC%d",event);
643 fTreeC = (TTree*)gDirectory->Get(treeName);
649 for(i=0; i<fNDetTypes; i++) {
650 if (fNDetTypes==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
651 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
653 branch = fTreeC->GetBranch(branchname);
654 if (branch) branch->SetAddress(&((*fCtype)[i]));
658 printf("ERROR: cannot find Clusters Tree for event:%d\n",event);
662 //_____________________________________________________________________________
663 void AliITS::MakeBranch(Option_t* option){
665 // Creates Tree branches for the ITS.
669 Int_t buffersize = 4000;
671 sprintf(branchname,"%s",GetName());
673 AliDetector::MakeBranch(option);
676 // one branch for digits per type of detector
678 char *det[3] = {"SPD","SDD","SSD"};
684 for(i=0; i<fNDetTypes ;i++) {
685 AliITSDetType *iDetType=DetType(i);
686 iDetType->GetClassNames(kDigclass,kClclass);
687 //printf("i, digclass, recclass %d %s %s\n",i,kDigclass,kClclass);
689 (*fDtype)[i] = new TClonesArray(kDigclass,100);
692 (*fCtype)[i] = new TClonesArray(kClclass,100);
697 for(i=0; i<fNDetTypes ;i++) {
698 if (fNDetTypes==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
699 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
701 if (fDtype && gAlice->TreeD()) {
702 gAlice->TreeD()->Branch(branchname,&((*fDtype)[i]), buffersize);
703 printf("Making Branch %s for digits of type %d\n",branchname,i+1);
707 // only one branch for rec points for all detector types
708 sprintf(branchname,"%sRecPoints",GetName());
710 fRecPoints=new TClonesArray("AliITSRecPoint",1000);
712 if (fRecPoints && gAlice->TreeR()) {
713 gAlice->TreeR()->Branch(branchname,&fRecPoints, buffersize);
714 printf("Making Branch %s for reconstructed space points\n",branchname);
720 //___________________________________________
721 void AliITS::SetTreeAddress()
724 // Set branch address for the Trees.
727 AliDetector::SetTreeAddress();
729 char *det[3] = {"SPD","SDD","SSD"};
732 TTree *treeD = gAlice->TreeD();
733 TTree *treeR = gAlice->TreeR();
737 for(i=0; i<fNDetTypes; i++) {
738 if (fNDetTypes==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
739 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
741 branch = treeD->GetBranch(branchname);
742 if (branch) branch->SetAddress(&((*fDtype)[i]));
749 sprintf(branchname,"%sRecPoints",GetName());
751 branch = treeR->GetBranch(branchname);
752 if (branch) branch->SetAddress(&fRecPoints);
759 //____________________________________________________________________________
760 void AliITS::InitModules(Int_t size,Int_t &nmodules){
762 //initialize the modules array
764 Int_t nl,indexMAX,index;
767 if(size<=0){ // default to using data stored in AliITSgeom
769 printf("Error in AliITS::InitModule fITSgeom not defined\n");
771 } // end if fITSgeom==0
772 nl = fITSgeom->GetNlayers();
773 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
774 fITSgeom->GetNdetectors(nl))+1;
776 fITSmodules = new TObjArray(indexMAX);
777 indSPD = fITSgeom->GetModuleIndex(2,fITSgeom->GetNladders(2),
778 fITSgeom->GetNdetectors(2));
779 indSDD = fITSgeom->GetModuleIndex(4,fITSgeom->GetNladders(4),
780 fITSgeom->GetNdetectors(4));
781 for(index=0;index<indexMAX;index++){
783 fITSmodules->AddAt( new AliITSmodule(index),index);
784 else if(index<=indSDD)
785 fITSmodules->AddAt( new AliITSmodule(index),index);
787 fITSmodules->AddAt( new AliITSmodule(index),index);
790 fITSmodules = new TObjArray(size);
795 //____________________________________________________________________________
796 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t lastev,Int_t nmodules,Option_t *option,Text_t *filename){
798 // fill the modules with the sorted by module hits; add hits from background
801 static TTree *trH1; //Tree with background hits
802 static TClonesArray *fHits2; //List of hits for one track only
804 static Bool_t first=kTRUE;
806 char *add = strstr(option,"Add");
811 cout<<"filename "<<filename<<endl;
812 file=new TFile(filename);
813 cout<<"I have opened "<<filename<<" file "<<endl;
814 fHits2 = new TClonesArray("AliITShit",1000 );
819 // Get Hits Tree header from file
820 if(fHits2) fHits2->Clear();
821 if(trH1) delete trH1;
825 sprintf(treeName,"TreeH%d",bgrev);
826 trH1 = (TTree*)gDirectory->Get(treeName);
827 //printf("TrH1 %p of treename %s for event %d \n",trH1,treeName,bgrev);
830 printf("ERROR: cannot find Hits Tree for event:%d\n",bgrev);
832 // Set branch addresses
835 sprintf(branchname,"%s",GetName());
836 if (trH1 && fHits2) {
837 branch = trH1->GetBranch(branchname);
838 if (branch) branch->SetAddress(&fHits2);
842 //Int_t ntracks1 =(Int_t)TrH1->GetEntries();
843 //printf("background - ntracks1 - %d\n",ntracks1);
846 // store temporarily coordinates of signal particles - see where delete
847 static Int_t *signal;
849 if(!signal) signal=new Int_t[nmodules];
850 memset(signal,0,sizeof(int)*nmodules);
851 // Float_t xhit[nmodules][4];
852 Float_t **xhit = new Float_t*[nmodules];
853 for(i=0;i<nmodules;i++) xhit[i] = new Float_t[4];
854 // Float_t yhit[nmodules][4];
855 Float_t **yhit = new Float_t*[nmodules];
856 for(i=0;i<nmodules;i++) yhit[i] = new Float_t[4];
858 Int_t npart = gAlice->GetEvent(evnt);
860 TClonesArray *itsHits = this->Hits();
861 Int_t lay,lad,det,index;
865 TTree *iTH = gAlice->TreeH();
866 Int_t ntracks =(Int_t) iTH->GetEntries();
869 for(t=0; t<ntracks; t++){
872 Int_t nhits = itsHits->GetEntriesFast();
873 if (!nhits) continue;
874 // cout << nhits << " hits in track " << t << endl;
875 for(h=0; h<nhits; h++){
876 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
877 itsHit->GetDetectorID(lay,lad,det);
878 index = fITSgeom->GetModuleIndex(lay,lad,det);
879 mod = this->GetModule(index);
881 xhit[index][signal[index]]=itsHit->fX;
882 yhit[index][signal[index]]=itsHit->fY;
884 if (signal[index] >4)
885 printf("index,nsignal %d %d\n",index,signal[index]);
887 if(lay == 1 || lay == 2)
888 mod->AddHit((AliITShit *) itsHit,t,h);
889 else if(lay == 3 || lay == 4)
890 mod->AddHit((AliITShit *) itsHit,t,h);
891 else if(lay == 5 || lay ==6)
892 mod->AddHit((AliITShit *)itsHit,t,h);
894 mod->AddHit(itsHit,t,h);
896 } // end loop over hits
897 } // end loop over tracks
899 // open the file with background
903 ntracks =(Int_t)trH1->GetEntries();
904 //printf("background - ntracks1 %d\n",ntracks);
905 //printf("background - Start loop over tracks \n");
908 for(track=0; track<ntracks; track++) {
910 if (fHits2) fHits2->Clear();
911 trH1->GetEvent(track);
913 for(i=0;i<fHits2->GetEntriesFast();++i) {
915 itsHit=(AliITShit*) (*fHits2)[i];
916 itsHit->GetDetectorID(lay,lad,det);
917 index = fITSgeom->GetModuleIndex(lay,lad,det);
918 mod = this->GetModule(index);
920 Float_t xbgr=itsHit->fX;
921 Float_t ybgr=itsHit->fY;
922 Float_t ebgr=itsHit->GetIonization();
925 for(isig =0; isig < signal[index]; isig++) {
927 (xbgr-xhit[index][isig])*(xbgr-xhit[index][isig])
928 +(ybgr-yhit[index][isig])*(ybgr-yhit[index][isig]);
929 if (dist<0.2&& ebgr!=0) cond=kTRUE; // check this number for ITS!
932 if(lay == 1 || lay == 2)
933 mod->AddHit((AliITShit *) itsHit,track,i);
934 else if(lay == 3 || lay == 4)
935 mod->AddHit((AliITShit *) itsHit,track,i);
936 else if(lay == 5 || lay ==6)
937 mod->AddHit((AliITShit *)itsHit,track,i);
939 mod->AddHit(itsHit,track,i);
942 } // end loop over hits
943 } // end loop over tracks
945 TTree *fAli=gAlice->TreeK();
948 if (fAli) fileAli =fAli->GetCurrentFile();
949 //printf("fAli, file %p %p\n",fAli,file);
955 for(i=0;i<nmodules;i++) delete[] xhit[i];
957 for(i=0;i<nmodules;i++) delete[] yhit[i];
959 //if (evnt==lastev) {delete [] signal; delete signal;}
961 //gObjectTable->Print();
966 //____________________________________________________________________________
967 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t lastev,Int_t size,
968 Option_t *option,Option_t *opt,Text_t *filename)
970 // keep galice.root for signal and name differently the file for
971 // background when add! otherwise the track info for signal will be lost !
973 char *all = strstr(opt,"All");
974 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
975 //printf("Det 1 2 3 %s %s %s \n",det[0],det[1],det[2]);
978 InitModules(size,nmodules);
979 FillModules(evNumber,bgrev,lastev,nmodules,option,filename);
980 //printf("nmodules %d\n",nmodules);
983 AliITSsimulation* sim;
985 TObjArray *branches=gAlice->TreeD()->GetListOfBranches();
986 AliITSgeom *geom = GetITSgeom();
989 for(id=0;id<3;id++) {
990 //printf("id %d All %s det[id] %s \n",id,all,det[id]);
991 if (!all && !det[id]) continue;
992 branch = (TBranch*)branches->UncheckedAt(id);
993 AliITSDetType *iDetType=DetType(id);
994 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
996 Error("HitsToDigits","The simulation class was not instantiated!");
998 // or SetDefaultSimulation(id,iDetType*);
1000 Int_t first = geom->GetStartDet(id);
1001 Int_t last = geom->GetLastDet(id);
1002 //printf("det type %d first, last %d %d \n",id,first,last);
1003 for(module=first;module<=last;module++) {
1004 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1005 sim->DigitiseModule(mod,module,evNumber);
1006 // fills all branches - wasted disk space
1007 gAlice->TreeD()->Fill();
1009 // try and fill only the branch
1012 } // loop over modules
1013 } // loop over detector types
1018 //Int_t nentries=(Int_t)gAlice->TreeD()->GetEntries();
1021 sprintf(hname,"TreeD%d",evNumber);
1022 gAlice->TreeD()->Write(hname);
1024 gAlice->TreeD()->Reset();
1029 //____________________________________________________________________________
1030 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt)
1033 char *all = strstr(opt,"All");
1034 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1036 static Bool_t first=kTRUE;
1044 AliITSClusterFinder* rec;
1046 TObjArray *branches=gAlice->TreeR()->GetListOfBranches();
1047 AliITSgeom *geom = GetITSgeom();
1050 for(id=0;id<fNDetTypes;id++) {
1051 if (!all && !det[id]) continue;
1052 branch = (TBranch*)branches->UncheckedAt(id);
1053 AliITSDetType *iDetType=DetType(id);
1054 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1056 Error("DigitsToRecPoints","The cluster finder class was not instantiated!");
1058 // or SetDefaultClusterFinder(id,iDetType*);
1060 TClonesArray *itsDigits = this->DigitsAddress(id);
1062 Int_t first = geom->GetStartDet(id);
1063 Int_t last = geom->GetLastDet(id);
1064 //printf("det type %d first, last %d %d \n",id,first,last);
1065 for(module=first;module<=last;module++) {
1066 //printf("AliITS: module=%d\n",module);
1067 this->ResetDigits();
1068 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1069 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1070 Int_t ndigits = itsDigits->GetEntriesFast();
1071 if (ndigits) rec->FindRawClusters();
1072 gAlice->TreeR()->Fill();
1076 // try and fill only the branch
1078 //ResetRecPoints(id);
1079 } // loop over modules
1080 } // loop over detector types
1083 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1085 //Int_t ncentries=(Int_t)TC->GetEntries();
1088 sprintf(hname,"TreeR%d",evNumber);
1089 gAlice->TreeR()->Write(hname);
1091 gAlice->TreeR()->Reset();
1093 sprintf(hname,"TreeC%d",evNumber);
1099 //____________________________________________________________________________
1100 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t lastev,Int_t size,
1101 Option_t *option,Option_t *opt,Text_t *filename)
1103 // keep galice.root for signal and name differently the file for
1104 // background when add! otherwise the track info for signal will be lost !
1106 char *all = strstr(opt,"All");
1107 char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),strstr(opt,"SSD")};
1110 InitModules(size,nmodules);
1111 FillModules(evNumber,bgrev,lastev,nmodules,option,filename);
1113 static AliITSsimulationFastPoints* sim=0;
1114 if (!sim) sim = new AliITSsimulationFastPoints();
1117 AliITSgeom *geom = GetITSgeom();
1120 for(id=0;id<3;id++) {
1121 if (!all && !det[id]) continue;
1122 Int_t first = geom->GetStartDet(id);
1123 Int_t last = geom->GetLastDet(id);
1124 for(module=first;module<=last;module++) {
1125 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1126 sim->CreateFastRecPoints(mod);
1127 gAlice->TreeR()->Fill();
1129 } // loop over modules
1130 } // loop over detector types
1135 //Int_t nentries=(Int_t)gAlice->TreeR()->GetEntries();
1138 sprintf(hname,"TreeR%d",evNumber);
1139 gAlice->TreeR()->Write(hname);
1141 gAlice->TreeR()->Reset();
1145 //______________________________________________________________________________
1146 void AliITS::Streamer(TBuffer &R__b)
1148 // Stream an object of class AliITS.
1152 if (R__b.IsReading()) {
1153 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1154 AliDetector::Streamer(R__b);
1156 R__b >> fITSmodules;
1160 fIdSens = new Int_t[fIdN];
1161 R__b.ReadFastArray(fIdSens,fIdN);
1162 for(i=0;i<fIdN;i++){
1164 fIdName[i] = new char[l+1]; // add room for null character.
1165 for(j=0;j<l;j++) R__b >> fIdName[i][j];
1166 fIdName[i][l] = '\0'; // Null terminate this string.
1168 //R__b.ReadArray(fIdName);
1169 R__b >> fMajorVersion;
1170 R__b >> fMinorVersion;
1175 fNdtype = new Int_t[fNDetTypes];
1176 R__b.ReadFastArray(fNdtype,fNDetTypes);
1179 fNctype = new Int_t[fNDetTypes];
1180 R__b.ReadFastArray(fNctype,fNDetTypes);
1181 fRecPoints->Streamer(R__b);
1182 R__b >> fNRecPoints;
1183 fTracks->Streamer(R__b);
1186 R__b.WriteVersion(AliITS::IsA());
1187 AliDetector::Streamer(R__b);
1189 R__b << fITSmodules;
1192 R__b.WriteFastArray(fIdSens,fIdN);
1193 for(i=0;i<fIdN;i++){
1194 l = strlen(fIdName[i]);
1196 for(j=0;j<l;j++) R__b << fIdName[i][j];
1198 //R__b.WriteArray(fIdName, __COUNTER__);
1199 R__b << fMajorVersion;
1200 R__b << fMinorVersion;
1204 R__b.WriteFastArray(fNdtype,fNDetTypes);
1206 R__b.WriteFastArray(fNctype,fNDetTypes);
1208 // fRecPoints->Streamer(R__b);
1209 R__b << fNRecPoints;
1211 // fTracks->Streamer(R__b);
1216 ClassImp(AliITSRecPoint)
1217 ClassImp(AliITSsegmentation)
1218 ClassImp(AliITSresponse)
1219 //ClassImp(AliITStrack)