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 **************************************************************************/
19 ///////////////////////////////////////////////////////////////////////////////
21 // An overview of the basic philosophy of the ITS code development
22 // and analysis is show in the figure below.
25 <img src="picts/ITS/ITS_Analysis_schema.gif">
28 <font size=+2 color=red>
29 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
30 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
36 // AliITS. Inner Traking System base class.
37 // This class contains the base procedures for the Inner Tracking System
41 <img src="picts/ITS/AliITS_Class_Diagram.gif">
44 <font size=+2 color=red>
45 <p>This show the class diagram of the different elements that are part of
53 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
56 // Modified and documented by Bjorn S. Nilsen
60 // Modified and documented by A. Bologna
63 // AliITS is the general base class for the ITS. Also see AliDetector for
64 // futher information.
66 ///////////////////////////////////////////////////////////////////////////////
68 #include <Riostream.h>
72 #include <TClonesArray.h>
75 #include <TObjectTable.h>
81 #include <TVirtualMC.h>
83 #include "AliConfig.h"
84 #include "AliHeader.h"
86 #include "AliITSClusterFinderSDD.h"
87 #include "AliITSClusterFinderSPD.h"
88 #include "AliITSClusterFinderSSD.h"
89 #include "AliITSDetType.h"
90 #include "AliITSLoader.h"
91 #include "AliITSRawClusterSPD.h"
92 #include "AliITSRawClusterSDD.h"
93 #include "AliITSRawClusterSSD.h"
94 #include "AliITSRecPoint.h"
95 #include "AliITSdigitSPD.h"
96 #include "AliITSdigitSDD.h"
97 #include "AliITSdigitSSD.h"
98 #include "AliITSgeom.h"
99 #include "AliITShit.h"
100 #include "AliITSmodule.h"
101 #include "AliITSpList.h"
102 #include "AliITSresponseSDD.h"
103 #include "AliITSresponseSPD.h"
104 #include "AliITSresponseSSD.h"
105 #include "AliITSsegmentationSDD.h"
106 #include "AliITSsegmentationSPD.h"
107 #include "AliITSsegmentationSSD.h"
108 #include "AliITSsimulationSDD.h"
109 #include "AliITSsimulationSPD.h"
110 #include "AliITSsimulationSSD.h"
112 #include "AliITSDigitizer.h"
113 #include "AliITSclustererV2.h"
114 #include "AliITStrackerV2.h"
115 #include "AliITSpidESD.h"
116 #include "AliV0vertexer.h"
117 #include "AliCascadeVertexer.h"
122 //______________________________________________________________________
123 AliITS::AliITS() : AliDetector() {
124 // Default initializer for ITS
125 // The default constructor of the AliITS class. In addition to
126 // creating the AliITS class it zeros the variables fIshunt (a member
127 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
128 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
137 fIshunt = 0; // not zeroed in AliDetector.
144 // SetDetectors(); // default to fOpt="All". This variable not written out.
150 fNDetTypes = kNTYPES;
165 SetMarkerColor(kRed);
167 //______________________________________________________________________
168 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
169 // The standard Constructor for the ITS class. In addition to
170 // creating the AliITS class, it allocates memory for the TClonesArrays
171 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
172 // (clusters). It also zeros the variables
173 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
174 // the pointers fIdSens and fIdName. To help in displaying hits via the
175 // ROOT macro display.C AliITS also sets the marker color to red. The
176 // variables passes with this constructor, const char *name and *title,
177 // are used by the constructor of AliDetector class. See AliDetector
178 // class for a description of these parameters and its constructor
181 // const char *name Detector name. Should always be "ITS"
182 // const char *title Detector title.
188 fIshunt = 0; // not zeroed in AliDetector
189 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
190 gAlice->GetMCApp()->AddHitList(fHits); // Not done in AliDetector.
195 SetDetectors(); // default to fOpt="All". This variable not written out.
201 fNDetTypes = kNTYPES;
202 fDetTypes = new TObjArray(fNDetTypes);
204 fSDigits = new TClonesArray("AliITSpListItem",1000);
207 fNdtype = new Int_t[fNDetTypes];
208 fDtype = new TObjArray(fNDetTypes);
210 fCtype = new TObjArray(fNDetTypes);
211 fNctype = new Int_t[fNDetTypes];
213 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
217 for(i=0;i<fNDetTypes;i++) {
218 fDetTypes->AddAt(new AliITSDetType(),i);
223 SetMarkerColor(kRed);
226 //______________________________________________________________________
228 // Default destructor for ITS.
229 // The default destructor of the AliITS class. In addition to deleting
230 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
231 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
232 // fITSpoints, fDetType and it's contents.
256 fRecPoints->Delete();
260 delete[] fIdName; // Array of TStrings
263 this->ClearModules();
266 }// end if fITSmodules!=0
284 } // end if fDetTypes
287 if (fITSgeom) delete fITSgeom;
289 //______________________________________________________________________
290 AliITS::AliITS(const AliITS &source) : AliDetector(source){
291 // Copy constructor. This is a function which is not allowed to be
292 // done to the ITS. It exits with an error.
294 // AliITS &source An AliITS class.
300 if(this==&source) return;
301 Error("Copy constructor",
302 "You are not allowed to make a copy of the AliITS");
305 //______________________________________________________________________
306 AliITS& AliITS::operator=(AliITS &source){
307 // Assignment operator. This is a function which is not allowed to be
308 // done to the ITS. It exits with an error.
310 // AliITS &source An AliITS class.
316 if(this==&source) return *this;
317 Error("operator=","You are not allowed to make a copy of the AliITS");
319 return *this; //fake return
321 //______________________________________________________________________
322 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t) const{
323 // Distance from mouse to ITS on the screen. Dummy routine
324 // A dummy routine used by the ROOT macro display.C to allow for the
325 // use of the mouse (pointing device) in the macro. In general this should
326 // never be called. If it is it returns the number 9999 for any value of
329 // Int_t Dummy screen coordinate.
330 // Int_t Dummy screen coordinate.
334 // Int_t Dummy = 9999 distance to ITS.
338 //______________________________________________________________________
340 // Initializer ITS after it has been built
341 // This routine initializes the AliITS class. It is intended to be
342 // called from the Init function in AliITSv?. Besides displaying a banner
343 // indicating that it has been called it initializes the array fIdSens
344 // and sets the default segmentation, response, digit and raw cluster
345 // classes therefore it should be called after a call to CreateGeometry.
356 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
358 //______________________________________________________________________
359 void AliITS::SetDefaults(){
360 // sets the default segmentation, response, digit and raw cluster classes.
368 if(fDebug) printf("%s: SetDefaults\n",ClassName());
370 AliITSDetType *iDetType;
374 if (!iDetType->GetSegmentationModel()) {
375 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
376 SetSegmentationModel(0,seg0);
378 if (!iDetType->GetResponseModel()) {
379 SetResponseModel(0,new AliITSresponseSPD());
381 // set digit and raw cluster classes to be used
383 const char *kData0=(iDetType->GetResponseModel())->DataType();
384 if (strstr(kData0,"real")) {
385 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
386 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
390 if (!iDetType->GetResponseModel()) {
391 SetResponseModel(1,new AliITSresponseSDD("simulated"));
393 AliITSresponse *resp1=iDetType->GetResponseModel();
394 if (!iDetType->GetSegmentationModel()) {
395 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
396 SetSegmentationModel(1,seg1);
398 const char *kData1=(iDetType->GetResponseModel())->DataType();
399 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
400 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
401 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
402 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
406 if (!iDetType->GetSegmentationModel()) {
407 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
408 SetSegmentationModel(2,seg2);
410 if (!iDetType->GetResponseModel()) {
411 SetResponseModel(2,new AliITSresponseSSD("simulated"));
413 const char *kData2=(iDetType->GetResponseModel())->DataType();
414 if (strstr(kData2,"real")) {
415 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
416 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
419 Warning("SetDefaults",
420 "Only the three basic detector types are initialized!");
423 //______________________________________________________________________
424 void AliITS::SetDefaultSimulation(){
425 // sets the default simulation.
433 AliITSDetType *iDetType;
434 AliITSsimulation *sim;
436 sim = iDetType->GetSimulationModel();
438 AliITSsegmentation *seg0=
439 (AliITSsegmentation*)iDetType->GetSegmentationModel();
440 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
441 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
442 SetSimulationModel(0,sim0);
443 }else{ // simulation exists, make sure it is set up properly.
444 ((AliITSsimulationSPD*)sim)->Init(
445 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
446 (AliITSresponseSPD*) iDetType->GetResponseModel());
447 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
448 // (AliITSresponse*)iDetType->GetResponseModel());
449 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
450 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
453 sim = iDetType->GetSimulationModel();
455 AliITSsegmentation *seg1=
456 (AliITSsegmentation*)iDetType->GetSegmentationModel();
457 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
458 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
459 SetSimulationModel(1,sim1);
460 }else{ // simulation exists, make sure it is set up properly.
461 ((AliITSsimulationSDD*)sim)->Init(
462 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
463 (AliITSresponseSDD*) iDetType->GetResponseModel());
464 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
465 // (AliITSresponse*)iDetType->GetResponseModel());
466 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
467 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
470 sim = iDetType->GetSimulationModel();
472 AliITSsegmentation *seg2=
473 (AliITSsegmentation*)iDetType->GetSegmentationModel();
474 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
475 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
476 SetSimulationModel(2,sim2);
477 }else{ // simulation exists, make sure it is set up properly.
478 ((AliITSsimulationSSD*)sim)->Init(
479 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
480 (AliITSresponseSSD*) iDetType->GetResponseModel());
481 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
482 // (AliITSresponse*)iDetType->GetResponseModel());
483 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
484 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
487 //______________________________________________________________________
488 void AliITS::SetDefaultClusterFinders(){
489 // Sets the default cluster finders. Used in finding RecPoints.
498 AliITSDetType *iDetType;
502 if (!iDetType->GetReconstructionModel()) {
503 AliITSsegmentation *seg0 =
504 (AliITSsegmentation*)iDetType->GetSegmentationModel();
505 TClonesArray *dig0=DigitsAddress(0);
506 TClonesArray *recp0=ClustersAddress(0);
507 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
509 SetReconstructionModel(0,rec0);
514 if (!iDetType->GetReconstructionModel()) {
515 AliITSsegmentation *seg1 =
516 (AliITSsegmentation*)iDetType->GetSegmentationModel();
517 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
518 TClonesArray *dig1=DigitsAddress(1);
519 TClonesArray *recp1=ClustersAddress(1);
520 AliITSClusterFinderSDD *rec1 =
521 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
522 SetReconstructionModel(1,rec1);
527 if (!iDetType->GetReconstructionModel()) {
528 AliITSsegmentation *seg2=
529 (AliITSsegmentation*)iDetType->GetSegmentationModel();
530 TClonesArray *dig2=DigitsAddress(2);
531 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
532 SetReconstructionModel(2,rec2);
535 //______________________________________________________________________
536 void AliITS::MakeBranch(Option_t* option){
537 // Creates Tree branches for the ITS.
539 // Option_t *option String of Tree types S,D, and/or R.
540 // const char *file String of the file name where these branches
541 // are to be stored. If blank then these branches
542 // are written to the same tree as the Hits were
548 Bool_t cH = (strstr(option,"H")!=0);
549 Bool_t cS = (strstr(option,"S")!=0);
550 Bool_t cD = (strstr(option,"D")!=0);
551 Bool_t cR = (strstr(option,"R")!=0);
552 Bool_t cRF = (strstr(option,"RF")!=0);
555 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
557 AliDetector::MakeBranch(option);
559 if(cS) MakeBranchS(0);
560 if(cD) MakeBranchD(0);
561 if(cR) MakeBranchR(0);
562 if(cRF) MakeBranchRF(0);
564 //______________________________________________________________________
565 void AliITS::SetTreeAddress(){
566 // Set branch address for the Trees.
573 TTree *treeS = fLoader->TreeS();
574 TTree *treeD = fLoader->TreeD();
575 TTree *treeR = fLoader->TreeR();
576 if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
578 AliDetector::SetTreeAddress();
580 SetTreeAddressS(treeS);
581 SetTreeAddressD(treeD);
582 SetTreeAddressR(treeR);
584 //______________________________________________________________________
585 AliITSDetType* AliITS::DetType(Int_t id){
586 // Return pointer to id detector type.
588 // Int_t id detector id number.
592 // returned, a pointer to a AliITSDetType.
594 return ((AliITSDetType*) fDetTypes->At(id));
596 //______________________________________________________________________
597 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
598 // Set the response model for the id detector type.
600 // Int_t id detector id number.
601 // AliITSresponse* a pointer containing an instance of AliITSresponse
602 // to be stored/owned b y AliITSDetType.
608 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
610 //______________________________________________________________________
611 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
612 // Set the segmentation model for the id detector type.
614 // Int_t id detector id number.
615 // AliITSsegmentation* a pointer containing an instance of
616 // AliITSsegmentation to be stored/owned b y
623 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
625 //______________________________________________________________________
626 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
627 // Set the simulation model for the id detector type.
629 // Int_t id detector id number.
630 // AliITSresponse* a pointer containing an instance of AliITSresponse
631 // to be stored/owned b y AliITSDetType.
637 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
640 //______________________________________________________________________
641 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
642 // Set the cluster finder model for the id detector type.
644 // Int_t id detector id number.
645 // AliITSClusterFinder* a pointer containing an instance of
646 // AliITSClusterFinder to be stored/owned b y
653 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
655 //______________________________________________________________________
656 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
657 // Set the digit and cluster classes name to be used for the id detector
660 // Int_t id detector id number.
661 // const char *digit Digit class name for detector id.
662 // const char *cluster Cluster class name for detector id.
668 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
670 //______________________________________________________________________
671 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
673 // The function to add information to the AliITShit class. See the
674 // AliITShit class for a full description. This function allocates the
675 // necessary new space for the hit information and passes the variable
676 // track, and the pointers *vol and *hits to the AliITShit constructor
679 // Int_t track Track number which produced this hit.
680 // Int_t *vol Array of Integer Hit information. See AliITShit.h
681 // Float_t *hits Array of Floating Hit information. see AliITShit.h
687 TClonesArray &lhits = *fHits;
688 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
690 //______________________________________________________________________
691 void AliITS::InitModules(Int_t size,Int_t &nmodules){
692 // Initialize the modules array.
694 // Int_t size Size of array of the number of modules to be
695 // created. If size <=0 then the number of modules
696 // is gotten from AliITSgeom class kept in fITSgeom.
698 // Int_t &nmodules The number of modules existing.
703 fITSmodules->Delete();
705 } // end fir fITSmoudles
707 Int_t nl,indexMAX,index;
709 if(size<=0){ // default to using data stored in AliITSgeom
711 Error("InitModules","fITSgeom not defined");
713 } // end if fITSgeom==0
714 nl = fITSgeom->GetNlayers();
715 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
716 fITSgeom->GetNdetectors(nl))+1;
718 fITSmodules = new TObjArray(indexMAX);
719 for(index=0;index<indexMAX;index++){
720 fITSmodules->AddAt( new AliITSmodule(index),index);
723 fITSmodules = new TObjArray(size);
724 for(index=0;index<size;index++) {
725 fITSmodules->AddAt( new AliITSmodule(index),index);
731 //______________________________________________________________________
732 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
733 Option_t *option,Text_t *filename){
734 // fill the modules with the sorted by module hits; add hits from
735 // background if option=Add.
737 // Int_t evnt Event to be processed.
738 // Int_t bgrev Background Hit tree number.
739 // Int_t nmodules Not used.
740 // Option_t *option String indicating if merging hits or not. To
741 // merge hits set equal to "Add". Otherwise no
742 // background hits are considered.
743 // Test_t *filename File name containing the background hits..
748 static TTree *trH1; //Tree with background hits
749 static Bool_t first=kTRUE;
751 const char *addBgr = strstr(option,"Add");
753 evnt = nmodules; // Dummy use of variables to remove warnings
756 file=new TFile(filename);
761 // Get Hits Tree header from file
762 if(trH1) delete trH1;
766 sprintf(treeName,"TreeH%d",bgrev);
767 trH1 = (TTree*)gDirectory->Get(treeName);
769 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
771 // Set branch addresses
774 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
777 FillModules(trH1,10000000); // Default mask 10M.
778 TTree *fAli=fLoader->GetRunLoader()->TreeK();
780 if (fAli) fileAli =fAli->GetCurrentFile();
784 //______________________________________________________________________
785 void AliITS::FillModules(TTree *treeH, Int_t mask) {
786 // fill the modules with the sorted by module hits;
787 // can be called many times to do a merging
789 // TTree *treeH The tree containing the hits to be copied into
791 // Int_t mask The track number mask to indecate which file
792 // this hits came from.
800 Error("FillModules","Tree is NULL");
802 Int_t lay,lad,det,index;
806 sprintf(branchname,"%s",GetName());
807 TBranch *branch = treeH->GetBranch(branchname);
809 Error("FillModules","%s branch in TreeH not found",branchname);
812 branch->SetAddress(&fHits);
813 Int_t nTracks =(Int_t) treeH->GetEntries();
815 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
817 Int_t nBytes = treeH->GetEvent(iPrimTrack);
818 if (nBytes <= 0) continue;
819 Int_t nHits = fHits->GetEntriesFast();
820 for(h=0; h<nHits; h++){
821 itsHit = (AliITShit *)fHits->UncheckedAt(h);
822 itsHit->GetDetectorID(lay,lad,det);
824 index = fITSgeom->GetModuleIndex(lay,lad,det);
826 index=det-1; // This should not be used.
827 } // end if [You must have fITSgeom for this to work!]
828 mod = GetModule(index);
829 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
830 mod->AddHit(itsHit,iPrimTrack,h);
831 } // end loop over hits
832 } // end loop over tracks
834 //______________________________________________________________________
835 void AliITS::ClearModules(){
836 // Clear the modules TObjArray.
842 if(fITSmodules) fITSmodules->Delete();
844 //______________________________________________________________________
845 void AliITS::MakeBranchS(const char *fl){
846 // Creates Tree Branch for the ITS summable digits.
848 // cont char *fl File name where SDigits branch is to be written
849 // to. If blank it write the SDigits to the same
850 // file in which the Hits were found.
855 Int_t buffersize = 4000;
858 // only one branch for SDigits.
859 sprintf(branchname,"%s",GetName());
862 if(fLoader->TreeS()){
863 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
864 MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
867 //______________________________________________________________________
868 void AliITS::SetTreeAddressS(TTree *treeS){
869 // Set branch address for the ITS summable digits Trees.
871 // TTree *treeS Tree containing the SDigits.
879 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
881 sprintf(branchname,"%s",GetName());
882 branch = treeS->GetBranch(branchname);
883 if (branch) branch->SetAddress(&fSDigits);
885 //______________________________________________________________________
886 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
887 // Creates Tree branches for the ITS.
889 // TTree *treeD Pointer to the Digits Tree.
890 // cont char *file File name where Digits branch is to be written
891 // to. If blank it write the SDigits to the same
892 // file in which the Hits were found.
897 Int_t buffersize = 4000;
900 sprintf(branchname,"%s",GetName());
901 // one branch for digits per type of detector
902 const char *det[3] = {"SPD","SDD","SSD"};
906 for (i=0; i<kNTYPES ;i++) {
907 DetType(i)->GetClassNames(digclass,clclass);
909 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
910 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
913 for (i=0; i<kNTYPES ;i++) {
914 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
915 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
916 if (fDtype && treeD) {
917 MakeBranchInTree(treeD, branchname, &((*fDtype)[i]),buffersize,file);
921 //______________________________________________________________________
922 void AliITS::SetTreeAddressD(TTree *treeD){
923 // Set branch address for the Trees.
925 // TTree *treeD Tree containing the Digits.
931 const char *det[3] = {"SPD","SDD","SSD"};
938 for (i=0; i<kNTYPES; i++) {
939 DetType(i)->GetClassNames(digclass,clclass);
941 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
942 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
944 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
945 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
947 branch = treeD->GetBranch(branchname);
948 if (branch) branch->SetAddress(&((*fDtype)[i]));
952 //______________________________________________________________________
953 void AliITS::Hits2SDigits(){
954 // Standard Hits to summable Digits function.
960 // return; // Using Hits in place of the larger sDigits.
961 fLoader->LoadHits("read");
962 fLoader->LoadSDigits("recreate");
963 AliRunLoader* rl = fLoader->GetRunLoader();
965 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
966 // Do the Hits to Digits operation. Use Standard input values.
967 // Event number from file, no background hit merging , use size from
968 // AliITSgeom class, option="All", input from this file only.
969 rl->GetEvent(iEvent);
970 if (!fLoader->TreeS()) fLoader->MakeTree("S");
973 HitsToSDigits(iEvent,0,-1," ",fOpt," ");
976 fLoader->UnloadHits();
977 fLoader->UnloadSDigits();
979 //______________________________________________________________________
980 void AliITS::Hits2PreDigits(){
981 // Standard Hits to summable Digits function.
987 AliHeader *header=fLoader->GetRunLoader()->GetHeader(); // Get event number from this file.
988 // Do the Hits to Digits operation. Use Standard input values.
989 // Event number from file, no background hit merging , use size from
990 // AliITSgeom class, option="All", input from this file only.
991 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
993 //______________________________________________________________________
994 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager) const
996 return new AliITSDigitizer(manager);
998 //______________________________________________________________________
999 void AliITS::SDigitsToDigits(Option_t *opt){
1000 // Standard Summable digits to Digits function.
1005 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1007 if(!GetITSgeom()) return; // need transformations to do digitization.
1008 AliITSgeom *geom = GetITSgeom();
1010 const char *all = strstr(opt,"All");
1011 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1013 if( !det[0] && !det[1] && !det[2] ) all = "All";
1015 static Bool_t setDef=kTRUE;
1016 if (setDef) SetDefaultSimulation();
1019 AliITSsimulation *sim = 0;
1020 AliITSDetType *iDetType = 0;
1021 TTree *trees = fLoader->TreeS();
1022 if( !(trees && this->GetSDigits()) ){
1023 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1026 sprintf( name, "%s", this->GetName() );
1027 TBranch *brchSDigits = trees->GetBranch( name );
1030 for(module=0;module<geom->GetIndexMax();module++){
1031 id = geom->GetModuleType(module);
1032 if (!all && !det[id]) continue;
1033 iDetType = DetType(id);
1034 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1036 Error("SDigit2Digits",
1037 "The simulation class was not instanciated!");
1040 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1042 // add summable digits to module
1043 this->GetSDigits()->Clear();
1044 brchSDigits->GetEvent(module);
1045 sim->AddSDigitsToModule(GetSDigits(),0);
1047 // Digitise current module sum(SDigits)->Digits
1048 sim->FinishSDigitiseModule();
1050 // fills all branches - wasted disk space
1051 fLoader->TreeD()->Fill();
1052 this->ResetDigits();
1055 fLoader->TreeD()->GetEntries();
1057 fLoader->TreeD()->AutoSave();
1059 fLoader->TreeD()->Reset();
1062 //______________________________________________________________________
1063 void AliITS::Hits2Digits(){
1064 // Standard Hits to Digits function.
1070 fLoader->LoadHits("read");
1071 fLoader->LoadDigits("recreate");
1072 AliRunLoader* rl = fLoader->GetRunLoader();
1074 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
1075 // Do the Hits to Digits operation. Use Standard input values.
1076 // Event number from file, no background hit merging , use size from
1077 // AliITSgeom class, option="All", input from this file only.
1078 rl->GetEvent(iEvent);
1079 if (!fLoader->TreeD()) fLoader->MakeTree("D");
1082 HitsToDigits(iEvent,0,-1," ",fOpt," ");
1085 fLoader->UnloadHits();
1086 fLoader->UnloadDigits();
1088 //______________________________________________________________________
1089 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1090 Option_t *option, Option_t *opt,Text_t *filename){
1091 // keep galice.root for signal and name differently the file for
1092 // background when add! otherwise the track info for signal will be lost !
1093 // the condition below will disappear when the geom class will be
1094 // initialized for all versions - for the moment it is only for v5 !
1095 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1098 // Int_t evnt Event to be processed.
1099 // Int_t bgrev Background Hit tree number.
1100 // Int_t nmodules Not used.
1101 // Option_t *option String indicating if merging hits or not. To
1102 // merge hits set equal to "Add". Otherwise no
1103 // background hits are considered.
1104 // Test_t *filename File name containing the background hits..
1109 // return; // using Hits instead of the larger sdigits.
1111 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1113 //______________________________________________________________________
1114 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1115 Option_t *option, Option_t *opt,Text_t *filename){
1116 // Keep galice.root for signal and name differently the file for
1117 // background when add! otherwise the track info for signal will be lost !
1118 // the condition below will disappear when the geom class will be
1119 // initialized for all versions - for the moment it is only for v5 !
1120 // 7 is the SDD beam test version.
1122 // Int_t evnt Event to be processed.
1123 // Int_t bgrev Background Hit tree number.
1124 // Int_t nmodules Not used.
1125 // Option_t *option String indicating if merging hits or not. To
1126 // merge hits set equal to "Add". Otherwise no
1127 // background hits are considered.
1128 // Test_t *filename File name containing the background hits..
1134 if(!GetITSgeom()) return; // need transformations to do digitization.
1135 AliITSgeom *geom = GetITSgeom();
1137 const char *all = strstr(opt,"All");
1138 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1140 static Bool_t setDef=kTRUE;
1141 if (setDef) SetDefaultSimulation();
1145 InitModules(size,nmodules);
1146 FillModules(evNumber,bgrev,nmodules,option,filename);
1148 AliITSsimulation *sim = 0;
1149 AliITSDetType *iDetType = 0;
1150 AliITSmodule *mod = 0;
1152 for(module=0;module<geom->GetIndexMax();module++){
1153 id = geom->GetModuleType(module);
1154 if (!all && !det[id]) continue;
1155 iDetType = DetType(id);
1156 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1158 Error("HitsToSDigits",
1159 "The simulation class was not instanciated!");
1162 mod = (AliITSmodule *)fITSmodules->At(module);
1163 sim->SDigitiseModule(mod,module,evNumber);
1164 // fills all branches - wasted disk space
1165 fLoader->TreeS()->Fill();
1171 fLoader->TreeS()->GetEntries();
1172 fLoader->TreeS()->AutoSave();
1173 fLoader->WriteSDigits("OVERWRITE");
1175 fLoader->TreeS()->Reset();
1177 //______________________________________________________________________
1178 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1179 Option_t *option, Option_t *opt,Text_t *filename){
1180 // Keep galice.root for signal and name differently the file for
1181 // background when add! otherwise the track info for signal will be lost !
1182 // the condition below will disappear when the geom class will be
1183 // initialized for all versions - for the moment it is only for v5 !
1184 // 7 is the SDD beam test version.
1186 // Int_t evnt Event to be processed.
1187 // Int_t bgrev Background Hit tree number.
1188 // Int_t nmodules Not used.
1189 // Option_t *option String indicating if merging hits or not. To
1190 // merge hits set equal to "Add". Otherwise no
1191 // background hits are considered.
1192 // Test_t *filename File name containing the background hits..
1198 if(!GetITSgeom()) return; // need transformations to do digitization.
1199 AliITSgeom *geom = GetITSgeom();
1201 const char *all = strstr(opt,"All");
1202 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1204 static Bool_t setDef=kTRUE;
1205 if (setDef) SetDefaultSimulation();
1209 InitModules(size,nmodules);
1210 FillModules(evNumber,bgrev,nmodules,option,filename);
1212 AliITSsimulation *sim = 0;
1213 AliITSDetType *iDetType = 0;
1214 AliITSmodule *mod = 0;
1216 for(module=0;module<geom->GetIndexMax();module++){
1217 id = geom->GetModuleType(module);
1218 if (!all && !det[id]) continue;
1219 iDetType = DetType(id);
1220 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1222 Error("HitsToDigits",
1223 "The simulation class was not instanciated!");
1226 mod = (AliITSmodule *)fITSmodules->At(module);
1227 sim->DigitiseModule(mod,module,evNumber);
1228 // fills all branches - wasted disk space
1229 fLoader->TreeD()->Fill();
1235 fLoader->TreeD()->GetEntries();
1236 fLoader->TreeD()->AutoSave();
1238 fLoader->TreeD()->Reset();
1240 //______________________________________________________________________
1241 void AliITS::ResetSDigits(){
1242 // Reset the Summable Digits array.
1248 if (fSDigits) fSDigits->Clear();
1251 //______________________________________________________________________
1252 void AliITS::ResetDigits(){
1253 // Reset number of digits and the digits array for the ITS detector.
1259 if (!fDtype) return;
1262 for (i=0;i<kNTYPES;i++ ) {
1263 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1264 if (fNdtype) fNdtype[i]=0;
1267 //______________________________________________________________________
1268 void AliITS::ResetDigits(Int_t i){
1269 // Reset number of digits and the digits array for this branch.
1275 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1276 if (fNdtype) fNdtype[i]=0;
1278 //______________________________________________________________________
1279 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1280 // Adds the a module full of summable digits to the summable digits tree.
1282 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1288 TClonesArray &lsdig = *fSDigits;
1289 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1291 //______________________________________________________________________
1292 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1293 // Add a real digit - as coming from data.
1295 // Int_t id Detector type number.
1296 // Int_t *digits Integer array containing the digits info. See
1303 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1304 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1306 //______________________________________________________________________
1307 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1308 // Add a simulated digit.
1310 // Int_t id Detector type number.
1311 // AliITSdigit *d Digit to be added to the Digits Tree. See
1318 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1322 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1325 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1328 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1332 //______________________________________________________________________
1333 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1334 Int_t *hits,Float_t *charges){
1335 // Add a simulated digit to the list.
1337 // Int_t id Detector type number.
1338 // Float_t phys Physics indicator. See AliITSdigits.h
1339 // Int_t *digits Integer array containing the digits info. See
1341 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1342 // containing the track numbers that contributed to
1344 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1345 // containing the hit numbers, from AliITSmodule, that
1346 // contributed to this digit.
1347 // Float_t *charge Floating point array of the signals contributed
1348 // to this digit by each track.
1354 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1357 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1360 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1364 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1368 //______________________________________________________________________
1369 void AliITS::MakeTreeC(Option_t *option){
1370 // Create a separate tree to store the clusters.
1372 // Option_t *option string which must contain "C" otherwise
1373 // no Cluster Tree is created.
1379 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1381 if (pITSLoader == 0x0) {
1382 Error("MakeTreeC","fLoader == 0x0 option=%s",option);
1385 if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C");
1389 void AliITS::MakeBranchC()
1391 //Makes barnches in treeC
1392 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1393 if (pITSLoader == 0x0)
1395 Error("MakeTreeC","fLoader == 0x0");
1398 TTree * lTC = pITSLoader->TreeC();
1401 Error("MakeTreeC","Can not get TreeC from Loader");
1405 Int_t buffersize = 4000;
1406 char branchname[30];
1407 const char *det[3] = {"SPD","SDD","SSD"};
1411 // one branch for Clusters per type of detector
1413 for (i=0; i<kNTYPES ;i++)
1415 AliITSDetType *iDetType=DetType(i);
1416 iDetType->GetClassNames(digclass,clclass);
1418 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1419 if(!ClustersAddress(i))
1421 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1423 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1424 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1427 if (lTC->GetBranch(branchname))
1429 Warning("MakeBranchC","Branch %s alread exists in TreeC",branchname);
1433 Info("MakeBranchC","Creating branch %s in TreeC",branchname);
1434 lTC->Branch(branchname,&((*fCtype)[i]), buffersize);
1436 } // end if fCtype && lTC
1440 //______________________________________________________________________
1441 void AliITS::GetTreeC(Int_t event){
1442 // Get the clusters tree for this event and set the branch address.
1444 // Int_t event Event number for the cluster tree.
1449 char branchname[30];
1450 const char *det[3] = {"SPD","SDD","SSD"};
1452 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1453 TTree * lTC = pITSLoader->TreeC();
1457 pITSLoader->CleanRawClusters();
1467 for (i=0; i<kNTYPES; i++) {
1468 AliITSDetType *iDetType=DetType(i);
1469 iDetType->GetClassNames(digclass,clclass);
1471 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1472 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1473 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1474 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1476 branch = lTC->GetBranch(branchname);
1477 if (branch) branch->SetAddress(&((*fCtype)[i]));
1481 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1484 //______________________________________________________________________
1485 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1486 // Add a cluster to the list.
1488 // Int_t id Detector type number.
1489 // AliITSRawCluster *c Cluster class to be added to the tree of
1496 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1500 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1503 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1506 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1510 //______________________________________________________________________
1511 void AliITS::ResetClusters(){
1512 // Reset number of clusters and the clusters array for ITS.
1519 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1521 //______________________________________________________________________
1522 void AliITS::ResetClusters(Int_t i){
1523 // Reset number of clusters and the clusters array for this branch.
1525 // Int_t i Detector type number.
1531 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1532 if (fNctype) fNctype[i]=0;
1534 //______________________________________________________________________
1535 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1536 // Creates Tree branches for the ITS Reconstructed points.
1538 // cont char *file File name where RecPoints branch is to be written
1539 // to. If blank it write the SDigits to the same
1540 // file in which the Hits were found.
1545 Int_t buffsz = 4000;
1546 char branchname[30];
1548 // only one branch for rec points for all detector types
1549 Bool_t oFast= (strstr(opt,"Fast")!=0);
1551 sprintf(branchname,"%sRecPointsF",GetName());
1553 sprintf(branchname,"%sRecPoints",GetName());
1557 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1558 if (fLoader->TreeR()) {
1559 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1560 MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file);
1563 //______________________________________________________________________
1564 void AliITS::SetTreeAddressR(TTree *treeR){
1565 // Set branch address for the Reconstructed points Trees.
1567 // TTree *treeR Tree containing the RecPoints.
1572 char branchname[30];
1575 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1577 sprintf(branchname,"%sRecPoints",GetName());
1578 branch = treeR->GetBranch(branchname);
1580 branch->SetAddress(&fRecPoints);
1583 sprintf(branchname,"%sRecPointsF",GetName());
1584 branch = treeR->GetBranch(branchname);
1586 branch->SetAddress(&fRecPoints);
1590 //______________________________________________________________________
1591 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1592 // Add a reconstructed space point to the list
1594 // const AliITSRecPoint &r RecPoint class to be added to the tree
1595 // of reconstructed points TreeR.
1601 TClonesArray &lrecp = *fRecPoints;
1602 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1604 //______________________________________________________________________
1605 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1606 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1607 // keep galice.root for signal and name differently the file for
1608 // background when add! otherwise the track info for signal will be lost !
1609 // the condition below will disappear when the geom class will be
1610 // initialized for all versions - for the moment it is only for v5 !
1612 // Int_t evnt Event to be processed.
1613 // Int_t bgrev Background Hit tree number.
1614 // Int_t size Size used by InitModules. See InitModules.
1615 // Option_t *opt0 Option passed to FillModules. See FillModules.
1616 // Option_t *opt1 String indicating if merging hits or not. To
1617 // merge hits set equal to "Add". Otherwise no
1618 // background hits are considered.
1619 // Test_t *flnm File name containing the background hits..
1625 if(!GetITSgeom()) return;
1626 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1627 AliITSgeom *geom = GetITSgeom();
1629 const char *all = strstr(opt1,"All");
1630 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1631 strstr(opt1,"SSD")};
1633 InitModules(size,nmodules);
1634 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1636 AliITSsimulation *sim = 0;
1637 AliITSDetType *iDetType = 0;
1638 AliITSmodule *mod = 0;
1641 //m.b. : this change is nothing but a nice way to make sure
1644 cout<<"HitsToFastRecPoints: N mod = "<<geom->GetIndexMax()<<endl;
1646 for(module=0;module<geom->GetIndexMax();module++)
1648 id = geom->GetModuleType(module);
1649 if (!all && !det[id]) continue;
1650 iDetType = DetType(id);
1651 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1654 Error("HitsToFastPoints","The simulation class was not instanciated!");
1657 mod = (AliITSmodule *)fITSmodules->At(module);
1658 sim->CreateFastRecPoints(mod,module,gRandom);
1659 cout<<module<<"\r";fflush(0);
1660 //gAlice->TreeR()->Fill();
1661 TTree *lTR = pITSloader->TreeR();
1662 TBranch *br=lTR->GetBranch("ITSRecPointsF");
1669 fLoader->WriteRecPoints("OVERWRITE");
1671 //______________________________________________________________________
1672 void AliITS::Digits2Reco(){
1673 // Find clusters and reconstruct space points.
1679 AliHeader *header=fLoader->GetRunLoader()->GetHeader();
1680 // to Digits to RecPoints for event in file, all digits in file, and
1681 // all ITS detectors.
1682 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1684 //______________________________________________________________________
1685 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1686 // cluster finding and reconstruction of space points
1687 // the condition below will disappear when the geom class will be
1688 // initialized for all versions - for the moment it is only for v5 !
1689 // 7 is the SDD beam test version
1691 // Int_t evNumber Event number to be processed.
1692 // Int_t lastentry Offset for module when not all of the modules
1694 // Option_t *opt String indicating which ITS sub-detectors should
1695 // be processed. If ="All" then all of the ITS
1696 // sub detectors are processed.
1702 if(!GetITSgeom()) return;
1703 AliITSgeom *geom = GetITSgeom();
1705 const char *all = strstr(opt,"All");
1706 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1708 static Bool_t setRec=kTRUE;
1709 if (setRec) SetDefaultClusterFinders();
1712 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1713 TTree *treeC=pITSloader->TreeC();
1714 AliITSClusterFinder *rec = 0;
1715 AliITSDetType *iDetType = 0;
1716 Int_t id,module,first=0;
1717 for(module=0;module<geom->GetIndexMax();module++){
1718 id = geom->GetModuleType(module);
1719 if (!all && !det[id]) continue;
1720 if(det[id]) first = geom->GetStartDet(id);
1721 iDetType = DetType(id);
1722 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1723 TClonesArray *itsDigits = this->DigitsAddress(id);
1725 Error("DigitsToRecPoints",
1726 "The reconstruction class was not instanciated! event=%d",
1730 this->ResetDigits();
1731 TTree *lTD = pITSloader->TreeD();
1733 lTD->GetEvent(lastentry+module);
1735 lTD->GetEvent(lastentry+(module-first));
1737 Int_t ndigits = itsDigits->GetEntriesFast();
1738 if (ndigits) rec->FindRawClusters(module);
1739 pITSloader->TreeR()->Fill();
1746 pITSloader->WriteRecPoints("OVERWRITE");
1747 pITSloader->WriteRawClusters("OVERWRITE");
1749 //______________________________________________________________________
1750 void AliITS::ResetRecPoints(){
1751 // Reset number of rec points and the rec points array.
1757 if (fRecPoints) fRecPoints->Clear();
1760 //______________________________________________________________________
1761 AliLoader* AliITS::MakeLoader(const char* topfoldername)
1763 //builds ITSgetter (AliLoader type)
1764 //if detector wants to use castomized getter, it must overload this method
1766 Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",topfoldername);
1767 fLoader = new AliITSLoader(GetName(),topfoldername);
1772 //_____________________________________________________________________________
1773 void AliITS::Reconstruct() const
1775 // reconstruct clusters
1777 AliLoader* loader = GetLoader();
1778 loader->LoadRecPoints("recreate");
1779 loader->LoadDigits("read");
1781 AliITSclustererV2 clusterer(GetITSgeom());
1782 AliRunLoader* runLoader = loader->GetRunLoader();
1783 Int_t nEvents = runLoader->GetNumberOfEvents();
1785 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
1786 runLoader->GetEvent(iEvent);
1788 TTree* treeClusters = loader->TreeR();
1789 if (!treeClusters) {
1790 loader->MakeTree("R");
1791 treeClusters = loader->TreeR();
1793 TTree* treeDigits = loader->TreeD();
1795 Error("Reconstruct", "Can't get digits tree !");
1799 clusterer.Digits2Clusters(treeDigits, treeClusters);
1801 loader->WriteRecPoints("OVERWRITE");
1804 loader->UnloadRecPoints();
1805 loader->UnloadDigits();
1808 //_____________________________________________________________________________
1809 AliTracker* AliITS::CreateTracker() const
1811 // create an ITS tracker
1813 return new AliITStrackerV2(GetITSgeom());
1816 //_____________________________________________________________________________
1817 void AliITS::FillESD(AliESD* esd) const
1819 // make PID, find V0s and cascades
1821 Double_t parITS[] = {34., 0.15, 10.};
1822 AliITSpidESD itsPID(parITS);
1823 itsPID.MakePID(esd);
1826 Double_t cuts[]={33, // max. allowed chi2
1827 0.16,// min. allowed negative daughter's impact parameter
1828 0.05,// min. allowed positive daughter's impact parameter
1829 0.080,// max. allowed DCA between the daughter tracks
1830 0.998,// max. allowed cosine of V0's pointing angle
1831 0.9, // min. radius of the fiducial volume
1832 2.9 // max. radius of the fiducial volume
1834 AliV0vertexer vtxer(cuts);
1835 Double_t vtx[3], cvtx[6];
1836 esd->GetVertex(vtx, cvtx);
1837 vtxer.SetVertex(vtx);
1838 vtxer.Tracks2V0vertices(esd);
1841 Double_t cts[]={33., // max. allowed chi2
1842 0.05, // min. allowed V0 impact parameter
1843 0.008, // window around the Lambda mass
1844 0.035, // min. allowed bachelor's impact parameter
1845 0.10, // max. allowed DCA between a V0 and a track
1846 0.9985, //max. allowed cosine of the cascade pointing angle
1847 0.9, // min. radius of the fiducial volume
1848 2.9 // max. radius of the fiducial volume
1850 AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
1851 cvtxer.V0sTracks2CascadeVertices(esd);