]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSreconstruction.cxx
Checking in the seeds of new cluster fitting code.
[u/mrichter/AliRoot.git] / ITS / AliITSreconstruction.cxx
index e9df18dd08bd8145f94c8032cf94ac9822e29604..06d5afb9896eaf0a572aa58596cdfff960d485eb 100644 (file)
  
 /*
 $Log$
+Revision 1.3.6.2  2002/10/14 13:14:08  hristov
+Updating VirtualMC to v3-09-02
+
+Revision 1.6  2002/09/09 17:30:02  nilsen
+Added new creator which passes a pointer to type AliRun. Can now use either
+gAlice or a local instance of AliRun.
+
+Revision 1.5  2002/05/13 14:27:57  hristov
+TreeC created once per event (M.Masera)
+
+Revision 1.4  2002/05/10 22:31:30  nilsen
+Changes by Massimo Masera to allow Recpoints and Clusters to be written
+to separate files.
+
+Revision 1.3  2002/02/06 13:52:27  barbera
+gAlice deletion corrected (from M. Masera)
+
 Revision 1.2  2002/01/31 18:52:09  nilsen
 Minor change to allow the use of files that are already open. grun.C macro
 that also does ITS digitizationa and Reconstruction all in one go.
@@ -59,9 +76,32 @@ AliITSreconstruction::AliITSreconstruction(){
 
     fFilename = "";
     fFile     = 0;
+    fFile2    = 0;
+    fITS      = 0;
+    fDet[0] = fDet[1] = fDet[2] = kTRUE;
+    fInit     = kFALSE;
+    fArp      = 0;
+    fDfArp    = kFALSE;
+}
+//______________________________________________________________________
+AliITSreconstruction::AliITSreconstruction(AliRun *ar){
+    // Standard constructor.
+    // Inputs:
+    //  AliRun *ar   Pointer to an existing AliRun object. Assumed that
+    //               this AliRun object will not be deleted by this distructor.
+    // Outputs:
+    //   none.
+    // Return:
+    //    A standardly constructed AliITSreconstruction class.
+
+    fFilename = "";
+    fFile     = 0;
+    fFile2    = 0;
     fITS      = 0;
     fDet[0] = fDet[1] = fDet[2] = kTRUE;
     fInit     = kFALSE;
+    fDfArp    = kFALSE;
+    fArp      = ar;
 }
 //______________________________________________________________________
 AliITSreconstruction::AliITSreconstruction(const char* filename){
@@ -78,25 +118,25 @@ AliITSreconstruction::AliITSreconstruction(const char* filename){
     //    A standardly constructed AliITSreconstruction class.
 
     fFilename = filename;
-
+    fFile2 = 0;
+    fFile = 0;
+    fArp      = 0;
+    fDfArp    = kTRUE;
     if(filename){
        fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
        if(fFile) fFile->Close();
        fFile = new TFile(fFilename.Data(),"UPDATE");
-       //
-        if(gAlice) {
-          delete gAlice;
-          gAlice = 0;
-        }   
-       gAlice = (AliRun*)fFile->Get("gAlice");
-       if(!gAlice) {
+    if(fArp) {
+      delete fArp;
+      fArp = 0;
+    }
+       fArp = (AliRun*)fFile->Get("gAlice");
+       if(!fArp) {
            cout << "gAlice not found on file. Aborting." << endl;
            fInit = kFALSE;
            return;
-       } // end if !gAlice
+       } // end if !fArp
     } // end if !filename.
-
-    Init();
 }
 //______________________________________________________________________
 AliITSreconstruction::~AliITSreconstruction(){
@@ -111,7 +151,9 @@ AliITSreconstruction::~AliITSreconstruction(){
     if(fFile) fFile->Close();
     fFile     = 0;
     fITS      = 0;
-    
+    if(fDfArp){
+       if(fArp) delete fArp;
+    } // end if
 }
 //______________________________________________________________________
 Bool_t AliITSreconstruction::Init(){
@@ -123,8 +165,7 @@ Bool_t AliITSreconstruction::Init(){
     // Return:
     //    kTRUE if no errors initilizing this class occurse else kFALSE
     Int_t nparticles;
-
-    fITS = (AliITS*) gAlice->GetDetector("ITS");
+    fITS = (AliITS*) fArp->GetDetector("ITS");
     if(!fITS){
        cout << "ITS not found aborting. fITS=" << fITS << endl;
        fInit = kFALSE;
@@ -139,9 +180,9 @@ Bool_t AliITSreconstruction::Init(){
 
     fDet[0] = fDet[1] = fDet[2] = kTRUE;
     fEnt0 = 0;
-    fEnt  = gAlice->GetEventsPerRun();
+    fEnt  = fArp->GetEventsPerRun();
     fITS->MakeTreeC();
-    nparticles = gAlice->GetEvent(fEnt0);
+    nparticles = fArp->GetEvent(fEnt0);
     
     // finished init.
     fInit = InitRec();
@@ -225,11 +266,33 @@ void AliITSreconstruction::Exec(const Option_t *opt){
        cout << "Initilization Failed, Can't run Exec." << endl;
        return;
     } // end if !fInit
+    TDirectory *curr = gDirectory;
+    if(fFile2)fFile2->cd();
     for(evnt=0;evnt<fEnt;evnt++){
-       nparticles = gAlice->GetEvent(evnt);
-       gAlice->SetEvent(evnt);
-       if(!gAlice->TreeR()) gAlice->MakeTree("R");
-       fITS->MakeBranch("R");
-       fITS->DigitsToRecPoints(evnt,0,lopt);
+      nparticles = fArp->GetEvent(evnt);
+      fArp->SetEvent(evnt);
+      if(!fArp->TreeR()){
+        if(fFile2){
+          fArp->MakeTree("R",fFile2);
+        }
+        else {
+          fArp->MakeTree("R");
+        }
+      }
+      fITS->MakeBranch("R");
+      fITS->MakeTreeC();
+      fITS->DigitsToRecPoints(evnt,0,lopt);
     } // end for evnt
+    curr->cd();
 }
+//______________________________________________________________________ 
+void AliITSreconstruction::SetOutputFile(TString filename){
+  // Set a file name for recpoints. Used only if this file is not the file
+  // containing digits. This obj is deleted by AliRun.
+  fFile2 = fArp->InitTreeFile("R",filename);
+}
+
+
+
+
+