]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSDigitizer.cxx
Coding convention obeyed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSDigitizer.cxx
index aa47cf42ed17ecc61fbd596e44b46344df2985a5..bd9b8ddab496710c7cf197c4f2cfcf6510935752 100644 (file)
@@ -165,8 +165,7 @@ void AliPHOSDigitizer::Digitize(const Int_t event)
   // get first the sdigitizer from the tasks list (must have same name as the digitizer)
   const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName()); 
   if ( !sDigitizer) {
   // get first the sdigitizer from the tasks list (must have same name as the digitizer)
   const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName()); 
   if ( !sDigitizer) {
-    Error("Digitize", "SDigitizer with name %s not found", GetName() ) ; 
-    abort() ; 
+    Fatal("Digitize", "SDigitizer with name %s not found", GetName() ) ; 
   }
     
   // loop through the sdigits posted to the White Board and add them to the noise
   }
     
   // loop through the sdigits posted to the White Board and add them to the noise
@@ -359,6 +358,8 @@ void AliPHOSDigitizer::Digitize(const Int_t event)
 //____________________________________________________________________________
 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
 {
 //____________________________________________________________________________
 Int_t AliPHOSDigitizer::DigitizeEnergy(Float_t energy, Int_t absId)
 {
+  // Returns digitized value of the energy in a cell absId
+
   Int_t chanel ;
   if(absId <= fEmcCrystals){ //digitize as EMC 
     chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;       
   Int_t chanel ;
   if(absId <= fEmcCrystals){ //digitize as EMC 
     chanel = (Int_t) TMath::Ceil((energy - fADCpedestalEmc)/fADCchanelEmc) ;       
@@ -471,8 +472,10 @@ void AliPHOSDigitizer::Exec(Option_t *option)
 }
 
 //____________________________________________________________________________ 
 }
 
 //____________________________________________________________________________ 
-Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) 
-{ // 
+Float_t AliPHOSDigitizer::FrontEdgeTime(TClonesArray * ticks) const
+{
+  // Returns the shortest time among all time ticks
+
   ticks->Sort() ; //Sort in accordance with times of ticks
   TIter it(ticks) ;
   AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
   ticks->Sort() ; //Sort in accordance with times of ticks
   TIter it(ticks) ;
   AliPHOSTick * ctick = (AliPHOSTick *) it.Next() ;
@@ -548,6 +551,8 @@ Bool_t AliPHOSDigitizer::Init()
 //____________________________________________________________________________ 
 void AliPHOSDigitizer::InitParameters()
 {
 //____________________________________________________________________________ 
 void AliPHOSDigitizer::InitParameters()
 {
+  // Set initial parameters for Digitizer
+
   fPinNoise           = 0.004 ;
   fEMCDigitThreshold  = 0.012 ;
   fCPVNoise           = 0.01;
   fPinNoise           = 0.004 ;
   fEMCDigitThreshold  = 0.012 ;
   fCPVNoise           = 0.01;
@@ -568,7 +573,7 @@ void AliPHOSDigitizer::InitParameters()
 }
 
 //__________________________________________________________________
 }
 
 //__________________________________________________________________
-void AliPHOSDigitizer::MixWith(const char* headerFile)
+void AliPHOSDigitizer::MixWith(const char* headerFile,const char* brname)
 {
   // Allows to produce digits by superimposing background and signal event.
   // It is assumed, that headers file with SIGNAL events is opened in 
 {
   // Allows to produce digits by superimposing background and signal event.
   // It is assumed, that headers file with SIGNAL events is opened in 
@@ -599,16 +604,17 @@ void AliPHOSDigitizer::MixWith(const char* headerFile)
   // before it was ???? "Folders/RunMC/Event/Data/PHOS/SDigits" ; 
   path += headerFile ; 
   path += "/" ; 
   // before it was ???? "Folders/RunMC/Event/Data/PHOS/SDigits" ; 
   path += headerFile ; 
   path += "/" ; 
-  path += GetName() ;
+  if(brname)
+     path += brname ; 
+  else
+    path += GetName() ;
   if ( gROOT->FindObjectAny(path.Data()) ) {
     Warning("MixWith", "Entry already exists, do not add\n" ) ;
     return;
   }
   if ( gROOT->FindObjectAny(path.Data()) ) {
     Warning("MixWith", "Entry already exists, do not add\n" ) ;
     return;
   }
-  
   gime->PostSDigits(GetName(),headerFile) ;
   gime->PostSDigits(GetName(),headerFile) ;
-  
   // check if the requested file is already open or exist and if SDigits Branch exist
   // check if the requested file is already open or exist and if SDigits Branch exist
-  TFile * file = (TFile*)gROOT->FindObject(headerFile); 
+  TFile * file = (TFile*)gROOT->GetFile(headerFile); 
   if ( !file ) { 
     file = new TFile(headerFile, "READ") ; 
     if (!file) { 
   if ( !file ) { 
     file = new TFile(headerFile, "READ") ; 
     if (!file) { 
@@ -628,10 +634,10 @@ void AliPHOSDigitizer::Print(Option_t* option)const
     message += GetName() ; 
     message += "-------------\n" ;
 
     message += GetName() ; 
     message += "-------------\n" ;
 
-    const Int_t nStreams = GetNInputStreams() ; 
-    if (nStreams) {
+    const Int_t kNStreams = GetNInputStreams() ; 
+    if (kNStreams) {
       Int_t index = 0 ;  
       Int_t index = 0 ;  
-      for (index = 0 ; index < nStreams ; index++) {  
+      for (index = 0 ; index < kNStreams ; index++) {  
        message += "Adding SDigits " ; 
        message += GetName() ;
        message += "from " ; 
        message += "Adding SDigits " ; 
        message += GetName() ;
        message += "from " ; 
@@ -682,12 +688,13 @@ void AliPHOSDigitizer::Print(Option_t* option)const
   message += gAlice->GetEvNumber() ;
   message += "\n       Number of entries in Digits list " ;  
   message += digits->GetEntriesFast()  ;  
   message += gAlice->GetEvNumber() ;
   message += "\n       Number of entries in Digits list " ;  
   message += digits->GetEntriesFast()  ;  
-  
+  char * tempo = new char[8192]; 
   if(strstr(option,"all")||strstr(option,"EMC")){  
     //loop over digits
     AliPHOSDigit * digit;
     message += "\nEMC digits (with primaries):\n"  ;
   if(strstr(option,"all")||strstr(option,"EMC")){  
     //loop over digits
     AliPHOSDigit * digit;
     message += "\nEMC digits (with primaries):\n"  ;
-    message += "Digit Id Amplitude Index Nprim  Primaries list\n" ; 
+    message += "\n   Id  Amplitude    Time          Index Nprim: Primaries list \n" ;    
     Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
     Int_t index ;
     for (index = 0 ; (index < digits->GetEntriesFast()) && 
     Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
     Int_t index ;
     for (index = 0 ; (index < digits->GetEntriesFast()) && 
@@ -695,19 +702,13 @@ void AliPHOSDigitizer::Print(Option_t* option)const
       digit = (AliPHOSDigit * )  digits->At(index) ;
       if(digit->GetNprimary() == 0) 
        continue;
       digit = (AliPHOSDigit * )  digits->At(index) ;
       if(digit->GetNprimary() == 0) 
        continue;
-      message += "\n" ; 
-      message += digit->GetId() ; 
-      message += " " ; 
-      message += digit->GetAmp() ;  
-      message += " " ; 
-      message += digit->GetIndexInList() ;      
-      message += " " ; 
-      message += digit->GetNprimary()  ;
-      message += " : " ; 
+      sprintf(tempo, "\n%6d  %8d    %6.5e %4d      %2d :",
+             digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;  
+      message += tempo ; 
       Int_t iprimary;
       for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
       Int_t iprimary;
       for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
-       message += digit->GetPrimary(iprimary+1)  ;
-       message += " " ; 
+       sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ; 
+       message += tempo ; 
       }    
     }
   }
       }    
     }
   }
@@ -717,36 +718,30 @@ void AliPHOSDigitizer::Print(Option_t* option)const
     //loop over CPV digits
     AliPHOSDigit * digit;
     message += "\nCPV digits:\n" ;
     //loop over CPV digits
     AliPHOSDigit * digit;
     message += "\nCPV digits:\n" ;
-    message += "Digit Id Amplitude Index Nprim Primaries list\n" ;
+    message += "\n   Id  Amplitude    Index Nprim: Primaries list \n" ;    
 
     Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
     Int_t index ;
     for (index = 0 ; index < digits->GetEntriesFast(); index++) {
       digit = (AliPHOSDigit * )  digits->At(index) ;
       if(digit->GetId() > maxEmc){
 
     Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
     Int_t index ;
     for (index = 0 ; index < digits->GetEntriesFast(); index++) {
       digit = (AliPHOSDigit * )  digits->At(index) ;
       if(digit->GetId() > maxEmc){
-       message += "\n" ; 
-       message += digit->GetId();  
-       message += " " ; 
-       message += digit->GetAmp() ; 
-       message += " " ; 
-       message += digit->GetIndexInList() ;  
-       message += " " ; 
-       message += digit->GetNprimary() ;
-       message += " : " ; 
-       
+       sprintf(tempo, "\n%6d  %8d    %4d      %2d :",
+               digit->GetId(), digit->GetAmp(), digit->GetIndexInList(), digit->GetNprimary()) ;  
+       message += tempo ; 
        Int_t iprimary;
        for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
        Int_t iprimary;
        for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
-         message += digit->GetPrimary(iprimary+1)  ;
-         message += " " ; 
+         sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ; 
+         message += tempo ; 
        }    
       }
     }
   }
        }    
       }
     }
   }
+  delete tempo ; 
   Info("Print", message.Data() ) ; 
 }
 
 //__________________________________________________________________
   Info("Print", message.Data() ) ; 
 }
 
 //__________________________________________________________________
-Float_t AliPHOSDigitizer::TimeOfNoise(void)
+Float_t AliPHOSDigitizer::TimeOfNoise(void) const
 {  // Calculates the time signal generated by noise
   //to be rewritten, now returns just big number
   return 1. ;
 {  // Calculates the time signal generated by noise
   //to be rewritten, now returns just big number
   return 1. ;