#include <TObject.h>
#include <TString.h>
#include <Riostream.h>
#include "AliCTPRawData.h"
#include "AliRunLoader.h"
#include "AliCentralTrigger.h"
#include "AliLog.h"
#include "AliDAQ.h"
#include "AliFstream.h"
ClassImp(AliCTPRawData)
AliCTPRawData::AliCTPRawData()
{
}
AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
TObject(source)
{
}
AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
{
if(this==&source) return *this;
((TObject *)this)->operator=(source);
return *this;
}
void AliCTPRawData::RawData()
{
ULong64_t l2class = 0;
UChar_t l2cluster = 0;
UInt_t l0input = 0;
UInt_t l1input = 0;
UShort_t l2input=0;
AliInfo("Storing the CTP DDL raw data...");
AliRunLoader *runloader = AliRunLoader::Instance();
if (runloader) {
if (!runloader->LoadTrigger()) {
AliCentralTrigger *aCTP = runloader->GetTrigger();
if (AliDebugLevel() > 0)
aCTP->Dump();
l2class = aCTP->GetClassMask();
l2cluster = aCTP->GetClusterMask();
l0input = aCTP->GetL0TriggerInputs();
l1input = aCTP->GetL1TriggerInputs();
l2input = aCTP->GetL2TriggerInputs();
}
else
AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
}
else
AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
TString fileName = AliDAQ::DdlFileName("TRG",0);
AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
AliFstream* outfile;
outfile = new AliFstream(fileName.Data());
UInt_t bunchCross = 0;
UInt_t orbitId = 0;
Bool_t esr = 0;
UInt_t word = 0;
word |= 0 << 15;
word |= bunchCross & 0xFFF;
AliDebug(1,Form("CTP word1 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (orbitId >> 12) & 0xFFF;
AliDebug(1,Form("CTP word2 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= orbitId & 0xFFF;
AliDebug(1,Form("CTP word3 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= ((UInt_t)esr) << 10;
word |= 0 << 8;
word |= (l2cluster & 0x3F) << 2;
word |= (UInt_t)((l2class >> 48) & 0x3);
AliDebug(1,Form("CTP word4 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2class >> 36) & 0xFFF);
AliDebug(1,Form("CTP word5 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2class >> 24) & 0xFFF);
AliDebug(1,Form("CTP word6 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2class >> 12) & 0xFFF);
AliDebug(1,Form("CTP word7 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)(l2class & 0xFFF);
AliDebug(1,Form("CTP word8 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l0input >> 12) & 0xFFF);
AliDebug(1,Form("CTP word9 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l0input >> 0) & 0xFFF);
AliDebug(1,Form("CTP word10 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l1input >> 12) & 0xFFF);
AliDebug(1,Form("CTP word11 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l1input >> 0) & 0xFFF);
AliDebug(1,Form("CTP word12 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2input >> 0) & 0xFFF);
AliDebug(1,Form("CTP word13 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
delete outfile;
return;
}
void AliCTPRawData::RawDataRun2()
{
ULong64_t l2class = 0;
ULong64_t l2classNext50 = 0;
UChar_t l2cluster = 0;
UInt_t l0input = 0;
UInt_t l1input = 0;
UShort_t l2input=0;
AliInfo("Storing the CTP DDL raw data...");
AliRunLoader *runloader = AliRunLoader::Instance();
if (runloader) {
if (!runloader->LoadTrigger()) {
AliCentralTrigger *aCTP = runloader->GetTrigger();
if (AliDebugLevel() > 0)
aCTP->Dump();
l2class = aCTP->GetClassMask();
l2classNext50 = aCTP->GetClassMaskNext50();
l2cluster = aCTP->GetClusterMask();
l0input = aCTP->GetL0TriggerInputs();
l1input = aCTP->GetL1TriggerInputs();
l2input = aCTP->GetL2TriggerInputs();
}
else
AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
}
else
AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
TString fileName = AliDAQ::DdlFileName("TRG",0);
AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
AliFstream* outfile;
outfile = new AliFstream(fileName.Data());
UInt_t bunchCross = 0;
UInt_t orbitId = 0;
Bool_t esr = 0;
UInt_t word = 0;
word |= 0 << 15;
word |= bunchCross & 0xFFF;
AliDebug(1,Form("CTP word1 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (orbitId >> 12) & 0xFFF;
AliDebug(1,Form("CTP word2 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= orbitId & 0xFFF;
AliDebug(1,Form("CTP word3 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= 1<<12;
word |= ((UInt_t)esr) << 10;
word |= 0 << 8;
word |= l2cluster;
AliDebug(1,Form("CTP word4 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2classNext50 >>46) & 0xF);
AliDebug(1,Form("CTP word5 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2classNext50 >> 34) & 0xFFF);
AliDebug(1,Form("CTP word6 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2classNext50 >> 22) & 0xFFF);
AliDebug(1,Form("CTP word7 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2classNext50 >> 10) & 0xFFF);
AliDebug(1,Form("CTP word8 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2classNext50 & 0x3FF)<<2);
word |= (UInt_t)((l2class >> 48) & 0x3);
AliDebug(1,Form("CTP word9 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2class >> 36) & 0xFFF);
AliDebug(1,Form("CTP word10 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2class >> 24) & 0xFFF);
AliDebug(1,Form("CTP word11 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2class >> 12) & 0xFFF);
AliDebug(1,Form("CTP word12 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)(l2class & 0xFFF);
AliDebug(1,Form("CTP word13 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l0input >> 12) & 0xFFF);
AliDebug(1,Form("CTP word14 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l0input >> 0) & 0xFFF);
AliDebug(1,Form("CTP word15 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l1input >> 12) & 0xFFF);
AliDebug(1,Form("CTP word16 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l1input >> 0) & 0xFFF);
AliDebug(1,Form("CTP word17 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
word = 0;
word |= 0 << 15;
word |= (UInt_t)((l2input >> 0) & 0xFFF);
AliDebug(1,Form("CTP word18 = 0x%x",word));
outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
delete outfile;
return;
}