]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Raw data implementation for AD
authormbroz <Michal.Broz@cern.ch>
Wed, 27 Aug 2014 12:06:11 +0000 (14:06 +0200)
committermbroz <Michal.Broz@cern.ch>
Wed, 27 Aug 2014 12:06:11 +0000 (14:06 +0200)
AD/ADrecLinkDef.h
AD/ADsimLinkDef.h
AD/AliAD.cxx
AD/AliADBuffer.cxx [new file with mode: 0644]
AD/AliADBuffer.h [new file with mode: 0644]
AD/AliADCalibData.cxx
AD/AliADConst.h
AD/AliADRawStream.cxx [new file with mode: 0644]
AD/AliADRawStream.h [new file with mode: 0644]
AD/CMakelibADrec.pkg
AD/CMakelibADsim.pkg

index da6d6d0f8910eaf46ce99891460cd187ab4656ef..85934f0decd31421cdb15ad07019e24307e29d64 100644 (file)
@@ -9,5 +9,6 @@
 #pragma link C++ class  AliADReconstructor+;
 #pragma link C++ class  AliADTrigger+;
 #pragma link C++ class  AliADRecoParam+;
+#pragma link C++ class  AliADRawStream+;
 
 #endif
index 384bded6b5722a71d2ffeb542dd543e8a10b6b9c..43b07f80f0e1db42276c4b5b306a8d511eaa443f 100644 (file)
@@ -11,5 +11,6 @@
 #pragma link C++ class  AliADhit+;
 #pragma link C++ class  AliADDigitizer+;
 #pragma link C++ class  AliADQADataMakerSim+;
+#pragma link C++ class  AliADBuffer+;
 
 #endif
index a29a69a2a5f9450fcce9369ea44e2f057b972fae..bdfcf9501fa27ecadb2ef0bc58d29eeada0c60df 100644 (file)
 #include "AliADhit.h"
 #include "AliADLoader.h"
 #include "AliADDigitizer.h"
+#include "AliADBuffer.h"
+#include "AliADConst.h"
 #include "AliDigitizationInput.h"
 #include "AliADdigit.h"
 #include "AliADSDigit.h"
+#include "AliADCalibData.h"
 #include "AliDAQ.h"
 #include "AliRawReader.h"
 #include "AliCDBManager.h"
@@ -285,15 +288,98 @@ void AliAD::Hits2SDigits(){
 
 
 //_____________________________________________________________________________
-
 void AliAD::Digits2Raw()
 {
-       // produces raw data from digits
-       // for AD not implemented yet (needs detailed hardware info)
+   //
+   //  Converts digits of the current event to raw data
+   //
+   AliAD *fAD = (AliAD*)gAlice->GetDetector("AD");
+   fLoader->LoadDigits();
+   TTree* digits = fLoader->TreeD();
+   if (!digits) {
+      Error("Digits2Raw", "no digits tree");
+      return;
+   }
+   TClonesArray * ADdigits = new TClonesArray("AliADdigit",1000);
+   fAD->SetTreeAddress();              
+   digits->GetBranch("ADDigit")->SetAddress(&ADdigits); 
+  
+   //const char *fileName    = AliDAQ::DdlFileName("AD",0);
+   //AliADBuffer* buffer  = new AliADBuffer(fileName);
+   AliADBuffer* buffer  = new AliADBuffer("AD.Buffer");
+   
+   // Get Trigger information first
+   // Read trigger inputs from trigger-detector object
+   AliDataLoader * dataLoader = fLoader->GetDigitsDataLoader();
+   if( !dataLoader->IsFileOpen() ) 
+        dataLoader->OpenFile( "READ" );
+   AliTriggerDetector* trgdet = (AliTriggerDetector*)dataLoader->GetDirectory()->Get( "Trigger" );
+   UInt_t triggerInfo = 0;
+   if(trgdet) {
+      triggerInfo = trgdet->GetMask() & 0xffff;
+   }
+   else {
+      AliError(Form("There is no trigger object for %s",fLoader->GetName()));
+   }
+
+   buffer->WriteTriggerInfo((UInt_t)triggerInfo); 
+   buffer->WriteTriggerScalers(); 
+   buffer->WriteBunchNumbers(); 
+  
+   // Now retrieve the channel information: charge smaples + time and 
+   // dump it into ADC and Time arrays
+   Int_t nEntries = Int_t(digits->GetEntries());
+   Short_t aADC[16][kNClocks];
+   Float_t aTime[16];
+   Float_t aWidth[16];
+   Bool_t  aIntegrator[16];
+  
+   for (Int_t i = 0; i < nEntries; i++) {
+     fAD->ResetDigits();
+     digits->GetEvent(i);
+     Int_t ndig = ADdigits->GetEntriesFast(); 
+   
+     if(ndig == 0) continue;
+     for(Int_t k=0; k<ndig; k++){
+         AliADdigit* fADDigit = (AliADdigit*) ADdigits->At(k);
+
+        Int_t iChannel       = fADDigit->PMNumber();
+        
+        for(Int_t iClock = 0; iClock < kNClocks; ++iClock) aADC[iChannel][iClock] = fADDigit->ChargeADC(iClock);
+        aTime[iChannel]      = fADDigit->Time(); //divide by resolution
+        aWidth[iChannel]     = fADDigit->Width(); //divide by resolution
+        aIntegrator[iChannel]= fADDigit->Integrator();
+        
+         //AliDebug(1,Form("DDL: %s\tdigit number: %d\tPM number: %d\tADC: %d\tTime: %f",
+                        //fileName,k,fADDigit->PMNumber(),aADC[iChannel][AliADdigit::kNClocks/2],aTime[iChannel])); 
+     }        
+   }
+
+   // Now fill raw data          
+   for (Int_t  iCIU = 0; iCIU < kNCIUBoards; iCIU++) { 
+   // decoding of one Channel Interface Unit numbered iCIU - there are 8 channels per CIU (and 2 CIUs) : 
+      for(Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) { 
+         for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
+             buffer->WriteChannel(iChannel, aADC[iChannel], aIntegrator[iChannel]);       
+         }
+         buffer->WriteBeamFlags(); 
+         buffer->WriteMBInfo(); 
+         buffer->WriteMBFlags();   
+         buffer->WriteBeamScalers(); 
+      } 
+
+      for(Int_t iChannel = iCIU*8 + 7; iChannel >= iCIU*8; iChannel--) {
+          buffer->WriteTiming(aTime[iChannel], aWidth[iChannel]); 
+      } // End of decoding of one CIU card    
+  } // end of decoding the eight CIUs
+
+     
+  delete buffer;
+  fLoader->UnloadDigits();  
+
 }
 
 //_____________________________________________________________________________
-
 Bool_t AliAD::Raw2SDigits(AliRawReader* /*rawReader*/)
 {
        // reads raw data to produce digits
diff --git a/AD/AliADBuffer.cxx b/AD/AliADBuffer.cxx
new file mode 100644 (file)
index 0000000..11e6623
--- /dev/null
@@ -0,0 +1,225 @@
+/**************************************************************************
+ * Copyright(c) 1998-2003, 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$ */
+
+// Storing digits in a binary file
+// according to the DDL mapping
+// Author: B. Cheynis
+
+#include <Riostream.h>
+#include <TObjArray.h>
+#include <TMath.h>
+
+#include "AliLog.h"
+#include "AliRawDataHeaderSim.h"
+#include "AliADBuffer.h"
+#include "AliADdigit.h"
+#include "AliADConst.h"
+
+ClassImp(AliADBuffer)
+
+//_____________________________________________________________________________
+AliADBuffer::AliADBuffer():TObject(),
+    fRemainingWord(0),
+    f()
+{
+  //
+  // default constructor
+  //
+}
+//_____________________________________________________________________________
+AliADBuffer::AliADBuffer(const char* fileName):TObject(),
+    fRemainingWord(0),
+    f()
+{
+  // Constructor
+  f = new AliFstream(fileName);
+  AliRawDataHeaderSim header;
+  f->WriteBuffer((char*)(&header), sizeof(header));
+
+}
+
+//_____________________________________________________________________________
+AliADBuffer::~AliADBuffer(){
+  // Destructor, it closes the IO stream
+  AliRawDataHeaderSim header;
+  header.fSize = f->Tellp();
+  header.SetAttribute(0);  // valid data
+  f->Seekp(0);
+  f->WriteBuffer((char*)(&header), sizeof(header));
+  delete f;
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteTriggerInfo(UInt_t trigger) {
+  // The method writes AD trigger information
+  // This info is contained in the first two
+  // raw-data words following the raw-data header (CDH).
+
+  f->WriteBuffer((char*)(&trigger),sizeof(trigger));
+
+  // By default all the inputs are unmasked... Hopefully
+  UInt_t triggerMask = 0xffff;
+  f->WriteBuffer((char*)(&triggerMask),sizeof(triggerMask));
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteTriggerScalers() {
+  // The method writes the AD trigger scalers
+  // For the moment there is no way to simulate
+  // this, so we fill the necessary 16 words with 0
+
+  // First the general trigger scalers (16 of them)
+  for(Int_t i = 0; i < 16; i++) {
+      UInt_t data = 0;
+      f->WriteBuffer((char*)&data,sizeof(data));
+  }
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteBunchNumbers() {
+  // The method writes the Bunch Numbers corresponding 
+  // to the 10 Minimum Bias events
+  // For the moment there is no way to simulate
+  // this, so we fill the necessary 10 words with 0
+
+  // First the bunch crossing numbers
+  // for these 10 events
+  
+  for(Int_t i = 0; i < 10; i++) {
+      UInt_t data = 0;
+      f->WriteBuffer((char*)&data,sizeof(data));
+  }
+
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteChannel(Int_t channel, Short_t *adc, Bool_t integrator){
+  // It writes AD charge information into a raw data file. 
+  // Being called by Digits2Raw
+  
+  UShort_t data = 0;
+  for(Int_t i = 0; i < kNClocks; ++i) {
+    if (adc[i] > 1023) {
+      AliWarning(Form("ADC (channel=%d) saturated: %d. Truncating to 1023",channel,adc[i]));
+      adc[i] = 1023;
+    }
+  }
+   
+    for(Int_t i = 0; i < (kNClocks); ++i) {
+      data =   (adc[i] & 0x3ff);
+      data |= ((integrator & 0x1) << 10);      
+      f->WriteBuffer((char*)&data,sizeof(data));
+    }
+    
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteBeamFlags() {
+
+//void AliADBuffer::WriteBeamFlags(Bool_t *bbFlag, Bool_t *bgFlag) {
+  // The method writes information about
+  // the Beam-Beam and Beam-Gas flags i.e. 
+  // 10  shorts for the 4 channels 
+  // of half a CIU card
+
+  // Beam-beam and beam-gas flags are available
+  // only for the triggered event-of-interest (sample index = 10)
+  // As soon as trigger simulation would become more complex
+  // and would allow to simulate neighbouring samples, this code
+  // should be extended in order to fill all (or fraction) of the
+  // flags
+  /*/
+  UShort_t data = 0;
+  
+  for(Int_t iEvOfInt = 0; iEvOfInt < kNClocks; iEvOfInt=iEvOfInt+2) {
+        for(Int_t iChannel = 0; iChannel < 4; iChannel++) {
+         data = 0;
+         if (bbFlag[iChannel]) data |= ((bbFlag[iChannel] & 0x1) << 2*iChannel);
+         if (bgFlag[iChannel]) data |= ((bgFlag[iChannel] & 0x1) << 2*iChannel+1);
+         
+         if(iEvOfInt < (kNClocks - 1)) {      
+            if (bbFlag[iChannel]) data |= ((bbFlag[iChannel] & 0x1) << 8 + 2*iChannel);
+            if (bgFlag[iChannel]) data |= ((bgFlag[iChannel] & 0x1) << 8 + 2*iChannel+1);
+         }
+         f->WriteBuffer((char*)&data,sizeof(data));
+        }
+      }
+   data = 0;
+   f->WriteBuffer((char*)&data,sizeof(data));//Empty short in the end
+   /*/
+  for(Int_t i = 0; i < 12; i++) {
+       UShort_t data = 0;
+       f->WriteBuffer((char*)&data,sizeof(data));
+       }
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteMBInfo() {
+  // The method writes information about
+  // the 10 previous minimum-bias events
+  // i.e. channels charge for each of these
+  // 10 events (4*10 shorts for the 4 channels 
+  // of half a CIU card)
+    
+  for(Int_t i = 0; i < 40; i++) {
+    UShort_t data = 0;
+    f->WriteBuffer((char*)&data,sizeof(data));
+  }
+}
+
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteMBFlags() {
+  // The method writes information about
+  // the Minimum Bias flags
+  // 5 16-bits words for the 4 channels 
+  // of half a CIU card + one empty 16-bit
+
+
+  for(Int_t i = 0; i < 6; i++) {
+    UShort_t data = 0;
+    f->WriteBuffer((char*)&data,sizeof(data));
+  }
+}
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteBeamScalers() {
+  // The method writes the AD beam scalers
+  // For the moment there is no way to simulate
+  // this, so we fill the necessary words with 0
+
+  // Beam-beam and beam-gas scalers for
+  // 4 individual channel (4x4 words)
+  // (64-bit + 64-bit)*4 = 32bit * 16
+  
+  for(Int_t i = 0; i < 16; i++) {
+    UInt_t data = 0;
+    f->WriteBuffer((char*)&data,sizeof(data));
+  }
+}
+
+
+
+//_____________________________________________________________________________
+void AliADBuffer::WriteTiming(Float_t time, Float_t width) {
+  // It writes the timing information into a raw data file. 
+  // Being called by Digits2Raw
+
+  // Writes the timing information
+  UInt_t data = TMath::Nint(time) & 0xfff;
+  data |= (TMath::Nint(width) & 0x7f) << 12;
+  f->WriteBuffer((char*)&data,sizeof(data));
+}
diff --git a/AD/AliADBuffer.h b/AD/AliADBuffer.h
new file mode 100644 (file)
index 0000000..06f4920
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef AliADBUFFER_H
+#define AliADBUFFER_H
+/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/////////////////////////////////////////////////////////////////////
+// Class used for storing AD digits according to the DDLs format//
+/////////////////////////////////////////////////////////////////////
+
+#ifdef __CINT__
+class fstream;
+#else
+#include "Riostream.h"
+#endif
+
+#include "AliFstream.h"
+
+class AliADBuffer:public TObject{
+
+public:
+  AliADBuffer();
+  AliADBuffer(const char* fileName); //constructor
+  virtual ~AliADBuffer(); //destructor
+  
+  void    WriteTriggerInfo(UInt_t trigger);
+  void    WriteTriggerScalers();
+  void    WriteBunchNumbers();  
+
+  void    WriteChannel(Int_t channel, Short_t *adc, Bool_t integrator);
+  void    WriteBeamFlags();
+  
+  void    WriteMBInfo();
+  void    WriteMBFlags();
+    
+  void    WriteBeamScalers();
+
+  void    WriteTiming(Float_t time, Float_t width);
+
+private:
+  AliADBuffer(const AliADBuffer &source); // copy constructor
+  AliADBuffer& operator=(const AliADBuffer &source); // ass. op.
+
+  UInt_t      fRemainingWord; // Remaining data word between even and odd channel's data
+  AliFstream* f;      //The IO file name
+  ClassDef(AliADBuffer,2)
+};
+
+#endif
index 78c80794dab5fd34ee859c81ef8af973e39a6dc6..d2815af3993a0a51068553e764f54ebe7b34c3ea 100644 (file)
@@ -193,8 +193,8 @@ Int_t AliADCalibData::GetBoardNumber(Int_t channel)
 {
   // Get FEE board number
   // from offline channel index
-  if (channel >= 0 && channel < 16) return (channel);
-  //if (channel >=8 && channel < 16) return (channel / 2);
+  if (channel >= 0 && channel < 8) return (0);
+  if (channel >=8 && channel < 16) return (1);
 
   AliErrorClass(Form("Wrong channel index: %d",channel));
   return -1;
@@ -207,7 +207,7 @@ Float_t AliADCalibData::GetLightYields(Int_t channel)
   // for a given channel
   if (!fLightYields) InitLightYields();
 
-  if (channel >= 0 && channel < 64) {
+  if (channel >= 0 && channel < 16) {
     return fLightYields[channel];
   }
 
index 922e44841d9476931a3a55374511b636a95427d1..dcef219edd7005c250db603542c417349a7aab14 100644 (file)
@@ -14,7 +14,7 @@ const Float_t kPMRespTime = 6.0; // PM response time (corresponds to 1.9 ns rise
 const Float_t kPMTransparency = 0.25; // Transparency of the first dynode of the PM
 const Float_t kPMNbOfSecElec = 6.0;   // Number of secondary electrons emitted from first dynode (per ph.e.)
 const Float_t kPhotoCathodeEfficiency = 0.18; // Photocathode efficiency
-const Int_t   kNCIUBoards = 16; //Number of CIU boards
+const Int_t   kNCIUBoards = 2; //Number of CIU boards
 
 #endif
 
diff --git a/AD/AliADRawStream.cxx b/AD/AliADRawStream.cxx
new file mode 100644 (file)
index 0000000..16de35e
--- /dev/null
@@ -0,0 +1,229 @@
+/**************************************************************************
+ * 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 is a class for reading the AD DDL raw data
+/// The format of the raw data corresponds to the one
+/// implemented in AliADBuffer class. 
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliADRawStream.h"
+#include "AliRawReader.h"
+#include "AliLog.h"
+#include "AliDAQ.h"
+#include "AliADCalibData.h"
+ClassImp(AliADRawStream)
+
+//_____________________________________________________________________________
+AliADRawStream::AliADRawStream(AliRawReader* rawReader) :
+  fTrigger(0),
+  fTriggerMask(0),
+  fPosition(-1),
+  fRawReader(rawReader),
+  fData(NULL)
+{
+  // create an object to read AD raw data
+  //
+  // select the raw data corresponding to
+  // the AD detector id
+  fRawReader->Reset();
+  AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("AD")));
+  fRawReader->Select("AD");
+
+  // Initalize the containers
+  for(Int_t i = 0; i < kNChannels; i++) {
+    fTime[i] = fWidth[i] = 0;
+    for(Int_t j = 0; j < kNEvOfInt; j++) {
+      fADC[i][j] = 0;
+      fIsInt[i][j] = fIsBB[i][j] = fIsBG[i][j] = kFALSE;
+    }
+    fBBScalers[i] = fBGScalers[i] = 0;
+    for(Int_t j = 0; j < kNBunches; j++) {
+      fChargeMB[i][j] = 0;
+      fIsIntMB[i][j] = fIsBBMB[i][j] = fIsBGMB[i][j] = kFALSE;
+    }
+  }
+  for(Int_t i = 0; i < kNScalers; i++) fScalers[i] = 0;
+  for(Int_t i = 0; i < kNBunches; i++) fBunchNumbers[i] = 0;
+}
+
+//_____________________________________________________________________________
+AliADRawStream::~AliADRawStream()
+{
+  // destructor
+}
+
+//_____________________________________________________________________________
+void AliADRawStream::Reset()
+{
+  // reset raw stream params
+
+  // Reinitalize the containers
+  for(Int_t i = 0; i < kNChannels; i++) {
+    fTime[i] = fWidth[i] = 0;
+    for(Int_t j = 0; j < kNEvOfInt; j++) {
+      fADC[i][j] = 0;
+      fIsInt[i][j] = fIsBB[i][j] = fIsBG[i][j] = kFALSE;
+    }
+    fBBScalers[i] = fBGScalers[i] = 0;
+    for(Int_t j = 0; j < kNBunches; j++) {
+      fChargeMB[i][j] = 0;
+      fIsIntMB[i][j] = fIsBBMB[i][j] = fIsBGMB[i][j] = kFALSE;
+    }
+  }
+  for(Int_t i = 0; i < kNScalers; i++) fScalers[i] = 0;
+  for(Int_t i = 0; i < kNBunches; i++) fBunchNumbers[i] = 0;
+
+  fTrigger = fTriggerMask = 0;
+  fPosition = -1;
+  fData = NULL;
+
+  if (fRawReader) fRawReader->Reset();
+}
+
+//_____________________________________________________________________________
+Bool_t AliADRawStream::Next()
+{
+  // read next digit from the AD raw data stream
+  // return kFALSE in case of error or no digits left
+
+  if (fPosition >= 0) return kFALSE;
+
+  if (!fRawReader->ReadNextData(fData)) return kFALSE;
+  if (fRawReader->GetDataSize() == 0) return kFALSE;
+     
+  if (fRawReader->GetDataSize() != 1568) {
+     fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 1568",fRawReader->GetDataSize()));
+     AliWarning(Form("Wrong AD raw data size: %d, expected 1568 bytes!",fRawReader->GetDataSize()));
+     return kFALSE;
+  }
+
+  fPosition = 0;
+
+  fTrigger = GetNextWord() & 0xffff;
+  fTriggerMask = GetNextWord() & 0xffff;
+
+  for(Int_t iScaler = 0; iScaler < kNScalers; iScaler++)
+     fScalers[iScaler] = GetNextWord();
+
+  for(Int_t iBunch = 0; iBunch < kNBunches; iBunch++)
+     fBunchNumbers[iBunch] = GetNextWord();
+  for (Int_t  iCIU = 0; iCIU < kNCIUBoards; iCIU++) { 
+  // decoding of one Channel Interface Unit numbered iCIU - there are 8 channels per CIU (and 2 CIUs) :
+  
+    for (Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) { 
+      for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
+        for(Int_t iEvOfInt = 0; iEvOfInt < kNEvOfInt; iEvOfInt++) {
+          UShort_t data = GetNextShort();
+          fADC[iChannel][iEvOfInt] = data & 0x3ff;
+          fIsInt[iChannel][iEvOfInt] = (data >> 10) & 0x1;
+        }
+      }
+      for(Int_t iEvOfInt = 0; iEvOfInt < kNEvOfInt; iEvOfInt=iEvOfInt+2) {
+        UShort_t data = GetNextShort();
+        for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {          
+          fIsBB[iChannel][iEvOfInt] = (data >>  2*(iChannel-iChannel_Offset)) & 0x1;
+          fIsBG[iChannel][iEvOfInt] = (data >> (2*(iChannel-iChannel_Offset)+1)) & 0x1; 
+         if(iEvOfInt < (kNEvOfInt - 1)) {      
+             fIsBB[iChannel][iEvOfInt+1] = (data >> (8+ 2*(iChannel-iChannel_Offset))) & 0x1;
+             fIsBG[iChannel][iEvOfInt+1] = (data >> (8+ 2*(iChannel-iChannel_Offset)+1)) & 0x1;
+         }
+        }
+      }
+
+      GetNextShort();
+
+      for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
+        for(Int_t iBunch = 0; iBunch < kNBunches; iBunch++) {
+          UShort_t data = GetNextShort();
+          fChargeMB[iChannel][iBunch] = data & 0x3ff;
+          fIsIntMB[iChannel][iBunch] = (data >> 10) & 0x1;
+        } 
+      }
+   
+      for(Int_t iBunch = 0; iBunch < kNBunches; iBunch=iBunch+2) {
+        UShort_t data = GetNextShort();
+        for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {  
+          fIsBBMB[iChannel][iBunch] = (data >>  2*iBunch) & 0x1;
+          fIsBGMB[iChannel][iBunch] = (data >> (2*iBunch+1)) & 0x1;
+         if(iBunch < (kNBunches - 1)) {
+             fIsBBMB[iChannel][iBunch+1] = (data >> (8+2*iBunch)) & 0x1;
+             fIsBGMB[iChannel][iBunch+1] = (data >> (8+2*iBunch+1)) & 0x1;
+         }       
+        }
+      }
+  
+      GetNextShort();
+   
+      for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
+        fBBScalers[iChannel] = ((ULong64_t)GetNextWord()) << 32;
+        fBBScalers[iChannel] |= GetNextWord();
+        fBGScalers[iChannel] = ((ULong64_t)GetNextWord()) << 32;
+        fBGScalers[iChannel] |= GetNextWord();
+      }
+
+    } 
+
+    for(Int_t iChannel = (iCIU*8) + 7; iChannel >= iCIU*8; iChannel--) { 
+      UInt_t time = GetNextWord();
+      fTime[iChannel]  = time & 0xfff;
+      fWidth[iChannel] = ((time >> 12) & 0x7f); // HPTDC used in pairing mode
+    }
+    
+    // End of decoding of one CIU card
+    // printf("Number of bytes used at end of reading CIU card number %d %d \n\n", iCIU+1, fPosition); 
+    
+  } // end of decoding the eight CIUs
+    
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+UInt_t AliADRawStream::GetNextWord()
+{
+  // This method returns the next 32 bit word
+  // inside the raw data payload.
+  // The method is supposed to be endian (platform)
+  // independent.
+  if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
+
+  UInt_t word = 0;
+  word |= fData[fPosition++];
+  word |= fData[fPosition++] << 8;
+  word |= fData[fPosition++] << 16;
+  word |= fData[fPosition++] << 24;
+
+  return word;
+}
+
+//_____________________________________________________________________________
+UShort_t AliADRawStream::GetNextShort()
+{
+  // This method returns the next 16 bit word
+  // inside the raw data payload.
+  // The method is supposed to be endian (platform)
+  // independent.
+  if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
+
+  UShort_t word = 0;
+  word |= fData[fPosition++];
+  word |= fData[fPosition++] << 8;
+
+  return word;
+}
diff --git a/AD/AliADRawStream.h b/AD/AliADRawStream.h
new file mode 100644 (file)
index 0000000..9a1ecd2
--- /dev/null
@@ -0,0 +1,133 @@
+#ifndef ALIADRAWSTREAM_H
+#define ALIADRAWSTREAM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+///////////////////////////////////////////////////////////////////////////////
+///
+/// This is a class for reading the AD DDL raw data
+/// The format of the raw data corresponds to the one
+/// implemented in AliADBuffer class.
+///
+/// PLEASE NOTE that Int_t channel is here the FEE channel from 0 to 16 in the 
+/// not yet defined order which may be not the same order as the order 
+/// defined in aliroot by the naming and numbering conventions.
+/// Therefore one has to go from FEE_Channel to AliRoot_Channel using 
+/// GetOfflineChannel(Int_t channel)  when going from Online to Offline !!!
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TMath.h>
+
+class AliRawReader;
+
+class AliADRawStream: public TObject {
+  public :
+    AliADRawStream(AliRawReader* rawReader);
+    virtual ~AliADRawStream();
+
+    virtual void      Reset();
+    virtual Bool_t    Next();
+
+// Getters of various scalers and Minimum Bias flags :
+
+   ULong64_t          GetBBScalers(Int_t channel) const  
+      { return        fBBScalers[channel]; }
+   ULong64_t          GetBGScalers(Int_t channel) const  
+      { return        fBGScalers[channel]; }
+   UInt_t             GetTriggerScalers(Int_t num_scaler) const 
+      { return        fScalers[num_scaler]; }
+   UInt_t             GetBunchNumbersMB(Int_t num_bunch) const 
+      { return        fBunchNumbers[num_bunch]; }
+   UShort_t           GetChargeMB(Int_t channel, Int_t num_bunch) const  
+      { return        fChargeMB[channel][num_bunch]; } 
+   Bool_t             GetIntMBFlag(Int_t channel, Int_t num_bunch) const   
+      { return        fIsIntMB[channel][num_bunch]; } 
+   Bool_t             GetBBMBFlag(Int_t channel, Int_t num_bunch) const   
+      { return        fIsBBMB[channel][num_bunch]; }  
+   Bool_t             GetBGMBFlag(Int_t channel, Int_t num_bunch) const   
+      { return        fIsBGMB[channel][num_bunch]; }      
+       
+// Getters of ADC signals, ADC pedestals, time information and corresponding flags :
+
+    Short_t           GetADC(Int_t channel) const
+      { return TMath::MaxElement(kNEvOfInt, fADC[channel]); }    // maximum value instead of central clock
+//    { return fADC[channel][kNEvOfInt/2]; }
+            
+    Short_t           GetPedestal(Int_t channel, Int_t event) const
+      { return fADC[channel][event]; }
+    Bool_t            GetIntegratorFlag(Int_t channel, Int_t event) const
+      { return fIsInt[channel][event]; }
+    Bool_t            GetBBFlag(Int_t channel, Int_t event) const
+      { return fIsBB[channel][event]; } 
+    Bool_t            GetBGFlag(Int_t channel, Int_t event) const
+      { return fIsBG[channel][event]; }   
+    Short_t           GetTime(Int_t channel) const
+      { return fTime[channel]; }
+    Short_t           GetWidth(Int_t channel) const
+      { return fWidth[channel]; }
+
+    UShort_t          GetTriggerInputs() const
+      { return fTrigger; }
+    UShort_t          GetTriggerInputsMask() const
+      { return fTriggerMask; }
+
+// Getter of Offline Channel number as used in aliroot (defined by aliroot 
+// numbering convention) from FEE channel (electronic channel number given 
+// by the V0 electronics readout) - See comment above - 
+
+    Int_t              GetOfflineChannel(Int_t channel)  const
+      { Int_t  fOfflineChannel[16] = {0,1,2,3,4,5,6,7,
+                                     8,9,10,11,12,13,14,15};
+               return fOfflineChannel[channel]; }      
+
+    enum EADRawDataParams {
+      kNChannels = 16, // number of electronic channels in AD (FEE numbering)
+      kNEvOfInt  = 21, // number of events of interest
+      kNScalers  = 16, // number of scalers
+      kNBunches  = 10  // number of bunches used in Minimum Bias information 
+    };
+
+    enum EADRawStreamError {
+      kRawDataSizeErr = 1
+    };
+
+  private:
+
+    AliADRawStream(const AliADRawStream& stream);
+    AliADRawStream& operator = (const AliADRawStream& stream);
+
+    UInt_t GetNextWord();
+    UShort_t GetNextShort();
+
+    ULong64_t     fBBScalers[kNChannels];        // 'Beam-Beam' scalers for all channels
+    ULong64_t     fBGScalers[kNChannels];        // 'Beam-Gas' scalers for all channels
+    UInt_t        fScalers[kNScalers];           // Trigger scalers
+    UInt_t        fBunchNumbers[kNBunches];      // Bunch numbers for the previous 10 MB events
+    UShort_t      fChargeMB[kNChannels][kNBunches]; // ADC counts for all channels for the previous 10 MB events
+    Bool_t        fIsIntMB[kNChannels][kNBunches];  // 'Integrator' flag for all channels for the previous 10 MB events
+    Bool_t        fIsBBMB[kNChannels][kNBunches];   // 'Beam-Beam' flag for all channels for the previous 10 MB events
+    Bool_t        fIsBGMB[kNChannels][kNBunches];   // 'Beam-Gas' for all channels for the previous 10 MB events
+
+    Short_t       fADC[kNChannels][kNEvOfInt];   // ADC counts for all channels and all events of interest
+    Bool_t        fIsInt[kNChannels][kNEvOfInt]; // 'Integrator' flag for all channels 
+    Bool_t        fIsBB[kNChannels][kNEvOfInt];  // 'Beam-Beam' flag for all channels
+    Bool_t        fIsBG[kNChannels][kNEvOfInt];  // 'Beam-Gas' flag for all channels
+    Short_t       fTime[kNChannels];             // leading time for all channels - from HPTDC - in HPTDC units
+    Short_t       fWidth[kNChannels];            // pulse width for all channels - from HPTDC - in HPTDC units
+
+    UShort_t      fTrigger;        // AD trigger inputs
+    UShort_t      fTriggerMask;    // AD trigger inputs mask
+
+    Int_t         fPosition;       // current position in the raw-data payload
+    
+
+    AliRawReader* fRawReader;      // object for reading the raw data
+
+    UChar_t*      fData;           // pointer to raw data payload
+
+    ClassDef(AliADRawStream, 0) // class for reading AD DDL raw data
+};
+
+#endif
index 5cf98a2e17e69a08e1b669b6e8095fc61f3f00e9..cbaab3fd4bbd62ff51a6bca213698b0694a2309e 100644 (file)
@@ -30,7 +30,7 @@ set ( SRCS
     AliADReconstructor.cxx 
     AliADTrigger.cxx 
     AliADRecoParam.cxx
-#    AliADRawStream.cxx 
+    AliADRawStream.cxx 
 #    AliADQADataMakerRec.cxx 
 #    AliADTriggerMask.cxx 
 #    AliADRecoParam.cxx 
index b0a0e8e636d2af969d8152e7678d9102e50cba54..fb5ad02b745b6fd360fd0ac2e3b1277973ed57bc 100644 (file)
@@ -31,7 +31,7 @@ set ( SRCS
     AliADv1.cxx 
     AliADhit.cxx 
     AliADDigitizer.cxx 
-#    AliADBuffer.cxx 
+    AliADBuffer.cxx 
     AliADQADataMakerSim.cxx
     )