]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSGetter.cxx
eff C++ warnings corrected.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGetter.cxx
index 50091c33f7c69a215eada83fd9e42873cf478c58..5ac90f3e29deddfac0ca026832032443d1639db7 100644 (file)
 #include "AliPHOSBeamTestEvent.h"
 #include "AliPHOSGetter.h"
 #include "AliPHOSLoader.h"
+#include "AliPHOSPulseGenerator.h"
 #include "AliRunLoader.h"
 #include "AliStack.h"  
-#include "AliPHOSRawStream.h"
+#include "AliPHOSRawDecoder.h"
 #include "AliRawReaderFile.h"
 #include "AliLog.h"
 #include "AliCDBLocal.h"
 #include "AliCDBStorage.h"
 #include "AliCDBManager.h"
+#include "AliPHOSRawDigiProducer.h"
 
 ClassImp(AliPHOSGetter)
   
@@ -464,7 +466,7 @@ AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char*
       }
     }
     else {
-      AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ; 
+      rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ; 
       if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging
        delete rl ; 
       fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ;      
@@ -638,12 +640,15 @@ void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHigh
   time   = 0. ; 
   energy = 0. ; 
 
+  // Create a shaper pulse object which contains all the shaper parameters
+  AliPHOSPulseGenerator pulse;
+
   if (lowGainFlag) {
     timezero1 = timezero2 = signalmax = timemax = 0. ;
-    signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ; 
-    signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ; 
+    signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ; 
+    signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ; 
     Int_t index ; 
-    for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+    for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
       gLowGain->GetPoint(index, time, signal) ; 
       if (signal > kNoiseThreshold && timezero1 == 0.) 
        timezero1 = time ;
@@ -654,21 +659,22 @@ void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHigh
        timemax   = time ; 
       }
     }
-    signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(), 
-                                               PHOS()->GetRawFormatLowGain()) ;
-    if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise 
+    signalmax /= 
+      pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(), 
+                                  pulse.GetRawFormatLowGain()) ;
+    if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise 
       signalF->SetParameter(2, signalmax) ; 
       signalF->SetParameter(3, timezero1) ;                
       gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ; 
       energy = signalF->GetParameter(2) ; 
-      time   = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
+      time   = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
     }
   } else {
     timezero1 = timezero2 = signalmax = timemax = 0. ;
-    signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ; 
-    signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ; 
+    signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ; 
+    signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ; 
     Int_t index ; 
-    for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+    for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) {
       gHighGain->GetPoint(index, time, signal) ;               
       if (signal > kNoiseThreshold && timezero1 == 0.) 
        timezero1 = time ;
@@ -679,14 +685,14 @@ void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHigh
        timemax   = time ; 
       }
     }
-    signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(), 
-                                               PHOS()->GetRawFormatHighGain()) ;;
-    if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise  
+    signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(), 
+                                             pulse.GetRawFormatHighGain()) ;;
+    if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise  
       signalF->SetParameter(2, signalmax) ; 
       signalF->SetParameter(3, timezero1) ;               
       gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ; 
       energy = signalF->GetParameter(2) ; 
-      time   = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
+      time   = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ;
     }
   }
   if (time == 0) energy = 0 ; 
@@ -733,107 +739,15 @@ Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
   // Reimplemented by Boris Polichtchouk (Jul 2006)
   // to make it working with the Jul-Aug 2006 beam test data.
  
+  //Create raw decoder.
 
-  AliPHOSRawStream in(rawReader);
-  in.SetOldRCUFormat(isOldRCUFormat);
-  TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
-  signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ; 
-
-  Int_t relId[4], id =0;
-  Bool_t lowGainFlag = kFALSE ; 
+  AliPHOSRawDecoder dc(rawReader);
+  dc.SetOldRCUFormat(isOldRCUFormat);
+  dc.SubtractPedestals(kTRUE);
 
   TClonesArray * digits = Digits() ;
-  digits->Clear() ;
-
-  Int_t iBin = 0;
-  Int_t idigit = 0 ; 
-  Double_t energyHG = 0. ; 
-  Double_t energyLG = 0. ; 
-  Double_t time   = 0. ;
-
-  Int_t iDigLow = 0;
-  Int_t iDigHigh = 0;
-
-  TH1F* gLowGain = 0;
-  TH1F* gHighGain = 0;
-
-  while ( in.Next() ) { // PHOS entries loop 
-       
-    if(!gHighGain) gHighGain = new TH1F("gHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength());
-    else
-      if(gHighGain->GetNbinsX() != in.GetTimeLength()) {
-       delete gHighGain;
-       gHighGain = new TH1F("gHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength());
-      }
-       
-    if(!gLowGain)  gLowGain = new TH1F("gLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength());
-    else
-      if(gLowGain->GetNbinsX() != in.GetTimeLength()) {
-        delete gLowGain;
-        gLowGain = new TH1F("gLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength());
-      }
-
-    lowGainFlag = in.IsLowGain();
-    
-    if(lowGainFlag) 
-      gLowGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
-    else {
-      gHighGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal());
-    }
-
-    iBin++;
-
-    if(iBin==in.GetTimeLength()) {
-      iBin=0;
-
-      if(lowGainFlag) iDigLow++;
-      else iDigHigh++;
-         
-      // Temporarily we do not fit the sample graph, but
-      // take the energy from the graph maximum, and the pedestal from the 0th point
-      // 30 Aug 2006
-
-      //FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, energy, time);
-      
-      energyHG = gHighGain->GetMaximum();
-      energyHG -= gHighGain->GetBinContent(0); // "pedestal subtraction"
-      
-      energyLG = gLowGain->GetMaximum();
-      energyLG -= gLowGain->GetBinContent(0); // "pedestal subtraction"
-      energyLG *= AliPHOS::GetRawFormatHighLowGainFactor(); // *16
-      
-      if(AliLog::GetGlobalDebugLevel()>3) {
-      AliDebug(4,Form("----Printing gHighGain: ----\n")); gHighGain->Print("all");
-      AliDebug(4,Form("----Printing gLowGain: ----\n")); gLowGain->Print("all");
-      }
-
-      AliDebug(2,Form("AliPHOSGetter::ReadRaw: mod %d energyHG %f, energyLG %f lowGainFlag %d\n",
-            in.GetModule(),energyHG,energyLG,(Int_t)lowGainFlag));
-      time = -1;
-
-      relId[0] = in.GetModule()+1;
-      relId[1] = 0;
-      relId[2] = in.GetRow();
-      relId[3] = in.GetColumn();
-      if(!PHOSGeometry()) Fatal("ReadRaw","Couldn't find PHOSGeometry!");
-      PHOSGeometry()->RelToAbsNumbering(relId, id);
-
-      if(!lowGainFlag) {
-       new((*digits)[idigit]) AliPHOSDigit(-1,id,(Float_t)energyHG,time);
-       idigit++;
-      }
-      else {
-       new((*digits)[idigit]) AliPHOSDigit(-1,id,(Float_t)energyLG,time);
-       idigit++;
-      }
-
-    }
-  }
-
-  // PHOS entries loop
-  digits->Sort() ;
+  AliPHOSRawDigiProducer pr;
+  pr.MakeDigits(digits,&dc);
 
   //!!!!for debug!!!
   Int_t modMax=-111;
@@ -842,6 +756,7 @@ Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
   Float_t eMax=-333;
   //!!!for debug!!!
 
+  Int_t relId[4];
   for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
     AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
     if(digit->GetEnergy()>eMax) {
@@ -852,15 +767,9 @@ Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat)
       colMax=relId[3];
     }
   }
-//   printf("\t\t\t------ %d Digits: %d LowGain + %d HighGain.\n",
-//      digits->GetEntriesFast(),iDigLow,iDigHigh);   
-
-  AliDebug(1,Form("Digit with max. energy:  modMax %d colMax %d rowMax %d  eMax %f\n",
-        modMax,colMax,rowMax,eMax));
 
-  delete signalF ;
-  delete gHighGain;
-  delete gLowGain;
+  AliDebug(1,Form("Digit with max. energy:  modMax %d colMax %d rowMax %d  eMax %f\n\n",
+                 modMax,colMax,rowMax,eMax));
 
   return digits->GetEntriesFast() ; 
 }