X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALQADataMakerRec.cxx;h=eb58eedfcedd7319bc885f186705d39c43245ad0;hb=dcfd261c7e6a12e62f62dc28c727056afb51bded;hp=dfa8f09985c482defbe6187443b9b086a5d5d3e5;hpb=3fe36ccbd5b3ad484ab3f2e27d3c8311e222dad3;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALQADataMakerRec.cxx b/EMCAL/AliEMCALQADataMakerRec.cxx index dfa8f09985c..eb58eedfced 100644 --- a/EMCAL/AliEMCALQADataMakerRec.cxx +++ b/EMCAL/AliEMCALQADataMakerRec.cxx @@ -17,7 +17,15 @@ Based on the QA code for PHOS written by Yves Schutz July 2007 Authors: J.Klay (Cal Poly) May 2008 S. Salur LBL April 2008 + +Created one histogram for QA shifter;-- Yaxian Mao: 11/2009 +The idea:average counts for all the towers should be flat +Change all existing histograms as experts +Change histograms for DQM shifter: -- Yaxian Mao 04/2010 +Calcuate the amplitude ratio from current run and the LED reference, for QAChecker use +Also calculate the ratio of amplitude from LED Monitor system (current/Reference), to check LED system + */ // --- ROOT system --- @@ -26,43 +34,133 @@ Authors: J.Klay (Cal Poly) May 2008 #include #include #include +#include +#include #include - +#include // --- Standard library --- // --- AliRoot header files --- +#include "AliDAQ.h" #include "AliESDCaloCluster.h" #include "AliESDCaloCells.h" #include "AliESDEvent.h" #include "AliLog.h" #include "AliEMCALQADataMakerRec.h" #include "AliQAChecker.h" +#include "AliEMCALDigit.h" #include "AliEMCALRecPoint.h" #include "AliEMCALRawUtils.h" #include "AliEMCALReconstructor.h" #include "AliEMCALRecParam.h" #include "AliRawReader.h" -#include "AliCaloRawStream.h" +#include "AliCaloRawStreamV3.h" +#include "AliEMCALGeoParams.h" +#include "AliRawEventHeaderBase.h" +#include "AliQAManager.h" +#include "AliCDBEntry.h" + +#include "AliCaloBunchInfo.h" +#include "AliCaloFitResults.h" +#include "AliCaloRawAnalyzerFastFit.h" +#include "AliCaloRawAnalyzerNN.h" +//#include "AliCaloRawAnalyzerLMS.h" +#include "AliCaloRawAnalyzerKStandard.h" +#include "AliCaloRawAnalyzerPeakFinder.h" +#include "AliCaloRawAnalyzerCrude.h" + +#include "AliCaloRawAnalyzerFactory.h" + +using namespace std; ClassImp(AliEMCALQADataMakerRec) //____________________________________________________________________________ - AliEMCALQADataMakerRec::AliEMCALQADataMakerRec() : - AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker"), - fSuperModules(4) // FIXME!!! number of SuperModules; 4 for 2009; update default to 12 for later runs.. +AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(fitAlgorithm fitAlgo) : + AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kEMCAL), "EMCAL Quality Assurance Data Maker"), + fFittingAlgorithm(0), + fRawAnalyzer(0), + fRawAnalyzerTRU(0), + fSuperModules(10), // FIXME!!! number of SuperModules; 10 for 2011; update default for later runs + fFirstPedestalSample(0), + fLastPedestalSample(3), + fFirstPedestalSampleTRU(0), + fLastPedestalSampleTRU(3), + fMinSignalLG(0), + fMaxSignalLG(AliEMCALGeoParams::fgkSampleMax), + fMinSignalHG(0), + fMaxSignalHG(AliEMCALGeoParams::fgkSampleMax), + fMinSignalTRU(0), + fMaxSignalTRU(AliEMCALGeoParams::fgkSampleMax), + fMinSignalLGLEDMon(0), + fMaxSignalLGLEDMon(AliEMCALGeoParams::fgkSampleMax), + fMinSignalHGLEDMon(0), + fMaxSignalHGLEDMon(AliEMCALGeoParams::fgkSampleMax), + fCalibRefHistoPro(NULL), + fCalibRefHistoH2F(NULL), + fLEDMonRefHistoPro(NULL), + fHighEmcHistoH2F(NULL) +// fTextSM(new TText*[fSuperModules]) , +// fLineCol(NULL), +// fLineRow(NULL) + { // ctor + SetFittingAlgorithm(fitAlgo); + + //fRawAnalyzerTRU = new AliCaloRawAnalyzerLMS(); + + fRawAnalyzerTRU = ( AliCaloRawAnalyzerKStandard*)AliCaloRawAnalyzerFactory::CreateAnalyzer(kLMS); + + fRawAnalyzerTRU->SetFixTau(kTRUE); + fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper +// for (Int_t sm = 0 ; sm < fSuperModules ; sm++){ +// fTextSM[sm] = NULL ; +// } } //____________________________________________________________________________ AliEMCALQADataMakerRec::AliEMCALQADataMakerRec(const AliEMCALQADataMakerRec& qadm) : - AliQADataMakerRec() + AliQADataMakerRec(), + fFittingAlgorithm(0), + fRawAnalyzer(0), + fRawAnalyzerTRU(0), + fSuperModules(qadm.GetSuperModules()), + fFirstPedestalSample(qadm.GetFirstPedestalSample()), + fLastPedestalSample(qadm.GetLastPedestalSample()), + fFirstPedestalSampleTRU(qadm.GetFirstPedestalSampleTRU()), + fLastPedestalSampleTRU(qadm.GetLastPedestalSampleTRU()), + fMinSignalLG(qadm.GetMinSignalLG()), + fMaxSignalLG(qadm.GetMaxSignalLG()), + fMinSignalHG(qadm.GetMinSignalHG()), + fMaxSignalHG(qadm.GetMaxSignalHG()), + fMinSignalTRU(qadm.GetMinSignalTRU()), + fMaxSignalTRU(qadm.GetMaxSignalTRU()), + fMinSignalLGLEDMon(qadm.GetMinSignalLGLEDMon()), + fMaxSignalLGLEDMon(qadm.GetMaxSignalLGLEDMon()), + fMinSignalHGLEDMon(qadm.GetMinSignalHGLEDMon()), + fMaxSignalHGLEDMon(qadm.GetMaxSignalHGLEDMon()), + fCalibRefHistoPro(NULL), + fCalibRefHistoH2F(NULL), + fLEDMonRefHistoPro(NULL), + fHighEmcHistoH2F(NULL) +// fTextSM(new TText*[fSuperModules]) , +// fLineCol(NULL), +// fLineRow(NULL) { //copy ctor SetName((const char*)qadm.GetName()) ; SetTitle((const char*)qadm.GetTitle()); - fSuperModules = qadm.GetSuperModules(); + SetFittingAlgorithm(qadm.GetFittingAlgorithm()); + + //fRawAnalyzerTRU = new AliCaloRawAnalyzerLMS(); + fRawAnalyzerTRU = (AliCaloRawAnalyzerKStandard*)AliCaloRawAnalyzerFactory::CreateAnalyzer(kLMS); + fRawAnalyzerTRU->SetFixTau(kTRUE); + fRawAnalyzerTRU->SetTau(2.5); // default for TRU shaper +// for (Int_t sm = 0 ; sm < fSuperModules ; sm++){ +// fTextSM[sm] = qadm.fTextSM[sm] ; +// } } //__________________________________________________________________ @@ -71,6 +169,11 @@ AliEMCALQADataMakerRec& AliEMCALQADataMakerRec::operator = (const AliEMCALQAData // Equal operator. this->~AliEMCALQADataMakerRec(); new(this) AliEMCALQADataMakerRec(qadm); +// fLineCol = NULL; +// fLineRow = NULL; +// for (Int_t sm = 0 ; sm < fSuperModules ; sm++){ +// fTextSM[sm] = qadm.fTextSM[sm] ; +// } return *this; } @@ -78,10 +181,67 @@ AliEMCALQADataMakerRec& AliEMCALQADataMakerRec::operator = (const AliEMCALQAData void AliEMCALQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list) { //Detector specific actions at end of cycle + +// if(fCycleCounter) +// GetRawsData(kNEventsPerTower)->Scale(1./fCycleCounter); + // do the QA checking AliQAChecker::Instance()->Run(AliQAv1::kEMCAL, task, list) ; } +//____________________________________________________________________________ +void AliEMCALQADataMakerRec::GetCalibRefFromOCDB() +{ + //Get the reference histogram from OCDB + TString sName1("hHighEmcalRawMaxMinusMin") ; + TString sName2("hLowLEDMonEmcalRawMaxMinusMin") ; + sName1.Prepend(Form("%s_", AliRecoParam::GetEventSpecieName(AliRecoParam::kCalib))) ; + sName2.Prepend(Form("%s_", AliRecoParam::GetEventSpecieName(AliRecoParam::kCalib))) ; + + TString refStorage(AliQAv1::GetQARefStorage()) ; + if (!refStorage.Contains(AliQAv1::GetLabLocalOCDB()) && !refStorage.Contains(AliQAv1::GetLabAliEnOCDB())) { + AliFatal(Form("%s is not a valid location for reference data", refStorage.Data())) ; + } else { + AliQAManager* manQA = AliQAManager::QAManager(AliQAv1::kRAWS) ; + AliQAv1::SetQARefDataDirName(AliRecoParam::kCalib) ; + if ( ! manQA->GetLock() ) { + manQA->SetDefaultStorage(AliQAv1::GetQARefStorage()) ; + manQA->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ; + manQA->SetRun(AliCDBManager::Instance()->GetRun()) ; + manQA->SetLock() ; + } + char * detOCDBDir = Form("%s/%s/%s", GetName(), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ; + AliCDBEntry * entry = manQA->Get(detOCDBDir, manQA->GetRun()) ; + if (entry) { + TList * listDetQAD =static_cast(entry->GetObject()) ; + if ( strcmp(listDetQAD->ClassName(), "TList") != 0 ) { + AliError(Form("Expected a Tlist and found a %s for detector %s", listDetQAD->ClassName(), GetName())) ; + listDetQAD = NULL ; + } + TObjArray * dirOCDB= NULL ; + if ( listDetQAD ) + dirOCDB = static_cast(listDetQAD->FindObject(Form("%s/%s", AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), AliRecoParam::GetEventSpecieName(AliRecoParam::kCalib)))) ; + if (dirOCDB){ + fCalibRefHistoPro = dynamic_cast(dirOCDB->FindObject(sName1.Data())) ; + fLEDMonRefHistoPro = dynamic_cast(dirOCDB->FindObject(sName2.Data())) ; + } + } + } + + if(fCalibRefHistoPro && fLEDMonRefHistoPro){ + + //Defining histograms binning, each 2D histogram covers all SMs + Int_t nSMSectors = fSuperModules / 2; // 2 SMs per sector + Int_t nbinsZ = 2*AliEMCALGeoParams::fgkEMCALCols; + Int_t nbinsPhi = nSMSectors * AliEMCALGeoParams::fgkEMCALRows; + + if(!fCalibRefHistoH2F) + fCalibRefHistoH2F = new TH2F("hCalibRefHisto", "hCalibRefHisto", nbinsZ, -0.5, nbinsZ - 0.5, nbinsPhi, -0.5, nbinsPhi -0.5); + ConvertProfile2H(fCalibRefHistoPro,fCalibRefHistoH2F) ; + } else { + AliFatal(Form("No reference object with name %s or %s found", sName1.Data(), sName2.Data())) ; + } +} //____________________________________________________________________________ void AliEMCALQADataMakerRec::InitESDs() { @@ -89,40 +249,55 @@ void AliEMCALQADataMakerRec::InitESDs() const Bool_t expert = kTRUE ; const Bool_t image = kTRUE ; - TH1F * h1 = new TH1F("hESDCaloClusterE", "ESDs CaloCluster energy in EMCAL", 200, 0., 20.) ; + TH1F * h1 = new TH1F("hESDCaloClusterE", "ESDs CaloCluster energy in EMCAL;Energy [GeV];Counts", 200, 0., 100.) ; h1->Sumw2() ; Add2ESDsList(h1, kESDCaloClusE, !expert, image) ; - TH1I * h2 = new TH1I("hESDCaloClusterM", "ESDs CaloCluster multiplicity in EMCAL", 100, 0, 100) ; + TH1I * h2 = new TH1I("hESDCaloClusterM", "ESDs CaloCluster multiplicity in EMCAL;# of Clusters;Entries", 100, 0, 100) ; h2->Sumw2() ; Add2ESDsList(h2, kESDCaloClusM, !expert, image) ; - TH1F * h3 = new TH1F("hESDCaloCellA", "ESDs CaloCell amplitude in EMCAL", 500, 0., 250.) ; + TH1F * h3 = new TH1F("hESDCaloCellA", "ESDs CaloCell amplitude in EMCAL;Energy [GeV];Counts", 500, 0., 50.) ; h3->Sumw2() ; Add2ESDsList(h3, kESDCaloCellA, !expert, image) ; - TH1I * h4 = new TH1I("hESDCaloCellM", "ESDs CaloCell multiplicity in EMCAL", 200, 0, 1000) ; + TH1I * h4 = new TH1I("hESDCaloCellM", "ESDs CaloCell multiplicity in EMCAL;# of Clusters;Entries", 200, 0, 1000) ; h4->Sumw2() ; Add2ESDsList(h4, kESDCaloCellM, !expert, image) ; } +//____________________________________________________________________________ +void AliEMCALQADataMakerRec::InitDigits() +{ + // create Digits histograms in Digits subdir + const Bool_t expert = kTRUE ; + const Bool_t image = kTRUE ; + + TH1I * h0 = new TH1I("hEmcalDigits", "Digits amplitude distribution in EMCAL;Amplitude [ADC counts];Counts", 500, 0, 500) ; + h0->Sumw2() ; + Add2DigitsList(h0, 0, !expert, image) ; + TH1I * h1 = new TH1I("hEmcalDigitsMul", "Digits multiplicity distribution in EMCAL;# of Digits;Entries", 200, 0, 2000) ; + h1->Sumw2() ; + Add2DigitsList(h1, 1, !expert, image) ; +} + //____________________________________________________________________________ void AliEMCALQADataMakerRec::InitRecPoints() { - // create Reconstructed Points histograms in RecPoints subdir + // create Reconstructed PoInt_ts histograms in RecPoints subdir const Bool_t expert = kTRUE ; const Bool_t image = kTRUE ; - TH1F* h0 = new TH1F("hEMCALRpE","EMCAL RecPoint energies",200, 0.,20.); //GeV + TH1F* h0 = new TH1F("hEMCALRpE","EMCAL RecPoint energies;Energy [GeV];Counts",200, 0.,20.); //GeV h0->Sumw2(); Add2RecPointsList(h0,kRecPE, !expert, image); - TH1I* h1 = new TH1I("hEMCALRpM","EMCAL RecPoint multiplicities",100,0,100); + TH1I* h1 = new TH1I("hEMCALRpM","EMCAL RecPoint multiplicities;# of Clusters;Entries",100,0,100); h1->Sumw2(); Add2RecPointsList(h1,kRecPM, !expert, image); - TH1I* h2 = new TH1I("hEMCALRpDigM","EMCAL RecPoint Digit Multiplicities",20,0,20); + TH1I* h2 = new TH1I("hEMCALRpDigM","EMCAL RecPoint Digit Multiplicities;# of Digits;Entries",20,0,20); h2->Sumw2(); Add2RecPointsList(h2,kRecPDigM, !expert, image); @@ -132,61 +307,188 @@ void AliEMCALQADataMakerRec::InitRecPoints() void AliEMCALQADataMakerRec::InitRaws() { // create Raws histograms in Raws subdir - const Bool_t expert = kTRUE ; - const Bool_t saveCorr = kTRUE ; - const Bool_t image = kTRUE ; - - int nTowersPerSM = 1152; // number of towers in a SuperModule; 24x48 - int nTot = fSuperModules * nTowersPerSM; // max number of towers in all SuperModules + const Bool_t expert = kTRUE ; + const Bool_t saveCorr = kTRUE ; + const Bool_t image = kTRUE ; + const Option_t *profileOption = "s"; - // counter info: number of channels per event (bins are SM index) - TProfile * h0 = new TProfile("hLowEmcalSupermodules", "Low Gain EMC: # of towers vs SuperMod", - fSuperModules, -0.5, fSuperModules-0.5) ; - Add2RawsList(h0, kNsmodLG, !expert, image, !saveCorr) ; - TProfile * h1 = new TProfile("hHighEmcalSupermodules", "High Gain EMC: # of towers vs SuperMod", - fSuperModules, -0.5, fSuperModules-0.5) ; - Add2RawsList(h1, kNsmodHG, !expert, image, !saveCorr) ; + Int_t nTowersPerSM = AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols; // number of towers in a SuperModule; 24x48 + Int_t nTot = fSuperModules * nTowersPerSM; // max number of towers in all SuperModules + + //Defining histograms binning, each 2D histogram covers all SMs + Int_t nSMSectors = fSuperModules / 2; // 2 SMs per sector + Int_t nbinsZ = 2*AliEMCALGeoParams::fgkEMCALCols; + Int_t nbinsPhi = nSMSectors * AliEMCALGeoParams::fgkEMCALRows; + + // 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) ; + Add2RawsList(h0, kNsmodLG, expert, !image, !saveCorr) ; + TProfile * h1 = new TProfile("hHighEmcalSupermodules", "High Gain EMC: # of towers vs SuperMod;SM Id;# of towers", + fSuperModules, -0.5, fSuperModules-0.5, profileOption) ; + Add2RawsList(h1, kNsmodHG, expert, !image, !saveCorr) ; // where did max sample occur? (bins are towers) - TProfile * h2 = new TProfile("hLowEmcalRawtime", "Low Gain EMC: Time at Max vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h2, kTimeLG, !expert, image, !saveCorr) ; - TProfile * h3 = new TProfile("hHighEmcalRawtime", "High Gain EMC: Time at Max vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h3, kTimeHG, !expert, image, !saveCorr) ; + TProfile * h2 = new TProfile("hLowEmcalRawtime", "Low Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]", + nTot, -0.5, nTot-0.5, profileOption) ; + Add2RawsList(h2, kTimeLG, expert, !image, !saveCorr) ; + TProfile * h3 = new TProfile("hHighEmcalRawtime", "High Gain EMC: Time at Max vs towerId;Tower Id;Time [ticks]", + nTot, -0.5, nTot-0.5, profileOption) ; + Add2RawsList(h3, kTimeHG, expert, !image, !saveCorr) ; // how much above pedestal was the max sample? (bins are towers) - TProfile * h4 = new TProfile("hLowEmcalRawMaxMinusMin", "Low Gain EMC: Max - Min vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h4, kSigLG, !expert, image, !saveCorr) ; - TProfile * h5 = new TProfile("hHighEmcalRawMaxMinusMin", "High Gain EMC: Max - Min vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h5, kSigHG, !expert, image, !saveCorr) ; + TProfile * h4 = new TProfile("hLowEmcalRawMaxMinusMin", "Low Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]", + nTot, -0.5, nTot-0.5, profileOption) ; + Add2RawsList(h4, kSigLG, expert, image, !saveCorr) ; + TProfile * h5 = new TProfile("hHighEmcalRawMaxMinusMin", "High Gain EMC: Max - Min vs towerId;Tower Id;Max-Min [ADC counts]", + nTot, -0.5, nTot-0.5, profileOption) ; + Add2RawsList(h5, kSigHG, expert, image, !saveCorr) ; // total counter: channels per event - TH1I * h6 = new TH1I("hLowNtot", "Low Gain EMC: Total Number of found towers", 200, 0, nTot) ; + TH1I * h6 = new TH1I("hLowNtot", "Low Gain EMC: Total Number of found towers;# of Towers;Counts", 200, 0, nTot) ; h6->Sumw2() ; - Add2RawsList(h6, kNtotLG, !expert, image, !saveCorr) ; - TH1I * h7 = new TH1I("hHighNtot", "High Gain EMC: Total Number of found towers", 200,0, nTot) ; + Add2RawsList(h6, kNtotLG, expert, !image, !saveCorr) ; + TH1I * h7 = new TH1I("hHighNtot", "High Gain EMC: Total Number of found towers;# of Towers;Counts", 200,0, nTot) ; h7->Sumw2() ; - Add2RawsList(h7, kNtotHG, !expert, image, !saveCorr) ; + Add2RawsList(h7, kNtotHG, expert, !image, !saveCorr) ; // pedestal (bins are towers) - TProfile * h8 = new TProfile("hLowEmcalRawPed", "Low Gain EMC: Pedestal vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h8, kPedLG, !expert, image, !saveCorr) ; - TProfile * h9 = new TProfile("hHighEmcalRawPed", "High Gain EMC: Pedestal vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h9, kPedHG, !expert, image, !saveCorr) ; - - // pedestal rms (standard dev = sqrt of variance estimator for pedestal) (bins are towers) - TProfile * h10 = new TProfile("hLowEmcalRawPedRMS", "Low Gain EMC: Pedestal RMS vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h10, kPedRMSLG, !expert, image, !saveCorr) ; - TProfile * h11 = new TProfile("hHighEmcalRawPedRMS", "High Gain EMC: Pedestal RMS vs towerId", - nTot, -0.5, nTot-0.5) ; - Add2RawsList(h11, kPedRMSHG, !expert, image, !saveCorr) ; + TProfile * h8 = new TProfile("hLowEmcalRawPed", "Low Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]", + nTot, -0.5, nTot-0.5, profileOption) ; + Add2RawsList(h8, kPedLG, expert, !image, !saveCorr) ; + TProfile * h9 = new TProfile("hHighEmcalRawPed", "High Gain EMC: Pedestal vs towerId;Tower Id;Pedestal [ADC counts]", + nTot, -0.5, nTot-0.5, profileOption) ; + Add2RawsList(h9, kPedHG, expert, !image, !saveCorr) ; + + //temp 2D amplitude histogram for the current run + fHighEmcHistoH2F = new TH2F("h2DHighEC2", "High Gain EMC:Max - Min [ADC counts]", nbinsZ, -0.5 , nbinsZ-0.5, nbinsPhi, -0.5, nbinsPhi-0.5); + fHighEmcHistoH2F->SetDirectory(0) ; // this histo must be memory resident + //add ratio histograms: to comapre the current run with the reference data + TH2F * h15 = new TH2F("h2DRatioAmp", "High Gain Ratio to Reference:Amplitude_{current run}/Amplitude_{reference run}", nbinsZ, -0.5 , nbinsZ-0.5, + nbinsPhi, -0.5, nbinsPhi-0.5); + //settings for display in amore + h15->SetTitle("Amplitude_{current run}/Amplitude_{reference run}"); + h15->SetMaximum(2.0); + h15->SetMinimum(0.1); + h15->SetOption("COLZ"); + gStyle->SetOptStat(0); + Int_t color[] = {4,3,2} ; + gStyle->SetPalette(3,color); + h15->GetZaxis()->SetNdivisions(3); + h15->UseCurrentStyle(); + h15->SetDirectory(0); + 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.); + gStyle->SetOptStat(0); + h16->UseCurrentStyle(); + h16->SetDirectory(0); + Add2RawsList(h16, kRatioDist, !expert, image, !saveCorr) ; + + // now repeat the same for TRU and LEDMon data + Int_t nTot2x2 = fSuperModules * AliEMCALGeoParams::fgkEMCALTRUsPerSM * AliEMCALGeoParams::fgkEMCAL2x2PerTRU; // max number of TRU channels for all SuperModules + + // counter info: number of channels per event (bins are SM index) + TProfile * hT0 = new TProfile("hTRUEmcalSupermodules", "TRU EMC: # of TRU channels vs SuperMod;SM Id;# of TRU channels", + fSuperModules, -0.5, fSuperModules-0.5, profileOption) ; + Add2RawsList(hT0, kNsmodTRU, expert, !image, !saveCorr) ; + + // where did max sample occur? (bins are TRU channels) + TProfile * hT1 = new TProfile("hTRUEmcalRawtime", "TRU EMC: Time at Max vs 2x2Id;2x2 Id;Time [ticks]", + nTot2x2, -0.5, nTot2x2-0.5, profileOption) ; + Add2RawsList(hT1, kTimeTRU, expert, !image, !saveCorr) ; + + // how much above pedestal was the max sample? (bins are TRU channels) + TProfile * hT2 = new TProfile("hTRUEmcalRawMaxMinusMin", "TRU EMC: Max - Min vs 2x2Id;2x2 Id;Max-Min [ADC counts]", + nTot2x2, -0.5, nTot2x2-0.5, profileOption) ; + Add2RawsList(hT2, kSigTRU, expert, !image, !saveCorr) ; + + // total counter: channels per event + TH1I * hT3 = new TH1I("hTRUNtot", "TRU EMC: Total Number of found TRU channels;# of TRU Channels;Counts", 200, 0, nTot2x2) ; + hT3->Sumw2() ; + Add2RawsList(hT3, kNtotTRU, expert, !image, !saveCorr) ; + + // pedestal (bins are TRU channels) + TProfile * hT4 = new TProfile("hTRUEmcalRawPed", "TRU EMC: Pedestal vs 2x2Id;2x2 Id;Pedestal [ADC counts]", + nTot2x2, -0.5, nTot2x2-0.5, profileOption) ; + Add2RawsList(hT4, kPedTRU, expert, !image, !saveCorr) ; + + // L0 trigger hits: # of hits (bins are TRU channels) + TH1I * hT5 = new TH1I("hTRUEmcalL0hits", "L0 trigger hits: Total number of 2x2 L0 generated", nTot2x2, -0.5, nTot2x2); + hT5->Sumw2(); + Add2RawsList(hT5, kNL0TRU, expert, !image, !saveCorr); + + // L0 trigger hits: average time (bins are TRU channels) + TProfile * hT6 = new TProfile("hTRUEmcalL0hitsAvgTime", "L0 trigger hits: average time bin", nTot2x2, -0.5, nTot2x2, profileOption); + Add2RawsList(hT6, kTimeL0TRU, expert, !image, !saveCorr); + + // and also LED Mon.. + // LEDMon has both high and low gain channels, just as regular FEE/towers + Int_t nTotLEDMon = fSuperModules * AliEMCALGeoParams::fgkEMCALLEDRefs; // max number of LEDMon channels for all SuperModules + + // counter info: number of channels per event (bins are SM index) + TProfile * hL0 = new TProfile("hLowLEDMonEmcalSupermodules", "LowLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips", + fSuperModules, -0.5, fSuperModules-0.5, profileOption) ; + Add2RawsList(hL0, kNsmodLGLEDMon, expert, !image, !saveCorr) ; + TProfile * hL1 = new TProfile("hHighLEDMonEmcalSupermodules", "HighLEDMon Gain EMC: # of strips vs SuperMod;SM Id;# of strips", + fSuperModules, -0.5, fSuperModules-0.5, profileOption) ; + Add2RawsList(hL1, kNsmodHGLEDMon, expert, !image, !saveCorr) ; + + // where did max sample occur? (bins are strips) + TProfile * hL2 = new TProfile("hLowLEDMonEmcalRawtime", "LowLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]", + nTotLEDMon, -0.5, nTotLEDMon-0.5, profileOption) ; + Add2RawsList(hL2, kTimeLGLEDMon, expert, !image, !saveCorr) ; + TProfile * hL3 = new TProfile("hHighLEDMonEmcalRawtime", "HighLEDMon Gain EMC: Time at Max vs stripId;Strip Id;Time [ticks]", + nTotLEDMon, -0.5, nTotLEDMon-0.5, profileOption) ; + Add2RawsList(hL3, kTimeHGLEDMon, expert, !image, !saveCorr) ; + + // how much above pedestal was the max sample? (bins are strips) + TProfile * hL4 = new TProfile("hLowLEDMonEmcalRawMaxMinusMin", "LowLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]", + nTotLEDMon, -0.5, nTotLEDMon-0.5, profileOption) ; + Add2RawsList(hL4, kSigLGLEDMon, expert, !image, !saveCorr) ; + TProfile * hL5 = new TProfile("hHighLEDMonEmcalRawMaxMinusMin", "HighLEDMon Gain EMC: Max - Min vs stripId;Strip Id;Max-Min [ADC counts]", + nTotLEDMon, -0.5, nTotLEDMon-0.5, profileOption) ; + Add2RawsList(hL5, kSigHGLEDMon, expert, !image, !saveCorr) ; + + // total counter: channels per event + TH1I * hL6 = new TH1I("hLowLEDMonNtot", "LowLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200, 0, nTotLEDMon) ; + hL6->Sumw2() ; + Add2RawsList(hL6, kNtotLGLEDMon, expert, !image, !saveCorr) ; + TH1I * hL7 = new TH1I("hHighLEDMonNtot", "HighLEDMon Gain EMC: Total Number of found strips;# of Strips;Counts", 200,0, nTotLEDMon) ; + hL7->Sumw2() ; + Add2RawsList(hL7, kNtotHGLEDMon, expert, !image, !saveCorr) ; + + // pedestal (bins are strips) + TProfile * hL8 = new TProfile("hLowLEDMonEmcalRawPed", "LowLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]", + nTotLEDMon, -0.5, nTotLEDMon-0.5, profileOption) ; + Add2RawsList(hL8, kPedLGLEDMon, expert, !image, !saveCorr) ; + TProfile * hL9 = new TProfile("hHighLEDMonEmcalRawPed", "HighLEDMon Gain EMC: Pedestal vs stripId;Strip Id;Pedestal [ADC counts]", + nTotLEDMon, -0.5, nTotLEDMon-0.5, profileOption) ; + Add2RawsList(hL9, kPedHGLEDMon, expert, !image, !saveCorr) ; + //add two histograms for shifter from the LED monitor system: comapre LED monitor with the reference run + //to be used for decision whether we need to change reference data + TH1F * hL10 = new TH1F("hMaxMinusMinLEDMonRatio", "LEDMon amplitude, Ratio to reference run", nTotLEDMon, -0.5, nTotLEDMon-0.5) ; + //settings for display in amore + hL10->SetTitle("Amplitude_{LEDMon current}/Amplitude_{LEDMon reference}"); + hL10->SetMaximum(2.0); + hL10->SetMinimum(0.1); + gStyle->SetOptStat(0); + hL10->UseCurrentStyle(); + hL10->SetDirectory(0); +// hL10->SetOption("E"); + Add2RawsList(hL10, kLEDMonRatio, !expert, image, !saveCorr) ; + + TH1F * hL11 = new TH1F("hMaxMinusMinLEDMonRatioDist", "LEDMon amplitude, Ratio distribution", nTotLEDMon, 0, 2); + hL11->SetMinimum(0.1) ; + gStyle->SetOptStat(0); + hL11->UseCurrentStyle(); + hL11->SetDirectory(0); + Add2RawsList(hL11, kLEDMonRatioDist, !expert, image, !saveCorr) ; + + GetCalibRefFromOCDB(); } //____________________________________________________________________________ @@ -217,155 +519,341 @@ void AliEMCALQADataMakerRec::MakeESDs(AliESDEvent * esd) //____________________________________________________________________________ void AliEMCALQADataMakerRec::MakeRaws(AliRawReader* rawReader) { - //Fill prepared histograms with Raw digit properties - - //Raw histogram filling not yet implemented - // - //Need to figure out how to get the info we want without having to - //actually run Raw2Digits twice. - //I suspect what we actually want is a raw digits method, not a true - //emcal raw data method, but this doesn't seem to be allowed in - //AliQADataMakerRec.h - - // For now, to avoid redoing the expensive signal fits we just - // look at max vs min of the signal spextra, a la online usage in - // AliCaloCalibPedestal + // Check that all the reference histograms exist before we try to use them - otherwise call InitRaws + if (!fCalibRefHistoPro || !fCalibRefHistoH2F || !fLEDMonRefHistoPro || !fHighEmcHistoH2F) { + InitRaws(); + } - rawReader->Reset() ; - AliCaloRawStream in(rawReader,"EMCAL"); + // make sure EMCal was readout during the event + Int_t emcID = AliDAQ::DetectorID("EMCAL"); // bit 18.. + const UInt_t *detPattern = rawReader->GetDetectorPattern(); + UInt_t emcInReadout = ( ((1 << emcID) & detPattern[0]) >> emcID); + if (! emcInReadout) return; // no poInt_t in looking at this event, if no EMCal data // setup - int nTowersPerSM = 1152; // number of towers in a SuperModule; 24x48 - int nRows = 24; // number of rows per SuperModule - int sampleMin = 0; - int sampleMax = 0x3ff; // 1023 = 10-bit range - - // for the pedestal calculation - Bool_t selectPedestalSamples = kTRUE; - int firstPedestalSample = 0; - int lastPedestalSample = 15; - - // SM counters; decl. should be safe, assuming we don't get more than 12 SuperModules.. - int nTotalSMLG[12] = {0}; - int nTotalSMHG[12] = {0}; - - // indices for the reading - int iSM = 0; - int sample = 0; - int gain = 0; - int time = 0; - // counters, on sample level - int i = 0; // the sample number in current event. - int max = sampleMin, min = sampleMax;//Use these for picking the pedestal - int maxTime = 0; - - // for the pedestal calculation - int sampleSum = 0; // sum of samples - int squaredSampleSum = 0; // sum of samples squared - int nSum = 0; // number of samples in sum - // calc. quantities - double meanPed = 0, squaredMean = 0, rmsPed = 0; - - while (in.Next()) { // loop over input stream - sample = in.GetSignal(); //Get the adc signal - time = in.GetTime(); - if (sample < min) { min = sample; } - if (sample > max) { - max = sample; - maxTime = time; - } - i++; - - // should we add it for the pedestal calculation? - if ( (firstPedestalSample<=time && time<=lastPedestalSample) || // sample time in range - !selectPedestalSamples ) { // or we don't restrict the sample range.. - then we'll take all - sampleSum += sample; - squaredSampleSum += sample*sample; - nSum++; - } - - if ( i >= in.GetTimeLength()) { - // calculate pedesstal estimate: mean of possibly selected samples - if (nSum > 0) { - meanPed = sampleSum / (1.0 * nSum); - squaredMean = squaredSampleSum / (1.0 * nSum); - // The variance (rms squared) is equal to the mean of the squares minus the square of the mean.. - rmsPed = sqrt(squaredMean - meanPed*meanPed); - } - else { - meanPed = 0; - squaredMean = 0; - rmsPed = 0; - } - - //If we're here then we're done with this tower - gain = -1; // init to not valid value - if ( in.IsLowGain() ) { - gain = 0; - } - else if ( in.IsHighGain() ) { - gain = 1; - } - - iSM = in.GetModule(); //The modules are numbered starting from 0 + rawReader->Reset() ; + AliCaloRawStreamV3 in(rawReader,"EMCAL"); + rawReader->Select("EMCAL", 0, AliEMCALGeoParams::fgkLastAltroDDL) ; //select EMCAL DDL's - if (iSM>=0 && iSMGetType() == 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; + + // SM counters; decl. should be safe, assuming we don't get more than expected SuperModules.. + Int_t nTotalSMLG[AliEMCALGeoParams::fgkEMCALModules] = {0}; + Int_t nTotalSMHG[AliEMCALGeoParams::fgkEMCALModules] = {0}; + Int_t nTotalSMTRU[AliEMCALGeoParams::fgkEMCALModules] = {0}; + Int_t nTotalSMLGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0}; + Int_t nTotalSMHGLEDMon[AliEMCALGeoParams::fgkEMCALModules] = {0}; + + const Int_t nTRUL0ChannelBits = 10; // used for L0 trigger bits checks + Int_t iSM = 0; // SuperModule index + // start loop over input stream + while (in.NextDDL()) { + Int_t iRCU = in.GetDDLNumber() % 2; // RCU0 or RCU1, within SuperModule + fRawAnalyzer->SetIsZeroSuppressed( in.GetZeroSupp() ); + + while (in.NextChannel()) { + iSM = in.GetModule(); // SuperModule + //prInt_tf("iSM %d DDL %d", iSM, in.GetDDLNumber()); + if (iSM>=0 && iSM bunchlist; + while (in.NextBunch()) { + nsamples += in.GetBunchLength(); + bunchlist.push_back( AliCaloBunchInfo(in.GetStartTimeBin(), in.GetBunchLength(), in.GetSignals() ) ); + } + + if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout + Float_t time = 0.; + Float_t amp = 0.; + // indices for pedestal calc. + Int_t firstPedSample = 0; + Int_t lastPedSample = 0; + bool isTRUL0IdData = false; + + if (! in.IsTRUData() ) { // high gain, low gain, LED Mon data - all have the same shaper/sampling + AliCaloFitResults fitResults = fRawAnalyzer->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2()); + amp = fitResults.GetAmp(); + time = fitResults.GetTof(); + firstPedSample = fFirstPedestalSample; + lastPedSample = fLastPedestalSample; + } + else { // TRU data is special, needs its own analyzer + AliCaloFitResults fitResults = fRawAnalyzerTRU->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2()); + amp = fitResults.GetAmp(); + time = fitResults.GetTof(); + firstPedSample = fFirstPedestalSampleTRU; + lastPedSample = fLastPedestalSampleTRU; + if (in.GetColumn() > n2x2PerTRU) { + isTRUL0IdData = true; + } + } + + // pedestal samples + Int_t nPed = 0; + vector pedSamples; + + // select earliest bunch + unsigned int bunchIndex = 0; + unsigned int startBin = bunchlist.at(0).GetStartBin(); + if (bunchlist.size() > 0) { + for(unsigned int ui=1; ui < bunchlist.size(); ui++ ) { + if (startBin > bunchlist.at(ui).GetStartBin() ) { + startBin = bunchlist.at(ui).GetStartBin(); + bunchIndex = ui; + } + } + } - if (gain == 0) { - //fill the low gain histograms, and counters - nTotalSMLG[iSM]++; // one more channel found - GetRawsData(kSigLG)->Fill(towerId, max - min); - GetRawsData(kTimeLG)->Fill(towerId, maxTime); - if (nSum>0) { // only fill pedestal info in case it could be calculated - GetRawsData(kPedLG)->Fill(towerId, meanPed); - GetRawsData(kPedRMSLG)->Fill(towerId, rmsPed); + // check bunch for entries in the pedestal sample range + Int_t bunchLength = bunchlist.at(bunchIndex).GetLength(); + const UShort_t *sig = bunchlist.at(bunchIndex).GetData(); + Int_t timebin = 0; + + if (! isTRUL0IdData) { // regular data, can look at pedestals + for (Int_t i = 0; iFill(towerId, max - min); - GetRawsData(kTimeHG)->Fill(towerId, maxTime); - if (nSum>0) { // only fill pedestal info in case it could be calculated - GetRawsData(kPedHG)->Fill(towerId, meanPed); - GetRawsData(kPedRMSHG)->Fill(towerId, rmsPed); + else { // TRU L0 Id Data + // which TRU the channel belongs to? + Int_t iTRUId = in.GetModule()*3 + (iRCU*in.GetBranch() + iRCU); + + for (Int_t i = 0; i< bunchLength; i++) { + for( Int_t j = 0; j < nTRUL0ChannelBits; j++ ){ + // check if the bit j is 1 + if( (sig[i] & ( 1 << j )) > 0 ){ + Int_t iTRUIdInSM = (in.GetColumn() - n2x2PerTRU)*nTRUL0ChannelBits+j; + if(iTRUIdInSM < n2x2PerTRU) { + Int_t iTRUAbsId = iTRUIdInSM + n2x2PerTRU * iTRUId; + // Fill the histograms + GetRawsData(kNL0TRU)->Fill(iTRUAbsId); + GetRawsData(kTimeL0TRU)->Fill(iTRUAbsId, 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(); + if ( in.IsLowGain() ) { + nTotalSMLG[iSM]++; + if ( (amp > fMinSignalLG) && (amp < fMaxSignalLG) ) { + GetRawsData(kSigLG)->Fill(towerId, amp); + GetRawsData(kTimeLG)->Fill(towerId, time); + } + if (nPed > 0) { + for (Int_t i=0; iFill(towerId, pedSamples[i]); + } + } + } // gain==0 + else if ( in.IsHighGain() ) { + nTotalSMHG[iSM]++; + if ( (amp > fMinSignalHG) && (amp < fMaxSignalHG) ) { + GetRawsData(kSigHG)->Fill(towerId, amp); + GetRawsData(kTimeHG)->Fill(towerId, time); + } + if (nPed > 0) { + for (Int_t i=0; iFill(towerId, pedSamples[i]); + } + } + } // gain==1 + } // low or high gain + // TRU + else if ( in.IsTRUData() && in.GetColumn() fMinSignalTRU) && (amp < fMaxSignalTRU) ) { + GetRawsData(kSigTRU)->Fill(iTRU2x2Id, amp); + GetRawsData(kTimeTRU)->Fill(iTRU2x2Id, time); + } + if (nPed > 0) { + for (Int_t i=0; iFill(iTRU2x2Id, pedSamples[i]); + } + } } - } - } // SM index OK - - // reset counters - max = sampleMin; min = sampleMax; - maxTime = 0; - i = 0; - // also pedestal calc counters - sampleSum = 0; // sum of samples - squaredSampleSum = 0; // sum of samples squared - nSum = 0; // number of samples in sum - - }//End if, of channel + // LED Mon + else if ( in.IsLEDMonData() ) { + // for LED Mon data, the mapping class holds the gain info in the Row variable + // and the Strip number in the Column.. + Int_t gain = in.GetRow(); + Int_t stripId = iSM*nStripsPerSM + in.GetColumn(); + + if ( gain == 0 ) { + nTotalSMLGLEDMon[iSM]++; + if ( (amp > fMinSignalLGLEDMon) && (amp < fMaxSignalLGLEDMon) ) { + GetRawsData(kSigLGLEDMon)->Fill(stripId, amp); + GetRawsData(kTimeLGLEDMon)->Fill(stripId, time); + } + if (nPed > 0) { + for (Int_t i=0; iFill(stripId, pedSamples[i]); + } + } + } // gain==0 + else if ( gain == 1 ) { + nTotalSMHGLEDMon[iSM]++; + if ( (amp > fMinSignalHGLEDMon) && (amp < fMaxSignalHGLEDMon) ) { + GetRawsData(kSigHGLEDMon)->Fill(stripId, amp); + GetRawsData(kTimeHGLEDMon)->Fill(stripId, time); + } + if (nPed > 0) { + for (Int_t i=0; iFill(stripId, pedSamples[i]); + } + } + } // low or high gain + } // LEDMon + + } // SM index OK + + } // nsamples>0 check, some data found for this channel; not only trailer/header + }// end while over channel - }//end while, of stream + }//end while over DDL's, of input stream + // TProfile * p = dynamic_cast(GetRawsData(kSigHG)) ; + ConvertProfile2H(dynamic_cast(GetRawsData(kSigHG)), fHighEmcHistoH2F) ; + Double_t binContent = 0. ; + + + //calculate the ratio of the amplitude and fill the histograms, only if the events type is Calib + if (rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent) { + //reset ratio histograms + GetRawsData(k2DRatioAmp)->Reset("ICE"); + GetRawsData(kRatioDist)->Reset("ICE"); + GetRawsData(kLEDMonRatio)->Reset("ICE"); + GetRawsData(kLEDMonRatioDist)->Reset("ICE"); + GetRawsData(k2DRatioAmp)->ResetStats(); + GetRawsData(kRatioDist)->ResetStats(); + GetRawsData(kLEDMonRatio)->ResetStats(); + GetRawsData(kLEDMonRatioDist)->ResetStats(); + + for(Int_t ix = 1; ix <= fHighEmcHistoH2F->GetNbinsX(); ix++) { + for(Int_t iy = 1; iy <= fHighEmcHistoH2F->GetNbinsY(); iy++) { + if(fCalibRefHistoH2F->GetBinContent(ix, iy))binContent = fHighEmcHistoH2F->GetBinContent(ix, iy)/fCalibRefHistoH2F->GetBinContent(ix, iy) ; + GetRawsData(k2DRatioAmp)->SetBinContent(ix, iy, binContent); + GetRawsData(kRatioDist)->Fill(GetRawsData(k2DRatioAmp)->GetBinContent(ix, iy)); + } + } + + //Now for LED monitor system, to calculate the ratio as well + Double_t binError = 0. ; + // for the binError, we add the relative errors, squared + Double_t relativeErrorSqr = 0. ; + + for(int ib = 1; ib <= fLEDMonRefHistoPro->GetNbinsX(); ib++) { + + if(fLEDMonRefHistoPro->GetBinContent(ib) != 0) { + binContent = GetRawsData(kSigLGLEDMon)->GetBinContent(ib) / fLEDMonRefHistoPro->GetBinContent(ib); + + relativeErrorSqr = TMath::Power( (fLEDMonRefHistoPro->GetBinError(ib) / fLEDMonRefHistoPro->GetBinContent(ib)), 2); + if(GetRawsData(kSigLGLEDMon)->GetBinContent(ib) != 0) { + relativeErrorSqr += TMath::Power( (GetRawsData(kSigLGLEDMon)->GetBinError(ib)/GetRawsData(kSigLGLEDMon)->GetBinContent(ib)), 2); + } + } + else { + binContent = 0; + relativeErrorSqr = 0; + } + GetRawsData(kLEDMonRatio)->SetBinContent(ib, binContent); + + binError = sqrt(relativeErrorSqr) * binContent; + GetRawsData(kLEDMonRatio)->SetBinError(ib, binError); + GetRawsData(kLEDMonRatioDist)->Fill(GetRawsData(kLEDMonRatio)->GetBinContent(ib)); + } + + } // let's also fill the SM and event counter histograms - int nTotalHG = 0; - int nTotalLG = 0; + Int_t nTotalHG = 0; + Int_t nTotalLG = 0; + Int_t nTotalTRU = 0; + Int_t nTotalHGLEDMon = 0; + Int_t nTotalLGLEDMon = 0; for (iSM=0; iSMFill(iSM, nTotalSMLG[iSM]); GetRawsData(kNsmodHG)->Fill(iSM, nTotalSMHG[iSM]); + GetRawsData(kNsmodTRU)->Fill(iSM, nTotalSMTRU[iSM]); + GetRawsData(kNsmodLGLEDMon)->Fill(iSM, nTotalSMLGLEDMon[iSM]); + GetRawsData(kNsmodHGLEDMon)->Fill(iSM, nTotalSMHGLEDMon[iSM]); } + GetRawsData(kNtotLG)->Fill(nTotalLG); GetRawsData(kNtotHG)->Fill(nTotalHG); + GetRawsData(kNtotTRU)->Fill(nTotalTRU); + GetRawsData(kNtotLGLEDMon)->Fill(nTotalLGLEDMon); + GetRawsData(kNtotHGLEDMon)->Fill(nTotalHGLEDMon); + + SetEventSpecie(saveSpecie) ; // just in case the next rawreader consumer forgets to reset; let's do it here again.. rawReader->Reset() ; return; } +//____________________________________________________________________________ +void AliEMCALQADataMakerRec::MakeDigits() +{ + // makes data from Digits + + GetDigitsData(1)->Fill(fDigitsArray->GetEntriesFast()) ; + TIter next(fDigitsArray) ; + AliEMCALDigit * digit ; + while ( (digit = dynamic_cast(next())) ) { + GetDigitsData(0)->Fill( digit->GetAmplitude()) ; + } + +} + +//____________________________________________________________________________ +void AliEMCALQADataMakerRec::MakeDigits(TTree * digitTree) +{ + // makes data from Digit Tree + if (fDigitsArray) + fDigitsArray->Clear("C") ; + else + fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ; + + TBranch * branch = digitTree->GetBranch("EMCAL") ; + if ( ! branch ) { + AliWarning("EMCAL branch in Digit Tree not found") ; + } else { + branch->SetAddress(&fDigitsArray) ; + branch->GetEntry(0) ; + MakeDigits() ; + } + +} + //____________________________________________________________________________ void AliEMCALQADataMakerRec::MakeRecPoints(TTree * clustersTree) { @@ -375,19 +863,20 @@ void AliEMCALQADataMakerRec::MakeRecPoints(TTree * clustersTree) AliError("can't get the branch with the EMCAL clusters !"); return; } - TObjArray * emcrecpoints = new TObjArray(100) ; - emcbranch->SetAddress(&emcrecpoints); + + TObjArray * emcRecPoints = new TObjArray(100) ; + emcbranch->SetAddress(&emcRecPoints); emcbranch->GetEntry(0); - GetRecPointsData(kRecPM)->Fill(emcrecpoints->GetEntriesFast()) ; - TIter next(emcrecpoints) ; + GetRecPointsData(kRecPM)->Fill(emcRecPoints->GetEntriesFast()) ; + TIter next(emcRecPoints) ; AliEMCALRecPoint * rp ; while ( (rp = dynamic_cast(next())) ) { - GetRecPointsData(kRecPE)->Fill( rp->GetEnergy()) ; + GetRecPointsData(kRecPE)->Fill(rp->GetEnergy()) ; GetRecPointsData(kRecPDigM)->Fill(rp->GetMultiplicity()); } - emcrecpoints->Delete(); - delete emcrecpoints; + emcRecPoints->Delete(); + delete emcRecPoints; } @@ -398,3 +887,100 @@ void AliEMCALQADataMakerRec::StartOfDetectorCycle() } +//____________________________________________________________________________ +void AliEMCALQADataMakerRec::SetFittingAlgorithm(Int_t fitAlgo) +{ + //Set fitting algorithm and initialize it if this same algorithm was not set before. + //printf("**** Set Algorithm , number %d ****\n",fitAlgo); + + + fRawAnalyzer = AliCaloRawAnalyzerFactory::CreateAnalyzer(fitAlgo); + fFittingAlgorithm = fitAlgo; + + /* + if(fitAlgo == fFittingAlgorithm && fRawAnalyzer) { + //Do nothing, this same algorithm already set before. + //printf("**** Algorithm already set before, number %d, %s ****\n",fitAlgo, fRawAnalyzer->GetName()); + return; + } + //Initialize the requested algorithm + if(fitAlgo != fFittingAlgorithm || !fRawAnalyzer) { + //printf("**** Init Algorithm , number %d ****\n",fitAlgo); + + fFittingAlgorithm = fitAlgo; + if (fRawAnalyzer) delete fRawAnalyzer; // delete prev. analyzer if existed. + + if (fitAlgo == kFastFit) { + fRawAnalyzer = new AliCaloRawAnalyzerFastFit(); + } + else if (fitAlgo == kNeuralNet) { + fRawAnalyzer = new AliCaloRawAnalyzerNN(); + } + else if (fitAlgo == kLMS) { + fRawAnalyzer = new AliCaloRawAnalyzerLMS(); + } + else if (fitAlgo == kPeakFinder) { + fRawAnalyzer = new AliCaloRawAnalyzerPeakFinder(); + } + else if (fitAlgo == kCrude) { + fRawAnalyzer = new AliCaloRawAnalyzerCrude(); + } + else { + AliWarning("EMCAL QA invalid fit algorithm choice") ; + } + + } + return; + */ +} + +//_____________________________________________________________________________________ +void AliEMCALQADataMakerRec::ConvertProfile2H(TProfile * p, TH2 * histo) +{ + // reset histogram + histo->Reset("ICE") ; + histo->ResetStats(); + + Int_t nbinsProf = p->GetNbinsX(); + + // loop through the TProfile p and fill the TH2F histo + Int_t row = 0; + Int_t col = 0; + Double_t binContent = 0; + Int_t towerNum = 0; // global tower Id + // i = 0; // tower Id within SuperModule + Int_t iSM = 0; // SuperModule index + Int_t iSMSide = 0; // 0=A, 1=C side + Int_t iSMSector = 0; // 2 SM's per sector + + // indices for 2D plots + Int_t col2d = 0; + Int_t row2d = 0; + + for (Int_t ibin = 1; ibin <= nbinsProf; ibin++) { + towerNum = (Int_t) p->GetBinCenter(ibin); + binContent = p->GetBinContent(ibin); + + // figure out what the tower indices are: col, row within a SuperModule + iSM = towerNum/(AliEMCALGeoParams::fgkEMCALRows * AliEMCALGeoParams::fgkEMCALCols); + col = (towerNum/AliEMCALGeoParams::fgkEMCALRows) % (AliEMCALGeoParams::fgkEMCALCols); + row = towerNum % (AliEMCALGeoParams::fgkEMCALRows); + + //DecodeTowerNum(towerNum, &SM, &col, &row); + // then we calculate what the global 2D coord are, based on which SM + // we are in + iSMSector = iSM / 2; + iSMSide = iSM % 2; + + if (iSMSide == 1) { // C side, shown to the right + col2d = col + AliEMCALGeoParams::fgkEMCALCols; + } + else { // A side, shown to the left + col2d = col; + } + + row2d = row + iSMSector * AliEMCALGeoParams::fgkEMCALRows; + + histo->SetBinContent(col2d+1, row2d+1, binContent); + } +}