]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ACORDE/AliACORDEQADataMakerRec.cxx
end-of-line normalization
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEQADataMakerRec.cxx
index 3fdd2123cdf5d3b5ddaf7695cf603236bd554c84..ecf9f0769d9d92b44c22e77ed3eb6c481a0df7a9 100755 (executable)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-//---\r
-//  Produces the data needed to calculate the quality assurance. \r
-//  All data must be mergeable objects.\r
-\r
-\r
-//  Authors:\r
-//\r
-//  Luciano Diaz Gonzalez <luciano.diaz@nucleares.unam.mx> (ICN-UNAM)\r
-//  Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch> (FCFM-BUAP)\r
-//  Arturo Fernandez Tellez <afernan@mail.cern.ch (FCFM-BUAP)\r
-//\r
-//  Created: June 13th 2008\r
-//---\r
-// Last update: Sept. 29th. 2011 (by Mario RC: mrodrigu@mail.cern.ch) \r
-//     --> ACOMultiSL0_DQM_Shifter filling histogram fixed\r
-//     --> Expert histogram updated: 2 histograms (Checks the hits for SL0 and AMU mode)\r
-//     --> To be include in the next update: threshold settings from AliACORDEQAThreshold class (not yet)\r
-// Last update: May 5th. 2011 (by Mario RC: mrodrigu@mail.cern.ch) -->Creates QA expert histograms \r
-// and QA-shifter histograms also with threshold lines and visual alarm\r
-// Last Update: Aug. 27th 2008 --> Implementation to declare QA expert histogram\r
-// Last update: Nov. 14t 2009 --> MRC <mrodrigu@mail.cern.ch> (FCFM-BUAP) \r
-//                     |--> Change in Multiplicity histogram for AMORE (to detect empty triggers events of ACORDE)\r
-\r
-\r
-\r
-// --- ROOT system ---\r
-#include <TClonesArray.h>\r
-#include <TFile.h> \r
-#include <TH1F.h> \r
-#include <TDirectory.h>\r
-#include <TPaveText.h>\r
-// --- Standard library ---\r
-\r
-// --- AliRoot header files ---\r
-#include "AliESDEvent.h"\r
-#include "AliLog.h"\r
-#include "AliACORDEdigit.h" \r
-#include "AliACORDEhit.h"\r
-#include "AliACORDEQADataMakerRec.h"\r
-#include "AliQAChecker.h"\r
-#include "AliACORDERawReader.h"\r
-#include "AliACORDERawStream.h"\r
-ClassImp(AliACORDEQADataMakerRec)\r
-           \r
-//____________________________________________________________________________ \r
- AliACORDEQADataMakerRec::AliACORDEQADataMakerRec():AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kACORDE), "ACORDE Quality Assurance Data Maker")\r
-{\r
-\r
-}\r
-//____________________________________________________________________________ \r
-AliACORDEQADataMakerRec::AliACORDEQADataMakerRec(const AliACORDEQADataMakerRec& qadm):\r
-  AliQADataMakerRec()\r
-{\r
-  SetName((const char*)qadm.GetName()) ; \r
-  SetTitle((const char*)qadm.GetTitle()); \r
-}\r
-\r
-//__________________________________________________________________\r
-AliACORDEQADataMakerRec::~AliACORDEQADataMakerRec()\r
-{\r
-}\r
-\r
-//__________________________________________________________________\r
-AliACORDEQADataMakerRec& AliACORDEQADataMakerRec::operator = (const AliACORDEQADataMakerRec& qadm )\r
-{\r
-  // Equal operator.\r
-  this->~AliACORDEQADataMakerRec();\r
-  new(this) AliACORDEQADataMakerRec(qadm);\r
-  return *this;\r
-}\r
-//____________________________________________________________________________\r
-void AliACORDEQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)\r
-{\r
-  //Detector specific actions at end of cycle\r
-  // do the QA checking\r
-  ResetEventTrigClasses(); // reset triggers list to select all histos\r
-  // Update for DQM GUI\r
-  //\r
-\r
-  for (Int_t specie = 0; specie < AliRecoParam::kNSpecies ; specie++) {\r
-    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ;\r
-    // \r
-    // RS Set event specie\r
-    SetEventSpecie(AliRecoParam::ConvertIndex(specie));\r
-    //\r
-    for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS Loop over the trigger classes\r
-      //\r
-       TObjArray * parr = GetRawsDataOfTrigClass(itc);\r
-       if (!parr) continue;\r
-       TObjArray &harr = *parr;\r
-       TH1* h0 = (TH1*)harr[0];\r
-       TH1* h2 = (TH1*)harr[2];\r
-       if (!h0 || !h2) continue;\r
-\r
-       Double_t integralSL0 = 0;\r
-       Double_t integralAMU = 0;\r
-\r
-       if ((itc==-1) && ( (integralAMU=h2->Integral()==0) || (integralSL0=h0->Integral()==0) ) ) continue;\r
-\r
-       Float_t maxSL0 = 1*h0->GetMaximum();\r
-       Float_t scaleSL0 = 0.;\r
-       if (maxSL0!=0) scaleSL0 = 1/maxSL0;\r
-       else scaleSL0 = 1.;\r
-       h0->Scale(scaleSL0);\r
-\r
-\r
-       Float_t maxAMU = 1*h2->GetMaximum();\r
-       Float_t scaleAMU = 0.;\r
-       if (maxAMU!=0) scaleAMU = 1/maxAMU;\r
-       else scaleAMU = 1.;\r
-       h2->Scale(scaleAMU);\r
-      \r
-       Int_t indexActiveModuleSL0 = 0;\r
-       Int_t indexActiveModuleAMU = 0;\r
-\r
-       for(Int_t iModule = 0; iModule < 60; iModule++){\r
-               if (h0->GetBinContent(iModule) > 0) indexActiveModuleSL0++;\r
-               if (h2->GetBinContent(iModule) > 0) indexActiveModuleAMU++;\r
-       }\r
-       \r
-       Float_t meanHitsSL0 = 0.;\r
-       Float_t meanHitsAMU = 0.;\r
-       //if ((indexActiveModuleSL0==0) || (indexActiveModuleAMU == 0)) continue;\r
-       if (indexActiveModuleAMU == 0) continue;\r
-\r
-       meanHitsSL0 = h0->Integral()/indexActiveModuleSL0;\r
-       meanHitsAMU = h2->Integral()/indexActiveModuleAMU;\r
-\r
-       TH1* h6 = (TH1*)harr[6];\r
-       //TH1* h7 = (TH1*)harr[7];\r
-\r
-       //Int_t goodModulesSL0 = 0;\r
-       //Int_t badModulesSL0 = 0;\r
-       Int_t goodModulesAMU = 0;\r
-       Int_t badModulesAMU = 0;\r
-\r
-       for (Int_t imod = 0; imod < 60; imod++)\r
-       {\r
-               //if (TMath::Abs(h0->GetBinContent(imod)/meanHitsSL0-1) < 0.65) goodModulesSL0++;\r
-               //else badModulesSL0++;\r
-               if (meanHitsAMU!=0)\r
-               {\r
-                       if (TMath::Abs(h2->GetBinContent(imod)/meanHitsAMU-1) <= 0.90) goodModulesAMU++;\r
-                       else badModulesAMU++;\r
-               }\r
-\r
-       }\r
-       h6->Fill(1,goodModulesAMU);\r
-       h6->Fill(2,badModulesAMU);\r
-\r
-       Float_t maxMod = 1*h6->GetMaximum();\r
-       Float_t scaleMaxMod = 0;\r
-       if (maxMod!=0) scaleMaxMod = 1./maxMod;\r
-       else scaleMaxMod = 0;\r
-       h6->Scale(scaleMaxMod);\r
-\r
-        TH1* h4 = (TH1*)harr[4];\r
-        TH1* h5 = (TH1*)harr[5];\r
-\r
-       if (h4 && h5 && meanHitsAMU!=0 && meanHitsSL0!=0){\r
-               for (Int_t iModule = 0; iModule < 60; iModule++){\r
-                       h4->Fill(h0->GetBinContent(iModule)/meanHitsSL0-1);\r
-                       h5->Fill(h2->GetBinContent(iModule)/meanHitsAMU-1);\r
-               }\r
-       }\r
-\r
-    } // end of trigger classes loop\r
-  } // end specie loop\r
-  // QA Checker standar (to be updated)\r
-  //\r
-  AliQAChecker::Instance()->Run(AliQAv1::kACORDE, task, list) ;\r
-}\r
-\r
-//____________________________________________________________________________\r
-void AliACORDEQADataMakerRec::StartOfDetectorCycle()\r
-{\r
-  //Detector specific actions at start of cycle\r
-\r
-}\r
\r
-//____________________________________________________________________________ \r
-void AliACORDEQADataMakerRec::InitRaws()\r
-{\r
-  // create Raw histograms in Raw subdir\r
-\r
-       const Bool_t expert   = kTRUE ; \r
-       const Bool_t saveCorr = kTRUE ; \r
-       const Bool_t image    = kTRUE ; \r
-       TH1F * fhACORDEBitPatternDQM = new TH1F("ACOHitsSL0_DQM_Shifter","Distribution of ACORDE fired modules for DQM shifter; No. of module; Counts",60,-0.5,59.5);// Hits histogram for QA-shifter ACO-SL0 trigger mode\r
-        TH1F * fhACORDEMultiplicitySL0DQM = new TH1F("ACOMultiSL0_DQM_Shifter","Multiplicity of ACORDE fired modules for DQM shifter; No. of fired modules; No. of events",62,-1,60); // Multiplicity histo. for QA-shifter ACO-SL0 trigger mode\r
-        TH1F * fhACORDEBitPatternAMUDQM = new TH1F("ACOHitsAMU_DQM_Shifter","Distribution of ACORDE fired modules for DQM shifter; No. of module; Counts",60,-0.5,59.5);// Hits histogram for QA-shifter ACO-SL0 trigger mode\r
-        TH1F * fhACORDEMultiplicityAMUDQM = new TH1F("ACOMultiAMU_DQM_Shifter","Multiplicity of ACORDE fired modules for DQM shifter; No. of fired modules; No. of events",62,-1,60); // Multiplicity histo. for QA-shifter ACO-SL0 trigger mode\r
-        TH1F * fhACORDEBitPatternCheckDQMSL0 = new TH1F("ACOHitsTriggerCheck_DQMExpertSL0","Check the activity of ACORDE's modules; Hits per module/mean of Hits; Counts",100,-3,5); // Check the trigger status of ACORDE (SL0 vs AMU)\r
-        TH1F * fhACORDEBitPatternCheckDQMAMU = new TH1F("ACOHitsTriggerCheck_DQMExpertAMU","Check the activity of ACORDE's modules; Hits per module/mean of Hits; Counts",100,-3,5); // Check the trigger status of ACORDE (SL0 vs AMU)\r
-\r
-  //const char *acoStatus[4]={"O.K.","High","Low","Not O.K."};\r
-  const char *acoStatus[2]={"STABLE RATE","FLUCTUATING RATE"};\r
-\r
-\r
-\r
-       TH1F * fhACORDEStatusAMU_DQM = new TH1F("fhACORDEStatusAMU_DQM","Status of rate for ACORDE's modules (AMU mode)",2,1,3);\r
-       for (Int_t i=0;i<2;i++) \r
-       {\r
-               fhACORDEStatusAMU_DQM->GetXaxis()->SetBinLabel(i+1,acoStatus[i]); \r
-       }\r
-       fhACORDEStatusAMU_DQM->SetYTitle("No. of modules (Norm.)");\r
-\r
-       Add2RawsList(fhACORDEStatusAMU_DQM,6,!expert,image,!saveCorr);\r
-\r
-       fhACORDEStatusAMU_DQM->SetFillColor(kAzure-7);\r
-\r
-\r
-         // Expert histograms\r
-         // Check the hits multiplicity from trigger configuration\r
-         Add2RawsList(fhACORDEBitPatternCheckDQMSL0,4,expert,image,!saveCorr);\r
-         fhACORDEBitPatternCheckDQMSL0->SetFillColor(kOrange);\r
-        Add2RawsList(fhACORDEBitPatternCheckDQMAMU,5,expert,image,!saveCorr);\r
-         fhACORDEBitPatternCheckDQMAMU->SetFillColor(kRed+2);\r
-\r
-       \r
-       // AMORE diplay settings for shifter on GUI\r
\r
-        // For SL0 ACO trigger mode\r
\r
-         Add2RawsList(fhACORDEBitPatternDQM,0,expert,image,!saveCorr);\r
-        ForbidCloning(fhACORDEBitPatternDQM);\r
-         Add2RawsList(fhACORDEMultiplicitySL0DQM,1,expert,image,!saveCorr);\r
-        ForbidCloning(fhACORDEMultiplicitySL0DQM);\r
-\r
-         // For Hits distribution on ACORDE\r
\r
-         fhACORDEBitPatternDQM->SetFillColor(kMagenta+2);\r
\r
-         // For ACORDE Multiplicity distribution of fired modules\r
\r
-         fhACORDEMultiplicitySL0DQM->SetFillColor(kMagenta);\r
\r
-         // For AMU ACO trigger mode\r
\r
-         Add2RawsList(fhACORDEBitPatternAMUDQM,2,expert,image,!saveCorr);\r
-         Add2RawsList(fhACORDEMultiplicityAMUDQM,3,expert,image,!saveCorr);\r
\r
-         // For Hits distribution on ACORDE\r
\r
-         fhACORDEBitPatternAMUDQM->SetFillColor(kViolet+7);\r
\r
-         // For ACORDE Multiplicity distribution of fired modules\r
\r
-         fhACORDEMultiplicityAMUDQM->SetFillColor(kViolet+6);\r
\r
-  //\r
-  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line\r
-}\r
-\r
-//____________________________________________________________________________ \r
-void AliACORDEQADataMakerRec::InitDigits()\r
-{\r
-  // create Digits histograms in Digits subdir\r
-  \r
-  const Bool_t expert   = kTRUE ; \r
-  const Bool_t image    = kTRUE ; \r
-  TH1F *    fhDigitsModule;\r
-  const char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
-                        "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
-                        "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
-                        "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
-                        "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
-                        "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
-\r
-\r
-  fhDigitsModule = new TH1F("ACORDEBitPatternfromDigits","Distribution of ACORDE from DIGITS;Modules;Counts",60,1,60);\r
-  Add2DigitsList(fhDigitsModule,0,!expert,image);\r
-  for (Int_t i=0;i<60;i++) fhDigitsModule->GetXaxis()->SetBinLabel(i+1,acoModule[i]); \r
-  //\r
-  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line\r
-}\r
-\r
-//____________________________________________________________________________ \r
-\r
-void AliACORDEQADataMakerRec::InitRecPoints()\r
-{\r
-  // create cluster histograms in RecPoint subdir\r
-  // Not needed for ACORDE by now !!!\r
-  //\r
-  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line\r
-}\r
-\r
-//____________________________________________________________________________\r
-void AliACORDEQADataMakerRec::InitESDs()\r
-{\r
-  //create ESDs histograms in ESDs subdir\r
-\r
-  const Bool_t expert   = kTRUE ; \r
-  const Bool_t image    = kTRUE ; \r
-  \r
-  TH1F *    fhESDsSingle;\r
-  TH1F *    fhESDsMulti;\r
-  TH1F *       fhESDsMultiplicity;\r
-  const char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",\r
-                        "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",\r
-                        "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",\r
-                        "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",\r
-                        "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",\r
-                        "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};\r
-\r
-\r
-   fhESDsSingle = new TH1F("ACORDEBitPatternfromESDsSingle","Distribution of ACORDE fired modules from ESDs-Single;Modules;Counts",60,1,60);\r
-   Add2ESDsList(fhESDsSingle,0,!expert,image);\r
-\r
-   fhESDsMulti = new TH1F("ACORDEBitPatternfromESDsMulti","Distribution of ACORDE fired modules from ESDs-Multi;Modules;Counts",60,1,60);\r
-   Add2ESDsList(fhESDsMulti,1,!expert,image);\r
-   \r
-   fhESDsMultiplicity = new TH1F("ACORDEMultiplicityfromESD","Number of fired ACORDE modules; No. of fired ACORDE modules;No. of events in ACORDE",60,-0.5,60);\r
-   Add2ESDsList(fhESDsMultiplicity,2,!expert,image);   \r
-   for (Int_t i=0;i<60;i++)\r
-   {\r
-       fhESDsSingle->GetXaxis()->SetBinLabel(i+1,acoModule[i]);\r
-       fhESDsMulti->GetXaxis()->SetBinLabel(i+1,acoModule[i]);\r
-   }\r
-   //\r
-   ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line\r
-}\r
-//____________________________________________________________________________\r
-void AliACORDEQADataMakerRec::MakeRaws(AliRawReader* rawReader)\r
-{\r
-  //fills QA histos for RAW\r
-  IncEvCountCycleRaws();\r
-  IncEvCountTotalRaws();\r
-  rawReader->Reset();\r
-  AliACORDERawStream rawStream(rawReader);\r
-  size_t contSingle=0;\r
-  size_t contMulti=0;\r
-  UInt_t dy[4];\r
-\r
-  bool kroSingle[60],kroMulti[60];\r
-  UInt_t tmpDy;\r
-\r
-  for(Int_t m=0;m<60;m++) {kroSingle[m]=0;kroMulti[m]=0;}\r
-\r
-if(rawStream.Next())\r
-{\r
-        dy[0]=rawStream.GetWord(0);\r
-        dy[1]=rawStream.GetWord(1);\r
-        dy[2]=rawStream.GetWord(2);\r
-        dy[3]=rawStream.GetWord(3);\r
-        tmpDy=dy[0];\r
-        for(Int_t r=0;r<30;r++)\r
-        {\r
-                kroSingle[r] = tmpDy & 1;\r
-                tmpDy>>=1;\r
-        }\r
-        tmpDy=dy[1];\r
-        for(Int_t r=30;r<60;r++)\r
-        {\r
-                kroSingle[r] = tmpDy & 1;\r
-                tmpDy>>=1;\r
-        }\r
-        tmpDy=dy[2];\r
-        for(Int_t r=0;r<30;r++)\r
-        {\r
-                kroMulti[r] = tmpDy & 1;\r
-                tmpDy>>=1;\r
-        }\r
-        tmpDy=dy[3];\r
-        for(Int_t r=30;r<60;r++)\r
-        {\r
-                kroMulti[r] = tmpDy & 1;\r
-                tmpDy>>=1;\r
-        }\r
-        contSingle=0;\r
-       contMulti=0;\r
-        for(Int_t r=0;r<60;r++)\r
-        {\r
-                       if(kroSingle[r]==1)\r
-                       {\r
-                         FillRawsData(0,r);\r
-                         //FillRawsData(4,r);\r
-                         contSingle++;\r
-                       }\r
-                       if(kroMulti[r]==1)\r
-                       {\r
-                         FillRawsData(2,r);\r
-                         //FillRawsData(6,r);\r
-                         contMulti++;\r
-                       }\r
-                       \r
-        } \r
-       FillRawsData(1,contSingle); \r
-       FillRawsData(3,contMulti); \r
-       //      FillRawsData(7,contMulti);\r
-}\r
-}\r
-//____________________________________________________________________________\r
-void AliACORDEQADataMakerRec::MakeDigits( TTree *digitsTree)\r
-{\r
-  //fills QA histos for Digits\r
-  IncEvCountCycleDigits();\r
-  IncEvCountTotalDigits();\r
-\r
-  if (fDigitsArray) \r
-    fDigitsArray->Clear() ; \r
-  else \r
-    fDigitsArray = new TClonesArray("AliACORDEdigit",1000);\r
-  TBranch * branch = digitsTree->GetBranch("ACORDEdigit");\r
-  if (!branch) {\r
-    AliWarning("ACORDE branch in Digits Tree not found");\r
-  } else {\r
-    branch->SetAddress(&fDigitsArray);\r
-    for(Int_t track = 0 ; track < branch->GetEntries() ; track++) {\r
-      branch->GetEntry(track);\r
-      for(Int_t idigit = 0 ; idigit < fDigitsArray->GetEntriesFast() ; idigit++) {\r
-        AliACORDEdigit *AcoDigit = (AliACORDEdigit*) fDigitsArray->UncheckedAt(idigit);\r
-        if (!AcoDigit) {\r
-          AliError("The unchecked digit doesn't exist");\r
-          continue ;\r
-        }\r
-        FillDigitsData(0,AcoDigit->GetModule()-1);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-//____________________________________________________________________________\r
-void AliACORDEQADataMakerRec::MakeESDs(AliESDEvent * esd)\r
-{\r
-  //fills QA histos for ESD\r
-  IncEvCountCycleESDs();\r
-  IncEvCountTotalESDs();\r
-  //\r
-  AliESDACORDE * fESDACORDE= esd->GetACORDEData();\r
-  Int_t acoMulti=0;\r
-  for(int i=0;i<60;i++)\r
-  {\r
-    if(fESDACORDE->GetHitChannel(i)) \r
-         {\r
-         FillESDsData(0,i+1);\r
-         FillESDsData(1,i+1);\r
-         acoMulti++;\r
-       }\r
-  } FillESDsData(2,acoMulti);\r
-\r
-}\r
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//---
+//  Produces the data needed to calculate the quality assurance. 
+//  All data must be mergeable objects.
+
+
+//  Authors:
+//
+//  Luciano Diaz Gonzalez <luciano.diaz@nucleares.unam.mx> (ICN-UNAM)
+//  Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch> (FCFM-BUAP)
+//  Arturo Fernandez Tellez <afernan@mail.cern.ch (FCFM-BUAP)
+//
+//  Created: June 13th 2008
+//---
+// Last update: Sept. 29th. 2011 (by Mario RC: mrodrigu@mail.cern.ch) 
+//     --> ACOMultiSL0_DQM_Shifter filling histogram fixed
+//     --> Expert histogram updated: 2 histograms (Checks the hits for SL0 and AMU mode)
+//     --> To be include in the next update: threshold settings from AliACORDEQAThreshold class (not yet)
+// Last update: May 5th. 2011 (by Mario RC: mrodrigu@mail.cern.ch) -->Creates QA expert histograms 
+// and QA-shifter histograms also with threshold lines and visual alarm
+// Last Update: Aug. 27th 2008 --> Implementation to declare QA expert histogram
+// Last update: Nov. 14t 2009 --> MRC <mrodrigu@mail.cern.ch> (FCFM-BUAP) 
+//                     |--> Change in Multiplicity histogram for AMORE (to detect empty triggers events of ACORDE)
+
+
+
+// --- ROOT system ---
+#include <TClonesArray.h>
+#include <TFile.h> 
+#include <TH1F.h> 
+#include <TDirectory.h>
+#include <TPaveText.h>
+// --- Standard library ---
+
+// --- AliRoot header files ---
+#include "AliESDEvent.h"
+#include "AliLog.h"
+#include "AliACORDEdigit.h" 
+#include "AliACORDEhit.h"
+#include "AliACORDEQADataMakerRec.h"
+#include "AliQAChecker.h"
+#include "AliACORDERawReader.h"
+#include "AliACORDERawStream.h"
+ClassImp(AliACORDEQADataMakerRec)
+           
+//____________________________________________________________________________ 
+ AliACORDEQADataMakerRec::AliACORDEQADataMakerRec():AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kACORDE), "ACORDE Quality Assurance Data Maker")
+{
+
+}
+//____________________________________________________________________________ 
+AliACORDEQADataMakerRec::AliACORDEQADataMakerRec(const AliACORDEQADataMakerRec& qadm):
+  AliQADataMakerRec()
+{
+  SetName((const char*)qadm.GetName()) ; 
+  SetTitle((const char*)qadm.GetTitle()); 
+}
+
+//__________________________________________________________________
+AliACORDEQADataMakerRec::~AliACORDEQADataMakerRec()
+{
+}
+
+//__________________________________________________________________
+AliACORDEQADataMakerRec& AliACORDEQADataMakerRec::operator = (const AliACORDEQADataMakerRec& qadm )
+{
+  // Equal operator.
+  this->~AliACORDEQADataMakerRec();
+  new(this) AliACORDEQADataMakerRec(qadm);
+  return *this;
+}
+//____________________________________________________________________________
+void AliACORDEQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
+{
+  //Detector specific actions at end of cycle
+  // do the QA checking
+  ResetEventTrigClasses(); // reset triggers list to select all histos
+  // Update for DQM GUI
+  //
+
+  for (Int_t specie = 0; specie < AliRecoParam::kNSpecies ; specie++) {
+    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ;
+    // 
+    // RS Set event specie
+    SetEventSpecie(AliRecoParam::ConvertIndex(specie));
+    //
+    for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS Loop over the trigger classes
+      //
+       TObjArray * parr = GetRawsDataOfTrigClass(itc);
+       if (!parr) continue;
+       TObjArray &harr = *parr;
+       TH1* h0 = (TH1*)harr[0];
+       TH1* h2 = (TH1*)harr[2];
+       if (!h0 || !h2) continue;
+
+       Double_t integralSL0 = 0;
+       Double_t integralAMU = 0;
+
+       if ((itc==-1) && ( (integralAMU=h2->Integral()==0) || (integralSL0=h0->Integral()==0) ) ) continue;
+
+       Float_t maxSL0 = 1*h0->GetMaximum();
+       Float_t scaleSL0 = 0.;
+       if (maxSL0!=0) scaleSL0 = 1/maxSL0;
+       else scaleSL0 = 1.;
+       h0->Scale(scaleSL0);
+
+
+       Float_t maxAMU = 1*h2->GetMaximum();
+       Float_t scaleAMU = 0.;
+       if (maxAMU!=0) scaleAMU = 1/maxAMU;
+       else scaleAMU = 1.;
+       h2->Scale(scaleAMU);
+      
+       Int_t indexActiveModuleSL0 = 0;
+       Int_t indexActiveModuleAMU = 0;
+
+       for(Int_t iModule = 0; iModule < 60; iModule++){
+               if (h0->GetBinContent(iModule) > 0) indexActiveModuleSL0++;
+               if (h2->GetBinContent(iModule) > 0) indexActiveModuleAMU++;
+       }
+       
+       Float_t meanHitsSL0 = 0.;
+       Float_t meanHitsAMU = 0.;
+       //if ((indexActiveModuleSL0==0) || (indexActiveModuleAMU == 0)) continue;
+       if (indexActiveModuleAMU == 0) continue;
+
+       meanHitsSL0 = h0->Integral()/indexActiveModuleSL0;
+       meanHitsAMU = h2->Integral()/indexActiveModuleAMU;
+
+       TH1* h6 = (TH1*)harr[6];
+       //TH1* h7 = (TH1*)harr[7];
+
+       //Int_t goodModulesSL0 = 0;
+       //Int_t badModulesSL0 = 0;
+       Int_t goodModulesAMU = 0;
+       Int_t badModulesAMU = 0;
+
+       for (Int_t imod = 0; imod < 60; imod++)
+       {
+               //if (TMath::Abs(h0->GetBinContent(imod)/meanHitsSL0-1) < 0.65) goodModulesSL0++;
+               //else badModulesSL0++;
+               if (meanHitsAMU!=0)
+               {
+                       if (TMath::Abs(h2->GetBinContent(imod)/meanHitsAMU-1) <= 0.90) goodModulesAMU++;
+                       else badModulesAMU++;
+               }
+
+       }
+       h6->Fill(1,goodModulesAMU);
+       h6->Fill(2,badModulesAMU);
+
+       Float_t maxMod = 1*h6->GetMaximum();
+       Float_t scaleMaxMod = 0;
+       if (maxMod!=0) scaleMaxMod = 1./maxMod;
+       else scaleMaxMod = 0;
+       h6->Scale(scaleMaxMod);
+
+        TH1* h4 = (TH1*)harr[4];
+        TH1* h5 = (TH1*)harr[5];
+
+       if (h4 && h5 && meanHitsAMU!=0 && meanHitsSL0!=0){
+               for (Int_t iModule = 0; iModule < 60; iModule++){
+                       h4->Fill(h0->GetBinContent(iModule)/meanHitsSL0-1);
+                       h5->Fill(h2->GetBinContent(iModule)/meanHitsAMU-1);
+               }
+       }
+
+    } // end of trigger classes loop
+  } // end specie loop
+  // QA Checker standar (to be updated)
+  //
+  AliQAChecker::Instance()->Run(AliQAv1::kACORDE, task, list) ;
+}
+
+//____________________________________________________________________________
+void AliACORDEQADataMakerRec::StartOfDetectorCycle()
+{
+  //Detector specific actions at start of cycle
+
+}
+//____________________________________________________________________________ 
+void AliACORDEQADataMakerRec::InitRaws()
+{
+  // create Raw histograms in Raw subdir
+
+       const Bool_t expert   = kTRUE ; 
+       const Bool_t saveCorr = kTRUE ; 
+       const Bool_t image    = kTRUE ; 
+       TH1F * fhACORDEBitPatternDQM = new TH1F("ACOHitsSL0_DQM_Shifter","Distribution of ACORDE fired modules for DQM shifter; No. of module; Counts",60,-0.5,59.5);// Hits histogram for QA-shifter ACO-SL0 trigger mode
+        TH1F * fhACORDEMultiplicitySL0DQM = new TH1F("ACOMultiSL0_DQM_Shifter","Multiplicity of ACORDE fired modules for DQM shifter; No. of fired modules; No. of events",62,-1,60); // Multiplicity histo. for QA-shifter ACO-SL0 trigger mode
+        TH1F * fhACORDEBitPatternAMUDQM = new TH1F("ACOHitsAMU_DQM_Shifter","Distribution of ACORDE fired modules for DQM shifter; No. of module; Counts",60,-0.5,59.5);// Hits histogram for QA-shifter ACO-SL0 trigger mode
+        TH1F * fhACORDEMultiplicityAMUDQM = new TH1F("ACOMultiAMU_DQM_Shifter","Multiplicity of ACORDE fired modules for DQM shifter; No. of fired modules; No. of events",62,-1,60); // Multiplicity histo. for QA-shifter ACO-SL0 trigger mode
+        TH1F * fhACORDEBitPatternCheckDQMSL0 = new TH1F("ACOHitsTriggerCheck_DQMExpertSL0","Check the activity of ACORDE's modules; Hits per module/mean of Hits; Counts",100,-3,5); // Check the trigger status of ACORDE (SL0 vs AMU)
+        TH1F * fhACORDEBitPatternCheckDQMAMU = new TH1F("ACOHitsTriggerCheck_DQMExpertAMU","Check the activity of ACORDE's modules; Hits per module/mean of Hits; Counts",100,-3,5); // Check the trigger status of ACORDE (SL0 vs AMU)
+
+  //const char *acoStatus[4]={"O.K.","High","Low","Not O.K."};
+  const char *acoStatus[2]={"STABLE RATE","FLUCTUATING RATE"};
+
+
+
+       TH1F * fhACORDEStatusAMU_DQM = new TH1F("fhACORDEStatusAMU_DQM","Status of rate for ACORDE's modules (AMU mode)",2,1,3);
+       for (Int_t i=0;i<2;i++) 
+       {
+               fhACORDEStatusAMU_DQM->GetXaxis()->SetBinLabel(i+1,acoStatus[i]); 
+       }
+       fhACORDEStatusAMU_DQM->SetYTitle("No. of modules (Norm.)");
+
+       Add2RawsList(fhACORDEStatusAMU_DQM,6,!expert,image,!saveCorr);
+
+       fhACORDEStatusAMU_DQM->SetFillColor(kAzure-7);
+
+
+         // Expert histograms
+         // Check the hits multiplicity from trigger configuration
+         Add2RawsList(fhACORDEBitPatternCheckDQMSL0,4,expert,image,!saveCorr);
+         fhACORDEBitPatternCheckDQMSL0->SetFillColor(kOrange);
+        Add2RawsList(fhACORDEBitPatternCheckDQMAMU,5,expert,image,!saveCorr);
+         fhACORDEBitPatternCheckDQMAMU->SetFillColor(kRed+2);
+
+       
+       // AMORE diplay settings for shifter on GUI
+        // For SL0 ACO trigger mode
+         Add2RawsList(fhACORDEBitPatternDQM,0,expert,image,!saveCorr);
+        ForbidCloning(fhACORDEBitPatternDQM);
+         Add2RawsList(fhACORDEMultiplicitySL0DQM,1,expert,image,!saveCorr);
+        ForbidCloning(fhACORDEMultiplicitySL0DQM);
+
+         // For Hits distribution on ACORDE
+         fhACORDEBitPatternDQM->SetFillColor(kMagenta+2);
+         // For ACORDE Multiplicity distribution of fired modules
+         fhACORDEMultiplicitySL0DQM->SetFillColor(kMagenta);
+         // For AMU ACO trigger mode
+         Add2RawsList(fhACORDEBitPatternAMUDQM,2,expert,image,!saveCorr);
+         Add2RawsList(fhACORDEMultiplicityAMUDQM,3,expert,image,!saveCorr);
+         // For Hits distribution on ACORDE
+         fhACORDEBitPatternAMUDQM->SetFillColor(kViolet+7);
+         // For ACORDE Multiplicity distribution of fired modules
+         fhACORDEMultiplicityAMUDQM->SetFillColor(kViolet+6);
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
+}
+
+//____________________________________________________________________________ 
+void AliACORDEQADataMakerRec::InitDigits()
+{
+  // create Digits histograms in Digits subdir
+  
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+  TH1F *    fhDigitsModule;
+  const char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",
+                        "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",
+                        "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",
+                        "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",
+                        "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",
+                        "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};
+
+
+  fhDigitsModule = new TH1F("ACORDEBitPatternfromDigits","Distribution of ACORDE from DIGITS;Modules;Counts",60,1,60);
+  Add2DigitsList(fhDigitsModule,0,!expert,image);
+  for (Int_t i=0;i<60;i++) fhDigitsModule->GetXaxis()->SetBinLabel(i+1,acoModule[i]); 
+  //
+  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
+}
+
+//____________________________________________________________________________ 
+
+void AliACORDEQADataMakerRec::InitRecPoints()
+{
+  // create cluster histograms in RecPoint subdir
+  // Not needed for ACORDE by now !!!
+  //
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
+}
+
+//____________________________________________________________________________
+void AliACORDEQADataMakerRec::InitESDs()
+{
+  //create ESDs histograms in ESDs subdir
+
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+  
+  TH1F *    fhESDsSingle;
+  TH1F *    fhESDsMulti;
+  TH1F *       fhESDsMultiplicity;
+  const char *acoModule[60]={"0_0","0_1","0_2","0_3","0_4","0_5","0_6","0_7","0_8","0_9",
+                        "1_0","1_1","1_2","1_3","1_4","1_5","1_6","1_7","1_8","1_9",
+                        "2_0","2_1","2_2","2_3","2_4","2_5","2_6","2_7","2_8","2_9",
+                        "3_0","3_1","3_2","3_3","3_4","3_5","3_6","3_7","3_8","3_9",
+                        "4_0","4_1","4_2","4_3","4_4","4_5","4_6","4_7","4_8","4_9",
+                        "5_0","5_1","5_2","5_3","5_4","5_5","5_6","5_7","5_8","5_9"};
+
+
+   fhESDsSingle = new TH1F("ACORDEBitPatternfromESDsSingle","Distribution of ACORDE fired modules from ESDs-Single;Modules;Counts",60,1,60);
+   Add2ESDsList(fhESDsSingle,0,!expert,image);
+
+   fhESDsMulti = new TH1F("ACORDEBitPatternfromESDsMulti","Distribution of ACORDE fired modules from ESDs-Multi;Modules;Counts",60,1,60);
+   Add2ESDsList(fhESDsMulti,1,!expert,image);
+   
+   fhESDsMultiplicity = new TH1F("ACORDEMultiplicityfromESD","Number of fired ACORDE modules; No. of fired ACORDE modules;No. of events in ACORDE",60,-0.5,60);
+   Add2ESDsList(fhESDsMultiplicity,2,!expert,image);   
+   for (Int_t i=0;i<60;i++)
+   {
+       fhESDsSingle->GetXaxis()->SetBinLabel(i+1,acoModule[i]);
+       fhESDsMulti->GetXaxis()->SetBinLabel(i+1,acoModule[i]);
+   }
+   //
+   ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
+}
+//____________________________________________________________________________
+void AliACORDEQADataMakerRec::MakeRaws(AliRawReader* rawReader)
+{
+  //fills QA histos for RAW
+  IncEvCountCycleRaws();
+  IncEvCountTotalRaws();
+  rawReader->Reset();
+  AliACORDERawStream rawStream(rawReader);
+  size_t contSingle=0;
+  size_t contMulti=0;
+  UInt_t dy[4];
+
+  bool kroSingle[60],kroMulti[60];
+  UInt_t tmpDy;
+
+  for(Int_t m=0;m<60;m++) {kroSingle[m]=0;kroMulti[m]=0;}
+
+if(rawStream.Next())
+{
+        dy[0]=rawStream.GetWord(0);
+        dy[1]=rawStream.GetWord(1);
+        dy[2]=rawStream.GetWord(2);
+        dy[3]=rawStream.GetWord(3);
+        tmpDy=dy[0];
+        for(Int_t r=0;r<30;r++)
+        {
+                kroSingle[r] = tmpDy & 1;
+                tmpDy>>=1;
+        }
+        tmpDy=dy[1];
+        for(Int_t r=30;r<60;r++)
+        {
+                kroSingle[r] = tmpDy & 1;
+                tmpDy>>=1;
+        }
+        tmpDy=dy[2];
+        for(Int_t r=0;r<30;r++)
+        {
+                kroMulti[r] = tmpDy & 1;
+                tmpDy>>=1;
+        }
+        tmpDy=dy[3];
+        for(Int_t r=30;r<60;r++)
+        {
+                kroMulti[r] = tmpDy & 1;
+                tmpDy>>=1;
+        }
+        contSingle=0;
+       contMulti=0;
+        for(Int_t r=0;r<60;r++)
+        {
+                       if(kroSingle[r]==1)
+                       {
+                         FillRawsData(0,r);
+                         //FillRawsData(4,r);
+                         contSingle++;
+                       }
+                       if(kroMulti[r]==1)
+                       {
+                         FillRawsData(2,r);
+                         //FillRawsData(6,r);
+                         contMulti++;
+                       }
+                       
+        } 
+       FillRawsData(1,contSingle); 
+       FillRawsData(3,contMulti); 
+       //      FillRawsData(7,contMulti);
+}
+}
+//____________________________________________________________________________
+void AliACORDEQADataMakerRec::MakeDigits( TTree *digitsTree)
+{
+  //fills QA histos for Digits
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
+
+  if (fDigitsArray) 
+    fDigitsArray->Clear() ; 
+  else 
+    fDigitsArray = new TClonesArray("AliACORDEdigit",1000);
+  TBranch * branch = digitsTree->GetBranch("ACORDEdigit");
+  if (!branch) {
+    AliWarning("ACORDE branch in Digits Tree not found");
+  } else {
+    branch->SetAddress(&fDigitsArray);
+    for(Int_t track = 0 ; track < branch->GetEntries() ; track++) {
+      branch->GetEntry(track);
+      for(Int_t idigit = 0 ; idigit < fDigitsArray->GetEntriesFast() ; idigit++) {
+        AliACORDEdigit *AcoDigit = (AliACORDEdigit*) fDigitsArray->UncheckedAt(idigit);
+        if (!AcoDigit) {
+          AliError("The unchecked digit doesn't exist");
+          continue ;
+        }
+        FillDigitsData(0,AcoDigit->GetModule()-1);
+      }
+    }
+  }
+}
+
+//____________________________________________________________________________
+void AliACORDEQADataMakerRec::MakeESDs(AliESDEvent * esd)
+{
+  //fills QA histos for ESD
+  IncEvCountCycleESDs();
+  IncEvCountTotalESDs();
+  //
+  AliESDACORDE * fESDACORDE= esd->GetACORDEData();
+  Int_t acoMulti=0;
+  for(int i=0;i<60;i++)
+  {
+    if(fESDACORDE->GetHitChannel(i)) 
+         {
+         FillESDsData(0,i+1);
+         FillESDsData(1,i+1);
+         acoMulti++;
+       }
+  } FillESDsData(2,acoMulti);
+
+}