]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALQADataMakerRec.cxx
Several updates (F. Colamaria)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQADataMakerRec.cxx
index e804e8d9d6cfae570adaae112c12ff05c4f95856..49c4ad0e50d8483ebf1732eee761ea82cc1b9230 100644 (file)
@@ -37,6 +37,7 @@ Also calculate the ratio of amplitude from LED Monitor system (current/Reference
 #include <TLine.h>
 #include <TText.h>
 #include <TProfile.h> 
+#include <TProfile2D.h> 
 #include <TStyle.h>
 // --- Standard library ---
 
@@ -69,6 +70,8 @@ Also calculate the ratio of amplitude from LED Monitor system (current/Reference
 #include "AliCaloRawAnalyzerKStandard.h"
 #include "AliCaloRawAnalyzerPeakFinder.h"
 #include "AliCaloRawAnalyzerCrude.h"
+#include "AliEMCALGeometry.h"
+#include "AliEMCALTriggerSTURawStream.h"
 
 #include "AliCaloRawAnalyzerFactory.h"
 
@@ -82,7 +85,8 @@ AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(fitAlgorithm fitAlgo) :
   fFittingAlgorithm(0),
   fRawAnalyzer(0),
   fRawAnalyzerTRU(0),
-  fSuperModules(10), // FIXME!!! number of SuperModules; 10 for 2011; update default for later runs 
+       fGeom(0),
+  fSuperModules(12), // FIXME!!! number of SuperModules; 12 for 2012; update default for later runs 
   fFirstPedestalSample(0),
   fLastPedestalSample(3),
   fFirstPedestalSampleTRU(0),
@@ -115,6 +119,8 @@ AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(fitAlgorithm fitAlgo) :
   
   fRawAnalyzerTRU->SetFixTau(kTRUE); 
   fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper
+
+       fGeom = new AliEMCALGeometry("EMCAL_COMPLETE12SMV1", "EMCAL");
 //  for (Int_t sm = 0 ; sm < fSuperModules ; sm++){
 //    fTextSM[sm] = NULL ;
 //  }
@@ -126,6 +132,7 @@ AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(const AliEMCALQADataMakerRec& qad
   fFittingAlgorithm(0),
   fRawAnalyzer(0),
   fRawAnalyzerTRU(0),
+       fGeom(0),
   fSuperModules(qadm.GetSuperModules()), 
   fFirstPedestalSample(qadm.GetFirstPedestalSample()), 
   fLastPedestalSample(qadm.GetLastPedestalSample()),  
@@ -324,7 +331,9 @@ void AliEMCALQADataMakerRec::InitRaws()
   Int_t nSMSectors = fSuperModules / 2; // 2 SMs per sector
   Int_t nbinsZ = 2*AliEMCALGeoParams::fgkEMCALCols;
   Int_t nbinsPhi = nSMSectors * AliEMCALGeoParams::fgkEMCALRows;
-   
+       
+  Int_t nTRUCols = 2*AliEMCALGeoParams::fgkEMCALTRUCols; //total TRU columns for 2D TRU histos
+  Int_t nTRURows = nSMSectors*AliEMCALGeoParams::fgkEMCALTRUsPerSM*AliEMCALGeoParams::fgkEMCALTRURows; //total TRU rows for 2D TRU histos
    // counter info: number of channels per event (bins are SM index)
   TProfile * h0 = new TProfile("hLowEmcalSupermodules", "Low Gain EMC: # of towers vs SuperMod;SM Id;# of towers",
                               fSuperModules, -0.5, fSuperModules-0.5, profileOption) ;
@@ -385,13 +394,15 @@ void AliEMCALQADataMakerRec::InitRaws()
   Add2RawsList(hT2, kNtotTRU, expert, !image, !saveCorr) ;
 
   // L0 trigger hits: # of hits (bins are TRU channels)
-  TH1I * hT3 = new TH1I("hTRUEmcalL0hits", "L0 trigger hits: Total number of 2x2 L0 generated", nTot2x2, -0.5, nTot2x2);
-  hT3->Sumw2();
-  Add2RawsList(hT3, kNL0TRU, !expert, image, !saveCorr);
+  TH2I * hT3 = new TH2I("hTRUEmcalL0hits", "L0 trigger hits: Total number of 2x2 L0 generated",  nTRUCols, -0.5, nTRUCols - 0.5, nTRURows, -0.5, nTRURows-0.5);
+  hT3->SetOption("COLZ");
+  //hT3->Sumw2();
+  Add2RawsList(hT3, kNL0TRU, expert, image, !saveCorr);
 
   // L0 trigger hits: average time (bins are TRU channels)
-  TProfile * hT4 = new TProfile("hTRUEmcalL0hitsAvgTime", "L0 trigger hits: average time bin", nTot2x2, -0.5, nTot2x2, profileOption); 
-  Add2RawsList(hT4, kTimeL0TRU, !expert, image, !saveCorr);
+  TProfile2D * hT4 = new TProfile2D("hTRUEmcalL0hitsAvgTime", "L0 trigger hits: average time bin", nTRUCols, -0.5, nTRUCols - 0.5, nTRURows, -0.5, nTRURows-0.5, profileOption);
+  hT4->SetOption("COLZ");
+  Add2RawsList(hT4, kTimeL0TRU, expert, image, !saveCorr);
 
   // L0 trigger hits: first in the event (bins are TRU channels)
   TH1I * hT5 = new TH1I("hTRUEmcalL0hitsFirst", "L0 trigger hits: First hit in the event", nTot2x2, -0.5, nTot2x2);
@@ -463,11 +474,11 @@ void AliEMCALQADataMakerRec::InitRaws()
   h15->GetZaxis()->SetNdivisions(3);
   h15->UseCurrentStyle();
   h15->SetDirectory(0);
-  Add2RawsList(h15, k2DRatioAmp, !expert, image, !saveCorr) ;
+  Add2RawsList(h15, k2DRatioAmp, expert, image, !saveCorr) ;
 
   TH1F * h16 = new TH1F("hRatioDist", "Amplitude_{current run}/Amplitude_{reference run} ratio distribution", nTot, 0., 2.);
-  h16->SetMinimum(0.1); 
-  h16->SetMaximum(100.);
+  // h16->SetMinimum(0.1); 
+  // h16->SetMaximum(100.);
   gStyle->SetOptStat(0);
   h16->UseCurrentStyle();
   h16->SetDirectory(0);
@@ -484,16 +495,50 @@ void AliEMCALQADataMakerRec::InitRaws()
   hL10->UseCurrentStyle();
   hL10->SetDirectory(0);
 //  hL10->SetOption("E");
-  Add2RawsList(hL10, kLEDMonRatio, !expert, image, !saveCorr) ;
+  Add2RawsList(hL10, kLEDMonRatio, expert, image, !saveCorr) ;
 
   TH1F * hL11 = new TH1F("hMaxMinusMinLEDMonRatioDist", "LEDMon amplitude, Ratio distribution", nTotLEDMon, 0, 2);
-  hL11->SetMinimum(0.1) ;
+  // hL11->SetMinimum(0.1) ;
   gStyle->SetOptStat(0);
   hL11->UseCurrentStyle();
   hL11->SetDirectory(0);
-  Add2RawsList(hL11, kLEDMonRatioDist, !expert, image, !saveCorr) ;
+  Add2RawsList(hL11, kLEDMonRatioDist, expert, image, !saveCorr) ;
   
   GetCalibRefFromOCDB();   
+
+
+       //STU histgrams
+
+ //histos
+ Int_t nSTUCols = AliEMCALGeoParams::fgkEMCALSTUCols;
+ Int_t nSTURows = AliEMCALGeoParams::fgkEMCALSTURows;
+//             kAmpL1, kGL1, kJL1,
+//             kGL1V0, kJL1V0, kSTUTRU  
+       
+ TProfile2D *hS0 = new TProfile2D("hL1Amp", "Mean STU signal per Row and Column", nSTUCols, -0.5, nSTUCols-0.5, nSTURows, -0.5, nSTURows-0.5);
+ Add2RawsList(hS0, kAmpL1, expert, !image, !saveCorr) ;
+       
+ TH2F *hS1 = new TH2F("hL1Gamma", "L1 Gamma patch position (FastOR top-left)", nSTUCols, -0.50, nSTUCols-0.5, nSTURows + 5, -0.5, nSTURows-0.5 + 5); //+5 for better visible error box
+ Add2RawsList(hS1, kGL1, !expert, image, !saveCorr) ;
+       
+ TH2F *hS2 = new TH2F("hL1Jet", "L1 Jet patch position (FastOR top-left)", 12, -0.5, nSTUCols-0.5, 16, 0, nSTURows-0.5);
+ Add2RawsList(hS2, kJL1, !expert, image, !saveCorr) ;
+       
+ TH2I *hS3 = new TH2I("hL1GV0", "L1 Gamma patch amplitude versus V0 signal", 500, 0, 50000, 1500, 0, 1500);
+ Add2RawsList(hS3, kGL1V0, expert, image, !saveCorr) ;
+       
+ TH2I *hS4 = new TH2I("hL1JV0", "L1 Jet patch amplitude versus V0 signal", 500, 0, 50000, 1000, 0, 1000);
+ Add2RawsList(hS4, kJL1V0, expert, !image, !saveCorr) ;
+
+ TH1I *hS5 = new TH1I("hFrameR","Link between TRU and STU", 32, 0, 32);
+ Add2RawsList(hS5, kSTUTRU, !expert, image, !saveCorr) ;
+
+ hS0->SetOption("COLZ");
+ hS1->SetOption("COLZ");
+ hS2->SetOption("COLZ");
+ hS3->SetOption("COLZ");
+ hS4->SetOption("COLZ");
+
   //
   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
 }
@@ -549,14 +594,13 @@ void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   if (rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent) { 
     SetEventSpecie(AliRecoParam::kCalib) ;     
   }
-  
+
   const Int_t nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48
   const Int_t nRows        = AliEMCALGeoParams::fgkEMCALRows; // number of rows per SuperModule
   const Int_t nStripsPerSM = AliEMCALGeoParams::fgkEMCALLEDRefs; // number of strips per SuperModule
   const Int_t n2x2PerSM    = AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // number of TRU 2x2's per SuperModule
   const Int_t n2x2PerTRU   = AliEMCALGeoParams::fgkEMCAL2x2PerTRU;
-       const Int_t nTot2x2                      = fSuperModules * n2x2PerSM; // total TRU channels
-
+  const Int_t nTot2x2     = fSuperModules * n2x2PerSM; // total TRU channel
 
   // SM counters; decl. should be safe, assuming we don't get more than expected SuperModules..
   Int_t nTotalSMLG[AliEMCALGeoParams::fgkEMCALModules]       = {0};
@@ -574,9 +618,12 @@ void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   // start loop over input stream  
   while (in.NextDDL()) {
     Int_t iRCU = in.GetDDLNumber() % 2; // RCU0 or RCU1, within SuperModule
+    Int_t iDDL = in.GetDDLNumber();
     fRawAnalyzer->SetIsZeroSuppressed( in.GetZeroSupp() ); 
-
+    
     while (in.NextChannel()) {
+      Int_t iBranch = in.GetBranch();
+      
       iSM = in.GetModule(); // SuperModule
       //prInt_tf("iSM %d DDL %d", iSM, in.GetDDLNumber()); 
       if (iSM>=0 && iSM<fSuperModules) { // valid module reading
@@ -656,18 +703,21 @@ void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
                  if(iTRUIdInSM < n2x2PerTRU) {
                    Int_t iTRUAbsId = iTRUIdInSM + n2x2PerTRU * iTRUId;
                    // Fill the histograms
-                   FillRawsData(kNL0TRU,iTRUAbsId);
-                   FillRawsData(kTimeL0TRU,iTRUAbsId, startBin);
-        triggers[iTRUAbsId][startBin] = 1;
-                               
-                               if((int)startBin < firstL0TimeBin) firstL0TimeBin = startBin;
+                   Int_t globTRUCol, globTRURow;
+                   GetTruChannelPosition(globTRURow, globTRUCol, iSM, iDDL, iBranch, iTRUIdInSM );
+                   
+                   FillRawsData(kNL0TRU, globTRUCol, globTRURow);
+                   FillRawsData(kTimeL0TRU, globTRUCol, globTRURow, startBin);
+                   triggers[iTRUAbsId][startBin] = 1;
+                   
+                   if((int)startBin < firstL0TimeBin) firstL0TimeBin = startBin;
                  }
                }
              }
              startBin--;
            } // i      
          } // TRU L0 Id data                   
-
+         
          // fill histograms
          if ( in.IsLowGain() || in.IsHighGain() ) { // regular towers
            Int_t towerId = iSM*nTowersPerSM + in.GetColumn()*nRows + in.GetRow();
@@ -752,16 +802,16 @@ void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     }// end while over channel 
    
   }//end while over DDL's, of input stream 
-       //filling some L0 trigger histos
-       if( firstL0TimeBin < 999 ){
-               for(Int_t i = 0; i < nTot2x2; i++) {    
-                       if( triggers[i][firstL0TimeBin] > 0 ) {
-                               //histo->Fill(i,j);
-                               FillRawsData(kNL0FirstTRU, i);
-                               FillRawsData(kTimeL0FirstTRU, i, firstL0TimeBin);
-                       }
-               }
-       }
+  //filling some L0 trigger histos
+  if( firstL0TimeBin < 999 ){
+    for(Int_t i = 0; i < nTot2x2; i++) {       
+      if( triggers[i][firstL0TimeBin] > 0 ) {
+       //histo->Fill(i,j);
+       FillRawsData(kNL0FirstTRU, i);
+       FillRawsData(kTimeL0FirstTRU, i, firstL0TimeBin);
+      }
+    }
+  }
   
   //calculate the ratio of the amplitude and fill the histograms, only if the events type is Calib
   // RS: operation on the group of histos kSigHG,k2DRatioAmp,kRatioDist,kLEDMonRatio,kLEDMonRatio,kSigLGLEDMon
@@ -855,9 +905,11 @@ void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   IncEvCountCycleESDs();
   IncEvCountTotalESDs();
   SetEventSpecie(saveSpecie) ; 
+  
+       MakeRawsSTU(rawReader);
+
   // just in case the next rawreader consumer forgets to reset; let's do it here again..
   rawReader->Reset() ;
-  
   return;
 }
 
@@ -1027,3 +1079,178 @@ void AliEMCALQADataMakerRec::ConvertProfile2H(TProfile * p, TH2 * histo)
     histo->SetBinContent(col2d+1, row2d+1, binContent);
   }
 } 
+//____________________________________________________________________________ 
+void AliEMCALQADataMakerRec::GetTruChannelPosition( Int_t &globRow, Int_t &globColumn, Int_t module, Int_t ddl, Int_t branch, Int_t column ) const
+{ // from local to global indices
+  Int_t mrow;
+  Int_t mcol;
+  Int_t trow;
+  Int_t tcol;
+  Int_t drow;
+  Int_t rcu;
+  // RCU 0 or 1
+  rcu = ddl % 2;
+
+  // 12 rows of 2x2s in a module (3 TRUs by 4 rows)
+  mrow = (module/2) * 12;
+  // 24 columns per module, odd module numbers increased by 24
+  mcol = (module%2) * 24;
+
+  // position within TRU coordinates
+  tcol = column / 4;
+  trow = column % 4;
+
+  //.combine
+  if( module%2 == 0 ){   // A side
+    // mirror rows
+    trow = 3 - trow;
+
+    // TRU in module row addition
+    drow = (rcu*branch+rcu) * 4;
+
+  }
+  else{   // C side
+    // mirror columns
+    tcol = 23 - tcol;
+
+    // TRU in module row addition
+    drow = (2 - (rcu*branch+rcu)) * 4;
+  }
+
+  // output global row/collumn position (0,0 = SMA0, phi = 0, |eta| = max)
+  globRow = mrow + drow + trow;
+  globColumn = mcol + tcol;
+  return;
+
+}
+//____________________________________________________________________________ 
+void AliEMCALQADataMakerRec::MakeRawsSTU(AliRawReader* rawReader)
+{ // STU specifics
+  AliEMCALTriggerSTURawStream* inSTU = new AliEMCALTriggerSTURawStream(rawReader);
+       
+  rawReader->Reset();
+  rawReader->Select("EMCAL", 44);
+
+  //L1 segmentation
+  Int_t sizeL1gsubr = 1;
+  Int_t sizeL1gpatch = 2; 
+  Int_t sizeL1jsubr = 4; 
+
+  Int_t iEMCALtrig[AliEMCALGeoParams::fgkEMCALSTUCols][AliEMCALGeoParams::fgkEMCALSTURows];
+  memset(iEMCALtrig, 0, sizeof(int) * AliEMCALGeoParams::fgkEMCALSTUCols * AliEMCALGeoParams::fgkEMCALSTURows);
+               
+  if (inSTU->ReadPayLoad()) 
+    {
+      //Fw version (use in case of change in L1 jet 
+      Int_t fw = inSTU->GetFwVersion();
+      Int_t sizeL1jpatch = 2+(fw >> 16);
+
+      //To check link
+      Int_t mask = inSTU->GetFrameReceived() ^ inSTU->GetRegionEnable();
+
+      for (int i = 0; i < 32; i++)
+       {
+               if (!((mask >> i) &  0x1)) FillRawsData(kSTUTRU, i);
+       }
+
+      //V0 signal in STU
+      Int_t iV0Sig = inSTU->GetV0A()+inSTU->GetV0C();
+      
+      //FastOR amplitude receive from TRU
+      for (Int_t i = 0; i < 32; i++)
+       {
+         UInt_t adc[96];
+         for (Int_t j = 0; j < 96; j++) adc[j] = 0;
+         
+         inSTU->GetADC(i, adc);
+         
+         Int_t iTRU = fGeom->GetTRUIndexFromSTUIndex(i);
+                               
+         for (Int_t j = 0; j < 96; j++)
+           {
+             Int_t idx;
+             fGeom->GetAbsFastORIndexFromTRU(iTRU, j, idx);
+                               
+             Int_t px, py;
+             fGeom->GetPositionInEMCALFromAbsFastORIndex(idx, px, py);
+                                       
+             iEMCALtrig[px][py] = adc[j];
+           }
+       }
+                       
+      //L1 Gamma patches
+      Int_t iTRUSTU, x, y;
+      for (Int_t i = 0; i < inSTU->GetNL1GammaPatch(0); i++)
+       {
+         if (inSTU->GetL1GammaPatch(i, 0, iTRUSTU, x, y)) // col (0..23), row (0..3)
+           {
+             Int_t iTRU;
+             iTRU = fGeom->GetTRUIndexFromSTUIndex(iTRUSTU);
+             
+             Int_t etaG = 23-x, phiG = y + 4 * int(iTRU/2); //position in EMCal
+             if (iTRU%2) etaG += 24; //C-side
+                                       
+             etaG = etaG - sizeL1gsubr * sizeL1gpatch + 1;
+                               
+             //Position of patch L1G (bottom-left FastOR of the patch)
+             FillRawsData(kGL1, etaG, phiG);
+                                       
+             //loop to sum amplitude of FOR in the gamma patch
+             Int_t iL1GPatchAmp = 0;
+             for (Int_t L1Gx = 0; L1Gx < sizeL1gpatch; L1Gx ++)
+               {
+                 for (Int_t L1Gy = 0; L1Gy < sizeL1gpatch; L1Gy ++)
+                   {
+                     if (etaG+L1Gx < 48 && phiG+L1Gy < 64) iL1GPatchAmp += iEMCALtrig[etaG+L1Gx][phiG+L1Gy];
+                     //cout << iEMCALtrig[etaG+L1Gx][phiG+L1Gy] << endl;
+                   }
+               }
+             
+             //if (iL1GPatchAmp > 500) cout << "L1G amp =" << iL1GPatchAmp << endl;
+             FillRawsData(kGL1V0, iV0Sig, iL1GPatchAmp);
+             
+           }
+       }
+               
+      //L1 Jet patches
+      for (Int_t i = 0; i < inSTU->GetNL1JetPatch(0); i++)
+       {
+         if (inSTU->GetL1JetPatch(i, 0, x, y)) // col (0,15), row (0,11)
+           {
+             
+             Int_t etaJ = sizeL1jsubr * (11-y-sizeL1jpatch + 1);
+             Int_t phiJ = sizeL1jsubr * (15-x-sizeL1jpatch + 1);
+             
+             //position of patch L1J (FOR bottom-left)
+             FillRawsData(kJL1, etaJ, phiJ);
+                                       
+             //loop the sum aplitude of FOR in the jet patch
+             Int_t iL1JPatchAmp = 0;
+             for (Int_t L1Jx = 0; L1Jx < sizeL1jpatch*4; L1Jx ++)
+               {
+                 for (Int_t L1Jy = 0; L1Jy < sizeL1jpatch*4; L1Jy ++)
+                   {
+                     if (etaJ+L1Jx < 48 && phiJ+L1Jy < 64) iL1JPatchAmp += iEMCALtrig[etaJ+L1Jx][phiJ+L1Jy];
+                   }
+               }
+               
+             //cout << "L1J amp =" << iL1JPatchAmp << endl;
+             FillRawsData(kJL1V0, iV0Sig, iL1JPatchAmp);
+           }
+       }
+    }
+               
+  //Fill FOR amplitude histo
+  for (Int_t i = 0; i < 48; i++)
+    {
+      for (Int_t j = 0; j < 60; j++)
+       {
+         if (iEMCALtrig[i][j] != 0) FillRawsData(kAmpL1, i, j, iEMCALtrig[i][j]);
+       }
+    }
+  
+  delete inSTU;
+  return;
+}
+
+