]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Update by Jochen to use new AliTRDmcmSim implementation
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 2 Apr 2009 13:40:25 +0000 (13:40 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 2 Apr 2009 13:40:25 +0000 (13:40 +0000)
TRD/AliTRDmcmSim.cxx
TRD/AliTRDrawData.cxx

index f562be80429e6d609ac0b25dd88bb2ed2192d7bd..8ec0ac7c5bfad3ab79256ba8b1b984893332fc18 100644 (file)
@@ -550,7 +550,8 @@ Int_t AliTRDmcmSim::GetCol( Int_t iadc )
   // Return column id of the pad for the given ADC channel
   //
 
-  if( !CheckInitialized() ) return -1;
+  if( !CheckInitialized() ) 
+    return -1;
 
   Int_t col = fFeeParam->GetPadColFromADC(fRobPos, fMcmPos, iadc);
   if (col < 0 || col >= fFeeParam->GetNcol()) 
@@ -587,7 +588,7 @@ Int_t AliTRDmcmSim::ProduceRawStream( UInt_t *buf, Int_t maxSize, UInt_t iEv)
 
   if (nw < maxSize) {
     buf[nw++] = x;
-       //printf("\nMCM header: %X ",x);
+    //printf("\nMCM header: %X ",x);
   }
   else {
     of++;
@@ -608,7 +609,7 @@ Int_t AliTRDmcmSim::ProduceRawStream( UInt_t *buf, Int_t maxSize, UInt_t iEv)
 
     if (nw < maxSize) {
       buf[nw++] = x;
-         //printf("ADC mask: %X nMask=%d ADC data: ",x,nActiveADC);
+      //printf("ADC mask: %X nMask=%d ADC data: ",x,nActiveADC);
     }
     else {
       of++;
@@ -649,7 +650,6 @@ Int_t AliTRDmcmSim::ProduceTrackletStream( UInt_t *buf, Int_t maxSize )
   // with -1 * number of overflowed words
   //
 
-  UInt_t  x;
   Int_t   nw  = 0;  // Number of written words
   Int_t   of  = 0;  // Number of overflowed words
     
@@ -658,16 +658,11 @@ Int_t AliTRDmcmSim::ProduceTrackletStream( UInt_t *buf, Int_t maxSize )
   // Produce tracklet data. A maximum of four 32 Bit words will be written per MCM 
   // fMCMT is filled continuously until no more tracklet words available
 
-  Int_t wd = 0;
-  while ( (wd < fMaxTracklets) && (fMCMT[wd] > 0) ){
-      x = fMCMT[wd];
-      if (nw < maxSize) {
-       buf[nw++] = x;
-      }
-      else {
-       of++;
-      }
-      wd++;
+  for (Int_t iTracklet = 0; iTracklet < fTrackletArray->GetEntriesFast(); iTracklet++) {
+    if (nw < maxSize) 
+      buf[nw++] = ((AliTRDtrackletMCM*) (*fTrackletArray)[iTracklet])->GetTrackletWord();
+    else 
+      of++;
   }
   
   if( of != 0 ) return -of; else return nw;
@@ -947,7 +942,7 @@ void AliTRDmcmSim::ZSMapping()
                                                                  // (lookup table accept (I2,I1,I0)=(111)
                                                                  // or (110) or (101) or (100))
   Int_t eBIN = fTrapConfig->GetTrapReg(AliTRDtrapConfig::kEBIN); // TRAP default = 1 (no neighbor sensitivity)
-  Int_t ep   = AliTRDfeeParam::GetPFeffectPedestal();
+  Int_t ep   = 0; // fTrapConfig->GetTrapReg(AliTRDtrapConfig::kFPNP); //??? really subtracted here
 
   Int_t **adc = fADCF;
 
@@ -987,7 +982,6 @@ void AliTRDmcmSim::ZSMapping()
       fZSM1Dim[iadc] &= fZSM[iadc][it];
     }
   }
-
 }
 
 void AliTRDmcmSim::DumpData( char *f, char *target )
@@ -1260,7 +1254,11 @@ void AliTRDmcmSim::CalcFitreg()
         if (adcLeft  < regTPFP) adcLeft  = 0; else adcLeft  -= regTPFP;
         if (adcCentral  < regTPFP) adcCentral  = 0; else adcCentral  -= regTPFP;
         if (adcRight < regTPFP) adcRight = 0; else adcRight -= regTPFP;
+
         // Calculate the center of gravity
+        // checking for adcCentral != 0 (in case of "bad" configuration)
+        if (adcCentral == 0)
+          continue;
         ypos = 128*(adcLeft - adcRight) / adcCentral;
         if (ypos < 0) ypos = -ypos;
         // make the correction using the LUT
@@ -1453,7 +1451,7 @@ void AliTRDmcmSim::FitTracklet()
 
         // assemble and store the tracklet word
         fMCMT[cpu] = (qTotal << 24) | (padrow << 20) | (slope << 13) | offset;
-        new ((*fTrackletArray)[cpu]) AliTRDtrackletMCM((UInt_t) fMCMT[cpu], fDetector*2 + fRobPos%2, fRobPos, fMcmPos);
+        new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletMCM((UInt_t) fMCMT[cpu], fDetector*2 + fRobPos%2, fRobPos, fMcmPos);
       }
     }
   }
@@ -1485,15 +1483,15 @@ void AliTRDmcmSim::Tracklet()
   }
   else {
     TTree *trackletTree = dl->Tree();
-    if (!trackletTree)
+    if (!trackletTree) {
       dl->MakeTree();
-    trackletTree = dl->Tree();
+      trackletTree = dl->Tree();
+    }
 
     AliTRDtrackletMCM *trkl = 0x0;
     TBranch *trkbranch = trackletTree->GetBranch("mcmtrklbranch");
     if (!trkbranch)
       trkbranch = trackletTree->Branch("mcmtrklbranch", "AliTRDtrackletMCM", &trkl, 32000);
-//      trkbranch = trackletTree->Branch("mcmtrklbranch", &fTrackletArray, 32000, 2);
 
     for (Int_t iTracklet = 0; iTracklet < fTrackletArray->GetEntriesFast(); iTracklet++) {
       trkl = ((AliTRDtrackletMCM*) (*fTrackletArray)[iTracklet]);
@@ -1734,3 +1732,5 @@ void AliTRDmcmSim::Sort6To2Worst(uint16_t  idx1i, uint16_t  idx2i, uint16_t  idx
 //    printf("idx21s=%d, idx23as=%d, idx22s=%d, idx23bs=%d, idx5o=%d, idx6o=%d\n",
 //            idx21s,    idx23as,    idx22s,    idx23bs,    *idx5o,    *idx6o);
 }
+
+
index 30f1372e520087a03906a11237b0e09d336722db..052b46241496d8cc5b54486239f8276342df68cb 100644 (file)
@@ -487,152 +487,106 @@ Int_t AliTRDrawData::ProduceHcData(AliTRDarrayADC *digits, Int_t side, Int_t det
 
        Int_t           nw = 0;                       // Number of written    words
        Int_t           of = 0;                       // Number of overflowed words
+       Int_t      *tempnw = 0x0;                     // Number of written    words for temp. buffer
+       Int_t      *tempof = 0x0;                     // 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)
-       Int_t         nRow = fGeo->GetRowMax( layer, stack, sect );
-       Int_t         nCol = fGeo->GetColMax( layer );
-       const Int_t kNTBin = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
-       Int_t       kCtype = 0;                       // Chamber type (0:C0, 1:C1)
+       const Int_t kCtype = fGeo->GetStack(det) == 2 ? 0 : 1;                       // Chamber type (0:C0, 1:C1)
 
-       Bool_t tracklet_on = fFee->GetTracklet();     // **new**   
-
-       // To avoid compiler warning
-        if (newSM) {
-          ;;
-       }
-
-       // Check the nCol and nRow.
-       if ((nCol == 144) && (nRow == 16 || nRow == 12)) {
-       kCtype = (nRow-12) / 4;
-       } else {
-       AliError(Form("This type of chamber is not supported (nRow=%d, nCol=%d).",nRow,nCol));
-       return 0;
-       }
+       Bool_t tracklet_on = fFee->GetTracklet();     // tracklet simulation active?
 
        AliDebug(1,Form("Producing raw data for sect=%d layer=%d stack=%d side=%d",sect,layer,stack,side));
+        
+       AliTRDmcmSim* mcm = new AliTRDmcmSim();
 
-       AliTRDmcmSim** mcm = new AliTRDmcmSim*[(kCtype + 3)*(fGeo->MCMmax())];
+       UInt_t *tempBuffer = buf; // tempBuffer used to write ADC data
+                                 // different in case of tracklet writing
+       
+       if (tracklet_on) {
+         tempBuffer = new UInt_t[maxSize];
+          tempnw = new Int_t(0);
+          tempof = new Int_t(0);
+        }
+        else {
+          tempnw = &nw;
+          tempof = &of;
+        }
 
-       //if (newEvent) ProduceSMIndexData(buf, nw);            // SM index words , Stack index words
+       WriteIntermediateWordsV2(tempBuffer,*tempnw,*tempof,maxSize,det,side);  //??? no tracklet or NZS
 
-       if (!tracklet_on) WriteIntermediateWordsV2(buf,nw,of,maxSize,det,side); // no tracklet or NZS
-       
        // 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 =  (kCtype + 3)-1; iRobRow >= 0; iRobRow-- ) {
        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);
-               Int_t entry = iRobRow*(fGeo->MCMmax()) + iMcm;
-       
-               mcm[entry] = new AliTRDmcmSim();
-               mcm[entry]->Init( det, iRob, iMcm , newEvent);
-               //mcm[entry]->Init( det, iRob, iMcm);
-               if (newEvent == kTRUE) newEvent = kFALSE; // only one mcm is concerned with new event
-               Int_t padrow = mcm[entry]->GetRow();
-
-               // Copy ADC data to MCM simulator
-               for (Int_t iAdc = 0; iAdc < 21; iAdc++ ) {
-                   Int_t padcol = mcm[entry]->GetCol( iAdc );
-                   if ((padcol >=    0) && (padcol <  nCol)) {
-                               for (Int_t iT = 0; iT < kNTBin; iT++) { 
-                                 mcm[entry]->SetData( iAdc, iT, digits->GetData( padrow, padcol, iT) );
-                               } 
-                   } 
-               else {  // this means it is out of chamber, and masked ADC
-                               mcm[entry]->SetDataPedestal( iAdc );
-                       }
-               }
+          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);
+            
+            mcm->Init(det, iRob, iMcm);
+            mcm->SetData(digits);     // no filtering done here (already done in digitizer)
+           if (tracklet_on) {
+             mcm->Tracklet();
+              Int_t tempNw = mcm->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;
+             }
+           }
+            mcm->ZSMapping();  // Calculate zero suppression mapping
+                               // at the moment it has to be rerun here
+            // Write MCM data to temp. buffer
+            Int_t tempNw = mcm->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;
+            }
+          }
+       }
 
-               // Simulate process in MCM
-               mcm[entry]->Filter();     // Apply filter
-               mcm[entry]->ZSMapping();  // Calculate zero suppression mapping
-//jkl          mcm[entry]->CopyArrays();
-//jkl          mcm[entry]->GeneratefZSM1Dim();
-//jkl          mcm[entry]->RestoreZeros();
-
-               if (tracklet_on) {
-                   mcm[entry]->Tracklet(); 
-                   Int_t tempNw =  mcm[entry]->ProduceTrackletStream( &buf[nw], maxSize - nw );
-                   //Int_t tempNw = 0;
-                   if( tempNw < 0 ) {
-                               of += tempNw;
-                               nw += maxSize - nw;
-                               AliError(Form("Buffer overflow detected. Please increase the buffer size and recompile."));
-                   } else {
-                               nw += tempNw;
-                   }
-               } else { // no tracklets: write raw-data already in this loop 
-                   // Write MCM data to buffer
-                   Int_t tempNw =  mcm[entry]->ProduceRawStream( &buf[nw], maxSize - nw, fEventCounter );
-                   if( tempNw < 0 ) {
-                               of += tempNw;
-                               nw += maxSize - nw;
-                               AliError(Form("Buffer overflow detected. Please increase the buffer size and recompile."));
-                   } else {
-                               nw += tempNw;
-                   }
-                   
-                   delete mcm[entry];
-               }
+        delete mcm;
 
-               //mcm->DumpData( "trdmcmdata.txt", "RFZS" ); // debugging purpose
-       }
-       }
 
-       // if tracklets are switched on, raw-data can be written only after all tracklets
+       // in case of tracklet writing copy temp data to final buffer
        if (tracklet_on) {
-       WriteIntermediateWordsV2(buf,nw,of,maxSize,det,side); 
-  
-       // Scan for ROB and MCM
-       for (Int_t iRobRow =  (kCtype + 3)-1; iRobRow >= 0; iRobRow-- ) {
-               //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);
-             
-                       Int_t entry = iRobRow*(fGeo->MCMmax()) + iMcm; 
-                     
-                       // Write MCM data to buffer
-                       Int_t tempNw =  mcm[entry]->ProduceRawStream( &buf[nw], maxSize - nw, fEventCounter );
-                       if( tempNw < 0 ) {
-                                       of += tempNw;
-                                       nw += maxSize - nw;
-                                       AliError(Form("Buffer overflow detected. Please increase the buffer size and recompile."));
-                       } else {
-                                       nw += tempNw;
-                       }
-             
-                     delete mcm[entry];
-         
-                       }       
-       }
+         if (nw + *tempnw < maxSize) {
+           memcpy(&buf[nw], tempBuffer, *tempnw * sizeof(UInt_t));
+           nw += *tempnw;
+         }
+         else {
+           AliError("Buffer overflow detected");
+         }
        }
 
-       delete [] mcm;
-  
        // Write end of raw data marker
        if (nw+3 < maxSize) {
-       buf[nw++] = kEndofrawdatamarker
-       buf[nw++] = kEndofrawdatamarker
-       buf[nw++] = kEndofrawdatamarker
-       buf[nw++] = kEndofrawdatamarker
+          buf[nw++] = 0x00000000; // fFee->GetRawDataEndmarker()
+          buf[nw++] = 0x00000000; // fFee->GetRawDataEndmarker()
+          buf[nw++] = 0x00000000; // fFee->GetRawDataEndmarker()
+          buf[nw++] = 0x00000000; // fFee->GetRawDataEndmarker()
        } else {
-       of++;
+          of++;
        }
        
+        if (tracklet_on) {
+          delete [] tempBuffer;
+          delete tempof;
+          delete tempnw;
+        }
+
        if (of != 0) {
-       AliError("Buffer overflow. Data is truncated. Please increase buffer size and recompile.");
+          AliError("Buffer overflow. Data is truncated. Please increase buffer size and recompile.");
        }
 
        return nw;
 }
 
-
 //_____________________________________________________________________________
 Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDarrayADC *digits, Int_t side
                                         , Int_t det, UInt_t *buf, Int_t maxSize)
@@ -1246,3 +1200,5 @@ AliTRDdigitsManager *AliTRDrawData::Raw2DigitsOLD(AliRawReader *rawReader)
   return digitsManager;
 
 }
+
+