]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
from Marta
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jun 2013 18:34:09 +0000 (18:34 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jun 2013 18:34:09 +0000 (18:34 +0000)
PWGJE/CMakelibPWGJEEMCALJetTasks.pkg
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetTriggerQA.C [new file with mode: 0644]
PWGJE/PWGJEEMCALJetTasksLinkDef.h

index 79e827dd0bf4a9e111235ea254a9a477038a4d46..38943ea314aeddf725f0a845f843f33cae237213 100644 (file)
@@ -53,6 +53,7 @@ set ( SRCS
  EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetHadCorQA.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetSpectra.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetSpectraMECpA.cxx
+ EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskFullpAJets.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskFullppJet.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskHJetEmbed.cxx
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.cxx b/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.cxx
new file mode 100644 (file)
index 0000000..b2253c1
--- /dev/null
@@ -0,0 +1,686 @@
+//
+// Jet trigger QA analysis task.
+//
+// Author: M.Verweij
+
+#include <TClonesArray.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TH3F.h>
+#include <THnSparse.h>
+#include <TList.h>
+#include <TLorentzVector.h>
+
+#include "AliVCluster.h"
+#include "AliVTrack.h"
+#include "AliEmcalJet.h"
+#include "AliRhoParameter.h"
+#include "AliLog.h"
+#include "AliAnalysisUtils.h"
+#include "AliEmcalParticle.h"
+#include "AliAODCaloTrigger.h"
+#include "AliEMCALGeometry.h"
+#include "AliVCaloCells.h"
+
+
+#include "AliAnalysisTaskEmcalJetTriggerQA.h"
+
+ClassImp(AliAnalysisTaskEmcalJetTriggerQA)
+
+//________________________________________________________________________
+AliAnalysisTaskEmcalJetTriggerQA::AliAnalysisTaskEmcalJetTriggerQA() : 
+  AliAnalysisTaskEmcalJet("AliAnalysisTaskEmcalJetTriggerQA", kTRUE),
+  fDebug(kFALSE),
+  fUseAnaUtils(kTRUE),
+  fAnalysisUtils(0),
+  fJetsNameCh("Jet_AKTChargedR040_PicoTracks_pT0150_caloClustersCorr_ET0300"),
+  fJetsCh(0),
+  fEtaMaxChJet(0.5),
+  fPhiMinChJet(0.),
+  fPhiMaxChJet(TMath::TwoPi()),
+  fMaxTrackPtChJet(100.),
+  fRhoChName(""),
+  fRhoCh(0),
+  fRhoChVal(0),
+  fTriggerClass(""),
+  fBitJ1((1<<8)),
+  fBitJ2((1<<11)),
+  fMaxPatchEnergy(0),
+  fTriggerType(-1),
+  fNFastOR(16),
+  fhNEvents(0),
+  fh3PtEtaPhiJetFull(0),
+  fh3PtEtaPhiJetCharged(0),
+  fh2NJetsPtFull(0),
+  fh2NJetsPtCharged(0),
+  fh3PtEtaAreaJetFull(0),
+  fh3PtEtaAreaJetCharged(0),
+  fh2PtNConstituentsCharged(0),
+  fh2PtNConstituents(0),
+  fh2PtMeanPtConstituentsCharged(0),
+  fh2PtMeanPtConstituentsNeutral(0),
+  fh2PtNEF(0),
+  fh2Ptz(0),
+  fh2PtLeadJet1VsLeadJet2(0),
+  fh3EEtaPhiCluster(0),
+  fh3PtLeadJet1VsPatchEnergy(0),
+  fh3PtLeadJet2VsPatchEnergy(0),
+  fh3PatchEnergyEtaPhiCenter(0)
+{
+  // Default constructor.
+
+  
+  SetMakeGeneralHistograms(kTRUE);
+}
+
+//________________________________________________________________________
+AliAnalysisTaskEmcalJetTriggerQA::AliAnalysisTaskEmcalJetTriggerQA(const char *name) : 
+  AliAnalysisTaskEmcalJet(name, kTRUE),
+  fDebug(kFALSE),
+  fUseAnaUtils(kTRUE),
+  fAnalysisUtils(0),
+  fJetsNameCh("Jet_AKTChargedR040_PicoTracks_pT0150_caloClustersCorr_ET0300"),
+  fJetsCh(0),
+  fEtaMaxChJet(0.5),
+  fPhiMinChJet(0.),
+  fPhiMaxChJet(TMath::TwoPi()),
+  fMaxTrackPtChJet(100.),
+  fRhoChName(""),
+  fRhoCh(0),
+  fRhoChVal(0),
+  fTriggerClass(""),
+  fBitJ1((1<<8)),
+  fBitJ2((1<<11)),
+  fMaxPatchEnergy(0),
+  fTriggerType(-1),
+  fNFastOR(16),
+  fhNEvents(0),
+  fh3PtEtaPhiJetFull(0),
+  fh3PtEtaPhiJetCharged(0),
+  fh2NJetsPtFull(0),
+  fh2NJetsPtCharged(0),
+  fh3PtEtaAreaJetFull(0),
+  fh3PtEtaAreaJetCharged(0),
+  fh2PtNConstituentsCharged(0),
+  fh2PtNConstituents(0),
+  fh2PtMeanPtConstituentsCharged(0),
+  fh2PtMeanPtConstituentsNeutral(0),
+  fh2PtNEF(0),
+  fh2Ptz(0),
+  fh2PtLeadJet1VsLeadJet2(0),
+  fh3EEtaPhiCluster(0),
+  fh3PtLeadJet1VsPatchEnergy(0),
+  fh3PtLeadJet2VsPatchEnergy(0),
+  fh3PatchEnergyEtaPhiCenter(0)
+{
+  // Standard constructor.
+
+  SetMakeGeneralHistograms(kTRUE);
+}
+
+//________________________________________________________________________
+AliAnalysisTaskEmcalJetTriggerQA::~AliAnalysisTaskEmcalJetTriggerQA()
+{
+  // Destructor.
+}
+
+//----------------------------------------------------------------------------------------------
+void AliAnalysisTaskEmcalJetTriggerQA::InitOnce() {
+  //
+  // only initialize once
+  //
+
+  // Initialize analysis util class for vertex selection
+  if(fUseAnaUtils) {
+    fAnalysisUtils = new AliAnalysisUtils();
+    fAnalysisUtils->SetMinVtxContr(2);
+    fAnalysisUtils->SetMaxVtxZ(10.);
+  }
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskEmcalJetTriggerQA::SelectEvent() {
+  //
+  // Decide if event should be selected for analysis
+  //
+
+  fhNEvents->Fill(0.5);
+  
+  if(fAnalysisUtils) {
+    if(!fAnalysisUtils->IsVertexSelected2013pA(InputEvent()))
+      return kFALSE;
+
+    fhNEvents->Fill(2.5);
+
+    if(fAnalysisUtils->IsPileUpEvent(InputEvent()))
+      return kFALSE;
+  }
+  else{
+    if(fUseAnaUtils)
+      AliError("fAnalysisUtils not initialized. Call AliAnalysisTaskEmcalJetTriggerQA::InitOnce()");
+  }
+
+  fhNEvents->Fill(3.5);
+
+  if(!fTriggerClass.IsNull()) {
+    //Check if requested trigger was fired
+    TString firedTrigClass = InputEvent()->GetFiredTriggerClasses();
+    if(!firedTrigClass.Contains(fTriggerClass))
+      return kFALSE;
+  }
+
+  fhNEvents->Fill(1.5);
+
+  return kTRUE;
+
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEmcalJetTriggerQA::FindTriggerPatch() {
+
+  //Code to get position of trigger
+
+  if(!fGeom)
+    fGeom = AliEMCALGeometry::GetInstance();
+
+
+  TString firedTrigClass = InputEvent()->GetFiredTriggerClasses();
+
+  AliAODCaloTrigger *trg = dynamic_cast<AliAODCaloTrigger*>(InputEvent()->GetCaloTrigger("EMCAL"));
+  trg->Reset();
+
+  int col, row; //FASTOR position
+
+  Int_t nPatchNotEmpty = 0; //counter number of patches which are not empty
+  fMaxPatchEnergy = 0.;
+  while (trg->Next())
+    {
+
+      trg->GetPosition(col, row); //col (0 to 63), row (0 to 47)
+      
+      if (col > -1 && row > -1)
+       {
+         Int_t id = -1; //FASTOR index
+         Int_t cellIndex[4] = {-1};
+         fGeom->GetAbsFastORIndexFromPositionInEMCAL(col,row,id); //phi is column, eta is row
+         if(id<0) continue;
+
+         fGeom->GetCellIndexFromFastORIndex(id,cellIndex);
+
+         Int_t ts = 0;
+         trg->GetL1TimeSum(ts);
+
+         Float_t ampTrg = 0.;
+         trg->GetAmplitude(ampTrg);
+
+         //L1 analysis
+         Int_t bit = 0;
+         trg->GetTriggerBits(bit);
+
+         Bool_t bTrigJ = TestFilterBit(bit,fBitJ1|fBitJ2);
+         if(!bTrigJ)
+           continue;
+
+         Bool_t bTrigJ1 = TestFilterBit(bit,fBitJ1);      
+         Bool_t bTrigJ2 = TestFilterBit(bit,fBitJ2);      
+
+         if(bTrigJ1) fTriggerType = 0;
+         if(bTrigJ2) fTriggerType = 1;
+         if(!bTrigJ1 && !bTrigJ2) fTriggerType = -1;
+
+         Double_t minPhiPatch =  10.;
+         Double_t maxPhiPatch = -10.;
+         Double_t minEtaPatch =  10.;
+         Double_t maxEtaPatch = -10.;
+
+         //Get energy in trigger patch 8x8 FASTOR
+         Double_t patchEnergy = 0.;
+         Double_t sumAmp = 0.;
+         //      const Int_t nFastOR = 8;//16;
+         for(Int_t fastrow = 0; fastrow<fNFastOR; fastrow++) {
+           for(Int_t fastcol = 0; fastcol<fNFastOR; fastcol++) {
+             Int_t nrow = row+fastrow;
+             Int_t ncol = col+fastcol;
+             fGeom->GetAbsFastORIndexFromPositionInEMCAL(ncol,nrow,id);
+
+             if(id<0) {
+               AliWarning(Form("%s: id smaller than 0 %d",GetName(),id));
+               continue;
+             }
+             
+             fGeom->GetCellIndexFromFastORIndex(id,cellIndex);
+             for(Int_t icell=0; icell<4; icell++) {
+
+               if(!fGeom->CheckAbsCellId(cellIndex[icell])) continue;
+
+               Double_t amp =0., time = 0., efrac = 0;
+               Int_t mclabel = -1;
+               Short_t absId = -1;
+               Int_t nSupMod = -1, nModule = -1, nIphi = -1, nIeta = -1;
+               fGeom->GetCellIndex(cellIndex[icell], nSupMod, nModule, nIphi, nIeta );
+               
+               fCaloCells->GetCell(cellIndex[icell], absId, amp, time,mclabel,efrac);
+
+               Double_t eta, phi;
+               fGeom->EtaPhiFromIndex(cellIndex[icell], eta, phi);
+
+               if(phi<minPhiPatch) minPhiPatch = phi;
+               if(phi>maxPhiPatch) maxPhiPatch = phi;
+               if(eta<minEtaPatch) minEtaPatch = eta;
+               if(eta>maxEtaPatch) maxEtaPatch = eta;
+
+               sumAmp+=fCaloCells->GetAmplitude(cellIndex[icell]);
+               patchEnergy+=amp;
+
+             }//cells in fastor loop
+           }//fastor col loop
+         }//fastor row loop
+
+         Double_t etaCent = minEtaPatch + 0.5*(maxEtaPatch-minEtaPatch);
+         Double_t phiCent = minPhiPatch + 0.5*(maxPhiPatch-minPhiPatch);
+         fh3PatchEnergyEtaPhiCenter->Fill(patchEnergy,etaCent,phiCent);
+
+         if(patchEnergy>0)
+           if(fDebug>2) AliInfo(Form("%s: patch edges eta: %f - %f   phi: %f - %f ampTrg: %f patchEnergy: %f sumAmp: %f",GetName(),minEtaPatch,maxEtaPatch,minPhiPatch,maxPhiPatch,ampTrg,patchEnergy,sumAmp));
+
+         if(patchEnergy>0) nPatchNotEmpty++;
+         
+         if(patchEnergy>fMaxPatchEnergy) fMaxPatchEnergy=patchEnergy;
+       }
+    }
+
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEmcalJetTriggerQA::LoadExtraBranches() {
+  //
+  // get charged jets
+  //
+
+  if (!fJetsNameCh.IsNull() && !fJetsCh) {
+    fJetsCh = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsNameCh.Data()));
+    if (!fJetsCh) {
+      AliError(Form("%s: Could not retrieve charged jets %s!", GetName(), fJetsNameCh.Data()));
+      return;
+    }
+    else if (!fJetsCh->GetClass()->GetBaseClass("AliEmcalJet")) {
+      AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fJetsNameCh.Data()));
+      fJetsCh = 0;
+      return;
+    }
+  }
+
+  //Get Charged Rho
+  if (!fRhoChName.IsNull() && !fRhoCh) {
+    fRhoCh = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoChName.Data()));
+    if (!fRhoCh) {
+      AliError(Form("%s: Could not retrieve charged rho %s!", GetName(), fRhoChName.Data()));
+      return;
+    }
+    else
+      fRhoChVal = 0.;
+  }
+  if (fRhoChName.IsNull() ) {
+    if(fDebug>10) AliInfo(Form("%s: fRhoChName empty %s",GetName(),fRhoChName.Data()));
+    fRhoChVal = 0.;
+  }
+  else if(!fRhoChName.IsNull() && fRhoCh) //do not use rho if rhoType==0
+    fRhoChVal = fRhoCh->GetVal();
+
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskEmcalJetTriggerQA::AcceptChargedJet(const AliEmcalJet *jet) const {
+
+  // Accept charged jet
+
+  Bool_t accept = kFALSE;
+
+  if(jet->Pt()<0.15) //reject ghost jets
+    return accept;
+
+  //do area cut
+  if(jet->Area()<fJetAreaCut)
+    return accept;
+
+  //Check if jet is within EMCAL acceptance
+  Double_t eta = jet->Eta();
+  Double_t phi = jet->Phi();
+  if(TMath::Abs(eta)>fEtaMaxChJet) 
+    return accept;
+
+  if(phi<fPhiMinChJet || phi>fPhiMaxChJet)
+    return accept;
+
+  if (jet->MaxTrackPt() > fMaxTrackPt)
+    return kFALSE;
+
+  return kTRUE;
+
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEmcalJetTriggerQA::UserCreateOutputObjects()
+{
+  // Create user output.
+
+  InitOnce();
+
+  AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
+
+  Bool_t oldStatus = TH1::AddDirectoryStatus();
+  TH1::AddDirectory(kFALSE);
+
+  fhNEvents = new TH1F("fhNEvents","fhNEvents;selection;N_{evt}",5,0,5);
+  fOutput->Add(fhNEvents);
+
+  Int_t nBinsPt = 120;
+  Double_t minPt = -20.;
+  Double_t maxPt = 100.;
+  Int_t nBinsEta = 40;
+  Double_t minEta = -1.;
+  Double_t maxEta = 1.;
+  Int_t nBinsPhi = 18*6;
+  Double_t minPhi = 0.;
+  Double_t maxPhi = TMath::TwoPi();
+  Int_t nBinsArea = 100;
+  Double_t minArea = 0.;
+  Double_t maxArea = 1.;
+
+  fh3PtEtaPhiJetFull = new TH3F("fh3PtEtaPhiJetFull","fh3PtEtaPhiJetFull;#it{p}_{T}^{jet};#eta;#varphi",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsPhi,minPhi,maxPhi);
+  fOutput->Add(fh3PtEtaPhiJetFull);
+
+  fh3PtEtaPhiJetCharged = new TH3F("fh3PtEtaPhiJetCharged","fh3PtEtaPhiJetCharged;#it{p}_{T}^{jet};#eta;#varphi",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsPhi,minPhi,maxPhi);
+  fOutput->Add(fh3PtEtaPhiJetCharged);
+
+  fh2NJetsPtFull = new TH2F("fh2NJetsPtFull","fh2NJetsPtFull;N_{jets};#it{p}_{T}^{jet}",20,-0.5,19.5,nBinsPt,minPt,maxPt);
+  fOutput->Add(fh2NJetsPtFull);
+
+  fh2NJetsPtCharged = new TH2F("fh2NJetsPtCharged","fh2NJetsPtCharged;N_{jets};#it{p}_{T}^{jet}",20,-0.5,19.5,nBinsPt,minPt,maxPt);
+  fOutput->Add(fh2NJetsPtCharged);
+
+  fh3PtEtaAreaJetFull = new TH3F("fh3PtEtaAreaJetFull","fh3PtEtaAreaJetFull;#it{p}_{T}^{jet};#eta;A",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsArea,minArea,maxArea);
+  fOutput->Add(fh3PtEtaAreaJetFull);
+
+  fh3PtEtaAreaJetCharged = new TH3F("fh3PtEtaAreaJetCharged","fh3PtEtaAreaJetCharged;#it{p}_{T}^{jet};#eta;A",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsArea,minArea,maxArea);
+  fOutput->Add(fh3PtEtaAreaJetCharged);
+
+  Int_t nBinsConst =100;
+  Double_t minConst = 0.;
+  Double_t maxConst = 100.;
+
+  Int_t nBinsMeanPt = 200;
+  Double_t minMeanPt = 0.;
+  Double_t maxMeanPt = 20.;
+
+  Int_t nBinsNEF = 101;
+  Double_t minNEF = 0.;
+  Double_t maxNEF = 1.01;
+
+  Int_t nBinsz = 101;
+  Double_t minz = 0.;
+  Double_t maxz = 1.01;
+
+  Int_t nBinsECluster =100;
+  Double_t minECluster = 0.;
+  Double_t maxECluster = 100.;
+
+
+  fh2PtNConstituentsCharged = new TH2F("fh2PtNConstituentsCharged","fh2PtNConstituentsCharged;#it{p}_{T}^{jet};N_{charged constituents}",nBinsPt,minPt,maxPt,nBinsConst,minConst,maxConst);
+  fOutput->Add(fh2PtNConstituentsCharged);
+
+  fh2PtNConstituents = new TH2F("fh2PtNConstituents","fh2PtNConstituents;#it{p}_{T}^{jet};N_{constituents}",nBinsPt,minPt,maxPt,nBinsConst,minConst,maxConst);
+  fOutput->Add(fh2PtNConstituents);
+
+  fh2PtMeanPtConstituentsCharged = new TH2F("fh2PtMeanPtConstituentsCharged","fh2PtMeanPtConstituentsCharged;#it{p}_{T}^{jet};charged #langle #it{p}_{T} #rangle",nBinsPt,minPt,maxPt,nBinsMeanPt,minMeanPt,maxMeanPt);
+  fOutput->Add(fh2PtMeanPtConstituentsCharged);
+
+  fh2PtMeanPtConstituentsNeutral = new TH2F("fh2PtMeanPtConstituentsNeutral","fh2PtMeanPtConstituentsNeutral;#it{p}_{T}^{jet};neutral langle #it{p}_{T} #rangle",nBinsPt,minPt,maxPt,nBinsMeanPt,minMeanPt,maxMeanPt);
+  fOutput->Add(fh2PtMeanPtConstituentsNeutral);
+
+  fh2PtNEF = new TH2F("fh2PtNEF","fh2PtNEF;#it{p}_{T}^{jet};NEF",nBinsPt,minPt,maxPt,nBinsNEF,minNEF,maxNEF);
+  fOutput->Add(fh2PtNEF);
+
+  fh2Ptz = new TH2F("fh2Ptz","fh2Ptz;#it{p}_{T}^{jet};z=p_{t,trk}^{proj}/p_{jet}",nBinsPt,minPt,maxPt,nBinsz,minz,maxz);
+  fOutput->Add(fh2Ptz);
+
+  fh2PtLeadJet1VsLeadJet2 = new TH2F("fh2PtLeadJet1VsLeadJet2","fh2PtLeadJet1VsLeadJet2;#it{p}_{T}^{jet 1};#it{p}_{T}^{jet 2}",nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt);
+  fOutput->Add(fh2PtLeadJet1VsLeadJet2);
+
+  fh3EEtaPhiCluster = new TH3F("fh3EEtaPhiCluster","fh3EEtaPhiCluster;E_{clus};#eta,#phi",nBinsECluster,minECluster,maxECluster,nBinsEta,minEta,maxEta,nBinsPhi,minPhi,maxPhi);
+  fOutput->Add(fh3EEtaPhiCluster);
+
+  fh3PtLeadJet1VsPatchEnergy = new TH3F("fh3PtLeadJet1VsPatchEnergy","fh3PtLeadJet1VsPatchEnergy;#it{p}_{T}^{jet 1};Amplitude_{patch};trig type",nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt,2,-0.5,1.5);
+  fOutput->Add(fh3PtLeadJet1VsPatchEnergy);
+  fh3PtLeadJet2VsPatchEnergy = new TH3F("fh3PtLeadJet2VsPatchEnergy","fh3PtLeadJet2VsPatchEnergy;#it{p}_{T}^{jet 1};Amplitude_{patch};trig type",nBinsPt,minPt,maxPt,nBinsPt,minPt,maxPt,2,-0.5,1.5);
+  fOutput->Add(fh3PtLeadJet2VsPatchEnergy);
+
+  fh3PatchEnergyEtaPhiCenter = new TH3F("fh3PatchEnergyEtaPhiCenter","fh3PatchEnergyEtaPhiCenter;E_{patch};#eta;#phi",nBinsPt,minPt,maxPt,nBinsEta,minEta,maxEta,nBinsPhi,minPhi,maxPhi);
+  fOutput->Add(fh3PatchEnergyEtaPhiCenter);
+
+
+  // =========== Switch on Sumw2 for all histos ===========
+  for (Int_t i=0; i<fOutput->GetEntries(); ++i) {
+    TH1 *h1 = dynamic_cast<TH1*>(fOutput->At(i));
+    if (h1){
+      h1->Sumw2();
+      continue;
+    }
+    TH2 *h2 = dynamic_cast<TH2*>(fOutput->At(i));
+    if (h2){
+      h2->Sumw2();
+      continue;
+    }
+    TH3 *h3 = dynamic_cast<TH3*>(fOutput->At(i));
+    if (h3){
+      h3->Sumw2();
+      continue;
+    }
+    THnSparse *hn = dynamic_cast<THnSparse*>(fOutput->At(i));
+    if(hn)hn->Sumw2();
+  }
+
+  TH1::AddDirectory(oldStatus);
+
+  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskEmcalJetTriggerQA::FillHistograms()
+{
+  // Fill histograms.
+
+  
+  if (fCaloClusters) {
+    const Int_t nclusters = fCaloClusters->GetEntriesFast();
+    
+    for (Int_t ic = 0; ic < nclusters; ic++) {
+      AliVCluster *cluster = static_cast<AliVCluster*>(fCaloClusters->At(ic));
+      if (!cluster) {
+       AliError(Form("Could not receive cluster %d", ic));
+       continue;
+      }
+      if (!cluster->IsEMCAL())
+        continue;
+
+      TLorentzVector lp;
+      cluster->GetMomentum(lp, const_cast<Double_t*>(fVertex));
+
+      //Fill eta,phi,E of clusters here
+      fh3EEtaPhiCluster->Fill(lp.E(),lp.Eta(),lp.Phi());
+    }
+  }
+
+  Double_t ptLeadJet1 = 0.;
+  Double_t ptLeadJet2 = 0.;
+
+  TArrayI *nJetsArr = new TArrayI(fh2NJetsPtFull->GetNbinsY()+1);
+  nJetsArr->Reset(0);
+  nJetsArr->Set(fh2NJetsPtFull->GetNbinsY()+1);
+
+  if (fJets) {
+    const Int_t njets = fJets->GetEntriesFast();
+    for (Int_t ij = 0; ij < njets; ij++) {
+
+      AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(ij));
+      if (!jet) {
+       AliError(Form("Could not receive jet %d", ij));
+       continue;
+      }  
+
+      if (!AcceptJet(jet))
+       continue;
+
+      Double_t jetPt = jet->Pt();
+      if(jetPt>ptLeadJet1) ptLeadJet1=jetPt;
+      fh3PtEtaPhiJetFull->Fill(jetPt,jet->Eta(),jet->Phi());
+      fh3PtEtaAreaJetFull->Fill(jetPt,jet->Eta(),jet->Area());
+      
+      //count jets above certain pT threshold
+      Int_t ptbin = fh2NJetsPtFull->GetYaxis()->FindBin(jetPt);
+      for(Int_t iptbin = ptbin; iptbin<=fh2NJetsPtFull->GetNbinsY(); iptbin++)
+       nJetsArr->AddAt(nJetsArr->At(iptbin)+1,iptbin);
+      
+      fh2PtNConstituentsCharged->Fill(jetPt,jet->GetNumberOfTracks());
+      fh2PtNConstituents->Fill(jetPt,jet->GetNumberOfConstituents());
+
+      fh2PtNEF->Fill(jetPt,jet->NEF());
+
+      AliVParticle *vp;
+      Double_t sumPtCh = 0.;
+      for(Int_t icc=0; icc<jet->GetNumberOfTracks(); icc++) {
+       vp = static_cast<AliVParticle*>(jet->TrackAt(icc, fTracks));
+       if(!vp) continue;
+       fh2Ptz->Fill(jetPt,GetZ(vp,jet));
+       
+       sumPtCh+=vp->Pt();
+       
+      }
+      
+      if(jet->GetNumberOfTracks()>0)
+       fh2PtMeanPtConstituentsCharged->Fill(jetPt,sumPtCh/(double)(jet->GetNumberOfTracks()) );
+
+
+      AliVCluster *vc = 0x0;
+      Double_t sumPtNe = 0.;
+      for(Int_t icc=0; icc<jet->GetNumberOfClusters(); icc++) {
+       vc = static_cast<AliVCluster*>(jet->ClusterAt(icc, fCaloClusters));
+       if(!vc) continue;
+
+       TLorentzVector lp;
+       vc->GetMomentum(lp, const_cast<Double_t*>(fVertex));
+       
+       sumPtNe+=lp.Pt();
+
+      }
+
+      if(jet->GetNumberOfClusters()>0)
+       fh2PtMeanPtConstituentsNeutral->Fill(jetPt,sumPtNe/(double)(jet->GetNumberOfClusters()) );
+
+    } //full jet loop
+
+    for(Int_t i=1; i<=fh2NJetsPtFull->GetNbinsY(); i++) {
+      Int_t nJetsInEvent = nJetsArr->At(i);
+      fh2NJetsPtFull->Fill(nJetsInEvent,fh2NJetsPtFull->GetYaxis()->GetBinCenter(i));
+    }
+
+  }
+
+  //Reset array to zero to also count charged jets
+  nJetsArr->Reset(0);
+  
+  //Loop over charged jets
+  if (fJetsCh) {
+    const Int_t njetsCh = fJetsCh->GetEntriesFast();
+    for (Int_t ij = 0; ij < njetsCh; ij++) {
+
+      AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJetsCh->At(ij));
+      if (!jet) {
+       AliError(Form("Could not receive charged jet %d", ij));
+       continue;
+      }
+
+      if(!AcceptChargedJet(jet)) 
+       continue;
+      
+      Double_t jetPt = jet->Pt();
+      if(jetPt>ptLeadJet2) ptLeadJet2=jetPt;
+      fh3PtEtaPhiJetCharged->Fill(jetPt,jet->Eta(),jet->Phi());
+      fh3PtEtaAreaJetCharged->Fill(jetPt,jet->Eta(),jet->Area());
+      
+      //count jets above certain pT threshold
+      Int_t ptbin = fh2NJetsPtCharged->GetYaxis()->FindBin(jetPt);
+      for(Int_t iptbin = ptbin; iptbin<=fh2NJetsPtCharged->GetNbinsY(); iptbin++)
+       nJetsArr->AddAt(nJetsArr->At(iptbin)+1,iptbin);
+      
+    }//ch jet loop
+    for(Int_t i=1; i<=fh2NJetsPtCharged->GetNbinsY(); i++) {
+      Int_t nJetsInEvent = nJetsArr->At(i);
+      fh2NJetsPtCharged->Fill(nJetsInEvent,fh2NJetsPtCharged->GetYaxis()->GetBinCenter(i));
+    }
+  }
+
+  if(fJets && fJetsCh) {
+    fh2PtLeadJet1VsLeadJet2->Fill(ptLeadJet1,ptLeadJet2);
+  }
+
+  fh3PtLeadJet1VsPatchEnergy->Fill(ptLeadJet1,fMaxPatchEnergy,fTriggerType);
+  fh3PtLeadJet2VsPatchEnergy->Fill(ptLeadJet2,fMaxPatchEnergy,fTriggerType);
+
+  if(nJetsArr) delete nJetsArr;
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliAnalysisTaskEmcalJetTriggerQA::Run()
+{
+  // Run analysis code here, if needed. It will be executed before FillHistograms().
+
+  //Check if event is selected (vertex & pile-up)
+  if(!SelectEvent())
+    return kFALSE;
+  
+  LoadExtraBranches();
+
+  if(fRhoChName.IsNull())
+    fRhoChVal = 0.;
+  else
+    fRhoChVal = fRhoCh->GetVal();
+
+  FindTriggerPatch();
+
+  return kTRUE;  // If return kFALSE FillHistogram() will NOT be executed.
+}
+
+//_______________________________________________________________________
+void AliAnalysisTaskEmcalJetTriggerQA::Terminate(Option_t *) 
+{
+  // Called once at the end of the analysis.
+}
+//________________________________________________________________________
+Double_t AliAnalysisTaskEmcalJetTriggerQA::GetZ(const AliVParticle *trk, const AliEmcalJet *jet)          const
+{  
+  // Get Z of constituent trk
+
+  return GetZ(trk->Px(),trk->Py(),trk->Pz(),jet->Px(),jet->Py(),jet->Pz());
+}
+
+//________________________________________________________________________
+Double_t AliAnalysisTaskEmcalJetTriggerQA::GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz) const
+{
+  // 
+  // Get the z of a constituent inside of a jet
+  //
+
+  Double_t pJetSq = jetPx*jetPx+jetPy*jetPy+jetPz*jetPz;
+
+  if(pJetSq>0.)
+    return (trkPx*jetPx+trkPy*jetPy+trkPz*jetPz)/pJetSq;
+  else {
+    AliWarning(Form("%s: strange, pjet*pjet seems to be zero pJetSq: %f",GetName(), pJetSq)); 
+    return 0;
+  }
+}
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.h b/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetTriggerQA.h
new file mode 100644 (file)
index 0000000..cb16503
--- /dev/null
@@ -0,0 +1,103 @@
+#ifndef ALIANALYSISTASKEMCALJETTRIGGERQA_H
+#define ALIANALYSISTASKEMCALJETTRIGGERQA_H
+
+class TH1;
+class TH2;
+class TH3;
+class TH3F;
+class TClonesArray;
+class TArrayI;
+class AliAnalysisUtils;
+
+#include <TRef.h>
+#include <TBits.h>
+
+#include "AliAnalysisTaskEmcalJet.h"
+
+class AliAnalysisTaskEmcalJetTriggerQA : public AliAnalysisTaskEmcalJet {
+ public:
+
+  AliAnalysisTaskEmcalJetTriggerQA();
+  AliAnalysisTaskEmcalJetTriggerQA(const char *name);
+  virtual ~AliAnalysisTaskEmcalJetTriggerQA();
+
+  void                        UserCreateOutputObjects();
+  void                        Terminate(Option_t *option);
+
+  void                        InitOnce();
+  void                        LoadExtraBranches();
+
+  Bool_t                      SelectEvent();              //decides if event is used for analysis
+  void                        FindTriggerPatch();
+
+  Bool_t                      AcceptChargedJet(const AliEmcalJet *jet) const;
+
+  //Setters
+  void SetDebug(Int_t d)                    { fDebug = d;}
+  void SetTriggerClass(const char *n)       { fTriggerClass = n; }
+  void SetNFastorPatch(Int_t i)             { fNFastOR = i;}
+  void SetJetsChName(const char *n)         { fJetsNameCh = n; }
+  void SetRhoChName(const char *n)          { fRhoChName = n; }
+  void SetChargedJetEtaMax(Double_t e)      { fEtaMaxChJet = e;}
+
+  Double_t GetZ(const AliVParticle *trk, const AliEmcalJet *jet)       const;
+  Double_t GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz) const;
+
+ protected:
+  Bool_t                      FillHistograms()   ;
+  Bool_t                      Run()              ;
+
+  Bool_t                      TestFilterBit(Int_t trigBit, UInt_t bitJetTrig) const {return (Bool_t) ((trigBit & bitJetTrig) != 0);}
+
+
+
+ private:
+  Bool_t            fDebug;                 //  debug level
+  Bool_t            fUseAnaUtils;           //  used for LHC13* data
+  AliAnalysisUtils *fAnalysisUtils;         //! vertex selection
+  TString           fJetsNameCh;            //  name of charged jet collection
+  TClonesArray     *fJetsCh;                //! list with charged jets
+  Double_t          fEtaMaxChJet;           //  max eta of jet axis, charged jets
+  Double_t          fPhiMinChJet;           //  min phi of jet axis, charged jets
+  Double_t          fPhiMaxChJet;           //  max phi of jet axis, charged jets
+  Double_t          fMaxTrackPtChJet;       //  maximum track pT in jet
+
+  TString           fRhoChName;             //  name of charged rho branch
+  AliRhoParameter  *fRhoCh;                 //! event rho charged
+  Double_t          fRhoChVal;              //  charged rho value
+
+  TString           fTriggerClass;          // trigger class to analyze EJ1 or EJ2    
+  UInt_t            fBitJ1;                 // trigger bit of EJE1
+  UInt_t            fBitJ2;                 // trigger bit of EJE2
+  Double_t          fMaxPatchEnergy;        // energy of patch with largest energy
+  Int_t             fTriggerType;           // trigger type
+  Int_t             fNFastOR;               // size of trigger patch fNFastORxfNFastOR
+
+  TH1F  *fhNEvents;                         //! Histo number of events
+  TH3F  *fh3PtEtaPhiJetFull;                //! pt,eta,phi of full jets
+  TH3F  *fh3PtEtaPhiJetCharged;             //! pt,eta,phi of charged jets
+  TH2F  *fh2NJetsPtFull;                    //! NJets per event vs pT,jet
+  TH2F  *fh2NJetsPtCharged;                 //! NJets per event vs pT,jet
+  TH3F  *fh3PtEtaAreaJetFull;               //! pt,eta,area of full jet
+  TH3F  *fh3PtEtaAreaJetCharged;            //! pt,eta,area of charged jets
+  TH2F  *fh2PtNConstituentsCharged;         //! pt, # charged jet constituents
+  TH2F  *fh2PtNConstituents;                //! pt, # jet constituents
+  TH2F  *fh2PtMeanPtConstituentsCharged;    //! pt, <pt> charged constituents
+  TH2F  *fh2PtMeanPtConstituentsNeutral;    //! pt, <pt> neutral constituents
+  TH2F  *fh2PtNEF;                          //! pt, NEF (neutral energy fraction)
+  TH2F  *fh2Ptz;                            //! pt, z=pT,h,proj/p,jet
+  TH2F  *fh2PtLeadJet1VsLeadJet2;           //! correlation between leading jet of the two branches
+  TH3F  *fh3EEtaPhiCluster;                 //! cluster E, eta, phi
+  TH3F  *fh3PtLeadJet1VsPatchEnergy;        //! leading jet energy vs leading patch energy vs jet trigger (J1/J2)
+  TH3F  *fh3PtLeadJet2VsPatchEnergy;        //! leading jet energy vs leading patch energy vs jet trigger (J1/J2)
+  TH3F  *fh3PatchEnergyEtaPhiCenter;        //! patch energy vs eta, phi at center of patch
+
+
+
+  AliAnalysisTaskEmcalJetTriggerQA(const AliAnalysisTaskEmcalJetTriggerQA&);            // not implemented
+  AliAnalysisTaskEmcalJetTriggerQA &operator=(const AliAnalysisTaskEmcalJetTriggerQA&); // not implemented
+
+  ClassDef(AliAnalysisTaskEmcalJetTriggerQA, 1) // jet sample analysis task
+};
+#endif
diff --git a/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetTriggerQA.C b/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetTriggerQA.C
new file mode 100644 (file)
index 0000000..e5e0705
--- /dev/null
@@ -0,0 +1,88 @@
+AliAnalysisTaskEmcalJetTriggerQA* AddTaskEmcalJetTriggerQA(TString kTracksName = "PicoTracks", 
+                                                          TString kClusName = "caloClusterCorr",
+                                                          Double_t R = 0.4, 
+                                                          Double_t ptminTrack = 0.15, 
+                                                          Double_t etminClus = 0.3, 
+                                                          Int_t rhoType = 0,
+                                                          UInt_t type = AliAnalysisTaskEmcal::kEMCAL,
+                                                          TString trigClass = "",
+                                                          TString kEmcalCellsName = "") {
+
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr)
+    {
+      Error("AddTaskEmcalJetTriggerQA","No analysis manager found.");
+      return 0;
+    }
+  Bool_t ismc=kFALSE;
+  ismc = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
+
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  if (!mgr->GetInputEventHandler())
+    {
+      ::Error("AddTaskEmcalJetTriggerQA", "This task requires an input event handler");
+      return NULL;
+    }
+
+
+  
+ TString strJetsFull = "";
+ TString strJetsCh = "";
+ TString wagonName = Form("DiJetR%03d%spT%04d%sET%04dRhoType%d",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack),kClusName.Data(),(int)(1000.*etminClus),rhoType);
+
+ if(kClusName.IsNull()) {  //particle level jets
+   strJetsFull = Form("Jet_AKTFullR%03d_%s_pT%04d",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack));
+   strJetsCh = Form("Jet_AKTChargedR%03d_%s_pT%04d",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack));
+   wagonName = Form("JetTriggerQAR%03d%spT%04dRhoType%dTrigClass%s",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack),rhoType,trigClass.Data());
+ }
+ else if(kTracksName.IsNull()) { //neutral/calo jets
+   strJetsFull = Form("Jet_AKTNeutralR%03d_%s_pT%04d_%s_ET%04d",(int)(100*R),"PicoTracks",(int)(1000.*ptminTrack),kClusName.Data(),(int)(1000.*etminClus));
+   strJetsCh = Form("Jet_AKTFullR%03d_%s_pT%04d_%s_ET%04d",(int)(100*R),"PicoTracks",(int)(1000.*ptminTrack),"caloClustersCorr",(int)(1000.*etminClus));
+   wagonName = Form("JetTriggerQANeutralR%03d%sET%04dRhoType%dTrigClass%s",(int)(100*R),kClusName.Data(),(int)(1000.*etminClus),rhoType,trigClass.Data());
+ }
+ else { //full jets
+   strJetsFull = Form("Jet_AKTFullR%03d_%s_pT%04d_%s_ET%04d",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack),kClusName.Data(),(int)(1000.*etminClus));
+   strJetsCh = Form("Jet_AKTChargedR%03d_%s_pT%04d_%s_ET%04d",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack),"caloClustersCorr",(int)(1000.*etminClus));
+   wagonName = Form("JetTriggerQAR%03d%spT%04d%sET%04dRhoType%dTrigClass%s",(int)(100*R),kTracksName.Data(),(int)(1000.*ptminTrack),kClusName.Data(),(int)(1000.*etminClus),rhoType,trigClass.Data());
+ }
+
+  AliAnalysisTaskEmcalJetTriggerQA *task = new AliAnalysisTaskEmcalJetTriggerQA(wagonName);
+  task->SetTracksName(kTracksName.Data());
+  task->SetClusName(kClusName.Data());
+  task->SetJetsName(strJetsFull.Data());
+  task->SetJetsChName(strJetsCh.Data());
+  task->SetJetRadius(R);
+  task->SetJetPtCut(0.15);
+  task->SetPercAreaCut(0.557);
+  task->SetTrackPtCut(ptminTrack);
+  task->SetClusPtCut(etminClus);
+  task->SetAnaType(type);
+  task->SetTriggerClass(trigClass.Data());
+  task->SetCaloCellsName(kEmcalCellsName.Data());
+
+  if(rhoType==1) {
+    task->SetRhoName("RhoSparse_Scaled");
+    task->SetRhoChName("RhoSparse");
+  }
+
+  task->SelectCollisionCandidates();
+
+  mgr->AddTask(task);
+
+  //Connnect input
+  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer() );
+
+  //Connect output
+  AliAnalysisDataContainer *coutput1 = 0x0;
+
+  TString containerName1 = Form("%s",wagonName.Data());
+
+  TString outputfile = Form("%s:%s",AliAnalysisManager::GetCommonFileName(),wagonName.Data());
+
+  coutput1 = mgr->CreateContainer(containerName1, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
+  mgr->ConnectOutput(task,1,coutput1);
+
+  return task;  
+
+}
index d0411b8c11ae755aa2c3c2fa79c0a2eba0d2f3bc..9d75f88f5c4d9ab64a03515ea09bcd2b6d21bcae 100644 (file)
@@ -35,6 +35,7 @@
 #pragma link C++ class AliAnalysisTaskEmcalJetSample+;
 #pragma link C++ class AliAnalysisTaskEmcalJetSpectra+;
 #pragma link C++ class AliAnalysisTaskEmcalJetSpectraMECpA;
+#pragma link C++ class AliAnalysisTaskEmcalJetTriggerQA+;
 #pragma link C++ class AliAnalysisTaskFullpAJets+;
 #pragma link C++ class AliAnalysisTaskFullppJet;
 #pragma link C++ class AliAnalysisTaskHJetEmbed+;
@@ -44,5 +45,4 @@
 #pragma link C++ class AliAnalysisTaskSOH+;
 #pragma link C++ class AliNtupCumInfo+;
 #pragma link C++ class AliNtupZdcInfo+;
-
 #endif