From 69be760c5a67613abb0369d0f017679ee504a41d Mon Sep 17 00:00:00 2001 From: cussonno Date: Fri, 23 Jul 2004 13:00:35 +0000 Subject: [PATCH] Realistic raw data format for tracker (Christian) --- MUON/AliMUONDDLTracker.cxx | 18 +- MUON/AliMUONDDLTracker.h | 70 +++-- MUON/AliMUONDDLTrigger.cxx | 35 +++ MUON/AliMUONDDLTrigger.h | 44 ++++ MUON/AliMUONRawData.cxx | 439 +++++++++++++++++++++++++------- MUON/AliMUONRawData.h | 39 ++- MUON/AliMUONSubEventTracker.cxx | 105 ++++++++ MUON/AliMUONSubEventTracker.h | 58 +++++ MUON/AliMUONSubEventTrigger.cxx | 31 +++ MUON/AliMUONSubEventTrigger.h | 59 +++++ MUON/MUONLinkDef.h | 5 +- MUON/README | 3 +- MUON/libMUON.pkg | 8 +- 13 files changed, 785 insertions(+), 129 deletions(-) create mode 100644 MUON/AliMUONDDLTrigger.cxx create mode 100644 MUON/AliMUONDDLTrigger.h create mode 100644 MUON/AliMUONSubEventTracker.cxx create mode 100644 MUON/AliMUONSubEventTracker.h create mode 100644 MUON/AliMUONSubEventTrigger.cxx create mode 100644 MUON/AliMUONSubEventTrigger.h diff --git a/MUON/AliMUONDDLTracker.cxx b/MUON/AliMUONDDLTracker.cxx index d3c9dd46c42..bbb70fd38a0 100644 --- a/MUON/AliMUONDDLTracker.cxx +++ b/MUON/AliMUONDDLTracker.cxx @@ -14,16 +14,24 @@ **************************************************************************/ #include "AliMUONDDLTracker.h" +#include "AliRawDataHeader.h" ClassImp(AliMUONDDLTracker) - + const Int_t AliMUONDDLTracker::fEndOfDDL = 0x0FFFFFFFF; + //___________________________________________ AliMUONDDLTracker::AliMUONDDLTracker() : TObject(), - fLength(0), - fBusPatchId(0), - fData(), - fEndOfDDL(0x0FFFFFFFF) + fTotalBlkLength(0), + fBlkLength(0), + fDSPId(0), + fPadding(0x0DEADDEAD), + fTotalDspLength(0), + fDspLength(0), + fDSPId1(0), + fEventWord(0) { //ctor + for (Int_t i = 0; i < 4; i++) + fBlkTriggerWord[i] = fDspTriggerWord[i] = 0; } diff --git a/MUON/AliMUONDDLTracker.h b/MUON/AliMUONDDLTracker.h index 311b9856136..42dbec36f29 100644 --- a/MUON/AliMUONDDLTracker.h +++ b/MUON/AliMUONDDLTracker.h @@ -5,7 +5,8 @@ #include -static const Int_t bufsize = 1024; +#include "AliRawDataHeader.h" + class AliMUONDDLTracker : public TObject { @@ -13,30 +14,61 @@ public: AliMUONDDLTracker(); virtual ~AliMUONDDLTracker(){;} - UInt_t GetRawData(Int_t n) const {return fData[n];} - Int_t GetLength() const {return fLength;} - Int_t GetBusPatchId() const {return fBusPatchId;} - Int_t GetEoD() const {return fEndOfDDL;} + // Block header + Int_t GetTotalBlkLength() const {return fTotalBlkLength;} + Int_t GetBlkLength() const {return fBlkLength;} + Int_t GetDspId() const {return fDSPId;} + Int_t GetBlkTriggerWord(Int_t n) const {return fBlkTriggerWord[n];} + const Int_t GetPadding() const {return fPadding;} + + void SetTotalBlkLength(Int_t l) {fTotalBlkLength = l;} + void SetBlkLength(Int_t l) {fBlkLength = l;} + void SetDSPId(Int_t d) {fDSPId = d;} + void SetBlkTriggerWord(Int_t w, Int_t n) {fBlkTriggerWord[n] = w;} + + // DSP header + Int_t GetTotalDspLength() const {return fTotalDspLength;} + Int_t GetDspLength() const {return fDspLength;} + Int_t GetDspId1() const {return fDSPId1;} + Int_t GetDspTriggerWord(Int_t n) const {return fDspTriggerWord[n];} + Int_t GetEventWord() const {return fEventWord;} + + void SetTotalDspLength(Int_t l) {fTotalDspLength = l;} + void SetDspLength(Int_t l) {fDspLength = l;} + void SetDSPId1(Int_t d) {fDSPId1 = d;} + void SetDspTriggerWord(Int_t w, Int_t n) {fDspTriggerWord[n] = w;} + void SetEventWord(Int_t w) {fEventWord = w;} - Char_t GetParity(Int_t n) {return (Char_t)(fData[n] >> 29) & 0x7;} - UShort_t GetManuId(Int_t n) {return (UShort_t)(fData[n] >> 18) & 0x7FF;} - Char_t GetChannelId(Int_t n) {return (Char_t)(fData[n] >> 12) & 0x3F;} - UShort_t GetCharge(Int_t n) {return (UShort_t)(fData[n] & 0xFFF);} + Int_t* GetBlkHeader() {return &fTotalBlkLength;} + Int_t* GetDspHeader() {return &fTotalDspLength;} - void SetRawData(UInt_t w) {fData[fLength++] = w;} - void SetLength(Int_t l) {fLength = l;} - void SetBusPatchId(Int_t b) {fBusPatchId = b;} - void SetEoD(Int_t e) {fEndOfDDL = e;} + AliRawDataHeader GetHeader(){return fHeader;} + Int_t GetHeaderSize() {return sizeof(AliRawDataHeader)/4;} // in words - Int_t* GetAddress() {return &fLength;} + const Int_t GetEoD() const {return fEndOfDDL;} private: - - Int_t fLength; // length of data - Int_t fBusPatchId; // bus patch id - UInt_t fData[bufsize]; // data - Int_t fEndOfDDL ; // end of DDL + // block header + Int_t fTotalBlkLength; // total length of block structure + Int_t fBlkLength; // length of raw data + Int_t fDSPId; // Dsp id + Int_t fBlkTriggerWord[4]; // counter trigger word + Int_t fPadding; // padding dummy word for 64 bits transfer + + // Dsp header + Int_t fTotalDspLength; // total length of block structure + Int_t fDspLength; // length of raw data + Int_t fDSPId1; // Dsp id ?? + Int_t fDspTriggerWord[4]; // counter trigger word ? + Int_t fEventWord; // nb word odd = 1, even = 0 + + static const Int_t fEndOfDDL; // end of DDL + + + AliRawDataHeader fHeader; // header of DDL + + ClassDef(AliMUONDDLTracker,1) // MUON DDL Tracker }; #endif diff --git a/MUON/AliMUONDDLTrigger.cxx b/MUON/AliMUONDDLTrigger.cxx new file mode 100644 index 00000000000..f756c6795c2 --- /dev/null +++ b/MUON/AliMUONDDLTrigger.cxx @@ -0,0 +1,35 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +#include "AliMUONDDLTrigger.h" + +ClassImp(AliMUONDDLTrigger) + +//___________________________________________ +AliMUONDDLTrigger::AliMUONDDLTrigger() + : TObject(), + fddlWord(), + fGlobalInput(), + fGlobalOutput(0), + fEndOfDDL(0xDEADFACE) +{ + //ctor +} + +//___________________________________________ +AliMUONDDLTrigger::~AliMUONDDLTrigger() +{ + //dtor +} diff --git a/MUON/AliMUONDDLTrigger.h b/MUON/AliMUONDDLTrigger.h new file mode 100644 index 00000000000..a757467c74f --- /dev/null +++ b/MUON/AliMUONDDLTrigger.h @@ -0,0 +1,44 @@ +#ifndef ALIMUONDDLTRIGGER_H +#define ALIMUONDDLTRIGGER_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +#include + +class AliMUONDDLTrigger : public TObject { + +public: + AliMUONDDLTrigger(); + virtual ~AliMUONDDLTrigger(); + + + UInt_t GetDDLWord() const {return fddlWord;} + Int_t GetGlobalInput(Int_t n) const {return fGlobalInput[n];} + Int_t GetGlobalOuput() const {return fGlobalOutput;} + Int_t GetEoD() const {return fEndOfDDL;} + + //DarcId:2,Version:8,SerialNb:4,EventType:4,MBZ:16; + Char_t GetDarcId() {return (Char_t)(fddlWord >> 30) & 0x10;} + Char_t GetVersion() {return (Char_t)(fddlWord >> 24) & 0xFF;} + Char_t GetSerialNb() {return (Char_t)(fddlWord >> 20) & 0xF;} + Char_t GetEventType() {return (Char_t)(fddlWord >> 16) & 0xF;} + + void SetDDLWord(UInt_t w) {fddlWord = w;} + void SetGlobalInput(Int_t in, Int_t n) {fGlobalInput[n] = in;} + void SetGlobalOutput(Int_t out) {fGlobalOutput = out;} + void SetEoD(Int_t e) {fEndOfDDL = e;} + + UInt_t* GetAddress() {return &fddlWord;} + + private: + + UInt_t fddlWord; // first word + Int_t fGlobalInput[4]; // global input + Int_t fGlobalOutput; // global ouput + Int_t fEndOfDDL; // end of DDL + + + ClassDef(AliMUONDDLTrigger,1) // MUON DDL Trigger +}; +#endif diff --git a/MUON/AliMUONRawData.cxx b/MUON/AliMUONRawData.cxx index 8476f65e3a2..8831c835f1a 100644 --- a/MUON/AliMUONRawData.cxx +++ b/MUON/AliMUONRawData.cxx @@ -20,22 +20,27 @@ // This class v-1: // * generates raw data for MUON tracker only (for the moment) // * a simple mapping is used (see below) -// * the bus patch id is calculated but not stored properly in the raw data -// this has to be changed +// * the bus patch id is calculated with an absolute number 0 - 999 // one DDL per 1/2 chamber is created for both cathode. // //////////////////////////////////// - +#include #include "AliMUONRawData.h" #include "AliMUONDigit.h" +#include "AliMUONTriggerDecision.h" #include "AliMUONConstants.h" #include "AliMUONData.h" -#include "AliMUONDDLTracker.h" #include "AliRun.h" #include "AliRunLoader.h" #include "AliLoader.h" #include "AliBitPacking.h" -#include "AliRawDataHeader.h" +#include "AliMUONDDLTracker.h" +#include "AliMUONDDLTrigger.h" + +// #include "AliMUON.h" +// #include "AliMUONLocalTrigger.h" +// #include "AliMUONGlobalTrigger.h" +// #include "AliMUONTriggerCircuit.h" const Int_t AliMUONRawData::fgkDefaultPrintLevel = 0; @@ -43,16 +48,11 @@ ClassImp(AliMUONRawData) // Class implementation in ROOT context //__________________________________________________________________________ AliMUONRawData::AliMUONRawData(AliLoader* loader) - : TObject() + : TObject(), + fDebug(0) { // Standard Constructor - fDebug = 0; - fNCh = 0; - fNTrackingCh = 0; - fNTriggerCh = 0; - fMUONData = 0; - fPrintLevel = fgkDefaultPrintLevel; // initialize loader's @@ -60,14 +60,27 @@ AliMUONRawData::AliMUONRawData(AliLoader* loader) // initialize container fMUONData = new AliMUONData(fLoader,"MUON","MUON"); + + // trigger decision, temp solution, local & global has to move to Digits Tree +// fTrigDec = new AliMUONTriggerDecision(fLoader); +// fTrigData = fTrigDec->GetMUONData(); + + // initialize array + fSubEventArray[0] = new TClonesArray("AliMUONSubEventTracker",1000); + fSubEventArray[1] = new TClonesArray("AliMUONSubEventTracker",1000); + + // initialize array + fSubEventTrigArray[0] = new TClonesArray("AliMUONSubEventTrigger",1000); + fSubEventTrigArray[1] = new TClonesArray("AliMUONSubEventTrigger",1000); + + // ddl pointer + fDDLTracker = new AliMUONDDLTracker(); + fDDLTrigger= new AliMUONDDLTrigger(); } //__________________________________________________________________________ AliMUONRawData::AliMUONRawData() : TObject(), - fNCh(0), - fNTrackingCh(0), - fNTriggerCh(0), fMUONData(0), fPrintLevel(fgkDefaultPrintLevel), fDebug(0), @@ -103,6 +116,23 @@ AliMUONRawData::~AliMUONRawData(void) { if (fMUONData) delete fMUONData; + if (fSubEventArray[0]) + fSubEventArray[0]->Delete(); //using delete cos allocating memory in copy ctor. + if (fSubEventArray[1]) + fSubEventArray[1]->Delete(); + + if (fSubEventTrigArray[0]) + fSubEventTrigArray[0]->Delete(); + if (fSubEventTrigArray[1]) + fSubEventTrigArray[1]->Delete(); + + if (fDDLTracker) + delete fDDLTracker; + if (fDDLTrigger) + delete fDDLTrigger; + +// if (fTrigDec) +// delete fTrigDec; return; } //____________________________________________________________________ @@ -110,81 +140,106 @@ Int_t AliMUONRawData::WriteRawData() { // convert digits of the current event to raw data - Int_t DDLId; Char_t name[20]; fLoader->LoadDigits("READ"); + fMUONData->SetTreeAddress("D"); - // printf("je suis dans WriteRawData\n"); for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) { + // for (Int_t ich = 0; ich < 2; ich++) { // open files DDLId = ich * 2 + 0x900; sprintf(name, "MUON_%d.ddl",DDLId); fFile1 = fopen(name,"w"); - DDLId = (ich * 2) + 1 + 0x900 ; + DDLId = (ich * 2) + 1 + 0x900; sprintf(name, "MUON_%d.ddl",DDLId); fFile2 = fopen(name,"w"); - WriteDDL(ich); + WriteTrackerDDL(ich); // reset and close fclose(fFile1); fclose(fFile2); fMUONData->ResetDigits(); } + + // trigger chambers + + + // open files +// DDLId = 0xA00; +// sprintf(name, "MUTR_%d.ddl",DDLId); +// fFile1 = fopen(name,"w"); + +// DDLId = 0xA00 + 1; +// sprintf(name, "MUTR_%d.ddl",DDLId); +// fFile2 = fopen(name,"w"); + +// WriteTriggerDDL(); +// // reset and close +// fclose(fFile1); +// fclose(fFile2); + fLoader->UnloadDigits(); + return kTRUE; } //____________________________________________________________________ -Int_t AliMUONRawData::WriteDDL(Int_t iCh) +Int_t AliMUONRawData::WriteTrackerDDL(Int_t iCh) { - + // resets TClonesArray* muonDigits = 0; + fSubEventArray[0]->Clear(); + fSubEventArray[1]->Clear(); + + // + TArrayI nbInBus[2]; + + nbInBus[0].Set(5000); + nbInBus[1].Set(5000); + + nbInBus[0].Reset(); + nbInBus[1].Reset(); + + // DDL header + AliRawDataHeader header = fDDLTracker->GetHeader(); + Int_t headerSize = fDDLTracker->GetHeaderSize(); // DDL event one per half chamber - AliMUONDDLTracker* eventDDL1; - AliMUONDDLTracker* eventDDL2; + AliMUONSubEventTracker* subEvent; // data format Char_t parity = 0x4; - UShort_t manuId; - UChar_t channelId; - UShort_t charge; - Int_t busPatchId; + UShort_t manuId = 0; + UChar_t channelId = 0; + UShort_t charge = 0; + Int_t busPatchId = 0; UInt_t word; - Int_t nWord; - Int_t dummy; - - Int_t offsetX = 0; // offet row - Int_t offsetY = 0; // offset columns - Int_t offsetCath = 0; //offset from one cathod to the other - Int_t maxChannel = 0; // maximum nb of channel in 1/2 chamber - Int_t id; + Int_t nEntries = 0; + Int_t* buffer = 0; + Int_t index; + Int_t indexDsp; + Int_t indexBlk; Int_t nDigits; - AliMUONDigit* digit; - - AliRawDataHeader header; + const AliMUONDigit* digit; - eventDDL1 = new AliMUONDDLTracker(); - eventDDL2 = new AliMUONDDLTracker(); + if (fPrintLevel > 0) + printf("WriteDDL chamber %d\n", iCh+1); for (Int_t iCath = 0; iCath < 2; iCath++) { - if (fPrintLevel) - printf("WriteDDL chamber %d and cathode %d\n", iCh+1, iCath); - fMUONData->ResetDigits(); fMUONData->GetCathode(iCath); muonDigits = fMUONData->Digits(iCh); nDigits = muonDigits->GetEntriesFast(); - if (fPrintLevel) + if (fPrintLevel == 2) printf("ndigits = %d\n",nDigits); // open DDL file, on per 1/2 chamber @@ -193,6 +248,222 @@ Int_t AliMUONRawData::WriteDDL(Int_t iCh) digit = (AliMUONDigit*) muonDigits->UncheckedAt(idig); + // mapping + GetDummyMapping(iCh, iCath, digit, busPatchId, manuId, channelId, charge); + + //packing word + AliBitPacking::PackWord((UInt_t)parity,word,29,31); + AliBitPacking::PackWord((UInt_t)manuId,word,18,28); + AliBitPacking::PackWord((UInt_t)channelId,word,12,17); + AliBitPacking::PackWord((UInt_t)charge,word,0,11); + + // set sub Event + subEvent = new AliMUONSubEventTracker(); + subEvent->AddData(word); + subEvent->SetBusPatchId(busPatchId); + if (digit->PadX() > 0) { + nbInBus[0][busPatchId]++; + AddData1(subEvent); + } else { + nbInBus[1][busPatchId]++; + AddData2(subEvent); + } + delete subEvent; + } + } + fSubEventArray[0]->Sort(); + fSubEventArray[1]->Sort(); + + // gather datas from same bus patch + for (Int_t iDDL = 0; iDDL < 2; iDDL++) { + nEntries = fSubEventArray[iDDL]->GetEntriesFast(); + + for (Int_t i = 0; i < nEntries; i++) { + AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i); + busPatchId = temp->GetBusPatchId(); + + // add bus patch header, length and total length managed by subevent class + temp->SetTriggerWord(0xdeadbeef); + for (Int_t j = 0; j < nbInBus[iDDL][busPatchId]-1; j++) { + AliMUONSubEventTracker* temp1 = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(++i); + temp->AddData(temp1->GetData(0)); + fSubEventArray[iDDL]->RemoveAt(i) ; + } + } + fSubEventArray[iDDL]->Compress(); + + if (fPrintLevel == 3) { + nEntries = fSubEventArray[iDDL]->GetEntriesFast(); + for (Int_t i = 0; i < nEntries; i++) { + AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(i); + printf("busPatchid back %d\n",temp->GetBusPatchId()); + for (Int_t j = 0; j < temp->GetLength(); j++) { + printf("manuId back %d, ",temp->GetManuId(j)); + printf("channelId back %d, ",temp->GetChannelId(j)); + printf("charge back %d\n",temp->GetCharge(j)); + } + } + printf("\n"); + } + + } + + Int_t iBusPatch; + Int_t iEntries; + + for (Int_t iDDL = 0; iDDL < 2; iDDL++) { + + + // filling buffer + nEntries = fSubEventArray[iDDL]->GetEntriesFast(); + buffer = new Int_t [(2048+24)*50]; // 24 words in average for one buspatch and 2048 manu info at most + + indexBlk = 0; + indexDsp = 0; + index = 0; + iBusPatch = 0; + iEntries = 0; + + for (Int_t iBlock = 0; iBlock < 2; iBlock++) { + + // block header + fDDLTracker->SetTotalBlkLength(0xFFFFFFFF); + memcpy(&buffer[index],fDDLTracker->GetBlkHeader(),32); + indexBlk = index; + index += 8; + + for (Int_t iDsp = 0; iDsp < 5; iDsp++) { + + // DSP header + fDDLTracker->SetTotalDspLength(0xEEEEEEEE); + memcpy(&buffer[index],fDDLTracker->GetDspHeader(),32); + indexDsp = index; + index += 8; + + for (Int_t i = 0; i < 5; i++) { + + iBusPatch = i + iBlock*25 + iDsp*5 + 50*(2*iCh + iDDL); + + AliMUONSubEventTracker* temp = (AliMUONSubEventTracker*)fSubEventArray[iDDL]->At(iEntries); + if (nEntries > 0) + busPatchId = temp->GetBusPatchId(); + else + busPatchId = -1; + + if (busPatchId == iBusPatch) { + // add bus patch structure + memcpy(&buffer[index],temp->GetAddress(),16); + index+= 4; + for (Int_t j = 0; j < temp->GetLength(); j++) + buffer[index++] = temp->GetData(j); + if (iEntries < nEntries-1) + iEntries++; + } else { + buffer[index++] = 4; // total length + buffer[index++] = 0; // raw data length + buffer[index++] = iBusPatch; // bus patch + buffer[index++] = 0xdeadbeef; // trigger word + } + } // bus patch + buffer[indexDsp] = index - indexDsp; + buffer[indexDsp+1] = index - indexDsp -8; + if ((index - indexDsp) % 2 == 0) + buffer[indexDsp+7] = 0; + else + buffer[indexDsp+7] = 1; + } // dsp + buffer[indexBlk] = index - indexBlk; + buffer[indexBlk+1] = index - indexBlk -8; + } + if (iDDL == 0) { + // write DDL 1 + header.fSize = index + headerSize;// total length in word + fwrite((char*)(&header),headerSize*4,1,fFile1); + fwrite(buffer,sizeof(int),index,fFile1); + } + if (iDDL == 1) { + // write DDL 2 + header.fSize = index + headerSize;// total length in word + fwrite((char*)(&header),headerSize*4,1,fFile2); + fwrite(buffer,sizeof(int),index,fFile2); + } + delete[] buffer; + } + + return kTRUE; +} +//____________________________________________________________________ +Int_t AliMUONRawData::WriteTriggerDDL() +{ + +// Long_t gloTrigPat; +// TClonesArray *localTrigger; +// TClonesArray *globalTrigger; +// AliMUONLocalTrigger *locTrg; +// AliMUONGlobalTrigger *gloTrg; +// AliMUONTriggerCircuit *circuit; + +// fTrigData->SetTreeAddress("D,GLT"); +// fTrigDec->Digits2Trigger(); + + +// AliMUON * pMUON = (AliMUON *) gAlice->GetDetector("MUON"); + +// // global trigger for trigger pattern +// gloTrigPat = 0; + +// globalTrigger = fMUONData->GlobalTrigger(); + +// gloTrg = (AliMUONGlobalTrigger*)globalTrigger->UncheckedAt(0); +// if (gloTrg->SinglePlusLpt()) gloTrigPat|= 0x1; +// if (gloTrg->SinglePlusHpt()) gloTrigPat|= 0x2; +// if (gloTrg->SinglePlusApt()) gloTrigPat|= 0x4; + +// if (gloTrg->SingleMinusLpt()) gloTrigPat|= 0x8; +// if (gloTrg->SingleMinusHpt()) gloTrigPat|= 0x10; +// if (gloTrg->SingleMinusApt()) gloTrigPat|= 0x20; + +// if (gloTrg->SingleUndefLpt()) gloTrigPat|= 0x40; +// if (gloTrg->SingleUndefHpt()) gloTrigPat|= 0x80; +// if (gloTrg->SingleUndefApt()) gloTrigPat|= 0x100; + +// if (gloTrg->PairUnlikeLpt()) gloTrigPat|= 0x200; +// if (gloTrg->PairUnlikeHpt()) gloTrigPat|= 0x400; +// if (gloTrg->PairUnlikeApt()) gloTrigPat|= 0x800; + +// if (gloTrg->PairLikeLpt()) gloTrigPat|= 0x1000; +// if (gloTrg->PairLikeHpt()) gloTrigPat|= 0x2000; +// if (gloTrg->PairLikeApt()) gloTrigPat|= 0x4000; + +// // local trigger +// localTrigger = fMUONData->LocalTrigger(); +// Int_t nlocals = (Int_t) (localTrigger->GetEntries());// 234 local cards + +// for (Int_t i=0; iUncheckedAt(i); +// circuit = &(pMUON->TriggerCircuit(locTrg->LoCircuit())); +// Float_t y11 = circuit->GetY11Pos(locTrg->LoStripX()); +// Int_t stripX21 = locTrg->LoStripX()+locTrg->LoDev()+1; +// Float_t y21 = circuit->GetY21Pos(stripX21); +// Float_t x11 = circuit->GetX11Pos(locTrg->LoStripY()); +// y11 = y21 = x11 = 0.; +// } + +// fTrigData->ResetTrigger(); +// fTrigData->ResetDigits(); + + return kTRUE; +} +//____________________________________________________________________ +void AliMUONRawData::GetDummyMapping(Int_t iCh, Int_t iCath, const AliMUONDigit* digit, + Int_t &busPatchId, UShort_t &manuId, UChar_t &channelId, UShort_t &charge) +{ + + Int_t offsetX = 0; // offet row + Int_t offsetY = 0; // offset columns + Int_t offsetCath = 0; //offset from one cathod to the other + Int_t maxChannel = 0; // maximum nb of channel in 1/2 chamber + Int_t id; switch (iCh+1) { case 1: case 2: @@ -218,69 +489,47 @@ Int_t AliMUONRawData::WriteDDL(Int_t iCh) // dummy mapping // manu Id directly from a matrix 8*8, same segmentation for B and NB // 50 buspatches for 1/2 chamber - - id = (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY + - offsetCath*iCath); - busPatchId = id/50; - - Int_t inBusId = (id - maxChannel/50 * busPatchId);// id channel in buspatch - Int_t manuPerBus = (maxChannel/(50*64)); // number of manus per buspatch + id = (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY + + offsetCath * iCath); + Int_t chPerBus = maxChannel/50; + busPatchId = id/chPerBus; // start at zero + if (digit->PadX() > 0) + busPatchId += 50*iCh*2; + else + busPatchId += 50*(2*iCh+1); // 64 manu cards for one buspatch - manuId = inBusId/manuPerBus; + manuId = (id % chPerBus)/64; //start at zero manuId &= 0x7FF; // 11 bits // channel id - channelId = (inBusId % manuPerBus); + channelId = (id % chPerBus) % 64; //start at zero channelId &= 0x3F; // 6 bits +// id = (TMath::Abs(digit->PadX()) * offsetX + digit->PadY() + offsetY + +// offsetCath * iCath); +// busPatchId = id/50; + +// Int_t inBusId = id - (maxChannel/50 * busPatchId);// id channel in buspatch +// Int_t manuPerBus = (maxChannel/(50*64)); // number of manus per buspatch + +// // 64 manu cards for one buspatch +// manuId = inBusId/manuPerBus; +// manuId &= 0x7FF; // 11 bits + +// // channel id +// channelId = (inBusId % manuPerBus); +// channelId &= 0x3F; // 6 bits + + if (fPrintLevel == 2) + printf("id: %d, busPatchId %d, manuId: %d, channelId: %d, maxchannel: %d, chPerBus %d\n", + id, busPatchId, manuId, channelId, maxChannel, chPerBus); // charge charge = digit->Signal(); charge &= 0xFFF; - if (fPrintLevel) + if (fPrintLevel == 2) printf("id: %d, busPatchId %d, manuId: %d, channelId: %d, padx: %d pady %d, charge %d\n", id, busPatchId, manuId, channelId, digit->PadX(), digit->PadY(), digit->Signal()); - //packing word - AliBitPacking::PackWord((UInt_t)parity,word,29,31); - AliBitPacking::PackWord((UInt_t)manuId,word,18,28); - AliBitPacking::PackWord((UInt_t)channelId,word,12,17); - AliBitPacking::PackWord((UInt_t)charge,word,0,11); - // set DDL Event - if (digit->PadX() > 0) { - eventDDL1->SetRawData(word); - eventDDL1->SetBusPatchId(busPatchId); // information not usable only last bus patch stored - } else { - eventDDL2->SetRawData(word); - eventDDL2->SetBusPatchId(busPatchId); - } - if (fPrintLevel) { - printf("word: 0x%x, ",word); - printf("manuId back %d, ",eventDDL1->GetManuId(eventDDL1->GetLength()-1)); - printf("channelId back %d, ",eventDDL1->GetChannelId(eventDDL1->GetLength()-1)); - printf("charge back %d\n",eventDDL1->GetCharge(eventDDL1->GetLength()-1)); - } - } - } - // write DDL event - nWord = eventDDL1->GetLength(); - if (nWord > 0) { // not empty event - header.fSize = nWord*4 + sizeof(AliRawDataHeader) + 12; // include EoD & length - fwrite((char*)(&header),sizeof(header),1,fFile1); - fwrite(eventDDL1->GetAddress(),sizeof(int),nWord+2,fFile1); - dummy = eventDDL1->GetEoD(); - fwrite(&dummy,sizeof(int),1,fFile1);// could be nicer ! - } - nWord = eventDDL2->GetLength(); - if (nWord > 0) { - header.fSize = nWord*4 + sizeof(AliRawDataHeader) + 12; - fwrite((char*)(&header),sizeof(header),1,fFile2); - fwrite(eventDDL2->GetAddress(),sizeof(int),nWord+2,fFile2); - dummy = eventDDL2->GetEoD(); - fwrite(&dummy,sizeof(int),1,fFile2); - } - delete eventDDL1; - delete eventDDL2; - return kTRUE; } diff --git a/MUON/AliMUONRawData.h b/MUON/AliMUONRawData.h index 3cb45a0ac6d..b4150ef6b9d 100644 --- a/MUON/AliMUONRawData.h +++ b/MUON/AliMUONRawData.h @@ -4,11 +4,17 @@ * See cxx source for full Copyright notice */ #include +#include "AliMUONSubEventTracker.h" +#include "AliMUONSubEventTrigger.h" + class TClonesArray; class AliLoader; class AliMUONData; class AliMUONDigit; class AliMUONDDLTracker; +class AliMUONDDLTrigger; + +//class AliMUONTriggerDecision; class AliMUONRawData : public TObject { @@ -24,6 +30,20 @@ class AliMUONRawData : public TObject Int_t GetPrintLevel(void) const {return fPrintLevel;} void SetPrintLevel(Int_t printLevel) {fPrintLevel = printLevel;} + void AddData1(AliMUONSubEventTracker* event) { + TClonesArray &temp = *fSubEventArray[0]; + new(temp[temp.GetEntriesFast()])AliMUONSubEventTracker(*event); + } + + void AddData2(AliMUONSubEventTracker* event) { + TClonesArray &temp = *fSubEventArray[1]; + new(temp[temp.GetEntriesFast()])AliMUONSubEventTracker(*event); + } + + void GetDummyMapping(Int_t iCh, Int_t iCath, const AliMUONDigit* digit, Int_t &busPatchId, + UShort_t &manuId, UChar_t &channelId, UShort_t &charge); + + protected: AliMUONRawData(); // Default constructor AliMUONRawData (const AliMUONRawData& rhs); // copy constructor @@ -32,11 +52,10 @@ class AliMUONRawData : public TObject private: static const Int_t fgkDefaultPrintLevel; // Default print level - Int_t fNCh; // Number of chambers - Int_t fNTrackingCh; // Number of tracking chambers* - Int_t fNTriggerCh; // Number of trigger chambers* AliMUONData* fMUONData; //! Data container for MUON subsystem +/* AliMUONTriggerDecision* fTrigDec; //! calculated trigger from digits tmp solution */ +/* AliMUONData* fTrigData; */ // print level Int_t fPrintLevel; @@ -51,7 +70,19 @@ class AliMUONRawData : public TObject FILE* fFile1; FILE* fFile2; - Int_t WriteDDL(Int_t iCh); + // array to sub event tracker + TClonesArray* fSubEventArray[2]; + + // array to sub event trigger + TClonesArray* fSubEventTrigArray[2]; + + // DDL class pointers + AliMUONDDLTracker* fDDLTracker; + AliMUONDDLTrigger* fDDLTrigger; + + // writing raw data + Int_t WriteTrackerDDL(Int_t iCh); + Int_t WriteTriggerDDL(); ClassDef(AliMUONRawData,0) // MUON cluster reconstructor in ALICE }; diff --git a/MUON/AliMUONSubEventTracker.cxx b/MUON/AliMUONSubEventTracker.cxx new file mode 100644 index 00000000000..333b883c92a --- /dev/null +++ b/MUON/AliMUONSubEventTracker.cxx @@ -0,0 +1,105 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +#include "AliMUONSubEventTracker.h" + +ClassImp(AliMUONSubEventTracker) + +//___________________________________________ +AliMUONSubEventTracker::AliMUONSubEventTracker() + : TObject(), + fTotalLength(0), + fLength(0), + fBusPatchId(0), + fTriggerWord(0), + fBufSize(1024) +{ + //ctor + fData = new UInt_t[fBufSize]; +} +//___________________________________________ +AliMUONSubEventTracker::~AliMUONSubEventTracker() +{ + if(fData) + delete[] fData; +} + +//___________________________________________ +void AliMUONSubEventTracker::SetAlloc(Int_t size) +{ + if (size < fBufSize) + return; + else + ResizeData(size); +} +//___________________________________________ +void AliMUONSubEventTracker::AddData(UInt_t data) +{ + // could have used class from ROOT + // but the structure must be as simple as possible + // to be written on disc blockwise + if (fLength == fBufSize) + ResizeData(); + fData[fLength++] = data; + fTotalLength = fLength + 4; +} + +//___________________________________________ +void AliMUONSubEventTracker::ResizeData(Int_t size) +{ + if (size == 0) + fBufSize *= 2; + else + fBufSize = size; + UInt_t* newData = new UInt_t[fBufSize]; + for (Int_t i = 0; i < fLength; i++) + newData[i] = fData[i]; + delete[] fData; + fData = newData; +} +//___________________________________________ +AliMUONSubEventTracker:: +AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event) +{ + fTotalLength = event.fTotalLength; + fLength = event.fLength; + fBusPatchId = event.fBusPatchId; + fTriggerWord = event.fTriggerWord; + + fData = new UInt_t[event.fBufSize]; + for (int i = 0; i < event.fBufSize; i++) + fData[i] = event.fData[i]; +} +//___________________________________________ +AliMUONSubEventTracker& +AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event) +{ + if (this == &event) return *this; + fTotalLength = event.fTotalLength; + fLength = event.fLength; + fBusPatchId = event.fBusPatchId; + fTriggerWord = event.fTriggerWord; + + for (int i = 0; i < event.fLength; i++) + fData[i] = event.fData[i]; + + return *this; +} +//___________________________________________ +Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const +{ + AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj; + return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1; +} diff --git a/MUON/AliMUONSubEventTracker.h b/MUON/AliMUONSubEventTracker.h new file mode 100644 index 00000000000..54b063896ca --- /dev/null +++ b/MUON/AliMUONSubEventTracker.h @@ -0,0 +1,58 @@ +#ifndef ALIMUONSUBEVENTTRACKER_H +#define ALIMUONSUBEVENTTRACKER_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +#include + + const Int_t bufSize = 1024; + +class AliMUONSubEventTracker : public TObject { + +public: + AliMUONSubEventTracker (); + virtual ~AliMUONSubEventTracker (); + AliMUONSubEventTracker(const AliMUONSubEventTracker& rhs); + AliMUONSubEventTracker& operator=(const AliMUONSubEventTracker& rhs); + + Int_t GetTotalLength() const {return fTotalLength;} + Int_t GetLength() const {return fLength;} + Int_t GetBusPatchId() const {return fBusPatchId;} + Int_t GetTriggerWord() const {return fTriggerWord;} + UInt_t GetData(Int_t n) const {return fData[n];} + UInt_t* GetData() const {return fData;} + + Char_t GetParity(Int_t n) {return (Char_t)(fData[n] >> 29) & 0x7;} + UShort_t GetManuId(Int_t n) {return (UShort_t)(fData[n] >> 18) & 0x7FF;} + Char_t GetChannelId(Int_t n) {return (Char_t)(fData[n] >> 12) & 0x3F;} + UShort_t GetCharge(Int_t n) {return (UShort_t)(fData[n] & 0xFFF);} + + void SetTotalLength(Int_t l) {fTotalLength = l;} + void SetLength(Int_t l) {fLength = l;} + void SetBusPatchId(Int_t b) {fBusPatchId = b;} + void SetTriggerWord(Int_t w) {fTriggerWord = w;} + void SetData(UInt_t d, Int_t n) {fData[n] = d; fLength++;} + + void AddData(UInt_t d); + void SetAlloc(Int_t size); + + Bool_t IsSortable() const {return kTRUE;} + Int_t Compare(const TObject *obj) const; + + Int_t* GetAddress() {return &fTotalLength;} + + private: + Int_t fTotalLength; // total length of buspatch structure + Int_t fLength; // length of raw data + Int_t fBusPatchId; // bus patch id + Int_t fTriggerWord ; // counter trigger word + UInt_t* fData; // data + + Int_t fBufSize; // initial size for data array + + void ResizeData(Int_t size = 0); + + ClassDef(AliMUONSubEventTracker,1) // MUON DDL Tracker +}; +#endif diff --git a/MUON/AliMUONSubEventTrigger.cxx b/MUON/AliMUONSubEventTrigger.cxx new file mode 100644 index 00000000000..808490b556b --- /dev/null +++ b/MUON/AliMUONSubEventTrigger.cxx @@ -0,0 +1,31 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +#include "AliMUONSubEventTrigger.h" + +ClassImp(AliMUONSubEventTrigger) + +//___________________________________________ +AliMUONSubEventTrigger::AliMUONSubEventTrigger() + : TObject(), + fRegWord(0), + fRegOutput(0) +{ + for (Int_t i = 0; i < 16*5; i++) + fLocalData[i] = 0; + + fRegInput[0] = fRegInput[1] = 0; + +} diff --git a/MUON/AliMUONSubEventTrigger.h b/MUON/AliMUONSubEventTrigger.h new file mode 100644 index 00000000000..0e00dd9ec8f --- /dev/null +++ b/MUON/AliMUONSubEventTrigger.h @@ -0,0 +1,59 @@ +#ifndef ALIMUONSUBEVENTTRIGGER_H +#define ALIMUONSUBEVENTTRIGGER_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +#include + +class AliMUONSubEventTrigger : public TObject{ + +public: + AliMUONSubEventTrigger(); + virtual ~AliMUONSubEventTrigger(){;} + + + UInt_t GetRegWord() const {return fRegWord;} + Int_t GetRegInput(Int_t n) const {return fRegInput[n];} + Int_t GetRegOutput() const {return fRegOutput;} + Int_t GetLocalData(Int_t n) const {return fLocalData[n];} + + //serialNB:5,DarcId:5,Version:8,MBZ:14 + Char_t GetSerialNb() {return (Char_t)(fRegWord >> 27) & 0x1F;} + Char_t GetRegId() {return (Char_t)(fRegWord >> 22) & 0x1F;} + Char_t GetVersion() {return (Char_t)(fRegWord >> 14) & 0xFF;} + + UShort_t GetX2(Int_t n) {return (fLocalData[16*n] >> 16) & 0xFFFF;} + UShort_t GetX1(Int_t n) {return (fLocalData[16*n]) & 0xFFFF;} + UShort_t GetX4(Int_t n) {return (fLocalData[16*n + 1] >> 16) & 0xFFFF;} + UShort_t GetX3(Int_t n) {return (fLocalData[16*n + 1]) & 0xFFFF;} + + UShort_t GetY2(Int_t n) {return (fLocalData[16*n + 2] >> 16) & 0xFFFF;} + UShort_t GetY1(Int_t n) {return (fLocalData[16*n + 2]) & 0xFFFF;} + UShort_t GetY4(Int_t n) {return (fLocalData[16*n + 3] >> 16) & 0xFFFF;} + UShort_t GetY3(Int_t n) {return (fLocalData[16*n + 3]) & 0xFFFF;} + + Char_t GetLocalId(Int_t n) {return fLocalData[16*n + 4] >> 19 & 0xF;} + Char_t GetLocalDec(Int_t n) {return fLocalData[16*n + 4] >> 15 & 0xF;} + Char_t GetTriggerY(Int_t n) {return fLocalData[16*n + 4] >> 14 & 0x1;} + Char_t GetYPos(Int_t n) {return fLocalData[16*n + 4] >> 10 & 0xF;} + Char_t GetXDev(Int_t n) {return fLocalData[16*n + 4] >> 5 & 0x1F;} + Char_t GetXPos(Int_t n) {return fLocalData[16*n + 4] & 0x1F;} + + void SetRegWord(UInt_t w) {fRegWord = w;} + void SetRegInput(Int_t in, Int_t n) {fRegInput[n] = in;} + void SetRegOutput(Int_t out) { fRegOutput = out;} + void SetLocalData(Int_t d, Int_t n) {fLocalData[n] = d;} + + UInt_t* GetAddress() {return &fRegWord;} + + private: + + UInt_t fRegWord; // first word + Int_t fLocalData[16*5]; // local data + Int_t fRegInput[2]; // regional input + Int_t fRegOutput; // regional output + + ClassDef(AliMUONSubEventTrigger,1) // MUON Pad Hit +}; +#endif diff --git a/MUON/MUONLinkDef.h b/MUON/MUONLinkDef.h index 6547d3903a8..7a72eac2c85 100644 --- a/MUON/MUONLinkDef.h +++ b/MUON/MUONLinkDef.h @@ -12,7 +12,7 @@ #pragma link C++ class AliMUONHit+; #pragma link C++ class AliMUONPadHit+; #pragma link C++ class AliMUONDigit+; -#pragma link C++ class AliMUONTransientDigit+; +#pragma link C++ clagss AliMUONTransientDigit+; #pragma link C++ class AliMUONReconstHit+; #pragma link C++ class AliMUONRawCluster+; #pragma link C++ class AliMUONGlobalTrigger+; @@ -49,7 +49,10 @@ #pragma link C++ class AliMUONTrackHit+; #pragma link C++ class AliMUONTrackParam+; #pragma link C++ class AliMUONTriggerConstants+; +#pragma link C++ class AliMUONDDLTrigger+; #pragma link C++ class AliMUONDDLTracker+; +#pragma link C++ class AliMUONSubEventTracker+; +#pragma link C++ class AliMUONSubEventTrigger+; #pragma link C++ class AliMUONRawData+; #pragma link C++ class AliMUONReconstructor+; #pragma link C++ class AliMUONSegmentationSlatModule+; diff --git a/MUON/README b/MUON/README index 782858967f4..7ee55aff3fc 100644 --- a/MUON/README +++ b/MUON/README @@ -253,12 +253,13 @@ gener->SetSigma(0,0,0.0); // Sigma in (X,Y,Z) (cm) on IP position gener->Init(); =========================================================== - csh Script for the full reconstruction + csh Script for the full reconstruction with raw data generator =========================================================== aliroot -b << EOF AliSimulation MuonSim("YourConfig.C") +MuonSim.SetWriteRawData("MUON"); MuonSim.Run(XXX) .q EOF diff --git a/MUON/libMUON.pkg b/MUON/libMUON.pkg index 1e6d335bbc0..c9f016bc433 100644 --- a/MUON/libMUON.pkg +++ b/MUON/libMUON.pkg @@ -33,12 +33,12 @@ SRCS = AliMUONChamber.cxx AliMUONChamberTrigger.cxx \ AliMUONSegmentationSlatModule.cxx AliMUONSegmentationSlatModuleN.cxx \ AliMUONSegmentationSlat.cxx AliMUONSegmentationSlatN.cxx \ AliMUONRecoEvent.cxx AliMUONRecoTrack.cxx AliMUONRecoDisplay.cxx \ - AliMUONMerger.cxx AliMUONFactory.cxx AliMUONDigitizer.cxx AliMUONDigitizerv1.cxx AliMUONDigitizerv2.cxx AliMUONSDigitizerv1.cxx \ + AliMUONMerger.cxx AliMUONFactory.cxx AliMUONDigitizer.cxx AliMUONDigitizerv1.cxx AliMUONDigitizerv2.cxx \ + AliMUONSDigitizerv1.cxx \ AliMUONTrackK.cxx AliMUONClusterFinderAZ.cxx AliMUONPixel.cxx \ AliMUONLoader.cxx AliMUONData.cxx AliMUONDataInterface.cxx \ - AliMUONDDLTracker.cxx \ - AliMUONRawData.cxx - + AliMUONDDLTrigger.cxx AliMUONSubEventTrigger.cxx AliMUONDDLTracker.cxx \ + AliMUONRawData.cxx AliMUONSubEventTracker.cxx SRCS += AliMUONSt1Segmentation.cxx AliMUONSt1Response.cxx \ -- 2.43.0