]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixes for reading zero-suppressed data. These should be propagated to
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Sep 2008 16:55:17 +0000 (16:55 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Sep 2008 16:55:17 +0000 (16:55 +0000)
the release.

16 files changed:
FMD/AliFMDAltroMapping.cxx
FMD/AliFMDDisplay.cxx
FMD/AliFMDGeometryBuilder.cxx
FMD/AliFMDInput.cxx
FMD/AliFMDInput.h
FMD/AliFMDPattern.cxx
FMD/AliFMDPedestalDA.cxx
FMD/AliFMDPedestalDA.h
FMD/AliFMDRawReader.cxx
FMD/AliFMDRawReader.h
FMD/AliFMDRawStream.cxx
FMD/AliFMDReconstructor.cxx
FMD/AliFMDReconstructor.h
FMD/scripts/FullMapping.C
FMD/scripts/TestAltroMapping.C
FMD/scripts/TestPedestalDA.C

index 2e6cdab02e7ef08544cfea22086984e3e5ebbabd..b093dfed5d4b201b6432f973d33a2201c47fa429 100644 (file)
@@ -147,17 +147,18 @@ AliFMDAltroMapping::Channel2StripBase(UShort_t  board, UShort_t  altro,
   // return the first strip, as seen by the ALTRO channel, in the
   // given range.  
   //
-  ring         =  Board2Ring(board);
+  ring          =  Board2Ring(board);
+  UShort_t fsec =  board < 16 ? 1 : 0;
   switch (ring) {
   case 'i':
   case 'I':
-    sec = ((board / 16) * 10 + (altro < 1 ? 0 : altro < 2 ? 4 : 6) 
+    sec = (fsec * 10 + (altro < 1 ? 0 : altro < 2 ? 4 : 6) 
           + 2 * (chan / 8) + chan % 2);
     str = ((chan % 8) / 2) * 128;
     break;
   case 'o':
   case 'O': 
-    sec = ((board / 16) * 20 + (altro < 1 ? 0 : altro < 2 ? 8 : 12) 
+    sec = (fsec * 20 + (altro < 1 ? 0 : altro < 2 ? 8 : 12) 
           + 2 * (chan / 4) + chan % 2);
     str = ((chan % 4) / 2) * 128;
     break;
@@ -377,21 +378,24 @@ AliFMDAltroMapping::Strip2Channel(Char_t    ring,  UShort_t  sec,
   // With this information, we can decode the detector coordinates to
   // give us a unique hardware address 
   //
-  UInt_t tmp   = 0;
+  UInt_t   tmp    = 0;
+  UShort_t fboard = 0;
   switch (ring) {
   case 'I':
   case 'i':
-    board =  (sec / 10) * 16;
-    altro =  (sec % 10) < 4 ? 0 : (sec % 10) < 6 ? 1 : 2;
-    tmp   =  (sec % 10) - (altro == 0 ? 0 : altro == 1 ? 4 : 6);
-    chan  =  2  * (str / 128) + (sec % 2) + ((tmp / 2) % 2) * 8;
+    fboard =  sec < 10 ? 1 : 0;
+    board  =  fboard * 16;
+    altro  =  (sec % 10) < 4 ? 0 : (sec % 10) < 6 ? 1 : 2;
+    tmp    =  (sec % 10) - (altro == 0 ? 0 : altro == 1 ? 4 : 6);
+    chan   =  2  * (str / 128) + (sec % 2) + ((tmp / 2) % 2) * 8;
     break;
   case 'O':
   case 'o':
-    board =  (sec / 20) * 16 + 1;
-    altro =  (sec % 20) < 8 ? 0 : (sec % 20) < 12 ? 1 : 2;
-    tmp   =  (sec % 20) - (altro == 0 ? 0 : altro == 1 ? 8 : 12);
-    chan  =  2 * (str / 128) + (sec % 2) + ((tmp / 2) % 4) * 4;
+    fboard =  sec < 20 ? 1 : 0;
+    board  =  fboard * 16 + 1;
+    altro  =  (sec % 20) < 8 ? 0 : (sec % 20) < 12 ? 1 : 2;
+    tmp    =  (sec % 20) - (altro == 0 ? 0 : altro == 1 ? 8 : 12);
+    chan   =  2 * (str / 128) + (sec % 2) + ((tmp / 2) % 4) * 4;
     break;
   }
   return kTRUE;
index 0d51db51e91b7a59558055e87e502eb24f3bec41..fac680a8da7715fc24856fb1ebc8d0a441fe3dd7 100644 (file)
@@ -54,6 +54,7 @@
 #include "AliFMDRecPoint.h"     // ALIFMDRECPOINT_H
 #include "AliFMDGeometry.h"    // ALIFMDGEOMETRY_H
 #include "AliFMDParameters.h"  // ALIFMDPARAMETERS_H
+#include "AliFMDRawReader.h"    // ALIFMDRAWREADER_H
 #include <AliESDFMD.h>          // ALIESDFMD_H
 // #include <AliLog.h>
 #include "AliFMDDebug.h" // Better debug macros
@@ -407,12 +408,19 @@ AliFMDDisplay::MakeAux()
   if (!fAux) {
     fAux = new TCanvas("aux", "Aux");
     fAux->SetLogy();
+    fAux->SetFillColor(kWhite);
+    fAux->SetBorderMode(0);
+    fAux->SetBorderSize(0);
     Float_t dBin = (range->fHigh - range->fLow) / range->fNbins;
     fSpec = new TH1D("spec", "Spectra", range->fNbins, 
-                    range->fLow-dBin/2, range->fHigh-dBin/2);
+                    range->fLow-dBin/2, range->fHigh+dBin/2);
     fSpecCut = static_cast<TH1*>(fSpec->Clone("specCut"));
+    fSpec->SetXTitle("signal");
+    fSpec->SetYTitle("events");
     fSpec->SetFillColor(2);
     fSpec->SetFillStyle(3001);
+    fSpecCut->SetXTitle("signal");
+    fSpecCut->SetYTitle("events");
     fSpecCut->SetFillColor(4);
     fSpecCut->SetFillStyle(3001);
   }
@@ -584,7 +592,8 @@ AliFMDDisplay::ChangeFactor()
   // The factor depends on what is 
   // drawn in the AUX canvas
   AliInfo(Form("Noise factor is now %4.1f, pedestal factor %3.1f", 
-              10*fFactor->GetMinimum(),fFactor->GetMaximum()));
+              fFactor->GetMinimum(),
+              (fFactor->GetMaximum()-fFactor->GetMaximum())));
   Redisplay();
 }
 
@@ -728,10 +737,14 @@ AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
   UShort_t str           =  digit->Strip();
   Double_t ped           =  parm->GetPedestal(det,ring, sec, str);
   Double_t pedW          =  parm->GetPedestalWidth(det,ring, sec, str);
-  Double_t threshold     =  (ped * fFactor->GetMaximum()
-                            + pedW * fFactor->GetMinimum());
+  Double_t threshold     =  (fFMDReader->IsZeroSuppressed(det-1) ? 
+                            0 : (ped * (fFactor->GetMaximum()
+                                        -fFactor->GetMinimum())
+                                 + pedW * fFactor->GetMinimum()));
   if (threshold > fgkAdcRange.fHigh) threshold = fgkAdcRange.fHigh;
   Float_t  counts        =  digit->Counts();
+  if (fFMDReader->IsZeroSuppressed(det-1))
+    counts += fFMDReader->NoiseFactor(det-1) * pedW;
 
   AliFMDDebug(10, ("FMD%d%c[%02d,%03d] counts %4d threshold %4d", 
                   det, ring, sec, str, Int_t(counts), Int_t(threshold)));
index 148fe83fe8a480a3ceb1efe82c238f85bf8998d0..6423586c9bc1724e8794f3ea190370995c80b63c 100644 (file)
@@ -755,7 +755,7 @@ AliFMDGeometryBuilder::FMD1Geometry(AliFMD1* fmd1,
   TGeoVolume* top    = gGeoManager->GetVolume("ALIC");
   // TGeoMatrix* matrix = new TGeoTranslation("FMD1 trans", 0, 0, z);
   TGeoRotation* rot = new TGeoRotation("FMD1 rotatation");
-  rot->RotateZ(-90);
+  rot->RotateZ(90);
   TGeoMatrix* matrix = new TGeoCombiTrans("FMD1 trans", 0, 0, z, rot);
   AliFMDDebug(5, ("Placing volumes %s and %s in ALIC at z=%f", 
                   fmd1TopVolume->GetName(), fmd1BotVolume->GetName(), z));
@@ -1020,6 +1020,7 @@ AliFMDGeometryBuilder::FMD3Geometry(AliFMD3* fmd3,
                                     holeLW, holeHW, holeD, holeL);
   TGeoTrd1* plateShape = new TGeoTrd1("FMD3_cooling_plate", 
                                      holeLW, holeHW, .033, holeL);
+  (void*)holeShape;
   TGeoRotation* holeRot = new TGeoRotation();
   holeRot->SetName("FMD3_cone_hole_rotation");
   holeRot->RotateZ(90);
@@ -1027,7 +1028,6 @@ AliFMDGeometryBuilder::FMD3Geometry(AliFMD3* fmd3,
   TGeoCombiTrans* holeBaseTrans = new TGeoCombiTrans(holeX, 0, holeZ, holeRot);
   holeBaseTrans->SetName("FMD3_cone_hole_base_matrix");
   TGeoCombiTrans* plateBaseTrans = new TGeoCombiTrans(plateX, 0,plateZ,holeRot);
-  (void*)holeShape;
   TGeoVolume* plateVolume = new TGeoVolume("FMD3_cooling_plate", 
                                           plateShape, fAl);
   plateShape->SetTitle("FMD3 cooling plate");
index c906a277201753faf41bab1e422eab96920325d1..4496982720aa754bdee0b3cedfe832d37bcd167f 100644 (file)
@@ -78,6 +78,7 @@ AliFMDInput::AliFMDInput()
     fStack(0),
     fFMDLoader(0), 
     fReader(0),
+    fFMDReader(0),
     fFMD(0),
     fESD(0),
     fESDEvent(0),
@@ -119,6 +120,7 @@ AliFMDInput::AliFMDInput(const char* gAliceFile)
     fStack(0),
     fFMDLoader(0), 
     fReader(0),
+    fFMDReader(0),
     fFMD(0),
     fESD(0),
     fESDEvent(0),
@@ -241,6 +243,7 @@ AliFMDInput::Init()
     else 
       fReader = new AliRawReaderFile(-1);
 #endif
+    fFMDReader = new AliFMDRawReader(fReader, 0);
   }
   
   // Optionally, get the geometry 
@@ -382,11 +385,11 @@ AliFMDInput::Begin(Int_t event)
 
   // Possibly load FMD Digit information 
   if (TESTBIT(fTreeMask, kRaw)) {
-    AliInfo("Getting FMD raw data digits");
+    // AliInfo("Getting FMD raw data digits");
     if (!fReader->NextEvent()) return kFALSE;
-    AliFMDRawReader r(fReader, 0);
+    // AliFMDRawReader r(fReader, 0);
     fArrayA->Clear();
-    r.ReadAdcs(fArrayA);
+    fFMDReader->ReadAdcs(fArrayA);
     AliFMDDebug(1, ("Got a total of %d digits", fArrayA->GetEntriesFast()));
   }
   fEventCount++;
index 588730245840b577f3ccf749e6a982834db57c93..d284ad31fb6c3573124c0c39a2220ee42f66fed3 100644 (file)
@@ -38,6 +38,7 @@ class AliLoader;
 class AliStack;
 class AliRun;
 class AliRawReader;
+class AliFMDRawReader;
 class AliFMD;
 class AliFMDHit;
 class AliFMDDigit;
@@ -249,6 +250,7 @@ protected:
       fStack(0),
       fFMDLoader(0),
       fReader(0),
+      fFMDReader(0),
       fFMD(0),
       fESD(0),
       fESDEvent(0),
@@ -276,34 +278,35 @@ protected:
       @return  REference to this */
   AliFMDInput& operator=(const AliFMDInput&) { return *this; }
 
-  TString       fGAliceFile; // File name of gAlice file
-  AliRunLoader* fLoader;     // Loader of FMD data 
-  AliRun*       fRun;        // Run information
-  AliStack*     fStack;      // Stack of particles 
-  AliLoader*    fFMDLoader;  // Loader of FMD data 
-  AliRawReader* fReader;     // Raw data reader 
-  AliFMD*       fFMD;        // FMD object
-  AliESDFMD*    fESD;        // FMD ESD data  
-  AliESDEvent*  fESDEvent;   // ESD Event object. 
-  TTree*        fTreeE;      // Header tree 
-  TTree*        fTreeH;      // Hits tree
-  TTree*        fTreeD;      // Digit tree 
-  TTree*        fTreeS;      // SDigit tree 
-  TTree*        fTreeR;      // RecPoint tree
-  TTree*        fTreeA;      // Raw data tree
-  TChain*       fChainE;     // Chain of ESD's
-  TClonesArray* fArrayE;     // Event info array
-  TClonesArray* fArrayH;     // Hit info array
-  TClonesArray* fArrayD;     // Digit info array
-  TClonesArray* fArrayS;     // SDigit info array
-  TClonesArray* fArrayR;     // Rec points info array
-  TClonesArray* fArrayA;     // Raw data (digits) info array
-  AliHeader*    fHeader;     // Header 
-  TGeoManager*  fGeoManager; // Geometry manager
-  Int_t         fTreeMask;   // Which tree's to load
-  TString       fRawFile;    // Raw input file
-  Bool_t        fIsInit;     // Have we been initialized 
-  Int_t         fEventCount; // Event counter 
+  TString          fGAliceFile; // File name of gAlice file
+  AliRunLoader*    fLoader;     // Loader of FMD data 
+  AliRun*          fRun;        // Run information
+  AliStack*        fStack;      // Stack of particles 
+  AliLoader*       fFMDLoader;  // Loader of FMD data 
+  AliRawReader*    fReader;     // Raw data reader 
+  AliFMDRawReader* fFMDReader;  // FMD raw reader
+  AliFMD*          fFMD;        // FMD object
+  AliESDFMD*       fESD;        // FMD ESD data  
+  AliESDEvent*     fESDEvent;   // ESD Event object. 
+  TTree*           fTreeE;      // Header tree 
+  TTree*           fTreeH;      // Hits tree
+  TTree*           fTreeD;      // Digit tree 
+  TTree*           fTreeS;      // SDigit tree 
+  TTree*           fTreeR;      // RecPoint tree
+  TTree*           fTreeA;      // Raw data tree
+  TChain*          fChainE;     // Chain of ESD's
+  TClonesArray*    fArrayE;     // Event info array
+  TClonesArray*    fArrayH;     // Hit info array
+  TClonesArray*    fArrayD;     // Digit info array
+  TClonesArray*    fArrayS;     // SDigit info array
+  TClonesArray*    fArrayR;     // Rec points info array
+  TClonesArray*    fArrayA;     // Raw data (digits) info array
+  AliHeader*       fHeader;     // Header 
+  TGeoManager*     fGeoManager; // Geometry manager
+  Int_t            fTreeMask;   // Which tree's to load
+  TString          fRawFile;    // Raw input file
+  Bool_t           fIsInit;     // Have we been initialized 
+  Int_t            fEventCount; // Event counter 
   ClassDef(AliFMDInput,0)  //Hits for detector FMD
 };
 
index d033d8ef83385d4d3b9d421c197f6531aa02e995..932736d11b423abfe9db4a9905946c48c2c9bc0e 100644 (file)
@@ -161,11 +161,12 @@ AliFMDPattern::AliFMDPatternDetector::Begin(Int_t      nlevel,
   TStyle* style = gStyle;  
   if (nlevel < 1) nlevel = style->GetNumberOfColors();
   fCounts.Set(nlevel);
+  Double_t rr = 1.05 * r;
   if (!fFrame) {
     // The code-checker thinks this is not using the declaration of
     // TH2F - what a morron!   
     fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId), 
-                     10, -r, r, 10, -r, r);
+                     100, -rr, rr, 100, -rr, rr);
     fFrame->SetStats(kFALSE);
     fFrame->Draw();
   }
@@ -190,6 +191,7 @@ AliFMDPattern::AliFMDPatternDetector::Begin(Int_t      nlevel,
     g->SetFillColor(col);
     g->SetMarkerSize(i * .2 + .2);
     g->SetMarkerStyle(2);
+    g->SetEditable(kFALSE);
     g->Draw("same p");
     fGraphs.AddAtAndExpand(g, i);
   }
@@ -217,7 +219,18 @@ AliFMDPattern::AliFMDPatternDetector::End()
   TIter   next(&fGraphs);
   TGraph* g = 0;
   Int_t   i = 0;
-  while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]);
+  while ((g = static_cast<TGraph*>(next()))) { 
+    Int_t cnt = fCounts[i++];
+    if (cnt > 0) { 
+      g->Set(cnt);
+      g->SetMarkerSize(i * .2 + .2);
+    }
+    else {
+      g->SetPoint(0,0,0);
+      g->SetMarkerSize(0);
+    }
+  }
+  
 }
 //____________________________________________________________________
 void
index bb84b771e5b1fcd4cf9779fa9c80ccd10196ce17..c3b8eeec3717b2e9ae4d7e74013a2ec70d83062d 100644 (file)
@@ -28,6 +28,7 @@
 //
 
 #include "AliFMDPedestalDA.h"
+#include "AliFMDAltroMapping.h"
 #include "iostream"
 #include "fstream"
 #include "AliLog.h"
@@ -45,8 +46,11 @@ AliFMDPedestalDA::AliFMDPedestalDA() : AliFMDBaseDA(),
   fNoiseSummary("NoiseSummary","noise",51200,0,51200),
   fZSfileFMD1(),
   fZSfileFMD2(),
-  fZSfileFMD3()
+  fZSfileFMD3(), 
+  fMinTimebin(3 * 4 * 3 * 16), // 3 ddls, 4 FECs, 3 Altros, 16 channels
+  fMaxTimebin(3 * 4 * 3 * 16)  // 3 ddls, 4 FECs, 3 Altros, 16 channels
 {
+  // Default constructor 
   fOutputFile.open("peds.csv");
   fZSfileFMD1.open("ddl3072.csv");
   fZSfileFMD2.open("ddl3073.csv");
@@ -61,22 +65,26 @@ AliFMDPedestalDA::AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) :
   fNoiseSummary("NoiseSummary","noise",51200,0,51200),
   fZSfileFMD1(),
   fZSfileFMD2(),
-  fZSfileFMD3()
+  fZSfileFMD3(),
+  fMinTimebin(pedDA.fMinTimebin),
+  fMaxTimebin(pedDA.fMaxTimebin)
 {
-  
+  // Copy constructor 
 }
 
 //_____________________________________________________________________
 AliFMDPedestalDA::~AliFMDPedestalDA() 
 { 
+  // Destructor.
 }
 
 //_____________________________________________________________________
 void AliFMDPedestalDA::Init() 
 { 
+  // Initialise 
   SetRequiredEvents(1000);
-  
+  fMinTimebin.Reset(1024);
+  fMaxTimebin.Reset(-1);
 }
 
 //_____________________________________________________________________
@@ -86,8 +94,16 @@ void AliFMDPedestalDA::AddChannelContainer(TObjArray* sectorArray,
                                           UShort_t sec, 
                                           UShort_t strip) 
 {
+  // Add a channel to the containers.
+  //
+  // Parameters:
+  //     sectorArray  Array of sectors
+  //     det          Detector 
+  //     ring         Ring
+  //     sec          Sector 
+  //     strip        Strip
   AliFMDParameters* pars        = AliFMDParameters::Instance();
-  UInt_t             samples     = pars->GetSampleRate(det, ring, sec, strip);
+  UInt_t            samples     = pars->GetSampleRate(det, ring, sec, strip);
   TObjArray*        sampleArray = new TObjArray(samples);
   sampleArray->SetOwner();
   for (UInt_t sample = 0; sample < samples; sample++) {
@@ -102,20 +118,22 @@ void AliFMDPedestalDA::AddChannelContainer(TObjArray* sectorArray,
     sampleArray->AddAt(hSample, sample);
   }
   sectorArray->AddAtAndExpand(sampleArray, strip);
-  
-
 }
 
 //_____________________________________________________________________
 void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit) 
 {
+  // Fill ADC values from a digit into the corresponding histogram.
+  //
+  // Parameters:
+  //    digit Digit to fill ADC values for.
   UShort_t det   = digit->Detector();
   Char_t   ring  = digit->Ring();
   UShort_t sec   = digit->Sector();
   UShort_t strip = digit->Strip();
   
   AliFMDParameters* pars     = AliFMDParameters::Instance();
-  UInt_t             samples  = pars->GetSampleRate(det, ring, sec, strip);
+  UInt_t            samples  = pars->GetSampleRate(det, ring, sec, strip);
   for (UInt_t sample = 0; sample < samples; sample++) {
     TH1S* hSample = GetChannel(det, ring, sec, strip, sample);
     hSample->Fill(digit->Count(sample));
@@ -127,21 +145,30 @@ void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit)
 void AliFMDPedestalDA::Analyse(UShort_t det, 
                               Char_t   ring, 
                               UShort_t sec, 
-                              UShort_t strip) {
-  
+                              UShort_t strip) 
+{
+  // Analyse a strip.  That is, compute the mean and spread of the ADC
+  // spectra for all strips.  Also output on files the values. 
+  //
+  // Parameters:
+  //     det   Detector
+  //     ring  Ring
+  //     sec   Sector 
+  //     strip Strip.
   AliFMDParameters* pars     = AliFMDParameters::Instance();
-  UInt_t             samples  = pars->GetSampleRate(det, ring, sec, strip);
+  Float_t           factor   = pars->GetPedestalFactor();
+  UInt_t            samples  = pars->GetSampleRate(det, ring, sec, strip);
   for (UShort_t sample = 0; sample < samples; sample++) {
   
-    TH1S* hChannel       = GetChannel(det, ring, sec, strip,sample);
+    TH1S* hChannel = GetChannel(det, ring, sec, strip,sample);
     if(hChannel->GetEntries() == 0) {
       //AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",
       //           det,ring,sec,strip));
       return;
     }
     
-    AliDebug(50, Form("Fitting FMD%d%c_%d_%d with %d entries",det,ring,sec,strip,
-                     hChannel->GetEntries()));
+    AliDebug(50, Form("Fitting FMD%d%c_%d_%d with %d entries",
+                     det,ring,sec,strip, hChannel->GetEntries()));
     TF1 fitFunc("fitFunc","gausn",0,300);
     fitFunc.SetParameters(100,100,1);
     hChannel->Fit("fitFunc","Q0+","",10,200);
@@ -160,22 +187,29 @@ void AliFMDPedestalDA::Analyse(UShort_t det,
     UShort_t ddl, board, altro, channel;
     UShort_t timebin;
     
-    pars->Detector2Hardware(det,ring,sec,strip,sample,ddl,board,altro,channel,timebin);
+    pars->Detector2Hardware(det,ring,sec,strip,sample,
+                           ddl,board,altro,channel,timebin);
+    Int_t idx = HWIndex(ddl, board, altro, channel);
+    if (idx >= 0) { 
+      fMinTimebin[idx] = TMath::Min(Short_t(timebin),   fMinTimebin[idx]);
+      fMaxTimebin[idx] = TMath::Max(Short_t(timebin+1), fMaxTimebin[idx]);
+    }
     
+    std::ostream* zsFile = 0;
     switch(det) {
-    case 1:
-      fZSfileFMD1 << board << ',' << altro << ',' << channel << ',' << timebin << ','
-                 << mean  << ',' << rms << "\n"; break;
-    case 2:
-      fZSfileFMD2 << board << ',' << altro << ',' << channel << ',' << timebin << ','
-                 << mean  << ',' << rms << "\n"; break;
-    case 3:
-      fZSfileFMD3 << board << ',' << altro << ',' << channel << ',' << timebin << ','
-                 << mean  << ',' << rms << "\n"; break;
-    default:
-      AliWarning("Unknown sample!"); break;
+    case 1:  zsFile = &fZSfileFMD1; break;
+    case 2:  zsFile = &fZSfileFMD2; break;
+    case 3:  zsFile = &fZSfileFMD3; break;
+    default: AliWarning("Unknown sample!"); break;
       
     }
+    *zsFile << board   << ',' 
+           << altro   << ',' 
+           << channel << ',' 
+           << timebin << ','
+           << mean    << ',' 
+           << rms     << ','
+           << factor  << "\n"; break;
     
     Float_t chi2ndf = 0;
     
@@ -183,69 +217,66 @@ void AliFMDPedestalDA::Analyse(UShort_t det,
     if(fitFunc.GetNDF())
       chi2ndf = fitFunc.GetChisquare() / fitFunc.GetNDF();
     
+    
     Int_t sampleToWrite = 2;
+    if      (samples == 2) sampleToWrite = 1;
+    else if (samples <  2) sampleToWrite = 0;
     
-    if(pars->GetSampleRate(det,ring,sec,strip)==2)
-      sampleToWrite = 1;
+    if(sample != sampleToWrite) continue;
     
-    if(pars->GetSampleRate(det,ring,sec,strip)<2)
-      sampleToWrite = 0;
     
-    if(sample==sampleToWrite) {
+    fOutputFile << det                         << ','
+               << ring                        << ','
+               << sec                         << ','
+               << strip                       << ','
+               << mean                        << ','
+               << rms                         << ','
+               << fitFunc.GetParameter(1)     << ','
+               << fitFunc.GetParameter(2)     << ','
+               << chi2ndf                     <<"\n";
     
-      fOutputFile << det                         << ','
-                 << ring                        << ','
-                 << sec                         << ','
-                 << strip                       << ','
-                 << mean                        << ','
-                 << rms                         << ','
-                 << fitFunc.GetParameter(1)     << ','
-                 << fitFunc.GetParameter(2)     << ','
-                 << chi2ndf                     <<"\n";
-      
-      if(fSaveHistograms  ) {
-       gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE));
-       TH1F* sumPed   = dynamic_cast<TH1F*>(gDirectory->Get("Pedestals"));
-       TH1F* sumNoise = dynamic_cast<TH1F*>(gDirectory->Get("Noise"));
-       Int_t nStr = (ring == 'I' ? 512 : 256);
-       if (!sumPed) {
-         sumPed = new TH1F("Pedestals", 
-                           Form("Summary of pedestals in FMD%d%c[%02d]", 
+    if(fSaveHistograms  ) {
+      gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE));
+      TH1F* sumPed   = dynamic_cast<TH1F*>(gDirectory->Get("Pedestals"));
+      TH1F* sumNoise = dynamic_cast<TH1F*>(gDirectory->Get("Noise"));
+      Int_t nStr = (ring == 'I' ? 512 : 256);
+      if (!sumPed) {
+       sumPed = new TH1F("Pedestals", 
+                         Form("Summary of pedestals in FMD%d%c[%02d]", 
+                              det, ring, sec), 
+                         nStr, -.5, nStr-.5);
+       sumPed->SetXTitle("Strip");
+       sumPed->SetYTitle("Pedestal [ADC]");
+       sumPed->SetDirectory(gDirectory);
+      }
+      if (!sumNoise) { 
+       sumNoise = new TH1F("Noise", 
+                           Form("Summary of noise in FMD%d%c[%02d]", 
                                 det, ring, sec), 
                            nStr, -.5, nStr-.5);
-         sumPed->SetXTitle("Strip");
-         sumPed->SetYTitle("Pedestal [ADC]");
-         sumPed->SetDirectory(gDirectory);
-       }
-       if (!sumNoise) { 
-         sumNoise = new TH1F("Noise", 
-                             Form("Summary of noise in FMD%d%c[%02d]", 
-                                  det, ring, sec), 
-                             nStr, -.5, nStr-.5);
-         sumNoise->SetXTitle("Strip");
-         sumNoise->SetYTitle("Noise [ADC]");
-         
-         sumNoise->SetDirectory(gDirectory);
-       }
-       sumPed->SetBinContent(strip+1, mean);
-       sumPed->SetBinError(strip+1, rms);
-       sumNoise->SetBinContent(strip+1, rms);
-      
-       if(sumNoise->GetEntries() == nStr)
-         sumNoise->Write(sumNoise->GetName(),TObject::kOverwrite);
-       if(sumPed->GetEntries() == nStr)
-         sumPed->Write(sumPed->GetName(),TObject::kOverwrite);
+       sumNoise->SetXTitle("Strip");
+       sumNoise->SetYTitle("Noise [ADC]");
        
-       fPedSummary.SetBinContent(fCurrentChannel,mean);
-       
-       fNoiseSummary.SetBinContent(fCurrentChannel,rms);
-       fCurrentChannel++;
-       
-       gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE));
-       hChannel->GetXaxis()->SetRange(1,1024);
-       
-       hChannel->Write();
+       sumNoise->SetDirectory(gDirectory);
       }
+      sumPed->SetBinContent(strip+1, mean);
+      sumPed->SetBinError(strip+1, rms);
+      sumNoise->SetBinContent(strip+1, rms);
+      
+      if(sumNoise->GetEntries() == nStr)
+       sumNoise->Write(sumNoise->GetName(),TObject::kOverwrite);
+      if(sumPed->GetEntries() == nStr)
+       sumPed->Write(sumPed->GetName(),TObject::kOverwrite);
+      
+      fPedSummary.SetBinContent(fCurrentChannel,mean);
+      
+      fNoiseSummary.SetBinContent(fCurrentChannel,rms);
+      fCurrentChannel++;
+      
+      gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE));
+      hChannel->GetXaxis()->SetRange(1,1024);
+      
+      hChannel->Write();
     }
   }
 }
@@ -253,28 +284,67 @@ void AliFMDPedestalDA::Analyse(UShort_t det,
 //_____________________________________________________________________
 void AliFMDPedestalDA::Terminate(TFile* diagFile) 
 {
+  // Called at the end of a job.  Fills in missing time-bins and
+  // closes output files
   if(fSaveHistograms) {
     diagFile->cd();
     
     fPedSummary.Write();
     fNoiseSummary.Write();
   }
+  AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
+  if(fZSfileFMD1.is_open()) FillinTimebins(fZSfileFMD1, map->Detector2DDL(1));
+  if(fZSfileFMD2.is_open()) FillinTimebins(fZSfileFMD2, map->Detector2DDL(2));
+  if(fZSfileFMD3.is_open()) FillinTimebins(fZSfileFMD3, map->Detector2DDL(3));
   
-  if(fZSfileFMD1.is_open()) { 
-    fZSfileFMD1.write("# EOF\n",6);
-    fZSfileFMD1.close();  }
-  if(fZSfileFMD2.is_open()) {
-    fZSfileFMD2.write("# EOF\n",6);
-    fZSfileFMD2.close(); }
-  if(fZSfileFMD3.is_open()) {
-    fZSfileFMD3.write("# EOF\n",6);
-    fZSfileFMD3.close(); }
-  
+}
+
+//_____________________________________________________________________
+void AliFMDPedestalDA::FillinTimebins(std::ofstream& out, UShort_t ddl)
+{
+  unsigned short  boards[] = { 0x0, 0x1, 0x10, 0x11, 0xFFFF };
+  unsigned short* board    = boards;
+  while ((*boards) != 0xFFFF) { 
+    for (UShort_t altro = 0; altro < 3; altro++) { 
+      for (UShort_t channel = 0; channel < 16; channel++) { 
+       Int_t idx = HWIndex(ddl, *board, altro, channel);
+       if (idx < 0) { 
+         AliWarning(Form("Invalid index for %4d/0x%02x/0x%x/0x%x: %d", 
+                         ddl, *board, altro, channel, idx));
+         continue;
+       }
+       Short_t min = fMinTimebin[idx];
+       Short_t max = fMaxTimebin[idx];
+       
+       // Channel not seen at all. 
+       if (min > 1023 || max < 0) continue;
+
+       out << "# Extra timebins for 0x" << std::hex 
+           << board << ',' << altro << ',' << channel 
+           << " got time-bins " << min << " to " << max-1 
+           << std::dec << std::endl;
+       
+       for (UShort_t t = 15; t < min; t++) 
+         // Write a phony line 
+         out << board << "," << altro << "," << channel << "," 
+             << t << "," << 1023 << "," << 0 << std::endl;
+
+       for (UShort_t t = max; t < 1024; t++) 
+         // Write a phony line 
+         out << board << "," << altro << "," << channel << "," 
+             << t << "," << 1023 << "," << 0 << std::endl;
+      } // channel loop
+    } // altro loop
+  } // board loop
+  // Write trailer, and close 
+  out.write("# EOF\n", 6);
+  out.close();
 }
 
 //_____________________________________________________________________
 void AliFMDPedestalDA::WriteHeaderToFile() 
 {
+  // Write headers to output files 
   AliFMDParameters* pars       = AliFMDParameters::Instance();
   fOutputFile.write(Form("# %s \n",pars->GetPedestalShuttleID()),13);
   fOutputFile.write("# Detector, "
@@ -286,28 +356,17 @@ void AliFMDPedestalDA::WriteHeaderToFile()
                    "Mu, "
                    "Sigma, "
                    "Chi2/NDF \n", 71);
-  fZSfileFMD1.write("# FMD 1 pedestals \n",19);
-  fZSfileFMD1.write("# board, "
-                   "altro, "
-                   "channel, "
-                   "timebin, "
-                   "pedestal, "
-                   "noise \n", 51);
-  fZSfileFMD2.write("# FMD 2 pedestals \n",19);
-  fZSfileFMD2.write("# board, "
-                   "altro, "
-                   "channel, "
-                   "timebin, "
-                   "pedestal, "
-                   "noise \n", 51);
-  fZSfileFMD3.write("# FMD 3 pedestals \n",19);
-  fZSfileFMD3.write("# board, "
-                   "altro, "
-                   "channel, "
-                   "timebin, "
-                   "pedestal, "
-                   "noise \n", 51);
-  
+
+  std::ostream* zss[] = { &fZSfileFMD1, &fZSfileFMD2, &fZSfileFMD3, 0 };
+  for (size_t i = 0; i < 3; i++) 
+    *(zss[i]) << "# FMD 1 pedestals \n"
+             << "# board, "
+             << "altro, "
+             << "channel, "
+             << "timebin, "
+             << "pedestal, "
+             << "noise, "
+             << "factor\n";
 }
 
 //_____________________________________________________________________
@@ -315,14 +374,25 @@ TH1S* AliFMDPedestalDA::GetChannel(UShort_t det,
                                   Char_t   ring, 
                                   UShort_t sec, 
                                   UShort_t strip,
-                                  UInt_t    sample) 
+                                  UInt_t   sample) 
 {
-  UShort_t   iring     = (ring == 'O' ? 0 : 1);
-  TObjArray* detArray  = static_cast<TObjArray*>(fDetectorArray.At(det));
-  TObjArray* ringArray = static_cast<TObjArray*>(detArray->At(iring));
-  TObjArray* secArray  = static_cast<TObjArray*>(ringArray->At(sec));
-  TObjArray*        sampleArray = static_cast<TObjArray*>(secArray->At(strip));
-  TH1S*      hSample = static_cast<TH1S*>(sampleArray->At(sample));
+  // Get the histogram corresponding to a strip sample.
+  // 
+  // Parameters:
+  //     det    Detector
+  //     ring   Ring
+  //     sec    Sector
+  //     strip  Strip
+  //     sample Sample
+  //
+  // Return:
+  //     ADC spectra of a strip.
+  UShort_t   iring       = (ring == 'O' ? 0 : 1);
+  TObjArray* detArray    = static_cast<TObjArray*>(fDetectorArray.At(det));
+  TObjArray* ringArray   = static_cast<TObjArray*>(detArray->At(iring));
+  TObjArray* secArray    = static_cast<TObjArray*>(ringArray->At(sec));
+  TObjArray* sampleArray = static_cast<TObjArray*>(secArray->At(strip));
+  TH1S*      hSample     = static_cast<TH1S*>(sampleArray->At(sample));
   return hSample;
   
 }
index 20eb89228f44eb8546f397da630edbaac341c312..56174675672cf8ab99745bed8e34eaaadb5bb57e 100644 (file)
 #include "TH1.h"
 #include "TObjArray.h"
 
-class AliFMDPedestalDA: public AliFMDBaseDA {
-  
- public:
-  AliFMDPedestalDA() ;
-  AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) ;
+class AliFMDPedestalDA: public AliFMDBaseDA 
+{
+public:
+  /** 
+   * Constructor.
+   * 
+   */  
+  AliFMDPedestalDA();
+  /** 
+   * Copy constructor 
+   * 
+   * @param pedDA Object to copy from
+   */  
+  AliFMDPedestalDA(const AliFMDPedestalDA & pedDA);
   //  AliFMDPedestalDA& operator = (const AliFMDPedestalDA & pedDA) ; 
+  /** 
+   * Destructor
+   * 
+   */
   virtual ~AliFMDPedestalDA();
+  /** 
+   * Initialiser
+   * 
+   */  
   void Init();
  
- protected:
-  void AddChannelContainer(TObjArray* sectorArray, UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
+protected:
+  /** 
+   * Add a channel to the containers. 
+   * 
+   * @param sectorArray  Array of sectors
+   * @param det          Detector 
+   * @param ring         Ring
+   * @param sec          Sector 
+   * @param strip        Strip
+   */
+  void AddChannelContainer(TObjArray* sectorArray, UShort_t det, 
+                          Char_t ring, UShort_t sec, UShort_t strip);
+  /** 
+   * Fill ADC values from a digit into the corresponding histogram.
+   * 
+   * @param digit Digit to fill ADC values for.
+   */
   void FillChannels(AliFMDDigit* digit);
+  /** 
+   * Analyse a strip.  That is, compute the mean and spread of the ADC
+   * spectra for all strips.  Also output on files the values. 
+   * 
+   * @param det   Detector
+   * @param ring  Ring
+   * @param sec   Sector 
+   * @param strip Strip.
+   */
   void Analyse(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
+  /** 
+   * Write headers to files. 
+   * 
+   */  
   void WriteHeaderToFile();
+  /** 
+   * Called at the end of an event.
+   * 
+   */  
   void FinishEvent() {}
+  /** 
+   * Called at the end of a job.  Fills in missing time-bins and
+   * closes output files  
+   * 
+   */  
   void Terminate(TFile* );
- private:
-  TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, UInt_t sample);
+private:
+  /** 
+   * Get the histogram corresponding to a strip sample.
+   * 
+   * @param det    Detector
+   * @param ring   Ring
+   * @param sec    Sector
+   * @param strip  Strip
+   * @param sample Sample
+   * 
+   * @return ADC spectra of a strip.
+   */
+  TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec, 
+                  UShort_t strip, UInt_t sample);
+  /** 
+   * Calculate the hardware index
+   * 
+   * @param ddl    DDL number
+   * @param board  Board number
+   * @param altro  ALTRO number
+   * @param chan   Channel number
+   * 
+   * @return Index into hardware cache.
+   */
+  Int_t HWIndex(UShort_t ddl, UShort_t board, UShort_t altro, 
+               UShort_t chan) const;
+  void FillinTimebins(std::ofstream& out, UShort_t ddl);
+  /** Current strip */ 
   Int_t fCurrentChannel;
+  /** Pedestal summary */
   TH1F  fPedSummary;
+  /** Noise summary */
   TH1F  fNoiseSummary;
+  /** Output file for zero-suppression for FMD1 */
   std::ofstream fZSfileFMD1;
+  /** Output file for zero-suppression for FMD2 */
   std::ofstream fZSfileFMD2;
+  /** Output file for zero-suppression for FMD3 */
   std::ofstream fZSfileFMD3;
+  /** The minimum timebin seen for all channels */
+  TArrayS fMinTimebin;
+  /** The maximum timebin seen for all channels */
+  TArrayS fMaxTimebin;
+  
   
   ClassDef(AliFMDPedestalDA,0)
-    
 };
+
+inline Int_t
+AliFMDPedestalDA::HWIndex(UShort_t ddl, UShort_t b, UShort_t a, UShort_t c)const
+{
+  // Save some array entries 
+  UShort_t lb = (b > 1 ? b-16+2 : b);
+  const Int_t kNDDL     = 3;
+  const Int_t kNBoard   = 4;
+  const Int_t kNAltro   = 3;
+  const Int_t kNChannel = 16;
+  Int_t idx =  c + kNChannel * (a + kNAltro * (lb + kNBoard * ddl));
+  if (idx > kNDDL * kNBoard * kNAltro * kNChannel) return -1;
+  return idx;
+}
+
 #endif
+//
+// Local Variables:
+//  mode: C++
+// End:
+//
index 898fe4377713c13e3f9c6cafdac420ef0859b042..2fbbd7743c1a5ef3cffd9772267ef4ab2bd8e19d 100644 (file)
@@ -133,13 +133,15 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
   UShort_t stripMin = 0;
   UShort_t stripMax = 0; // 127;
   UShort_t preSamp  = 0; // 14+5;
-  
+
+  Int_t  oldddl = -1;
   UInt_t ddl    = 0;
   UInt_t rate   = 0;
   UInt_t last   = 0;
   UInt_t hwaddr = 0;
   // Data array is approx twice the size needed. 
   UShort_t data[2048];
+  for (size_t i = 0; i < 2048; i++) data[i] = 0; // kUShortMax;
 
   Bool_t isGood = kTRUE;
   while (isGood) {
@@ -150,8 +152,28 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
                      array->GetEntriesFast()));
       break;
     }
+    if (oldddl != ddl) { 
+      fZeroSuppress[ddl] = input.GetZeroSupp();
+      AliFMDDebug(20, ("RCU @ DDL %d zero suppression: %s", 
+                      ddl, (fZeroSuppress[ddl] ? "yes" : "no")));
 
-    AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
+      // WARNING: We store the noise factor in the 2nd baseline
+      // filters excluded post samples, since we'll never use that
+      // mode. 
+      fNoiseFactor[ddl]  = input.GetNPostsamples();
+      AliFMDDebug(20, ("RCU @ DDL %d noise factor: %d", ddl,fNoiseFactor[ddl]));
+
+      Int_t nChAddrMismatch = input.GetNChAddrMismatch();
+      Int_t nChLenMismatch  = input.GetNChLengthMismatch();
+      if (nChAddrMismatch != 0) 
+       AliWarning(Form("Got %d channels with address mis-matches for 0x%03x",
+                       nChAddrMismatch, hwaddr));
+      if (nChLenMismatch != 0) 
+       AliWarning(Form("Got %d channels with length mis-matches for 0x%03x",
+                       nChLenMismatch, hwaddr));
+      oldddl = ddl;
+    }
+    // AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
 
     UShort_t det, sec, samp, board, chip, channel;
     Short_t strbase;
@@ -170,11 +192,15 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
     stripMin = pars->GetMinStrip(det, ring, sec, strbase);
     stripMax = pars->GetMaxStrip(det, ring, sec, strbase);
     preSamp  = pars->GetPreSamples(det, ring, sec, strbase);
-    rate     = pars->GetSampleRate(det, ring, sec, strbase);
+    // WARNING: We use the number of pre-samples to store the
+    // oversampling rate in. 
+    rate     = input.GetNPretriggerSamples();
+    if (rate == 0) rate = pars->GetSampleRate(det, ring, sec, strbase);
     
     // Loop over the `timebins', and make the digits
     for (size_t i = 0; i < last; i++) {
       // if (i < preSamp) continue;
+      AliFMDDebug(15, ("0x%04x/0x%03x/%04d %4d", ddl, hwaddr, i, data[i]));
 
       Short_t  stroff = 0;
       map->Timebin2Strip(sec, i, preSamp, rate, stroff, samp);
@@ -184,6 +210,7 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
                      ddl, hwaddr, i, det, ring, sec, str, samp));
       if (str < 0) { 
        AliFMDDebug(8, ("Got presamples at timebin %d", i));
+       data[i] = 0; // Reset cache 
        continue;
       }
       
@@ -194,6 +221,7 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
       if (lstrip < stripMin || lstrip > stripMax) {
        AliFMDDebug(5, ("FMD%d%c[%02d,%03d]-%d out of range (%3d->%3d)", 
                        det, ring, sec, samp, str, stripMin, stripMax));
+       data[i] = 0; // Reset cache 
        continue;
       }
       
@@ -211,6 +239,7 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
                  ("Setting from FMD%d%c[%2d,%3d]-%d from timebin %4d = %4d", 
                   det, ring, sec, str, samp, i, data[i]));
       digit->SetCount(samp, data[i]);
+      data[i] = 0; // Reset cache 
     }
   }
   return kTRUE;
index 1595baedaa1486b479642ab1c9e91edccc20a6b2..d2159ea2aeb64ac0a299f6101fd26851aeae8ed3 100644 (file)
@@ -60,13 +60,38 @@ public:
       @param array Array to read into 
       @return @c true on success */
   virtual Bool_t ReadAdcs(TClonesArray* array);
-  /** Read SOD event into a container. 
-      @param array Array to read into 
-      @return @c true on success */
+  /** 
+   * Read SOD event into passed objects.
+   * 
+   * @param samplerate   The sample rate object to fill
+   * @param striprange   The strip range object to fill
+   * @param pulseSize    The pulse size object to fill
+   * @param pulseLength  The pulse length (in events) object to fill
+   * 
+   * @return @c true on success
+   */  
   virtual Bool_t ReadSODevent(AliFMDCalibSampleRate* samplerate, 
                              AliFMDCalibStripRange* striprange, 
                              TArrayS &pulseSize, 
                              TArrayS &pulseLength);
+  /** 
+   * Check of the data from DDL @a ddl is zero-suppressed
+   * 
+   * @param ddl DDL number (0-2)
+   * 
+   * @return @c true if the data from this DDL is zero-suppressed. 
+   */  
+  Bool_t IsZeroSuppressed(UShort_t ddl) const { return fZeroSuppress[ddl]; }
+  /** 
+   * The factor used to multiply the noise when making on-line
+   * pedestal subtraction.
+   * 
+   * @param ddl DDL number (0-2)
+   * 
+   * @return The factor used. 
+   */
+  UShort_t NoiseFactor(UShort_t ddl) const { return fNoiseFactor[ddl]; }
+
 protected:
   AliFMDRawReader(const AliFMDRawReader& o) 
     : TTask(o), 
@@ -86,6 +111,8 @@ protected:
   UShort_t        fSampleRate; // The sample rate (if 0, inferred from data)
   UChar_t*        fData; 
   ULong_t        fNbytes; 
+  Bool_t          fZeroSuppress[3];
+  UShort_t        fNoiseFactor[3];
   AliFMDUShortMap fSeen;
   
   ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache 
index 757e5baf20e25aefcbefc3013a462815e1c7c60c..f8c71c56fbfabebf9fc237591947b179a3ef0bf6 100644 (file)
@@ -85,7 +85,26 @@ AliFMDRawStream::ReadChannel(UInt_t& ddl, UInt_t& addr,
        break;
       }
     }
+    // Sanity check - if the total bunch length is less than 1, then
+    // read until we get the next bunch. 
+    Int_t b  = GetTimeLength();
+    if (b < 1) { 
+      AliWarning(Form("Bunch length %0d is less than 0 for "
+                     "DDL %4d address 0x%03x", 
+                     b, ddl, addr));
+      last = 0xFFFF;
+      continue;
+    }
+
+    // Sanity check - if the current time is less than 0, then read
+    // until we get a new bunch. 
     Int_t t  = GetTime();
+    if (t < 0) {
+      AliWarning(Form("Time %0d is less than 0 for DDL %4d address 0x%03x", 
+                     t, ddl, addr));
+      last = 0xFFFF;
+      continue;
+    }
     l        = TMath::Max(l, t);
     data[t]  = signal;
     last     = 0xFFFF;
index 6a6b1c1148781f57eb2ac9c75a7a83f6cb1bb8c2..6cf371cc0e5f90c71d5741400041f111dc482a59 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliFMDDebug.h"
 #include "AliFMDGeometry.h"                // ALIFMDGEOMETRY_H
 #include "AliFMDParameters.h"              // ALIFMDPARAMETERS_H
+#include "AliFMDAltroMapping.h"            // ALIFMDALTROMAPPING_H
 #include "AliFMDDigit.h"                   // ALIFMDDIGIT_H
 #include "AliFMDReconstructor.h"           // ALIFMDRECONSTRUCTOR_H
 #include "AliFMDRawReader.h"               // ALIFMDRAWREADER_H
@@ -202,6 +203,11 @@ AliFMDReconstructor::ConvertDigits(AliRawReader* reader,
   AliFMDRawReader rawRead(reader, digitsTree);
   // rawRead.SetSampleRate(fFMD->GetSampleRate());
   rawRead.Exec();
+  AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
+  for (size_t i = 1; i <= 3; i++) { 
+    fZS[i]       = rawRead.IsZeroSuppressed(map->Detector2DDL(i));
+    fZSFactor[i] = rawRead.NoiseFactor(map->Detector2DDL(i));
+  }
 }
 
 //____________________________________________________________________
@@ -363,10 +369,13 @@ AliFMDReconstructor::SubtractPedestal(AliFMDDigit* digit) const
   // something like that. 
 
   AliFMDParameters* param  = AliFMDParameters::Instance();
-  Float_t           ped    = param->GetPedestal(digit->Detector(), 
-                                               digit->Ring(), 
-                                               digit->Sector(), 
-                                               digit->Strip());
+  Bool_t            zs     = fZS[digit->Detector()-1];
+  UShort_t          fac    = fZSFactor[digit->Detector()-1];
+  Float_t           ped    = (zs ? 0 : 
+                             param->GetPedestal(digit->Detector(), 
+                                                digit->Ring(), 
+                                                digit->Sector(), 
+                                                digit->Strip()));
   Float_t           noise  = param->GetPedestalWidth(digit->Detector(), 
                                                     digit->Ring(), 
                                                     digit->Sector(), 
@@ -383,7 +392,8 @@ AliFMDReconstructor::SubtractPedestal(AliFMDDigit* digit) const
   // else if (digit->Count2() > 0) adc = digit->Count2();
   // else                          adc = digit->Count1();
   Int_t adc    = digit->Counts();
-  Int_t counts = TMath::Max(Int_t(adc - ped), 0);
+  Int_t counts = adc + Int_t(zs ? fac * noise : - ped);
+  counts       = TMath::Max(Int_t(counts), 0);
   if (counts < noise * fNoiseFactor) counts = 0;
   if (counts > 0) AliFMDDebug(15, ("Got a hit strip"));
   if (fDiagStep1) fDiagStep1->Fill(adc, counts);
index 27e5fea771dd30a5a98e39b2c1e4d6516c067a3f..a39ab01083aeaa532d57d84c8303dd4fceb0751b 100644 (file)
@@ -192,6 +192,8 @@ protected:
   TH1*                  fDiagStep3;    // Diagnostics histogram
   TH1*                  fDiagStep4;    // Diagnostics histogram
   TH1*                  fDiagAll;      // Diagnostics histogram
+  mutable Bool_t        fZS[3];         // Zero-suppredded?
+  mutable UShort_t      fZSFactor[3];   // Noise factor for Zero-suppression
 private:
    
   ClassDef(AliFMDReconstructor, 3)  // class for the FMD reconstruction
index 89059a56b4510fe1e756813ae70d0291f1badf74..a4b408c430e139d0f61b7af9194d30dbd62938ea 100644 (file)
@@ -3,12 +3,12 @@
 void
 FullMapping()
 {
+  AliGeomManager::LoadGeometry("geometry.root");
   AliCDBManager*    cdb   = AliCDBManager::Instance();
   AliFMDParameters* param = AliFMDParameters::Instance();
   AliFMDGeometry*   geom  = AliFMDGeometry::Instance();
   cdb->SetDefaultStorage("local://$ALICE_ROOT");
   cdb->SetRun(0);
-  AliGeomManager::LoadGeometry();
   param->Init();
   geom->Init();
   geom->InitTransformations();
index 9bfc44b54c15df6dd690de0e10b58131562c2430..08b751d711915d0262efb4c1eab224422b95a551 100644 (file)
@@ -17,7 +17,8 @@
 # include <TError.h>
 # include <iostream>
 #endif
-#define SHOW_ALL 1
+bool show_all=false;
+
 //____________________________________________________________________
 /** @ingroup ALTRO_test
     @param ddl 
@@ -113,20 +114,22 @@ CheckTrans(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam,
     ok = false;
     Warning("TestHWMap", "Sample # differ %d != %d", sam, osam);
   }
-#ifndef SHOW_ALL
-  if (!ok) 
-    PrintTrans(det,ring,sec,str,sam,
-              ddl,hwaddr,timebin,
-              odet,oring,osec,ostr,osam);
-#endif
+
+  if (!show_all) { 
+    if (!ok) 
+      PrintTrans(det,ring,sec,str,sam,
+                ddl,hwaddr,timebin,
+                odet,oring,osec,ostr,osam);
+  }
 }
 
 //____________________________________________________________________
 /** @ingroup ALTRO_test
  */
 void
-TestAltroMapping(Int_t min=1, Int_t max=3)
+TestAltroMapping(bool sa=false, Int_t min=1, Int_t max=3)
 {
+  show_all = sa;
   // AliLog::SetModuleDebugLevel("FMD", 1);
   // if (min < 1 || min > 3) min = 1;
   if (max < min)          max = min;
@@ -162,11 +165,10 @@ TestAltroMapping(Int_t min=1, Int_t max=3)
                      Addr2Str(ddl, hwaddr, timebin));
              continue;
            }
-#ifdef SHOW_ALL
-           PrintTrans(det,ring,sec,str,sam,
-                      ddl,hwaddr,timebin,
-                      odet,oring,osec,ostr,osam);
-#endif
+           if (show_all) 
+             PrintTrans(det,ring,sec,str,sam,
+                        ddl,hwaddr,timebin,
+                        odet,oring,osec,ostr,osam);
            CheckTrans(det,ring,sec,str,sam,
                       ddl,hwaddr,timebin,
                       odet,oring,osec,ostr,osam);
index c2608d8e52fd0d6c5f4a9c3b4a778170d87e74e8..766bcc03a02a330158751db4c3d94b02e105dfb7 100644 (file)
@@ -38,7 +38,7 @@ void TestPedestalDA(Char_t* fileName="data.raw", Int_t runNumber=1,
   params->UseCompleteHeader(oldFormat);
   
   // Set-up raw readers 
-  AliRawReader *reader = new AliRawReaderDate(fileName,-1);
+  AliRawReader *reader = AliRawReader::Create(fileName);
 
 
   // Set-up timer