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.61 2001/10/11 15:26:07 mariana
19 Correct HitsToFastRecPoints
21 Revision 1.60 2001/10/04 22:38:10 nilsen
22 Changes made to support PreDigits (SDigits) plus other helpful changes.
24 Revision 1.59 2001/08/30 09:56:18 hristov
25 The operator[] is replaced by At() or AddAt() in case of TObjArray.
27 Revision 1.58 2001/07/26 15:05:29 hristov
28 Use global gRandom generator (M.Ivanov)
30 Revision 1.57 2001/07/24 14:26:11 mariana
31 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
33 Revision 1.56 2001/07/05 12:49:49 mariana
34 Temporary patches required by root.v3.01.05
36 Revision 1.55 2001/06/14 14:59:00 barbera
37 Tracking V1 decoupled from AliITS
39 Revision 1.54 2001/05/31 20:37:56 barbera
40 Bari/Salerno model set as defaault SPD simulation
42 Revision 1.53 2001/05/31 18:52:24 barbera
43 Bari model becomes the default
45 Revision 1.53 2001/05/30 07:52:24 hristov
46 TPC and CONTAINERS included in the search path
48 Revision 1.52 2001/05/30 06:04:58 hristov
49 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
51 Revision 1.51 2001/05/16 14:57:15 alibrary
52 New files for folders and Stack
54 Revision 1.50 2001/05/11 09:15:21 barbera
55 Corrected to make fast point creation working with PPR geometry
57 Revision 1.49 2001/05/11 07:37:49 hristov
58 Legacy lines commented
60 Revision 1.48 2001/05/10 18:14:25 barbera
63 Revision 1.47 2001/05/10 17:55:59 barbera
64 Modified to create rec points also for PPR geometries
66 Revision 1.46 2001/05/10 00:05:28 nilsen
67 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
68 should probably be cleaned up to only check to make sure that fITSgeom has
69 been properly defined.
71 Revision 1.45 2001/05/01 22:35:48 nilsen
72 Remove/commented a number of cout<< statements. and made change needed by
75 Revision 1.44 2001/04/26 22:44:01 nilsen
76 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
77 done properly in AliITSv???.cxx via SetDefaults.
79 Revision 1.43 2001/04/26 13:22:52 barbera
80 TMatrix and TVector elimininated to speed up the code
82 Revision 1.42 2001/04/25 21:55:12 barbera
83 Updated version to be compatible with actual verion of STEER and TPC
85 Revision 1.41 2001/04/21 15:16:51 barbera
86 Updated with the new SSD reconstruction code
88 Revision 1.40 2001/03/17 15:07:06 mariana
89 Update SDD response parameters
91 Revision 1.39 2001/03/12 17:45:32 hristov
92 Changes needed on Sun with CC 5.0
94 Revision 1.38 2001/03/07 14:04:51 barbera
95 Some vector dimensions increased to cope with full events
97 Revision 1.37 2001/03/07 12:36:35 barbera
98 A change added in the tracking part to manage delta rays
100 Revision 1.36 2001/03/02 19:44:11 barbera
101 modified to taking into account new version tracking v1
103 Revision 1.35 2001/02/28 18:16:46 mariana
104 Make the code compatible with the new AliRun
106 Revision 1.34 2001/02/11 15:51:39 mariana
107 Set protection in MakeBranch
109 Revision 1.33 2001/02/10 22:26:39 mariana
110 Move the initialization of the containers for raw clusters in MakeTreeC()
112 Revision 1.32 2001/02/08 23:55:31 nilsen
113 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
114 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
116 Revision 1.31 2001/02/02 23:57:28 nilsen
117 Added include file that are no londer included in AliITSgeom.h
119 Revision 1.30 2001/01/30 09:23:13 hristov
120 Streamers removed (R.Brun)
122 Revision 1.29 2001/01/26 20:01:09 hristov
123 Major upgrade of AliRoot code
125 Revision 1.28 2000/12/18 14:02:00 barbera
126 new version of the ITS tracking to take into account the new TPC track parametrization
128 Revision 1.27 2000/12/08 13:49:27 barbera
129 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
131 Revision 1.26 2000/11/27 13:12:13 barbera
132 New version containing the files for tracking
134 Revision 1.25 2000/11/12 22:38:05 barbera
135 Added header file for the SPD Bari model
137 Revision 1.24 2000/10/09 22:18:12 barbera
138 Bug fixes from MAriana to le AliITStest.C run correctly
140 Revision 1.23 2000/10/05 20:47:42 nilsen
141 fixed dependencies of include files. Tryed but failed to get a root automaticly
142 generates streamer function to work. Modified SetDefaults.
144 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
145 Needed to include stdlib.h
148 Revision 1.22 2000/10/04 19:45:52 barbera
149 Corrected by F. Carminati for v3.04
151 Revision 1.21 2000/10/02 21:28:08 fca
152 Removal of useless dependecies via forward declarations
154 Revision 1.20 2000/10/02 16:31:39 barbera
155 General code clean-up
157 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
158 General code clean-up (e.g., printf -> cout)
160 Revision 1.19 2000/09/22 12:13:25 nilsen
161 Patches and updates for fixes to this and other routines.
163 Revision 1.18 2000/07/12 05:32:20 fca
164 Correcting several syntax problem with static members
166 Revision 1.17 2000/07/10 16:07:18 fca
167 Release version of ITS code
169 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
170 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
172 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
173 //fixed FillModule. Removed fi(fabs(xl)<dx....
175 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
176 This is the version of the files after the merging done in December 1999.
177 See the ReadMe110100.txt file for details
179 Revision 1.9 1999/11/14 14:33:25 fca
180 Correct problems with distructors and pointers, thanks to I.Hrivnacova
182 Revision 1.8 1999/09/29 09:24:19 fca
183 Introduction of the Copyright and cvs Log
187 ///////////////////////////////////////////////////////////////////////////////
189 // An overview of the basic philosophy of the ITS code development
190 // and analysis is show in the figure below.
193 <img src="picts/ITS/ITS_Analysis_schema.gif">
196 <font size=+2 color=red>
197 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
198 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
204 // AliITS. Inner Traking System base class.
205 // This class contains the base procedures for the Inner Tracking System
209 <img src="picts/ITS/AliITS_Class_Diagram.gif">
212 <font size=+2 color=red>
213 <p>This show the class diagram of the different elements that are part of
221 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
224 // Modified and documented by Bjorn S. Nilsen
228 // Modified and documented by A. Bologna
231 // AliITS is the general base class for the ITS. Also see AliDetector for
232 // futher information.
234 ///////////////////////////////////////////////////////////////////////////////
235 #include <iostream.h>
243 #include <TClonesArray.h>
245 #include <TObjectTable.h>
252 #include "AliHeader.h"
255 #include "AliITSDetType.h"
256 #include "AliITSresponseSPD.h"
257 #include "AliITSresponseSDD.h"
258 #include "AliITSresponseSSD.h"
259 #include "AliITSsegmentationSPD.h"
260 #include "AliITSsegmentationSDD.h"
261 #include "AliITSsegmentationSSD.h"
262 #include "AliITSsimulationSPD.h"
263 #include "AliITSsimulationSDD.h"
264 #include "AliITSsimulationSSD.h"
265 #include "AliITSClusterFinderSPD.h"
266 #include "AliITSClusterFinderSDD.h"
267 #include "AliITSClusterFinderSSD.h"
268 #include "AliITShit.h"
269 #include "AliITSgeom.h"
270 #include "AliITSpList.h"
271 #include "AliITSdigit.h"
272 #include "AliITSmodule.h"
273 #include "AliITSRecPoint.h"
274 #include "AliITSRawCluster.h"
278 //______________________________________________________________________
279 AliITS::AliITS() : AliDetector() {
280 // Default initialiser for ITS
281 // The default constructor of the AliITS class. In addition to
282 // creating the AliITS class it zeros the variables fIshunt (a member
283 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
284 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
287 fIshunt = 0; // not zeroed in AliDetector.
293 SetDetectors(); // default to "All". This variable not written out.
299 fNDetTypes = kNTYPES;
315 SetMarkerColor(kRed);
317 //______________________________________________________________________
318 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
319 // Default initialiser for ITS
320 // The constructor of the AliITS class. In addition to creating the
321 // AliITS class, it allocates memory for the TClonesArrays fHits and
322 // fDigits, and for the TObjArray fITSpoints. It also zeros the variables
323 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
324 // the pointers fIdSens and fIdName. To help in displaying hits via the
325 // ROOT macro display.C AliITS also sets the marker color to red. The
326 // variables passes with this constructor, const char *name and *title,
327 // are used by the constructor of AliDetector class. See AliDetector
328 // class for a description of these parameters and its constructor
331 fIshunt = 0; // not zeroed in AliDetector
332 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
333 gAlice->AddHitList(fHits); // Not done in AliDetector.
338 SetDetectors(); // default to "All". This variable not written out.
344 fNDetTypes = kNTYPES;
345 fDetTypes = new TObjArray(fNDetTypes);
347 // fSDigits = new TObjArray(1000);
348 fSDigits = new TClonesArray("AliITSpListItem",1000);
351 fNdtype = new Int_t[fNDetTypes];
352 fDtype = new TObjArray(fNDetTypes);
354 fCtype = new TObjArray(fNDetTypes);
355 fNctype = new Int_t[fNDetTypes];
358 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
362 for(i=0;i<fNDetTypes;i++) {
363 fDetTypes->AddAt(new AliITSDetType(),i);
368 SetMarkerColor(kRed);
370 //______________________________________________________________________
372 // Default distructor for ITS
373 // The default destructor of the AliITS class. In addition to deleting
374 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
375 // fIdSens, fIdName, and fITSpoints.
381 // delete fIdName; // TObjArray of TObjStrings
382 if(fIdName!=0) delete[] fIdName; // Array of TStrings
383 if(fIdSens!=0) delete[] fIdSens;
385 this->ClearModules();
387 }// end if fITSmodules!=0
403 } // end if fDetTypes
405 if (fTreeC) delete fTreeC;
407 if (fITSgeom) delete fITSgeom;
409 //______________________________________________________________________
410 AliITS::AliITS(AliITS &source){
413 if(this==&source) return;
414 Error("AliITS::Copy constructor",
415 "You are not allowed to make a copy of the AliITS");
418 //______________________________________________________________________
419 AliITS& AliITS::operator=(AliITS &source){
420 // assignment operator
422 if(this==&source) return *this;
423 Error("AliITS::operator=",
424 "You are not allowed to make a copy of the AliITS");
426 return *this; //fake return
428 //______________________________________________________________________
429 Int_t AliITS::DistancetoPrimitive(Int_t , Int_t ){
430 // Distance from mouse to ITS on the screen. Dummy routine
431 // A dummy routine used by the ROOT macro display.C to allow for the
432 // use of the mouse (pointing device) in the macro. In general this should
433 // never be called. If it is it returns the number 9999 for any value of
438 //______________________________________________________________________
440 // Initialise ITS after it has been built
441 // This routine initializes the AliITS class. It is intended to be
442 // called from the Init function in AliITSv?. Besides displaying a banner
443 // indicating that it has been called it initializes the array fIdSens
444 // and sets the default segmentation, response, digit and raw cluster
445 // classes therefore it should be called after a call to CreateGeometry.
450 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
452 //______________________________________________________________________
453 void AliITS::SetDefaults(){
454 // sets the default segmentation, response, digit and raw cluster classes
456 if(fDebug) printf("%s: SetDefaults\n",ClassName());
458 AliITSDetType *iDetType;
462 if (!iDetType->GetSegmentationModel()) {
463 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
464 SetSegmentationModel(0,seg0);
466 if (!iDetType->GetResponseModel()) {
467 SetResponseModel(0,new AliITSresponseSPD());
469 // set digit and raw cluster classes to be used
471 const char *kData0=(iDetType->GetResponseModel())->DataType();
472 if (strstr(kData0,"real")) {
473 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
474 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
478 if (!iDetType->GetResponseModel()) {
479 SetResponseModel(1,new AliITSresponseSDD());
481 AliITSresponse *resp1=iDetType->GetResponseModel();
482 if (!iDetType->GetSegmentationModel()) {
483 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
484 SetSegmentationModel(1,seg1);
486 const char *kData1=(iDetType->GetResponseModel())->DataType();
487 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
488 if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
489 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
490 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
494 if (!iDetType->GetSegmentationModel()) {
495 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
496 SetSegmentationModel(2,seg2);
498 if (!iDetType->GetResponseModel()) {
499 SetResponseModel(2,new AliITSresponseSSD());
501 const char *kData2=(iDetType->GetResponseModel())->DataType();
502 if (strstr(kData2,"real")) {
503 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
504 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
507 Warning("SetDefaults",
508 "Only the three basic detector types are initialised!");
511 //______________________________________________________________________
512 void AliITS::SetDefaultSimulation(){
513 // sets the default simulation
515 AliITSDetType *iDetType;
517 if (!iDetType->GetSimulationModel()) {
518 AliITSsegmentation *seg0=
519 (AliITSsegmentation*)iDetType->GetSegmentationModel();
520 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
521 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
522 SetSimulationModel(0,sim0);
525 if (!iDetType->GetSimulationModel()) {
526 AliITSsegmentation *seg1=
527 (AliITSsegmentation*)iDetType->GetSegmentationModel();
528 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
529 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
530 SetSimulationModel(1,sim1);
533 if (!iDetType->GetSimulationModel()) {
534 AliITSsegmentation *seg2=
535 (AliITSsegmentation*)iDetType->GetSegmentationModel();
536 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
537 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
538 SetSimulationModel(2,sim2);
541 //______________________________________________________________________
542 void AliITS::SetDefaultClusterFinders(){
543 // sets the default cluster finders
546 AliITSDetType *iDetType;
550 if (!iDetType->GetReconstructionModel()) {
551 AliITSsegmentation *seg0 =
552 (AliITSsegmentation*)iDetType->GetSegmentationModel();
553 TClonesArray *dig0=DigitsAddress(0);
554 TClonesArray *recp0=ClustersAddress(0);
555 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
557 SetReconstructionModel(0,rec0);
562 if (!iDetType->GetReconstructionModel()) {
563 AliITSsegmentation *seg1 =
564 (AliITSsegmentation*)iDetType->GetSegmentationModel();
565 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
566 TClonesArray *dig1=DigitsAddress(1);
567 TClonesArray *recp1=ClustersAddress(1);
568 AliITSClusterFinderSDD *rec1 =
569 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
570 SetReconstructionModel(1,rec1);
575 if (!iDetType->GetReconstructionModel()) {
576 AliITSsegmentation *seg2=
577 (AliITSsegmentation*)iDetType->GetSegmentationModel();
578 TClonesArray *dig2=DigitsAddress(2);
579 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
580 SetReconstructionModel(2,rec2);
583 //______________________________________________________________________
584 void AliITS::MakeBranch(Option_t* option, const char *file){
585 // Creates Tree branches for the ITS.
586 const char *cS = strstr(option,"S");
587 const char *cD = strstr(option,"D");
588 const char *cR = strstr(option,"R");
590 AliDetector::MakeBranch(option,file);
592 if(cS) MakeBranchS(file);
593 if(cD) MakeBranchD(file);
594 if(cR) MakeBranchR(file);
596 //______________________________________________________________________
597 void AliITS::SetTreeAddress(){
598 // Set branch address for the Trees.
599 TTree *treeS = gAlice->TreeS();
600 TTree *treeD = gAlice->TreeD();
601 TTree *treeR = gAlice->TreeR();
603 AliDetector::SetTreeAddress();
605 SetTreeAddressS(treeS);
606 SetTreeAddressD(treeD);
607 SetTreeAddressR(treeR);
609 //______________________________________________________________________
610 AliITSDetType* AliITS::DetType(Int_t id){
611 //return pointer to id detector type
613 return ((AliITSDetType*) fDetTypes->At(id));
615 //______________________________________________________________________
616 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
617 //set the response model for the id detector type
619 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
621 //______________________________________________________________________
622 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
623 //set the segmentation model for the id detector type
625 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
627 //______________________________________________________________________
628 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
629 //set the simulation model for the id detector type
631 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
634 //______________________________________________________________________
635 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
636 //set the cluster finder model for the id detector type
638 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
640 //______________________________________________________________________
641 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
642 //set the digit and cluster classes to be used for the id detector type
644 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
646 //______________________________________________________________________
647 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
649 // The function to add information to the AliITShit class. See the
650 // AliITShit class for a full description. This function allocates the
651 // necessary new space for the hit information and passes the variable
652 // track, and the pointers *vol and *hits to the AliITShit constructor
655 TClonesArray &lhits = *fHits;
656 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
658 //______________________________________________________________________
659 void AliITS::InitModules(Int_t size,Int_t &nmodules){
660 //initialize the modules array
663 fITSmodules->Delete();
665 } // end fir fITSmoudles
667 Int_t nl,indexMAX,index;
669 if(size<=0){ // default to using data stored in AliITSgeom
671 Error("AliITS::InitModules",
672 "in AliITS::InitModule fITSgeom not defined\n");
674 } // end if fITSgeom==0
675 nl = fITSgeom->GetNlayers();
676 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
677 fITSgeom->GetNdetectors(nl))+1;
679 fITSmodules = new TObjArray(indexMAX);
680 for(index=0;index<indexMAX;index++){
681 fITSmodules->AddAt( new AliITSmodule(index),index);
684 fITSmodules = new TObjArray(size);
685 for(index=0;index<size;index++) {
686 fITSmodules->AddAt( new AliITSmodule(index),index);
692 //______________________________________________________________________
693 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
694 Option_t *option,Text_t *filename){
695 // fill the modules with the sorted by module hits; add hits from
696 // background if option=Add
697 static TTree *trH1; //Tree with background hits
698 static TClonesArray *fHits2; //List of hits for one track only
699 static Bool_t first=kTRUE;
701 const char *addBgr = strstr(option,"Add");
705 file=new TFile(filename);
706 fHits2 = new TClonesArray("AliITShit",1000 );
711 // Get Hits Tree header from file
712 if(fHits2) fHits2->Clear();
713 if(trH1) delete trH1;
717 sprintf(treeName,"TreeH%d",bgrev);
718 trH1 = (TTree*)gDirectory->Get(treeName);
720 Error("AliITS::FillModules","cannot find Hits Tree for event:%d\n",
723 // Set branch addresses
726 sprintf(branchname,"%s",GetName());
727 if (trH1 && fHits2) {
728 branch = trH1->GetBranch(branchname);
729 if (branch) branch->SetAddress(&fHits2);
730 } // end if trH1 && fHits
733 TClonesArray *itsHits = this->Hits();
734 Int_t lay,lad,det,index;
737 TTree *iTH = gAlice->TreeH();
738 Int_t ntracks =(Int_t) iTH->GetEntries();
740 for(t=0; t<ntracks; t++){
743 Int_t nhits = itsHits->GetEntriesFast();
744 if (!nhits) continue;
745 for(h=0; h<nhits; h++){
746 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
747 itsHit->GetDetectorID(lay,lad,det);
748 // temporarily index=det-1 !!!
749 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
752 mod = this->GetModule(index);
753 mod->AddHit(itsHit,t,h);
754 } // end loop over hits
755 } // end loop over tracks
757 // open the file with background
761 ntracks =(Int_t)trH1->GetEntries();
763 for (track=0; track<ntracks; track++) {
764 if (fHits2) fHits2->Clear();
765 trH1->GetEvent(track);
767 for(i=0;i<fHits2->GetEntriesFast();++i) {
768 itsHit=(AliITShit*) (*fHits2)[i];
769 itsHit->GetDetectorID(lay,lad,det);
770 // temporarily index=det-1 !!!
771 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
774 mod = this->GetModule(index);
775 mod->AddHit(itsHit,track,i);
776 } // end loop over hits
777 } // end loop over tracks
778 TTree *fAli=gAlice->TreeK();
780 if (fAli) fileAli =fAli->GetCurrentFile();
784 //______________________________________________________________________
785 void AliITS::ClearModules(){
786 //clear the modules TObjArray
788 if(fITSmodules) fITSmodules->Delete();
790 //______________________________________________________________________
791 void AliITS::MakeBranchS(const char *file){
792 // Creates Tree branche for the ITS summable digits.
793 Int_t buffersize = 4000;
796 // only one branch for SDigits.
797 sprintf(branchname,"%s",GetName());
798 if(fSDigits && gAlice->TreeS()){
799 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,file);
802 //______________________________________________________________________
803 void AliITS::SetTreeAddressS(TTree *treeS){
804 // Set branch address for the ITS summable digits Trees.
809 sprintf(branchname,"%s",GetName());
810 branch = treeS->GetBranch(branchname);
811 if (branch) branch->SetAddress(&fSDigits);
813 //______________________________________________________________________
814 void AliITS::MakeBranchD(const char *file){
815 // Creates Tree branches for the ITS.
816 Int_t buffersize = 4000;
819 sprintf(branchname,"%s",GetName());
820 // one branch for digits per type of detector
821 const char *det[3] = {"SPD","SDD","SSD"};
825 for (i=0; i<kNTYPES ;i++) {
826 DetType(i)->GetClassNames(digclass,clclass);
828 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
831 for (i=0; i<kNTYPES ;i++) {
832 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
833 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
834 if (fDtype && gAlice->TreeD()) {
835 MakeBranchInTree(gAlice->TreeD(),
836 branchname, &((*fDtype)[i]),buffersize,file);
840 //______________________________________________________________________
841 void AliITS::SetTreeAddressD(TTree *treeD){
842 // Set branch address for the Trees.
844 const char *det[3] = {"SPD","SDD","SSD"};
851 for (i=0; i<kNTYPES; i++) {
852 DetType(i)->GetClassNames(digclass,clclass);
854 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
856 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
857 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
859 branch = treeD->GetBranch(branchname);
860 if (branch) branch->SetAddress(&((*fDtype)[i]));
864 //______________________________________________________________________
865 void AliITS::Hits2SDigits(){
866 // Standard Hits to summable Digits function.
868 return; // Using Hits inplace of the larger sDigits.
869 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
870 // Do the Hits to Digits operation. Use Standard input values.
871 // Event number from file, no background hit merging , use size from
872 // AliITSgeom class, option="All", input from this file only.
873 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
875 //______________________________________________________________________
876 void AliITS::Hits2PreDigits(){
877 // Standard Hits to summable Digits function.
879 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
880 // Do the Hits to Digits operation. Use Standard input values.
881 // Event number from file, no background hit merging , use size from
882 // AliITSgeom class, option="All", input from this file only.
883 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
885 //______________________________________________________________________
886 void AliITS::SDigits2Digits(){
887 // Standard Summable digits to Digits function.
891 //______________________________________________________________________
892 void AliITS::Hits2Digits(){
893 // Standard Hits to Digits function.
895 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
896 // Do the Hits to Digits operation. Use Standard input values.
897 // Event number from file, no background hit merging , use size from
898 // AliITSgeom class, option="All", input from this file only.
899 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
901 //______________________________________________________________________
902 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
903 Option_t *option, Option_t *opt,Text_t *filename){
904 // keep galice.root for signal and name differently the file for
905 // background when add! otherwise the track info for signal will be lost !
906 // the condition below will disappear when the geom class will be
907 // initialised for all versions - for the moment it is only for v5 !
908 // 7 is the SDD beam test version
909 return; // using Hits instead of the larger sdigits.
911 //______________________________________________________________________
912 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
913 Option_t *option, Option_t *opt,Text_t *filename){
914 // keep galice.root for signal and name differently the file for
915 // background when add! otherwise the track info for signal will be lost !
916 // the condition below will disappear when the geom class will be
917 // initialised for all versions - for the moment it is only for v5 !
918 // 7 is the SDD beam test version
920 if(!GetITSgeom()) return; // need transformations to do digitization.
921 AliITSgeom *geom = GetITSgeom();
923 const char *all = strstr(opt,"All");
924 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
926 static Bool_t setDef=kTRUE;
927 if (setDef) SetDefaultSimulation();
931 InitModules(size,nmodules);
932 FillModules(evNumber,bgrev,nmodules,option,filename);
934 AliITSsimulation *sim = 0;
935 AliITSDetType *iDetType = 0;
936 AliITSmodule *mod = 0;
938 for(module=0;module<geom->GetIndexMax();module++){
939 id = geom->GetModuleType(module);
940 if (!all && !det[id]) continue;
941 iDetType = DetType(id);
942 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
944 Error("HitsToSDigits",
945 "The simulation class was not instantiated!");
948 mod = (AliITSmodule *)fITSmodules->At(module);
949 sim->SDigitiseModule(mod,module,evNumber);
950 // fills all branches - wasted disk space
951 gAlice->TreeS()->Fill();
957 gAlice->TreeS()->GetEntries();
960 sprintf(hname,"TreeS%d",evNumber);
961 gAlice->TreeS()->Write(hname,TObject::kOverwrite);
963 gAlice->TreeS()->Reset();
965 //______________________________________________________________________
966 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
967 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 !
970 // the condition below will disappear when the geom class will be
971 // initialised for all versions - for the moment it is only for v5 !
972 // 7 is the SDD beam test version
973 /* Int_t ver = this->IsVersion();
974 if(ver!=5 && ver!=7 && ver!=8 && ver!=9) return;
976 if(!GetITSgeom()) return; // need transformations to do digitization.
977 AliITSgeom *geom = GetITSgeom();
979 const char *all = strstr(opt,"All");
980 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
982 static Bool_t setDef=kTRUE;
983 if (setDef) SetDefaultSimulation();
987 InitModules(size,nmodules);
988 FillModules(evNumber,bgrev,nmodules,option,filename);
990 AliITSsimulation *sim = 0;
991 AliITSDetType *iDetType = 0;
992 AliITSmodule *mod = 0;
994 for(module=0;module<geom->GetIndexMax();module++){
995 id = geom->GetModuleType(module);
996 if (!all && !det[id]) continue;
997 iDetType = DetType(id);
998 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1000 Error("HitsToDigits",
1001 "The simulation class was not instantiated!");
1004 mod = (AliITSmodule *)fITSmodules->At(module);
1005 sim->DigitiseModule(mod,module,evNumber);
1006 // fills all branches - wasted disk space
1007 gAlice->TreeD()->Fill();
1013 for (id=0;id<kNTYPES;id++) {
1014 if (!all && !det[id]) continue;
1015 AliITSDetType *iDetType=DetType(id);
1016 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1018 first = geom->GetStartDet(id);
1019 last = geom->GetLastDet(id);
1020 } else first=last=0;
1021 for(module=first;module<=last;module++) {
1022 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1023 sim->DigitiseModule(mod,module,evNumber);
1024 // fills all branches - wasted disk space
1025 gAlice->TreeD()->Fill();
1027 } // loop over modules
1028 } // loop over detector types
1032 gAlice->TreeD()->GetEntries();
1035 sprintf(hname,"TreeD%d",evNumber);
1036 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
1038 gAlice->TreeD()->Reset();
1040 //______________________________________________________________________
1041 void AliITS::ResetSDigits(){
1042 // Reset the Summable Digits array
1044 if (fSDigits) fSDigits->Clear();
1047 //______________________________________________________________________
1048 void AliITS::ResetDigits(){
1049 // Reset number of digits and the digits array for the ITS detector
1051 if (!fDtype) return;
1054 for (i=0;i<kNTYPES;i++ ) {
1055 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1056 if (fNdtype) fNdtype[i]=0;
1059 //______________________________________________________________________
1060 void AliITS::ResetDigits(Int_t i){
1061 // Reset number of digits and the digits array for this branch
1063 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1064 if (fNdtype) fNdtype[i]=0;
1066 //______________________________________________________________________
1067 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1068 // adds the a module full of summable digits to the summable digits tree.
1070 TClonesArray &lsdig = *fSDigits;
1071 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1073 //______________________________________________________________________
1074 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1075 // add a real digit - as coming from data
1077 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1078 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1080 //______________________________________________________________________
1081 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1082 // add a simulated digit
1084 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1088 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1091 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1094 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1098 //______________________________________________________________________
1099 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1100 Int_t *hits,Float_t *charges){
1101 // add a simulated digit to the list
1103 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1106 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1109 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1113 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1117 //______________________________________________________________________
1118 void AliITS::MakeTreeC(Option_t *option){
1119 // create a separate tree to store the clusters
1121 const char *optC = strstr(option,"C");
1122 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
1125 Int_t buffersize = 4000;
1126 char branchname[30];
1127 const char *det[3] = {"SPD","SDD","SSD"};
1131 // one branch for Clusters per type of detector
1133 for (i=0; i<kNTYPES ;i++) {
1134 AliITSDetType *iDetType=DetType(i);
1135 iDetType->GetClassNames(digclass,clclass);
1137 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1138 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1139 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1140 if (fCtype && fTreeC) {
1141 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1142 } // end if fCtype && fTreeC
1145 //______________________________________________________________________
1146 void AliITS::GetTreeC(Int_t event){
1147 // get the clusters tree for this event and set the branch address
1149 char branchname[30];
1150 const char *det[3] = {"SPD","SDD","SSD"};
1157 sprintf(treeName,"TreeC%d",event);
1158 fTreeC = (TTree*)gDirectory->Get(treeName);
1166 for (i=0; i<kNTYPES; i++) {
1167 AliITSDetType *iDetType=DetType(i);
1168 iDetType->GetClassNames(digclass,clclass);
1170 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1171 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1172 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1174 branch = fTreeC->GetBranch(branchname);
1175 if (branch) branch->SetAddress(&((*fCtype)[i]));
1179 Error("AliITS::GetTreeC",
1180 "cannot find Clusters Tree for event:%d\n",event);
1183 //______________________________________________________________________
1184 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1185 // add a cluster to the list
1187 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1191 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1194 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1197 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1201 //______________________________________________________________________
1202 void AliITS::ResetClusters(){
1203 // Reset number of clusters and the clusters array for ITS
1206 for (i=0;i<kNTYPES;i++ ) {
1207 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1208 if (fNctype) fNctype[i]=0;
1211 //______________________________________________________________________
1212 void AliITS::ResetClusters(Int_t i){
1213 // Reset number of clusters and the clusters array for this branch
1215 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1216 if (fNctype) fNctype[i]=0;
1218 //______________________________________________________________________
1219 void AliITS::MakeBranchR(const char *file){
1220 // Creates Tree branches for the ITS Reconstructed points.
1221 Int_t buffersize = 4000;
1222 char branchname[30];
1224 // sprintf(branchname,"%s",GetName());
1225 // only one branch for rec points for all detector types
1226 sprintf(branchname,"%sRecPoints",GetName());
1227 if (fRecPoints && gAlice->TreeR()) {
1228 MakeBranchInTree(gAlice->TreeR(),branchname, &fRecPoints,
1232 //______________________________________________________________________
1233 void AliITS::SetTreeAddressR(TTree *treeR){
1234 // Set branch address for the Reconstructed points Trees.
1235 char branchname[30];
1239 // sprintf(branchname,"%s",GetName());
1240 sprintf(branchname,"%sRecPoints",GetName());
1241 branch = treeR->GetBranch(branchname);
1242 if (branch) branch->SetAddress(&fRecPoints);
1244 //______________________________________________________________________
1245 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1246 // Add a reconstructed space point to the list
1248 TClonesArray &lrecp = *fRecPoints;
1249 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1251 //______________________________________________________________________
1252 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1253 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1254 // keep galice.root for signal and name differently the file for
1255 // background when add! otherwise the track info for signal will be lost !
1256 // the condition below will disappear when the geom class will be
1257 // initialised for all versions - for the moment it is only for v5 !
1258 /* Int_t ver = this->IsVersion();
1259 if(ver!=5 && ver!=8 && ver!=9) return;
1261 if(!GetITSgeom()) return;
1262 AliITSgeom *geom = GetITSgeom();
1264 const char *all = strstr(opt1,"All");
1265 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1266 strstr(opt1,"SSD")};
1268 InitModules(size,nmodules);
1269 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1271 AliITSsimulation *sim = 0;
1272 AliITSDetType *iDetType = 0;
1273 AliITSmodule *mod = 0;
1276 //m.b. : this change is nothing but a nice way to make sure
1278 for(module=0;module<geom->GetIndexMax();module++){
1279 id = geom->GetModuleType(module);
1280 if (!all && !det[id]) continue;
1281 iDetType = DetType(id);
1282 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1284 Error("HitsToFastPoints",
1285 "The simulation class was not instantiated!");
1288 mod = (AliITSmodule *)fITSmodules->At(module);
1289 sim->CreateFastRecPoints(mod,module,gRandom);
1290 gAlice->TreeR()->Fill();
1295 for (id=0;id<kNTYPES;id++) {
1296 if (!all && !det[id]) continue;
1297 AliITSDetType *iDetType=DetType(id);
1298 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1300 Error("HitsToFastPoints",
1301 "The simulation class was not instantiated!");
1306 first = geom->GetStartDet(id);
1307 last = geom->GetLastDet(id);
1308 } else first=last=0;
1309 for(module=first;module<=last;module++) {
1310 AliITSmodule *mod = (AliITSmodule *)fITSmodules->At(module);
1311 sim->CreateFastRecPoints(mod,module,gRandom);
1312 gAlice->TreeR()->Fill();
1314 } // loop over modules
1315 } // loop over detector types
1320 sprintf(hname,"TreeR%d",evNumber);
1321 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1323 gAlice->TreeR()->Reset();
1325 //______________________________________________________________________
1326 void AliITS::Digits2Reco(){
1327 // find clusters and reconstruct space points
1329 AliHeader *header=gAlice->GetHeader();
1330 // to Digits to RecPoints for event in file, all digits in file, and
1331 // all ITS detectors.
1332 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1334 //______________________________________________________________________
1335 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1336 // cluster finding and reconstruction of space points
1337 // the condition below will disappear when the geom class will be
1338 // initialised for all versions - for the moment it is only for v5 !
1339 // 7 is the SDD beam test version
1340 /* Int_t ver = this->IsVersion();
1341 if(ver!=5 && ver!=8 && ver!=9) return;
1343 if(!GetITSgeom()) return;
1344 AliITSgeom *geom = GetITSgeom();
1346 const char *all = strstr(opt,"All");
1347 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1349 static Bool_t setRec=kTRUE;
1350 if (setRec) SetDefaultClusterFinders();
1353 TTree *treeC=TreeC();
1355 AliITSClusterFinder *rec = 0;
1356 AliITSDetType *iDetType = 0;
1357 Int_t id,module,first=0;
1358 for(module=0;module<geom->GetIndexMax();module++){
1359 id = geom->GetModuleType(module);
1360 if (!all && !det[id]) continue;
1361 if(det[id]) first = geom->GetStartDet(id);
1362 iDetType = DetType(id);
1363 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1364 TClonesArray *itsDigits = this->DigitsAddress(id);
1366 Error("DigitsToRecPoints",
1367 "The reconstruction class was not instantiated!");
1370 this->ResetDigits();
1371 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1372 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1373 Int_t ndigits = itsDigits->GetEntriesFast();
1374 if (ndigits) rec->FindRawClusters(module);
1375 gAlice->TreeR()->Fill();
1383 for (id=0;id<kNTYPES;id++) {
1384 if (!all && !det[id]) continue;
1385 AliITSDetType *iDetType=DetType(id);
1386 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1387 TClonesArray *itsDigits = this->DigitsAddress(id);
1390 first = geom->GetStartDet(id);
1391 last = geom->GetLastDet(id);
1392 } else first=last=0;
1393 printf("first module - last module %d %d\n",first,last);
1394 for(module=first;module<=last;module++) {
1395 this->ResetDigits();
1396 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1397 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1398 Int_t ndigits = itsDigits->GetEntriesFast();
1399 if (ndigits) rec->FindRawClusters(module);
1400 gAlice->TreeR()->Fill();
1404 } // loop over modules
1405 } // loop over detector types
1407 gAlice->TreeR()->GetEntries();
1408 treeC->GetEntries();
1411 sprintf(hname,"TreeR%d",evNumber);
1412 gAlice->TreeR()->Write(hname,TObject::kOverwrite);
1414 gAlice->TreeR()->Reset();
1416 sprintf(hname,"TreeC%d",evNumber);
1417 treeC->Write(hname,TObject::kOverwrite);
1420 //______________________________________________________________________
1421 void AliITS::ResetRecPoints(){
1422 // Reset number of rec points and the rec points array
1424 if (fRecPoints) fRecPoints->Clear();