Filling BB flags in digit with trigger simulator
authormbroz <Michal.Broz@cern.ch>
Fri, 30 Jan 2015 19:34:26 +0000 (20:34 +0100)
committermbroz <Michal.Broz@cern.ch>
Fri, 30 Jan 2015 19:34:26 +0000 (20:34 +0100)
AD/ADbase/AliADCalibData.cxx
AD/ADbase/AliADConst.h
AD/ADrec/AliADReconstructor.cxx
AD/ADrec/AliADTrigger.cxx
AD/ADsim/AliADDigitizer.cxx
AD/ADsim/AliADDigitizer.h
AD/ADsim/AliADTriggerSimulator.cxx
AD/ADsim/AliADTriggerSimulator.h

index 37f1304..7ec428b 100644 (file)
@@ -51,9 +51,9 @@ AliADCalibData::AliADCalibData():
   // default constructor
   
     for(int t=0; t<16; t++) {
-        fMeanHV[t]      = 1500.0;
+        fMeanHV[t]      = 1400.0;
         fWidthHV[t]     = 0.0; 
-       fTimeOffset[t]  = 0.0;
+       fTimeOffset[t]  = 230.0;
         fTimeGain[t]    = 1.0;
        fDeadChannel[t]= kFALSE;
        fDiscriThr[t]  = 2.5;
@@ -67,9 +67,9 @@ AliADCalibData::AliADCalibData():
     for(int i=0; i<kNCIUBoards ;i++) {
        fTimeResolution[i]  = 25./256.;     // Default time resolution
        fWidthResolution[i] = 25./64.;     // Default time width resolution
-       fMatchWindow[i] = 4;
+       fMatchWindow[i] = 16;
        fSearchWindow[i] = 16;
-       fTriggerCountOffset[i] = 3247;
+       fTriggerCountOffset[i] = 3553;
        fRollOver[i] = 3563;
     }
     for(int i=0; i<kNCIUBoards ;i++) {
@@ -82,7 +82,8 @@ AliADCalibData::AliADCalibData():
        fPedestalSubtraction[i] = kFALSE;
        }
     for(Int_t j = 0; j < 16; ++j) {
-       fEnableCharge[j] = fEnableTiming[j] = kFALSE;
+       fEnableCharge[j] = kFALSE;
+       fEnableTiming[j] = kTRUE;
        fPedestalOdd[j] = fPedestalEven[j] = 0;
        fPedestalCutOdd[j] = fPedestalCutEven[j] = 0;
        }
@@ -117,7 +118,7 @@ AliADCalibData::AliADCalibData(const char* name) :
    SetName(namst.Data());
    SetTitle(namst.Data());
    for(int t=0; t<16; t++) {
-       fMeanHV[t]      = 100.0;
+       fMeanHV[t]      = 1500.0;
        fWidthHV[t]     = 0.0; 
        fTimeOffset[t]  = 5.0;
        fTimeGain[t]    = 1.0;
@@ -148,7 +149,8 @@ AliADCalibData::AliADCalibData(const char* name) :
        fPedestalSubtraction[i] = kFALSE;
        }
     for(Int_t j = 0; j < 16; ++j) {
-       fEnableCharge[j] = fEnableTiming[j] = kFALSE;
+       fEnableCharge[j] = kFALSE;
+       fEnableTiming[j] = kTRUE;
        fPedestalOdd[j] = fPedestalEven[j] = 0;
        fPedestalCutOdd[j] = fPedestalCutEven[j] = 0;
        }
index 96bb176..a05c52f 100644 (file)
@@ -4,7 +4,7 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. */
 
 const Float_t kIntTimeRes = 0.39; // intrinsic time resolution of the scintillator
-const Float_t kADOffset = -1338.6; // general V0 offset between the TDCs and the trigger
+const Float_t kADOffset = -1488.6; // general AD offset between the TDCs and the trigger
 const Int_t   kNClocks = 21; // Number of ADC clocks that are read out
 const Float_t kChargePerADC = 0.6e-12; // Charge per ADC
 const Int_t   kNPhotonsPerMIP = 30000;// Number of photons per MIP
index c0dc36b..0ea81c9 100644 (file)
@@ -264,11 +264,11 @@ void AliADReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,AliE
   fESDAD->SetBGFlag(aBGflag);
   //fESDAD->SetBit(AliESDAD::kCorrectedForSaturation,kTRUE);
 
-  /*/ now fill the V0 decision and channel flags
+  /*/ now fill the AD decision and channel flags
   {
-    AliADTriggerMask triggerMask;
-    triggerMask.SetRecoParam(GetRecoParam());
-    triggerMask.FillMasks(fESDAD, fCalibData, fTimeSlewing);
+    AliADDecision offlineDecision;
+    offlineDecision.SetRecoParam(GetRecoParam());
+    offlineDecision.FillDecisions(fESDAD, fCalibData, fTimeSlewing);
   }/*/
 
   if (esd) { 
@@ -278,7 +278,7 @@ void AliADReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,AliE
      AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend");
      if (fr) {
         AliDebug(1, Form("Writing AD friend data to ESD tree"));
-        //fr->SetADfriend(fESDADfriend);
+        fr->SetADfriend(fESDADfriend);
     }
   }
 
index 3677ea5..1ed3f9b 100644 (file)
@@ -63,8 +63,8 @@ void AliADTrigger::CreateInputs()
    fInputs.AddLast( new AliTriggerInput( "AD_CTA2_OR_CTC2",   "AD", 0 ) );
    fInputs.AddLast( new AliTriggerInput( "AD_MTA_AND_MTC",   "AD", 0 ) );
    fInputs.AddLast( new AliTriggerInput( "AD_MTA_OR_MTC",   "AD", 0 ) );
-   fInputs.AddLast( new AliTriggerInput( "0ADA",   "AD", 0 ) );
-   fInputs.AddLast( new AliTriggerInput( "0ADC",   "AD", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "0ABA",   "AD", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "0ABC",   "AD", 0 ) );
    fInputs.AddLast( new AliTriggerInput( "AD_BGA_OR_BGC",   "AD", 0 ) );
    fInputs.AddLast( new AliTriggerInput( "AD_BEAMGAS",   "AD", 0 ) );
 }
index 0fbde40..2dcdb4d 100644 (file)
@@ -53,6 +53,7 @@
 #include "AliADdigit.h"
 #include "AliADDigitizer.h"
 #include "AliADSDigit.h"
+#include "AliADTriggerSimulator.h"
 
 ClassImp(AliADDigitizer)
 
@@ -198,22 +199,26 @@ Bool_t AliADDigitizer::Init()
     fNBinsLT[i] = TMath::Nint(((Float_t)(fCalibData->GetMatchWindow(board)+1)*25.0)/
                              fCalibData->GetTimeResolution(board));
     fBinSize[i] = fCalibData->GetTimeResolution(board);
-
-    fHptdcOffset[i] =  delays->GetBinContent(i+1);
+    
+    fHptdcOffset[i] = (((Float_t)fCalibData->GetRollOver(board)-
+                       (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0
+                      //+fCalibData->GetTimeOffset(i)
+                      +delays->GetBinContent(16-i) - 250);
+                      //-l1Delay-
+                      //-phase->GetMeanPhase()
+                      //+kADOffset);
                       
     fClockOffset[i] = (((Float_t)fCalibData->GetRollOver(board)-
-                       (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0+
-                      fCalibData->GetTimeOffset(i)-
-                      l1Delay+
-                      kADOffset);
+                       (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0
+                      +fCalibData->GetTimeOffset(i) - 250);
+                      //-l1Delay
+                      //+kADOffset);
 
     fTime[i] = new Float_t[fNBins[i]];
     memset(fTime[i],0,fNBins[i]*sizeof(Float_t));
-    
-   // AliWarning(Form("PMT %d,PM gain %f, fNBins %d, TimeBinSize %f,",i, fPmGain[i], fNBins[i],fBinSize[i]));
-    
+      
   }
-
+  //std::cout<<"AD: "<<" fNBins = "<<fNBins[0]<<" fNBinsLT = "<<fNBinsLT[0]<<" fHptdcOffset = "<<fHptdcOffset[0]<<" fClockOffset = "<<fClockOffset[0]<<std::endl;
   return kTRUE;
 
 }
@@ -306,7 +311,7 @@ void AliADDigitizer::DigitizeHits()
           }
           Float_t dt_scintillator = gRandom->Gaus(0,kIntTimeRes);
           Float_t t = dt_scintillator + hit->GetTof();
-          //t += fHptdcOffset[pmt];
+          t += fHptdcOffset[pmt];
           
           Float_t charge = nPhot*fPmGain[pmt]*fBinSize[pmt]/integral;
             
@@ -314,6 +319,8 @@ void AliADDigitizer::DigitizeHits()
             
             Int_t firstBin = TMath::Max(0,(Int_t)((tPhE-kPMRespTime)/fBinSize[pmt]));
             Int_t lastBin = TMath::Min(fNBins[pmt]-1,(Int_t)((tPhE+2.*kPMRespTime)/fBinSize[pmt]));
+            //std::cout<<"Bins: "<<firstBin*fBinSize[pmt]<<" - "<<lastBin*fBinSize[pmt]<<std::endl;
+            //std::cout<<"Bins: "<<firstBin<<" - "<<lastBin<<std::endl;
             
             for(Int_t iBin = firstBin; iBin <= lastBin; ++iBin) {
               Float_t tempT = fBinSize[pmt]*(0.5+iBin)-tPhE;
@@ -356,8 +363,7 @@ void AliADDigitizer::DigitizeSDigits()
          }
        }
       }
-      //Float_t tadc = t - fClockOffset[ipmt];
-      Float_t tadc = t;
+      Float_t tadc = t - fClockOffset[ipmt];
       Int_t clock = kNClocks/2 - Int_t(tadc/25.0);
       if (clock >= 0 && clock < kNClocks)
        fAdc[ipmt][clock] += fTime[ipmt][iBin]/kChargePerADC;
@@ -382,7 +388,10 @@ void AliADDigitizer::DigitizeSDigits()
       fAdc[j][iClock]  += gRandom->Gaus(fAdcPedestal[j][integrator], fAdcSigma[j][integrator]);
     }
   }
-       
+  //Fill BB and BG flags in trigger simulator
+  AliADTriggerSimulator * triggerSimulator = new AliADTriggerSimulator();
+  triggerSimulator->FillFlags(fBBFlag,fBGFlag,fLeadingTime);
+       
 }
 
 //____________________________________________________________________________ 
@@ -473,7 +482,6 @@ void AliADDigitizer::WriteDigits(AliLoader *loader)
   TTree* treeD  = loader->TreeD();
   DigitsArray();
   treeD->Branch("ADDigit", &fDigits); 
-  //fAD->MakeBranchInTree(treeD,"AD",&fDigits,1000,"");
   
   Short_t *chargeADC = new Short_t[kNClocks];
   for (Int_t i=0; i<16; i++) {      
@@ -482,7 +490,7 @@ void AliADDigitizer::WriteDigits(AliLoader *loader)
       if (tempadc > 1023) tempadc = 1023;
       chargeADC[j] = tempadc;
     }
-    AddDigit(i, fLeadingTime[i], fTimeWidth[i], Bool_t((10+fEvenOrOdd)%2), chargeADC, fLabels[i]);
+    AddDigit(i, fLeadingTime[i], fTimeWidth[i], Bool_t((10+fEvenOrOdd)%2), chargeADC, fBBFlag[i], fBGFlag[i], fLabels[i]);
   }
   delete [] chargeADC;
 
@@ -520,14 +528,14 @@ void AliADDigitizer::WriteSDigits(AliLoader *loader)
 
 
 //____________________________________________________________________________
-void AliADDigitizer::AddDigit(Int_t pmnumber, Float_t time, Float_t width, Bool_t integrator, Short_t *chargeADC, Int_t *labels) 
+void AliADDigitizer::AddDigit(Int_t pmnumber, Float_t time, Float_t width, Bool_t integrator, Short_t *chargeADC, Bool_t bbFlag, Bool_t bgFlag, Int_t *labels) 
  { 
  
 // Adds Digit 
  
   TClonesArray &ldigits = *fDigits;  
         
-  new(ldigits[fNdigits++]) AliADdigit(pmnumber,time,width,integrator,chargeADC,labels);
+  new(ldigits[fNdigits++]) AliADdigit(pmnumber,time,width,integrator,chargeADC,bbFlag,bgFlag,labels);
         
 }
 //____________________________________________________________________________
index 803aafc..b966ca2 100644 (file)
@@ -46,7 +46,7 @@ public:
    void WriteSDigits(AliLoader *loader);
    void ReadSDigits();
 
-   void AddDigit(Int_t pmnumber, Float_t time, Float_t width, Bool_t integrator, Short_t *chargeADC, Int_t *labels);
+   void AddDigit(Int_t pmnumber, Float_t time, Float_t width, Bool_t integrator, Short_t *chargeADC, Bool_t bbFlag, Bool_t bgFlag, Int_t *labels);
    void AddSDigit(Int_t pmnumber, Int_t nbins, Float_t *charges, Int_t *labels);
    TClonesArray* DigitsArray(); 
    TClonesArray* SDigitsArray(); 
@@ -81,6 +81,8 @@ public:
    Float_t  fAdc[16][kNClocks];      //! Container for ADC samples
    Float_t  fLeadingTime[16];        //! Leading time container
    Float_t  fTimeWidth[16];          //! Time width container
+   Bool_t   fBBFlag[16];            //! Container for BB flags
+   Bool_t   fBGFlag[16];            //! Container for BG flags
    Float_t  fAdcPedestal[16][2];     //! Pedestals, one per integrator
    Float_t  fAdcSigma[16][2];        //! Sigma of pedestals
    Float_t  fPmGain[16];             //! PMT gains
index 2d94b1f..0ca387a 100644 (file)
@@ -200,16 +200,28 @@ void AliADTriggerSimulator::LoadClockOffset()
 
   for(Int_t board = 0; board < kNCIUBoards; ++board) {
     fClockOffset[board] = (((Float_t)calibdata->GetRollOver(board)-
-                           (Float_t)calibdata->GetTriggerCountOffset(board))*25.0-
-                          l1Delay+
-                          kADOffset);
+                           (Float_t)calibdata->GetTriggerCountOffset(board))*25.0
+                             );
+                            //-l1Delay+
+                            //+kADOffset);
     AliDebug(1,Form("Board %d Offset %f",board,fClockOffset[board]));
   }
 }
+//_____________________________________________________________________________
+void AliADTriggerSimulator::FillFlags(Bool_t *bbFlag, Bool_t *bgFlag, Float_t time[16]){
 
+  for(Int_t i = 0; i<16; i++){
+       Int_t board   = AliADCalibData::GetBoardNumber(i);
+       Float_t temptime = time[i] - fClockOffset[board];
+       bbFlag[i] = fCalibData->GetEnableTiming(i) && fBBGate[board]->IsInCoincidence(temptime);
+       bgFlag[i] = fCalibData->GetEnableTiming(i) && fBGGate[board]->IsInCoincidence(temptime);
+       //AliInfo(Form("Ch %d BB=%d BG=%d",i,bbFlag[i],bgFlag[i] ));
+       }
+}
 //_____________________________________________________________________________
 void AliADTriggerSimulator::Run() {
-       //AliInfo("Generating AD Triggers");
+//     AliInfo("Generating AD Triggers");
+//     Print("");
        
        // Loop over AD entries
        Int_t nEntries = (Int_t)fDigitsTree->GetEntries();
@@ -246,15 +258,15 @@ void AliADTriggerSimulator::Run() {
                                         digit->ChargeADC(8),digit->ChargeADC(9),digit->ChargeADC(10),
                                         digit->ChargeADC(11),digit->ChargeADC(12),digit->ChargeADC(13),
                                         digit->ChargeADC(14),digit->ChargeADC(15)));
+                       //for(Int_t i=0; i<21; i++) std::cout<<digit->ChargeADC(i)<<" ";
+                       //std::cout<<std::endl;
+                       //std::cout<<"Time - Offset = "<<time<<std::endl;
                        AliDebug(10,Form(" PM nb : %d ; TDC= %f(%f)  Enable Time %d charge %d inCoin %d charge %f",
                                         pmNumber,time,digit->Time(),
                                         fCalibData->GetEnableTiming(pmNumber),fCalibData->GetEnableCharge(pmNumber),
                                         fBBGate[board]->IsInCoincidence(time),fCharges[pmNumber]));
                        fBBFlags[pmNumber] = fCalibData->GetEnableTiming(pmNumber) && fBBGate[board]->IsInCoincidence(time);
                        fBGFlags[pmNumber] = fCalibData->GetEnableTiming(pmNumber) && fBGGate[board]->IsInCoincidence(time);
-                       // Store the BB and BG flags in the digits tree
-                       digit->SetBBflag(fBBFlags[pmNumber]);
-                       digit->SetBGflag(fBGFlags[pmNumber]);
                        
                } // end of loop over digits
        } // end of loop over events in digits tree
index 0c0857e..c217856 100644 (file)
@@ -64,6 +64,7 @@ public:
        void SetBeamGas()               { (fTriggerWord += 0x1<<15);};
        
        void Run();
+       void FillFlags(Bool_t *bbFlag, Bool_t *bgFlag, Float_t time[16]);
        virtual void Print(Option_t* /* opt */) const;
        
 private:
@@ -91,9 +92,9 @@ private:
        TTree* fDigitsTree; //Pointer to AD digit tree
        TClonesArray* fDigits; //Pointer to AD digit array
        
-       Bool_t fBBFlags[64]; // Individual BB Flags
-       Bool_t fBGFlags[64]; // Individual BG Flags
-       Float_t  fCharges[64]; // Individual Charge
+       Bool_t fBBFlags[16]; // Individual BB Flags
+       Bool_t fBGFlags[16]; // Individual BG Flags
+       Float_t  fCharges[16]; // Individual Charge
        
        UShort_t fTriggerWord; // Word holding the 16 triggers return by the FEE