]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Major fixes to the raw-data simulation. The ADC samples and signal width are added...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 10 Jun 2010 13:03:27 +0000 (13:03 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 10 Jun 2010 13:03:27 +0000 (13:03 +0000)
VZERO/AliVZERO.cxx
VZERO/AliVZEROBuffer.cxx
VZERO/AliVZEROBuffer.h
VZERO/AliVZERODigitizer.cxx
VZERO/AliVZERORawStream.cxx
VZERO/AliVZEROReconstructor.cxx
VZERO/AliVZEROdigit.cxx
VZERO/AliVZEROdigit.h

index 947d88fa82d214f2f96514bde79d483620706da7..9a076979f1c27047066aeb6c5ba4a96911e150f5 100755 (executable)
@@ -42,6 +42,7 @@
 #include "TBranch.h"
 #include "TClonesArray.h"
 #include "TStopwatch.h"
+#include "TParameter.h"
 
 // --- AliRoot header files ---
 #include "AliRun.h"
@@ -55,6 +56,7 @@
 #include "AliDAQ.h"
 #include "AliRawReader.h"
 #include "AliVZERORawStream.h"
+#include "AliVZEROCalibData.h"
 
 ClassImp(AliVZERO)
  //__________________________________________________________________
@@ -263,19 +265,6 @@ void AliVZERO::Digits2Raw()
    const char *fileName    = AliDAQ::DdlFileName("VZERO",0);
    AliVZEROBuffer* buffer  = new AliVZEROBuffer(fileName);
   
-   //  Verbose level
-   //  0: Silent
-   //  1: cout messages
-   //  2: txt files with digits 
-   //  BE CAREFUL, verbose level 2 MUST be used only for debugging and
-   //  it is highly suggested to use this mode only for debugging digits files
-   //  reasonably small, because otherwise the size of the txt files can reach
-   //  quickly several MB wasting time and disk space.
-  
-   ofstream ftxt;
-   buffer->SetVerbose(0);
-   Int_t verbose = buffer->GetVerbose();
-
    // Get Trigger information first
    // Read trigger inputs from trigger-detector object
    AliDataLoader * dataLoader = fLoader->GetDigitsDataLoader();
@@ -294,16 +283,44 @@ void AliVZERO::Digits2Raw()
    buffer->WriteTriggerScalers(); 
    buffer->WriteBunchNumbers(); 
   
-   // Now retrieve the channel information: charge+time and 
-   // dump it into ADC and Time arrays
-   // We assume here an ordered (by PMNumber) array of
-   // digits!!
+   Int_t aBBflagsV0A = 0;
+   Int_t aBBflagsV0C = 0;
+   Int_t aBGflagsV0A = 0;
+   Int_t aBGflagsV0C = 0;
+
+   if (digits->GetUserInfo()->FindObject("BBflagsV0A")) {
+     aBBflagsV0A = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BBflagsV0A"))->GetVal();
+   }
+   else
+     AliWarning("V0A beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+
+   if (digits->GetUserInfo()->FindObject("BBflagsV0C")) {
+     aBBflagsV0C = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BBflagsV0C"))->GetVal();
+   }
+   else
+     AliWarning("V0C beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
 
+   if (digits->GetUserInfo()->FindObject("BGflagsV0A")) {
+     aBGflagsV0A = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BGflagsV0A"))->GetVal();
+   }
+   else
+     AliWarning("V0A beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+
+   if (digits->GetUserInfo()->FindObject("BGflagsV0C")) {
+     aBGflagsV0C = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BGflagsV0C"))->GetVal();
+   }
+   else
+     AliWarning("V0C beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+
+   // Now retrieve the channel information: charge smaples + time and 
+   // dump it into ADC and Time arrays
    Int_t nEntries = Int_t(digits->GetEntries());
-   Float_t ADC[64];
-   Int_t PMNumber[64];
-   Float_t Time[64];
-   Bool_t Integrator[64];
+   Short_t aADC[64][AliVZEROdigit::kNClocks];
+   Float_t aTime[64];
+   Float_t aWidth[64];
+   Bool_t  aIntegrator[64];
+   Bool_t  aBBflag[64];
+   Bool_t  aBGflag[64];
   
    for (Int_t i = 0; i < nEntries; i++) {
      fVZERO->ResetDigits();
@@ -311,24 +328,26 @@ void AliVZERO::Digits2Raw()
      Int_t ndig = VZEROdigits->GetEntriesFast(); 
    
      if(ndig == 0) continue;
-     if(verbose == 2) {ftxt.open("VZEROdigits.txt",ios::app);}
      for(Int_t k=0; k<ndig; k++){
          AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k);
          // Convert aliroot channel k into FEE channel iChannel before writing data
-        Int_t iChannel      = buffer->GetOnlineChannel(k);             
-        ADC[iChannel]       = fVZERODigit->ADC();
-        PMNumber[iChannel]  = fVZERODigit->PMNumber();
-        Time[iChannel]      = fVZERODigit->Time();
-        Integrator[iChannel]= fVZERODigit->Integrator(); 
-         if(verbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
-                           <<PMNumber[k]<<"\tADC: "<< ADC[k] << "\tTime: "<< Time[k] << endl;} 
-        if(verbose == 2) {
-             ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
-                          <<PMNumber[k]<<"\tADC: "<< ADC[k] << "\tTime: "<< Time[k] << endl;}        
-//      printf("DDL: %s, channel: %d, PM: %d, ADC: %f, Time: %f \n", 
-//                 fileName,k,PMNumber[k],ADC[k],Time[k]); 
+        Int_t iChannel       = AliVZEROCalibData::GetBoardNumber(fVZERODigit->PMNumber()) * 8 +
+          AliVZEROCalibData::GetFEEChannelNumber(fVZERODigit->PMNumber());
+        for(Int_t iClock = 0; iClock < AliVZEROdigit::kNClocks; ++iClock) aADC[iChannel][iClock] = fVZERODigit->ChargeADC(iClock);
+        aTime[iChannel]      = fVZERODigit->Time();
+        aWidth[iChannel]     = fVZERODigit->Width();
+        aIntegrator[iChannel]= fVZERODigit->Integrator();
+        if(fVZERODigit->PMNumber() < 32) {
+          aBBflag[iChannel] = (aBBflagsV0C >> fVZERODigit->PMNumber()) & 0x1;
+          aBGflag[iChannel] = (aBGflagsV0C >> fVZERODigit->PMNumber()) & 0x1;
+        }
+        else {
+          aBBflag[iChannel] = (aBBflagsV0A >> (fVZERODigit->PMNumber()-32)) & 0x1;
+          aBGflag[iChannel] = (aBGflagsV0A >> (fVZERODigit->PMNumber()-32)) & 0x1;
+        }
+         AliDebug(1,Form("DDL: %s\tdigit number: %d\tPM number: %d\tADC: %f\tTime: %f",
+                        fileName,k,fVZERODigit->PMNumber(),aADC[k],aTime[k])); 
      }        
-   if(verbose==2) ftxt.close();
    }
 
    // Now fill raw data
@@ -339,16 +358,16 @@ void AliVZERO::Digits2Raw()
   
       for(Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) { 
          for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
-             buffer->WriteChannel(iChannel, (Int_t) ADC[iChannel], Time[iChannel], Integrator[iChannel]);       
+             buffer->WriteChannel(iChannel, aADC[iChannel], aIntegrator[iChannel]);       
          }
-         buffer->WriteBeamFlags(); 
+         buffer->WriteBeamFlags(&aBBflag[iChannel_Offset],&aBGflag[iChannel_Offset]); 
          buffer->WriteMBInfo(); 
          buffer->WriteMBFlags();   
          buffer->WriteBeamScalers(); 
       } 
-//      for(Int_t iChannel=0; iChannel < 8; iChannel++) {
-      for(Int_t iChannel=7; iChannel >= 0; iChannel--) {
-          buffer->WriteTiming(iChannel, (Int_t) ADC[iChannel], Time[iChannel]); 
+
+      for(Int_t iChannel = iCIU*8 + 7; iChannel >= iCIU*8; iChannel--) {
+          buffer->WriteTiming(aTime[iChannel], aWidth[iChannel]); 
       }
 
     // End of decoding of one CIU card
index ea68b6ca6d9197d08c397bf26a4e64f4899f140b..03243dfb96e3054d6698ad7af4df5b374379a5bb 100644 (file)
 
 #include <Riostream.h>
 #include <TObjArray.h>
+#include <TMath.h>
+
 #include "AliLog.h"
 #include "AliRawDataHeaderSim.h"
 #include "AliVZEROBuffer.h"
-
-//#include "TFile.h"
-//#include "TTree.h"
+#include "AliVZEROdigit.h"
 
 ClassImp(AliVZEROBuffer)
 
 //_____________________________________________________________________________
 AliVZEROBuffer::AliVZEROBuffer():TObject(),
-    fVerbose(0),
+    fRemainingWord(0),
     f()
 {
   //
@@ -42,7 +42,7 @@ AliVZEROBuffer::AliVZEROBuffer():TObject(),
 }
 //_____________________________________________________________________________
 AliVZEROBuffer::AliVZEROBuffer(const char* fileName):TObject(),
-    fVerbose(0),
+    fRemainingWord(0),
     f()
 {
   // Constructor
@@ -67,26 +67,6 @@ AliVZEROBuffer::~AliVZEROBuffer(){
   //delete fout;
 }
 
-//_____________________________________________________________________________
-AliVZEROBuffer::AliVZEROBuffer(const AliVZEROBuffer &source):TObject(source),
-   fVerbose(0),
-   f()
-
-{
-  // Copy Constructor
-  this->fVerbose=source.fVerbose;
-  return;
-}
-
-//_____________________________________________________________________________
-AliVZEROBuffer& AliVZEROBuffer::operator=(const AliVZEROBuffer &source)
-
-{
-  //Assigment operator
-  this->fVerbose=source.fVerbose;
-  return *this;
-}
-
 //_____________________________________________________________________________
 void AliVZEROBuffer::WriteTriggerInfo(UInt_t trigger) {
   // The method writes VZERO trigger information
@@ -131,56 +111,80 @@ void AliVZEROBuffer::WriteBunchNumbers() {
 }
 
 //_____________________________________________________________________________
-void AliVZEROBuffer::WriteChannel(Int_t cell, UInt_t ADC, Float_t /*Time*/, Bool_t integrator){
+void AliVZEROBuffer::WriteChannel(Int_t channel, Short_t *adc, Bool_t integrator){
   // It writes VZERO charge information into a raw data file. 
   // Being called by Digits2Raw
   
   UInt_t data = 0;
+  for(Int_t i = 0; i < AliVZEROdigit::kNClocks; ++i) {
+    if (adc[i] > 1023) {
+      AliWarning(Form("ADC (channel=%d) saturated: %d. Truncating to 1023",channel,adc[i]));
+      adc[i] = 1023;
+    }
+  }
   
-  if (/*ADC < 0 || */ ADC > 1023) {
-      AliInfo(Form("ADC saturated: %d. Truncating to 1023",ADC));
-      ADC = 1023;
+  if(channel%2 == 0) {
+    for(Int_t i = 0; i < (AliVZEROdigit::kNClocks/2); ++i) {
+      data =   (adc[2*i] & 0x3ff);
+      data |= ((integrator & 0x1) << 10);
+
+      data |= ((adc[2*i+1] & 0x3ff) << 16);
+      data |= ((!integrator & 0x1) << 26);
+
+      f->WriteBuffer((char*)&data,sizeof(data));
+    }
+    fRemainingWord = (adc[AliVZEROdigit::kNClocks-1] & 0x3ff);
+    fRemainingWord |= ((integrator & 0x1) << 10);
   }
+  else {
+    data = fRemainingWord;
+    data |= ((adc[0] & 0x3ff) << 16);
+    data |= ((integrator & 0x1) << 26);
+    f->WriteBuffer((char*)&data,sizeof(data));
 
-  if(cell%2 == 0)  
-  // Information about previous 10 interaction 
-  // Not available in the simulation...
-  // Even cell number -- skip  5 words
-    { for(Int_t i = 0; i < 5; i++)
-         { data = 0; 
-           f->WriteBuffer((char*)&data,sizeof(data)); }      
-      data = ADC & 0x3ff;
-      data |= (integrator & 0x1) << 10; 
-      f->WriteBuffer((char*)&data,sizeof(data)); }
-  else
-  // Information about previous 10 interaction 
-  // Odd cell number -- skip 4 words and shift ADC by 16 bits 
-    { for(Int_t i = 0; i < 4; i++)
-         { data = 0;
-           f->WriteBuffer((char*)&data,sizeof(data)); }           
-      data = (ADC & 0x3ff) << 16;
-      data |= (integrator & 0x1) << 26;
-      f->WriteBuffer((char*)&data,sizeof(data)); }
+    for(Int_t i = 1; i <= (AliVZEROdigit::kNClocks/2); ++i) {
+      data =   (adc[2*i-1] & 0x3ff);
+      data |= ((!integrator & 0x1) << 10);
+
+      data |= ((adc[2*i] & 0x3ff) << 16);
+      data |= ((integrator & 0x1) << 26);
+
+      f->WriteBuffer((char*)&data,sizeof(data));
+    }
+  }
     
-  data = 0;
-  // Information about following 10 interaction
-  // Not available in the simulation...
-  for(Int_t i = 0; i < 5; i++)
-      f->WriteBuffer((char*)&data,sizeof(data));     
 }
 
 //_____________________________________________________________________________
-void AliVZEROBuffer::WriteBeamFlags() {
+void AliVZEROBuffer::WriteBeamFlags(Bool_t *bbFlag, Bool_t *bgFlag) {
   // The method writes information about
   // the Beam-Beam and Beam-Gas flags i.e. 
   // 6  words for the 4 channels 
   // of half a CIU card
 
-
-  for(Int_t i = 0; i < 6; i++) {
+  // Beam-beam and beam-gas flags are available
+  // only for the triggered event-of-interest (sample index = 10)
+  // As soon as trigger simulation would become more complex
+  // and would allow to simulate neighbouring samples, this code
+  // should be extended in order to fill all (or fraction) of the
+  // flags
+  for(Int_t i = 0; i < 2; i++) {
     UInt_t data = 0;
     f->WriteBuffer((char*)&data,sizeof(data));
   }
+  {
+    UInt_t data = 0;
+    for(Int_t iChannel = 0; iChannel < 4; ++iChannel) {
+      if (bbFlag[iChannel]) data |= (1 << (2*iChannel + 16));
+      if (bgFlag[iChannel]) data |= (1 << (2*iChannel + 17));
+    }
+    f->WriteBuffer((char*)&data,sizeof(data));
+  }  
+  for(Int_t i = 0; i < 3; i++) {
+    UInt_t data = 0;
+    f->WriteBuffer((char*)&data,sizeof(data));
+  }
+
 }
 
 
@@ -229,26 +233,12 @@ void AliVZEROBuffer::WriteBeamScalers() {
 }
 
 //_____________________________________________________________________________
-void AliVZEROBuffer::WriteTiming(Int_t /*cell*/, UInt_t /* ADC*/, Float_t Time){
+void AliVZEROBuffer::WriteTiming(Float_t time, Float_t width) {
   // It writes the timing information into a raw data file. 
   // Being called by Digits2Raw
 
-  UInt_t data = 0;
-  Int_t  coarse1, coarse2, fine;
-
   // Writes the timing information
-//  data = Time & 0xfff;
-  
-  coarse1 = int( Time/25.0 );
-  coarse2 = int( (Time - 25*coarse1)/(25.0/8.0) );
-  fine    = int( (Time - 25*coarse1 -(25.0/8.0)*coarse2)/(25.0/256.0) );
-  
-  data  = (coarse1 & 0xf) << 8;
-  data |= (coarse2 & 0x7) << 5;  
-  data |= (fine & 0x1f);   
-  
-  // The signal width is not available the digits!
-  // To be added soon
-  // data |= (width & 0x7f) << 12;
+  UInt_t data = TMath::Nint(time/(25.0/256.0)) & 0xfff;
+  data |= (TMath::Nint(width/(25./64.)) & 0x7f) << 12;
   f->WriteBuffer((char*)&data,sizeof(data));
 }
index 63b813860917856f8ceefaf3815d3ab17f1ae56e..26afb35edc688d72d370e51cd8a4338129f1457e 100644 (file)
@@ -21,38 +21,23 @@ public:
   AliVZEROBuffer();
   AliVZEROBuffer(const char* fileName); //constructor
   virtual ~AliVZEROBuffer(); //destructor
-  AliVZEROBuffer(const AliVZEROBuffer &source); // copy constructor
-  AliVZEROBuffer& operator=(const AliVZEROBuffer &source); // ass. op.
   void    WriteTriggerInfo(UInt_t trigger);
   void    WriteTriggerScalers();
   void    WriteBunchNumbers();  
-  void    WriteChannel(Int_t cell,UInt_t ADC, Float_t Time, Bool_t integrator);
-  void    WriteBeamFlags();
+  void    WriteChannel(Int_t channel, Short_t *adc, Bool_t integrator);
+  void    WriteBeamFlags(Bool_t *bbFlag, Bool_t *bgFlag);
   void    WriteMBInfo();
   void    WriteMBFlags();  
   void    WriteBeamScalers();
-  void    WriteTiming(Int_t cell,UInt_t ADC, Float_t Time);
-
-  void    SetVerbose(Int_t val){fVerbose=val;}
-  Int_t   GetVerbose() const{return  fVerbose;} 
-  
-// Getter of Online channel number (as defined in the FEE readout) from the 
-// Offline channel (as defined by aliroot numbering convention):
-  Int_t              GetOnlineChannel(Int_t channel)  const
-       { Int_t  fOnlineChannel[64] = {39, 38, 37, 36, 35, 34, 33, 32, 
-                                      47, 46, 45, 44, 43, 42, 41, 40, 
-                                     55, 54, 53, 52, 51, 50, 49, 48, 
-                                     63, 62, 61, 60, 59, 58, 57, 56,
-                                      7,  6,  5,  4,  3,  2,  1,  0, 
-                                     15, 14, 13, 12, 11, 10,  9,  8,
-                                     23, 22, 21, 20, 19, 18, 17, 16, 
-                                     31, 30, 29, 28, 27, 26, 25, 24};
-               return fOnlineChannel[channel]; }
-              
+  void    WriteTiming(Float_t time, Float_t width);
+
 private:
-  Int_t fVerbose; //Verbosity level: 0-silent, 1:cout msg, 2: txt files for checking
+  AliVZEROBuffer(const AliVZEROBuffer &source); // copy constructor
+  AliVZEROBuffer& operator=(const AliVZEROBuffer &source); // ass. op.
+
+  UInt_t      fRemainingWord; // Remaining data word between even and odd channel's data
   AliFstream* f;      //The IO file name
-  ClassDef(AliVZEROBuffer,1)
+  ClassDef(AliVZEROBuffer,2)
 };
 
 #endif
index 227abe141705c62ec144d1ddab26cc4e13341963..3afa01fb18116c13189d5d146567bd1aabccaea7 100644 (file)
@@ -348,7 +348,7 @@ void AliVZERODigitizer::Exec(Option_t* /*option*/)
     Float_t thr = fCalibData->GetDiscriThr(ipmt)*kChargePerADC*maximum*fBinSize[ipmt]/integral2;
     Bool_t ltFound = kFALSE, ttFound = kFALSE;
     for (Int_t iBin = 0; iBin < fNBins[ipmt]; ++iBin) {
-      Float_t t = fBinSize[ipmt]*Float_t(iBin+0.5);
+      Float_t t = fBinSize[ipmt]*Float_t(iBin);
       if (fTime[ipmt][iBin] > thr) {
        if (!ltFound && (iBin < fNBinsLT[ipmt])) {
          ltFound = kTRUE;
@@ -421,7 +421,7 @@ void AliVZERODigitizer::AddDigit(Int_t PMnumber, Float_t adc, Float_t time, Floa
  
   TClonesArray &ldigits = *fDigits;  
         
-  new(ldigits[fNdigits++]) AliVZEROdigit(PMnumber,adc,time,width,kFALSE,kFALSE,integrator,chargeADC,labels);
+  new(ldigits[fNdigits++]) AliVZEROdigit(PMnumber,adc,time,width,integrator,chargeADC,labels);
         
 }
 //____________________________________________________________________________
index 1d1306d92d892991a317e54e4e028ce18d5ce81c..dac7e880c30534b33ab89875438c836062ce972b 100644 (file)
@@ -180,16 +180,14 @@ Bool_t AliVZERORawStream::Next()
 
     } 
 
-//    for(Int_t iChannel = iCIU*8; iChannel < (iCIU*8) + 8; iChannel++) { 
-//    In fact times are stored the other way around in raw data...
-      for(Int_t iChannel = (iCIU*8) + 7; iChannel >= iCIU*8; iChannel--) { 
-        UInt_t time = GetNextWord();
-       Float_t coarse1  = 25. * ((time >> 8) & 0xf );
-       Float_t coarse2  = 25. / 8. * ((time >> 5) & 0x7 );
-       Float_t fine     = 25. / 256. * (time & 0x1f);
-       // fTime[iChannel] = time & 0xfff;
-       fTime[iChannel]  = coarse1 + coarse2 + fine;
-       fWidth[iChannel] = 0.4 * ( (time >> 12) & 0x7f);   // HPTDC used in pairing mode
+    for(Int_t iChannel = (iCIU*8) + 7; iChannel >= iCIU*8; iChannel--) { 
+      UInt_t time = GetNextWord();
+      Float_t coarse1  = 25. * ((time >> 8) & 0xf );
+      Float_t coarse2  = 25. / 8. * ((time >> 5) & 0x7 );
+      Float_t fine     = 25. / 256. * (time & 0x1f);
+
+      fTime[iChannel]  = coarse1 + coarse2 + fine;
+      fWidth[iChannel] = 0.4 * ( (time >> 12) & 0x7f);   // HPTDC used in pairing mode
     }
     
     // End of decoding of one CIU card
index ff0806dda878c031a4b49c927059c3abb87912e4..5958687de38af195f4cf2cbb030f5c644d40b512 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <TH1F.h>
 #include <TF1.h>
+#include <TParameter.h>
 
 #include "AliRunLoader.h"
 #include "AliRawReader.h"
@@ -138,6 +139,7 @@ void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
      Float_t adc[64]; 
      Float_t time[64], width[64];  
      Bool_t BBFlag[64], BGFlag[64], integrator[64];
+     Short_t chargeADC[64][21];
      for(Int_t i=0; i<64; i++) {
        Int_t j   =  rawStream.GetOfflineChannel(i);
        adc[j]    = 0.0;
@@ -152,6 +154,7 @@ void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
        Int_t imax = -1;
        Float_t adcPedSub[21];
        for(Int_t iClock=0; iClock<21; iClock++){
+        chargeADC[j][iClock] = (Short_t)rawStream.GetPedestal(i,iClock);
         Bool_t iIntegrator = rawStream.GetIntegratorFlag(i,iClock);
         Int_t k = j+64*iIntegrator;
         adcPedSub[iClock] = rawStream.GetPedestal(i,iClock) - fCalibData->GetPedestal(k);
@@ -223,8 +226,20 @@ void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
          fESDVZEROfriend->SetBunchNumbersMB(iBunch,rawStream.GetBunchNumbersMB(iBunch));
      
 
+     Int_t aBBflagsV0A = 0;
+     Int_t aBBflagsV0C = 0;
+     Int_t aBGflagsV0A = 0;
+     Int_t aBGflagsV0C = 0;
+
      // Channels(aliroot numbering) will be ordered in the tree
      for(Int_t iChannel = 0; iChannel < 64; iChannel++) {
+       if(iChannel<32) {
+        if (BBFlag[iChannel]) aBBflagsV0C |= (1 << iChannel);
+        if (BGFlag[iChannel]) aBGflagsV0C |= (1 << iChannel);
+       } else {
+        if (BBFlag[iChannel]) aBBflagsV0A |= (1 << (iChannel-32));
+        if (BGFlag[iChannel]) aBGflagsV0A |= (1 << (iChannel-32));
+       }
          if(fCalibData->IsChannelDead(iChannel)){
            adc[iChannel]  = (Float_t) kInvalidADC; 
            time[iChannel] = (Float_t) kInvalidTime;     
@@ -232,9 +247,17 @@ void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
         if (adc[iChannel] > 0)
           new ((*fDigitsArray)[fDigitsArray->GetEntriesFast()])
              AliVZEROdigit(iChannel, adc[iChannel], time[iChannel],
-                          width[iChannel], BBFlag[iChannel], BGFlag[iChannel],integrator[iChannel]);
+                          width[iChannel],integrator[iChannel],
+                          chargeADC[iChannel]);
         
      }          
+
+     // Store the BB and BG flags in the digits tree (user info)
+     digitsTree->GetUserInfo()->Add(new TParameter<int>("BBflagsV0A",aBBflagsV0A));
+     digitsTree->GetUserInfo()->Add(new TParameter<int>("BBflagsV0C",aBBflagsV0C));
+     digitsTree->GetUserInfo()->Add(new TParameter<int>("BGflagsV0A",aBGflagsV0A));
+     digitsTree->GetUserInfo()->Add(new TParameter<int>("BGflagsV0C",aBGflagsV0C));
+
      digitsTree->Fill();
   }
 
@@ -259,19 +282,48 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
   Float_t    adc[64]; 
   Float_t   time[64]; 
   Float_t  width[64];
-  Bool_t  BBFlag[64];
-  Bool_t  BGFlag[64];
+  Bool_t aBBflag[64];
+  Bool_t aBGflag[64];
    
   for (Int_t i=0; i<64; i++){
        adc[i]    = 0.0;
        mult[i]   = 0.0;
        time[i]   = kInvalidTime;
        width[i]  = 0.0;
-       BBFlag[i] = kFALSE;
-       BGFlag[i] = kFALSE;
+       aBBflag[i] = kFALSE;
+       aBGflag[i] = kFALSE;
   }
      
-  // loop over VZERO entries to get multiplicity
+  Int_t aBBflagsV0A = 0;
+  Int_t aBBflagsV0C = 0;
+  Int_t aBGflagsV0A = 0;
+  Int_t aBGflagsV0C = 0;
+
+  if (digitsTree->GetUserInfo()->FindObject("BBflagsV0A")) {
+    aBBflagsV0A = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BBflagsV0A"))->GetVal();
+  }
+  else
+    AliWarning("V0A beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+
+  if (digitsTree->GetUserInfo()->FindObject("BBflagsV0C")) {
+    aBBflagsV0C = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BBflagsV0C"))->GetVal();
+  }
+  else
+    AliWarning("V0C beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+
+  if (digitsTree->GetUserInfo()->FindObject("BGflagsV0A")) {
+    aBGflagsV0A = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BGflagsV0A"))->GetVal();
+  }
+  else
+    AliWarning("V0A beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+
+  if (digitsTree->GetUserInfo()->FindObject("BGflagsV0C")) {
+    aBGflagsV0C = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BGflagsV0C"))->GetVal();
+  }
+  else
+    AliWarning("V0C beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+  
+
   Int_t nEntries = (Int_t)digitsTree->GetEntries();
   for (Int_t e=0; e<nEntries; e++) {
     digitsTree->GetEvent(e);
@@ -288,10 +340,22 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
         adc[pmNumber]   =  digit->ADC() - pedestal; 
         time[pmNumber]  =  CorrectLeadingTime(pmNumber,digit->Time(),adc[pmNumber]);
        width[pmNumber] =  digit->Width();
-       BBFlag[pmNumber]=  digit->BBFlag();
-       BGFlag[pmNumber]=  digit->BGFlag();
-
-       AliDebug(2,Form("PM = %d ADC = %f TDC %f",pmNumber, digit->ADC(),digit->Time()));
+       if(pmNumber < 32) {
+         aBBflag[pmNumber] = (aBBflagsV0C >> pmNumber) & 0x1;
+         aBGflag[pmNumber] = (aBGflagsV0C >> pmNumber) & 0x1;
+       }
+       else {
+         aBBflag[pmNumber] = (aBBflagsV0A >> (pmNumber-32)) & 0x1;
+         aBGflag[pmNumber] = (aBGflagsV0A >> (pmNumber-32)) & 0x1;
+       }
+
+       if (adc[pmNumber] > 0) AliDebug(1,Form("PM = %d ADC = %f TDC %f    Int %d (%d %d %d %d %d)    %f %f   %f %f    %d %d",pmNumber, adc[pmNumber],digit->Time(),
+                                              integrator,
+                                              digit->ChargeADC(8),digit->ChargeADC(9),digit->ChargeADC(10),
+                                              digit->ChargeADC(11),digit->ChargeADC(12),
+                                              fCalibData->GetPedestal(pmNumber),fCalibData->GetSigma(pmNumber),
+                                              fCalibData->GetPedestal(pmNumber+64),fCalibData->GetSigma(pmNumber+64),
+                                              aBBflag[pmNumber],aBGflag[pmNumber]));
 
        if(adc[pmNumber] > (fCalibData->GetPedestal(k) + GetRecoParam()->GetNSigmaPed()*fCalibData->GetSigma(k))) {
            mult[pmNumber] += adc[pmNumber]*fCalibData->GetMIPperADC(pmNumber);
@@ -304,8 +368,8 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
   fESDVZERO->SetADC(adc);
   fESDVZERO->SetTime(time);
   fESDVZERO->SetWidth(width);
-  fESDVZERO->SetBBFlag(BBFlag);
-  fESDVZERO->SetBGFlag(BGFlag);
+  fESDVZERO->SetBBFlag(aBBflag);
+  fESDVZERO->SetBGFlag(aBGflag);
 
   // now fill the V0 decision and channel flags
   {
index fefaedc0258c3993e43b1df7da737310cb525533..ce6ebc803124c1bd539561f625260e731e94a833 100644 (file)
@@ -24,8 +24,6 @@ AliVZEROdigit::AliVZEROdigit()
     fADC(0.),
     fTime(0.),
     fWidth(0.),
-    fBBFlag(0),
-    fBGFlag(0),
     fIntegrator(0)
 
 {
@@ -41,8 +39,6 @@ AliVZEROdigit::AliVZEROdigit(Int_t PMnumber, Float_t adc, Float_t time)
    fADC(adc),
    fTime(time),
    fWidth(0.),
-   fBBFlag(0),
-   fBGFlag(0),
    fIntegrator(0)
 {  
   // Constructor
@@ -52,7 +48,7 @@ AliVZEROdigit::AliVZEROdigit(Int_t PMnumber, Float_t adc, Float_t time)
 
 //__________________________________________________________________________
 AliVZEROdigit::AliVZEROdigit(Int_t   PMnumber, Float_t adc, Float_t time, 
-                             Float_t width, Bool_t BeamBeamFlag, Bool_t BeamGasFlag,
+                             Float_t width,
                             Bool_t integrator,
                             Short_t *chargeADC,
                             Int_t *labels)
@@ -61,8 +57,6 @@ fPMNumber(PMnumber),
 fADC(adc),
 fTime(time),
 fWidth(width),
-fBBFlag(BeamBeamFlag),
-fBGFlag(BeamGasFlag),
 fIntegrator(integrator)
 {  
   // Constructor
index ac2692dec2de9a58718c7c4c0451260bac5b52c4..4d7bb3a647b18b4208531a37a3d60049d05294f2 100644 (file)
@@ -14,7 +14,7 @@ class AliVZEROdigit: public AliDigit  {
     AliVZEROdigit();
     AliVZEROdigit(Int_t   PMnumber, Float_t  adc, Float_t time);
     AliVZEROdigit(Int_t   PMnumber, Float_t  adc, Float_t time, 
-                  Float_t TimeWidth, Bool_t BBFlag, Bool_t BGFlag,
+                  Float_t TimeWidth,
                  Bool_t  Integrator,
                  Short_t *chargeADC = 0,
                  Int_t *labels = 0);
@@ -27,8 +27,6 @@ class AliVZEROdigit: public AliDigit  {
     Float_t ADC()        const {return fADC;}
     Float_t Time()       const {return fTime;}
     Float_t Width()      const {return fWidth;} 
-    Bool_t  BBFlag()     const {return fBBFlag;} 
-    Bool_t  BGFlag()     const {return fBGFlag;}
     Bool_t  Integrator() const {return fIntegrator;}
     Short_t ChargeADC(Int_t clock) const {return (clock >= 0 && clock < kNClocks) ? fChargeADC[clock] : 0;}
     
@@ -37,12 +35,10 @@ class AliVZEROdigit: public AliDigit  {
     Float_t fADC;           // ADC response
     Float_t fTime;          // Time of Flight
     Float_t fWidth;         // Width of the time distribution
-    Bool_t  fBBFlag;        // Beam-Beam Flag given by Yannick in Raw Data only
-    Bool_t  fBGFlag;        // Beam-Gas  Flag given by Yannick in Raw Data only
     Bool_t  fIntegrator;    // Integrator used
     Short_t fChargeADC[kNClocks]; // ADC samples as present in raw data
 
-    ClassDef(AliVZEROdigit,4)  // VZERO Digit class
+    ClassDef(AliVZEROdigit,5)  // VZERO Digit class
 };
 
 #endif