]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITS.cxx
Removing obsolete macros
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
index 9361e250e1409c43c59d07e438d267983842d9ad..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.
 
@@ -258,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>
@@ -273,7 +313,6 @@ the AliITS class.
 #include <TTree.h>
 #include <TString.h>
 
-#include "AliMC.h"
 #include "AliHeader.h"
 
 #include "AliITS.h"
@@ -419,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){
@@ -595,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
 }
 //______________________________________________________________________
@@ -878,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");
@@ -886,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;
 
@@ -903,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());
@@ -910,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;
@@ -935,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
@@ -957,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();
@@ -964,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:
@@ -1163,11 +1296,7 @@ void AliITS::SDigitsToDigits(Option_t *opt){
     } // end for module
 
     gAlice->TreeD()->GetEntries();
-    /*
-    char hname[30];
-    sprintf(hname,"TreeD%d",gAlice->GetEvNumber());
-    gAlice->TreeD()->Write(hname,TObject::kOverwrite);
-    */
+
     gAlice->TreeD()->AutoSave();
     // reset tree
     gAlice->TreeD()->Reset();
@@ -1271,11 +1400,6 @@ 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();
@@ -1339,11 +1463,6 @@ 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();
@@ -1449,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.
@@ -1484,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;
@@ -1496,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){
@@ -1528,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;
 
@@ -1724,11 +1867,7 @@ void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
     } // 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();
@@ -1803,17 +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();
 }
 //______________________________________________________________________