#include <TArrayF.h> // ROOT_TArrayI
#include <TArrayC.h> // ROOT_TArrayI
#include <TClonesArray.h> // ROOT_TClonesArray
+#include <TTree.h>
// #include <fstream>
#include "AliDAQ.h"
return;
}
- TClonesArray* digits = new TClonesArray("AliFMDDigit", 1000);
fFMD->SetTreeAddress();
- TBranch* digitBranch = digitTree->GetBranch(fFMD->GetName());
- if (!digitBranch) {
- AliError(Form("no branch for %s", fFMD->GetName()));
- return;
- }
- digitBranch->SetAddress(&digits);
+ TClonesArray* digits = fFMD->Digits();
+ // new TClonesArray("AliFMDDigit", 1000);
+ // TBranch* digitBranch = digitTree->GetBranch(fFMD->GetName());
+ // if (!digitBranch) {
+ // AliError(Form("no branch for %s", fFMD->GetName()));
+ // return;
+ // }
+ // digitBranch->SetAddress(&digits);
Int_t nEvents = Int_t(digitTree->GetEntries());
AliFMDDebug(5, ("Got a total of %5d events from tree", nEvents));
WriteDigits(digits);
}
loader->UnloadDigits();
+ //delete digits;
}
#if 1
//____________________________________________________________________
-void
+Long_t
AliFMDRawWriter::WriteDigits(TClonesArray* digits)
{
// WRite an array of digits to disk file
Int_t nDigits = digits->GetEntries();
- if (nDigits < 1) return;
+ if (nDigits < 1) return 0;
AliFMDDebug(5, ("Got a total of %5d digits from tree", nDigits));
AliFMDParameters* pars = AliFMDParameters::Instance();
UShort_t threshold = 0;
+ UShort_t factor = 0;
UInt_t prevddl = 0xFFFF;
UInt_t prevaddr = 0xFFF;
// UShort_t prevStrip = 0;
// The Altro buffer
AliAltroBufferV3* altro = 0;
- Int_t totalWords = 0;
- Int_t nCounts = 0;
-
+ Int_t totalWords = 0;
+ Int_t nCounts = 0;
+ Long_t nBits = 0;
+
// Loop over the digits in the event. Note, that we assume the
// the digits are in order in the branch. If they were not, we'd
// have to cache all channels before we could write the data to
threshold = pars->GetZeroSuppression(det, ring, sector, strip);
sampleRate = pars->GetSampleRate(det, ring, sector, strip);
preSamples = pars->GetPreSamples(det, ring, sector, strip);
+ factor = UShort_t(pars->GetPedestalFactor());
if (det != oldDet) {
AliFMDDebug(5, ("Got new detector: %d (was %d)", det, oldDet));
- oldDet = det;
+ oldDet = det;
}
AliFMDDebug(15, ("Sample rate is %d", sampleRate));
time, prevaddr, nWords));
totalWords += nWords;
ZeroSuppress(data.fArray, nWords, peds.fArray, noise.fArray, threshold);
- if (altro) altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
+ if (altro)
+ /*nBits+=*/altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
data.Reset(-1);
peds.Reset(0);
noise.Reset(0);
// When the first argument is false, we write the real
// header.
AliFMDDebug(15, ("Closing output"));
- altro->Flush();
- altro->WriteDataHeader(kFALSE, kFALSE);
+ WriteRCUTrailer(altro, prevddl, threshold > 0, factor, sampleRate);
+
delete altro;
altro = 0;
}
// already
if (altro) {
ZeroSuppress(data.fArray, nWords, peds.fArray, noise.fArray, threshold);
- if (nWords > 0) altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
- altro->Flush();
- altro->WriteDataHeader(kFALSE, kFALSE);
+ if (nWords > 0)
+ /* nBits += */ altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
+ WriteRCUTrailer(altro, prevddl, threshold > 0, factor, sampleRate);
delete altro;
}
- AliFMDDebug(5, ("Wrote a total of %d words for %d counts",
- nWords, nCounts));
+ AliFMDDebug(5, ("Wrote a total of %d words in %ld bytes for %d counts",
+ nWords, nBits / 8, nCounts));
+ return nBits;
+}
+//____________________________________________________________________
+void
+AliFMDRawWriter::WriteRCUTrailer(AliAltroBufferV3* altro,
+ UInt_t ddl,
+ Bool_t zs,
+ UShort_t factor,
+ UShort_t rate) const
+{
+ // Flush and write the data header
+ altro->Flush();
+ altro->WriteDataHeader(kFALSE, kFALSE);
+
+ // Set parameters in RCU trailer.
+ // Zero-suppression flag
+ altro->SetZeroSupp(zs); // bool
+ // WARNING: We store the noise factor in the 2nd baseline
+ // filters excluded post samples, since we'll never use that
+ // mode.
+ // altro->SetNPostsamples(factor); //
+ altro->SetNNonZSPostsamples(factor);
+ // WARNING: We store the sample rate in the number of pre-trigger
+ // samples, since we'll never use that mode.
+ altro->SetNPretriggerSamples(rate); // fSampleRate[ddl]
+ // Active front-end cars
+ altro->SetActiveFECsA((ddl == 0 ? 0x1 : 0x3));
+ altro->SetActiveFECsB((ddl == 0 ? 0x1 : 0x3));
+
+ // Calculate number of samples
+ altro->SetNSamplesPerCh(rate * 128);
+ AliDebug(5,Form("Writing RCU trailer @ DDL %d w/zs=%d, factor=%d, rate=%d",
+ ddl, zs > 0, factor, rate));
+ altro->WriteRCUTrailer(ddl);
}
+
//____________________________________________________________________
void
AliFMDRawWriter::ZeroSuppress(Int_t*& data, Int_t nWords,
void
AliFMDRawWriter::WriteDigits(TClonesArray* digits)
{
+ //
+ // Write digits to file
+ //
Int_t nDigits = digits->GetEntries();
if (nDigits < 1) return;