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 "AliITStrackerSA.h"
116 #include "AliITSpidESD.h"
117 #include "AliV0vertexer.h"
118 #include "AliITSVertexerPPZ.h"
119 #include "AliITSVertexerFast.h"
120 #include "AliITSVertexerZ.h"
121 #include "AliITSVertexerIons.h"
122 #include "AliCascadeVertexer.h"
128 //______________________________________________________________________
129 AliITS::AliITS() : AliDetector() {
130 // Default initializer for ITS
131 // The default constructor of the AliITS class. In addition to
132 // creating the AliITS class it zeros the variables fIshunt (a member
133 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
134 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
143 fIshunt = 0; // not zeroed in AliDetector.
150 // SetDetectors(); // default to fOpt="All". This variable not written out.
156 fNDetTypes = kNTYPES;
171 SetMarkerColor(kRed);
174 //______________________________________________________________________
175 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
176 // The standard Constructor for the ITS class. In addition to
177 // creating the AliITS class, it allocates memory for the TClonesArrays
178 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
179 // (clusters). It also zeros the variables
180 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
181 // the pointers fIdSens and fIdName. To help in displaying hits via the
182 // ROOT macro display.C AliITS also sets the marker color to red. The
183 // variables passes with this constructor, const char *name and *title,
184 // are used by the constructor of AliDetector class. See AliDetector
185 // class for a description of these parameters and its constructor
188 // const char *name Detector name. Should always be "ITS"
189 // const char *title Detector title.
195 fIshunt = 0; // not zeroed in AliDetector
196 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
197 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);// Not done in AliDetector.
202 SetDetectors(); // default to fOpt="All". This variable not written out.
208 fNDetTypes = kNTYPES;
209 fDetTypes = new TObjArray(fNDetTypes);
211 fSDigits = new TClonesArray("AliITSpListItem",1000);
214 fNdtype = new Int_t[fNDetTypes];
215 fDtype = new TObjArray(fNDetTypes);
217 fCtype = new TObjArray(fNDetTypes);
218 fNctype = new Int_t[fNDetTypes];
220 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
224 for(i=0;i<fNDetTypes;i++) {
225 fDetTypes->AddAt(new AliITSDetType(),i);
230 SetMarkerColor(kRed);
233 //______________________________________________________________________
235 // Default destructor for ITS.
236 // The default destructor of the AliITS class. In addition to deleting
237 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
238 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
239 // fITSpoints, fDetType and it's contents.
263 fRecPoints->Delete();
267 delete[] fIdName; // Array of TStrings
270 this->ClearModules();
273 }// end if fITSmodules!=0
291 } // end if fDetTypes
294 if (fITSgeom) delete fITSgeom;
296 //______________________________________________________________________
297 AliITS::AliITS(const AliITS &source) : AliDetector(source){
298 // Copy constructor. This is a function which is not allowed to be
299 // done to the ITS. It exits with an error.
301 // AliITS &source An AliITS class.
307 if(this==&source) return;
308 Error("Copy constructor",
309 "You are not allowed to make a copy of the AliITS");
312 //______________________________________________________________________
313 AliITS& AliITS::operator=(AliITS &source){
314 // Assignment operator. This is a function which is not allowed to be
315 // done to the ITS. It exits with an error.
317 // AliITS &source An AliITS class.
323 if(this==&source) return *this;
324 Error("operator=","You are not allowed to make a copy of the AliITS");
326 return *this; //fake return
328 //______________________________________________________________________
329 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t) const{
330 // Distance from mouse to ITS on the screen. Dummy routine
331 // A dummy routine used by the ROOT macro display.C to allow for the
332 // use of the mouse (pointing device) in the macro. In general this should
333 // never be called. If it is it returns the number 9999 for any value of
336 // Int_t Dummy screen coordinate.
337 // Int_t Dummy screen coordinate.
341 // Int_t Dummy = 9999 distance to ITS.
345 //______________________________________________________________________
347 // Initializer ITS after it has been built
348 // This routine initializes the AliITS class. It is intended to be
349 // called from the Init function in AliITSv?. Besides displaying a banner
350 // indicating that it has been called it initializes the array fIdSens
351 // and sets the default segmentation, response, digit and raw cluster
352 // classes therefore it should be called after a call to CreateGeometry.
363 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
365 //______________________________________________________________________
366 void AliITS::SetDefaults(){
367 // sets the default segmentation, response, digit and raw cluster classes.
375 if(fDebug) printf("%s: SetDefaults\n",ClassName());
377 AliITSDetType *iDetType;
381 if (!iDetType->GetSegmentationModel()) {
382 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
383 SetSegmentationModel(0,seg0);
385 if (!iDetType->GetResponseModel()) {
386 SetResponseModel(0,new AliITSresponseSPD());
388 // set digit and raw cluster classes to be used
390 const char *kData0=(iDetType->GetResponseModel())->DataType();
391 if (strstr(kData0,"real")) {
392 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
393 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
397 if (!iDetType->GetResponseModel()) {
398 SetResponseModel(1,new AliITSresponseSDD("simulated"));
400 AliITSresponse *resp1=iDetType->GetResponseModel();
401 if (!iDetType->GetSegmentationModel()) {
402 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
403 SetSegmentationModel(1,seg1);
405 const char *kData1=(iDetType->GetResponseModel())->DataType();
406 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
407 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
408 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
409 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
413 if (!iDetType->GetSegmentationModel()) {
414 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
415 SetSegmentationModel(2,seg2);
417 if (!iDetType->GetResponseModel()) {
418 SetResponseModel(2,new AliITSresponseSSD("simulated"));
420 const char *kData2=(iDetType->GetResponseModel())->DataType();
421 if (strstr(kData2,"real")) {
422 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
423 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
426 Warning("SetDefaults",
427 "Only the three basic detector types are initialized!");
430 //______________________________________________________________________
431 void AliITS::SetDefaultSimulation(){
432 // sets the default simulation.
440 AliITSDetType *iDetType;
441 AliITSsimulation *sim;
443 sim = iDetType->GetSimulationModel();
445 AliITSsegmentation *seg0=
446 (AliITSsegmentation*)iDetType->GetSegmentationModel();
447 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
448 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
449 SetSimulationModel(0,sim0);
450 }else{ // simulation exists, make sure it is set up properly.
451 ((AliITSsimulationSPD*)sim)->Init(
452 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
453 (AliITSresponseSPD*) iDetType->GetResponseModel());
454 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
455 // (AliITSresponse*)iDetType->GetResponseModel());
456 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
457 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
460 sim = iDetType->GetSimulationModel();
462 AliITSsegmentation *seg1=
463 (AliITSsegmentation*)iDetType->GetSegmentationModel();
464 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
465 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
466 SetSimulationModel(1,sim1);
467 }else{ // simulation exists, make sure it is set up properly.
468 ((AliITSsimulationSDD*)sim)->Init(
469 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
470 (AliITSresponseSDD*) iDetType->GetResponseModel());
471 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
472 // (AliITSresponse*)iDetType->GetResponseModel());
473 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
474 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
477 sim = iDetType->GetSimulationModel();
479 AliITSsegmentation *seg2=
480 (AliITSsegmentation*)iDetType->GetSegmentationModel();
481 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
482 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
483 SetSimulationModel(2,sim2);
484 }else{ // simulation exists, make sure it is set up properly.
485 ((AliITSsimulationSSD*)sim)->Init(
486 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
487 (AliITSresponseSSD*) iDetType->GetResponseModel());
488 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
489 // (AliITSresponse*)iDetType->GetResponseModel());
490 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
491 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
494 //______________________________________________________________________
495 void AliITS::SetDefaultClusterFinders(){
496 // Sets the default cluster finders. Used in finding RecPoints.
505 AliITSDetType *iDetType;
509 if (!iDetType->GetReconstructionModel()) {
510 AliITSsegmentation *seg0 =
511 (AliITSsegmentation*)iDetType->GetSegmentationModel();
512 TClonesArray *dig0=DigitsAddress(0);
513 TClonesArray *recp0=ClustersAddress(0);
514 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
516 SetReconstructionModel(0,rec0);
521 if (!iDetType->GetReconstructionModel()) {
522 AliITSsegmentation *seg1 =
523 (AliITSsegmentation*)iDetType->GetSegmentationModel();
524 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
525 TClonesArray *dig1=DigitsAddress(1);
526 TClonesArray *recp1=ClustersAddress(1);
527 AliITSClusterFinderSDD *rec1 =
528 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
529 SetReconstructionModel(1,rec1);
534 if (!iDetType->GetReconstructionModel()) {
535 AliITSsegmentation *seg2=
536 (AliITSsegmentation*)iDetType->GetSegmentationModel();
537 TClonesArray *dig2=DigitsAddress(2);
538 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
539 SetReconstructionModel(2,rec2);
542 //______________________________________________________________________
543 void AliITS::MakeBranch(Option_t* option){
544 // Creates Tree branches for the ITS.
546 // Option_t *option String of Tree types S,D, and/or R.
547 // const char *file String of the file name where these branches
548 // are to be stored. If blank then these branches
549 // are written to the same tree as the Hits were
555 Bool_t cH = (strstr(option,"H")!=0);
556 Bool_t cS = (strstr(option,"S")!=0);
557 Bool_t cD = (strstr(option,"D")!=0);
558 Bool_t cR = (strstr(option,"R")!=0);
559 Bool_t cRF = (strstr(option,"RF")!=0);
562 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
564 AliDetector::MakeBranch(option);
566 if(cS) MakeBranchS(0);
567 if(cD) MakeBranchD(0);
568 if(cR) MakeBranchR(0);
569 if(cRF) MakeBranchRF(0);
571 //______________________________________________________________________
572 void AliITS::SetTreeAddress(){
573 // Set branch address for the Trees.
580 TTree *treeS = fLoader->TreeS();
581 TTree *treeD = fLoader->TreeD();
582 TTree *treeR = fLoader->TreeR();
583 if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
585 AliDetector::SetTreeAddress();
587 SetTreeAddressS(treeS);
588 SetTreeAddressD(treeD);
589 SetTreeAddressR(treeR);
591 //______________________________________________________________________
592 AliITSDetType* AliITS::DetType(Int_t id){
593 // Return pointer to id detector type.
595 // Int_t id detector id number.
599 // returned, a pointer to a AliITSDetType.
601 return ((AliITSDetType*) fDetTypes->At(id));
603 //______________________________________________________________________
604 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
605 // Set the response model for the id detector type.
607 // Int_t id detector id number.
608 // AliITSresponse* a pointer containing an instance of AliITSresponse
609 // to be stored/owned b y AliITSDetType.
615 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
617 //______________________________________________________________________
618 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
619 // Set the segmentation model for the id detector type.
621 // Int_t id detector id number.
622 // AliITSsegmentation* a pointer containing an instance of
623 // AliITSsegmentation to be stored/owned b y
630 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
632 //______________________________________________________________________
633 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
634 // Set the simulation model for the id detector type.
636 // Int_t id detector id number.
637 // AliITSresponse* a pointer containing an instance of AliITSresponse
638 // to be stored/owned b y AliITSDetType.
644 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
647 //______________________________________________________________________
648 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
649 // Set the cluster finder model for the id detector type.
651 // Int_t id detector id number.
652 // AliITSClusterFinder* a pointer containing an instance of
653 // AliITSClusterFinder to be stored/owned b y
660 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
662 //______________________________________________________________________
663 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
664 // Set the digit and cluster classes name to be used for the id detector
667 // Int_t id detector id number.
668 // const char *digit Digit class name for detector id.
669 // const char *cluster Cluster class name for detector id.
675 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
677 //______________________________________________________________________
678 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
680 // The function to add information to the AliITShit class. See the
681 // AliITShit class for a full description. This function allocates the
682 // necessary new space for the hit information and passes the variable
683 // track, and the pointers *vol and *hits to the AliITShit constructor
686 // Int_t track Track number which produced this hit.
687 // Int_t *vol Array of Integer Hit information. See AliITShit.h
688 // Float_t *hits Array of Floating Hit information. see AliITShit.h
694 TClonesArray &lhits = *fHits;
695 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
697 //______________________________________________________________________
698 void AliITS::InitModules(Int_t size,Int_t &nmodules){
699 // Initialize the modules array.
701 // Int_t size Size of array of the number of modules to be
702 // created. If size <=0 then the number of modules
703 // is gotten from AliITSgeom class kept in fITSgeom.
705 // Int_t &nmodules The number of modules existing.
710 fITSmodules->Delete();
712 } // end fir fITSmoudles
714 Int_t nl,indexMAX,index;
716 if(size<=0){ // default to using data stored in AliITSgeom
718 Error("InitModules","fITSgeom not defined");
720 } // end if fITSgeom==0
721 nl = fITSgeom->GetNlayers();
722 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
723 fITSgeom->GetNdetectors(nl))+1;
725 fITSmodules = new TObjArray(indexMAX);
726 for(index=0;index<indexMAX;index++){
727 fITSmodules->AddAt( new AliITSmodule(index),index);
730 fITSmodules = new TObjArray(size);
731 for(index=0;index<size;index++) {
732 fITSmodules->AddAt( new AliITSmodule(index),index);
738 //______________________________________________________________________
739 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
740 Option_t *option, const char *filename){
741 // fill the modules with the sorted by module hits; add hits from
742 // background if option=Add.
744 // Int_t evnt Event to be processed.
745 // Int_t bgrev Background Hit tree number.
746 // Int_t nmodules Not used.
747 // Option_t *option String indicating if merging hits or not. To
748 // merge hits set equal to "Add". Otherwise no
749 // background hits are considered.
750 // Test_t *filename File name containing the background hits..
755 static TTree *trH1; //Tree with background hits
756 static Bool_t first=kTRUE;
758 const char *addBgr = strstr(option,"Add");
760 evnt = nmodules; // Dummy use of variables to remove warnings
763 file=new TFile(filename);
768 // Get Hits Tree header from file
769 if(trH1) delete trH1;
773 sprintf(treeName,"TreeH%d",bgrev);
774 trH1 = (TTree*)gDirectory->Get(treeName);
776 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
778 // Set branch addresses
781 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
784 FillModules(trH1,10000000); // Default mask 10M.
785 TTree *fAli=fLoader->GetRunLoader()->TreeK();
787 if (fAli) fileAli =fAli->GetCurrentFile();
791 //______________________________________________________________________
792 void AliITS::FillModules(TTree *treeH, Int_t mask) {
793 // fill the modules with the sorted by module hits;
794 // can be called many times to do a merging
796 // TTree *treeH The tree containing the hits to be copied into
798 // Int_t mask The track number mask to indecate which file
799 // this hits came from.
807 Error("FillModules","Tree is NULL");
809 Int_t lay,lad,det,index;
813 sprintf(branchname,"%s",GetName());
814 TBranch *branch = treeH->GetBranch(branchname);
816 Error("FillModules","%s branch in TreeH not found",branchname);
819 branch->SetAddress(&fHits);
820 Int_t nTracks =(Int_t) treeH->GetEntries();
822 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
824 Int_t nBytes = treeH->GetEvent(iPrimTrack);
825 if (nBytes <= 0) continue;
826 Int_t nHits = fHits->GetEntriesFast();
827 for(h=0; h<nHits; h++){
828 itsHit = (AliITShit *)fHits->UncheckedAt(h);
829 itsHit->GetDetectorID(lay,lad,det);
831 index = fITSgeom->GetModuleIndex(lay,lad,det);
833 index=det-1; // This should not be used.
834 } // end if [You must have fITSgeom for this to work!]
835 mod = GetModule(index);
836 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
837 mod->AddHit(itsHit,iPrimTrack,h);
838 } // end loop over hits
839 } // end loop over tracks
841 //______________________________________________________________________
842 void AliITS::ClearModules(){
843 // Clear the modules TObjArray.
849 if(fITSmodules) fITSmodules->Delete();
851 //______________________________________________________________________
852 void AliITS::MakeBranchS(const char *fl){
853 // Creates Tree Branch for the ITS summable digits.
855 // cont char *fl File name where SDigits branch is to be written
856 // to. If blank it write the SDigits to the same
857 // file in which the Hits were found.
862 Int_t buffersize = 4000;
865 // only one branch for SDigits.
866 sprintf(branchname,"%s",GetName());
869 if(fLoader->TreeS()){
870 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
871 MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
874 //______________________________________________________________________
875 void AliITS::SetTreeAddressS(TTree *treeS){
876 // Set branch address for the ITS summable digits Trees.
878 // TTree *treeS Tree containing the SDigits.
886 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
888 sprintf(branchname,"%s",GetName());
889 branch = treeS->GetBranch(branchname);
890 if (branch) branch->SetAddress(&fSDigits);
892 //______________________________________________________________________
893 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
894 // Creates Tree branches for the ITS.
896 // TTree *treeD Pointer to the Digits Tree.
897 // cont char *file File name where Digits branch is to be written
898 // to. If blank it write the SDigits to the same
899 // file in which the Hits were found.
904 Int_t buffersize = 4000;
907 sprintf(branchname,"%s",GetName());
908 // one branch for digits per type of detector
909 const char *det[3] = {"SPD","SDD","SSD"};
913 for (i=0; i<kNTYPES ;i++) {
914 DetType(i)->GetClassNames(digclass,clclass);
916 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
917 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
920 for (i=0; i<kNTYPES ;i++) {
921 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
922 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
923 if (fDtype && treeD) {
924 MakeBranchInTree(treeD, branchname, &((*fDtype)[i]),buffersize,file);
928 //______________________________________________________________________
929 void AliITS::SetTreeAddressD(TTree *treeD){
930 // Set branch address for the Trees.
932 // TTree *treeD Tree containing the Digits.
938 const char *det[3] = {"SPD","SDD","SSD"};
945 for (i=0; i<kNTYPES; i++) {
946 DetType(i)->GetClassNames(digclass,clclass);
948 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
949 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
951 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
952 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
954 branch = treeD->GetBranch(branchname);
955 if (branch) branch->SetAddress(&((*fDtype)[i]));
959 //______________________________________________________________________
960 void AliITS::Hits2SDigits(){
961 // Standard Hits to summable Digits function.
967 // return; // Using Hits in place of the larger sDigits.
968 fLoader->LoadHits("read");
969 fLoader->LoadSDigits("recreate");
970 AliRunLoader* rl = fLoader->GetRunLoader();
972 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
973 // Do the Hits to Digits operation. Use Standard input values.
974 // Event number from file, no background hit merging , use size from
975 // AliITSgeom class, option="All", input from this file only.
976 rl->GetEvent(iEvent);
977 if (!fLoader->TreeS()) fLoader->MakeTree("S");
980 HitsToSDigits(iEvent,0,-1," ",fOpt," ");
983 fLoader->UnloadHits();
984 fLoader->UnloadSDigits();
986 //______________________________________________________________________
987 void AliITS::Hits2PreDigits(){
988 // Standard Hits to summable Digits function.
994 AliHeader *header=fLoader->GetRunLoader()->GetHeader(); // Get event number from this file.
995 // Do the Hits to Digits operation. Use Standard input values.
996 // Event number from file, no background hit merging , use size from
997 // AliITSgeom class, option="All", input from this file only.
998 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1000 //______________________________________________________________________
1001 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager) const
1003 return new AliITSDigitizer(manager);
1005 //______________________________________________________________________
1006 void AliITS::SDigitsToDigits(Option_t *opt){
1007 // Standard Summable digits to Digits function.
1012 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1014 if(!GetITSgeom()) return; // need transformations to do digitization.
1015 AliITSgeom *geom = GetITSgeom();
1017 const char *all = strstr(opt,"All");
1018 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1020 if( !det[0] && !det[1] && !det[2] ) all = "All";
1022 static Bool_t setDef=kTRUE;
1023 if (setDef) SetDefaultSimulation();
1026 AliITSsimulation *sim = 0;
1027 AliITSDetType *iDetType = 0;
1028 TTree *trees = fLoader->TreeS();
1029 if( !(trees && this->GetSDigits()) ){
1030 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1033 sprintf( name, "%s", this->GetName() );
1034 TBranch *brchSDigits = trees->GetBranch( name );
1037 for(module=0;module<geom->GetIndexMax();module++){
1038 id = geom->GetModuleType(module);
1039 if (!all && !det[id]) continue;
1040 iDetType = DetType(id);
1041 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1043 Error("SDigit2Digits",
1044 "The simulation class was not instanciated!");
1047 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1049 // add summable digits to module
1050 this->GetSDigits()->Clear();
1051 brchSDigits->GetEvent(module);
1052 sim->AddSDigitsToModule(GetSDigits(),0);
1054 // Digitise current module sum(SDigits)->Digits
1055 sim->FinishSDigitiseModule();
1057 // fills all branches - wasted disk space
1058 fLoader->TreeD()->Fill();
1059 this->ResetDigits();
1062 fLoader->TreeD()->GetEntries();
1064 fLoader->TreeD()->AutoSave();
1066 fLoader->TreeD()->Reset();
1069 //______________________________________________________________________
1070 void AliITS::Hits2Digits(){
1071 // Standard Hits to Digits function.
1077 fLoader->LoadHits("read");
1078 fLoader->LoadDigits("recreate");
1079 AliRunLoader* rl = fLoader->GetRunLoader();
1081 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
1082 // Do the Hits to Digits operation. Use Standard input values.
1083 // Event number from file, no background hit merging , use size from
1084 // AliITSgeom class, option="All", input from this file only.
1085 rl->GetEvent(iEvent);
1086 if (!fLoader->TreeD()) fLoader->MakeTree("D");
1089 HitsToDigits(iEvent,0,-1," ",fOpt," ");
1092 fLoader->UnloadHits();
1093 fLoader->UnloadDigits();
1095 //______________________________________________________________________
1096 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1097 Option_t *option, Option_t *opt, const char *filename){
1098 // keep galice.root for signal and name differently the file for
1099 // background when add! otherwise the track info for signal will be lost !
1100 // the condition below will disappear when the geom class will be
1101 // initialized for all versions - for the moment it is only for v5 !
1102 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1105 // Int_t evnt Event to be processed.
1106 // Int_t bgrev Background Hit tree number.
1107 // Int_t nmodules Not used.
1108 // Option_t *option String indicating if merging hits or not. To
1109 // merge hits set equal to "Add". Otherwise no
1110 // background hits are considered.
1111 // Test_t *filename File name containing the background hits..
1116 // return; // using Hits instead of the larger sdigits.
1118 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1120 //______________________________________________________________________
1121 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1122 Option_t *option, Option_t *opt, const char *filename){
1123 // Keep galice.root for signal and name differently the file for
1124 // background when add! otherwise the track info for signal will be lost !
1125 // the condition below will disappear when the geom class will be
1126 // initialized for all versions - for the moment it is only for v5 !
1127 // 7 is the SDD beam test version.
1129 // Int_t evnt Event to be processed.
1130 // Int_t bgrev Background Hit tree number.
1131 // Int_t nmodules Not used.
1132 // Option_t *option String indicating if merging hits or not. To
1133 // merge hits set equal to "Add". Otherwise no
1134 // background hits are considered.
1135 // Test_t *filename File name containing the background hits..
1141 if(!GetITSgeom()) return; // need transformations to do digitization.
1142 AliITSgeom *geom = GetITSgeom();
1144 const char *all = strstr(opt,"All");
1145 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1147 static Bool_t setDef=kTRUE;
1148 if (setDef) SetDefaultSimulation();
1152 InitModules(size,nmodules);
1153 FillModules(evNumber,bgrev,nmodules,option,filename);
1155 AliITSsimulation *sim = 0;
1156 AliITSDetType *iDetType = 0;
1157 AliITSmodule *mod = 0;
1159 for(module=0;module<geom->GetIndexMax();module++){
1160 id = geom->GetModuleType(module);
1161 if (!all && !det[id]) continue;
1162 iDetType = DetType(id);
1163 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1165 Error("HitsToSDigits",
1166 "The simulation class was not instanciated!");
1169 mod = (AliITSmodule *)fITSmodules->At(module);
1170 sim->SDigitiseModule(mod,module,evNumber);
1171 // fills all branches - wasted disk space
1172 fLoader->TreeS()->Fill();
1178 fLoader->TreeS()->GetEntries();
1179 fLoader->TreeS()->AutoSave();
1180 fLoader->WriteSDigits("OVERWRITE");
1182 fLoader->TreeS()->Reset();
1184 //______________________________________________________________________
1185 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1186 Option_t *option, Option_t *opt, const char *filename){
1187 // Keep galice.root for signal and name differently the file for
1188 // background when add! otherwise the track info for signal will be lost !
1189 // the condition below will disappear when the geom class will be
1190 // initialized for all versions - for the moment it is only for v5 !
1191 // 7 is the SDD beam test version.
1193 // Int_t evnt Event to be processed.
1194 // Int_t bgrev Background Hit tree number.
1195 // Int_t nmodules Not used.
1196 // Option_t *option String indicating if merging hits or not. To
1197 // merge hits set equal to "Add". Otherwise no
1198 // background hits are considered.
1199 // Test_t *filename File name containing the background hits..
1205 if(!GetITSgeom()) return; // need transformations to do digitization.
1206 AliITSgeom *geom = GetITSgeom();
1208 const char *all = strstr(opt,"All");
1209 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1211 static Bool_t setDef=kTRUE;
1212 if (setDef) SetDefaultSimulation();
1216 InitModules(size,nmodules);
1217 FillModules(evNumber,bgrev,nmodules,option,filename);
1219 AliITSsimulation *sim = 0;
1220 AliITSDetType *iDetType = 0;
1221 AliITSmodule *mod = 0;
1223 for(module=0;module<geom->GetIndexMax();module++){
1224 id = geom->GetModuleType(module);
1225 if (!all && !det[id]) continue;
1226 iDetType = DetType(id);
1227 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1229 Error("HitsToDigits",
1230 "The simulation class was not instanciated!");
1233 mod = (AliITSmodule *)fITSmodules->At(module);
1234 sim->DigitiseModule(mod,module,evNumber);
1235 // fills all branches - wasted disk space
1236 fLoader->TreeD()->Fill();
1242 fLoader->TreeD()->GetEntries();
1243 fLoader->TreeD()->AutoSave();
1245 fLoader->TreeD()->Reset();
1247 //______________________________________________________________________
1248 void AliITS::ResetSDigits(){
1249 // Reset the Summable Digits array.
1255 if (fSDigits) fSDigits->Clear();
1258 //______________________________________________________________________
1259 void AliITS::ResetDigits(){
1260 // Reset number of digits and the digits array for the ITS detector.
1266 if (!fDtype) return;
1269 for (i=0;i<kNTYPES;i++ ) {
1270 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1271 if (fNdtype) fNdtype[i]=0;
1274 //______________________________________________________________________
1275 void AliITS::ResetDigits(Int_t i){
1276 // Reset number of digits and the digits array for this branch.
1282 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1283 if (fNdtype) fNdtype[i]=0;
1285 //______________________________________________________________________
1286 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1287 // Adds the a module full of summable digits to the summable digits tree.
1289 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1295 TClonesArray &lsdig = *fSDigits;
1296 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1298 //______________________________________________________________________
1299 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1300 // Add a real digit - as coming from data.
1302 // Int_t id Detector type number.
1303 // Int_t *digits Integer array containing the digits info. See
1310 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1311 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1313 //______________________________________________________________________
1314 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1315 // Add a simulated digit.
1317 // Int_t id Detector type number.
1318 // AliITSdigit *d Digit to be added to the Digits Tree. See
1325 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1329 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1332 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1335 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1339 //______________________________________________________________________
1340 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1341 Int_t *hits,Float_t *charges){
1342 // Add a simulated digit to the list.
1344 // Int_t id Detector type number.
1345 // Float_t phys Physics indicator. See AliITSdigits.h
1346 // Int_t *digits Integer array containing the digits info. See
1348 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1349 // containing the track numbers that contributed to
1351 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1352 // containing the hit numbers, from AliITSmodule, that
1353 // contributed to this digit.
1354 // Float_t *charge Floating point array of the signals contributed
1355 // to this digit by each track.
1361 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1362 AliITSresponseSDD *resp = 0;
1365 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1368 resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel();
1369 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1373 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1377 //______________________________________________________________________
1378 void AliITS::MakeTreeC(Option_t *option){
1379 // Create a separate tree to store the clusters.
1381 // Option_t *option string which must contain "C" otherwise
1382 // no Cluster Tree is created.
1388 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1390 if (pITSLoader == 0x0) {
1391 Error("MakeTreeC","fLoader == 0x0 option=%s",option);
1394 if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C");
1398 void AliITS::MakeBranchC()
1400 //Makes barnches in treeC
1401 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1402 if (pITSLoader == 0x0)
1404 Error("MakeTreeC","fLoader == 0x0");
1407 TTree * lTC = pITSLoader->TreeC();
1410 Error("MakeTreeC","Can not get TreeC from Loader");
1414 Int_t buffersize = 4000;
1415 char branchname[30];
1416 const char *det[3] = {"SPD","SDD","SSD"};
1420 // one branch for Clusters per type of detector
1422 for (i=0; i<kNTYPES ;i++)
1424 AliITSDetType *iDetType=DetType(i);
1425 iDetType->GetClassNames(digclass,clclass);
1427 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1428 if(!ClustersAddress(i))
1430 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1432 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1433 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1436 if (lTC->GetBranch(branchname))
1438 Warning("MakeBranchC","Branch %s alread exists in TreeC",branchname);
1442 Info("MakeBranchC","Creating branch %s in TreeC",branchname);
1443 lTC->Branch(branchname,&((*fCtype)[i]), buffersize);
1445 } // end if fCtype && lTC
1449 //______________________________________________________________________
1450 void AliITS::GetTreeC(Int_t event){
1451 // Get the clusters tree for this event and set the branch address.
1453 // Int_t event Event number for the cluster tree.
1458 char branchname[30];
1459 const char *det[3] = {"SPD","SDD","SSD"};
1461 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1462 TTree * lTC = pITSLoader->TreeC();
1466 pITSLoader->CleanRawClusters();
1476 for (i=0; i<kNTYPES; i++) {
1477 AliITSDetType *iDetType=DetType(i);
1478 iDetType->GetClassNames(digclass,clclass);
1480 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1481 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1482 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1483 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1485 branch = lTC->GetBranch(branchname);
1486 if (branch) branch->SetAddress(&((*fCtype)[i]));
1490 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1493 //______________________________________________________________________
1494 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1495 // Add a cluster to the list.
1497 // Int_t id Detector type number.
1498 // AliITSRawCluster *c Cluster class to be added to the tree of
1505 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1509 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1512 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1515 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1519 //______________________________________________________________________
1520 void AliITS::ResetClusters(){
1521 // Reset number of clusters and the clusters array for ITS.
1528 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1530 //______________________________________________________________________
1531 void AliITS::ResetClusters(Int_t i){
1532 // Reset number of clusters and the clusters array for this branch.
1534 // Int_t i Detector type number.
1540 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1541 if (fNctype) fNctype[i]=0;
1543 //______________________________________________________________________
1544 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1545 // Creates Tree branches for the ITS Reconstructed points.
1547 // cont char *file File name where RecPoints branch is to be written
1548 // to. If blank it write the SDigits to the same
1549 // file in which the Hits were found.
1554 Int_t buffsz = 4000;
1555 char branchname[30];
1557 // only one branch for rec points for all detector types
1558 Bool_t oFast= (strstr(opt,"Fast")!=0);
1560 sprintf(branchname,"%sRecPointsF",GetName());
1562 sprintf(branchname,"%sRecPoints",GetName());
1566 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1567 if (fLoader->TreeR()) {
1568 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1569 MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file);
1572 //______________________________________________________________________
1573 void AliITS::SetTreeAddressR(TTree *treeR){
1574 // Set branch address for the Reconstructed points Trees.
1576 // TTree *treeR Tree containing the RecPoints.
1581 char branchname[30];
1584 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1586 sprintf(branchname,"%sRecPoints",GetName());
1587 branch = treeR->GetBranch(branchname);
1589 branch->SetAddress(&fRecPoints);
1592 sprintf(branchname,"%sRecPointsF",GetName());
1593 branch = treeR->GetBranch(branchname);
1595 branch->SetAddress(&fRecPoints);
1599 //______________________________________________________________________
1600 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1601 // Add a reconstructed space point to the list
1603 // const AliITSRecPoint &r RecPoint class to be added to the tree
1604 // of reconstructed points TreeR.
1610 TClonesArray &lrecp = *fRecPoints;
1611 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1613 //______________________________________________________________________
1614 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1615 Option_t *opt0,Option_t *opt1, const char *flnm){
1616 // keep galice.root for signal and name differently the file for
1617 // background when add! otherwise the track info for signal will be lost !
1618 // the condition below will disappear when the geom class will be
1619 // initialized for all versions - for the moment it is only for v5 !
1621 // Int_t evnt Event to be processed.
1622 // Int_t bgrev Background Hit tree number.
1623 // Int_t size Size used by InitModules. See InitModules.
1624 // Option_t *opt0 Option passed to FillModules. See FillModules.
1625 // Option_t *opt1 String indicating if merging hits or not. To
1626 // merge hits set equal to "Add". Otherwise no
1627 // background hits are considered.
1628 // Test_t *flnm File name containing the background hits..
1634 if(!GetITSgeom()) return;
1635 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1636 AliITSgeom *geom = GetITSgeom();
1638 const char *all = strstr(opt1,"All");
1639 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1640 strstr(opt1,"SSD")};
1642 InitModules(size,nmodules);
1643 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1645 AliITSsimulation *sim = 0;
1646 AliITSDetType *iDetType = 0;
1647 AliITSmodule *mod = 0;
1650 //m.b. : this change is nothing but a nice way to make sure
1653 cout<<"HitsToFastRecPoints: N mod = "<<geom->GetIndexMax()<<endl;
1655 for(module=0;module<geom->GetIndexMax();module++)
1657 id = geom->GetModuleType(module);
1658 if (!all && !det[id]) continue;
1659 iDetType = DetType(id);
1660 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1663 Error("HitsToFastPoints","The simulation class was not instanciated!");
1666 mod = (AliITSmodule *)fITSmodules->At(module);
1667 sim->CreateFastRecPoints(mod,module,gRandom);
1668 cout<<module<<"\r";fflush(0);
1669 //gAlice->TreeR()->Fill();
1670 TTree *lTR = pITSloader->TreeR();
1671 TBranch *br=lTR->GetBranch("ITSRecPointsF");
1678 fLoader->WriteRecPoints("OVERWRITE");
1680 //______________________________________________________________________
1681 void AliITS::Digits2Reco(){
1682 // Find clusters and reconstruct space points.
1688 AliHeader *header=fLoader->GetRunLoader()->GetHeader();
1689 // to Digits to RecPoints for event in file, all digits in file, and
1690 // all ITS detectors.
1691 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1693 //______________________________________________________________________
1694 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1695 // cluster finding and reconstruction of space points
1696 // the condition below will disappear when the geom class will be
1697 // initialized for all versions - for the moment it is only for v5 !
1698 // 7 is the SDD beam test version
1700 // Int_t evNumber Event number to be processed.
1701 // Int_t lastentry Offset for module when not all of the modules
1703 // Option_t *opt String indicating which ITS sub-detectors should
1704 // be processed. If ="All" then all of the ITS
1705 // sub detectors are processed.
1711 if(!GetITSgeom()) return;
1712 AliITSgeom *geom = GetITSgeom();
1714 const char *all = strstr(opt,"All");
1715 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1717 static Bool_t setRec=kTRUE;
1718 if (setRec) SetDefaultClusterFinders();
1721 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1722 TTree *treeC=pITSloader->TreeC();
1723 AliITSClusterFinder *rec = 0;
1724 AliITSDetType *iDetType = 0;
1725 Int_t id,module,first=0;
1726 for(module=0;module<geom->GetIndexMax();module++){
1727 id = geom->GetModuleType(module);
1728 if (!all && !det[id]) continue;
1729 if(det[id]) first = geom->GetStartDet(id);
1730 iDetType = DetType(id);
1731 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1732 TClonesArray *itsDigits = this->DigitsAddress(id);
1734 Error("DigitsToRecPoints",
1735 "The reconstruction class was not instanciated! event=%d",
1739 this->ResetDigits();
1740 TTree *lTD = pITSloader->TreeD();
1742 lTD->GetEvent(lastentry+module);
1744 lTD->GetEvent(lastentry+(module-first));
1746 Int_t ndigits = itsDigits->GetEntriesFast();
1747 if (ndigits) rec->FindRawClusters(module);
1748 pITSloader->TreeR()->Fill();
1755 pITSloader->WriteRecPoints("OVERWRITE");
1756 pITSloader->WriteRawClusters("OVERWRITE");
1758 //______________________________________________________________________
1759 void AliITS::ResetRecPoints(){
1760 // Reset number of rec points and the rec points array.
1766 if (fRecPoints) fRecPoints->Clear();
1769 //______________________________________________________________________
1770 AliLoader* AliITS::MakeLoader(const char* topfoldername)
1772 //builds ITSgetter (AliLoader type)
1773 //if detector wants to use castomized getter, it must overload this method
1775 Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",topfoldername);
1776 fLoader = new AliITSLoader(GetName(),topfoldername);
1781 //_____________________________________________________________________________
1782 void AliITS::Reconstruct() const
1784 // reconstruct clusters
1786 AliLoader* loader = GetLoader();
1787 loader->LoadRecPoints("recreate");
1788 loader->LoadDigits("read");
1790 AliITSclustererV2 clusterer(GetITSgeom());
1791 AliRunLoader* runLoader = loader->GetRunLoader();
1792 Int_t nEvents = runLoader->GetNumberOfEvents();
1793 runLoader->LoadKinematics();
1795 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
1796 runLoader->GetEvent(iEvent);
1798 TTree* treeClusters = loader->TreeR();
1799 if (!treeClusters) {
1800 loader->MakeTree("R");
1801 treeClusters = loader->TreeR();
1803 TTree* treeDigits = loader->TreeD();
1805 Error("Reconstruct", "Can't get digits tree !");
1809 clusterer.Digits2Clusters(treeDigits, treeClusters);
1811 loader->WriteRecPoints("OVERWRITE");
1814 loader->UnloadRecPoints();
1815 loader->UnloadDigits();
1818 //_____________________________________________________________________________
1819 AliTracker* AliITS::CreateTracker() const
1821 // create an ITS tracker
1823 return new AliITStrackerSA(GetITSgeom());
1825 //_____________________________________________________________________________
1826 AliVertexer* AliITS::CreateVertexer() const
1828 // create a ITS vertexer
1830 if(fSelectedVertexer.Contains("ions") || fSelectedVertexer.Contains("IONS")){
1831 Info("CreateVertexer","a AliITSVertexerIons object has been selected\n");
1832 return new AliITSVertexerIons("null");
1834 if(fSelectedVertexer.Contains("smear") || fSelectedVertexer.Contains("SMEAR")){
1835 Double_t smear[3]={0.005,0.005,0.01};
1836 Info("CreateVertexer","a AliITSVertexerFast object has been selected\n");
1837 return new AliITSVertexerFast(smear);
1839 if(fSelectedVertexer.Contains("ppz") || fSelectedVertexer.Contains("PPZ")){
1840 Info("CreateVertexer","a AliITSVertexerPPZ object has been selected\n");
1841 return new AliITSVertexerPPZ("null");
1843 // by default an AliITSVertexerZ object is instatiated
1844 Info("CreateVertexer","a AliITSVertexerZ object has been selected\n");
1845 return new AliITSVertexerZ("null");
1848 //_____________________________________________________________________________
1849 void AliITS::FillESD(AliESD* esd) const
1851 // make PID, find V0s and cascades
1853 Double_t parITS[] = {34., 0.15, 10.};
1854 AliITSpidESD itsPID(parITS);
1855 itsPID.MakePID(esd);
1858 Double_t cuts[]={33, // max. allowed chi2
1859 0.16,// min. allowed negative daughter's impact parameter
1860 0.05,// min. allowed positive daughter's impact parameter
1861 0.080,// max. allowed DCA between the daughter tracks
1862 0.998,// max. allowed cosine of V0's pointing angle
1863 0.9, // min. radius of the fiducial volume
1864 2.9 // max. radius of the fiducial volume
1866 AliV0vertexer vtxer(cuts);
1867 Double_t vtx[3], cvtx[6];
1868 esd->GetVertex()->GetXYZ(vtx);
1869 esd->GetVertex()->GetSigmaXYZ(cvtx);
1870 vtxer.SetVertex(vtx);
1871 vtxer.Tracks2V0vertices(esd);
1874 Double_t cts[]={33., // max. allowed chi2
1875 0.05, // min. allowed V0 impact parameter
1876 0.008, // window around the Lambda mass
1877 0.035, // min. allowed bachelor's impact parameter
1878 0.10, // max. allowed DCA between a V0 and a track
1879 0.9985, //max. allowed cosine of the cascade pointing angle
1880 0.9, // min. radius of the fiducial volume
1881 2.9 // max. radius of the fiducial volume
1883 AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
1884 cvtxer.V0sTracks2CascadeVertices(esd);