]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - START/AliSTARTDigitizer.cxx
Delete the run loader before creating a new getter
[u/mrichter/AliRoot.git] / START / AliSTARTDigitizer.cxx
index 4e7a4b5f280e6fdd796d926f8797f5d3dcfb8180..18dbd7836dec8a2f2a4efc02fbdd0ec27ca93b35 100644 (file)
@@ -23,6 +23,7 @@
 #include <TRandom.h>
 #include <TArrayI.h>
 #include <TH1.h>
+#include <TError.h>
 
 
 #include "AliSTARTDigitizer.h"
@@ -84,7 +85,7 @@ Bool_t AliSTARTDigitizer::Init()
 
 //---------------------------------------------------------------------
 
-void AliSTARTDigitizer::Exec(Option_t* option)
+void AliSTARTDigitizer::Exec(Option_t* /*option*/)
 {
 
 
@@ -93,7 +94,6 @@ void AliSTARTDigitizer::Exec(Option_t* option)
 
   outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
   outgime = outRL->GetLoader("STARTLoader");
-  cout<<" outgime "<<outgime<<endl;
 
 #ifdef DEBUG
   cout<<"AliSTARTDigitizer::>SDigits2Digits start...\n";
@@ -126,7 +126,8 @@ void AliSTARTDigitizer::Exec(Option_t* option)
   fPhotons = new TClonesArray ("AliSTARThitPhoton", 10000);                    //!!!
   AliSTART *START  = (AliSTART*) gAlice->GetDetector("START");
   AliSTARThit  *startHit;
-  AliSTARThitPhoton  *startHitPhoton;                                          //!!!
+  //use if Cherenkov photons
+  //  AliSTARThitPhoton  *startHitPhoton;                                              //!!!
   TBranch *brHits=0;
   TBranch *brHitPhoton=0;
   fdigits= new AliSTARTdigit();
@@ -146,14 +147,11 @@ void AliSTARTDigitizer::Exec(Option_t* option)
       }
 
     inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
-    //   AliSTARTLoader *pSTARTloader = (AliSTARTLoader*)fLoader;
-    //  pSTARTLoader->LoadHits("READ");
     ingime = inRL->GetLoader("STARTLoader");
-    cout<<" ingime "<<ingime<<endl;
-    //    AliSTARTLoader *pSTARTLoader ;
     ingime->LoadHits("READ");//probably it is necessary to load them before
-    ingime->LoadDigits("UPDATE");//probably it is necessary to load them before
-    TClonesArray *STARThitsPhotons = START->Photons ();
+    outgime->LoadDigits("UPDATE");//probably it is necessary to load them before
+    //use if Cherenkov photons
+    //  TClonesArray *STARThitsPhotons = START->Photons ();
     TClonesArray *fHits = START->Hits ();
     //    cout<<" Load  "<<AliSTARTLoader::LoadDigits()<<endl;
 
@@ -161,7 +159,6 @@ void AliSTARTDigitizer::Exec(Option_t* option)
     brHits = th->GetBranch("START");
     brHitPhoton = th->GetBranch("STARThitPhoton");
     if (brHits) {
-      cout<<" brHits "<<endl;
       START->SetHitsAddressBranch(brHits,brHitPhoton);
     }else{
       cerr<<"EXEC Branch START hit not found"<<endl;
@@ -193,17 +190,20 @@ void AliSTARTDigitizer::Exec(Option_t* option)
     } // was photons
     */
     // Start loop on tracks in the hits containers
-    cout<<" fHits "<<fHits<<endl;;
     for (Int_t track=0; track<ntracks;track++) {
       brHits->GetEntry(track);
       nhits = fHits->GetEntriesFast();
       //  cout<<" brHits hits "<<nhits<<endl;
       for (hit=0;hit<nhits;hit++) {
        startHit   = (AliSTARThit*) fHits->UncheckedAt(hit);
-       pmt=startHit->fPmt;
-       volume = startHit->fVolume;
+       if (!startHit) {
+         ::Error("Exec","The unchecked hit doesn't exist");
+         break;
+       }
+       pmt=startHit->Pmt();
+       volume = startHit->Volume();
        if(volume==1){
-         timeright[pmt] = startHit->fTime;
+         timeright[pmt] = startHit->Time();
          if(timeright[pmt]<besttimeright)
            //&&CountEr[pmt-1]>thresholdAmpl)
            {
@@ -211,7 +211,7 @@ void AliSTARTDigitizer::Exec(Option_t* option)
          } //timeright
        }//time for right shoulder
        if(volume==2){            
-         timeleft[pmt] = startHit->fTime;
+         timeleft[pmt] = startHit->Time();
          if(timeleft[pmt]<besttimeleft)
            //&&CountEl[pmt-1]>thresholdAmpl) 
            {
@@ -221,24 +221,24 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        }//time for left shoulder
       } //hit loop
     } //track loop
+  
     // z position
     cout<<" right time  "<<besttimeright<<
       " right distance "<<besttimeright*30<<endl;;
     cout<<" left time  "<<besttimeleft<<
-      " right distance "<<besttimeleft*30<<endl;;
+      " left distance "<<besttimeleft*30<<endl;;
   
 
     //folding with experimental time distribution
     
-    besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
-    //    cout<<" besttimerightGaus "<<besttimerightGaus<<endl;
-    bestRightADC=Int_t (besttimerightGaus*1000/channelWidth);
+    besttimeleftGaus=gRandom->Gaus(besttimeright,0.05);
+    cout<<" besttimeleftGaus "<<besttimeleftGaus<<endl;
+    bestLeftADC=Int_t (besttimeleftGaus*1000/channelWidth);
     Float_t koef=69.7/350.;
-    besttimeleft=koef*besttimeleft;
-    besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
+    besttimeright=koef*besttimeleft;
+    besttimerightGaus=gRandom->Gaus(besttimeleft,0.05);
     
-    bestLeftADC=Int_t (besttimeleftGaus*1000/channelWidth);
+    bestRightADC=Int_t (besttimerightGaus*1000/channelWidth);
     timediff=besttimerightGaus-besttimeleftGaus;
     cout<<" timediff in ns "<<timediff<<" z= "<<timediff*30<<endl;
     meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
@@ -293,28 +293,12 @@ void AliSTARTDigitizer::Exec(Option_t* option)
 
 // trick to find out output dir:
 
-
-/*
-   // trick to find out output dir:
-    TTree *outTree = fManager->GetTreeD();
-    if (!outTree) {
-      cerr<<"something wrong with output...."<<endl;
-      exit(111);
-    }
-
     Char_t nameDigits[20];
+    sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
     TDirectory *wd = gDirectory;
-    outTree->GetDirectory()->cd();
+    outgime->GetDigitsDataLoader()->GetDirectory()->cd();
     fdigits->Write(nameDigits);
-    cout<<nameDigits<<endl;
     wd->cd();
-*/  
-    cout<<" outgime v konce "<<outgime<<endl;
-    outgime->Dump();
-    outgime->Print();
-    Char_t nameDigits[20];
-    sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
-    fdigits->Write(nameDigits);
 
     //    outgime->WriteDigits("OVERWRITE");
   }
@@ -322,7 +306,7 @@ void AliSTARTDigitizer::Exec(Option_t* option)
 
 
 //------------------------------------------------------------------------
-Bool_t AliSTARTDigitizer::RegisterPhotoE(AliSTARThitPhoton *hit)
+Bool_t AliSTARTDigitizer::RegisterPhotoE(/*AliSTARThitPhoton *hit*/)
 {
     Double_t    P = 0.2;    
     Double_t    p;