- // ADC data
- for (Int_t iAdc = 0; iAdc < 21; iAdc++ ) {
- Int_t padcol = fFee->GetPadColFromADC(iRob, iMcm, iAdc);
- UInt_t aa = !(iAdc & 1) + 2;
- UInt_t *a = new UInt_t[nTBin+2];
- // 3 timebins are packed into one 32 bits word
- for (Int_t iT = 0; iT < nTBin; iT+=3) {
- if ((padcol >= 0) && (padcol < nCol)) {
- a[iT ] = ((iT ) < nTBin ) ? digits->GetDataUnchecked(padrow,padcol,iT ) : 0;
- a[iT+1] = ((iT + 1) < nTBin ) ? digits->GetDataUnchecked(padrow,padcol,iT + 1) : 0;
- a[iT+2] = ((iT + 2) < nTBin ) ? digits->GetDataUnchecked(padrow,padcol,iT + 2) : 0;
- }
- else {
- a[iT] = a[iT+1] = a[iT+2] = 0; // This happenes at the edge of chamber (should be pedestal! How?)
- }
- x = (a[iT+2] << 22) | (a[iT+1] << 12) | (a[iT] << 2) | aa;
- if (nw < maxSize) {
- buf[nw++] = x;
+//_____________________________________________________________________________
+Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det, UInt_t *buf, Int_t maxSize, Bool_t /*newEvent = kFALSE*/, Bool_t /*newSM = kFALSE*/){
+ //
+ // This function produces the raw data for one HC, i.e. tracklets, tracklet endmarkers,
+ // raw data, raw data endmarkers.
+ // This function can be used for both ZS and NZS data
+ //
+
+ Int_t nw = 0; // Number of written words
+ Int_t of = 0; // Number of overflowed words
+ Int_t *tempnw = &nw; // Number of written words for temp. buffer
+ Int_t *tempof = &of; // Number of overflowed words for temp. buffer
+ Int_t layer = fGeo->GetLayer( det ); // Layer
+ Int_t stack = fGeo->GetStack( det ); // Stack
+ Int_t sect = fGeo->GetSector( det ); // Sector (=iDDL)
+ const Int_t kCtype = fGeo->GetStack(det) == 2 ? 0 : 1; // Chamber type (0:C0, 1:C1)
+
+ Bool_t trackletOn = fFee->GetTracklet(); // tracklet simulation active?
+
+ AliDebug(1,Form("Producing raw data for sect=%d layer=%d stack=%d side=%d",sect,layer,stack,side));
+
+ UInt_t *tempBuffer = buf; // tempBuffer used to write ADC data
+ // different in case of tracklet writing
+
+ if (trackletOn) {
+ tempBuffer = new UInt_t[maxSize];
+ tempnw = new Int_t(0);
+ tempof = new Int_t(0);
+ }
+
+ WriteIntermediateWords(tempBuffer,*tempnw,*tempof,maxSize,det,side);
+
+ if (digits->HasData()) {
+ // scanning direction such, that tracklet-words are sorted in ascending z and then in ascending y order
+ // ROB numbering on chamber and MCM numbering on ROB increase with decreasing z and increasing y
+ for (Int_t iRobRow = 0; iRobRow <= (kCtype + 3)-1; iRobRow++ ) {
+ // ROB number should be increasing
+ Int_t iRob = iRobRow * 2 + side;
+ // MCM on one ROB
+ for (Int_t iMcmRB = 0; iMcmRB < fGeo->MCMmax(); iMcmRB++ ) {
+ Int_t iMcm = 16 - 4*(iMcmRB/4 + 1) + (iMcmRB%4);
+
+ fMcmSim->Init(det, iRob, iMcm);
+ fMcmSim->SetData(digits); // no filtering done here (already done in digitizer)
+ if (trackletOn) {
+ fMcmSim->Tracklet();
+ Int_t tempNw = fMcmSim->ProduceTrackletStream(&buf[nw], maxSize - nw);
+ if( tempNw < 0 ) {
+ of += tempNw;
+ nw += maxSize - nw;
+ AliError(Form("Buffer overflow detected. Please increase the buffer size and recompile."));
+ } else {
+ nw += tempNw;
+ }
+ }
+ fMcmSim->ZSMapping(); // Calculate zero suppression mapping
+ // at the moment it has to be rerun here
+ // Write MCM data to temp. buffer
+ Int_t tempNw = fMcmSim->ProduceRawStream( &tempBuffer[*tempnw], maxSize - *tempnw, fEventCounter );
+ if ( tempNw < 0 ) {
+ *tempof += tempNw;
+ *tempnw += maxSize - nw;
+ AliError(Form("Buffer overflow detected. Please increase the buffer size and recompile."));
+ } else {
+ *tempnw += tempNw;
+ }
+ }