]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - START/AliSTARTDigitizer.cxx
Transition to NewIO
[u/mrichter/AliRoot.git] / START / AliSTARTDigitizer.cxx
index 65b473a1f4ea335f7469df87fb6c1180efce58aa..9c3ae72d0b64cb0f0b2bde687e4096393b2475fc 100644 (file)
 #include "AliGenEventHeader.h"
 #include "AliRun.h"
 #include "AliPDG.h"
+#include "AliLoader.h"
+#include "AliRunLoader.h"
 
 #include <stdlib.h>
-#include <iostream.h>
-#include <fstream.h>
+#include <Riostream.h>
+#include <Riostream.h>
 
 ClassImp(AliSTARTDigitizer)
 
@@ -84,7 +86,13 @@ Bool_t AliSTARTDigitizer::Init()
 void AliSTARTDigitizer::Exec(Option_t* option)
 {
 
-  cout<<" AliSTARTDigitizer::Exec"<<endl;
+
+  AliRunLoader *inRL, *outRL;//in and out Run Loaders
+  AliLoader *ingime, *outgime;// in and out ITSLoaders
+
+  outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+  outgime = outRL->GetLoader("STARTLoader");
+
 #ifdef DEBUG
   cout<<"AliSTARTDigitizer::>SDigits2Digits start...\n";
 #endif
@@ -94,7 +102,6 @@ void AliSTARTDigitizer::Exec(Option_t* option)
   Int_t hit, nhits;
   Int_t CountEr[13],CountEl[13];                                                       //!!!
   Int_t volume,pmt,tr,tl,sumRight;
-  char nameDigits[20];
   Float_t timediff,timeav;
   Float_t besttimeright,besttimeleft,meanTime;
   Int_t  bestRightADC,bestLeftADC;
@@ -103,7 +110,7 @@ void AliSTARTDigitizer::Exec(Option_t* option)
   Float_t timeleft[13]={13*0};
   Float_t channelWidth=2.5; //ps
   Int_t channelWidthADC=1; //ps
-  Int_t thresholdAmpl=10;
+  //  Int_t thresholdAmpl=10;
 
   ftimeRightTDC = new TArrayI(12); 
   ftimeLeftTDC = new TArrayI(12); 
@@ -137,9 +144,14 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        CountEr[i0]=0;   CountEl[i0]=0;
       }
     TClonesArray *STARThits = START->Hits ();
+
+    inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+    ingime = inRL->GetLoader("STARTLoader");
+    ingime->LoadHits("READ");//probably it is necessary to load them before
     TClonesArray *STARThitsPhotons = START->Photons ();
 
-   TTree *th = fManager->GetInputTreeH(inputFile);
+
+   TTree *th = ingime->TreeH();
     brHits = th->GetBranch("START");
     brHitPhoton = th->GetBranch("STARThitPhoton");
     if (brHits) {
@@ -210,12 +222,12 @@ void AliSTARTDigitizer::Exec(Option_t* option)
     
     besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
     //    cout<<" besttimerightGaus "<<besttimerightGaus<<endl;
-    bestRightADC=(Int_t) besttimerightGaus*1000/channelWidth;
+    bestRightADC=Int_t (besttimerightGaus*1000/channelWidth);
     Float_t koef=69.7/350.;
     besttimeleft=koef*besttimeleft;
     besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
     
-    bestLeftADC=(Int_t) besttimeleftGaus*1000/channelWidth;
+    bestLeftADC=Int_t (besttimeleftGaus*1000/channelWidth);
     timediff=besttimerightGaus-besttimeleftGaus;
     cout<<" timediff in ns "<<timediff<<" z= "<<timediff*30<<endl;
     meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
@@ -267,20 +279,9 @@ void AliSTARTDigitizer::Exec(Option_t* option)
       }
     else
       {timeAv=999999; timeDiff=99999;}
-    
-    // trick to find out output dir:
-    TTree *outTree = fManager->GetTreeD();
-    if (!outTree) {
-      cerr<<"something wrong with output...."<<endl;
-      exit(111);
-    }
-
-    TDirectory *wd = gDirectory;
-    outTree->GetDirectory()->cd();
-    sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
-    fdigits->Write(nameDigits);
-    cout<<nameDigits<<endl;
-    wd->cd();
+
+// trick to find out output dir:
+    outgime->WriteDigits("OVERWRITE");
   }
 }