]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Simulation parameters collected in AliPHOSSimParam
authorprsnko <prsnko@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Mar 2008 18:16:37 +0000 (18:16 +0000)
committerprsnko <prsnko@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Mar 2008 18:16:37 +0000 (18:16 +0000)
13 files changed:
PHOS/AliPHOS.cxx
PHOS/AliPHOSAnalyze.cxx
PHOS/AliPHOSDigitizer.cxx
PHOS/AliPHOSDigitizer.h
PHOS/AliPHOSJetFinder.cxx
PHOS/AliPHOSSDigitizer.cxx
PHOS/AliPHOSSDigitizer.h
PHOS/AliPHOSSimParam.cxx [new file with mode: 0644]
PHOS/AliPHOSSimParam.h [new file with mode: 0644]
PHOS/AliPHOSv1.cxx
PHOS/AliPHOSv1.h
PHOS/PHOSbaseLinkDef.h
PHOS/libPHOSbase.pkg

index 4e93e6197825008193b41f1cf5de7537c68dd7c2..d4131c882e7edf15082de71ffada55656da8e1c2 100644 (file)
@@ -97,6 +97,7 @@ class TFile;
 #include "AliPHOSRawDigiProducer.h"
 #include "AliPHOSQAChecker.h"
 #include "AliPHOSRecoParamEmc.h"
+#include "AliPHOSSimParam.h"
 
 ClassImp(AliPHOS)
 
@@ -417,6 +418,10 @@ void AliPHOS::Digits2Raw()
 {
 // convert digits of the current event to raw data
   
+  if(AliPHOSSimParam::GetInstance()->IsEDigitizationOn()){
+    AliError("Energy digitization should be OFF if use Digits2Raw") ;
+  }
+
   AliPHOSLoader * loader = dynamic_cast<AliPHOSLoader*>(fLoader) ; 
 
   // get the digits
index b198b1f77333a8bab2850ea09867e180b939588b..bf71e8b7a4f697226aaec4d851ce9521a25a8225 100644 (file)
@@ -260,8 +260,7 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod){
        phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
        Float_t x,z ;
        phosgeom->RelPosInModule(relid,x,z);
-       AliPHOSSDigitizer* sd = dynamic_cast<AliPHOSSDigitizer*>(gime->SDigitizer());
-       Float_t e = sd->Calibrate(sdigit->GetAmp()) ;
+       Float_t e = sdigit->GetEnergy() ;
        nsdig[relid[0]-1]++ ;
        if(relid[0]==Nmod){
          if(relid[1]==0)  //EMC
@@ -288,8 +287,7 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod){
        phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
        Float_t x,z ;
        phosgeom->RelPosInModule(relid,x,z) ;
-       AliPHOSSDigitizer* sd = dynamic_cast<AliPHOSSDigitizer*>(gime->SDigitizer());
-       Float_t e = sd->Calibrate(digit->GetAmp()) ;
+       Float_t e = digit->GetEnergy() ;
        if(relid[0]==Nmod){
          if(relid[1]==0)  //EMC
            emcDigits->Fill(x,z,e) ;
index 742e35e7ce8e11ff6d3e64a5296b95950a231fa9..69621c9f3636ec02d08e30c86f33b28c44b7f01e 100644 (file)
 #include "TSystem.h"
 #include "TBenchmark.h"
 #include "TRandom.h"
+#include "TMath.h"
 
 // --- Standard library ---
 
 #include "AliLog.h"
 #include "AliRunDigitizer.h"
 #include "AliPHOSDigit.h"
-#include "AliPHOSGetter.h"
 #include "AliPHOSDigitizer.h"
-#include "AliPHOSSDigitizer.h"
 #include "AliPHOSGeometry.h"
 #include "AliPHOSTick.h"
+#include "AliPHOSSimParam.h"
+#include "AliPHOSCalibData.h"
+#include "AliRunLoader.h"
+#include "AliPHOSLoader.h"
 
 ClassImp(AliPHOSDigitizer)
 
@@ -150,23 +153,10 @@ AliPHOSDigitizer::AliPHOSDigitizer() :
   fInputFileNames(0x0),
   fEventNames(0x0),
   fEmcCrystals(0),
-  fPinNoise(0.f),
-  fEMCDigitThreshold(0.f),
-  fCPVNoise(0.f),
-  fCPVDigitThreshold(0.f),
-  fTimeResolution(0.f),
-  fTimeThreshold(0.f),
-  fTimeSignalLength(0.f),
-  fADCchanelEmc(0.f),
-  fADCpedestalEmc(0.f),
-  fNADCemc(0),
-  fADCchanelCpv(0.f),
-  fADCpedestalCpv(0.f),
-  fNADCcpv(0),
   fEventFolderName(""),
   fFirstEvent(0),
   fLastEvent(0), 
-//  fQADM (0x0), 
+  fcdb(0x0),
   fEventCounter(0)
 {
   // ctor
@@ -185,23 +175,10 @@ AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
   fInputFileNames(0x0),
   fEventNames(0x0),
   fEmcCrystals(0),
-  fPinNoise(0.f),
-  fEMCDigitThreshold(0.f),
-  fCPVNoise(0.f),
-  fCPVDigitThreshold(0.f),
-  fTimeResolution(0.f),
-  fTimeThreshold(0.f),
-  fTimeSignalLength(0.f),
-  fADCchanelEmc(0.f),
-  fADCpedestalEmc(0.f),
-  fNADCemc(0),
-  fADCchanelCpv(0.f),
-  fADCpedestalCpv(0.f),
-  fNADCcpv(0),
   fEventFolderName(eventFolderName),
   fFirstEvent(0),
   fLastEvent(0), 
-//  fQADM (0x0), 
+  fcdb(0x0),
   fEventCounter(0)
 {
   // ctor
@@ -209,13 +186,7 @@ AliPHOSDigitizer::AliPHOSDigitizer(TString alirunFileName,
   Init() ;
   fDefaultInit = kFALSE ; 
   fManager = 0 ;                     // We work in the standalong mode
- // //Initialize the quality assurance data maker only once
-//  fQADM = new AliPHOSQADataMaker() ;  
-//  //FIXME: get the run number
-//  Int_t run = 0 ;
-//  //EMXIF    
-//   GetQADataMaker()->Init(AliQA::kDIGITS, run, fgkCycles) ;    
-//   GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;    
+  fcdb = new AliPHOSCalibData(-1);
 }
 
 //____________________________________________________________________________ 
@@ -228,35 +199,16 @@ AliPHOSDigitizer::AliPHOSDigitizer(const AliPHOSDigitizer & d) :
   fInputFileNames(0x0),//?
   fEventNames(0x0),//?
   fEmcCrystals(d.fEmcCrystals),
-  fPinNoise(d.fPinNoise),
-  fEMCDigitThreshold(d.fEMCDigitThreshold),
-  fCPVNoise(d.fCPVNoise),
-  fCPVDigitThreshold(d.fCPVDigitThreshold),
-  fTimeResolution(d.fTimeResolution),
-  fTimeThreshold(d.fTimeThreshold),
-  fTimeSignalLength(d.fTimeSignalLength),
-  fADCchanelEmc(d.fADCchanelEmc),
-  fADCpedestalEmc(d.fADCpedestalEmc),
-  fNADCemc(d.fNADCemc),
-  fADCchanelCpv(d.fADCchanelCpv),
-  fADCpedestalCpv(d.fADCpedestalCpv),
-  fNADCcpv(d.fNADCcpv),
   fEventFolderName(d.fEventFolderName),
   fFirstEvent(d.fFirstEvent),
   fLastEvent(d.fLastEvent), 
-//  fQADM (d.fQADM), 
+  fcdb (0x0), 
   fEventCounter(0)
-
 {
   // copyy ctor 
   SetName(d.GetName()) ; 
   SetTitle(d.GetTitle()) ; 
-//Initialize the quality assurance data maker only once
- //FIXME: get the run number
-//  Int_t run = 0 ;
-//  //EMXIF    
-//  GetQADataMaker()->Init(AliQA::kDIGITS, run, fgkCycles) ;    
-//  GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;    
+  fcdb = new AliPHOSCalibData(-1);
 }
 
 //____________________________________________________________________________ 
@@ -269,23 +221,10 @@ AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd) :
   fInputFileNames(0x0),
   fEventNames(0x0),
   fEmcCrystals(0),
-  fPinNoise(0.f),
-  fEMCDigitThreshold(0.f),
-  fCPVNoise(0.f),
-  fCPVDigitThreshold(0.f),
-  fTimeResolution(0.f),
-  fTimeThreshold(0.f),
-  fTimeSignalLength(0.f),
-  fADCchanelEmc(0.f),
-  fADCpedestalEmc(0.f),
-  fNADCemc(0),
-  fADCchanelCpv(0.f),
-  fADCpedestalCpv(0.f),
-  fNADCcpv(0),
   fEventFolderName(fManager->GetInputFolderName(0)),
   fFirstEvent(0),
   fLastEvent(0), 
-//  fQADM (0x0), 
+  fcdb (0x0), 
   fEventCounter(0)
 
 {
@@ -294,27 +233,23 @@ AliPHOSDigitizer::AliPHOSDigitizer(AliRunDigitizer * rd) :
   SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
   InitParameters() ; 
   fDefaultInit = kFALSE ; 
-//Initialize the quality assurance data maker only once
-//  fQADM = new AliPHOSQADataMaker() ;  
-// //FIXME: get the run number
-//  Int_t run = 0 ;
-//  //EMXIF    
-//  GetQADataMaker()->Init(AliQA::kDIGITS, run) ;    
-//  GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ;    
+  fcdb = new AliPHOSCalibData(-1);
 }
 
 //____________________________________________________________________________ 
   AliPHOSDigitizer::~AliPHOSDigitizer()
 {
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
-
-  // Clean Digitizer from the white board
-  gime->PhosLoader()->CleanDigitizer() ;
   // dtor
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  if(rl){                                                                                                                               
+    AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));                                                                 
+    phosLoader->CleanDigitizer() ;
+  }
+
   delete [] fInputFileNames ; 
   delete [] fEventNames ; 
 
-//  delete fQADM ; 
+  if(fcdb){ delete fcdb ; fcdb=0;} 
 
 }
 
@@ -329,17 +264,33 @@ void AliPHOSDigitizer::Digitize(Int_t event)
   // This design avoids scanning over the list of digits to add 
   // contribution to new SDigits only.
 
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; 
-  Int_t ReadEvent = event ; 
+
+  Bool_t toMakeNoise = kTRUE ; //Do not create noisy digits if merge with real data
+
+  //First stream 
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));                                                                
+
+  Int_t readEvent = event ; 
   if (fManager) 
-    ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ; 
+    readEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ; 
   AliDebug(1,Form("Adding event %d from input stream 0 %s %s", 
-                 ReadEvent, GetTitle(), fEventFolderName.Data())) ; 
-  gime->Event(ReadEvent, "S") ;
-  TClonesArray * digits = gime->Digits() ; 
+                 readEvent, GetTitle(), fEventFolderName.Data())) ; 
+  rl->GetEvent(readEvent) ;
+  phosLoader->CleanSDigits() ; 
+  phosLoader->LoadSDigits("READ") ;
+
+  //Prepare Output
+  TClonesArray * digits = phosLoader->Digits() ;
+  if( !digits ) {
+    phosLoader->MakeDigitsArray() ; 
+    digits = phosLoader->Digits() ;
+  }
   digits->Clear() ;
 
-  const AliPHOSGeometry *geom = gime->PHOSGeometry() ; 
+  //
+  const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
   //Making digits with noise, first EMC
   Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ();
   
@@ -350,35 +301,52 @@ void AliPHOSDigitizer::Digitize(Int_t event)
   
   digits->Expand(nCPV) ;
 
-  // get first the sdigitizer from the tasks list 
-  if ( !gime->SDigitizer() ) 
-    gime->LoadSDigitizer();
-  AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(); 
-
-  if ( !sDigitizer )
-    AliFatal(Form("SDigitizer with name %s %s not found", 
-                 GetTitle(), fEventFolderName.Data() )) ; 
-
   //take all the inputs to add together and load the SDigits
   TObjArray * sdigArray = new TObjArray(fInput) ;
-  sdigArray->AddAt(gime->SDigits(), 0) ;
-  Int_t i ;
-  for(i = 1 ; i < fInput ; i++){
+  sdigArray->AddAt(phosLoader->SDigits(), 0) ;
+  for(Int_t i = 1 ; i < fInput ; i++){
     TString tempo(fEventNames[i]) ; 
     tempo += i ;
-    AliPHOSGetter * gime1 = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ;
-    if (fManager) 
-      ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ; 
-    AliInfo(Form("Adding event %d from input stream %d %s %s", 
-                ReadEvent, i, fInputFileNames[i].Data(), tempo.Data())) ; 
-    gime1->Event(ReadEvent,"S");
-    sdigArray->AddAt(gime1->SDigits(), i) ;
+    AliRunLoader* rl2 = AliRunLoader::GetRunLoader(tempo) ;
+    if(!rl2){ 
+      rl2 = AliRunLoader::Open(fInputFileNames[i], tempo) ;
+      if (!rl2) {
+        Fatal("AliPHOSDigitizer", "Could not find the Run Loader for %s - %s",fInputFileNames[i].Data(), tempo.Data()) ;
+        return ;
+      }
+      rl2->LoadHeader();
+    }
+    AliPHOSLoader * phosLoader2 = dynamic_cast<AliPHOSLoader*>(rl2->GetLoader("PHOSLoader"));
+    if(fManager){ 
+      readEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ; 
+    }
+    TClonesArray * digs ;
+    if(AliPHOSSimParam::GetInstance()->IsStreamDigits(i)){ //This is Digits Stream
+      AliInfo(Form("Adding event %d from input stream %d %s %s", 
+                readEvent, i, fInputFileNames[i].Data(), tempo.Data())) ; 
+       rl2->GetEvent(readEvent) ;
+       phosLoader2->CleanDigits() ;
+       phosLoader2->LoadDigits("READ") ;
+       digs = phosLoader2->Digits() ;
+       toMakeNoise=0 ; //Do not add noise, it is already in stream
+    }
+    else{
+      AliInfo(Form("Adding event %d (SDigits) from input stream %d %s %s",
+                 readEvent, i, fInputFileNames[i].Data(), tempo.Data())) ;
+       rl2->GetEvent(readEvent) ;
+       phosLoader2->CleanSDigits() ; 
+       phosLoader2->LoadSDigits("READ") ;
+       digs = phosLoader2->SDigits() ;
+    } 
+    sdigArray->AddAt(digs, i) ;
   }
 
   //Find the first crystal with signal
   Int_t nextSig = 200000 ; 
   TClonesArray * sdigits ;  
-  for(i = 0 ; i < fInput ; i++){
+  for(Int_t i = 0 ; i < fInput ; i++){
     sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
     if ( !sdigits->GetEntriesFast() )
       continue ; 
@@ -393,30 +361,38 @@ void AliPHOSDigitizer::Digitize(Int_t event)
   AliPHOSDigit * digit ;
   AliPHOSDigit * curSDigit ;
   
-  TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
+//  TClonesArray * ticks = new TClonesArray("AliPHOSTick",1000) ;
   
   //Put Noise contribution
+  Double_t apdNoise = 0. ;
+  if(toMakeNoise)
+     apdNoise = AliPHOSSimParam::GetInstance()->GetAPDNoise() ; 
+
   for(absID = 1 ; absID <= nEMC ; absID++){
-    Float_t noise = gRandom->Gaus(0., fPinNoise) ; 
-    // YVK: do not digitize amplitudes for EMC
-//     new((*digits)[absID-1]) AliPHOSDigit( -1, absID, sDigitizer->Digitize(noise), TimeOfNoise() ) ;
+    Float_t noise = gRandom->Gaus(0.,apdNoise) ; 
     new((*digits)[absID-1]) AliPHOSDigit( -1, absID, noise, TimeOfNoise() ) ;
     //look if we have to add signal?
     digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
     
     if(absID==nextSig){
       //Add SDigits from all inputs 
-      ticks->Clear() ;
-      Int_t contrib = 0 ;
-      Float_t a = digit->GetEnergy() ;
-      Float_t b = TMath::Abs( a / fTimeSignalLength) ;
-      //Mark the beginning of the signal
-      new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);  
-      //Mark the end of the signal     
-      new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b); 
+//      ticks->Clear() ;
+//      Int_t contrib = 0 ;
+
+//New Timing model is necessary
+//      Float_t a = digit->GetEnergy() ;
+//      Float_t b = TMath::Abs( a / fTimeSignalLength) ;
+//      //Mark the beginning of the signal
+//      new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime(),0, b);  
+//      //Mark the end of the signal     
+//      new((*ticks)[contrib++]) AliPHOSTick(digit->GetTime()+fTimeSignalLength, -a, -b); 
+
+// Calculate time as time of the largest digit
+      Float_t time = digit->GetTime() ;
+      Float_t eTime= digit->GetEnergy() ;
       
       //loop over inputs
-      for(i = 0 ; i < fInput ; i++){
+      for(Int_t i = 0 ; i < fInput ; i++){
        if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
          curSDigit = dynamic_cast<AliPHOSDigit*>(dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;       
        else
@@ -431,10 +407,15 @@ void AliPHOSDigitizer::Digitize(Int_t event)
            primaryoffset = 10000000*i ;
          curSDigit->ShiftPrimary(primaryoffset) ;
          
-         a = curSDigit->GetEnergy() ;
-         b = a /fTimeSignalLength ;
-         new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);  
-         new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); 
+//New Timing model is necessary
+//       a = curSDigit->GetEnergy() ;
+//       b = a /fTimeSignalLength ;
+//       new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime(),0, b);  
+//       new((*ticks)[contrib++]) AliPHOSTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); 
+          if(curSDigit->GetEnergy()>eTime){
+            eTime=curSDigit->GetEnergy() ;
+            time=curSDigit->GetTime() ;
+          }
          
          *digit += *curSDigit ;  //add energies
 
@@ -447,12 +428,13 @@ void AliPHOSDigitizer::Digitize(Int_t event)
       }
       
       //calculate and set time
-      Float_t time = FrontEdgeTime(ticks) ;
+//New Timing model is necessary
+//      Float_t time = FrontEdgeTime(ticks) ;
       digit->SetTime(time) ;
       
       //Find next signal module
       nextSig = 200000 ;
-      for(i = 0 ; i < fInput ; i++){
+      for(Int_t i = 0 ; i < fInput ; i++){
        sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
        Int_t curNext = nextSig ;
        if(sdigits->GetEntriesFast() > index[i] ){
@@ -462,19 +444,30 @@ void AliPHOSDigitizer::Digitize(Int_t event)
       }
     }
   }
+
+  //distretize energy if necessary
+  if(AliPHOSSimParam::GetInstance()->IsEDigitizationOn()){
+    Float_t adcW=AliPHOSSimParam::GetInstance()->GetADCchannelW() ;
+    for(Int_t i = 0 ; i < nEMC ; i++){                                                                                                       
+      digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
+      digit->SetEnergy(adcW*ceil(digit->GetEnergy()/adcW)) ;
+    } 
+  }
+
   
-  ticks->Delete() ;
-  delete ticks ;
+//  ticks->Delete() ;
+//  delete ticks ;
   
   //Now CPV digits (different noise and no timing)
+  Float_t cpvNoise = AliPHOSSimParam::GetInstance()->GetCPVNoise() ;
   for(absID = nEMC+1; absID <= nCPV; absID++){
-    Float_t noise = gRandom->Gaus(0., fCPVNoise) ; 
-    new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise), TimeOfNoise() ) ;
+    Float_t noise = gRandom->Gaus(0., cpvNoise) ; 
+    new((*digits)[absID-1]) AliPHOSDigit( -1,absID,noise, TimeOfNoise() ) ;
     //look if we have to add signal?
     if(absID==nextSig){
       digit = dynamic_cast<AliPHOSDigit *>(digits->At(absID-1)) ;
       //Add SDigits from all inputs
-      for(i = 0 ; i < fInput ; i++){
+      for(Int_t i = 0 ; i < fInput ; i++){
        if( dynamic_cast<TClonesArray *>(sdigArray->At(i))->GetEntriesFast() > index[i] )
          curSDigit = dynamic_cast<AliPHOSDigit*>( dynamic_cast<TClonesArray *>(sdigArray->At(i))->At(index[i])) ;      
        else
@@ -502,7 +495,7 @@ void AliPHOSDigitizer::Digitize(Int_t event)
 
       //Find next signal module
       nextSig = 200000 ;
-      for(i = 0 ; i < fInput ; i++){
+      for(Int_t i = 0 ; i < fInput ; i++){
        sdigits = dynamic_cast<TClonesArray *>(sdigArray->At(i)) ;
        Int_t curNext = nextSig ;
        if(sdigits->GetEntriesFast() > index[i] )
@@ -518,47 +511,48 @@ void AliPHOSDigitizer::Digitize(Int_t event)
   Int_t relId[4];
 
   //set amplitudes in bad channels to zero
-  if(!gime->CalibData()) {
-    AliPHOSCalibData* cdb = new AliPHOSCalibData(-1);
-    gime->SetCalibData(cdb);
-  }
-  for(i = 0 ; i <digits->GetEntries(); i++){
+
+  for(Int_t i = 0 ; i <digits->GetEntries(); i++){
     digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
-    gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
+    geom->AbsToRelNumbering(digit->GetId(),relId);
     if(relId[1] == 0) // Emc
-      if(gime->CalibData()->IsBadChannelEmc(relId[0],relId[3],relId[2])) digit->SetEnergy(0.); 
+      if(fcdb->IsBadChannelEmc(relId[0],relId[3],relId[2])) digit->SetEnergy(0.); 
   }
 
   //remove digits below thresholds
-  for(i = 0 ; i < nEMC ; i++){
+  Float_t emcThreshold = AliPHOSSimParam::GetInstance()->GetEmcDigitsThreshold() ;
+  for(Int_t i = 0 ; i < nEMC ; i++){
     digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ;
-//By default no decalibration should be applyed
-//    DecalibrateEMC(digit);
 
-    if(digit->GetEnergy() < fEMCDigitThreshold)
+    if(digit->GetEnergy() < emcThreshold){
       digits->RemoveAt(i) ;
-    else
-      digit->SetTime(gRandom->Gaus(digit->GetTime(),fTimeResolution) ) ;
+      continue ;
+    }
+    Float_t tres = TimeResolution(digit->GetEnergy()) ; 
+    digit->SetTime(gRandom->Gaus(digit->GetTime(), tres) ) ;
   }
 
-  for(i = nEMC; i < nCPV ; i++)
-//     if( sDigitizer->Calibrate( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetAmp() ) < fCPVDigitThreshold )
-    if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < fCPVDigitThreshold )
+  Float_t cpvDigitThreshold = AliPHOSSimParam::GetInstance()->GetCpvDigitsThreshold() ;
+  for(Int_t i = nEMC; i < nCPV ; i++){
+    if( dynamic_cast<AliPHOSDigit*>(digits->At(i))->GetEnergy() < cpvDigitThreshold )
       digits->RemoveAt(i) ;
+  } 
     
   digits->Compress() ;  
   
   Int_t ndigits = digits->GetEntriesFast() ;
   digits->Expand(ndigits) ;
 
+
   //Set indexes in list of digits and make true digitization of the energy
-  for (i = 0 ; i < ndigits ; i++) { 
+  for (Int_t i = 0 ; i < ndigits ; i++) { 
     digit = dynamic_cast<AliPHOSDigit*>( digits->At(i) ) ; 
     digit->SetIndexInList(i) ;     
     if(digit->GetId() > fEmcCrystals){ //digitize CPV only
       digit->SetAmp(DigitizeCPV(digit->GetEnergy(),digit->GetId()) ) ;
     }
   }
+
 }
 
 //____________________________________________________________________________
@@ -566,20 +560,15 @@ void AliPHOSDigitizer::DecalibrateEMC(AliPHOSDigit *digit)
 {
   // Decalibrate EMC digit, i.e. change its energy by a factor read from CDB
 
-  AliPHOSGetter* gime = AliPHOSGetter::Instance();
-
-  if(!gime->CalibData()) {
-    AliPHOSCalibData* cdb = new AliPHOSCalibData(-1);
-    gime->SetCalibData(cdb);
-  }
+  const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
 
   //Determine rel.position of the cell absolute ID
   Int_t relId[4];
-  gime->PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId);
+  geom->AbsToRelNumbering(digit->GetId(),relId);
   Int_t module=relId[0];
   Int_t row   =relId[2];
   Int_t column=relId[3];
-  Float_t decalibration = gime->CalibData()->GetADCchannelEmc(module,column,row);
+  Float_t decalibration = fcdb->GetADCchannelEmc(module,column,row);
   Float_t energy = digit->GetEnergy() / decalibration;
   digit->SetEnergy(energy);
 }
@@ -588,16 +577,11 @@ Int_t AliPHOSDigitizer::DigitizeCPV(Float_t charge, Int_t absId)
 {
   // Returns digitized value of the CPV charge in a pad absId
 
-  AliPHOSGetter* gime = AliPHOSGetter::Instance();
-
-  if(!gime->CalibData()) {
-    AliPHOSCalibData* cdb = new AliPHOSCalibData(-1); // use AliCDBManager's run number
-    gime->SetCalibData(cdb);
-  }
+  const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
 
   //Determine rel.position of the cell absId
   Int_t relId[4];
-  gime->PHOSGeometry()->AbsToRelNumbering(absId,relId);
+  geom->AbsToRelNumbering(absId,relId);
   Int_t module=relId[0];
   Int_t row   =relId[2];
   Int_t column=relId[3];
@@ -607,15 +591,12 @@ Int_t AliPHOSDigitizer::DigitizeCPV(Float_t charge, Int_t absId)
   if(absId > fEmcCrystals){ //digitize CPV only
 
     //reading calibration data for cell absId.
-    //If no calibration DB found, accept default values.
+    Float_t adcPedestalCpv = fcdb->GetADCpedestalCpv(module,column,row);
+    Float_t adcChanelCpv   = fcdb->GetADCchannelCpv( module,column,row);
 
-    if(gime->CalibData()) {
-      fADCpedestalCpv = gime->CalibData()->GetADCpedestalCpv(module,column,row);
-      fADCchanelCpv   = gime->CalibData()->GetADCchannelCpv( module,column,row);
-    }
-
-    channel = (Int_t) TMath::Ceil((charge - fADCpedestalCpv)/fADCchanelCpv) ;       
-    if(channel > fNADCcpv ) channel =  fNADCcpv ;
+    channel = (Int_t) TMath::Ceil((charge - adcPedestalCpv)/adcChanelCpv) ;       
+    Int_t nMax = AliPHOSSimParam::GetInstance()->GetNADCcpv() ;
+    if(channel > nMax ) channel = nMax ;
   }
   return channel ;
 }
@@ -640,28 +621,17 @@ void AliPHOSDigitizer::Exec(Option_t *option)
     return ; 
   }
   
- // // check the QA result for Hits and SDigits
-//  AliQA * qa = AliQA::Instance(AliQA::kPHOS) ; 
-//  if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kFATAL)) {
-//     AliFatal("QA status in Hits and/or SDIGITS was Fatal") ;
-//  } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kERROR)) {
-//     AliError("QA status in Hits and/or SDIGITS was Error") ;
-//  } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kWARNING) ) {
-//     AliWarning("QA status in Hits and/or SDIGITS was Warning") ;
-//  } else if ( qa->IsSet(AliQA::kPHOS, AliQA::kSIM, AliQA::kINFO) ) {
-//     AliInfo("QA status in Hits and/or SDIGITS was Info") ;
-//  }
-   
  if(strstr(option,"tim"))
      gBenchmark->Start("PHOSDigitizer");
   
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ;
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
 
   // Post Digitizer to the white board
-  gime->PostDigitizer(this) ;
+  phosLoader->PostDigitizer(this) ;
   
   if (fLastEvent == -1) 
-    fLastEvent = gime->MaxEvent() - 1 ;
+    fLastEvent = rl->GetNumberOfEvents() - 1 ;
   else if (fManager) 
     fLastEvent = fFirstEvent ; 
  
@@ -671,34 +641,19 @@ void AliPHOSDigitizer::Exec(Option_t *option)
 
   for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
     fEventCounter++ ; 
-    gime->Event(ievent,"S") ;
 
     Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
 
-//    //makes the quality assurance data
-//    if (GetQADataMaker()->IsCycleDone() ) {
-//      GetQADataMaker()->EndOfCycle(AliQA::kDIGITS) ; 
-//       GetQADataMaker()->StartOfCycle(AliQA::kDIGITS) ; 
-//    }
-//    GetQADataMaker()->Exec(AliQA::kDIGITS, gime->Digits()) ; 
-//     GetQADataMaker()->Increment() ;
-                                  
     WriteDigits() ;
 
     if(strstr(option,"deb"))
       PrintDigits(option);
     
     //increment the total number of Digits per run 
-    fDigitsInRun += gime->Digits()->GetEntriesFast() ;  
+    fDigitsInRun += phosLoader->Digits()->GetEntriesFast() ;  
  }
  
-//   //Write the quality assurance data only after the last event 
-// if ( fEventCounter == gime->MaxEvent() ) { 
-//    GetQADataMaker()->EndOfCycle(AliQA::kDIGITS) ;    
-//     GetQADataMaker()->Finish() ;
-//  }
-  
-  gime->PhosLoader()->CleanDigitizer();
+  phosLoader->CleanDigitizer();
 
   if(strstr(option,"tim")){
     gBenchmark->Stop("PHOSDigitizer");
@@ -709,52 +664,46 @@ void AliPHOSDigitizer::Exec(Option_t *option)
         gBenchmark->GetCpuTime("PHOSDigitizer")/nEvents )); 
   } 
 }
-
 //____________________________________________________________________________ 
-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() ;
-  Float_t time = ctick->CrossingTime(fTimeThreshold) ;    
-
-  AliPHOSTick * t ;  
-  while((t=(AliPHOSTick*) it.Next())){
-    if(t->GetTime() < time)  //This tick starts before crossing
-      *ctick+=*t ;
-    else
-      return time ;
-
-    time = ctick->CrossingTime(fTimeThreshold) ;    
-  }
-  return time ;
+Float_t AliPHOSDigitizer::TimeResolution(Float_t e){
+  //calculate TOF resolution using beam-test resutls
+  Float_t a=AliPHOSSimParam::GetInstance()->GetTOFa() ;
+  Float_t b=AliPHOSSimParam::GetInstance()->GetTOFb() ;
+  return TMath::Sqrt(a*a+b*b/e) ;
 }
 
+////____________________________________________________________________________ 
+//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() ;
+//  Float_t time = ctick->CrossingTime(fTimeThreshold) ;    
+//
+//  AliPHOSTick * t ;  
+//  while((t=(AliPHOSTick*) it.Next())){
+//    if(t->GetTime() < time)  //This tick starts before crossing
+//      *ctick+=*t ;
+//    else
+//      return time ;
+//
+//    time = ctick->CrossingTime(fTimeThreshold) ;    
+//  }
+//  return time ;
+//}
+
 //____________________________________________________________________________ 
 Bool_t AliPHOSDigitizer::Init()
 {
   // Makes all memory allocations
   fInit = kTRUE ; 
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; 
-  if ( gime == 0 ) {
-    AliFatal(Form("Could not obtain the Getter object for file %s and event %s !", 
-                 GetTitle(), fEventFolderName.Data()));  
-    return kFALSE;
-  } 
-  
-  const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
+
+  const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
 
   fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ;
   
-  TString opt("Digits") ; 
-  if(gime->VersionExists(opt) ) { 
-    AliError(Form("Give a version name different from %s", 
-                 fEventFolderName.Data() )) ;
-    fInit = kFALSE ; 
-  }
-
   fFirstEvent = 0 ; 
   fLastEvent = fFirstEvent ; 
   if (fManager) 
@@ -774,7 +723,12 @@ Bool_t AliPHOSDigitizer::Init()
   }
 
   //to prevent cleaning of this object while GetEvent is called
-  gime->PhosLoader()->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  if(!rl){
+    rl = AliRunLoader::Open(GetTitle(), fEventFolderName) ; 
+  }
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+  phosLoader->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
 
   return fInit ; 
 }
@@ -784,79 +738,11 @@ void AliPHOSDigitizer::InitParameters()
 {
   // Set initial parameters Digitizer
 
-  fPinNoise           = 0.004 ;  // [GeV]
-  fEMCDigitThreshold  = 0.012 ;  // [GeV]
-  fCPVNoise           = 0.01;    // [aux units]
-  fCPVDigitThreshold  = 0.09 ;   // [aux units]
-  fTimeResolution     = 0.5e-9 ; // [sec]
-  fTimeSignalLength   = 1.0e-9 ; // [sec]
   fDigitsInRun  = 0 ; 
-  fADCchanelEmc = 1.0;        // Coefficient between real and measured energies in EMC
-  fADCpedestalEmc = 0. ;      //
-  fNADCemc = (Int_t) TMath::Power(2,16) ;  // number of channels in EMC ADC
-
-  fADCchanelCpv = 0.0012 ;          // width of one ADC channel in CPV 'popugais'
-  fADCpedestalCpv = 0.012 ;         // 
-  fNADCcpv = (Int_t) TMath::Power(2,12);      // number of channels in CPV ADC
-
-//   fTimeThreshold = 0.001*10000000 ; //Means 1 MeV in terms of SDigits amplitude
-  fTimeThreshold = 0.001 ; // [GeV]
   SetEventRange(0,-1) ;
     
 }
 
-//__________________________________________________________________
-void AliPHOSDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
-{
-  // Allows to produce digits by superimposing background and signal event.
-  // It is assumed, that headers file with SIGNAL events is opened in 
-  // the constructor. 
-  // Sets the BACKGROUND event, with which the SIGNAL event is to be mixed 
-  // Thus we avoid writing (changing) huge and expensive 
-  // backgound files: all output will be writen into SIGNAL, i.e. 
-  // opened in constructor file. 
-  //
-  // One can open as many files to mix with as one needs.
-  // However only Sdigits with the same name (i.e. constructed with the same SDigitizer)
-  // can be mixed.
-
-  if( strcmp(fEventFolderName, "") == 0 )
-    Init() ;
-
-  if(fManager){
-    Warning("MixWith", "Cannot use this method with AliRunDigitizer\n" ) ;
-    return ;
-  }
-  // looking for file which contains AliRun
-  if (gSystem->AccessPathName(alirunFileName)) {// file does not exist
-    AliError(Form("File %s does not exist!", alirunFileName.Data())) ;
-    return ; 
-  }
-  // looking for the file which contains SDigits
-  AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
-  TString fileName( gime->GetSDigitsFileName() ) ; 
-    if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name 
-      fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ;
-    if ( (gSystem->AccessPathName(fileName)) ) { 
-      AliError(Form("The file %s does not exist!", fileName.Data())) ;
-      return ;
-    }
-    // need to increase the arrays
-    TString tempo = fInputFileNames[fInput-1] ; 
-    delete [] fInputFileNames ; 
-    fInputFileNames = new TString[fInput+1] ; 
-    fInputFileNames[fInput-1] = tempo ; 
-    tempo = fEventNames[fInput-1] ; 
-    delete [] fEventNames ; 
-    fEventNames = new TString[fInput+1] ; 
-    fEventNames[fInput-1] = tempo ; 
-
-    fInputFileNames[fInput] = alirunFileName ; 
-    fEventNames[fInput]     = eventFolderName ;
-    fInput++ ;
-}
-
 //__________________________________________________________________
 void AliPHOSDigitizer::Print(const Option_t *)const 
 {
@@ -875,20 +761,14 @@ void AliPHOSDigitizer::Print(const Option_t *)const
     for (index = 0 ; index < nStreams ; index++) {  
       TString tempo(fEventNames[index]) ; 
       tempo += index ;
-      AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[index], tempo) ; 
-      TString fileName( gime->GetSDigitsFileName() ) ; 
-      if ( fEventNames[index] != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name 
-       fileName = fileName.ReplaceAll(".root", "") + "_" + fEventNames[index]  + ".root" ;
-      printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ; 
+      printf ("Adding SDigits from %s \n", fInputFileNames[index].Data()) ; 
     }
-    AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; 
-    printf("\nWriting digits to %s", gime->GetDigitsFileName().Data()) ;
     
-    printf("\nWith following parameters:\n") ;
-    printf("  Electronics noise in EMC (fPinNoise)    = %f GeV\n", fPinNoise ) ; 
-    printf("  Threshold  in EMC  (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ;  
-    printf("  Noise in CPV (fCPVNoise)                = %f aux units\n", fCPVNoise ) ; 
-    printf("  Threshold in CPV (fCPVDigitThreshold)   = %f aux units\n",fCPVDigitThreshold ) ;  
//   printf("\nWith following parameters:\n") ;
//   printf("  Electronics noise in EMC (fPinNoise)    = %f GeV\n", fPinNoise ) ; 
//   printf("  Threshold  in EMC  (fEMCDigitThreshold) = %f GeV\n", fEMCDigitThreshold ) ;  
//   printf("  Noise in CPV (fCPVNoise)                = %f aux units\n", fCPVNoise ) ; 
//   printf("  Threshold in CPV (fCPVDigitThreshold)   = %f aux units\n",fCPVDigitThreshold ) ;  
     printf(" ---------------------------------------------------\n") ;   
   }
   else
@@ -901,8 +781,11 @@ void AliPHOSDigitizer::Print(const Option_t *)const
 {
   // Print a table of digits
   
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; 
-  TClonesArray * digits = gime->Digits() ; 
+
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+  TClonesArray * digits = phosLoader->Digits() ; 
+  const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
   
   AliInfo(Form("%d", digits->GetEntriesFast())) ; 
   printf("\nevent %d", gAlice->GetEvNumber()) ;
@@ -914,7 +797,7 @@ void AliPHOSDigitizer::Print(const Option_t *)const
     AliPHOSDigit * digit;
     printf("\nEMC digits (with primaries):\n")  ;
     printf("\n   Id  Amplitude    Time          Index Nprim: Primaries list \n") ;    
-    Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
+    Int_t maxEmc = geom->GetNModules()*geom->GetNCristalsInModule() ;
     Int_t index ;
     for (index = 0 ; (index < digits->GetEntriesFast()) && 
           (dynamic_cast<AliPHOSDigit *>(digits->At(index))->GetId() <= maxEmc) ; index++) {
@@ -939,7 +822,7 @@ void AliPHOSDigitizer::Print(const Option_t *)const
     AliPHOSDigit * digit;
     printf("\nCPV digits (with primaries):\n")  ;
     printf("\n   Id  Amplitude    Time          Index Nprim: Primaries list \n") ;    
-    Int_t maxEmc = gime->PHOSGeometry()->GetNModules()*gime->PHOSGeometry()->GetNCristalsInModule() ;
+    Int_t maxEmc = geom->GetNModules()*geom->GetNCristalsInModule() ;
     Int_t index ;
     for (index = 0 ; index < digits->GetEntriesFast(); index++) {
       digit = (AliPHOSDigit * )  digits->At(index) ;
@@ -972,12 +855,14 @@ void AliPHOSDigitizer::Unload()
   for(i = 1 ; i < fInput ; i++){
     TString tempo(fEventNames[i]) ; 
     tempo += i ;
-    AliPHOSGetter * gime = AliPHOSGetter::Instance(fInputFileNames[i], tempo) ; 
-    gime->PhosLoader()->UnloadSDigits() ; 
+    AliRunLoader* rl = AliRunLoader::GetRunLoader(tempo) ; 
+    AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+    phosLoader->UnloadSDigits() ; 
   }
   
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName) ; 
-  gime->PhosLoader()->UnloadDigits() ; 
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+  phosLoader->UnloadDigits() ; 
 }
 
 //____________________________________________________________________________
@@ -992,18 +877,24 @@ void AliPHOSDigitizer::WriteDigits()
   //      and branch "AliPHOSDigitizer", with the same title to keep all the parameters
   //      and names of files, from which digits are made.
 
-  AliPHOSGetter * gime = AliPHOSGetter::Instance(GetTitle()) ; 
-  const TClonesArray * digits = gime->Digits() ; 
-  TTree * treeD = gime->TreeD();
-
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(fEventFolderName) ;
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+  const TClonesArray * digits = phosLoader->Digits() ; 
+  TTree * treeD = phosLoader->TreeD();
+  if(!treeD){
+    phosLoader->MakeTree("D");
+    treeD = phosLoader->TreeD();
+  }
+  
   // -- create Digits branch
   Int_t bufferSize = 32000 ;    
   TBranch * digitsBranch = treeD->Branch("PHOS","TClonesArray",&digits,bufferSize);
   digitsBranch->SetTitle(fEventFolderName);
   digitsBranch->Fill() ;
   
-  gime->WriteDigits("OVERWRITE");
-  gime->WriteDigitizer("OVERWRITE");
+  phosLoader->WriteDigits("OVERWRITE");
+  phosLoader->WriteDigitizer("OVERWRITE");
 
   Unload() ; 
 
index 861b413726e28a2c3b7a3c653c831c7ad705269f..bf5f34eb4b4063ab851a1c006c5c1e4ad0359c8f 100644 (file)
@@ -43,9 +43,9 @@ class TClonesArray ;
 
 // --- AliRoot header files ---
 #include "AliDigitizer.h"
-class AliPHOSSDigitizer ;
-//class AliPHOSQADataMaker ; 
+#include "AliConfig.h"
 class AliRunDigitizer ;
+class AliPHOSCalibData ; 
 
 class AliPHOSDigitizer: public AliDigitizer {
 
@@ -59,39 +59,10 @@ public:
   void    Digitize(Int_t event) ;            // Make Digits from SDigits 
   void    Exec(Option_t *option);                  // Supervising method
 
-  //CPV parameters
-  Float_t GetCPVNoise()     const { return fCPVNoise ;}
-  Float_t GetCPVThreshold() const { return fCPVDigitThreshold ;}
-  Float_t GetCPVchannel()   const { return fADCchanelCpv; }
-  Float_t GetCPVpedestal()  const { return fADCpedestalCpv; }
-
-  void    SetCPVNoise(Float_t CPVNoise)          {fCPVNoise = CPVNoise;}
-  void    SetCPVThreshold(Float_t CPVThreshold)  {fCPVDigitThreshold= CPVThreshold;}
-  void    SetNCPVchannels(Int_t n)     { fNADCcpv = n; }
-  void    SetCPVchannel(Float_t width) { fADCchanelCpv = width; }
-  void    SetCPVpedestal(Float_t ped)  { fADCpedestalCpv = ped; }
-
-
-  //EMC parameters
-  Float_t GetEMCThreshold() const { return fEMCDigitThreshold;}
-  Float_t GetEMCchannel()   const { return fADCchanelEmc; }
-  Float_t GetEMCpedestal()  const { return fADCpedestalEmc; }  
-  Float_t GetPinNoise()     const { return fPinNoise;}
-  Float_t GetTimeResolution() const { return fTimeResolution ; }
-
-  void   SetEMCThreshold(Float_t EMCThreshold)  {fEMCDigitThreshold = EMCThreshold;}
-  void   SetPinNoise(Float_t PinNoise )         {fPinNoise = PinNoise;}
-  void   SetNEMCchannels(Int_t n)      { fNADCemc = n; }
-  void   SetEMCchannel(Float_t width)  { fADCchanelEmc = width; }
-  void   SetEMCpedestal(Float_t ped)   { fADCpedestalEmc = ped ; }  
-  void   SetEventFolderName(TString name) { fEventFolderName = name ; }
-  void   SetTimeResolution(Float_t res){ fTimeResolution = res ; }  
   void   SetEventRange(Int_t first=0, Int_t last=-1) {fFirstEvent=first; fLastEvent=last; }
 
   //General
   Int_t   GetDigitsInRun()  const { return fDigitsInRun ;}  
-  void    MixWith(TString alirunFileName, 
-                 TString eventFolderName = AliConfig::GetDefaultEventFolderName()) ; // Add another one file to mix
 
   void    Print(const Option_t * = "")const ;
  
@@ -103,7 +74,6 @@ public:
 
   
 private:
-//  AliPHOSQADataMaker * GetQADataMaker() const { return fQADM ; } 
 
   virtual Bool_t Init() ; 
   void    InitParameters() ; 
@@ -112,8 +82,10 @@ private:
   void    WriteDigits() ;                     // Writes Digits for the current event
   Float_t TimeOfNoise(void) const;            // Calculate time signal generated by noise
 
+  Float_t TimeResolution(Float_t energy) ;    //TOF resolution
+
   //Calculate the time of crossing of the threshold by front edge
-  Float_t FrontEdgeTime(TClonesArray * ticks) const ; 
+  //  Float_t FrontEdgeTime(TClonesArray * ticks) const ; 
   //Calculate digitized signal with gived ADC parameters
   void    DecalibrateEMC(AliPHOSDigit * digit);
   Int_t   DigitizeCPV(Float_t charge, Int_t absId) ;
@@ -130,34 +102,13 @@ private:
 
   Int_t   fEmcCrystals ;            // Number of EMC crystalls in the given geometry
 
-  Float_t fPinNoise ;               // Electronics noise in EMC
-  Float_t fEMCDigitThreshold  ;     // Threshold for storing digits in EMC
-
-  Float_t fCPVNoise ;               // Noise in CPV
-  Float_t fCPVDigitThreshold  ;     // Threshold for storing digits in CPV
-
-
-  Float_t fTimeResolution ;         // Time resolution of FEE electronics
-  Float_t fTimeThreshold ;          // Threshold to start timing for given crystall
-  Float_t fTimeSignalLength ;       // Length of the timing signal 
-
-  Float_t fADCchanelEmc ;           // width of one ADC channel in GeV
-  Float_t fADCpedestalEmc ;         // value of the EMC ADC pedestal
-  Int_t   fNADCemc ;                // number of channels in EMC ADC
-
-  Float_t fADCchanelCpv ;           // width of one ADC channel in CPV units
-  Float_t fADCpedestalCpv ;         // value of the CPV ADC pedestal in CPV units
-  Int_t   fNADCcpv ;                // number of channels in CPV ADC
-
   TString fEventFolderName;         // skowron: name of EFN to read data from in stand alone mode
   Int_t   fFirstEvent;              // first event to process
   Int_t   fLastEvent;               // last  event to process 
-//  AliPHOSQADataMaker * fQADM ; //!Quality Assurance Data Maker
+  AliPHOSCalibData* fcdb;           //! Calibration parameters DB
+
   Int_t fEventCounter ;             //! counts the events processed
   
-  //QA stuff
-//  static const Int_t fgkCycles = 9999 ; // QA data accumulation cycle 
-
   ClassDef(AliPHOSDigitizer,4)  // description 
 
 };
index 0297f6c643bb107d5aaaa55172ae4d81a5048b6c..be9355010a23d2b956041078dd642f836ea2df49 100644 (file)
@@ -316,33 +316,9 @@ void AliPHOSJetFinder::FindJetsFromDigits(const TClonesArray * digits, TObjArray
 }
 //____________________________________________________________________________ 
 Double_t AliPHOSJetFinder::Calibrate(const AliPHOSDigit * digit){ 
-//   if(fPedestals || fGains ){  //use calibration data
-//     if(!fPedestals || !fGains ){
-//       AliError(Form("Either Pedestals of Gains not set!")) ;
-//       return 0 ;
-//     }
-//     Float_t en=(digit->GetAmp() - fPedestals->Data(digit->GetId)()))*fGains->Data(digit->GetId()) ;
-//     if(en>0)
-//       return en ;
-//     else
-//       return 0. ;
-//   }
-//   else{ //simulation
-  if(fSimGain==0){ //read simulation parameters
-    AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
-    if(!gime){
-      AliError(Form("Can not read Calibration parameters")) ;
-      return 0 ;
-    }
-    const TTask * task = gime->Digitizer() ;
-    if(strcmp(task->IsA()->GetName(),"AliPHOSDigitizer")==0){
-      const AliPHOSDigitizer * dig = static_cast<const AliPHOSDigitizer *>(task) ;
-      fSimGain     = dig->GetEMCchannel() ;
-      fSimPedestal = dig->GetEMCpedestal();
-    }
-  }
+  //Both simulated and raw digits are already calibrated
   
-  return fSimPedestal + digit->GetAmp()*fSimGain ;        
+  return digit->GetEnergy() ;        
   
   //  }  
 }
index fc0a53d83e7590e1ce0a9d4ec6a8d08e79e8c1b4..e9f8cf6d614a0f3c05e78b98ceeda0f57536f496 100644 (file)
@@ -105,7 +105,6 @@ ClassImp(AliPHOSSDigitizer)
 //____________________________________________________________________________ 
 AliPHOSSDigitizer::AliPHOSSDigitizer() : 
   TTask("",""),
-  fA(0.f), fB(0.f),
   fPrimThreshold(0.f),
   fDefaultInit(kTRUE),
   fEventFolderName(""),
@@ -113,7 +112,6 @@ AliPHOSSDigitizer::AliPHOSSDigitizer() :
   fSDigitsInRun(0),
   fFirstEvent(0),
   fLastEvent(0)
-//  , fQADM (0x0)
 {
   // ctor
   // Intialize the quality assurance data maker        
@@ -123,7 +121,6 @@ AliPHOSSDigitizer::AliPHOSSDigitizer() :
 AliPHOSSDigitizer::AliPHOSSDigitizer(const char * alirunFileName, 
                                     const char * eventFolderName):
   TTask("PHOS"+AliConfig::Instance()->GetSDigitizerTaskName(), alirunFileName),
-  fA(0.f), fB(0.f),
   fPrimThreshold(0.f),
   fDefaultInit(kFALSE),
   fEventFolderName(eventFolderName),
@@ -131,26 +128,16 @@ AliPHOSSDigitizer::AliPHOSSDigitizer(const char * alirunFileName,
   fSDigitsInRun(0),
   fFirstEvent(0),
   fLastEvent(0)
-//  , fQADM (0x0)
 {
   // ctor
   InitParameters() ; 
   Init();
   fDefaultInit = kFALSE ; 
-//  // Intialize the quality assurance data maker 
-//  //FIXME: get the run number
-//  Int_t run = 0 ;
-//  //EMXIF    
-//  GetQADataMaker()->Init(AliQA::kHITS, run, fgkCycles) ;
-//  GetQADataMaker()->StartOfCycle(AliQA::kHITS) ;
-//  GetQADataMaker()->Init(AliQA::kSDIGITS, run) ; 
-//  GetQADataMaker()->StartOfCycle(AliQA::kSDIGITS, kTRUE) ;
 }
 
 //____________________________________________________________________________
 AliPHOSSDigitizer::AliPHOSSDigitizer(const AliPHOSSDigitizer& sd) :
   TTask(sd.GetName(), sd.GetTitle()),
-  fA(sd.fA), fB(sd.fB),
   fPrimThreshold(sd.fPrimThreshold),
   fDefaultInit(kFALSE),
   fEventFolderName(sd.fEventFolderName),
@@ -158,17 +145,8 @@ AliPHOSSDigitizer::AliPHOSSDigitizer(const AliPHOSSDigitizer& sd) :
   fSDigitsInRun(sd.fSDigitsInRun),
   fFirstEvent(sd.fFirstEvent),
   fLastEvent(sd.fLastEvent)
-//  , fQADM (sd.fQADM)
 { 
   // cpy ctor
-//  // Intialize the quality assurance data maker      
-//  //FIXME: get the run number
-//  Int_t run = 0 ;
-//  //EMXIF    
-//  GetQADataMaker()->Init(AliQA::kHITS, run, fgkCycles) ;
-//  GetQADataMaker()->StartOfCycle(AliQA::kHITS) ;
-//  GetQADataMaker()->Init(AliQA::kSDIGITS, run) ; 
-//  GetQADataMaker()->StartOfCycle(AliQA::kSDIGITS, kTRUE) ;
 }
 
 //_____________________________________________________________________________
@@ -222,8 +200,6 @@ void AliPHOSSDigitizer::Init()
 void AliPHOSSDigitizer::InitParameters()
 { 
   // initializes the parameters for digitization
-  fA             = 0;
-  fB             = 10000000.;
   fPrimThreshold = 0.01 ;
   fSDigitsInRun  = 0 ;
 }
@@ -373,8 +349,6 @@ void AliPHOSSDigitizer::Print(const Option_t *)const
   // Prints parameters of SDigitizer
   Info("Print", "\n------------------- %s -------------", GetName() ) ; 
   printf("   Writing SDigits to branch with title  %s\n", fEventFolderName.Data()) ;
-  printf("   with digitization parameters  A = %f\n", fA) ; 
-  printf("                                 B = %f\n", fB) ;
   printf("   Threshold for Primary assignment= %f\n", fPrimThreshold)  ; 
   printf("---------------------------------------------------\n") ;
   
@@ -386,7 +360,7 @@ Bool_t AliPHOSSDigitizer::operator==( AliPHOSSDigitizer const &sd )const
   // Equal operator.
   // SDititizers are equal if their pedestal, slope and threshold are equal
 
-  if( (fA==sd.fA)&&(fB==sd.fB)&&(fPrimThreshold==sd.fPrimThreshold))
+  if(fPrimThreshold==sd.fPrimThreshold)
     return kTRUE ;
   else
     return kFALSE ;
index 4bebb781a1b3c32c6df96f52b1200379950adb8d..c7c1ddb1017c99010b2722479e6dda2bfaf38010 100644 (file)
@@ -58,8 +58,6 @@ public:
 
   virtual ~AliPHOSSDigitizer(); // dtor
 
-  Float_t        Calibrate(Int_t amp)const {return (amp - fA)/fB ; }
-  Int_t          Digitize(Float_t Energy)const { return (Int_t ) ( fA + Energy*fB); }
   virtual void   Exec(Option_t *option); 
   Int_t    GetSDigitsInRun() const {return fSDigitsInRun ;}  
   virtual void   Print(const Option_t * = "") const ;
@@ -70,7 +68,6 @@ public:
 
  
 private:
-//  AliPHOSQADataMaker * GetQADataMaker() const { return fQADM ; } 
 
   void     Init() ;
   void     InitParameters() ;
@@ -79,8 +76,6 @@ private:
 
 
 private:
-  Float_t fA ;              // Pedestal parameter
-  Float_t fB ;              // Slope Digitizition parameters
   Float_t fPrimThreshold ;  // To store primari if Elos > threshold
   Bool_t  fDefaultInit;     //! Says if the task was created by defaut ctor (only parameters are initialized)
   TString fEventFolderName; // event folder name
@@ -89,10 +84,7 @@ private:
   Int_t   fFirstEvent;      // first event to process
   Int_t   fLastEvent;       // last  event to process
 
-//  AliPHOSQADataMaker * fQADM ; //!Quality Assurance Data Maker
-//  static const Int_t fgkCycles = 9999 ; // QA data accumulation cycle 
-
-  ClassDef(AliPHOSSDigitizer,4)  // description 
+  ClassDef(AliPHOSSDigitizer,5)  // description 
 
 };
 
diff --git a/PHOS/AliPHOSSimParam.cxx b/PHOS/AliPHOSSimParam.cxx
new file mode 100644 (file)
index 0000000..14ff7af
--- /dev/null
@@ -0,0 +1,134 @@
+/**************************************************************************
+ * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved.      *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// Base class for the PHOS simulation parameters.
+// Do not use in the simulation; use derivative classes instead.
+// Author: Dmitri Peressounko, RRC KI
+
+// --- AliRoot header files ---
+#include "AliPHOSSimParam.h"
+#include "AliLog.h"
+
+ClassImp(AliPHOSSimParam)
+
+AliPHOSSimParam  * AliPHOSSimParam::fgSimParam = 0 ;
+//-----------------------------------------------------------------------------
+AliPHOSSimParam::AliPHOSSimParam() :
+  TNamed(),
+  fLightYieldMean(0.),fIntrinsicAPDEfficiency(0.),
+  fLightFactor(0.),fAPDFactor(0.),         
+  fAPDNoise(0.),fEMCDigitThreshold(0.),
+  fEMCADCchannel(0.),fTOFa(0.),fTOFb(0.),
+  fADCpedestalCpv(0.),fADCchanelCpv(0.),
+  fCPVNoise(0.),fCPVDigitThreshold(0.),fNADCcpv(0),
+  fDigitizeE(0)
+{
+  //Default constructor.
+  for(Int_t i=0; i<10; i++) fDStream[i] = 0 ;
+}
+
+//-----------------------------------------------------------------------------
+AliPHOSSimParam::AliPHOSSimParam(Int_t) :
+  TNamed(),
+  fLightYieldMean(0.),fIntrinsicAPDEfficiency(0.),
+  fLightFactor(0.),fAPDFactor(0.),         
+  fAPDNoise(0.),fEMCDigitThreshold(0.),
+  fEMCADCchannel(0.),fTOFa(0.),fTOFb(0.),
+  fADCpedestalCpv(0.),fADCchanelCpv(0.),
+  fCPVNoise(0.),fCPVDigitThreshold(0.),fNADCcpv(0),
+  fDigitizeE(0)
+{
+  //Real (private) constructor 
+  //Set default parameters
+
+  //Parameters describing energy deposition and light collection by APD, used in AliPHOSv1
+  //Photoelectron statistics:
+  // The light yield is a poissonian distribution of the number of
+  // photons created in the PbWo4 crystal, calculated using following formula
+  // NumberOfPhotons = EnergyLost * LightYieldMean* APDEfficiency 
+  // LightYieldMean is parameter calculated to be over 47000 photons per GeV
+  // APDEfficiency is 0.02655
+  // k_0 is 0.0045 from Valery Antonenko
+  // The number of electrons created in the APD is
+  // NumberOfElectrons = APDGain * LightYield
+  // The APD Gain is 300
+  fLightYieldMean = 47000;            //Average number of photoelectrons per GeV
+  fIntrinsicAPDEfficiency = 0.02655 ; //APD efficiency including geometric coverage
+//  fLightYieldAttenuation  = 0.0045 ;  //light attenuation in PWO. Last analysis shows no z-position dependence
+//                                      //so we removed this dependence from simulations 
+  fLightFactor            = fLightYieldMean * fIntrinsicAPDEfficiency ; //Average number of photons collected by 
+                            //APD per GeV deposited energy
+  fAPDFactor              = (13.418/fLightYieldMean/100.) * 300. ; //factor relating light yield and APD response
+                            //evaluated as (13.418/fLightYieldMean/100) * APDGain ;
+
+
+  //Parameters defining electronic noise calculation and Digits noise thresholds
+  //used in AliPHOSDigitizer
+  fAPDNoise           = 0.004 ;  // [GeV]
+  fEMCDigitThreshold  = 0.012 ;  // [GeV]
+  fEMCADCchannel      = 0.005 ;  // [GeV]
+  fTOFa               = 0.5e-9 ; // [sec] constant term
+  fTOFb               = 1.e-9 ;  // [sec/sqrt(GeV)]] stohastic term
+
+  fADCpedestalCpv     = 0.012 ;  // [aux units]
+  fADCchanelCpv       = 0.0012;  // [aux units]    
+  fCPVNoise           = 0.01;    // [aux units]
+  fCPVDigitThreshold  = 0.09 ;   // [aux units]
+  fNADCcpv  =  (Int_t)TMath::Power(2,12) ;
+
+  //Imput streams for merging. If true => this stream contains digits (and thus noise) and not SDigits.
+  for(Int_t i=0; i<10; i++){
+    fDStream[i] = 0 ;
+  }
+  fgSimParam = this ;
+}
+
+//-----------------------------------------------------------------------------
+AliPHOSSimParam::AliPHOSSimParam(const AliPHOSSimParam& ):
+  TNamed(),
+  fLightYieldMean(0.),fIntrinsicAPDEfficiency(0.),
+  fLightFactor(0.),fAPDFactor(0.),         
+  fAPDNoise(0.),fEMCDigitThreshold(0.),
+  fEMCADCchannel(0.),fTOFa(0.),fTOFb(0.),
+  fADCpedestalCpv(0.),fADCchanelCpv(0.),
+  fCPVNoise(0.),fCPVDigitThreshold(0.),fNADCcpv(0),
+  fDigitizeE(0)
+{
+  //Copy constructor.
+  AliError("Should not use copy constructor for singleton") ;
+  for(Int_t  i=0; i<10; i++){
+    fDStream[i] = 0 ;
+  }
+  fgSimParam = this ;
+}
+//-----------------------------------------------------------------------------                                                            
+AliPHOSSimParam * AliPHOSSimParam::GetInstance(){
+
+  if(!fgSimParam)
+    new AliPHOSSimParam(0) ;
+  return fgSimParam ;
+}
+//-----------------------------------------------------------------------------
+AliPHOSSimParam& AliPHOSSimParam::operator = (const AliPHOSSimParam& simParam)
+{
+  //Assignment operator.
+
+  if(this != &simParam) {
+    AliError("Should not use operator= for singleton\n") ;
+  }
+
+  return *this;
+}
+
diff --git a/PHOS/AliPHOSSimParam.h b/PHOS/AliPHOSSimParam.h
new file mode 100644 (file)
index 0000000..8ed3516
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef ALIPHOSSIMPARAM_H
+#define ALIPHOSSIMPARAM_H
+/* Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                          */
+
+/* $Id: AliPHOSSimParam.h 23530 2008-01-25 06:46:13Z prsnko $ */
+                                              
+// Base class for the PHOS simulation parameters.
+// Do not use in the reconstruction; use derivative classes instead.
+
+#include "TNamed.h"
+#include "TMath.h"
+
+class AliPHOSSimParam : public TNamed {
+
+public:
+
+  AliPHOSSimParam();
+  AliPHOSSimParam(const AliPHOSSimParam& recoParam);
+  AliPHOSSimParam& operator = (const AliPHOSSimParam& recoParam);
+  virtual ~AliPHOSSimParam() {}
+
+  static AliPHOSSimParam * GetInstance() ;
+
+  //Parameters used in conversion of deposited energy to APD response [see AliPHOSv1 for details]
+  void SetMeanLightYield(Float_t ly=47000.){fLightYieldMean=ly; //recalculate now dependencies
+                                            fLightFactor = fLightYieldMean * fIntrinsicAPDEfficiency ; 
+                                            fAPDFactor   = (13.418/fLightYieldMean/100.) * 300. ; }
+  void SetAPDEfficiency(Float_t eff=0.02655){fIntrinsicAPDEfficiency=eff;
+                                             fLightFactor = fLightYieldMean * fIntrinsicAPDEfficiency ;}
+  Float_t GetLightFactor(void) const { return fLightFactor ;}
+  Float_t GetAPDFactor(void) const { return fAPDFactor ;}
+
+  //Parameters use in EMC noise calculation [see AliPHOSDigitizer for details]
+  Float_t GetAPDNoise() const { return fAPDNoise;  }          //RMS of APD noise
+  void SetAPDNoise(Float_t noise=0.012){fAPDNoise = noise;  }
+
+  Float_t GetEmcDigitsThreshold() const { return fEMCDigitThreshold ; }  //Minimal energy to keep digit
+  void SetEMCDigitsThreshold(Float_t thresh=0.01){fEMCDigitThreshold=thresh;} 
+
+  //Parameters for energy digitization [see AliPHOSDigitizer for details]
+  void SetADCchannelW(Float_t width=0.005){fEMCADCchannel=width ;} //EMC channel width
+  Float_t GetADCchannelW(void) const {return fEMCADCchannel; }
+
+  void SetEDigitizationOn(Bool_t on=kTRUE){fDigitizeE=on ;}   //Use digitization in simulation or left it
+  Bool_t IsEDigitizationOn(void)const {return fDigitizeE ;}   //for Digits2Raw->Digits procedure
+
+  //Parameters for EMC TOF resolution [see AliPHOSDigitizer::TimeResolution()]
+  Float_t GetTOFa()const{return fTOFa ;}  //constant term
+  Float_t GetTOFb()const{return fTOFb ;}  //stohastic term
+  void SetTOFparameters(Float_t a=0.5e-9, Float_t b=1.5e-9){fTOFa=a; fTOFb=b; }
+
+  //Parameters for CPV noise and digitization  [see AliPHOSDigitizer for details] 
+  Float_t GetCPVNoise() const {return fCPVNoise ;}           //RMS of CPV noise in
+  void SetCPVNoise(Float_t noise=0.01){ fCPVNoise = noise ;} //CPV popugais
+
+  Float_t GetCpvDigitsThreshold() const {return fCPVDigitThreshold ;}           //Minimal energy to keep digit in
+  void SetCpvDigitsThreshold(Float_t thresh=0.09){fCPVDigitThreshold = thresh;} //CPV popugais
+
+  Float_t GetADCpedestalCpv() const {return fADCpedestalCpv ;}      //CPV pedestal value 
+  void SetADCpedestalCpv(Float_t ped=0.012){ fADCpedestalCpv=ped ;} //in CPV popugais
+
+  Float_t GetADCchanelCpv() const {return fADCchanelCpv;}     //Price of one ADC channel 
+  void SetADCchanelCpv(Float_t w=0.0012) {fADCchanelCpv=w; }  //for CPV
+
+  Int_t GetNADCcpv() const {return fNADCcpv ;}                         //Max number of channels
+  void SettNADCcpv(Int_t n=12) { fNADCcpv=(Int_t)TMath::Power(2,n) ; } //in CPV  ADC
+
+  //Mark streams for mixing as streams contaning Digits (true) or SDigits (false)
+  //Streamt numbering the same as in StreamManager
+  void    SetStreamDigits(Int_t i){if(i<10)fDStream[i]=kTRUE;}
+  Bool_t  IsStreamDigits(Int_t i){return fDStream[i]; }
+
+private:
+
+  AliPHOSSimParam(Int_t i); //True constructor which should be called by GetInstance()
+
+private:
+
+  //Parameters used in conversion of deposited energy to APD response (AliPHOSv1)
+  Float_t  fLightYieldMean ;        //Average number of photoelectrons per GeV
+  Float_t  fIntrinsicAPDEfficiency; //APD efficiency including geometric coverage
+  Float_t  fLightFactor ;           //Average number of photons collected by APD per GeV deposited energy
+  Float_t  fAPDFactor ;             //factor relating light yield and APD response 
+  //Parameters used in electronic noise calculation and thresholds for EMC (AliPHOSDigitizer)
+  Float_t fAPDNoise;            //RMS of APD noise
+  Float_t fEMCDigitThreshold ;  //minimal energy to keep digit 
+  Float_t fEMCADCchannel ;      //width of ADC channel in GeV
+  Float_t fTOFa  ;              //constant term of TOF resolution 
+  Float_t fTOFb  ;              //stohastic term of TOF resolution 
+
+  //CPV parameters
+  Float_t fADCpedestalCpv ;    //Pedestal value
+  Float_t fADCchanelCpv ;      //ADC channel width
+  Float_t fCPVNoise ;          //RMS of CPV noise 
+  Float_t fCPVDigitThreshold ; //Minimal energy to keep digit 
+  Int_t   fNADCcpv ;           //Max number of channels in CPV ADC
+  Bool_t fDStream[10] ;   //Mark mixing stream contains digits or SDigits
+  Bool_t fDigitizeE ;     //Use energy digitization in simulation or left to Digits2Raw()
+
+  static AliPHOSSimParam * fgSimParam ; // pointer to the unique instance of the class
+
+  ClassDef(AliPHOSSimParam,1)
+};
+
+#endif
index 841e42b2dcb3e622954d4015e7c3e32e22699905..bcd546884c5294111cb301bcb690c229e72f43be 100644 (file)
 #include "AliRun.h"
 #include "AliMC.h"
 #include "AliStack.h"
+#include "AliPHOSSimParam.h"
 
 ClassImp(AliPHOSv1)
 
 //____________________________________________________________________________
-AliPHOSv1::AliPHOSv1():
-  fLightYieldMean(0.),
-  fIntrinsicPINEfficiency(0.),
-  fLightYieldAttenuation(0.),
-  fRecalibrationFactor(0.),
-  fElectronsPerGeV(0.),
-  fAPDGain(0.),
-  fLightFactor(0.),
-  fAPDFactor(0.)
+AliPHOSv1::AliPHOSv1()
 {
   //Def ctor.
 }
 
 //____________________________________________________________________________
 AliPHOSv1::AliPHOSv1(const char *name, const char *title):
-  AliPHOSv0(name,title),
-  fLightYieldMean(0.),
-  fIntrinsicPINEfficiency(0.),
-  fLightYieldAttenuation(0.),
-  fRecalibrationFactor(0.),
-  fElectronsPerGeV(0.),
-  fAPDGain(0.),
-  fLightFactor(0.),
-  fAPDFactor(0.)
+  AliPHOSv0(name,title)
 {
   //
   // We store hits :
@@ -120,26 +105,6 @@ AliPHOSv1::AliPHOSv1(const char *name, const char *title):
   fNhits = 0 ;
 
   fIshunt     =  2 ; // All hits are associated with primary particles
-
-  //Photoelectron statistics:
-  // The light yield is a poissonian distribution of the number of
-  // photons created in the PbWo4 crystal, calculated using following formula
-  // NumberOfPhotons = EnergyLost * LightYieldMean* APDEfficiency *
-  //              exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit);
-  // LightYieldMean is parameter calculated to be over 47000 photons per GeV
-  // APDEfficiency is 0.02655
-  // k_0 is 0.0045 from Valery Antonenko
-  // The number of electrons created in the APD is
-  // NumberOfElectrons = APDGain * LightYield
-  // The APD Gain is 300
-  fLightYieldMean = 47000;
-  fIntrinsicPINEfficiency = 0.02655 ; //APD= 0.1875/0.1271 * 0.018 (PIN)
-  fLightYieldAttenuation  = 0.0045 ; 
-  fRecalibrationFactor    = 13.418/ fLightYieldMean ;
-  fElectronsPerGeV        = 2.77e+8 ;
-  fAPDGain                = 300. ;
-  fLightFactor            = fLightYieldMean * fIntrinsicPINEfficiency ; 
-  fAPDFactor              = (fRecalibrationFactor/100.) * fAPDGain ;   
 }
 
 //____________________________________________________________________________
@@ -379,10 +344,10 @@ void AliPHOSv1::StepManager(void)
       //Calculates the light yield, the number of photons produced in the
       //crystal 
       //There is no dependence of reponce on distance from energy deposition to APD
-      Float_t lightYield = gRandom->Poisson(fLightFactor * lostenergy) ;
+      Float_t lightYield = gRandom->Poisson(AliPHOSSimParam::GetInstance()->GetLightFactor() * lostenergy) ;
 
       //Calculates de energy deposited in the crystal  
-      xyzte[4] = fAPDFactor * lightYield ;
+      xyzte[4] = AliPHOSSimParam::GetInstance()->GetAPDFactor() * lightYield ;
       
       Int_t primary ;
       if(fIshunt == 2){
@@ -400,10 +365,9 @@ void AliPHOSv1::StepManager(void)
          part = gAlice->GetMCApp()->Particle(primary) ;
        }
       }
-      else
+      else{
        primary  =  gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() ); 
-
-      
+      }
       
       // add current hit to the hit list
       // Info("StepManager","%d %d", primary, tracknumber) ; 
index 3d5c6af030d4625d3c632ebc7c10a002fe0226a0..20d2c10966758da716396e529013f8371ca56222 100644 (file)
@@ -54,42 +54,11 @@ public:
   Float_t    CPVPadResponseFunction(Float_t qhit, Float_t zg, Float_t xg) ;
   Double_t   CPVCumulPadResponse(Double_t x, Double_t y) ;
 
-  //Variables conserning light yeild and APD efficiency
-  Float_t GetLightYieldMean()         const { return  fLightYieldMean ;}
-  Float_t GetLightYieldAttenuation()  const { return  fLightYieldAttenuation ;}
-  Float_t GetRecalibrationFactor()    const { return  fRecalibrationFactor ;}
-  Float_t GetAPDGain()                const { return  fAPDGain ;}
-  Float_t GetIntrinsicPINEfficiency() const { return  fIntrinsicPINEfficiency ;}
-  Float_t GetElectronsPerGeV()        const { return  fElectronsPerGeV ;}
-
-  void    SetLightYieldMean(Float_t LightYieldMean) 
-                                   {fLightYieldMean = LightYieldMean;}
-  void    SetLightYieldAttenuation(Float_t LightYieldAttenuation)
-                                   {fLightYieldAttenuation = LightYieldAttenuation;}
-  void    SetIntrinsicPINEfficiency(Float_t IntrinsicPINEfficiency) 
-                                   {fIntrinsicPINEfficiency = IntrinsicPINEfficiency;}
-  void    SetRecalibrationFactor(Float_t RecalibrationFactor) 
-                                   {fRecalibrationFactor = RecalibrationFactor;}
-  void    SetElectronsPerGeV(Float_t ElectronsPerGeV) 
-                                   {fElectronsPerGeV = ElectronsPerGeV;}
-  void    SetAPDGain(Float_t APDGain)   {fAPDGain = APDGain;}
-
-protected:
-
-  Float_t fLightYieldMean ;         // Mean lightyield in the PbOW4 xtal per GeV (Poisson distribution)
-  Float_t fIntrinsicPINEfficiency ; // Photo efficiency of the PIN diode   
-  Float_t fLightYieldAttenuation ;  // Attenuation of the light through the crystal
-  Float_t fRecalibrationFactor ;    // Recalibration factor
-  Float_t fElectronsPerGeV ;        // Number of electrons per GeV created in the PIN by a ionizing particle
-  Float_t fAPDGain ;                // APD Gain
-  Float_t fLightFactor ;            //! a calculated factor
-  Float_t fAPDFactor ;              //! a calculated factor
-
  private:
   AliPHOSv1(AliPHOSv1 & phos);
   AliPHOSv1 & operator = (const AliPHOSv1 & /*rvalue*/);
 
-  ClassDef(AliPHOSv1,2)  // Implementation of PHOS manager class for layout EMC+PPSD
+  ClassDef(AliPHOSv1,3)  // Implementation of PHOS manager class for layout EMC+PPSD
 
 };
 
index 38c6466f33954076118b367bcbe4e4375c89ac2d..90802b748ecdf4bbe1e2a92d1688998caea846b9 100644 (file)
@@ -43,5 +43,6 @@
 #pragma link C++ class AliPHOSTrackSegment+;
 
 #pragma link C++ class AliPHOSReconstructor+;
+#pragma link C++ class AliPHOSSimParam+;
 
 #endif
index b5a4823ae88e2796b8aa21ae487d1b2fa6c08d6a..0726db826c72799f6d947a18e971ed948b98cfeb 100644 (file)
@@ -25,7 +25,7 @@ SRCS          =  AliPHOS.cxx \
                  AliPHOSRecParticle.cxx AliPHOSRecPoint.cxx \
                  AliPHOSEmcRecPoint.cxx \
                  AliPHOSCpvRecPoint.cxx   AliPHOSTrackSegment.cxx \
-                 AliPHOSReconstructor.cxx 
+                 AliPHOSReconstructor.cxx AliPHOSSimParam.cxx
 
 HDRS:= $(SRCS:.cxx=.h)