event plane weighting (duplicate code but should be quickest for running)
authorrbertens <rbertens@cern.ch>
Wed, 8 Oct 2014 15:37:45 +0000 (17:37 +0200)
committerrbertens <rbertens@cern.ch>
Wed, 8 Oct 2014 15:38:25 +0000 (17:38 +0200)
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetMatching.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetMatching.h

index 36f6de3..d25567f 100644 (file)
@@ -80,13 +80,13 @@ using namespace std;
 ClassImp(AliAnalysisTaskJetMatching)
 
 AliAnalysisTaskJetMatching::AliAnalysisTaskJetMatching() : AliAnalysisTaskEmcalJet("AliAnalysisTaskJetMatching", kTRUE), 
-    fDebug(0), fSourceJets(0), fSourceJetsName(0), fTargetJets(0), fTargetJetsName(0), fMatchedJets(0), fMatchedJetsName(GetName()), fSourceRho(0), fSourceRhoName(0), fTargetRho(0), fTargetRhoName(0), fUseScaledRho(0), fSourceRadius(0.3), fTargetRadius(0.3), fMatchingScheme(kGeoEtaPhi), fUseEmcalBaseJetCuts(kFALSE), fSourceBKG(kNoSourceBKG), fTargetBKG(kNoTargetBKG), fOutputList(0), fHistUnsortedCorrelation(0), fHistMatchedCorrelation(0), fHistSourceJetPt(0), fHistMatchedSourceJetPt(0), fHistTargetJetPt(0), fHistMatchedJetPt(0), fHistSourceMatchedJetPt(0), fHistDetectorResponseProb(0), fHistNoConstSourceJet(0), fHistNoConstTargetJet(0), fHistNoConstMatchJet(0), fProfFracPtMatched(0), fProfFracPtJets(0), fProfFracNoMatched(0), fProfFracNoJets(0), fHistAnalysisSummary(0), fProfQAMatched(0), fProfQA(0), fNoMatchedJets(200), fMatchEta(.3), fMatchPhi(.3), fMatchR(.08), fDoDetectorResponse(kFALSE), fMatchConstituents(kTRUE), fMinFracRecoveredConstituents(.5), fMinFracRecoveredConstituentPt(0.5), fGetBijection(kTRUE), fh1Trials(0x0), fh1AvgTrials(0x0), fh1Xsec(0x0), fAvgTrials(0) {
+    fDebug(0), fSourceJets(0), fSourceJetsName(0), fTargetJets(0), fTargetJetsName(0), fMatchedJets(0), fMatchedJetsName(GetName()), fSourceRho(0), fSourceRhoName(0), fTargetRho(0), fTargetRhoName(0), fUseScaledRho(0), fSourceRadius(0.3), fTargetRadius(0.3), fMatchingScheme(kGeoEtaPhi), fUseEmcalBaseJetCuts(kFALSE), fSourceBKG(kNoSourceBKG), fTargetBKG(kNoTargetBKG), fOutputList(0), fHistUnsortedCorrelation(0), fHistMatchedCorrelation(0), fHistSourceJetPt(0), fHistMatchedSourceJetPt(0), fHistTargetJetPt(0), fHistMatchedJetPt(0), fHistSourceMatchedJetPt(0), fHistDetectorResponseProb(0), fHistNoConstSourceJet(0), fHistNoConstTargetJet(0), fHistNoConstMatchJet(0), fProfFracPtMatched(0), fProfFracPtJets(0), fProfFracNoMatched(0), fProfFracNoJets(0), fHistDiJet(0), fHistDiJetLeadingJet(0), fHistAnalysisSummary(0), fProfQAMatched(0), fProfQA(0), fNoMatchedJets(200), fMatchEta(.3), fMatchPhi(.3), fMatchR(.08), fDoDetectorResponse(kFALSE), fMatchConstituents(kTRUE), fMinFracRecoveredConstituents(.5), fMinFracRecoveredConstituentPt(0.5), fGetBijection(kTRUE), fh1Trials(0x0), fh1AvgTrials(0x0), fh1Xsec(0x0), fAvgTrials(0) {
     // default constructor
     ClearMatchedJetsCache();
 }
 //_____________________________________________________________________________
 AliAnalysisTaskJetMatching::AliAnalysisTaskJetMatching(const char* name) : AliAnalysisTaskEmcalJet(name, kTRUE),
-    fDebug(0), fSourceJets(0), fSourceJetsName(0), fTargetJets(0), fTargetJetsName(0), fMatchedJets(0), fMatchedJetsName(GetName()), fSourceRho(0), fSourceRhoName(0), fTargetRho(0), fTargetRhoName(0), fUseScaledRho(0), fSourceRadius(0.3), fTargetRadius(0.3), fMatchingScheme(kGeoEtaPhi), fUseEmcalBaseJetCuts(kFALSE), fSourceBKG(kNoSourceBKG), fTargetBKG(kNoTargetBKG), fOutputList(0), fHistUnsortedCorrelation(0), fHistMatchedCorrelation(0), fHistSourceJetPt(0), fHistMatchedSourceJetPt(0), fHistTargetJetPt(0), fHistMatchedJetPt(0), fHistSourceMatchedJetPt(0), fHistDetectorResponseProb(0), fHistNoConstSourceJet(0), fHistNoConstTargetJet(0), fHistNoConstMatchJet(0), fProfFracPtMatched(0), fProfFracPtJets(0), fProfFracNoMatched(0), fProfFracNoJets(0), fHistAnalysisSummary(0), fProfQAMatched(0), fProfQA(0), fNoMatchedJets(200), fMatchEta(.3), fMatchPhi(.3), fMatchR(.08), fDoDetectorResponse(kFALSE), fMatchConstituents(kTRUE), fMinFracRecoveredConstituents(0.5), fMinFracRecoveredConstituentPt(0.5), fGetBijection(kTRUE), fh1Trials(0x0), fh1AvgTrials(0x0), fh1Xsec(0x0), fAvgTrials(0) {
+    fDebug(0), fSourceJets(0), fSourceJetsName(0), fTargetJets(0), fTargetJetsName(0), fMatchedJets(0), fMatchedJetsName(GetName()), fSourceRho(0), fSourceRhoName(0), fTargetRho(0), fTargetRhoName(0), fUseScaledRho(0), fSourceRadius(0.3), fTargetRadius(0.3), fMatchingScheme(kGeoEtaPhi), fUseEmcalBaseJetCuts(kFALSE), fSourceBKG(kNoSourceBKG), fTargetBKG(kNoTargetBKG), fOutputList(0), fHistUnsortedCorrelation(0), fHistMatchedCorrelation(0), fHistSourceJetPt(0), fHistMatchedSourceJetPt(0), fHistTargetJetPt(0), fHistMatchedJetPt(0), fHistSourceMatchedJetPt(0), fHistDetectorResponseProb(0), fHistNoConstSourceJet(0), fHistNoConstTargetJet(0), fHistNoConstMatchJet(0), fProfFracPtMatched(0), fProfFracPtJets(0), fProfFracNoMatched(0), fProfFracNoJets(0), fHistDiJet(0), fHistDiJetLeadingJet(0), fHistAnalysisSummary(0), fProfQAMatched(0), fProfQA(0), fNoMatchedJets(200), fMatchEta(.3), fMatchPhi(.3), fMatchR(.08), fDoDetectorResponse(kFALSE), fMatchConstituents(kTRUE), fMinFracRecoveredConstituents(0.5), fMinFracRecoveredConstituentPt(0.5), fGetBijection(kTRUE), fh1Trials(0x0), fh1AvgTrials(0x0), fh1Xsec(0x0), fAvgTrials(0) {
     // constructor
     ClearMatchedJetsCache();
     DefineInput(0, TChain::Class());
@@ -185,6 +185,13 @@ void AliAnalysisTaskJetMatching::UserCreateOutputObjects()
     fOutputList->Add(fProfFracPtJets);
     fProfFracNoJets = new TProfile("fProfFracNoJets", "source constituents / target constituents", 15, -50, 250);
     fOutputList->Add(fProfFracNoJets);
+    switch (fMatchingScheme) {
+        case kDiJet : {
+            fHistDiJet = BookTH2F("fHistDiJet", "matched jet #varphi", "matched jet #eta", 100, 0., TMath::TwoPi(), 100, -2.5, 2.5);
+            fHistDiJetLeadingJet = BookTH2F("fHistDiJetLeadingJet", "matched jet #varphi", "matched jet #eta", 100, 0., TMath::TwoPi(), 100, -2.5, 2.5);
+        } break;
+        default : break;
+    }
     fOutputList->Sort();
     PostData(1, fOutputList);
 }
@@ -275,12 +282,17 @@ Bool_t AliAnalysisTaskJetMatching::Run()
     if(fh1AvgTrials) fh1AvgTrials->Fill("#sum{avg ntrials}", fAvgTrials);
     // step one: do geometric matching 
     switch (fMatchingScheme) {
+        // FIXME having separate dedicated functions is not necessary and historical
+        // cluttered code - should be cleaned up and merged into one
         case kGeoEtaPhi : {
             DoGeometricMatchingEtaPhi();
         } break;
         case kGeoR : {
             DoGeometricMatchingR();
         } break;
+        case kDiJet : {
+            DoDiJetMatching();
+        } break;
         default : break;
     }
     // break if no jet was matched
@@ -386,6 +398,29 @@ void AliAnalysisTaskJetMatching::DoGeometricMatchingR()
     }
 }
 //_____________________________________________________________________________
+void AliAnalysisTaskJetMatching::DoDiJetMatching()
+{
+    // match dijets. this is in a sense a 'special' mode of the task as both jet supplied jet arrays 
+    // (target and source) are the same jet collection, matching will be performed on distribution in
+    // azimuth
+    if(fDebug > 0) printf("__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
+    // get the leading jet in a given acceptance
+    Int_t leadingJetIndex(-1), subLeadingJetIndex(-1);
+    AliEmcalJet* leadingJet(GetLeadingJet(fSourceJets, leadingJetIndex));
+    if(!leadingJet) return;
+    fHistDiJetLeadingJet->Fill(leadingJet->Eta(), leadingJet->Phi());
+    Double_t sourcePhi(leadingJet->Phi()), targetPhi(-1);
+    // grab the sub-leading jet
+    AliEmcalJet* subLeadingJet(GetSubLeadingJet(fSourceJets, leadingJetIndex, subLeadingJetIndex));
+    if(!subLeadingJet) return;
+    else { // check if the sub-leading jet is actually the away-side jet
+        targetPhi = subLeadingJet->Phi() + TMath::Pi();
+        if(TMath::Abs(sourcePhi-targetPhi) > TMath::Abs(sourcePhi-targetPhi+TMath::TwoPi())) sourcePhi+=TMath::TwoPi();
+        if(TMath::Abs(sourcePhi-targetPhi) > TMath::Abs(sourcePhi-targetPhi-TMath::TwoPi())) sourcePhi-=TMath::TwoPi();
+        if(TMath::Abs(sourcePhi-targetPhi) < fMatchPhi) fHistDiJet->Fill(subLeadingJet->Eta(), subLeadingJet->Phi());
+    }
+}
+//_____________________________________________________________________________
 void AliAnalysisTaskJetMatching::DoConstituentMatching()
 {
     // match constituents within matched jets 
@@ -552,6 +587,45 @@ void AliAnalysisTaskJetMatching::FillMatchedJetHistograms()
     }
 }
 //_____________________________________________________________________________
+AliEmcalJet* AliAnalysisTaskJetMatching::GetLeadingJet(TClonesArray* source, Int_t &leadingJetIndex, Double_t etaMin, Double_t etaMax) 
+{
+    // return the leading jet within given acceptance
+    Int_t iJets(source->GetEntriesFast());
+    Double_t pt(0);
+    AliEmcalJet* leadingJet(0x0);
+    for(Int_t i(0); i < iJets; i++) {
+        AliEmcalJet* jet = static_cast<AliEmcalJet*>(source->At(i));
+        if(jet->Eta() < etaMin || jet->Eta() > etaMax) continue;
+        if(jet->Pt() > pt) {
+           leadingJet = jet;
+           pt = leadingJet->Pt();
+           leadingJetIndex = i;
+        }
+    }
+    return leadingJet;
+}
+//_____________________________________________________________________________
+AliEmcalJet* AliAnalysisTaskJetMatching::GetSubLeadingJet(TClonesArray* source, Int_t leadingJetIndex, Int_t &subLeadingJetIndex, Double_t etaMin, Double_t etaMax) 
+{
+    // return the leading jet within given acceptance
+    // same as GetLeadingJet() but skips the leading jet (so returned jet is 
+    // sub-leading by design)
+    Int_t iJets(source->GetEntriesFast());
+    Double_t pt(0);
+    AliEmcalJet* leadingJet(0x0);
+    for(Int_t i(0); i < iJets; i++) {
+        if(i == leadingJetIndex) continue;
+        AliEmcalJet* jet = static_cast<AliEmcalJet*>(source->At(i));
+        if(jet->Eta() < etaMin || jet->Eta() > etaMax) continue;
+        if(jet->Pt() > pt) {
+           leadingJet = jet;
+           pt = leadingJet->Pt();
+           subLeadingJetIndex = i;
+        }
+    }
+    return leadingJet;
+}
+//_____________________________________________________________________________
 void AliAnalysisTaskJetMatching::PrintInfo() const
 {
     // print some info 
index 24fde26..2f28bfb 100644 (file)
@@ -20,7 +20,7 @@ class AliAnalysisTaskJetMatching : public AliAnalysisTaskEmcalJet
 {
     public:
         // enumerators
-        enum matchingSceme      {kGeoEtaPhi, kGeoR};
+        enum matchingSceme      {kGeoEtaPhi, kGeoR, kDiJet};
         enum sourceBKG          {kNoSourceBKG, kSourceRho, kSourceLocalRho};
         enum targetBKG          {kNoTargetBKG, kTargetRho, kTargetLocalRho};
         // constructors, destructor
@@ -79,6 +79,7 @@ class AliAnalysisTaskJetMatching : public AliAnalysisTaskEmcalJet
         // methods
         void                    DoGeometricMatchingEtaPhi();
         void                    DoGeometricMatchingR();
+        void                    DoDiJetMatching();
         void                    DoConstituentMatching();
         void                    GetBijection();
         void                    PostMatchedJets();
@@ -95,6 +96,8 @@ class AliAnalysisTaskJetMatching : public AliAnalysisTaskEmcalJet
                 fMatchedJetContainer[i][0] = 0x0; fMatchedJetContainer[i][1] = 0x0; }
             fNoMatchedJets = 0;
         }
+        AliEmcalJet*            GetLeadingJet(TClonesArray* source, Int_t &leadingJetIndex, Double_t etaMin = -.7, Double_t etaMax = .7);
+        AliEmcalJet*            GetSubLeadingJet(TClonesArray* source, Int_t leadingJetIndex, Int_t &subLeadingJetIndex, Double_t etaMin = -.7, Double_t etaMax = .7);
         void                    PrintInfo() const;
         virtual void            Terminate(Option_t* option);
 
@@ -134,6 +137,8 @@ class AliAnalysisTaskJetMatching : public AliAnalysisTaskEmcalJet
         TProfile*               fProfFracPtJets;        //! sum pt fraction for matched jets
         TProfile*               fProfFracNoMatched;     //! no of constituents fraction found / jet
         TProfile*               fProfFracNoJets;        //! no of consstituents fraction jet / jet
+        TH2F*                   fHistDiJet;             //! matched dijet eta, phi
+        TH2F*                   fHistDiJetLeadingJet;   //! leading jet (for dijet) eta, phi
         TH1F*                   fHistAnalysisSummary;   //! flags
         TProfile*               fProfQAMatched;         //! QA spreads of matched jets
         TProfile*               fProfQA;                //! QA spreads of source and target jets