From d6d75a3f7104bff3387f8a1f7e2c3737ff34450c Mon Sep 17 00:00:00 2001 From: dsilverm Date: Fri, 10 Oct 2008 08:21:25 +0000 Subject: [PATCH] CCUSB reader from Rachid Guernane for SuperModule calibration - added to EMCAL base lib (also preliminary STU = trigger unit reader) --- EMCAL/EMCALbaseLinkDef.h | 2 + EMCAL/SMcalib/AliEMCALCCUSBRawStream.cxx | 116 +++++++++++++++++++++++ EMCAL/SMcalib/AliEMCALCCUSBRawStream.h | 60 ++++++++++++ EMCAL/SMcalib/dumpCCUSB.C | 59 ++++++++++++ EMCAL/libEMCALbase.pkg | 5 +- 5 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 EMCAL/SMcalib/AliEMCALCCUSBRawStream.cxx create mode 100644 EMCAL/SMcalib/AliEMCALCCUSBRawStream.h create mode 100644 EMCAL/SMcalib/dumpCCUSB.C diff --git a/EMCAL/EMCALbaseLinkDef.h b/EMCAL/EMCALbaseLinkDef.h index 8a63376ef25..99c559e63a1 100644 --- a/EMCAL/EMCALbaseLinkDef.h +++ b/EMCAL/EMCALbaseLinkDef.h @@ -27,5 +27,7 @@ #pragma link C++ class AliEMCALRecParam+; #pragma link C++ class AliEMCALQAChecker+; #pragma link C++ class AliEMCALSpaceFrame+; +#pragma link C++ class AliEMCALSTURawStream+; +#pragma link C++ class AliEMCALCCUSBRawStream+; #endif diff --git a/EMCAL/SMcalib/AliEMCALCCUSBRawStream.cxx b/EMCAL/SMcalib/AliEMCALCCUSBRawStream.cxx new file mode 100644 index 00000000000..1ebe5750e3b --- /dev/null +++ b/EMCAL/SMcalib/AliEMCALCCUSBRawStream.cxx @@ -0,0 +1,116 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +/////////////////////////////////////////////////////////////////////////////// +/// +/// This class provides access to CC-USB data in test bench raw data. +/// Author: guernane@lpsc.in2p3.fr +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "AliEMCALCCUSBRawStream.h" +#include "AliRawReader.h" + +ClassImp(AliEMCALCCUSBRawStream) + +AliEMCALCCUSBRawStream::AliEMCALCCUSBRawStream(AliRawReader* rawReader) : + fRawReader(rawReader), + fData(0), + fHeader(0), + fOptHeader(0), + fEventLength(0), + fEOBuffer(0) +{ + fRawReader = rawReader; + + fRawReader->Reset(); + fRawReader->SelectEquipment(1, 1, 1); +} + +Bool_t AliEMCALCCUSBRawStream::Next() +{ +// read the next raw digit +// returns kFALSE if there is no digit left + + if ( fEOBuffer == 0xFFFFFFFF ) { fEOBuffer = 0; return kFALSE; } + + if (!fRawReader->ReadNextInt((UInt_t&) fHeader)) { + Error("Next", "No header"); + return kFALSE; + } + + if (!fRawReader->ReadNextInt((UInt_t&) fOptHeader)) { + Error("Next", "No optional header"); + return kFALSE; + } + + if (!fRawReader->ReadNextInt((UInt_t&) fEventLength)) { + Error("Next", "No event length"); + return kFALSE; + } + + for (Int_t i = 0; i < fgkNScalerCCUSB; i++) + { + if (!fRawReader->ReadNext((UChar_t*)&fData,8)) + { + Error("Next", "Internal CC-USB scaler issing"); + return kFALSE; + } + + fScalerCCUSB[i] = fData; + } + + for (Int_t i = 0; i < fgkNScalerLecroy; i++) + { + if (!fRawReader->ReadNext((UChar_t*)&fData,8)) + { + Error("Next", "Lecroy scaler missing"); + return kFALSE; + } + + fScalerLecroy[i] = fData; + } + + for (Int_t i = 0; i < fgkNTDC; i++) + { + if (!fRawReader->ReadNextInt(fData)) + { + Error("Next", "Incomplete TDC equipment"); + return kFALSE; + } + + fTDC[i] = fData; + } + + for (Int_t i = 0; i < fgkNQDC; i++) + { + if (!fRawReader->ReadNextInt(fData)) + { + Error("Next", "Incomplete QDC equipment"); + return kFALSE; + } + + fQDC[i] = fData; + } + + if ( !fRawReader->ReadNextInt((UInt_t&) fEOBuffer) ) + { + Error("Next", "No end of buffer"); + return kFALSE; + } + + return kTRUE; +} + diff --git a/EMCAL/SMcalib/AliEMCALCCUSBRawStream.h b/EMCAL/SMcalib/AliEMCALCCUSBRawStream.h new file mode 100644 index 00000000000..c66cf66edbc --- /dev/null +++ b/EMCAL/SMcalib/AliEMCALCCUSBRawStream.h @@ -0,0 +1,60 @@ +#ifndef ALIEMCALCCUSBRAWSTREAM_H +#define ALIEMCALCCUSBRAWSTREAM_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/////////////////////////////////////////////////////////////////////////////// +/// +/// This class provides access to CC-USB data in EMCAL test bench raw data. +/// Author: guernane@lpsc.in2p3.fr +/// +/////////////////////////////////////////////////////////////////////////////// + +#include + +class AliRawReader; + +class AliEMCALCCUSBRawStream: public TObject { + public : + AliEMCALCCUSBRawStream(AliRawReader* rawReader); + virtual ~AliEMCALCCUSBRawStream() {}; + + virtual Bool_t Next(); + + UInt_t GetTDC(Int_t iTDC) const + {return fTDC[iTDC];} + + UInt_t GetQDC(Int_t iQDC) const + {return fQDC[iQDC];} + UInt_t GetScalerCCUSB(Int_t iScaler) const + {return fScalerCCUSB[iScaler];} + UInt_t GetScalerLecroy(Int_t iScaler) const + {return fScalerLecroy[iScaler];} + + private : + AliEMCALCCUSBRawStream(const AliEMCALCCUSBRawStream& stream); + AliEMCALCCUSBRawStream& operator = (const AliEMCALCCUSBRawStream& stream); + + AliRawReader* fRawReader; // object for reading the raw data + UInt_t fData; // data read for file + UInt_t fHeader; // bit 15=1 indicates a watchdog buffer + // bit 14=1 indicates a scaler buffer + // bits 0-9 represent the number of events in the buffer + UInt_t fOptHeader; // bits 0-11 represent the number of words in the buffer + UInt_t fEventLength; // event length including terminator words + UInt_t fEOBuffer; // event terminator + + static const Int_t fgkNScalerCCUSB = 2; // number of internal CC-USB scalers + static const Int_t fgkNScalerLecroy = 12; // number of Lecroy scalers + static const Int_t fgkNTDC = 40; // number of TDC + static const Int_t fgkNQDC = 32; // number of QDC + + UInt_t fTDC[fgkNTDC]; // TDC channels + UInt_t fQDC[fgkNQDC]; // QDC values + UInt_t fScalerCCUSB[fgkNScalerCCUSB]; // Internal scaler values + UInt_t fScalerLecroy[fgkNScalerLecroy]; // Lecroy scaler values + + ClassDef(AliEMCALCCUSBRawStream, 0) // class for reading CC-USB raw digits +}; + +#endif diff --git a/EMCAL/SMcalib/dumpCCUSB.C b/EMCAL/SMcalib/dumpCCUSB.C new file mode 100644 index 00000000000..6141fdf26ad --- /dev/null +++ b/EMCAL/SMcalib/dumpCCUSB.C @@ -0,0 +1,59 @@ +// aliroot macro to dump CC-USB raw data +// + +void dumpCCUSB(const int runno = 117, const int evtnum = -1 ) +{ + TH1F *hTDC[40], *hQDC[32], *hScalerCCUSB[2], *hScalerLecroy[12]; + + for (Int_t i=0;i<40;i++) hTDC[i] = new TH1F(Form("hTDC%d",i),Form("hTDC%d",i),4096,0.,4096.); + for (Int_t i=0;i<32;i++) hQDC[i] = new TH1F(Form("hQDC%d",i),Form("hQDC%d",i),4096,0.,4096.); + for (Int_t i=0;i<2;i++) hScalerCCUSB[i] = new TH1F(Form("hScalerCCUSB%d",i),Form("hScalerCCUSB%d",i),4096,0.,4096.); + for (Int_t i=0;i<12;i++) hScalerLecroy[i] = new TH1F(Form("hScalerLecroy%d",i),Form("hScalerLecroy%d",i),4096,0.,4096.); + + Char_t fname[256]; + sprintf(fname, "/local/data/Run_%09d.Seq_1A.Stream_0.root",runno); + + cout << "Reading file: " << fname << endl; + AliRawReader *rawReader = new AliRawReaderRoot(fname); + rawReader->SelectEvents( 7 ); // physics events + + int firstevent = evtnum; + int lastevent = evtnum; + + if (evtnum < 0) { // get a bunch of events + firstevent = 0; + lastevent = - evtnum; + } + + if (evtnum == 0) { // get all events + firstevent = 0; + lastevent = 1000000; + } + + Int_t iev = 1; + + while ( rawReader->NextEvent() && iev <= lastevent ) + { + AliEMCALCCUSBRawStream *inCCUSB = new AliEMCALCCUSBRawStream(rawReader); + + while ( inCCUSB->Next() ) + { + for (Int_t i=0;i<2;i++) hScalerCCUSB[i]->Fill(inCCUSB->GetScalerCCUSB(i)); + for (Int_t i=0;i<12;i++) hScalerLecroy[i]->Fill(inCCUSB->GetScalerLecroy(i)); + for (Int_t i=0;i<40;i++) hTDC[i]->Fill(inCCUSB->GetTDC(i)); + for (Int_t i=0;i<32;i++) hQDC[i]->Fill(inCCUSB->GetQDC(i)); + } + + iev ++; + } + + TCanvas *c1 = new TCanvas("c1","",600,600); + c1->Divide(4,4); + for (Int_t i=0;i<8;i++) {c1->cd(i+1); hTDC[i]->Draw();} + c1->cd(9); hScalerCCUSB[0]->Draw(); +} + + + + + diff --git a/EMCAL/libEMCALbase.pkg b/EMCAL/libEMCALbase.pkg index 700be6ff486..1db0b8a4d37 100644 --- a/EMCAL/libEMCALbase.pkg +++ b/EMCAL/libEMCALbase.pkg @@ -23,7 +23,10 @@ AliCaloCalibSignal.cxx \ AliEMCALSurvey.cxx \ AliEMCALRecParam.cxx \ AliEMCALQAChecker.cxx \ -AliEMCALSpaceFrame.cxx +AliEMCALSpaceFrame.cxx \ +AliEMCALSTURawStream.cxx \ +SMcalib/AliEMCALCCUSBRawStream.cxx + HDRS= $(SRCS:.cxx=.h) -- 2.43.0