]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Digits and raw data updated for commissioning
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Oct 2007 10:56:19 +0000 (10:56 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Oct 2007 10:56:19 +0000 (10:56 +0000)
ZDC/AliZDC.cxx
ZDC/AliZDCCalibData.cxx
ZDC/AliZDCCalibData.h
ZDC/AliZDCDigitizer.cxx
ZDC/AliZDCRawStream.cxx
ZDC/AliZDCRawStream.h

index 12f8fe548dff8c506323860f3cc62e7277e7e0bf..394254809959112764ce37cf677bb86d7fc9b36e 100644 (file)
@@ -379,25 +379,20 @@ void AliZDC::Digits2Raw()
 {
   // Convert ZDC digits to raw data
 
-  // Format: 22 interger values -> ZN1 (C+Q1-4), ZP1 (C+Q1-4), ZEM1, 2, ZN (C+Q1-4), ZP2 (C+Q1-4))
-  //        + 22 interger values for the out of time channels
+  // Format: 24 int values -> ZN1(C+Q1-4), ZP1(C+Q1-4), ZEM1, ZEM2, ZN(C+Q1-4), ZP2(C+Q1-4), 2 Ref PMs
+  //        + 24 int values for the corresponding out of time channels
   // For the CAEN module V965 we have an Header, the Data Words and an End Of Block
   //   12 channels x 2 gain chains read from 1st ADC module
-  //   10 channels x 2 gain chains read from 2nd ADC module
+  //   12 channels x 2 gain chains read from 2nd ADC module
   //   12 channels x 2 gain chains read from 3rd ADC module (o.o.t.)
-  //   10 channels x 2 gain chains read from 4rth ADC module (o.o.t.)
+  //   12 channels x 2 gain chains read from 4rth ADC module (o.o.t.)
   //
-  const int knADCData1=24, knADCData2=20; 
+  const int knADCData1=24, knADCData2=24; // In principle the 2 numbers can be different!
   UInt_t lADCHeader1; 
-  UInt_t lADCData1[knADCData1];
-  //
   UInt_t lADCHeader2; 
+  UInt_t lADCData1[knADCData1];
   UInt_t lADCData2[knADCData2];
-  //
-  UInt_t lADCHeader3; 
   UInt_t lADCData3[knADCData1];
-  //
-  UInt_t lADCHeader4; 
   UInt_t lADCData4[knADCData2];
   //
   UInt_t lADCEndBlock;
@@ -409,7 +404,7 @@ void AliZDC::Digits2Raw()
   TTree* treeD = fLoader->TreeD();
   if(!treeD) return;
   treeD->SetBranchAddress("ZDC", &pdigit);
-  //printf("\t AliZDC::Digits2raw -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
+  //printf("\t AliZDC::Digits2Raw -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
 
   // Fill data array
   // ADC header
@@ -420,27 +415,22 @@ void AliZDC::Digits2Raw()
     
   lADCHeader1 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 |
                lADCHeaderCNT1 << 8 ;
-  //          
   lADCHeader2 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 |
                lADCHeaderCNT2 << 8 ;
-  //          
-  lADCHeader3 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 |
-               lADCHeaderCNT1 << 8 ;
-  //          
-  lADCHeader4 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 |
-               lADCHeaderCNT2 << 8 ;
-  //printf("\t lADCHeader1 = %x, lADCHeader2 = %x\n",lADCHeader1, lADCHeader2);
       
   // ADC data word
   UInt_t lADCDataGEO = lADCHeaderGEO;
+  //
   UInt_t lADCDataValue1[knADCData1];
   UInt_t lADCDataValue2[knADCData2];
   UInt_t lADCDataValue3[knADCData1];
   UInt_t lADCDataValue4[knADCData2];
+  //
   UInt_t lADCDataOvFlw1[knADCData1];
   UInt_t lADCDataOvFlw2[knADCData2];
   UInt_t lADCDataOvFlw3[knADCData1];
   UInt_t lADCDataOvFlw4[knADCData2];
+  //
   for(Int_t i=0; i<knADCData1 ; i++){
     lADCDataValue1[i] = 0;
     lADCDataOvFlw1[i] = 0;
@@ -453,6 +443,7 @@ void AliZDC::Digits2Raw()
     lADCDataValue4[i] = 0;
     lADCDataOvFlw4[i] = 0;
   }
+  //
   UInt_t lADCDataChannel = 0;
   
   // loop over digits
@@ -462,83 +453,116 @@ void AliZDC::Digits2Raw()
     //digit.Print("");
     
     // *** ADC data
-    Int_t index1=0, index2=0;
-    // *** ADC1 (ZN1, ZP1, ZEM1,2) o ADC3 (ZN1, ZP1, ZEM1,2 o.o.t.)
-    if(digit.GetSector(0)==1 || digit.GetSector(0)==2 || digit.GetSector(0)==3){
-      if(digit.GetSector(0)==1 || digit.GetSector(0)==2){
-        index1 = (digit.GetSector(0)-1) + digit.GetSector(1)*4; // ZN1 or ZP1
-        lADCDataChannel = (digit.GetSector(0)-1)*8 + digit.GetSector(1);
-      }
-      else if(digit.GetSector(0)==3){ // ZEM 1,2
-        index1 = 20 + (digit.GetSector(1)-1);
-        lADCDataChannel = 5 + (digit.GetSector(1)-1)*8;
+    Int_t index=0;
+    if(digit.GetSector(1)!=5){ // ZDC signal channels
+      // *** ADC1 (ZN1, ZP1, ZEM1,2) or ADC3 (ZN1, ZP1, ZEM1,2 o.o.t.)
+      if(digit.GetSector(0)==1 || digit.GetSector(0)==2 || digit.GetSector(0)==3){
+        if(digit.GetSector(0)==1 || digit.GetSector(0)==2){
+          index = (digit.GetSector(0)-1) + 4*digit.GetSector(1); // ZN1 or ZP1
+          lADCDataChannel = 8*(digit.GetSector(0)-1) + digit.GetSector(1);
+        }
+        else if(digit.GetSector(0)==3){ // ZEM 1,2
+          index = 20 + (digit.GetSector(1)-1);
+          lADCDataChannel = 5 + 8*(digit.GetSector(1)-1);
+        }
+        //
+        /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n",
+               iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel,
+               digit.GetADCValue(0),digit.GetADCValue(1));// Ch. debug
+        */
+        //
+        if(iDigit<knADCData1){ // *** In-time signals
+          lADCDataValue1[index] = digit.GetADCValue(0);   // High gain ADC ch.    
+          if(lADCDataValue1[index] > 2047) lADCDataOvFlw1[index] = 1; 
+          lADCDataValue1[index+2] = digit.GetADCValue(1); // Low gain ADC ch.
+          if(lADCDataValue1[index+2] > 2047) lADCDataOvFlw1[index+2] = 1; 
+        
+          lADCData1[index] = lADCDataGEO << 27 | 0x1 << 24 | lADCDataChannel << 17 | 
+                         lADCDataOvFlw1[index] << 12 | (lADCDataValue1[index] & 0xfff); 
+          lADCData1[index+2] = lADCDataGEO << 27 | 0x1 << 24  | lADCDataChannel << 17 | 0x1 << 16 |
+                         lADCDataOvFlw1[index+2] << 12 | (lADCDataValue1[index+2] & 0xfff);  
+        }
+       else{ // *** Out-of-time signals
+          lADCDataValue3[index] = digit.GetADCValue(0);   // High gain ADC ch.    
+          if(lADCDataValue3[index] > 2047) lADCDataOvFlw3[index] = 1; 
+         lADCDataValue3[index+2] = digit.GetADCValue(1); // Low gain ADC ch.
+         if(lADCDataValue3[index+2] > 2047) lADCDataOvFlw3[index+2] = 1; 
+      
+         lADCData3[index] = lADCDataGEO << 27 | lADCDataChannel << 17 | 
+                         lADCDataOvFlw3[index] << 12 | (lADCDataValue3[index] & 0xfff); 
+         lADCData3[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
+                         lADCDataOvFlw3[index+2] << 12 | (lADCDataValue3[index+2] & 0xfff);  
+       }                  
       }
-      //
-      /*printf("\t AliZDC::Digits2raw -> det %d, quad %d, index = %d, ADCch = %d\n",
-               digit.GetSector(0),digit.GetSector(1),index1,lADCDataChannel);// Ch. debug
-      */
-      //
-      if(iDigit<22){
-        lADCDataValue1[index1] = digit.GetADCValue(0);         // High gain ADC ch.    
-        if(lADCDataValue1[index1] > 2047) lADCDataOvFlw1[index1] = 1; 
-        lADCDataValue1[index1+2] = digit.GetADCValue(1); // Low gain ADC ch.
-        if(lADCDataValue1[index1+2] > 2047) lADCDataOvFlw1[index1+2] = 1; 
-    
-        lADCData1[index1] = lADCDataGEO << 27 | lADCDataChannel << 17 | 
-                        lADCDataOvFlw1[index1] << 12 | (lADCDataValue1[index1] & 0xfff); 
-        lADCData1[index1+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
-                        lADCDataOvFlw1[index1+2] << 12 | (lADCDataValue1[index1+2] & 0xfff);  
+      // *** ADC2 (ZN2, ZP2) or ADC4 (ZN2, ZP2 o.o.t.)
+      else if(digit.GetSector(0)==4 || digit.GetSector(0)==5){
+       index = (digit.GetSector(0)-4) + 4*digit.GetSector(1); // ZN2 or ZP2
+       lADCDataChannel = 8*(digit.GetSector(0)-4) + digit.GetSector(1);
+       //
+        /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n",
+               iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel,
+               digit.GetADCValue(0),digit.GetADCValue(1));// Ch. debug
+        */
+        //
+        if(iDigit<knADCData2){ // *** In-time signals
+          lADCDataValue2[index] = digit.GetADCValue(0);
+          if(lADCDataValue2[index] > 2047) lADCDataOvFlw2[index] = 1; 
+          lADCDataValue2[index+2] = digit.GetADCValue(1);
+          if(lADCDataValue2[index+2] > 2047) lADCDataOvFlw2[index+2] = 1; 
+          //
+          lADCData2[index] =   lADCDataGEO << 27 | lADCDataChannel << 17 | 
+                         lADCDataOvFlw2[index] << 12 | (lADCDataValue2[index] & 0xfff); 
+          lADCData2[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
+                         lADCDataOvFlw2[index+2] << 12 | (lADCDataValue2[index+2] & 0xfff);   
+        }                
+       else{ // *** Out-of-time signals
+          lADCDataValue4[index] = digit.GetADCValue(0);
+          if(lADCDataValue4[index] > 2047) lADCDataOvFlw4[index] = 1; 
+          lADCDataValue4[index+2] = digit.GetADCValue(1);
+          if(lADCDataValue4[index+2] > 2047) lADCDataOvFlw4[index+2] = 1; 
+          //
+          lADCData4[index] =   lADCDataGEO << 27 | lADCDataChannel << 17 | 
+                        lADCDataOvFlw4[index] << 12 | (lADCDataValue4[index] & 0xfff); 
+          lADCData4[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
+                        lADCDataOvFlw4[index+2] << 12 | (lADCDataValue4[index+2] & 0xfff);   
+        }                 
       }
-      else{
-        lADCDataValue3[index1] = digit.GetADCValue(0);         // High gain ADC ch.    
-        if(lADCDataValue3[index1] > 2047) lADCDataOvFlw3[index1] = 1; 
-        lADCDataValue3[index1+2] = digit.GetADCValue(1); // Low gain ADC ch.
-        if(lADCDataValue3[index1+2] > 2047) lADCDataOvFlw3[index1+2] = 1; 
-    
-        lADCData3[index1] = lADCDataGEO << 27 | lADCDataChannel << 17 | 
-                        lADCDataOvFlw3[index1] << 12 | (lADCDataValue3[index1] & 0xfff); 
-        lADCData3[index1+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
-                        lADCDataOvFlw3[index1+2] << 12 | (lADCDataValue3[index1+2] & 0xfff);  
-      }                  
     }
-    // *** ADC2 (ZN2, ZP2) o ADC4 (ZN2, ZP2 o.o.t.)
-    else if(digit.GetSector(0)==4 || digit.GetSector(0)==5){
-      index2 = (digit.GetSector(0)-4) + digit.GetSector(1)*4; // ZN2 or ZP2
-      lADCDataChannel = (digit.GetSector(0)-4)*8 + digit.GetSector(1);
+    // *** ADC2 (Reference PTMs) or ADC4 (Reference PTMs o.o.t.)
+    else if(digit.GetSector(1)==5){
+      index = 20 + (digit.GetSector(0)-1)*1/3; 
+      lADCDataChannel = 5 + (digit.GetSector(0)-1)*8/3;
       //
-      /*printf("\t AliZDC::Digits2raw -> det %d, quad %d, index = %d, ADCch = %d\n",
-               digit.GetSector(0),digit.GetSector(1),index1,lADCDataChannel); // Ch. debug
+      /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n",
+               iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel,
+               digit.GetADCValue(0),digit.GetADCValue(1));// Ch. debug
       */
       //
-      if(iDigit<22){
-        lADCDataValue2[index2] = digit.GetADCValue(0);
-        if(lADCDataValue2[index2] > 2047) lADCDataOvFlw2[index2] = 1; 
-        lADCDataValue2[index2+2] = digit.GetADCValue(1);
-        if(lADCDataValue2[index2+2] > 2047) lADCDataOvFlw2[index2+2] = 1; 
+      if(iDigit<knADCData2){ // *** In-time signals
+        lADCDataValue2[index] = digit.GetADCValue(0);
+        if(lADCDataValue2[index] > 2047) lADCDataOvFlw2[index] = 1; 
+        lADCDataValue2[index+2] = digit.GetADCValue(1);
+        if(lADCDataValue2[index+2] > 2047) lADCDataOvFlw2[index+2] = 1; 
         //
-        lADCData2[index2] =   lADCDataGEO << 27 | lADCDataChannel << 17 | 
-                        lADCDataOvFlw2[index2] << 12 | (lADCDataValue2[index2] & 0xfff); 
-        lADCData2[index2+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
-                        lADCDataOvFlw2[index2+2] << 12 | (lADCDataValue2[index2+2] & 0xfff);   
-      }                 
-      else{
-        lADCDataValue4[index2] = digit.GetADCValue(0);
-        if(lADCDataValue4[index2] > 2047) lADCDataOvFlw4[index2] = 1; 
-        lADCDataValue4[index2+2] = digit.GetADCValue(1);
-        if(lADCDataValue4[index2+2] > 2047) lADCDataOvFlw4[index2+2] = 1; 
+        lADCData2[index] =   lADCDataGEO << 27 | lADCDataChannel << 17 | 
+                       lADCDataOvFlw2[index] << 12 | (lADCDataValue2[index] & 0xfff); 
+        lADCData2[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
+                       lADCDataOvFlw2[index+2] << 12 | (lADCDataValue2[index+2] & 0xfff);   
+      }                
+      else{ // *** Out-of-time signals
+        lADCDataValue4[index] = digit.GetADCValue(0);
+        if(lADCDataValue4[index] > 2047) lADCDataOvFlw4[index] = 1; 
+        lADCDataValue4[index+2] = digit.GetADCValue(1);
+        if(lADCDataValue4[index+2] > 2047) lADCDataOvFlw4[index+2] = 1; 
         //
-        lADCData4[index2] =   lADCDataGEO << 27 | lADCDataChannel << 17 | 
-                        lADCDataOvFlw4[index2] << 12 | (lADCDataValue4[index2] & 0xfff); 
-        lADCData4[index2+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
-                        lADCDataOvFlw4[index2+2] << 12 | (lADCDataValue4[index2+2] & 0xfff);   
-      }                 
-    } 
-    if((index1<0) || (index1>23)) {
-      Error("Digits2Raw", "sector[0] = %d, sector[1] = %d", 
-           digit.GetSector(0), digit.GetSector(1));
-      continue;
+        lADCData4[index] =   lADCDataGEO << 27 | lADCDataChannel << 17 | 
+                     lADCDataOvFlw4[index] << 12 | (lADCDataValue4[index] & 0xfff); 
+        lADCData4[index+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
+                     lADCDataOvFlw4[index+2] << 12 | (lADCDataValue4[index+2] & 0xfff);   
+      }                
+           
     }
-    if((index2<0) || (index2>19)) {
+    if((index<0) || (index>23)) {
       Error("Digits2Raw", "sector[0] = %d, sector[1] = %d", 
            digit.GetSector(0), digit.GetSector(1));
       continue;
@@ -546,7 +570,9 @@ void AliZDC::Digits2Raw()
     
     
   }
-  /*  for(Int_t i=0;i<24;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]);
+  //
+  /*
+  for(Int_t i=0;i<24;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]);
   for(Int_t i=0;i<20;i++) printf("\t ADCData2[%d] = %x\n",i,lADCData2[i]);
   for(Int_t i=0;i<24;i++) printf("\t ADCData3[%d] = %x\n",i,lADCData3[i]);
   for(Int_t i=0;i<20;i++) printf("\t ADCData4[%d] = %x\n",i,lADCData4[i]);
@@ -555,10 +581,9 @@ void AliZDC::Digits2Raw()
   // End of Block
   UInt_t lADCEndBlockGEO = lADCHeaderGEO;
   UInt_t lADCEndBlockEvCount = gAlice->GetEventNrInRun();
-  
+  //  
   lADCEndBlock = lADCEndBlockGEO << 27 | 0x1 << 26 | lADCEndBlockEvCount;
-  
-  //printf("\t ADCEndBlock = %d\n",lADCEndBlock);
+  printf("\t AliZDC::Digits2Raw -> ADCEndBlock = %d\n",lADCEndBlock);
 
 
   // open the output file
@@ -572,12 +597,15 @@ void AliZDC::Digits2Raw()
   header.fSize = sizeof(header) + 
                  sizeof(lADCHeader1) + sizeof(lADCData1) + sizeof(lADCEndBlock) +
                 sizeof(lADCHeader2) + sizeof(lADCData2) + sizeof(lADCEndBlock) +
-                 sizeof(lADCHeader3) + sizeof(lADCData3) + sizeof(lADCEndBlock) +
-                sizeof(lADCHeader4) + sizeof(lADCData4) + sizeof(lADCEndBlock);
+                 sizeof(lADCHeader1) + sizeof(lADCData3) + sizeof(lADCEndBlock) +
+                sizeof(lADCHeader2) + sizeof(lADCData4) + sizeof(lADCEndBlock);
+  //
   /*printf("sizeof header = %d, ADCHeader1 = %d, ADCData1 = %d, ADCEndBlock = %d\n",
           sizeof(header),sizeof(lADCHeader1),sizeof(lADCData1),sizeof(lADCEndBlock));
   printf("sizeof header = %d, ADCHeader2 = %d, ADCData2 = %d, ADCEndBlock = %d\n",
-          sizeof(header),sizeof(lADCHeader2),sizeof(lADCData2),sizeof(lADCEndBlock));*/
+          sizeof(header),sizeof(lADCHeader2),sizeof(lADCData2),sizeof(lADCEndBlock));
+  */
+  //    
   header.SetAttribute(0);  // valid data
   file->WriteBuffer((char*)(&header), sizeof(header));
 
@@ -588,10 +616,10 @@ void AliZDC::Digits2Raw()
   file->WriteBuffer((char*) &lADCHeader2, sizeof (lADCHeader2));
   file->WriteBuffer((char*)(lADCData2), sizeof(lADCData2));
   file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
-  file->WriteBuffer((char*) &lADCHeader3, sizeof (lADCHeader3));
+  file->WriteBuffer((char*) &lADCHeader1, sizeof (lADCHeader1));
   file->WriteBuffer((char*)(lADCData3), sizeof(lADCData3));
   file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
-  file->WriteBuffer((char*) &lADCHeader4, sizeof (lADCHeader4));
+  file->WriteBuffer((char*) &lADCHeader2, sizeof (lADCHeader2));
   file->WriteBuffer((char*)(lADCData4), sizeof(lADCData4));
   file->WriteBuffer((char*) &lADCEndBlock, sizeof(lADCEndBlock));
   delete file;
@@ -632,8 +660,8 @@ Bool_t AliZDC::Raw2SDigits(AliRawReader* rawReader)
     Int_t jcount = 0;
     while(rawStream.Next()){
       if(rawStream.IsADCDataWord()){
-        //For the moment only in-time SDigits are foreseen (1st 44 raw values)
-        if(jcount < 44){ 
+        //For the moment only in-time SDigits are foreseen (1st 48 raw values)
+        if(jcount < 48){ 
           for(Int_t j=0; j<2; j++) sector[j] = rawStream.GetSector(j);
          ADCRaw = rawStream.GetADCValue();
          ADCRes = rawStream.GetADCGain();
@@ -681,9 +709,12 @@ Int_t AliZDC::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const
   Float_t PedValue;
   Float_t meanPed, Pedwidth;
   Int_t index=0;
-  if(Det==1|| Det==2)        index = 10*(Det-1)+Quad+5*Res;   // ZN1, ZP1
-  else if(Det==3)            index = 10*(Det-1)+(Quad-1)+Res; // ZEM
-  else if(Det==4|| Det==5)    index = 10*(Det-2)+Quad+5*Res+4; // ZN2, ZP2
+  if(Quad!=5){
+    if(Det==1 || Det==2)      index = 10*(Det-1)+Quad+5*Res;   // ZN1, ZP1
+    else if(Det==3)          index = 10*(Det-1)+(Quad-1)+Res; // ZEM
+    else if(Det==4 || Det==5) index = 10*(Det-2)+Quad+5*Res+4; // ZN2, ZP2
+  }
+  else index = 10*(Quad-1)+(Det-1)*1/3+2*Res+4; // Reference PMs
   //
   //
   meanPed = CalibData->GetMeanPed(index);
index 819ae5fb01380f091537e58039274e9bfb5024f5..e4cf998939e4e3f2b68b9b4aa68ca31fa6814129 100644 (file)
@@ -50,7 +50,7 @@ AliZDCCalibData::AliZDCCalibData(const AliZDCCalibData& calibda) :
   SetName(calibda.GetName());
   SetTitle(calibda.GetName());
   Reset();
-  for(int t=0; t<47; t++){
+  for(int t=0; t<48; t++){
      fMeanPedestal[t] = calibda.GetMeanPed(t);
      fMeanPedWidth[t] = calibda.GetMeanPedWidth(t);
      fOOTPedestal[t]  = calibda.GetOOTPed(t);
@@ -73,7 +73,7 @@ AliZDCCalibData &AliZDCCalibData::operator =(const AliZDCCalibData& calibda)
   SetName(calibda.GetName());
   SetTitle(calibda.GetName());
   Reset();
-  for(int t=0; t<47; t++){
+  for(int t=0; t<48; t++){
      fMeanPedestal[t] = calibda.GetMeanPed(t);
      fMeanPedWidth[t] = calibda.GetMeanPedWidth(t);
      fOOTPedestal[t]  = calibda.GetOOTPed(t);
@@ -97,10 +97,10 @@ AliZDCCalibData::~AliZDCCalibData()
 void AliZDCCalibData::Reset()
 {
   // Reset
-  memset(fMeanPedestal,0,47*sizeof(Float_t));
-  memset(fMeanPedWidth,0,47*sizeof(Float_t));
-  memset(fOOTPedestal,0,47*sizeof(Float_t));
-  memset(fOOTPedWidth,0,47*sizeof(Float_t));
+  memset(fMeanPedestal,0,48*sizeof(Float_t));
+  memset(fMeanPedWidth,0,48*sizeof(Float_t));
+  memset(fOOTPedestal,0,48*sizeof(Float_t));
+  memset(fOOTPedWidth,0,48*sizeof(Float_t));
   memset(fEnCalibration,0,6*sizeof(Float_t));
 }                                                                                       
 
@@ -110,7 +110,7 @@ void  AliZDCCalibData::Print(Option_t *) const
 {
    // Printing of calibration object
    printf("\n #######  In-time pedestal values (mean value, sigma)     ####### \n");
-   for(int t=0; t<47; t++){
+   for(int t=0; t<48; t++){
      if(t==0 || t==24) printf("\n-------- ZN1 HighRes -------- \n");
      else if(t==5 || t==29) printf("\n-------- ZN1 LowRes -------- \n");
      else if(t==10 || t==34) printf("\n-------- ZP1 HighRes -------- \n");
@@ -123,7 +123,7 @@ void  AliZDCCalibData::Print(Option_t *) const
    }
    //
    printf("\n\n #######        Out-of-time pedestal values (mean value, sigma) ####### \n");
-   for(int t=0; t<47; t++){
+   for(int t=0; t<48; t++){
      if(t==0 || t==24) printf("\n-------- ZN1 HighRes -------- \n");
      else if(t==5 || t==29) printf("\n-------- ZN1 LowRes -------- \n");
      else if(t==10 || t==34) printf("\n-------- ZP1 HighRes -------- \n");
@@ -169,28 +169,28 @@ void  AliZDCCalibData::Print(Option_t *) const
 //________________________________________________________________
 void AliZDCCalibData::SetMeanPed(Float_t* MeanPed)
 {
-  if(MeanPed) for(int t=0; t<47; t++) fMeanPedestal[t] = MeanPed[t];
-  else for(int t=0; t<47; t++) fMeanPedestal[t] = 0.;
+  if(MeanPed) for(int t=0; t<48; t++) fMeanPedestal[t] = MeanPed[t];
+  else for(int t=0; t<48; t++) fMeanPedestal[t] = 0.;
 }
 //________________________________________________________________
 void AliZDCCalibData::SetMeanPedWidth(Float_t* MeanPedWidth)
 {
-  if(MeanPedWidth) for(int t=0; t<47; t++) fMeanPedWidth[t] = MeanPedWidth[t];
-  else for(int t=0; t<47; t++) fMeanPedWidth[t] = 0.;
+  if(MeanPedWidth) for(int t=0; t<48; t++) fMeanPedWidth[t] = MeanPedWidth[t];
+  else for(int t=0; t<48; t++) fMeanPedWidth[t] = 0.;
 }
 
 //________________________________________________________________
 void AliZDCCalibData::SetOOTPed(Float_t* OOTPed)
 {
-  if(OOTPed) for(int t=0; t<47; t++) fOOTPedestal[t] = OOTPed[t];
-  else for(int t=0; t<47; t++) fOOTPedestal[t] = 0.;
+  if(OOTPed) for(int t=0; t<48; t++) fOOTPedestal[t] = OOTPed[t];
+  else for(int t=0; t<48; t++) fOOTPedestal[t] = 0.;
 }
 
 //________________________________________________________________
 void AliZDCCalibData::SetOOTPedWidth(Float_t* OOTPedWidth)
 {
-  if(OOTPedWidth) for(int t=0; t<47; t++) fOOTPedWidth[t] = OOTPedWidth[t];
-  else for(int t=0; t<47; t++) fOOTPedWidth[t] = 0.;
+  if(OOTPedWidth) for(int t=0; t<48; t++) fOOTPedWidth[t] = OOTPedWidth[t];
+  else for(int t=0; t<48; t++) fOOTPedWidth[t] = 0.;
 }
 
 //________________________________________________________________
@@ -199,13 +199,13 @@ void AliZDCCalibData:: SetPedCorrCoeff(Float_t* PedCorrCoeff)
   // Set coefficients for pedestal correlations
   if(PedCorrCoeff){
     for(Int_t j=0; j<2; j++){
-     for(int t=0; t<47; t++)
+     for(int t=0; t<48; t++)
        fPedCorrCoeff[j][t] = PedCorrCoeff[t];
     }
   }
   else{
     for(Int_t j=0; j<2; j++){
-     for(int t=0; t<47; t++)
+     for(int t=0; t<48; t++)
        fPedCorrCoeff[j][t] = 0.;
     }
   }
@@ -217,13 +217,13 @@ void AliZDCCalibData:: SetPedCorrCoeff(Float_t* PedCorrCoeff0, Float_t* PedCorrC
 {
   // Set coefficients for pedestal correlations
   if(PedCorrCoeff0 && PedCorrCoeff1){
-    for(int t=0; t<47; t++){
+    for(int t=0; t<48; t++){
        fPedCorrCoeff[0][t] = PedCorrCoeff0[t];
        fPedCorrCoeff[0][t] = PedCorrCoeff1[t];
     }
   }
   else{
-     for(int t=0; t<47; t++){
+     for(int t=0; t<48; t++){
        fPedCorrCoeff[0][t] = 0.;
        fPedCorrCoeff[1][t] = 0.;
     }
index e67063b2c95b62bad1c94f27d309c89ebda9f363..ca651fd83a0ecfa1c1f9c164208994735c70073f 100644 (file)
@@ -99,11 +99,11 @@ class AliZDCCalibData: public TNamed {
   
  protected:
   // --- Pedestals
-  Float_t  fMeanPedestal[47];   // Mean pedestal values 
-  Float_t  fMeanPedWidth[47];   // Mean pedestal widths 
-  Float_t  fOOTPedestal[47];    // "Out of Time" pedestal values
-  Float_t  fOOTPedWidth[47];    // "Out of Time" pedestal widths
-  Float_t  fPedCorrCoeff[2][47]; // Fit of correlation in-time vs. out-of-time
+  Float_t  fMeanPedestal[48];   // Mean pedestal values 
+  Float_t  fMeanPedWidth[48];   // Mean pedestal widths 
+  Float_t  fOOTPedestal[48];    // "Out of Time" pedestal values
+  Float_t  fOOTPedWidth[48];    // "Out of Time" pedestal widths
+  Float_t  fPedCorrCoeff[2][48]; // Fit of correlation in-time vs. out-of-time
   // --- E calibration
   Float_t  fEnCalibration[6];   // Coeff. for energy calibration
   // --- Coefficients for tower calibration
index c683c4c54a15e3f1eaa74d56739dba01a482d7da..867063a23cff69d0da47bc062174113eb3d17ae1 100644 (file)
@@ -118,7 +118,7 @@ void AliZDCDigitizer::Exec(Option_t* /*option*/)
   // Execute digitization
 
   // ------------------------------------------------------------
-  // !!! 2nd ZDC set added (needed for trigger purposes!)
+  // !!! 2nd ZDC set added 
   // *** 1st 3 arrays are digits from REAL (simulated) hits
   // *** last 2 are copied from simulated digits
   // --- pm[0][...] = light in ZN right  [C, Q1, Q2, Q3, Q4]
@@ -266,9 +266,23 @@ void AliZDCDigitizer::Exec(Option_t* /*option*/)
           new(pdigit) AliZDCDigit(sectorL, digiL);
            treeD->Fill();
        }
-       //
-        //printf("\t AliZDCDigitizer -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
     }
+  } // Loop over detector
+  // Adding in-time digits for 2 reference PTM signals (after signal ch.)
+  // (for the moment the ref. signal is completely invented assuming a PMgain of 5*10^4!)
+  Int_t sectorRef[2];
+  sectorRef[1] = 5;
+  Int_t sigRef[2] = {100, 800};
+  for(Int_t iref=0; iref<2; iref++){
+     sectorRef[0] = 3*iref+1;
+     for(Int_t res=0; res<2; res++){
+       sigRef[res] += Pedestal(sectorRef[0], sectorRef[1], res);
+     }
+     /*printf("\t RefDigit added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n",
+         sectorRef[0], sectorRef[1], sigRef[0], sigRef[1]); // Chiara debugging!
+     */
+     new(pdigit) AliZDCDigit(sectorRef, sigRef);
+     treeD->Fill();     
   }
   //
   // --- Adding digits for out-of-time channels after signal digits
@@ -299,9 +313,24 @@ void AliZDCDigitizer::Exec(Option_t* /*option*/)
            treeD->Fill();
        }
        //
-        //printf("\t AliZDCDigitizer -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
     }
   }
+  // Adding out-of-time digits for 2 reference PTM signals (after out-of-time ch.)
+  Int_t sigRefoot[2];
+  for(Int_t iref=0; iref<2; iref++){
+     sectorRef[0] = 3*iref+1;
+     for(Int_t res=0; res<2; res++){
+       sigRefoot[res] = Pedestal(sectorRef[0], sectorRef[1], res);
+     }
+     /*printf("\t RefDigitoot added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n",
+         sectorRef[0], sectorRef[1], sigRefoot[0], sigRefoot[1]); // Chiara debugging!
+     */
+     new(pdigit) AliZDCDigit(sectorRef, sigRefoot);
+     treeD->Fill();
+     
+  }
+  //printf("\t AliZDCDigitizer -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
+
   // write the output tree
   loader->WriteDigits("OVERWRITE");
   loader->UnloadDigits();
@@ -434,21 +463,26 @@ Int_t AliZDCDigitizer::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const
   if(fIsCalibration == 0){
     Float_t meanPed, Pedwidth;
     Int_t index=0;
-    if(Det==1|| Det==2)                index = 10*(Det-1)+Quad+5*Res;   // ZN1, ZP1
-    else if(Det==3)            index = 10*(Det-1)+(Quad-1)+Res; // ZEM
-    else if(Det==4|| Det==5)   index = 10*(Det-2)+Quad+5*Res+4; // ZN2, ZP2
+    if(Quad!=5){
+      if(Det==1 || Det==2)     index = 10*(Det-1)+Quad+5*Res;   // ZN1, ZP1
+      else if(Det==3)          index = 10*(Det-1)+(Quad-1)+Res; // ZEM
+      else if(Det==4 || Det==5)        index = 10*(Det-2)+Quad+5*Res+4; // ZN2, ZP2
+    }
+    else index = 10*(Quad-1)+(Det-1)*1/3+2*Res+4; // Reference PMs
+    //
     meanPed = fCalibData->GetMeanPed(index);
     Pedwidth = fCalibData->GetMeanPedWidth(index);
     PedValue = gRandom->Gaus(meanPed,Pedwidth);
     //
     /*printf("\t Pedestal -> det = %d, quad = %d, res = %d - Ped[%d] = %d\n",
-       Det, Quad, index,(Int_t) PedValue); // Chiara debugging!
+       Det, Quad, Res, index,(Int_t) PedValue); // Chiara debugging!
     */
   }
-  
   // To create calibration object
-  else PedValue = gRandom->Gaus((40.+10.*gRandom->Rndm()),5.);
-  
+  else{
+    if(Res == 0) PedValue = gRandom->Gaus((35.+10.*gRandom->Rndm()),(0.5+0.2*gRandom->Rndm())); //High gain
+    else  PedValue = gRandom->Gaus((250.+100.*gRandom->Rndm()),(3.5+2.*gRandom->Rndm())); //Low gain
+  }
 
   return (Int_t) PedValue;
 }
index 5527d1eae55d1403eeb012c92a3c34253f9c5a38..84b330d2136f39f6562c325a6d974131262f3b81 100644 (file)
 /* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
-///
-/// This class provides access to ZDC digits in raw data.
-///
-/// It loops over all ZDC digits in the raw data given by the AliRawReader.
-/// The Next method goes to the next digit. If there are no digits left
-/// it returns kFALSE.
-/// Getters provide information about the current digit.
-///
+//                                                                          //
+// This class provides access to ZDC digits in raw data.                    //
+//                                                                          //
+// It loops over all ZDC digits in the raw data given by the AliRawReader.   //
+// The Next method goes to the next digit. If there are no digits left      //
+// it returns kFALSE.                                                       //
+// Getters provide information about the current digit.                     //
+//                                                                          //
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliZDCRawStream.h"
@@ -37,7 +37,7 @@ ClassImp(AliZDCRawStream)
 AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) :
   fRawReader(rawReader),
   fRawADC(0),   
-  fADCModule(-1),
+  fADCModule(0),        
   fADCValue(-1),        
   fADCGain(0)
 {
@@ -81,61 +81,67 @@ Bool_t AliZDCRawStream::Next()
   if(!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE;
   fIsADCDataWord = kFALSE;
   
-  //ADC Header
-  if(fRawADC & 0x2000000){
-      if(((fRawADC & 0x3f00) >> 8) == 24)      fADCModule=1; //fRawADC=2001800 -> 24 words -> 1st ADC module
-      else if(((fRawADC & 0x3f00) >> 8) == 20) fADCModule=2; //fRawADC=2001400 -> 20 words -> 2nd ADC module
-      //
-      //printf(" **** This is the ADC Header - %d data words will follow \n",((fRawADC & 0x3f00) >> 8));
-      //printf("  fRawADC = %x, fADCModule = %d\n",fRawADC, fADCModule);
+  if(fRawADC & 0x2000000){//ADC Header
+    fADCModule++;
+    //printf(" \t AliZDCRawStream -> Header ADC %d -> ADC datum contains %d data words \n",fADCModule,((fRawADC & 0x3f00) >> 8));
   }
-  else if((fRawADC & 0x4000000) || (fRawADC & 0x3000000)){
-    fSector[0] = 0;
-    //ADC EOB
-    /*if(fRawADC & 0x4000000){
-      printf(" **** This is the ADC End Of Block - event number %d\n",(fRawADC & 0xffffff));
-    }*/
+  else if((fRawADC & 0x4000000)){//ADC EOB
+    //printf(" \t AliZDCRawStream -> ADC %d End Of Block - event number %d\n\n",fADCModule, (fRawADC & 0xffffff));
+    fSector[0] = fSector[1] = 99;
   } 
-  //ADC Data Words
-  else{
-    /*printf("This is an ADC Data Word -> channel %d range %d\n",(fRawADC & 0x1e0000) >> 17, (fRawADC & 0x10000) >> 16);
-    if(fRawADC & 0x1000) printf("ZDCRawStream -> ADC overflow\n");
-    if(fRawADC & 0x2000) printf("ZDCRawStream -> ADC underflow\n");*/
-    //
-    fADCGain = (fRawADC & 0x10000) >> 16;
-    fADCValue = (fRawADC & 0xfff);   
+  else if((fRawADC & 0x6000000)){//Not valid datum
+    printf(" \t AliZDCRawStream -> Not valid datum in ADC module %d\n",fADCModule);
+  }
+  else{//ADC data word
     fIsADCDataWord = kTRUE;
-    //
-    Int_t vADCChannel = (fRawADC & 0x1e0000) >> 17;
-    if(fADCModule==1){  //1st ADC module
-      if(vADCChannel >= 0 && vADCChannel <= 4){ 
-        fSector[0] = 1;
-        fSector[1] = vADCChannel;
-      } 
-      else if(vADCChannel >= 8 && vADCChannel <= 12){
-        fSector[0] = 2;
-        fSector[1] = vADCChannel-8;
-      } 
-      else if(vADCChannel == 5 || vADCChannel == 13){
-        fSector[0] = 3;
-        fSector[1] = ((vADCChannel-5)/8)+1;
+    //printf(" \t \t ADC Data Word");
+    if(!(fRawADC & 0x1000) && !(fRawADC & 0x2000)){ // Valid ADC data
+      fADCGain = (fRawADC & 0x10000) >> 16;
+      fADCValue = (fRawADC & 0xfff);   
+      //
+      Int_t vADCChannel = (fRawADC & 0x1e0000) >> 17;
+      if(fADCModule==1 || fADCModule==3){  //1st & 3rd ADC modules
+        if(vADCChannel >= 0 && vADCChannel <= 4){ 
+          fSector[0] = 1; // ZN1
+          fSector[1] = vADCChannel;
+        } 
+        else if(vADCChannel >= 8 && vADCChannel <= 12){
+          fSector[0] = 2; // ZP1
+          fSector[1] = vADCChannel-8;
+        } 
+        else if(vADCChannel == 5 || vADCChannel == 13){
+          fSector[0] = 3; // ZEM 1,2
+          fSector[1] = ((vADCChannel-5)/8)+1;
+        }
       }
+      else if(fADCModule==2 || fADCModule==4){  //2nd & 4rth ADC modules
+        if(vADCChannel >= 0 && vADCChannel <= 4){ 
+          fSector[0] = 4; // ZN2
+          fSector[1] = vADCChannel;
+        } 
+        else if(vADCChannel >= 8 && vADCChannel <= 12){
+          fSector[0] = 5; // ZP2
+          fSector[1] = vADCChannel-8;
+        } 
+        else if(vADCChannel == 5 || vADCChannel == 13){
+          fSector[0] = (vADCChannel-5)/8+1; // PM Ref 1,2
+          fSector[1] = 5;
+        }
+      }
+      else{
+        AliWarning(" \t AliZDCRawStream -> No valid ADC module!");
+        printf(" ADCmod = %d\n", fADCModule);
+        fRawReader->AddMajorErrorLog(kInvalidADCModule);
+      }
+      /*printf(" \t \tADC %d ch %d range %d -> det %d quad %d value %x\n",
+           fADCModule, vADCChannel, fADCGain, fSector[0], fSector[1], fADCValue);//Chiara debugging
+      */
     }
-    else if(fADCModule==2){  //2nd ADC module
-      if(vADCChannel >= 0 && vADCChannel <= 4){ 
-        fSector[0] = 4;
-        fSector[1] = vADCChannel;
-      } 
-      else if(vADCChannel >= 8 && vADCChannel <= 12){
-        fSector[0] = 5;
-        fSector[1] = vADCChannel-8;
-      } 
-    }
-    else {
-      AliWarning("No valid ADC module!");
-      fRawReader->AddMajorErrorLog(kInvalidADCModule);
-    }      
-    
+    else if(fRawADC & 0x1000) 
+      printf(" \t \tADC %d ch %d range %d  overflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Overflow
+    else if(fRawADC & 0x2000) 
+      printf(" \t \tADC %d ch %d range %d  underflow\n",fADCModule, (fRawADC & 0x1e0000) >> 17, fADCGain); // Underflow
   }
+
   return kTRUE;
 }
index 440a3b622cc95245c7c600d3ebc4fb862eb58dd9..187e06d3bf8dafb5c22d15f16cc8f609d0880fd1 100644 (file)
@@ -23,7 +23,6 @@ class AliZDCRawStream: public TObject {
     virtual Bool_t   Next();
 
     Int_t            GetSector(Int_t i) const {return fSector[i];};
-    Int_t            GetADCModule() const {return fADCModule;};
     Int_t            GetADCValue() const {return fADCValue;};
     UInt_t           GetADCRaw() const {return fRawADC;};
     Int_t            GetADCGain() const {return fADCGain;};