]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/AliRICHDigitizer.cxx
Separated TOF libraries (base,rec,sim)
[u/mrichter/AliRoot.git] / RICH / AliRICHDigitizer.cxx
index 3eaa2806e80798452c1d596c5f8a03b292dec9a8..dbca6d8572b6005c3ea582d90cb62c3378cbbe4e 100644 (file)
@@ -36,16 +36,15 @@ Bool_t AliRICHDigitizer::Init()
 {
 //This methode is called from AliRunDigitizer after the corresponding file is open
   if(GetDebug())Info("Init","Start.");
-  AliRunLoader *pOutAL = 
-    AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+  AliRunLoader *pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
   if (!pOutAL->GetAliRun()) pOutAL->LoadgAlice();
-  fRich=(AliRICH*)pOutAL->GetAliRun()->GetDetector("RICH");
-  Rich()->P()->GenSigmaThMap();
+  fRich=(AliRICH*)pOutAL->GetAliRun()->GetDetector("RICH");//retrive RICH pointer from OUTPUT stream
   return kTRUE;
 }//Init()
 //__________________________________________________________________________________________________
 void AliRICHDigitizer::Exec(Option_t*)
 {
+//this method invoked   
   if(GetDebug())Info("Exec","Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr());
   
   AliRunLoader *pInAL=0, *pOutAL;//in and out Run loaders
@@ -53,47 +52,52 @@ void AliRICHDigitizer::Exec(Option_t*)
  
   pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
   pOutRL = pOutAL->GetLoader("RICHLoader");
-  pOutRL->MakeTree("D");   Rich()->MakeBranch("D"); //create TreeD with RICH branches in output stream
+  pOutRL->MakeTree("D");   R()->MakeBranch("D"); //create TreeD with RICH branches in output stream
   
   TClonesArray tmpCA("AliRICHdigit");//tmp storage for sdigits sum up from all input files
   Int_t total=0;
   for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop
-    pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN)); 
+    pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN));//get run loader from current input 
     pInRL = pInAL->GetLoader("RICHLoader"); if(pInRL==0) continue;//no RICH in this input, check the next input
     if (!pInAL->GetAliRun()) pInAL->LoadgAlice();
     AliRICH* rich=(AliRICH*)pInAL->GetAliRun()->GetDetector("RICH");
     pInRL->LoadSDigits(); pInRL->TreeS()->GetEntry(0);
-    Info("Exec","input %i has %i sdigits",inFileN,rich->SDigits()->GetEntries());
-    for(Int_t i=0;i<rich->SDigits()->GetEntries();i++) {
+    if(GetDebug())Info("Exec","input %i has %i sdigits",inFileN,rich->SDigits()->GetEntries());
+    for(Int_t i=0;i<rich->SDigits()->GetEntries();i++){//collect sdigits from current input to tmpCA
       new(tmpCA[total++]) AliRICHdigit(*(AliRICHdigit*)rich->SDigits()->At(i)); 
       ((AliRICHdigit*)tmpCA[total-1])->AddTidOffset(fManager->GetMask(inFileN));
     }
     pInRL->UnloadSDigits();   rich->ResetSDigits();
   }//files loop
   
-  tmpCA.Sort();                     //sort them according to Id() methode
+  tmpCA.Sort();                     //sort them according to Id() method
   
-  Int_t chFbMip=0,chamber=0,x=0,y=0,tid[3],id=0; Double_t q=0;
+  if(GetDebug()) {tmpCA.Print();Info("Exec","Totally %i sdigits in %i inputs",tmpCA.GetEntries(),fManager->GetNinputs());}
+  Int_t cfm=0,chamber=0,id=0; //cfm is cerenkov feedback mip mixture
+  TVector pad(2); pad[0]=0;pad[1]=0;
+  Double_t q=0;
+  Int_t tid[3]={0,0,0};
   Int_t iNdigitsPerPad=0;//how many sdigits for a given pad
   for(Int_t i=0;i<tmpCA.GetEntries();i++){//sdigits loop (sorted)
     AliRICHdigit *pSdig=(AliRICHdigit*)tmpCA.At(i);//get new sdigit
     if(pSdig->Id()==id){//still the same pad
-      iNdigitsPerPad++;         q+=pSdig->Q();       chFbMip+=pSdig->ChFbMi();//sum up charge and cfm
-      if(iNdigitsPerPad<=3)        tid[iNdigitsPerPad-1]=pSdig->Tid(0);
+      iNdigitsPerPad++;         q+=pSdig->Q();       cfm+=pSdig->ChFbMi();//sum up charge and cfm
+      if(pSdig->ChFbMi()==1) tid[0] = pSdig->GetTrack(0); // force the first tid to be mip's tid if it exists in the current pad
+      if(iNdigitsPerPad<=3)        tid[iNdigitsPerPad-1]=pSdig->GetTrack(0);
       else                         if(GetDebug())Warning("Exec","More then 3 sdigits for the given pad");
     }else{//new pad, add the pevious one
-        if(id!=kBad&&Rich()->P()->IsOverTh(chamber,x,y,q)) Rich()->AddDigit(chamber,x,y,(Int_t)q,chFbMip,tid); //add newly created dig
-        chFbMip=pSdig->ChFbMi(); chamber=pSdig->C(); id=pSdig->Id();  x=pSdig->X(); y=pSdig->Y(); q=pSdig->Q();  //init all values by current sdig
-        iNdigitsPerPad=1; tid[0]=pSdig->Tid(0); tid[1]=tid[2]=kBad;
+        if(id!=kBad&&R()->P()->IsOverTh(chamber,pad,q)) R()->AddDigit(chamber,pad,(Int_t)q,cfm,tid); //add newly created dig
+        cfm=pSdig->ChFbMi(); chamber=pSdig->C(); id=pSdig->Id();  pad=pSdig->Pad(); q=pSdig->Q();  //init all values by current sdig
+        iNdigitsPerPad=1; tid[0]=pSdig->GetTrack(0); tid[1]=tid[2]=kBad;
       }
   }//sdigits loop (sorted)
-  if(tmpCA.GetEntries()&&Rich()->P()->IsOverTh(chamber,x,y,q)) Rich()->AddDigit(chamber,x,y,(Int_t)q,chFbMip,tid);//add the last dig
+  if(tmpCA.GetEntries()&&R()->P()->IsOverTh(chamber,pad,q)) R()->AddDigit(chamber,pad,(Int_t)q,cfm,tid);//add the last dig
   
   pOutRL->TreeD()->Fill();              //fill the tree with the list of digits
   pOutRL->WriteDigits("OVERWRITE");     //serialize them to file
   
   tmpCA.Clear();
-  pOutRL->UnloadDigits();   Rich()->ResetDigits();
+  pOutRL->UnloadDigits();   R()->ResetDigits();
             
   if(GetDebug())Info("Exec","Stop.");
 }//Exec()