]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - START/AliSTARTDigitizer.cxx
rotated geomtry, fixed warnings
[u/mrichter/AliRoot.git] / START / AliSTARTDigitizer.cxx
index 90fd8be006652d2fb61161f7f5a57d95dce7ecc3..b9b4b6ea3e5debab4d3972ec433abf9072e895da 100644 (file)
@@ -35,6 +35,9 @@
 #include "AliGenEventHeader.h"
 #include "AliRun.h"
 #include "AliPDG.h"
+#include "AliLoader.h"
+#include "AliRunLoader.h"
+#include "AliSTARTLoader.h"
 
 #include <stdlib.h>
 #include <Riostream.h>
@@ -81,10 +84,16 @@ Bool_t AliSTARTDigitizer::Init()
 
 //---------------------------------------------------------------------
 
-void AliSTARTDigitizer::Exec(Option_t* option)
+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 +103,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;
@@ -110,13 +118,15 @@ void AliSTARTDigitizer::Exec(Option_t* option)
   fRightADC = new TArrayI(12); 
   fLeftADC = new TArrayI(12); 
   
-
-  fHits = new TClonesArray ("AliSTARThit", 1000);
+  inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
+  inRL->LoadgAlice();
+  
+  //  fHits = new TClonesArray ("AliSTARThit", 1000);
   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();
@@ -124,8 +134,6 @@ void AliSTARTDigitizer::Exec(Option_t* option)
   Int_t nFiles=fManager->GetNinputs();
   for (Int_t inputFile=0; inputFile<nFiles;  inputFile++) {
 
-
     besttimeright=9999.;
     besttimeleft=9999.;
     Int_t timeDiff=0;
@@ -136,10 +144,17 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        timeright[i0]=0; timeleft[i0]=0;
        CountEr[i0]=0;   CountEl[i0]=0;
       }
-    TClonesArray *STARThits = START->Hits ();
-    TClonesArray *STARThitsPhotons = START->Photons ();
 
-   TTree *th = fManager->GetInputTreeH(inputFile);
+    inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+    ingime = inRL->GetLoader("STARTLoader");
+    ingime->LoadHits("READ");//probably it is necessary to load them before
+    ingime->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;
+
+    TTree *th = ingime->TreeH();
     brHits = th->GetBranch("START");
     brHitPhoton = th->GetBranch("STARThitPhoton");
     if (brHits) {
@@ -153,7 +168,9 @@ void AliSTARTDigitizer::Exec(Option_t* option)
     if (ntracks<=0) return;
     // Start loop on tracks in the photon hits containers 
     // for amplitude
+    /*
     if(brHitPhoton) {
+      cout<<"brHitPhoton "<<endl; 
       for (Int_t track=0; track<ntracks;track++) {
        brHitPhoton -> GetEntry(track);;
        nhits = STARThitsPhotons->GetEntriesFast();
@@ -170,13 +187,14 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        } //hit photons
       } //track photons
     } // was photons
-
+    */
     // Start loop on tracks in the hits containers
     for (Int_t track=0; track<ntracks;track++) {
       brHits->GetEntry(track);
-      nhits = STARThits->GetEntriesFast();
+      nhits = fHits->GetEntriesFast();
+      //  cout<<" brHits hits "<<nhits<<endl;
       for (hit=0;hit<nhits;hit++) {
-       startHit   = (AliSTARThit*) STARThits->UncheckedAt(hit);
+       startHit   = (AliSTARThit*) fHits->UncheckedAt(hit);
        pmt=startHit->fPmt;
        volume = startHit->fVolume;
        if(volume==1){
@@ -198,24 +216,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.;
@@ -267,26 +285,37 @@ void AliSTARTDigitizer::Exec(Option_t* option)
       }
     else
       {timeAv=999999; timeDiff=99999;}
-    
-    // trick to find out output dir:
+
+// 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];
     TDirectory *wd = gDirectory;
     outTree->GetDirectory()->cd();
-    sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
     fdigits->Write(nameDigits);
     cout<<nameDigits<<endl;
     wd->cd();
+*/  
+
+     Char_t nameDigits[20];
+    sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
+    fdigits->Write(nameDigits);
+
+    //    outgime->WriteDigits("OVERWRITE");
   }
 }
 
 
 //------------------------------------------------------------------------
-Bool_t AliSTARTDigitizer::RegisterPhotoE(AliSTARThitPhoton *hit)
+Bool_t AliSTARTDigitizer::RegisterPhotoE(/*AliSTARThitPhoton *hit*/)
 {
     Double_t    P = 0.2;    
     Double_t    p;
@@ -297,3 +326,4 @@ Bool_t AliSTARTDigitizer::RegisterPhotoE(AliSTARThitPhoton *hit)
     
     return kTRUE;
 }
+//----------------------------------------------------------------------------