First version of the PHOS/EMCAL ALTRO decoder which derives from the new AliAltroRawS...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Jun 2009 08:14:25 +0000 (08:14 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Jun 2009 08:14:25 +0000 (08:14 +0000)
RAW/AliCaloRawStreamV3.cxx [new file with mode: 0644]
RAW/AliCaloRawStreamV3.h [new file with mode: 0644]
RAW/CMake_libRAWDatarec.txt
RAW/RAWDatarecLinkDef.h
RAW/libRAWDatarec.pkg
RAW/readCaloV3.C [new file with mode: 0644]

diff --git a/RAW/AliCaloRawStreamV3.cxx b/RAW/AliCaloRawStreamV3.cxx
new file mode 100644 (file)
index 0000000..85ca464
--- /dev/null
@@ -0,0 +1,179 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/* $Id: $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// This class provides access to PHOS/EMCAL digits in raw data.
+//
+// It loops over all PHOS/EMCAL digits in the raw data given by the AliRawReader.
+// The Next method goes to the next digit. If there are no digits left
+// it returns kFALSE.
+// Several getters provide information about the current digit.
+// usage: 
+//    AliRawReader *reader = AliRawReader::Create(fileName);
+//    AliCaloRawStreamV3 *stream = new AliCaloRawStreamV3(reader,calo);
+//    while (reader->NextEvent())
+//      while (stream->NextDDL())
+//        while (stream->NextChannel()) ...
+///
+/// Yuri Kharlov. 23 June 2009
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TString.h>
+#include <TSystem.h>
+
+#include "AliCaloRawStreamV3.h"
+#include "AliRawReader.h"
+#include "AliCaloAltroMapping.h"
+
+ClassImp(AliCaloRawStreamV3)
+
+
+//_____________________________________________________________________________
+AliCaloRawStreamV3::AliCaloRawStreamV3(AliRawReader* rawReader, TString calo, AliAltroMapping **mapping) :
+  AliAltroRawStreamV3(rawReader),
+  fModule(-1),
+  fRow(-1),
+  fColumn(-1),
+  fCaloFlag(0),
+  fFilter(0),
+  fNRCU(0),
+  fNSides(0),
+  fCalo(calo),
+  fExternalMapping(kFALSE)
+{
+  // create an object to read PHOS/EMCAL raw digits
+  SelectRawData(calo);
+
+  // PHOS and EMCAL have differen number of RCU per module
+  //For PHOS
+  fNRCU = 4;
+  fNSides = 1;
+  //For EMCAL
+  TString sides[]={"A","C"};
+  if(fCalo == "EMCAL")  {
+    fNRCU = 2;
+    fNSides = 2;
+  }
+
+  if (mapping == NULL) {
+    TString path = gSystem->Getenv("ALICE_ROOT");
+    path += "/"+fCalo+"/mapping/RCU";
+    TString path2;
+    for(Int_t j = 0; j < fNSides; j++){
+      for(Int_t i = 0; i < fNRCU; i++) {
+       path2 = path;
+       path2 += i;
+       if(fCalo == "EMCAL") path2 += sides[j];
+       path2 += ".data";
+       fMapping[j*fNRCU+ i] = new AliCaloAltroMapping(path2.Data());
+      }
+    }
+  }
+  else {
+    fExternalMapping = kTRUE;
+    for(Int_t i = 0; i < fNRCU*fNSides; i++)
+      fMapping[i] = mapping[i];
+  }
+}
+
+//_____________________________________________________________________________
+AliCaloRawStreamV3::AliCaloRawStreamV3(const AliCaloRawStreamV3& stream) :
+  AliAltroRawStreamV3(stream),
+  fModule(-1),
+  fRow(-1),
+  fColumn(-1),
+  fCaloFlag(0),
+  fFilter(0),
+  fNRCU(0),
+  fNSides(0),
+  fCalo(""),
+  fExternalMapping(kFALSE)
+{  
+  Fatal("AliCaloRawStreamV3", "copy constructor not implemented");
+}
+
+//_____________________________________________________________________________
+AliCaloRawStreamV3& AliCaloRawStreamV3::operator = (const AliCaloRawStreamV3& 
+                                             /* stream */)
+{
+  Fatal("operator =", "assignment operator not implemented");
+  return *this;
+}
+
+//_____________________________________________________________________________
+AliCaloRawStreamV3::~AliCaloRawStreamV3()
+{
+// destructor
+
+  if (!fExternalMapping)
+    for(Int_t i = 0; i < fNRCU*fNSides; i++)
+      delete fMapping[i];
+}
+
+//_____________________________________________________________________________
+void AliCaloRawStreamV3::Reset()
+{
+  // reset phos/emcal raw stream params
+  AliAltroRawStreamV3::Reset();
+  fModule = fRow = fColumn = -1;
+  fFilter = fCaloFlag = 0;
+  fCalo="";
+}
+
+//_____________________________________________________________________________
+Bool_t AliCaloRawStreamV3::NextChannel()
+{
+  // Read next PHOS/EMCAL signal
+  // Apply the PHOS/EMCAL altro mapping to get
+  // the module,row and column indeces
+
+  if (AliAltroRawStreamV3::NextChannel()) {
+    ApplyAltroMapping();
+    if ( fFilter > 0 ) { // some data should be filtered out
+      if ( (fFilter & (1<<fCaloFlag)) != 0) {  
+       // this particular data should be filtered out
+       NextChannel(); // go to the next address instead
+      }
+    }
+    return kTRUE;
+  }
+  else
+    return kFALSE;
+}
+
+//_____________________________________________________________________________
+void AliCaloRawStreamV3::ApplyAltroMapping()
+{
+  // Take the DDL index, load
+  // the corresponding altro mapping
+  // object and fill the sector,row and pad indeces
+
+  Int_t ddlNumber = GetDDLNumber();
+  fModule = ddlNumber / fNRCU;
+
+  Int_t rcuIndex = ddlNumber % fNRCU;
+
+  if(fCalo=="EMCAL"){ // EMCAL may need to increase RCU index for the maps
+    if (fModule%2 == 1) { rcuIndex += 2; } // other='C' side maps
+  }
+
+  Short_t hwAddress = GetHWAddress();
+  fRow      = fMapping[rcuIndex]->GetPadRow(hwAddress);
+  fColumn   = fMapping[rcuIndex]->GetPad(hwAddress);
+  fCaloFlag = fMapping[rcuIndex]->GetSector(hwAddress);
+}
diff --git a/RAW/AliCaloRawStreamV3.h b/RAW/AliCaloRawStreamV3.h
new file mode 100644 (file)
index 0000000..ba4fd18
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef ALICALORAWSTREAMV3_H
+#define ALICALORAWSTREAMV3_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: $ */
+
+///////////////////////////////////////////////////////////////////////////////
+///
+/// This class provides access to Calo digits in raw data.
+///
+/// Yuri Kharlov. 23 June 2009
+/// 
+///////////////////////////////////////////////////////////////////////////////
+
+// --- ROOT system ---
+#include "TString.h"
+
+// --- AliRoot header files ---
+#include "AliAltroRawStreamV3.h"
+class AliRawReader;
+class AliAltroMapping;
+
+class AliCaloRawStreamV3: public AliAltroRawStreamV3 {
+
+public :
+  AliCaloRawStreamV3(AliRawReader* rawReader, TString calo, AliAltroMapping **mapping = NULL);
+  virtual ~AliCaloRawStreamV3();
+  
+  virtual void             Reset();
+  virtual Bool_t           NextChannel();
+  
+  Int_t   GetModule()      const {return fModule;}
+  Int_t   GetRow()         const {return fRow   ;} // EMCAL notation
+  Int_t   GetColumn()      const {return fColumn;} // EMCAL notation
+  Int_t   GetCellX()       const {return fRow   ;} // PHOS notation
+  Int_t   GetCellZ()       const {return fColumn;} // PHOS notation
+  Int_t   GetNRCU()        const {return fNRCU  ;}
+  Int_t   GetNSides()      const {return fNSides;}
+  TString GetCalorimeter() const {return fCalo  ;}
+
+  enum EAliCaloFlag { kLowGain=0, kHighGain=1, kTRUData=2, kLEDMonData=3 };
+  Bool_t  IsLowGain()      const {return (fCaloFlag == kLowGain)   ;}
+  Bool_t  IsHighGain()     const {return (fCaloFlag == kHighGain)  ;}
+  Bool_t  IsTRUData()      const {return (fCaloFlag == kTRUData)   ;}
+  Bool_t  IsLEDMonData()   const {return (fCaloFlag == kLEDMonData);} 
+
+  Int_t   GetCaloFlag() const { return fCaloFlag; } 
+  Int_t   GetFilter() const { return fFilter; } 
+
+  void SkipData(EAliCaloFlag caloFlag=kLEDMonData) 
+    { fFilter |= (1<<caloFlag); }
+
+protected:
+
+  AliCaloRawStreamV3& operator = (const AliCaloRawStreamV3& stream);
+  AliCaloRawStreamV3(const AliCaloRawStreamV3& stream);
+
+  virtual void ApplyAltroMapping();
+
+  Int_t            fModule;   // index of current module
+  Int_t            fRow;      // index of current row
+  Int_t            fColumn;   // index of current column
+  Int_t            fCaloFlag; // low (0) or (1) high gain; see enum EAliCaloFlag above
+  Int_t            fFilter;   // default 0 = let everything through
+  Int_t            fNRCU;     // number of RCU per (super)module
+  Int_t            fNSides;   // Division of EMCal in "A" "C" sides
+  TString          fCalo;     // Calorimeter name
+  Bool_t           fExternalMapping;   // use external mapping or create a default one
+  AliAltroMapping *fMapping[4];   // pointers to ALTRO mapping
+
+  ClassDef(AliCaloRawStreamV3, 1)   // class for reading PHOS/EMCAL raw digits
+
+};
+
+#endif
index f0e0611..17339ce 100644 (file)
@@ -7,7 +7,7 @@ set(SRCS
        AliRawReaderMemory.cxx 
        AliRawHLTManager.cxx 
        AliAltroRawStream.cxx 
-       AliCaloRawStream.cxx 
+       AliCaloRawStream.cxx AliCaloRawStreamV3.cxx 
        AliVMERawStream.cxx 
        AliAltroDecoder.cxx AliAltroData.cxx AliAltroBunch.cxx AliAltroRawStreamFast.cxx
         AliRawReaderChain.cxx
index c6ee6ca..448db5a 100644 (file)
@@ -14,6 +14,7 @@
 #pragma link C++ class AliRawReaderMemory+;
 #pragma link C++ class AliAltroRawStream+;
 #pragma link C++ class AliCaloRawStream+;
+#pragma link C++ class AliCaloRawStreamV3+;
 #pragma link C++ class AliVMERawStream+;
 #pragma link C++ class AliAltroDecoder+;
 #pragma link C++ class AliAltroData+;
index dc1c58b..d3efc72 100644 (file)
@@ -8,6 +8,7 @@ SRCS:=  AliFilter.cxx \
        AliRawHLTManager.cxx \
        AliAltroRawStream.cxx \
        AliCaloRawStream.cxx \
+       AliCaloRawStreamV3.cxx \
        AliVMERawStream.cxx \
        AliAltroDecoder.cxx AliAltroData.cxx AliAltroBunch.cxx AliAltroRawStreamFast.cxx \
        AliAltroRawStreamV3.cxx
diff --git a/RAW/readCaloV3.C b/RAW/readCaloV3.C
new file mode 100644 (file)
index 0000000..a423465
--- /dev/null
@@ -0,0 +1,97 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+  #include <TStopwatch.h>
+  #include <TStyle.h>
+  #include <TH1F.h>
+  #include <TH2F.h>
+  #include <TString.h>
+  #include <TCanvas.h>
+  #include "AliRawReader.h"
+  #include "AliCaloRawStreamV3.h"
+  #include "AliLog.h"
+#endif
+
+
+void readCaloV3(const char *fileName = "./", const TString calo="PHOS")
+{
+  TH1D *hAmplHG  = new TH1D("hAmplHG" ,"HG amplitude" ,1024,-0.5,1023.5);
+  TH1D *hAmplLG  = new TH1D("hAmplLG" ,"LG amplitude" ,1024,-0.5,1023.5);
+  TH1D *hAmplTRU = new TH1D("hAmplTRU","TRU amplitude",1024,-0.5,1023.5);
+  TH1F *hModule  = new TH1F("hModule" ,"Module number",10,-0.5,9.5);
+  TH2F *hXZHG    = new TH2F("hXZHG"   ,"XZ HG cells",64,-0.5,63.5,64,-0.5,63.5);
+  TH2F *hXZLG    = new TH2F("hXZLG"   ,"XZ LG cells",64,-0.5,63.5,64,-0.5,63.5);
+  TH2F *hHWaddr  = new TH2F("hHWaddr","DDL is vs HW addr",216,-0.5,215.5,4096,-0.5,4095.5);
+
+  //  AliLog::SetGlobalLogLevel(AliLog::kFatal);
+  //  AliLog::SetPrintRepetitions(kFALSE);
+
+  AliRawReader *reader = AliRawReader::Create(fileName);
+  reader->Reset();
+
+  TStopwatch timer;
+  timer.Start();
+
+  AliCaloRawStreamV3 *stream = new AliCaloRawStreamV3(reader,calo);
+
+  Int_t iev = 0;
+
+  while (reader->NextEvent()) {
+    AliInfoGeneral("",Form("Reading event %d\n",iev++));
+    while (stream->NextDDL()) {
+      while (stream->NextChannel()) {
+//     AliInfoGeneral("",Form("New channel: HW=%d, module=%d, row=%d, col=%d, caloflag=%d",
+//                         stream->GetHWAddress(),
+//                         stream->GetModule(),
+//                         stream->GetRow(),
+//                         stream->GetColumn(),
+//                         stream->GetCaloFlag()));
+       hHWaddr->Fill(stream->GetDDLNumber(),stream->GetHWAddress());
+       hModule->Fill(stream->GetModule());
+       if (stream->IsHighGain())
+         hXZHG->Fill(stream->GetRow(),stream->GetColumn());
+       if (stream->IsLowGain())
+         hXZLG->Fill(stream->GetRow(),stream->GetColumn());
+
+       while (stream->NextBunch()) {
+         const UShort_t *sig = stream->GetSignals();
+         Int_t startBin = stream->GetStartTimeBin();
+         for (Int_t i = 0; i < stream->GetBunchLength(); i++) {
+           if (stream->IsHighGain())
+             hAmplHG->Fill(sig[i]);
+           if (stream->IsLowGain())
+             hAmplLG->Fill(sig[i]);
+           if (stream->IsTRUData())
+             hAmplTRU->Fill(sig[i]);
+         }
+       }
+      }
+    }
+    stream->Reset();
+  }
+
+  timer.Stop();
+  timer.Print();
+
+  gStyle->SetPalette(1);
+  TCanvas *c1 = new TCanvas("c1","",0,0,900,600);
+  c1->Divide(3,1);
+  c1->cd(1);
+  hAmplHG->Draw();
+  c1->cd(2);
+  hAmplLG->Draw();
+  c1->cd(3);
+  hAmplTRU->Draw();
+
+  TCanvas *c2 = new TCanvas("c2","",0,0,900,600);
+  c2->Divide(2,1);
+  c2->cd(1);
+  hModule->Draw();
+  c2->cd(2);
+  hHWaddr->Draw("colz");
+
+  TCanvas *c3 = new TCanvas("c3","",0,0,900,600);
+  c3->Divide(2,1);
+  c3->cd(1);
+  hXZHG->Draw("colz");
+  c3->cd(2);
+  hXZLG->Draw("colz");
+}