From eef0e082260ec8cd706d303f84f1e8a97e50399e Mon Sep 17 00:00:00 2001 From: loizides Date: Mon, 29 Aug 2011 18:55:14 +0000 Subject: [PATCH] clusterize on fastor level. Still needs work on coding convention. Code should be moved to UserTasks. --- PWG4/CMakelibPWG4CaloCalib.pkg | 2 + .../AliAnalysisTaskEMCALFastOR2Trigger.cxx | 304 ++++++++++++++++++ .../AliAnalysisTaskEMCALFastOR2Trigger.h | 72 +++++ PWG4/CaloCalib/AliEMCALFastORPatch.cxx | 170 ++++++++++ PWG4/CaloCalib/AliEMCALFastORPatch.h | 40 +++ PWG4/PWG4CaloCalibLinkDef.h | 3 + 6 files changed, 591 insertions(+) create mode 100755 PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.cxx create mode 100644 PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.h create mode 100644 PWG4/CaloCalib/AliEMCALFastORPatch.cxx create mode 100644 PWG4/CaloCalib/AliEMCALFastORPatch.h diff --git a/PWG4/CMakelibPWG4CaloCalib.pkg b/PWG4/CMakelibPWG4CaloCalib.pkg index a0be0242315..d95dfe3ea62 100644 --- a/PWG4/CMakelibPWG4CaloCalib.pkg +++ b/PWG4/CMakelibPWG4CaloCalib.pkg @@ -33,6 +33,8 @@ set ( SRCS CaloCalib/AliAnalysisTaskEMCALClusterize.cxx CaloCalib/AliAnalysisTaskEMCALClusterizeFast.cxx CaloCalib/AliAnalysisTaskEMCALPi0PbPb.cxx + CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.cxx + CaloCalib/AliEMCALFastORPatch.cxx ) string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) diff --git a/PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.cxx b/PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.cxx new file mode 100755 index 00000000000..c3f94d996e7 --- /dev/null +++ b/PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.cxx @@ -0,0 +1,304 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +/* $Id$ */ + +/* AliAnalysisTaskEMCALFastOR2Trigger.cxx + * + */ + +#include "AliAnalysisTaskEMCALFastOR2Trigger.h" + +#include +#include +#include +#include +#include + +#include "AliAnalysisTaskSE.h" +#include "AliAnalysisManager.h" +#include "AliStack.h" +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" +#include "AliAODEvent.h" +#include "AliMCEvent.h" +#include "AliEMCALGeometry.h" +#include "AliCaloCalibPedestal.h" + +#include "AliEMCALFastORPatch.h" + +ClassImp(AliAnalysisTaskEMCALFastOR2Trigger) + +//________________________________________________________________________ +AliAnalysisTaskEMCALFastOR2Trigger::AliAnalysisTaskEMCALFastOR2Trigger() // All data members should be initialised here +:AliAnalysisTaskSE(), +fMinL0Time(7), +fMaxL0Time(9), +fTimeCutOn(1), +fTriggerClustersName("triggerClusters"), +fPedestal(0), +fCheckDeadClusters(0), +nRow(2), +nCol(2), +shiftRow(1), +shiftCol(1) // The last in the above list should not have a comma after it +{ + // Dummy constructor ALWAYS needed for I/O. +} + +//________________________________________________________________________ +AliAnalysisTaskEMCALFastOR2Trigger::AliAnalysisTaskEMCALFastOR2Trigger(const char *name) // All data members should be initialised here +:AliAnalysisTaskSE(name), +fMinL0Time(7), +fMaxL0Time(9), +fTimeCutOn(1), +fTriggerClustersName("triggerClusters"), +fPedestal(0), +fCheckDeadClusters(0), +nRow(2), +nCol(2), +shiftRow(1), +shiftCol(1) // The last in the above list should not have a comma after it +{ + // Constructor + +} + +//________________________________________________________________________ +AliAnalysisTaskEMCALFastOR2Trigger::~AliAnalysisTaskEMCALFastOR2Trigger() +{ + // Destructor. +} + +//________________________________________________________________________ +void AliAnalysisTaskEMCALFastOR2Trigger::UserCreateOutputObjects() +{ + // Called once (on the worker node) +} + +//________________________________________________________________________ +void AliAnalysisTaskEMCALFastOR2Trigger::UserExec(Option_t *) +{ + // Main loop + // Called for each event + + // Create pointer to reconstructed event + AliVEvent *event = InputEvent(); + if (!event) { Printf("ERROR: Could not retrieve event"); return; } + + // create pointer to event + AliESDEvent* esd = dynamic_cast(event); + if (!esd) + { + AliError("Cannot get the ESD event"); + return; + } + + AliESDCaloTrigger *triggers = esd->GetCaloTrigger("EMCAL"); + + if (!triggers || !(triggers->GetEntries() > 0)) + return; + + AliEMCALGeometry *fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName()); + Int_t nSupMod = 0, nModule = 0, nIphi = 0, nIeta = 0, iphi = 0, ieta = 0; + + // ------------------------------- + // Trigger clusterizer parameters + + Int_t totalCols = 48; + Int_t totalRows = 60; + Int_t nTRURow = 15; + Int_t nTRUCol = 2; + Int_t nColFastOR = totalCols / nTRUCol; + Int_t nRowFastOR = totalRows / nTRURow; + Int_t maxiShiftRow = nRow / shiftRow; + Int_t maxiShiftCol = nCol / shiftCol; + Int_t nFastORCluster = nCol * nRow; + Int_t nTriggerClusters = totalRows * totalCols / nCol / nRow; + Int_t nTotalClus = nTriggerClusters * maxiShiftCol * maxiShiftRow; + Int_t nClusRowNoShift = nRowFastOR / nRow; + Int_t nClusColNoShift = nColFastOR / nCol; + + TClonesArray *triggers_array = dynamic_cast(InputEvent()->FindListObject(fTriggerClustersName)); + if(!triggers_array) + { + triggers_array = new TClonesArray("AliESDCaloTrigger", nTotalClus); + triggers_array->SetName(fTriggerClustersName); + InputEvent()->AddObject(triggers_array); + } + else + { + triggers_array->Delete(); + } + + Bool_t *dead_clusters = new Bool_t[nTotalClus]; + for (Int_t i = 0; i < nTotalClus; i++) + { + dead_clusters[i] = kFALSE; + } + // ------------------------------- + + triggers->Reset(); + + while (triggers->Next()) + { + Float_t L0FastORamp = 0; + + triggers->GetAmplitude(L0FastORamp); + + if (L0FastORamp < 0) + continue; + + if (fTimeCutOn) + { + + Int_t ntimes = 0; + triggers->GetNL0Times(ntimes); + + if (ntimes < 1) + continue; + + Int_t trgtimes[25]; + triggers->GetL0Times(trgtimes); + + Bool_t trgInTimeWindow = 0; + for (Int_t i = 0; i < ntimes; i++) + { + if ((fMaxL0Time >= trgtimes[i]) && (fMinL0Time <= trgtimes[i])) + trgInTimeWindow = 1; + } + + if (!trgInTimeWindow) + continue; + } + + Int_t gCol = 0, gRow = 0; + + triggers->GetPosition(gCol, gRow); + + Int_t find = -1; + fGeom->GetAbsFastORIndexFromPositionInEMCAL(gCol, gRow, find); + + if (find<0) + continue; + + Int_t cidx[4] = {-1}; + Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx); + + if (!ret) + continue; + + Bool_t deadCluster = kFALSE; + + if (fCheckDeadClusters && fPedestal) + { + for (Int_t i = 0; i < 4; i++) + { + fGeom->GetCellIndex (cidx[i], nSupMod, nModule, nIphi, nIeta); + fGeom->GetCellPhiEtaIndexInSModule (nSupMod, nModule, nIphi, nIeta, iphi, ieta); + + Double_t d = fPedestal->GetDeadMap(nSupMod)->GetBinContent(ieta,iphi); + if (d == AliCaloCalibPedestal::kDead || d == AliCaloCalibPedestal::kHot) + { + deadCluster = kTRUE; + } + } + } + + // -------------------------- + // Trigger clusterizer + + for (Int_t ishiftRow = 0; ishiftRow < maxiShiftRow; ishiftRow++) + { + Int_t nClusRow = (nRowFastOR - shiftRow * ishiftRow) / nRow; + + for (Int_t ishiftCol = 0; ishiftCol < maxiShiftCol; ishiftCol++) + { + Int_t iTotalClus = nTriggerClusters * (ishiftRow * maxiShiftCol + ishiftCol); + + Int_t nClusCol = (nColFastOR - shiftCol * ishiftCol) / nCol; + + Int_t irow_eff = gRow - shiftRow * ishiftRow; + Int_t iTRUrow = irow_eff / nRowFastOR; + irow_eff -= iTRUrow * nRowFastOR; + Int_t iClusRow = irow_eff / nRow; + + if (irow_eff < 0 || iClusRow >= nClusRow) + continue; + + Int_t icol_eff = gCol - shiftCol * ishiftCol; + Int_t iTRUcol = icol_eff / nColFastOR; + icol_eff -= iTRUcol * nColFastOR; + Int_t iClusCol = icol_eff / nCol; + + if (icol_eff < 0 || iClusCol >= nClusCol) + continue; + + irow_eff += iTRUrow * nRowFastOR; + iClusRow = irow_eff / nRow; + + icol_eff += iTRUcol * nColFastOR; + iClusCol = icol_eff / nCol; + + Int_t iTriggerCluster = iClusRow + iClusCol * nClusRowNoShift * nTRURow + iTotalClus; + Int_t iTriggerDigit = irow_eff % nRow + (icol_eff % nCol) * nRow; + + if (dead_clusters[iTriggerCluster] && fCheckDeadClusters) deadCluster = kTRUE; + + if (deadCluster) + { + dead_clusters[iTriggerCluster] = kTRUE; + if (triggers_array->At(iTriggerCluster)) + { + triggers_array->RemoveAt(iTriggerCluster); + } + continue; + } + + if (!triggers_array->At(iTriggerCluster)) + { + (*triggers_array)[iTriggerCluster] = new AliEMCALFastORPatch(iTriggerCluster, nFastORCluster); + } + + AliEMCALFastORPatch *triggerCluster = dynamic_cast(triggers_array->At(iTriggerCluster)); + + if (triggerCluster->GetFastORamplitude(iTriggerDigit) > -1) + { + AliFatal("ERROR: FastOR already added!"); + return; + } + + triggerCluster->AddFastORat(L0FastORamp, gCol, gRow, iTriggerDigit); + + } // loop on col shift + + } // loop on row shift + + // ------------------------------ + } // loop on L0 FastOR triggers + + delete[] dead_clusters; + + triggers_array->Compress(); +} + + +//________________________________________________________________________ +void AliAnalysisTaskEMCALFastOR2Trigger::Terminate(Option_t *) +{ + // Called once at the end of the query + + +} diff --git a/PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.h b/PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.h new file mode 100644 index 00000000000..6f738bc48a1 --- /dev/null +++ b/PWG4/CaloCalib/AliAnalysisTaskEMCALFastOR2Trigger.h @@ -0,0 +1,72 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + + +#ifndef ALIANALYSISTASKEMCALFASTOR2TRIGGER_H +#define ALIANALYSISTASKEMCALFASTOR2TRIGGER_H + +class TList; +class TTree; +class AliEMCALFastORPatch; +class AliCaloCalibPedestal; + +#include "AliAnalysisTaskSE.h" + +class AliAnalysisTaskEMCALFastOR2Trigger : public AliAnalysisTaskSE { +public: + AliAnalysisTaskEMCALFastOR2Trigger(); + AliAnalysisTaskEMCALFastOR2Trigger(const char *name); + virtual ~AliAnalysisTaskEMCALFastOR2Trigger(); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + + void SetCheckDeadClusters(Bool_t c) {fCheckDeadClusters = c;} + Bool_t GetCheckDeadClusters() {return fCheckDeadClusters;} + + void SetPedestal(AliCaloCalibPedestal *pds) {fPedestal = pds;} + AliCaloCalibPedestal* GetPedestal() {return fPedestal;} + + void SetnCol(Int_t n) {nCol = n;} + Int_t GetnCol() {return nCol;} + void SetnRow(Int_t n) {nRow = n;} + Int_t GetnRow() {return nRow;} + void SetshiftCol(Int_t n) {shiftCol = n;} + Int_t GetshiftCol() {return shiftCol;} + void SetshiftRow(Int_t n) {shiftRow = n;} + Int_t GetshiftRow() {return shiftRow;} + + void SetTriggerClustersName(TString name) {fTriggerClustersName = name;} + + Int_t GetMinL0Time() {return fMinL0Time;} + void SetMinL0Time(Int_t t) {fMinL0Time = t;} + Int_t GetMaxL0Time() {return fMaxL0Time;} + void SetMaxL0Time(Int_t t) {fMaxL0Time = t;} + + Bool_t GetTimeCutOn() {return fTimeCutOn;} + + void SetTimeCutOn(Bool_t yes) {fTimeCutOn = yes;} + +private: + Bool_t fCheckDeadClusters; + Int_t nCol; + Int_t nRow; + Int_t shiftCol; + Int_t shiftRow; + AliCaloCalibPedestal *fPedestal; + TString fTriggerClustersName; + Int_t fMinL0Time; + Int_t fMaxL0Time; + Bool_t fTimeCutOn; + + AliAnalysisTaskEMCALFastOR2Trigger (const AliAnalysisTaskEMCALFastOR2Trigger&); // not implemented + AliAnalysisTaskEMCALFastOR2Trigger operator=(const AliAnalysisTaskEMCALFastOR2Trigger&); // not implemented + + ClassDef(AliAnalysisTaskEMCALFastOR2Trigger, 1); +}; + +#endif + diff --git a/PWG4/CaloCalib/AliEMCALFastORPatch.cxx b/PWG4/CaloCalib/AliEMCALFastORPatch.cxx new file mode 100644 index 00000000000..028ff0967c9 --- /dev/null +++ b/PWG4/CaloCalib/AliEMCALFastORPatch.cxx @@ -0,0 +1,170 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +/* $Id$ */ + +#include "AliEMCALFastORPatch.h" + +#include +#include + +#include "AliESDCaloTrigger.h" + +ClassImp(AliEMCALFastORPatch) + +AliEMCALFastORPatch::AliEMCALFastORPatch() +:TObject(), +fFastORamplitudes(0), +fFastORcolumns(0), +fFastORrows(0), +fSize(0), +fAbsId(-1) +{ + // Dummy constructor +} + +AliEMCALFastORPatch::AliEMCALFastORPatch(Int_t aid, Int_t size) +:TObject(), +fFastORamplitudes(new Float_t[size]), +fFastORcolumns(new Int_t[size]), +fFastORrows(new Int_t[size]), +fSize(4), +fAbsId(aid) +{ + // Constructor + for (Int_t i = 0; i < fSize; i++) + { + fFastORamplitudes[i] = -1; + fFastORrows[i] = -1; + fFastORcolumns[i] = -1; + } +} + +AliEMCALFastORPatch::~AliEMCALFastORPatch() +{ + // Destructor + delete[] fFastORamplitudes; + delete[] fFastORcolumns; + delete[] fFastORrows; +} + +Float_t AliEMCALFastORPatch::GetTotalAmplitude() +{ + Float_t total = 0; + for (Int_t i = 0; i < GetNumberOfFastOR(); i++) + { + Float_t amp = GetFastORamplitude(i); + if (amp > 0) + total += amp; + } + return total; +} + +Float_t AliEMCALFastORPatch::GetFastORamplitude(Int_t i) +{ + if (i < 0 || i > fSize) return -1; + return fFastORamplitudes[i]; +} + +Int_t AliEMCALFastORPatch::GetFastORrow(Int_t i) +{ + if (i < 0 || i > fSize) return -1; + return fFastORrows[i]; +} + +Int_t AliEMCALFastORPatch::GetFastORcolumn(Int_t i) +{ + if (i < 0 || i > fSize) return -1; + return fFastORcolumns[i]; +} + +Int_t AliEMCALFastORPatch::GetNumberOfFastOR() +{ + return fSize; +} + +Bool_t AliEMCALFastORPatch::AddFastORat(AliESDCaloTrigger* f, Int_t i) +{ + Float_t amp = 0; + Int_t gCol = 0, gRow = 0; + f->GetAmplitude(amp); + f->GetPosition(gCol, gRow); + + return AddFastORat(amp, gCol, gRow, i); +} + +Bool_t AliEMCALFastORPatch::AddFastORat(Float_t amp, Int_t gCol, Int_t gRow, Int_t i) +{ + if (i < 0) return kFALSE; + + if (i > fSize) Expand(i + 1); + + fFastORamplitudes[i] = amp; + fFastORrows[i] = gRow; + fFastORcolumns[i] = gCol; + + return kTRUE; +} + +void AliEMCALFastORPatch::RemoveFastORat(Int_t i) +{ + fFastORamplitudes[i] = -1; + fFastORrows[i] = -1; + fFastORcolumns[i] = -1; +} + +Int_t AliEMCALFastORPatch::GetAbsId() +{ + return fAbsId; +} + +void AliEMCALFastORPatch::SetAbsId(Int_t aid) +{ + fAbsId = aid; +} + +void AliEMCALFastORPatch::Expand(Int_t size) +{ + Float_t *newFastORamplitudes = new Float_t[size]; + Int_t *newFastORcolumns = new Int_t[size]; + Int_t *newFastORrows = new Int_t[size]; + + for (Int_t i = 0; i < fSize; i++) + { + newFastORamplitudes[i] = fFastORamplitudes[i]; + newFastORcolumns[i] = fFastORcolumns[i]; + newFastORrows[i] = fFastORrows[i]; + } + + delete[] fFastORamplitudes; + delete[] fFastORcolumns; + delete[] fFastORrows; + + fFastORamplitudes = newFastORamplitudes; + fFastORcolumns = newFastORcolumns; + fFastORrows = newFastORrows; + + fSize = size; +} + +Bool_t AliEMCALFastORPatch::Contains(Int_t row, Int_t col) +{ + for (Int_t i = 0; i < fSize; i++) + { + if (col == fFastORcolumns[i] && row == fFastORrows[i]) + return kTRUE; + } + return kFALSE; +} \ No newline at end of file diff --git a/PWG4/CaloCalib/AliEMCALFastORPatch.h b/PWG4/CaloCalib/AliEMCALFastORPatch.h new file mode 100644 index 00000000000..ed648ab59a0 --- /dev/null +++ b/PWG4/CaloCalib/AliEMCALFastORPatch.h @@ -0,0 +1,40 @@ +#ifndef ALIEMCALFASTORPATCH_H +#define ALIEMCALFASTORPATCH_H + +// $Id$ + +class TObjArray; +class AliESDCaloTrigger; + +#include + +class AliEMCALFastORPatch : public TObject { + +public: + AliEMCALFastORPatch(); + AliEMCALFastORPatch(Int_t aid, Int_t size = 4); + virtual ~AliEMCALFastORPatch(); + + Float_t GetTotalAmplitude(); + Float_t GetFastORamplitude(Int_t i); + Int_t GetNumberOfFastOR(); + Bool_t AddFastORat(AliESDCaloTrigger* f, Int_t i); + Bool_t AddFastORat(Float_t amp, Int_t gCol, Int_t gRow, Int_t i); + void RemoveFastORat(Int_t i); + Int_t GetAbsId(); + void SetAbsId(Int_t aid); + Int_t GetFastORrow(Int_t i); + Int_t GetFastORcolumn(Int_t i); + void Expand(Int_t size); + Bool_t Contains(Int_t row, Int_t col); + +private: + Float_t *fFastORamplitudes; + Int_t *fFastORcolumns; + Int_t *fFastORrows; + Int_t fSize; + Int_t fAbsId; + + ClassDef(AliEMCALFastORPatch, 1); +}; +#endif //ALIEMCALFASTORPATCH_H \ No newline at end of file diff --git a/PWG4/PWG4CaloCalibLinkDef.h b/PWG4/PWG4CaloCalibLinkDef.h index 7f8c60c8b86..08cc6ebfe11 100644 --- a/PWG4/PWG4CaloCalibLinkDef.h +++ b/PWG4/PWG4CaloCalibLinkDef.h @@ -15,4 +15,7 @@ #pragma link C++ class AliStaVertex+; #pragma link C++ class AliStaTrigger+; #pragma link C++ class AliStaPart+; +#pragma link C++ class AliAnalysisTaskEMCALFastOR2Trigger+; +#pragma link C++ class AliEMCALFastORPatch+; + #endif -- 2.43.0