]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOS.cxx
Setting "const" to member functions of AliPHOSEMCAGeometry
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.cxx
index d4131c882e7edf15082de71ffada55656da8e1c2..7cbced51f148b7187154b230d97d6398325d81f9 100644 (file)
 
 // --- ROOT system ---
 class TFile;
+#include <TF1.h> 
 #include <TFolder.h> 
-#include <TTree.h>
-#include <TVirtualMC.h> 
+#include <TGeoGlobalMagField.h>
 #include <TH1F.h> 
-#include <TF1.h> 
 #include <TRandom.h> 
+#include <TTree.h>
+#include <TVirtualMC.h> 
 
 // --- Standard library ---
 
 // --- AliRoot header files ---
 #include "AliMagF.h"
 #include "AliPHOS.h"
-#include "AliPHOSGetter.h"
+#include "AliPHOSLoader.h"
 #include "AliRun.h"
 #include "AliPHOSDigitizer.h"
 #include "AliPHOSSDigitizer.h"
@@ -94,15 +95,17 @@ class TFile;
 #include "AliPHOSPulseGenerator.h"
 #include "AliDAQ.h"
 #include "AliPHOSRawDecoder.h"
+#include "AliPHOSRawDecoderv1.h"
+#include "AliPHOSCalibData.h"
 #include "AliPHOSRawDigiProducer.h"
 #include "AliPHOSQAChecker.h"
-#include "AliPHOSRecoParamEmc.h"
+#include "AliPHOSRecoParam.h"
 #include "AliPHOSSimParam.h"
 
 ClassImp(AliPHOS)
 
 //____________________________________________________________________________
-  AliPHOS:: AliPHOS() : AliDetector()
+  AliPHOS:: AliPHOS() : AliDetector(),fgCalibData(0)
 {
   // Default ctor
   fName   = "PHOS" ;
@@ -110,7 +113,8 @@ ClassImp(AliPHOS)
 }
 
 //____________________________________________________________________________
-AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title)
+AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title),
+fgCalibData(0)
 {
   //   ctor : title is used to identify the layout
 }
@@ -118,6 +122,7 @@ AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title)
 //____________________________________________________________________________
 AliPHOS::~AliPHOS() 
 {  
+  if(fgCalibData) delete fgCalibData ;
 }
 
 //____________________________________________________________________________
@@ -288,8 +293,8 @@ void AliPHOS::CreateMaterials()
   // DEFINITION OF THE TRACKING MEDIA
 
   // for PHOS: idtmed[699->798] equivalent to fIdtmed[0->100]
-  Int_t   isxfld = gAlice->Field()->Integ() ;
-  Float_t sxmgmx = gAlice->Field()->Max() ;
+  Int_t   isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ() ;
+  Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max() ;
 
   // The scintillator of the calorimeter made of PBW04                              -> idtmed[699]
   AliMedium(0, "PHOS Xtal    $", 0, 1,
@@ -441,15 +446,18 @@ void AliPHOS::Digits2Raw()
   }
 
   // get mapping from OCDB
-  const TObjArray* maps = AliPHOSRecoParamEmc::GetMappings();
+  const TObjArray* maps = AliPHOSRecoParam::GetMappings();
   if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
 
   // some digitization constants
-  const Float_t    kThreshold = 0.001; // skip digits below 1 MeV
+  const Float_t    kThreshold = 1.; // skip digits below 1 ADC channel
   const Int_t      kAdcThreshold = 1;  // Lower ADC threshold to write to raw data
 
   Int_t prevDDL = -1;
 
+  if(fgCalibData==0)
+    fgCalibData= new AliPHOSCalibData(-1) ;
+
   // Create a shaper pulse object
   AliPHOSPulseGenerator *pulse = new AliPHOSPulseGenerator();
   
@@ -475,8 +483,11 @@ void AliPHOS::Digits2Raw()
   // loop over digits (assume ordered digits)
   for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
     AliPHOSDigit* digit = dynamic_cast<AliPHOSDigit *>(digits->At(iDigit)) ;
+
+    // Skip small energy below treshold
     if (digit->GetEnergy() < kThreshold) 
       continue;
+
     Int_t relId[4];
     geom->AbsToRelNumbering(digit->GetId(), relId);
     Int_t module = relId[0];
@@ -531,7 +542,7 @@ void AliPHOS::Digits2Raw()
                    relId[0]-1,relId[3]-1,relId[2]-1));
     // if a signal is out of time range, write only trailer
     if (digit->GetTimeR() > pulse->GetRawFormatTimeMax()*0.5 ) {
-      AliInfo("Signal is out of time range.\n");
+      AliDebug(2,"Signal is out of time range.\n");
       buffer[iDDL]->FillBuffer(0);
       buffer[iDDL]->FillBuffer(pulse->GetRawFormatTimeBins() );  // time bin
       buffer[iDDL]->FillBuffer(3);                               // bunch length
@@ -550,6 +561,8 @@ void AliPHOS::Digits2Raw()
       }
       pulse->SetAmplitude(energy);
       pulse->SetTZero(digit->GetTimeR());
+      Double_t r =fgCalibData->GetHighLowRatioEmc(relId[0],relId[3],relId[2]) ;
+      pulse->SetHG2LGRatio(r) ;
       pulse->MakeSamples();
       pulse->GetSamples(adcValuesHigh, adcValuesLow) ; 
       buffer[iDDL]->WriteChannel(relId[3]-1, relId[2]-1, 0, 
@@ -605,7 +618,7 @@ void AliPHOS::SetTreeAddress()
   char branchname[20];
   sprintf(branchname,"%s",GetName());
   // Branch address for hit tree
-    TTree *treeH = TreeH();
+    TTree *treeH = fLoader->TreeH();
   if (treeH) {
     branch = treeH->GetBranch(branchname);
     if (branch) 
@@ -617,36 +630,50 @@ void AliPHOS::SetTreeAddress()
   }
 }
 
-//____________________________________________________________________________
-Bool_t AliPHOS::Raw2SDigits(AliRawReader* rawReader)
-{
-
-  AliPHOSLoader * loader = dynamic_cast<AliPHOSLoader*>(fLoader) ;
-
-  TTree * tree = 0 ;
-  tree = loader->TreeS() ;
-  if ( !tree ) {
-    loader->MakeTree("S");
-    tree = loader->TreeS() ;
-  }
+//____________________________________________________________________________          
+Bool_t AliPHOS::Raw2SDigits(AliRawReader* rawReader)    
+{       
+                
+  AliPHOSLoader * loader = dynamic_cast<AliPHOSLoader*>(fLoader) ;      
+                
+  TTree * tree = 0 ;    
+  tree = loader->TreeS() ;      
+  if ( !tree ) {        
+    loader->MakeTree("S");      
+    tree = loader->TreeS() ;    
+  }     
+                
+  TClonesArray * sdigits = loader->SDigits() ;          
+  if(!sdigits) {        
+    loader->MakeSDigitsArray();         
+    sdigits = loader->SDigits();        
+  }     
+  sdigits->Clear();     
+                
+  const TObjArray* maps = AliPHOSRecoParam::GetMappings();
+  if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
 
-  TClonesArray * sdigits = loader->SDigits() ;
-  if(!sdigits) { 
-    loader->MakeSDigitsArray();
-    sdigits = loader->SDigits();
+  AliAltroMapping *mapping[4];
+  for(Int_t i = 0; i < 4; i++) {
+    mapping[i] = (AliAltroMapping*)maps->At(i);
   }
-  sdigits->Clear();
 
-  AliPHOSRawDecoder dc(rawReader);
-  AliPHOSRawDigiProducer pr;
-  pr.MakeDigits(sdigits,&dc);
+  AliPHOSRawDecoderv1 dc(rawReader,mapping);    
 
-  Int_t bufferSize = 32000 ;
-  // TBranch * sdigitsBranch = tree->Branch("PHOS",&sdigits,bufferSize);
-  tree->Branch("PHOS",&sdigits,bufferSize);
-  tree->Fill();
+  dc.SubtractPedestals(AliPHOSSimParam::GetInstance()->EMCSubtractPedestals());
+  dc.SetAmpOffset(AliPHOSSimParam::GetInstance()->GetGlobalAltroOffset());
+  dc.SetAmpThreshold(AliPHOSSimParam::GetInstance()->GetGlobalAltroThreshold());
 
-  fLoader->WriteSDigits("OVERWRITE");
-  return kTRUE;
-    
+  AliPHOSRawDigiProducer pr;
+  pr.SetSampleQualityCut(AliPHOSSimParam::GetInstance()->GetEMCSampleQualityCut());     
+  pr.MakeDigits(sdigits,&dc);   
+                
+  Int_t bufferSize = 32000 ;    
+  // TBranch * sdigitsBranch = tree->Branch("PHOS",&sdigits,bufferSize);        
+  tree->Branch("PHOS",&sdigits,bufferSize);     
+  tree->Fill();         
+                
+  fLoader->WriteSDigits("OVERWRITE");   
+  return kTRUE;         
+  
 }