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(),
147 fSelectedVertexer(0){
148 // Default initializer for ITS
149 // The default constructor of the AliITS class. In addition to
150 // creating the AliITS class it zeros the variables fIshunt (a member
151 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
152 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
161 fIshunt = 0; // not zeroed in AliDetector.
164 // SetDetectors(); // default to fOpt="All". This variable not written out.
165 SetMarkerColor(kRed);
168 //______________________________________________________________________
169 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
187 fSelectedVertexer(0){
188 // The standard Constructor for the ITS class. In addition to
189 // creating the AliITS class, it allocates memory for the TClonesArrays
190 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
191 // (clusters). It also zeros the variables
192 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
193 // the pointers fIdSens and fIdName. To help in displaying hits via the
194 // ROOT macro display.C AliITS also sets the marker color to red. The
195 // variables passes with this constructor, const char *name and *title,
196 // are used by the constructor of AliDetector class. See AliDetector
197 // class for a description of these parameters and its constructor
200 // const char *name Detector name. Should always be "ITS"
201 // const char *title Detector title.
207 fIshunt = 0; // not zeroed in AliDetector
208 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
209 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);// Not done in AliDetector.
214 SetDetectors(); // default to fOpt="All". This variable not written out.
220 fNDetTypes = kNTYPES;
221 fDetTypes = new TObjArray(fNDetTypes);
223 fSDigits = new TClonesArray("AliITSpListItem",1000);
226 fNdtype = new Int_t[fNDetTypes];
227 fDtype = new TObjArray(fNDetTypes);
229 fCtype = new TObjArray(fNDetTypes);
230 fNctype = new Int_t[fNDetTypes];
232 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
236 for(i=0;i<fNDetTypes;i++) {
237 fDetTypes->AddAt(new AliITSDetType(),i);
242 SetMarkerColor(kRed);
245 //______________________________________________________________________
247 // Default destructor for ITS.
248 // The default destructor of the AliITS class. In addition to deleting
249 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
250 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
251 // fITSpoints, fDetType and it's contents.
275 fRecPoints->Delete();
279 delete[] fIdName; // Array of TStrings
282 this->ClearModules();
285 }// end if fITSmodules!=0
303 } // end if fDetTypes
306 if (fITSgeom) delete fITSgeom;
308 //______________________________________________________________________
309 AliITS::AliITS(const AliITS &source) : AliDetector(source){
310 // Copy constructor. This is a function which is not allowed to be
311 // done to the ITS. It exits with an error.
313 // AliITS &source An AliITS class.
319 if(this==&source) return;
320 Error("Copy constructor",
321 "You are not allowed to make a copy of the AliITS");
324 //______________________________________________________________________
325 AliITS& AliITS::operator=(AliITS &source){
326 // Assignment operator. This is a function which is not allowed to be
327 // done to the ITS. It exits with an error.
329 // AliITS &source An AliITS class.
335 if(this==&source) return *this;
336 Error("operator=","You are not allowed to make a copy of the AliITS");
338 return *this; //fake return
340 //______________________________________________________________________
341 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t) const{
342 // Distance from mouse to ITS on the screen. Dummy routine
343 // A dummy routine used by the ROOT macro display.C to allow for the
344 // use of the mouse (pointing device) in the macro. In general this should
345 // never be called. If it is it returns the number 9999 for any value of
348 // Int_t Dummy screen coordinate.
349 // Int_t Dummy screen coordinate.
353 // Int_t Dummy = 9999 distance to ITS.
357 //______________________________________________________________________
359 // Initializer ITS after it has been built
360 // This routine initializes the AliITS class. It is intended to be
361 // called from the Init function in AliITSv?. Besides displaying a banner
362 // indicating that it has been called it initializes the array fIdSens
363 // and sets the default segmentation, response, digit and raw cluster
364 // classes therefore it should be called after a call to CreateGeometry.
375 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
377 //______________________________________________________________________
378 void AliITS::SetDefaults(){
379 // sets the default segmentation, response, digit and raw cluster classes.
387 if(fDebug) printf("%s: SetDefaults\n",ClassName());
389 AliITSDetType *iDetType;
393 if (!iDetType->GetSegmentationModel()) {
394 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
395 SetSegmentationModel(0,seg0);
397 if (!iDetType->GetResponseModel()) {
398 SetResponseModel(0,new AliITSresponseSPD());
400 // set digit and raw cluster classes to be used
402 const char *kData0=(iDetType->GetResponseModel())->DataType();
403 if (strstr(kData0,"real")) {
404 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
405 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
409 if (!iDetType->GetResponseModel()) {
410 SetResponseModel(1,new AliITSresponseSDD("simulated"));
412 AliITSresponse *resp1=iDetType->GetResponseModel();
413 if (!iDetType->GetSegmentationModel()) {
414 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
415 SetSegmentationModel(1,seg1);
417 const char *kData1=(iDetType->GetResponseModel())->DataType();
418 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
419 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
420 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
421 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
425 if (!iDetType->GetSegmentationModel()) {
426 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
427 SetSegmentationModel(2,seg2);
429 if (!iDetType->GetResponseModel()) {
430 SetResponseModel(2,new AliITSresponseSSD("simulated"));
432 const char *kData2=(iDetType->GetResponseModel())->DataType();
433 if (strstr(kData2,"real")) {
434 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
435 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
438 Warning("SetDefaults",
439 "Only the three basic detector types are initialized!");
442 //______________________________________________________________________
443 void AliITS::SetDefaultSimulation(){
444 // sets the default simulation.
452 AliITSDetType *iDetType;
453 AliITSsimulation *sim;
455 sim = iDetType->GetSimulationModel();
457 AliITSsegmentation *seg0=
458 (AliITSsegmentation*)iDetType->GetSegmentationModel();
459 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
460 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
461 SetSimulationModel(0,sim0);
462 }else{ // simulation exists, make sure it is set up properly.
463 ((AliITSsimulationSPD*)sim)->Init(
464 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
465 (AliITSresponseSPD*) iDetType->GetResponseModel());
466 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
467 // (AliITSresponse*)iDetType->GetResponseModel());
468 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
469 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
472 sim = iDetType->GetSimulationModel();
474 AliITSsegmentation *seg1=
475 (AliITSsegmentation*)iDetType->GetSegmentationModel();
476 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
477 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
478 SetSimulationModel(1,sim1);
479 }else{ // simulation exists, make sure it is set up properly.
480 ((AliITSsimulationSDD*)sim)->Init(
481 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
482 (AliITSresponseSDD*) iDetType->GetResponseModel());
483 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
484 // (AliITSresponse*)iDetType->GetResponseModel());
485 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
486 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
489 sim = iDetType->GetSimulationModel();
491 AliITSsegmentation *seg2=
492 (AliITSsegmentation*)iDetType->GetSegmentationModel();
493 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
494 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
495 SetSimulationModel(2,sim2);
496 }else{ // simulation exists, make sure it is set up properly.
497 ((AliITSsimulationSSD*)sim)->Init(
498 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
499 (AliITSresponseSSD*) iDetType->GetResponseModel());
500 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
501 // (AliITSresponse*)iDetType->GetResponseModel());
502 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
503 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
506 //______________________________________________________________________
507 void AliITS::SetDefaultClusterFinders(){
508 // Sets the default cluster finders. Used in finding RecPoints.
517 AliITSDetType *iDetType;
521 if (!iDetType->GetReconstructionModel()) {
522 AliITSsegmentation *seg0 =
523 (AliITSsegmentation*)iDetType->GetSegmentationModel();
524 TClonesArray *dig0=DigitsAddress(0);
525 TClonesArray *recp0=ClustersAddress(0);
526 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
528 SetReconstructionModel(0,rec0);
533 if (!iDetType->GetReconstructionModel()) {
534 AliITSsegmentation *seg1 =
535 (AliITSsegmentation*)iDetType->GetSegmentationModel();
536 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
537 TClonesArray *dig1=DigitsAddress(1);
538 TClonesArray *recp1=ClustersAddress(1);
539 AliITSClusterFinderSDD *rec1 =
540 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
541 SetReconstructionModel(1,rec1);
546 if (!iDetType->GetReconstructionModel()) {
547 AliITSsegmentation *seg2=
548 (AliITSsegmentation*)iDetType->GetSegmentationModel();
549 TClonesArray *dig2=DigitsAddress(2);
550 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
551 SetReconstructionModel(2,rec2);
554 //______________________________________________________________________
555 void AliITS::MakeBranch(Option_t* option){
556 // Creates Tree branches for the ITS.
558 // Option_t *option String of Tree types S,D, and/or R.
559 // const char *file String of the file name where these branches
560 // are to be stored. If blank then these branches
561 // are written to the same tree as the Hits were
567 Bool_t cH = (strstr(option,"H")!=0);
568 Bool_t cS = (strstr(option,"S")!=0);
569 Bool_t cD = (strstr(option,"D")!=0);
570 Bool_t cR = (strstr(option,"R")!=0);
571 Bool_t cRF = (strstr(option,"RF")!=0);
574 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
576 AliDetector::MakeBranch(option);
578 if(cS) MakeBranchS(0);
579 if(cD) MakeBranchD(0);
580 if(cR) MakeBranchR(0);
581 if(cRF) MakeBranchRF(0);
583 //______________________________________________________________________
584 void AliITS::SetTreeAddress(){
585 // Set branch address for the Trees.
592 TTree *treeS = fLoader->TreeS();
593 TTree *treeD = fLoader->TreeD();
594 TTree *treeR = fLoader->TreeR();
595 if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
597 AliDetector::SetTreeAddress();
599 SetTreeAddressS(treeS);
600 SetTreeAddressD(treeD);
601 SetTreeAddressR(treeR);
603 //______________________________________________________________________
604 AliITSDetType* AliITS::DetType(Int_t id){
605 // Return pointer to id detector type.
607 // Int_t id detector id number.
611 // returned, a pointer to a AliITSDetType.
613 return ((AliITSDetType*) fDetTypes->At(id));
615 //______________________________________________________________________
616 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
617 // Set the response model for the id detector type.
619 // Int_t id detector id number.
620 // AliITSresponse* a pointer containing an instance of AliITSresponse
621 // to be stored/owned b y AliITSDetType.
627 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
629 //______________________________________________________________________
630 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
631 // Set the segmentation model for the id detector type.
633 // Int_t id detector id number.
634 // AliITSsegmentation* a pointer containing an instance of
635 // AliITSsegmentation to be stored/owned b y
642 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
644 //______________________________________________________________________
645 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
646 // Set the simulation model for the id detector type.
648 // Int_t id detector id number.
649 // AliITSresponse* a pointer containing an instance of AliITSresponse
650 // to be stored/owned b y AliITSDetType.
656 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
659 //______________________________________________________________________
660 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
661 // Set the cluster finder model for the id detector type.
663 // Int_t id detector id number.
664 // AliITSClusterFinder* a pointer containing an instance of
665 // AliITSClusterFinder to be stored/owned b y
672 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
674 //______________________________________________________________________
675 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
676 // Set the digit and cluster classes name to be used for the id detector
679 // Int_t id detector id number.
680 // const char *digit Digit class name for detector id.
681 // const char *cluster Cluster class name for detector id.
687 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
689 //______________________________________________________________________
690 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
692 // The function to add information to the AliITShit class. See the
693 // AliITShit class for a full description. This function allocates the
694 // necessary new space for the hit information and passes the variable
695 // track, and the pointers *vol and *hits to the AliITShit constructor
698 // Int_t track Track number which produced this hit.
699 // Int_t *vol Array of Integer Hit information. See AliITShit.h
700 // Float_t *hits Array of Floating Hit information. see AliITShit.h
706 TClonesArray &lhits = *fHits;
707 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
709 //______________________________________________________________________
710 void AliITS::InitModules(Int_t size,Int_t &nmodules){
711 // Initialize the modules array.
713 // Int_t size Size of array of the number of modules to be
714 // created. If size <=0 then the number of modules
715 // is gotten from AliITSgeom class kept in fITSgeom.
717 // Int_t &nmodules The number of modules existing.
722 fITSmodules->Delete();
724 } // end fir fITSmoudles
726 Int_t nl,indexMAX,index;
728 if(size<=0){ // default to using data stored in AliITSgeom
730 Error("InitModules","fITSgeom not defined");
732 } // end if fITSgeom==0
733 nl = fITSgeom->GetNlayers();
734 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
735 fITSgeom->GetNdetectors(nl))+1;
737 fITSmodules = new TObjArray(indexMAX);
738 for(index=0;index<indexMAX;index++){
739 fITSmodules->AddAt( new AliITSmodule(index),index);
742 fITSmodules = new TObjArray(size);
743 for(index=0;index<size;index++) {
744 fITSmodules->AddAt( new AliITSmodule(index),index);
750 //______________________________________________________________________
751 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
752 Option_t *option, const char *filename){
753 // fill the modules with the sorted by module hits; add hits from
754 // background if option=Add.
756 // Int_t evnt Event to be processed.
757 // Int_t bgrev Background Hit tree number.
758 // Int_t nmodules Not used.
759 // Option_t *option String indicating if merging hits or not. To
760 // merge hits set equal to "Add". Otherwise no
761 // background hits are considered.
762 // Test_t *filename File name containing the background hits..
767 static TTree *trH1; //Tree with background hits
768 static Bool_t first=kTRUE;
770 const char *addBgr = strstr(option,"Add");
772 evnt = nmodules; // Dummy use of variables to remove warnings
775 file=new TFile(filename);
780 // Get Hits Tree header from file
781 if(trH1) delete trH1;
785 sprintf(treeName,"TreeH%d",bgrev);
786 trH1 = (TTree*)gDirectory->Get(treeName);
788 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
790 // Set branch addresses
793 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
796 FillModules(trH1,10000000); // Default mask 10M.
797 TTree *fAli=fLoader->GetRunLoader()->TreeK();
799 if (fAli) fileAli =fAli->GetCurrentFile();
803 //______________________________________________________________________
804 void AliITS::FillModules(TTree *treeH, Int_t mask) {
805 // fill the modules with the sorted by module hits;
806 // can be called many times to do a merging
808 // TTree *treeH The tree containing the hits to be copied into
810 // Int_t mask The track number mask to indecate which file
811 // this hits came from.
819 Error("FillModules","Tree is NULL");
821 Int_t lay,lad,det,index;
825 sprintf(branchname,"%s",GetName());
826 TBranch *branch = treeH->GetBranch(branchname);
828 Error("FillModules","%s branch in TreeH not found",branchname);
831 branch->SetAddress(&fHits);
832 Int_t nTracks =(Int_t) treeH->GetEntries();
834 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
836 Int_t nBytes = treeH->GetEvent(iPrimTrack);
837 if (nBytes <= 0) continue;
838 Int_t nHits = fHits->GetEntriesFast();
839 for(h=0; h<nHits; h++){
840 itsHit = (AliITShit *)fHits->UncheckedAt(h);
841 itsHit->GetDetectorID(lay,lad,det);
843 index = fITSgeom->GetModuleIndex(lay,lad,det);
845 index=det-1; // This should not be used.
846 } // end if [You must have fITSgeom for this to work!]
847 mod = GetModule(index);
848 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
849 mod->AddHit(itsHit,iPrimTrack,h);
850 } // end loop over hits
851 } // end loop over tracks
853 //______________________________________________________________________
854 void AliITS::ClearModules(){
855 // Clear the modules TObjArray.
861 if(fITSmodules) fITSmodules->Delete();
863 //______________________________________________________________________
864 void AliITS::MakeBranchS(const char *fl){
865 // Creates Tree Branch for the ITS summable digits.
867 // cont char *fl File name where SDigits branch is to be written
868 // to. If blank it write the SDigits to the same
869 // file in which the Hits were found.
874 Int_t buffersize = 4000;
877 // only one branch for SDigits.
878 sprintf(branchname,"%s",GetName());
881 if(fLoader->TreeS()){
882 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
883 MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
886 //______________________________________________________________________
887 void AliITS::SetTreeAddressS(TTree *treeS){
888 // Set branch address for the ITS summable digits Trees.
890 // TTree *treeS Tree containing the SDigits.
898 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
900 sprintf(branchname,"%s",GetName());
901 branch = treeS->GetBranch(branchname);
902 if (branch) branch->SetAddress(&fSDigits);
904 //______________________________________________________________________
905 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
906 // Creates Tree branches for the ITS.
908 // TTree *treeD Pointer to the Digits Tree.
909 // cont char *file File name where Digits branch is to be written
910 // to. If blank it write the SDigits to the same
911 // file in which the Hits were found.
916 Int_t buffersize = 4000;
919 sprintf(branchname,"%s",GetName());
920 // one branch for digits per type of detector
921 const char *det[3] = {"SPD","SDD","SSD"};
925 for (i=0; i<kNTYPES ;i++) {
926 DetType(i)->GetClassNames(digclass,clclass);
928 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
929 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
932 for (i=0; i<kNTYPES ;i++) {
933 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
934 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
935 if (fDtype && treeD) {
936 MakeBranchInTree(treeD, branchname, &((*fDtype)[i]),buffersize,file);
940 //______________________________________________________________________
941 void AliITS::SetTreeAddressD(TTree *treeD){
942 // Set branch address for the Trees.
944 // TTree *treeD Tree containing the Digits.
950 const char *det[3] = {"SPD","SDD","SSD"};
957 for (i=0; i<kNTYPES; i++) {
958 DetType(i)->GetClassNames(digclass,clclass);
960 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
961 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
963 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
964 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
966 branch = treeD->GetBranch(branchname);
967 if (branch) branch->SetAddress(&((*fDtype)[i]));
971 //______________________________________________________________________
972 void AliITS::Hits2SDigits(){
973 // Standard Hits to summable Digits function.
979 // return; // Using Hits in place of the larger sDigits.
980 fLoader->LoadHits("read");
981 fLoader->LoadSDigits("recreate");
982 AliRunLoader* rl = fLoader->GetRunLoader();
984 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
985 // Do the Hits to Digits operation. Use Standard input values.
986 // Event number from file, no background hit merging , use size from
987 // AliITSgeom class, option="All", input from this file only.
988 rl->GetEvent(iEvent);
989 if (!fLoader->TreeS()) fLoader->MakeTree("S");
992 HitsToSDigits(iEvent,0,-1," ",fOpt," ");
995 fLoader->UnloadHits();
996 fLoader->UnloadSDigits();
998 //______________________________________________________________________
999 void AliITS::Hits2PreDigits(){
1000 // Standard Hits to summable Digits function.
1006 AliHeader *header=fLoader->GetRunLoader()->GetHeader(); // Get event number from this file.
1007 // Do the Hits to Digits operation. Use Standard input values.
1008 // Event number from file, no background hit merging , use size from
1009 // AliITSgeom class, option="All", input from this file only.
1010 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1012 //______________________________________________________________________
1013 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager) const
1015 return new AliITSDigitizer(manager);
1017 //______________________________________________________________________
1018 void AliITS::SDigitsToDigits(Option_t *opt){
1019 // Standard Summable digits to Digits function.
1024 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1026 if(!GetITSgeom()) return; // need transformations to do digitization.
1027 AliITSgeom *geom = GetITSgeom();
1029 const char *all = strstr(opt,"All");
1030 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1032 if( !det[0] && !det[1] && !det[2] ) all = "All";
1034 static Bool_t setDef=kTRUE;
1035 if (setDef) SetDefaultSimulation();
1038 AliITSsimulation *sim = 0;
1039 AliITSDetType *iDetType = 0;
1040 TTree *trees = fLoader->TreeS();
1041 if( !(trees && this->GetSDigits()) ){
1042 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1045 sprintf( name, "%s", this->GetName() );
1046 TBranch *brchSDigits = trees->GetBranch( name );
1049 for(module=0;module<geom->GetIndexMax();module++){
1050 id = geom->GetModuleType(module);
1051 if (!all && !det[id]) continue;
1052 iDetType = DetType(id);
1053 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1055 Error("SDigit2Digits","The simulation class was not "
1056 "instanciated for module %d type %s!",module,
1057 geom->GetModuleTypeName(module));
1060 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1062 // add summable digits to module
1063 this->GetSDigits()->Clear();
1064 brchSDigits->GetEvent(module);
1065 sim->AddSDigitsToModule(GetSDigits(),0);
1067 // Digitise current module sum(SDigits)->Digits
1068 sim->FinishSDigitiseModule();
1070 // fills all branches - wasted disk space
1071 fLoader->TreeD()->Fill();
1072 this->ResetDigits();
1075 fLoader->TreeD()->GetEntries();
1077 fLoader->TreeD()->AutoSave();
1079 fLoader->TreeD()->Reset();
1082 //______________________________________________________________________
1083 void AliITS::Hits2Digits(){
1084 // Standard Hits to Digits function.
1090 fLoader->LoadHits("read");
1091 fLoader->LoadDigits("recreate");
1092 AliRunLoader* rl = fLoader->GetRunLoader();
1094 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
1095 // Do the Hits to Digits operation. Use Standard input values.
1096 // Event number from file, no background hit merging , use size from
1097 // AliITSgeom class, option="All", input from this file only.
1098 rl->GetEvent(iEvent);
1099 if (!fLoader->TreeD()) fLoader->MakeTree("D");
1102 HitsToDigits(iEvent,0,-1," ",fOpt," ");
1105 fLoader->UnloadHits();
1106 fLoader->UnloadDigits();
1108 //______________________________________________________________________
1109 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1110 Option_t *option, Option_t *opt, const char *filename){
1111 // keep galice.root for signal and name differently the file for
1112 // background when add! otherwise the track info for signal will be lost !
1113 // the condition below will disappear when the geom class will be
1114 // initialized for all versions - for the moment it is only for v5 !
1115 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1118 // Int_t evnt Event to be processed.
1119 // Int_t bgrev Background Hit tree number.
1120 // Int_t nmodules Not used.
1121 // Option_t *option String indicating if merging hits or not. To
1122 // merge hits set equal to "Add". Otherwise no
1123 // background hits are considered.
1124 // Test_t *filename File name containing the background hits..
1129 // return; // using Hits instead of the larger sdigits.
1131 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1133 //______________________________________________________________________
1134 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1135 Option_t *option, Option_t *opt, const char *filename){
1136 // Keep galice.root for signal and name differently the file for
1137 // background when add! otherwise the track info for signal will be lost !
1138 // the condition below will disappear when the geom class will be
1139 // initialized for all versions - for the moment it is only for v5 !
1140 // 7 is the SDD beam test version.
1142 // Int_t evnt Event to be processed.
1143 // Int_t bgrev Background Hit tree number.
1144 // Int_t nmodules Not used.
1145 // Option_t *option String indicating if merging hits or not. To
1146 // merge hits set equal to "Add". Otherwise no
1147 // background hits are considered.
1148 // Test_t *filename File name containing the background hits..
1154 if(!GetITSgeom()) return; // need transformations to do digitization.
1155 AliITSgeom *geom = GetITSgeom();
1157 const char *all = strstr(opt,"All");
1158 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1160 static Bool_t setDef=kTRUE;
1161 if (setDef) SetDefaultSimulation();
1165 InitModules(size,nmodules);
1166 FillModules(evNumber,bgrev,nmodules,option,filename);
1168 AliITSsimulation *sim = 0;
1169 AliITSDetType *iDetType = 0;
1170 AliITSmodule *mod = 0;
1172 for(module=0;module<geom->GetIndexMax();module++){
1173 id = geom->GetModuleType(module);
1174 if (!all && !det[id]) continue;
1175 iDetType = DetType(id);
1176 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1178 Error("HitsToSDigits","The simulation class was not "
1179 "instanciated for module %d type %s!",module,
1180 geom->GetModuleTypeName(module));
1183 mod = (AliITSmodule *)fITSmodules->At(module);
1184 sim->SDigitiseModule(mod,module,evNumber);
1185 // fills all branches - wasted disk space
1186 fLoader->TreeS()->Fill();
1192 fLoader->TreeS()->GetEntries();
1193 fLoader->TreeS()->AutoSave();
1194 fLoader->WriteSDigits("OVERWRITE");
1196 fLoader->TreeS()->Reset();
1198 //______________________________________________________________________
1199 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1200 Option_t *option, Option_t *opt, const char *filename){
1201 // Keep galice.root for signal and name differently the file for
1202 // background when add! otherwise the track info for signal will be lost !
1203 // the condition below will disappear when the geom class will be
1204 // initialized for all versions - for the moment it is only for v5 !
1205 // 7 is the SDD beam test version.
1207 // Int_t evnt Event to be processed.
1208 // Int_t bgrev Background Hit tree number.
1209 // Int_t nmodules Not used.
1210 // Option_t *option String indicating if merging hits or not. To
1211 // merge hits set equal to "Add". Otherwise no
1212 // background hits are considered.
1213 // Test_t *filename File name containing the background hits..
1219 if(!GetITSgeom()) return; // need transformations to do digitization.
1220 AliITSgeom *geom = GetITSgeom();
1222 const char *all = strstr(opt,"All");
1223 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1225 static Bool_t setDef=kTRUE;
1226 if (setDef) SetDefaultSimulation();
1230 InitModules(size,nmodules);
1231 FillModules(evNumber,bgrev,nmodules,option,filename);
1233 AliITSsimulation *sim = 0;
1234 AliITSDetType *iDetType = 0;
1235 AliITSmodule *mod = 0;
1237 for(module=0;module<geom->GetIndexMax();module++){
1238 id = geom->GetModuleType(module);
1239 if (!all && !det[id]) continue;
1240 iDetType = DetType(id);
1241 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1243 Error("HitsToDigits","The simulation class was not "
1244 "instanciated for module %d type %s!",module,
1245 geom->GetModuleTypeName(module));
1248 mod = (AliITSmodule *)fITSmodules->At(module);
1249 sim->DigitiseModule(mod,module,evNumber);
1250 // fills all branches - wasted disk space
1251 fLoader->TreeD()->Fill();
1257 fLoader->TreeD()->GetEntries();
1258 fLoader->TreeD()->AutoSave();
1260 fLoader->TreeD()->Reset();
1262 //______________________________________________________________________
1263 void AliITS::ResetSDigits(){
1264 // Reset the Summable Digits array.
1270 if (fSDigits) fSDigits->Clear();
1273 //______________________________________________________________________
1274 void AliITS::ResetDigits(){
1275 // Reset number of digits and the digits array for the ITS detector.
1281 if (!fDtype) return;
1284 for (i=0;i<kNTYPES;i++ ) {
1285 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1286 if (fNdtype) fNdtype[i]=0;
1289 //______________________________________________________________________
1290 void AliITS::ResetDigits(Int_t i){
1291 // Reset number of digits and the digits array for this branch.
1297 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1298 if (fNdtype) fNdtype[i]=0;
1300 //______________________________________________________________________
1301 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1302 // Adds the a module full of summable digits to the summable digits tree.
1304 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1310 TClonesArray &lsdig = *fSDigits;
1311 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1313 //______________________________________________________________________
1314 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1315 // Add a real digit - as coming from data.
1317 // Int_t id Detector type number.
1318 // Int_t *digits Integer array containing the digits info. See
1325 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1326 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1328 //______________________________________________________________________
1329 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1330 // Add a simulated digit.
1332 // Int_t id Detector type number.
1333 // AliITSdigit *d Digit to be added to the Digits Tree. See
1340 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1344 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1347 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1350 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1354 //______________________________________________________________________
1355 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1356 Int_t *hits,Float_t *charges){
1357 // Add a simulated digit to the list.
1359 // Int_t id Detector type number.
1360 // Float_t phys Physics indicator. See AliITSdigits.h
1361 // Int_t *digits Integer array containing the digits info. See
1363 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1364 // containing the track numbers that contributed to
1366 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1367 // containing the hit numbers, from AliITSmodule, that
1368 // contributed to this digit.
1369 // Float_t *charge Floating point array of the signals contributed
1370 // to this digit by each track.
1376 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1377 AliITSresponseSDD *resp = 0;
1380 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1383 resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel();
1384 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1388 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1392 //______________________________________________________________________
1393 void AliITS::MakeTreeC(Option_t *option){
1394 // Create a separate tree to store the clusters.
1396 // Option_t *option string which must contain "C" otherwise
1397 // no Cluster Tree is created.
1403 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1405 if (pITSLoader == 0x0) {
1406 Error("MakeTreeC","fLoader == 0x0 option=%s",option);
1409 if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C");
1413 void AliITS::MakeBranchC()
1415 //Makes barnches in treeC
1416 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1417 if (pITSLoader == 0x0)
1419 Error("MakeTreeC","fLoader == 0x0");
1422 TTree * lTC = pITSLoader->TreeC();
1425 Error("MakeTreeC","Can not get TreeC from Loader");
1429 Int_t buffersize = 4000;
1430 char branchname[30];
1431 const char *det[3] = {"SPD","SDD","SSD"};
1435 // one branch for Clusters per type of detector
1437 for (i=0; i<kNTYPES ;i++)
1439 AliITSDetType *iDetType=DetType(i);
1440 iDetType->GetClassNames(digclass,clclass);
1442 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1443 if(!ClustersAddress(i))
1445 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1447 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1448 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1451 if (lTC->GetBranch(branchname))
1453 Warning("MakeBranchC","Branch %s alread exists in TreeC",branchname);
1457 Info("MakeBranchC","Creating branch %s in TreeC",branchname);
1458 lTC->Branch(branchname,&((*fCtype)[i]), buffersize);
1460 } // end if fCtype && lTC
1464 //______________________________________________________________________
1465 void AliITS::GetTreeC(Int_t event){
1466 // Get the clusters tree for this event and set the branch address.
1468 // Int_t event Event number for the cluster tree.
1473 char branchname[30];
1474 const char *det[3] = {"SPD","SDD","SSD"};
1476 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1477 TTree * lTC = pITSLoader->TreeC();
1481 pITSLoader->CleanRawClusters();
1491 for (i=0; i<kNTYPES; i++) {
1492 AliITSDetType *iDetType=DetType(i);
1493 iDetType->GetClassNames(digclass,clclass);
1495 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1496 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1497 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1498 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1500 branch = lTC->GetBranch(branchname);
1501 if (branch) branch->SetAddress(&((*fCtype)[i]));
1505 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1508 //______________________________________________________________________
1509 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1510 // Add a cluster to the list.
1512 // Int_t id Detector type number.
1513 // AliITSRawCluster *c Cluster class to be added to the tree of
1520 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1524 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1527 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1530 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1534 //______________________________________________________________________
1535 void AliITS::ResetClusters(){
1536 // Reset number of clusters and the clusters array for ITS.
1543 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1545 //______________________________________________________________________
1546 void AliITS::ResetClusters(Int_t i){
1547 // Reset number of clusters and the clusters array for this branch.
1549 // Int_t i Detector type number.
1555 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1556 if (fNctype) fNctype[i]=0;
1558 //______________________________________________________________________
1559 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1560 // Creates Tree branches for the ITS Reconstructed points.
1562 // cont char *file File name where RecPoints branch is to be written
1563 // to. If blank it write the SDigits to the same
1564 // file in which the Hits were found.
1569 Int_t buffsz = 4000;
1570 char branchname[30];
1572 // only one branch for rec points for all detector types
1573 Bool_t oFast= (strstr(opt,"Fast")!=0);
1575 sprintf(branchname,"%sRecPointsF",GetName());
1577 sprintf(branchname,"%sRecPoints",GetName());
1581 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1582 if (fLoader->TreeR()) {
1583 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1584 MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file);
1587 //______________________________________________________________________
1588 void AliITS::SetTreeAddressR(TTree *treeR){
1589 // Set branch address for the Reconstructed points Trees.
1591 // TTree *treeR Tree containing the RecPoints.
1596 char branchname[30];
1599 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1601 sprintf(branchname,"%sRecPoints",GetName());
1602 branch = treeR->GetBranch(branchname);
1604 branch->SetAddress(&fRecPoints);
1607 sprintf(branchname,"%sRecPointsF",GetName());
1608 branch = treeR->GetBranch(branchname);
1610 branch->SetAddress(&fRecPoints);
1614 //______________________________________________________________________
1615 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1616 // Add a reconstructed space point to the list
1618 // const AliITSRecPoint &r RecPoint class to be added to the tree
1619 // of reconstructed points TreeR.
1625 TClonesArray &lrecp = *fRecPoints;
1626 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1628 //______________________________________________________________________
1629 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1630 Option_t *opt0,Option_t *opt1, const char *flnm){
1631 // keep galice.root for signal and name differently the file for
1632 // background when add! otherwise the track info for signal will be lost !
1633 // the condition below will disappear when the geom class will be
1634 // initialized for all versions - for the moment it is only for v5 !
1636 // Int_t evnt Event to be processed.
1637 // Int_t bgrev Background Hit tree number.
1638 // Int_t size Size used by InitModules. See InitModules.
1639 // Option_t *opt0 Option passed to FillModules. See FillModules.
1640 // Option_t *opt1 String indicating if merging hits or not. To
1641 // merge hits set equal to "Add". Otherwise no
1642 // background hits are considered.
1643 // Test_t *flnm File name containing the background hits..
1649 if(!GetITSgeom()) return;
1650 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1651 AliITSgeom *geom = GetITSgeom();
1653 const char *all = strstr(opt1,"All");
1654 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1655 strstr(opt1,"SSD")};
1657 InitModules(size,nmodules);
1658 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1660 AliITSsimulation *sim = 0;
1661 AliITSDetType *iDetType = 0;
1662 AliITSmodule *mod = 0;
1665 //m.b. : this change is nothing but a nice way to make sure
1668 cout<<"HitsToFastRecPoints: N mod = "<<geom->GetIndexMax()<<endl;
1670 for(module=0;module<geom->GetIndexMax();module++){
1671 id = geom->GetModuleType(module);
1672 if (!all && !det[id]) continue;
1673 iDetType = DetType(id);
1674 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1677 Error("HitsToFastPoints","The simulation class was not "
1678 "instanciated for module %d type %x!",module,
1679 geom->GetModuleTypeName(module));
1682 mod = (AliITSmodule *)fITSmodules->At(module);
1683 sim->CreateFastRecPoints(mod,module,gRandom);
1684 cout<<module<<"\r";fflush(0);
1685 //gAlice->TreeR()->Fill();
1686 TTree *lTR = pITSloader->TreeR();
1687 TBranch *br=lTR->GetBranch("ITSRecPointsF");
1694 fLoader->WriteRecPoints("OVERWRITE");
1696 //______________________________________________________________________
1697 void AliITS::Digits2Reco(){
1698 // Find clusters and reconstruct space points.
1704 AliHeader *header=fLoader->GetRunLoader()->GetHeader();
1705 // to Digits to RecPoints for event in file, all digits in file, and
1706 // all ITS detectors.
1707 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1709 //______________________________________________________________________
1710 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1711 // cluster finding and reconstruction of space points
1712 // the condition below will disappear when the geom class will be
1713 // initialized for all versions - for the moment it is only for v5 !
1714 // 7 is the SDD beam test version
1716 // Int_t evNumber Event number to be processed.
1717 // Int_t lastentry Offset for module when not all of the modules
1719 // Option_t *opt String indicating which ITS sub-detectors should
1720 // be processed. If ="All" then all of the ITS
1721 // sub detectors are processed.
1727 if(!GetITSgeom()) return;
1728 AliITSgeom *geom = GetITSgeom();
1730 const char *all = strstr(opt,"All");
1731 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1733 static Bool_t setRec=kTRUE;
1734 if (setRec) SetDefaultClusterFinders();
1737 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1738 TTree *treeC=pITSloader->TreeC();
1739 AliITSClusterFinder *rec = 0;
1740 AliITSDetType *iDetType = 0;
1741 Int_t id,module,first=0;
1742 for(module=0;module<geom->GetIndexMax();module++){
1743 id = geom->GetModuleType(module);
1744 if (!all && !det[id]) continue;
1745 if(det[id]) first = geom->GetStartDet(id);
1746 iDetType = DetType(id);
1747 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1748 TClonesArray *itsDigits = this->DigitsAddress(id);
1750 Error("DigitsToRecPoints",
1751 "The reconstruction class was not instanciated! event=%d",
1755 this->ResetDigits();
1756 TTree *lTD = pITSloader->TreeD();
1758 lTD->GetEvent(lastentry+module);
1760 lTD->GetEvent(lastentry+(module-first));
1762 Int_t ndigits = itsDigits->GetEntriesFast();
1763 if (ndigits) rec->FindRawClusters(module);
1764 pITSloader->TreeR()->Fill();
1771 pITSloader->WriteRecPoints("OVERWRITE");
1772 pITSloader->WriteRawClusters("OVERWRITE");
1774 //______________________________________________________________________
1775 void AliITS::ResetRecPoints(){
1776 // Reset number of rec points and the rec points array.
1782 if (fRecPoints) fRecPoints->Clear();
1785 //______________________________________________________________________
1786 AliLoader* AliITS::MakeLoader(const char* topfoldername)
1788 //builds ITSgetter (AliLoader type)
1789 //if detector wants to use castomized getter, it must overload this method
1791 Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",topfoldername);
1792 fLoader = new AliITSLoader(GetName(),topfoldername);
1797 //_____________________________________________________________________________
1798 void AliITS::Reconstruct() const
1800 // reconstruct clusters
1802 AliLoader* loader = GetLoader();
1803 loader->LoadRecPoints("recreate");
1804 loader->LoadDigits("read");
1806 AliITSclustererV2 clusterer(GetITSgeom());
1807 AliRunLoader* runLoader = loader->GetRunLoader();
1808 Int_t nEvents = runLoader->GetNumberOfEvents();
1809 runLoader->LoadKinematics();
1811 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
1812 runLoader->GetEvent(iEvent);
1814 TTree* treeClusters = loader->TreeR();
1815 if (!treeClusters) {
1816 loader->MakeTree("R");
1817 treeClusters = loader->TreeR();
1819 TTree* treeDigits = loader->TreeD();
1821 Error("Reconstruct", "Can't get digits tree !");
1825 clusterer.Digits2Clusters(treeDigits, treeClusters);
1827 loader->WriteRecPoints("OVERWRITE");
1830 loader->UnloadRecPoints();
1831 loader->UnloadDigits();
1834 //_____________________________________________________________________________
1835 AliTracker* AliITS::CreateTracker() const
1837 // create an ITS tracker
1839 return new AliITStrackerSA(GetITSgeom());
1841 //_____________________________________________________________________________
1842 AliVertexer* AliITS::CreateVertexer() const
1844 // create a ITS vertexer
1846 if(fSelectedVertexer.Contains("ions") || fSelectedVertexer.Contains("IONS")){
1847 Info("CreateVertexer","a AliITSVertexerIons object has been selected\n");
1848 return new AliITSVertexerIons("null");
1850 if(fSelectedVertexer.Contains("smear") || fSelectedVertexer.Contains("SMEAR")){
1851 Double_t smear[3]={0.005,0.005,0.01};
1852 Info("CreateVertexer","a AliITSVertexerFast object has been selected\n");
1853 return new AliITSVertexerFast(smear);
1855 if(fSelectedVertexer.Contains("ppz") || fSelectedVertexer.Contains("PPZ")){
1856 Info("CreateVertexer","a AliITSVertexerPPZ object has been selected\n");
1857 return new AliITSVertexerPPZ("null");
1859 // by default an AliITSVertexerZ object is instatiated
1860 Info("CreateVertexer","a AliITSVertexerZ object has been selected\n");
1861 return new AliITSVertexerZ("null");
1864 //_____________________________________________________________________________
1865 void AliITS::FillESD(AliESD* esd) const
1867 // make PID, find V0s and cascades
1869 Double_t parITS[] = {34., 0.15, 10.};
1870 AliITSpidESD itsPID(parITS);
1871 itsPID.MakePID(esd);
1874 Double_t cuts[]={33, // max. allowed chi2
1875 0.16,// min. allowed negative daughter's impact parameter
1876 0.05,// min. allowed positive daughter's impact parameter
1877 0.08,// max. allowed DCA between the daughter tracks
1878 0.99,// max. allowed cosine of V0's pointing angle
1879 0.9, // min. radius of the fiducial volume
1880 2.9 // max. radius of the fiducial volume
1882 AliV0vertexer vtxer(cuts);
1883 Double_t vtx[3], cvtx[6];
1884 esd->GetVertex()->GetXYZ(vtx);
1885 esd->GetVertex()->GetSigmaXYZ(cvtx);
1886 vtxer.SetVertex(vtx);
1887 vtxer.Tracks2V0vertices(esd);
1890 Double_t cts[]={33., // max. allowed chi2
1891 0.05, // min. allowed V0 impact parameter
1892 0.008, // window around the Lambda mass
1893 0.035, // min. allowed bachelor's impact parameter
1894 0.10, // max. allowed DCA between a V0 and a track
1895 0.9985, //max. allowed cosine of the cascade pointing angle
1896 0.9, // min. radius of the fiducial volume
1897 2.9 // max. radius of the fiducial volume
1899 AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
1900 cvtxer.SetVertex(vtx);
1901 cvtxer.V0sTracks2CascadeVertices(esd);