]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDGainDA.cxx
fix requested by Laurent Aphecetche to clean up the memory properly during simulation...
[u/mrichter/AliRoot.git] / FMD / AliFMDGainDA.cxx
index d5cfc57d5ed23d3417aa6c8492c25b32d296d7e1..f24161e2a2005796cafb5b98714d72a769c7a252 100644 (file)
@@ -37,6 +37,7 @@
 #include "TMath.h"
 #include "TGraphErrors.h"
 #include "AliFMDParameters.h"
+#include "AliFMDAltroMapping.h"
 
 //_____________________________________________________________________
 ClassImp(AliFMDGainDA)
@@ -167,11 +168,14 @@ void AliFMDGainDA::FillChannels(AliFMDDigit* digit) {
   UShort_t sec   = digit->Sector();
   UShort_t strip = digit->Strip();
   
-  //Strip is always seen as the first in a VA chip. All other strips are junk
-  if(strip % fNumberOfStripsPerChip) return;
+  //Strip is always seen as the first in a VA chip. All other strips are junk.
+  //Strips are counted from zero on even sectors and from 511 on odd sectors...
+   
+  if((sec%2)     && ((strip+1) % fNumberOfStripsPerChip)) return;
+  if(((sec+1)%2) && (strip % fNumberOfStripsPerChip)) return;
+  
   Int_t vaChip   = strip / fNumberOfStripsPerChip; 
   TH1S* hChannel = GetChannelHistogram(det, ring, sec, vaChip);
-  
   hChannel->Fill(digit->Counts());
   UpdatePulseAndADC(det,ring,sec,strip);
 }
@@ -183,8 +187,8 @@ void AliFMDGainDA::Analyse(UShort_t det,
                           UShort_t strip) {
   TGraphErrors* grChannel = GetChannel(det,ring,sec,strip);
   if(!grChannel->GetN()) {
-    // AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",
-    //                 det, ring , sec, strip));
+    AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",
+                     det, ring , sec, strip));
     return;
   }
   TF1 fitFunc("fitFunc","pol1",-10,280); 
@@ -210,13 +214,13 @@ void AliFMDGainDA::Analyse(UShort_t det,
              << chi2ndf                     <<"\n";
   
   //due to RCU trouble, first strips on VAs are excluded
-  if(strip%128 != 0) {
+  // if(strip%128 != 0) {
     
-    fSummaryGains.SetBinContent(fCurrentSummaryStrip,fitFunc.GetParameter(1));
-    fSummaryGains.SetBinError(fCurrentSummaryStrip,fitFunc.GetParError(1));
-    
-    fCurrentSummaryStrip++;
-  }
+  fSummaryGains.SetBinContent(fCurrentSummaryStrip,fitFunc.GetParameter(1));
+  fSummaryGains.SetBinError(fCurrentSummaryStrip,fitFunc.GetParError(1));
+  
+  fCurrentSummaryStrip++;
+    // }
   if(fSaveHistograms) {
     gDirectory->cd(GetSectorPath(det,ring, sec, kTRUE));
     
@@ -244,8 +248,10 @@ void AliFMDGainDA::Analyse(UShort_t det,
 //_____________________________________________________________________
 void AliFMDGainDA::Terminate(TFile* diagFile)
 {
-  diagFile->cd();
-  fSummaryGains.Write();
+  if(diagFile) {
+    diagFile->cd();
+    fSummaryGains.Write();
+  }
 }
 
 //_____________________________________________________________________
@@ -306,14 +312,21 @@ void AliFMDGainDA::UpdatePulseAndADC(UShort_t det,
 {
   
   AliFMDParameters* pars = AliFMDParameters::Instance();
-  UInt_t ddl, board,chip,ch;
-  pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,ch);
+  // UInt_t ddl, board,chip,ch;
+  UShort_t board = pars->GetAltroMap()->Sector2Board(ring, sec);
+  // pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,ch);
+  /// pars->GetAltroMap()->Strip2Channel(
   Int_t halfring = GetHalfringIndex(det,ring,board/16);
   
   if(GetCurrentEvent()> (fNumberOfStripsPerChip*fEventsPerChannel.At(halfring)))
     return;
-  if(strip % fNumberOfStripsPerChip) return;
-  if(((GetCurrentEvent()) % fPulseLength.At(halfring)) && GetCurrentEvent() > 0) return;
+  
+  if((sec%2)     && ((strip+1) % fNumberOfStripsPerChip)) return;
+  
+  if(((sec+1)%2) && (strip % fNumberOfStripsPerChip)) return;
+  
+  if(((GetCurrentEvent()) % fPulseLength.At(halfring)) 
+     && GetCurrentEvent() > 0) return;
      
   Int_t vaChip = strip/fNumberOfStripsPerChip; 
   TH1S* hChannel = GetChannelHistogram(det,ring,sec,vaChip);
@@ -325,7 +338,8 @@ void AliFMDGainDA::UpdatePulseAndADC(UShort_t det,
   }
   Double_t mean      = hChannel->GetMean();
   Double_t rms       = hChannel->GetRMS();
-  Double_t pulse     = Double_t(fCurrentPulse.At(halfring)) * fPulseSize.At(halfring);
+  Double_t pulse     = (Double_t(fCurrentPulse.At(halfring)) 
+                       * fPulseSize.At(halfring));
   Int_t    firstBin  = hChannel->GetXaxis()->GetFirst();
   Int_t    lastBin   = hChannel->GetXaxis()->GetLast();
   hChannel->GetXaxis()->SetRangeUser(mean-4*rms,mean+4*rms);
@@ -335,7 +349,15 @@ void AliFMDGainDA::UpdatePulseAndADC(UShort_t det,
   
   hChannel->GetXaxis()->SetRange(firstBin,lastBin);
   
-  Int_t channelNumber = strip + (GetCurrentEvent()-1)/((fPulseLength.At(halfring)*fHighPulse)/fPulseSize.At(halfring)); 
+  Int_t    channelNumber      = (strip + 
+                                (GetCurrentEvent()-1)
+                                / ((fPulseLength.At(halfring)*fHighPulse)
+                                   / fPulseSize.At(halfring))); 
+  if(sec%2)
+    channelNumber      = (strip - 
+                         (GetCurrentEvent()-1)
+                         / ((fPulseLength.At(halfring)*fHighPulse)
+                            / fPulseSize.At(halfring))); 
   
   TGraphErrors* channel = GetChannel(det,ring,sec,channelNumber);