]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITS.cxx
Removing obsolete macros
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
index f5a2a279a315b9a3ef4b402d5d415061c0a3b932..334c77f434a88cdf2ccccacb0b31ea9261bc6451 100644 (file)
 
 /*
 $Log$
+Revision 1.76  2002/11/21 23:05:27  alibrary
+Removing AliMC and AliMCProcess
+
+Revision 1.75  2002/10/22 14:45:25  alibrary
+Introducing Riostream.h
+
+Revision 1.74  2002/10/14 14:57:00  hristov
+Merging the VirtualMC branch to the main development branch (HEAD)
+
+Revision 1.67.4.3  2002/10/14 13:14:07  hristov
+Updating VirtualMC to v3-09-02
+
+Revision 1.73  2002/09/09 17:14:25  nilsen
+Update of documentation to reflect changes in AliITSdigitS?D classes.
+
+Revision 1.72  2002/06/10 17:28:55  nilsen
+Added new FillModules routine and cleaned up the old one.
+
+Revision 1.71  2002/05/13 14:27:56  hristov
+TreeC created once per event (M.Masera)
+
+Revision 1.70  2002/05/10 22:28:30  nilsen
+Changes by Massimo Masera to allow the TTree of clusters to be written to a
+file otherthan the one with digits in it.
+
+Revision 1.69  2002/05/05 21:06:55  nilsen
+Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
+proper initilization when a simulation has already been defined.
+
+Revision 1.68  2002/05/02 18:51:53  nilsen
+AliITS.h
+   Method MakeBranchR has now a second argument, with a default value:
+       Option_t *opt=" ". Opt="Fast" is to create a separate branch
+       for fast points in TreeR
+   New method MakeBranchRF: it a separate branch in TreeR for Fast Points
+
+AliITS.cxx
+1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
+   TreeR
+2) Changes in MakeBranchR to allow the creation of a special branch
+   for fast points
+
+Revision 1.67  2002/03/15 17:22:51  nilsen
+Intoduced SDigits2Digits and SDigitsToDigits functions.
+
+Revision 1.66  2001/11/28 01:35:45  nilsen
+Using standard constructors instead of default constructors for Clusterfinder,
+Response, and FastSimulator.
+
+Revision 1.65  2001/11/27 16:27:28  nilsen
+Adding AliITSDigitizer class to do merging and digitization . Based on the
+TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
+file. The following files required minor changes. AliITS, added functions
+SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
+AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
+the original Root Directory in function Compress1D. Now it uses gDirectory.
+
 Revision 1.64  2001/11/19 16:17:02  nilsen
 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
 bugs found by Rene require more work to fix. Will be fixed soon.
@@ -243,9 +300,7 @@ the AliITS class.
 // futher information.
 //
 ///////////////////////////////////////////////////////////////////////////////
-#include <iostream.h>
-#include <iomanip.h>
-#include <fstream.h>
+#include <Riostream.h>
 #include <stdlib.h>
 #include <TMath.h>
 #include <TRandom.h>
@@ -258,7 +313,6 @@ the AliITS class.
 #include <TTree.h>
 #include <TString.h>
 
-#include "AliMC.h"
 #include "AliHeader.h"
 
 #include "AliITS.h"
@@ -306,7 +360,8 @@ AliITS::AliITS() : AliDetector() {
     fEuclidOut  = 0;
     fITSgeom    = 0;
     fITSmodules = 0;
-    SetDetectors(); // default to fOpt="All". This variable not written out.
+    fOpt        = "All";
+//    SetDetectors(); // default to fOpt="All". This variable not written out.
 
     fIdN        = 0;
     fIdName     = 0;
@@ -403,36 +458,49 @@ AliITS::~AliITS(){
     // Return:
     //      none.
 
+  if (fHits) {
+    fHits->Delete();
     delete fHits;
+    fHits=0;
+  }
+  if (fSDigits) {
+    fSDigits->Delete();
     delete fSDigits;
-    delete fDigits;
+    fSDigits=0;
+  }
+//    delete fDigits; fDigits=0;
+  if (fRecPoints) {
+    fRecPoints->Delete();
     delete fRecPoints;
-    if(fIdName!=0) delete[] fIdName;  // Array of TStrings
-    if(fIdSens!=0) delete[] fIdSens;
-    if(fITSmodules!=0) {
+    fRecPoints=0;
+  }
+  delete[] fIdName;  // Array of TStrings
+  delete[] fIdSens;
+  if(fITSmodules) {
        this->ClearModules();
        delete fITSmodules;
-    }// end if fITSmodules!=0
-
-    if(fDtype) {
-       fDtype->Delete();
-       delete fDtype;
-    } // end if fDtype
-    delete [] fNdtype;
-    if (fCtype) {
-       fCtype->Delete();
-       delete fCtype;
-    } // end if fCtype
-    delete [] fNctype;
-
-    if (fDetTypes) {
-       fDetTypes->Delete();
-       delete fDetTypes;
-    } // end if fDetTypes
-
-    if (fTreeC) delete fTreeC;
-
-    if (fITSgeom) delete fITSgeom;
+       fITSmodules = 0;
+  }// end if fITSmodules!=0
+
+  if(fDtype) {
+    fDtype->Delete();
+    delete fDtype;
+  } // end if fDtype
+  delete [] fNdtype;
+  if (fCtype) {
+    fCtype->Delete();
+    delete fCtype;
+  } // end if fCtype
+  delete [] fNctype;
+
+  if (fDetTypes) {
+    fDetTypes->Delete();
+    delete fDetTypes;
+  } // end if fDetTypes
+
+  if (fTreeC) delete fTreeC;
+
+  if (fITSgeom) delete fITSgeom;
 }
 //______________________________________________________________________
 AliITS::AliITS(AliITS &source){
@@ -536,7 +604,7 @@ void AliITS::SetDefaults(){
     // SDD
     iDetType=DetType(1); 
     if (!iDetType->GetResponseModel()) {
-       SetResponseModel(1,new AliITSresponseSDD()); 
+       SetResponseModel(1,new AliITSresponseSDD("simulated")); 
     } // end if
     AliITSresponse *resp1=iDetType->GetResponseModel();
     if (!iDetType->GetSegmentationModel()) {
@@ -556,7 +624,7 @@ void AliITS::SetDefaults(){
        SetSegmentationModel(2,seg2); 
     } // end if
     if (!iDetType->GetResponseModel()) {
-       SetResponseModel(2,new AliITSresponseSSD()); 
+       SetResponseModel(2,new AliITSresponseSSD("simulated"));
     } // end if
     const char *kData2=(iDetType->GetResponseModel())->DataType();
     if (strstr(kData2,"real")) {
@@ -579,29 +647,57 @@ void AliITS::SetDefaultSimulation(){
     //      none.
 
     AliITSDetType *iDetType;
+    AliITSsimulation *sim;
     iDetType=DetType(0);
-    if (!iDetType->GetSimulationModel()) {
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
        AliITSsegmentation *seg0=
            (AliITSsegmentation*)iDetType->GetSegmentationModel();
        AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
        AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
        SetSimulationModel(0,sim0);
+    }else{ // simulation exists, make sure it is set up properly.
+       ((AliITSsimulationSPD*)sim)->Init(
+           (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
+           (AliITSresponseSPD*) iDetType->GetResponseModel());
+//     if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//         (AliITSresponse*)iDetType->GetResponseModel());
+//     if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//         (AliITSsegmentation*)iDetType->GetSegmentationModel());
     } // end if
     iDetType=DetType(1);
-    if (!iDetType->GetSimulationModel()) {
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
        AliITSsegmentation *seg1=
            (AliITSsegmentation*)iDetType->GetSegmentationModel();
        AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
        AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
        SetSimulationModel(1,sim1);
+    }else{ // simulation exists, make sure it is set up properly.
+       ((AliITSsimulationSDD*)sim)->Init(
+           (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
+           (AliITSresponseSDD*) iDetType->GetResponseModel());
+//     if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//         (AliITSresponse*)iDetType->GetResponseModel());
+//     if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//         (AliITSsegmentation*)iDetType->GetSegmentationModel());
     } //end if
     iDetType=DetType(2);
-    if (!iDetType->GetSimulationModel()) {
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
        AliITSsegmentation *seg2=
            (AliITSsegmentation*)iDetType->GetSegmentationModel();
        AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
        AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
        SetSimulationModel(2,sim2);
+    }else{ // simulation exists, make sure it is set up properly.
+       ((AliITSsimulationSSD*)sim)->Init(
+           (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
+           (AliITSresponseSSD*) iDetType->GetResponseModel());
+//     if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//         (AliITSresponse*)iDetType->GetResponseModel());
+//     if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//         (AliITSsegmentation*)iDetType->GetSegmentationModel());
     } // end if
 }
 //______________________________________________________________________
@@ -665,15 +761,18 @@ void AliITS::MakeBranch(Option_t* option, const char *file){
     //      none.
     // Return:
     //      none.
-    const char *cS = strstr(option,"S");
-    const char *cD = strstr(option,"D");
-    const char *cR = strstr(option,"R");
+    Bool_t cS = (strstr(option,"S")!=0);
+    Bool_t cD = (strstr(option,"D")!=0);
+    Bool_t cR = (strstr(option,"R")!=0);
+    Bool_t cRF = (strstr(option,"RF")!=0);
+    if(cRF)cR = kFALSE;
 
     AliDetector::MakeBranch(option,file);
 
     if(cS) MakeBranchS(file);
     if(cD) MakeBranchD(file);
     if(cR) MakeBranchR(file);
+    if(cRF) MakeBranchRF(file);
 }
 //______________________________________________________________________
 void AliITS::SetTreeAddress(){
@@ -859,7 +958,7 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     // Return:
     //      none.
     static TTree *trH1;                 //Tree with background hits
-    static TClonesArray *fHits2;        //List of hits for one track only
+//    static TClonesArray *fHits2;        //List of hits for one track only
     static Bool_t first=kTRUE;
     static TFile *file;
     const char *addBgr = strstr(option,"Add");
@@ -867,13 +966,13 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     if (addBgr ) {
        if(first) {
            file=new TFile(filename);
-           fHits2     = new TClonesArray("AliITShit",1000  );
+//         fHits2     = new TClonesArray("AliITShit",1000  );
        } // end if first
        first=kFALSE;
        file->cd();
        file->ls();
        // Get Hits Tree header from file
-       if(fHits2) fHits2->Clear();
+//     if(fHits2) fHits2->Clear();
        if(trH1) delete trH1;
        trH1=0;
 
@@ -884,6 +983,7 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
            Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
        } // end if !trH1
        // Set branch addresses
+/*
        TBranch *branch;
        char branchname[20];
        sprintf(branchname,"%s",GetName());
@@ -891,8 +991,11 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
            branch = trH1->GetBranch(branchname);
            if (branch) branch->SetAddress(&fHits2);
        } // end if trH1 && fHits
+*/
     } // end if addBgr
 
+    FillModules(gAlice->TreeH(),0); // fill from this file's tree.
+/*
     TClonesArray *itsHits = this->Hits();
     Int_t lay,lad,det,index;
     AliITShit *itsHit=0;
@@ -916,10 +1019,12 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
            mod->AddHit(itsHit,t,h);
        } // end loop over hits 
     } // end loop over tracks
-
+*/
     // open the file with background
     
     if (addBgr ) {
+       FillModules(trH1,10000000); // Default mask 10M.
+/*
        Int_t track,i;
        ntracks =(Int_t)trH1->GetEntries();     
        // Loop over tracks
@@ -938,6 +1043,7 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
                mod->AddHit(itsHit,track,i);
            }  // end loop over hits
        } // end loop over tracks
+*/
        TTree *fAli=gAlice->TreeK();
        TFile *fileAli=0;
        if (fAli) fileAli =fAli->GetCurrentFile();
@@ -945,6 +1051,52 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     } // end if add
 }
 //______________________________________________________________________
+void AliITS::FillModules(TTree *treeH, Int_t mask) {
+    // fill the modules with the sorted by module hits; 
+    // can be called many times to do a merging
+    // Inputs:
+    //      TTree *treeH  The tree containing the hits to be copied into
+    //                    the modules.
+    //      Int_t mask    The track number mask to indecate which file
+    //                    this hits came from.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+
+    Int_t lay,lad,det,index;
+    AliITShit *itsHit=0;
+    AliITSmodule *mod=0;
+    char branchname[20];
+    sprintf(branchname,"%s",GetName());
+    TBranch *branch = treeH->GetBranch(branchname);
+    if (!branch) {
+       Error("FillModules","%s branch in TreeH not found",branchname);
+       return;
+    } // end if !branch
+    branch->SetAddress(&fHits);
+    Int_t nTracks =(Int_t) treeH->GetEntries();
+    Int_t iPrimTrack,h;
+    for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
+       ResetHits();
+       Int_t nBytes = treeH->GetEvent(iPrimTrack);
+       if (nBytes <= 0) continue;
+       Int_t nHits = fHits->GetEntriesFast();
+       for(h=0; h<nHits; h++){
+           itsHit = (AliITShit *)fHits->UncheckedAt(h);
+           itsHit->GetDetectorID(lay,lad,det);
+           if (fITSgeom) {
+               index = fITSgeom->GetModuleIndex(lay,lad,det);
+           } else {
+               index=det-1; // This should not be used.
+           } // end if [You must have fITSgeom for this to work!]
+           mod = GetModule(index);
+           itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
+           mod->AddHit(itsHit,iPrimTrack,h);
+       } // end loop over hits 
+    } // end loop over tracks
+}
+//______________________________________________________________________
 void AliITS::ClearModules(){
     // Clear the modules TObjArray.
     // Inputs:
@@ -995,6 +1147,7 @@ void AliITS::SetTreeAddressS(TTree *treeS){
 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
     // Creates Tree branches for the ITS.
     // Inputs:
+    //      TTree     *treeD Pointer to the Digits Tree.
     //      cont char *file  File name where Digits branch is to be written
     //                       to. If blank it write the SDigits to the same
     //                       file in which the Hits were found.
@@ -1064,7 +1217,7 @@ void AliITS::Hits2SDigits(){
     // Outputs:
     //      none.
 
-    return; // Using Hits in place of the larger sDigits.
+//    return; // Using Hits in place of the larger sDigits.
     AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
     // Do the Hits to Digits operation. Use Standard input values.
     // Event number from file, no background hit merging , use size from
@@ -1086,14 +1239,68 @@ void AliITS::Hits2PreDigits(){
     HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
 }
 //______________________________________________________________________
-void AliITS::SDigits2Digits(){
+void AliITS::SDigitsToDigits(Option_t *opt){
     // Standard Summable digits to Digits function.
     // Inputs:
     //      none.
     // Outputs:
     //      none.
+    char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+
+    if(!GetITSgeom()) return; // need transformations to do digitization.
+    AliITSgeom *geom = GetITSgeom();
+
+    const char *all = strstr(opt,"All");
+    const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
+                         strstr(opt,"SSD")};
+    if( !det[0] && !det[1] && !det[2] ) all = "All";
+    else all = 0;
+    static Bool_t setDef=kTRUE;
+    if (setDef) SetDefaultSimulation();
+    setDef=kFALSE;
+
+    AliITSsimulation *sim      = 0;
+    AliITSDetType    *iDetType = 0;
+    TTree            *trees    = gAlice->TreeS();
+    if( !(trees && this->GetSDigits()) ){
+       Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
+       return;
+    } // end if
+    sprintf( name, "%s", this->GetName() );
+    TBranch *brchSDigits = trees->GetBranch( name );
+    
+    Int_t id,module;
+    for(module=0;module<geom->GetIndexMax();module++){
+       id       = geom->GetModuleType(module);
+        if (!all && !det[id]) continue;
+       iDetType = DetType(id);
+       sim      = (AliITSsimulation*)iDetType->GetSimulationModel();
+       if (!sim) {
+           Error("SDigit2Digits",
+                 "The simulation class was not instanciated!");
+           exit(1);
+       } // end if !sim
+       sim->InitSimulationModule(module,gAlice->GetEvNumber());
+//
+       // add summable digits to module
+       this->GetSDigits()->Clear();
+       brchSDigits->GetEvent(module);
+       sim->AddSDigitsToModule(GetSDigits(),0);
+//
+        // Digitise current module sum(SDigits)->Digits
+        sim->FinishSDigitiseModule();
 
-    Hits2Digits();
+        // fills all branches - wasted disk space
+        gAlice->TreeD()->Fill();
+        this->ResetDigits();
+    } // end for module
+
+    gAlice->TreeD()->GetEntries();
+
+    gAlice->TreeD()->AutoSave();
+    // reset tree
+    gAlice->TreeD()->Reset();
+    
 }
 //______________________________________________________________________
 void AliITS::Hits2Digits(){
@@ -1130,7 +1337,9 @@ void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
     //      none.
     // Return:
     //      none.
-    return; // using Hits instead of the larger sdigits.
+//    return; // using Hits instead of the larger sdigits.
+
+    HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
 }
 //______________________________________________________________________
 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
@@ -1191,10 +1400,7 @@ void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
     ClearModules();
 
     gAlice->TreeS()->GetEntries();
-
-    char hname[30];
-    sprintf(hname,"TreeS%d",evNumber);
-    gAlice->TreeS()->Write(hname,TObject::kOverwrite);
+    gAlice->TreeS()->AutoSave();
     // reset tree
     gAlice->TreeS()->Reset();
 }
@@ -1257,10 +1463,7 @@ void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
     ClearModules();
 
     gAlice->TreeD()->GetEntries();
-
-    char hname[30];
-    sprintf(hname,"TreeD%d",evNumber);
-    gAlice->TreeD()->Write(hname,TObject::kOverwrite);
+    gAlice->TreeD()->AutoSave();
     // reset tree
     gAlice->TreeD()->Reset();
 }
@@ -1365,9 +1568,11 @@ void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
     //      Float_t phys    Physics indicator. See AliITSdigits.h
     //      Int_t *digits   Integer array containing the digits info. See 
     //                      AliITSdigit.h
-    //      Int_t *tracks   Integer array [3] containing the track numbers that
-    //                      contributed to this digit.
-    //      Int_t *hits     Integer array [3] containing the hit numbers that
+    //      Int_t *tracks   Integer array [AliITSdigitS?D::GetNTracks()] 
+    //                      containing the track numbers that contributed to
+    //                      this digit.
+    //      Int_t *hits     Integer array [AliITSdigitS?D::GetNTracks()]
+    //                      containing the hit numbers, from AliITSmodule, that
     //                      contributed to this digit.
     //      Float_t *charge Floating point array of the signals contributed
     //                      to this digit by each track.
@@ -1400,9 +1605,22 @@ void AliITS::MakeTreeC(Option_t *option){
     //      none.
     // Return:
     //      none.
-
+  TDirectory *cwd = gDirectory;
+  TFile *fileRecPoints = gAlice->GetTreeRFile();
+  if(fileRecPoints)fileRecPoints->cd();
     const char *optC = strstr(option,"C");
-    if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
+    char hname[30];
+    Int_t cureve = gAlice->GetEvNumber();
+    sprintf(hname,"TreeC%d",cureve);
+    if(fTreeC){
+      const char *curname = fTreeC->GetName();
+      char *exists = strstr(hname,curname);
+      if(!exists){
+        delete fTreeC; 
+        fTreeC=0;
+      }
+    }
+    if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
     else return;
 
     Int_t buffersize = 4000;
@@ -1412,18 +1630,21 @@ void AliITS::MakeTreeC(Option_t *option){
     char clclass[40];
 
     // one branch for Clusters per type of detector
-    Int_t i;
+    Int_t i;   
     for (i=0; i<kNTYPES ;i++) {
         AliITSDetType *iDetType=DetType(i); 
         iDetType->GetClassNames(digclass,clclass);
        // clusters
-        fCtype->AddAt(new TClonesArray(clclass,1000),i);
+        if(!ClustersAddress(i)){
+          fCtype->AddAt(new TClonesArray(clclass,1000),i);
+        }
         if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
        else  sprintf(branchname,"%sClusters%d",GetName(),i+1);
        if (fCtype   && fTreeC) {
            TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
        } // end if fCtype && fTreeC
     } // end for i
+    cwd->cd();
 }
 //______________________________________________________________________
 void AliITS::GetTreeC(Int_t event){
@@ -1444,7 +1665,13 @@ void AliITS::GetTreeC(Int_t event){
     } // end if fTreeC
 
     sprintf(treeName,"TreeC%d",event);
-    fTreeC = (TTree*)gDirectory->Get(treeName);
+    TFile *fileRecPoints = gAlice->GetTreeRFile();
+    if(!fileRecPoints){
+      fTreeC = (TTree*)gDirectory->Get(treeName);
+    }
+    else {
+      fTreeC = (TTree*)fileRecPoints->Get(treeName);
+    }
 
     TBranch *branch;
 
@@ -1519,7 +1746,7 @@ void AliITS::ResetClusters(Int_t i){
     if (fNctype)  fNctype[i]=0;
 }
 //______________________________________________________________________
-void AliITS::MakeBranchR(const char *file){
+void AliITS::MakeBranchR(const char *file, Option_t *opt){
     // Creates Tree branches for the ITS Reconstructed points.
     // Inputs:
     //      cont char *file  File name where RecPoints branch is to be written
@@ -1533,7 +1760,12 @@ void AliITS::MakeBranchR(const char *file){
     char branchname[30];
 
     // only one branch for rec points for all detector types
-    sprintf(branchname,"%sRecPoints",GetName());
+    Bool_t oFast= (strstr(opt,"Fast")!=0);
+    if(oFast){
+      sprintf(branchname,"%sRecPointsF",GetName());
+    } else {
+      sprintf(branchname,"%sRecPoints",GetName());
+    }
     if (fRecPoints && gAlice->TreeR()) {
        MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
     } // end if
@@ -1553,7 +1785,16 @@ void AliITS::SetTreeAddressR(TTree *treeR){
     TBranch *branch;
     sprintf(branchname,"%sRecPoints",GetName());
     branch = treeR->GetBranch(branchname);
-    if (branch) branch->SetAddress(&fRecPoints);
+    if (branch) {
+      branch->SetAddress(&fRecPoints);
+    }
+    else {
+      sprintf(branchname,"%sRecPointsF",GetName());
+      branch = treeR->GetBranch(branchname);
+      if (branch) {
+        branch->SetAddress(&fRecPoints);
+      }
+    }
 }
 //______________________________________________________________________
 void AliITS::AddRecPoint(const AliITSRecPoint &r){
@@ -1619,15 +1860,15 @@ void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
        } // end if !sim
        mod      = (AliITSmodule *)fITSmodules->At(module);
        sim->CreateFastRecPoints(mod,module,gRandom);
-       gAlice->TreeR()->Fill(); 
+    // gAlice->TreeR()->Fill(); 
+    TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
+    br->Fill();
        ResetRecPoints();
     } // end for module
 
     ClearModules();
 
-    char hname[30];
-    sprintf(hname,"TreeR%d",evNumber);
-    gAlice->TreeR()->Write(hname,TObject::kOverwrite);
+    gAlice->TreeR()->AutoSave();
     // reset tree
     gAlice->TreeR()->Reset();
 }
@@ -1673,7 +1914,6 @@ void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
     setRec=kFALSE;
 
     TTree *treeC=TreeC();
-
     AliITSClusterFinder *rec     = 0;
     AliITSDetType      *iDetType = 0;
     Int_t id,module,first=0;
@@ -1694,7 +1934,7 @@ void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
        else gAlice->TreeD()->GetEvent(lastentry+(module-first));
        Int_t ndigits = itsDigits->GetEntriesFast();
        if (ndigits) rec->FindRawClusters(module);
-       gAlice->TreeR()->Fill(); 
+    gAlice->TreeR()->Fill(); 
        ResetRecPoints();
        treeC->Fill();
        ResetClusters();
@@ -1702,15 +1942,11 @@ void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
 
     gAlice->TreeR()->GetEntries();
     treeC->GetEntries();
-
-    char hname[30];
-    sprintf(hname,"TreeR%d",evNumber);
-    gAlice->TreeR()->Write(hname,TObject::kOverwrite);
+    gAlice->TreeR()->AutoSave();
     // reset tree
     gAlice->TreeR()->Reset();
 
-    sprintf(hname,"TreeC%d",evNumber);
-    treeC->Write(hname,TObject::kOverwrite);
+    treeC->AutoSave();
     treeC->Reset();
 }
 //______________________________________________________________________