]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/AliRICHDigitizer.cxx
Transition to NewIO
[u/mrichter/AliRoot.git] / RICH / AliRICHDigitizer.cxx
index 758ecf3bc155600d3e4327e69e23d2b52d277eb9..8d009dba1fd53951643ec58f46360ef56de1770c 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* 
-   $Log$
-   Revision 1.5  2002/07/09 13:11:26  hristov
-   Old style include files needed on HP (aCC)
+/* $Id$ */
 
-   Revision 1.4  2002/05/28 07:53:10  morsch
-   Wrong order of arguments in for-statement corrected.
+//Piotr.Skowronski@cern.ch :
+//Corrections applied in order to compile (only) with new I/O and folder structure
+//To be implemented correctly by responsible
 
-   Revision 1.3  2001/12/05 14:53:34  hristov
-   Destructor corRevision 1.60  2002/10/22 16:28:21  alibrary
-  Introducing Riostream.h
-
-  Revision 1.59  2002/10/14 14:57:31  hristov
-  Merging the VirtualMC branch to the main development branch (HEAD)
-
-  Revision 1.58.6.1  2002/06/10 15:12:46  hristov
-  Merged with v3-08-02rected
-
-   Revision 1.2  2001/11/07 14:50:31  hristov
-   Minor correction of the Log part
-
-   Revision 1.1  2001/11/02 15:37:26  hristov
-   Digitizer class created. Code cleaning and bug fixes (J.Chudoba)
-*/
 #include <Riostream.h> 
 
 #include <TTree.h> 
@@ -45,6 +27,9 @@
 #include <TDirectory.h>
 #include <TParticle.h>
 
+#include "AliRunLoader.h"
+#include "AliLoader.h"
+
 #include "AliRICHDigitizer.h"
 #include "AliRICHChamber.h"
 #include "AliHitMap.h"
@@ -82,7 +67,7 @@ AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer* manager)
   fDebug   = 0; 
   if (GetDebug()>2) 
     cerr<<"AliRICHDigitizer::AliRICHDigitizer"
-       <<"(AliRunDigitizer* manager) was processed"<<endl;
+      <<"(AliRunDigitizer* manager) was processed"<<endl;
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -123,7 +108,7 @@ void AliRICHDigitizer::Update(AliRICHSDigit *padhit)
   //
   Int_t iqpad    = Int_t(padhit->QPad()); // charge per pad
   pdigit->AddSignal(iqpad);
-  pdigit->AddPhysicsSignal(iqpad);             
+  pdigit->AddPhysicsSignal(iqpad);            
 
   // update list of tracks
   //
@@ -181,11 +166,21 @@ void AliRICHDigitizer::Exec(Option_t* option)
 
   AliRICHChamber*       iChamber;
   AliSegmentation*  segmentation;
-  
+  AliRunLoader *inRL, *outRL;//in and out Run Loaders
+  AliLoader *ingime, *outgime;// in and out ITSLoaders
+  outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+  outgime = outRL->GetLoader("RICHLoader");
+
   fTDList = new TObjArray;
-    
+  
+     
   AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH");
-  pRICH->MakeBranchInTreeD(fManager->GetTreeD());
+  
+  if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
+  
+  pRICH->MakeBranchInTreeD(outgime->TreeD());
   fHitMap= new AliHitMap* [kNCH];
         
   for (Int_t i =0; i<kNCH; i++) {
@@ -197,36 +192,41 @@ void AliRICHDigitizer::Exec(Option_t* option)
 // Loop over files to digitize
   fSignal = kTRUE;
   fCounter = 0;
-  for (Int_t inputFile=0; inputFile<fManager->GetNinputs();
-       inputFile++) {
-
+  for (Int_t inputFile=0; inputFile<fManager->GetNinputs(); inputFile++) 
+   {
+    inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+    ingime = inRL->GetLoader("RICHLoader");
+    
 // Connect RICH branches
 
     if (inputFile > 0 ) fSignal = kFALSE;
     TBranch *branchHits = 0;
     TBranch *branchSDigits = 0;
-    TTree *treeH = fManager->GetInputTreeH(inputFile);
+
+    ingime->LoadHits("READ");
+    TTree *treeH = ingime->TreeH();
     if (GetDebug()>2) {
       cerr<<"   inputFile  "<<inputFile<<endl;
       cerr<<"   treeH, fHits "<<treeH<<" "<<fHits<<endl;
     }
     if (treeH && fHits) {
       branchHits = treeH->GetBranch("RICH");
-      if (branchHits) {
-       fHits->Clear();
-       branchHits->SetAddress(&fHits);
+      if (branchHits) 
+       {
+         fHits->Clear();
+          branchHits->SetAddress(&fHits);
       }
       else
-       Error("Exec","branch RICH was not found");
+      Error("Exec","branch RICH was not found");
     }
     if (GetDebug()>2) cerr<<"   branchHits = "<<branchHits<<endl;
 
     if (treeH && fSDigits) {
       branchSDigits = treeH->GetBranch("RICHSDigits");
       if (branchSDigits) 
-       branchSDigits->SetAddress(&fSDigits);
+      branchSDigits->SetAddress(&fSDigits);
       else
-       Error("exec","branch RICHSDigits was not found");
+      Error("exec","branch RICHSDigits was not found");
     }
     if (GetDebug()>2) cerr<<"   branchSDigits = "<<branchSDigits<<endl;
 
@@ -344,8 +344,8 @@ void AliRICHDigitizer::Exec(Option_t* option)
     }      //end loop over list of tracks for one pad
     if (nptracks < kMAXTRACKSPERRICHDIGIT ) {
       for (Int_t t=nptracks; t<kMAXTRACKSPERRICHDIGIT; t++) {
-       tracks[t]=0;
-       charges[t]=0;
+      tracks[t]=0;
+      charges[t]=0;
       }
     }
     //write file
@@ -354,10 +354,8 @@ void AliRICHDigitizer::Exec(Option_t* option)
       
     // fill digits
     pRICH->AddDigits(ich,tracks,charges,fDigits);
-    
-   
-  }    
-  fManager->GetTreeD()->Fill();
+  }      
+  outgime->TreeD()->Fill();
 
   //pRICH->ResetDigits();
   fTDList->Delete();    // or fTDList->Clear(); ???
@@ -374,8 +372,10 @@ void AliRICHDigitizer::Exec(Option_t* option)
     Int_t ndigit=richDigits->GetEntriesFast();
     printf ("Chamber %d digits %d \n",k,ndigit);
   }
-  fManager->GetTreeD()->Write(0,TObject::kOverwrite);
-  pRICH->ResetDigits();
+  pRICH->ResetDigits(); /// ??? should it be here???
+  
+  outgime->WriteDigits("OVERWRITE");
+
   delete [] fHitMap;
   delete fTDList;