update from salvatore
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 4 Jul 2012 19:43:14 +0000 (19:43 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 4 Jul 2012 19:43:14 +0000 (19:43 +0000)
PWGGA/EMCALJetTasks/AliJetResponseMaker.cxx

index e2859d3..70747c9 100644 (file)
@@ -225,6 +225,96 @@ void AliJetResponseMaker::UserCreateOutputObjects()
 }
 
 //________________________________________________________________________
+void AliJetResponseMaker::ExecOnce()
+{
+  // Execute once.
+
+  if (!fMCJetsName.IsNull() && !fMCJets) {
+    fMCJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fMCJetsName));
+    if (!fMCJets) {
+      AliError(Form("%s: Could not retrieve mc jets %s!", GetName(), fMCJetsName.Data()));
+      return;
+    }
+    else if (!fMCJets->GetClass()->GetBaseClass("AliEmcalJet")) {
+      AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fMCJetsName.Data())); 
+      fMCJets = 0;
+      return;
+    }
+  }
+
+  if (!fMCTracksName.IsNull() && !fMCTracks) {
+    fMCTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fMCTracksName));
+    if (!fMCTracks) {
+      AliError(Form("%s: Could not retrieve mc tracks %s!", GetName(), fMCTracksName.Data())); 
+      return;
+    }
+    else {
+      TClass *cl = fMCTracks->GetClass();
+      if (!cl->GetBaseClass("AliVParticle") && !cl->GetBaseClass("AliEmcalParticle")) {
+       AliError(Form("%s: Collection %s does not contain AliVParticle nor AliEmcalParticle objects!", GetName(), fMCTracksName.Data())); 
+       fMCTracks = 0;
+       return;
+      }
+    }
+  }
+
+  AliAnalysisTaskEmcalJet::ExecOnce();
+}
+
+//________________________________________________________________________
+Bool_t AliJetResponseMaker::RetrieveEventObjects()
+{
+  // Retrieve event objects.
+
+  if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects())
+    return kFALSE;
+  
+  fPythiaHeader = dynamic_cast<AliGenPythiaEventHeader*>(MCEvent()->GenEventHeader());
+
+  if (!fPythiaHeader)
+    return kFALSE;
+
+  if (fDoWeighting)
+    fEventWeight = fPythiaHeader->EventWeight();
+  else
+    fEventWeight = 1;
+
+  const Int_t ptHardLo[11] = { 0, 5,11,21,36,57, 84,117,152,191,234};
+  const Int_t ptHardHi[11] = { 5,11,21,36,57,84,117,152,191,234,1000000};
+
+  Double_t pthard = fPythiaHeader->GetPtHard();
+  
+  for (fPtHardBin = 0; fPtHardBin < 11; fPtHardBin++) {
+    if (pthard >= ptHardLo[fPtHardBin] && pthard < ptHardHi[fPtHardBin])
+      break;
+  }
+  fPtHardBin--;
+
+  fNTrials = fPythiaHeader->Trials();
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
+Bool_t AliJetResponseMaker::Run()
+{
+  // Find the closest jets
+
+  fHistEvents->SetBinContent(fPtHardBin, fHistEvents->GetBinContent(fPtHardBin) + 1);
+
+  if (TMath::Abs(fVertex[2]) > fVertexCut)
+    return kFALSE;
+  
+  fHistAcceptedEvents->SetBinContent(fPtHardBin, fHistEvents->GetBinContent(fPtHardBin) + 1);
+  fHistNTrials->SetBinContent(fPtHardBin, fHistNTrials->GetBinContent(fPtHardBin) + fNTrials);
+
+  DoJetLoop(fJets, fMCJets, kFALSE);
+  DoJetLoop(fMCJets, fJets, kTRUE);
+
+  return kTRUE;
+}
+
+//________________________________________________________________________
 void AliJetResponseMaker::DoJetLoop(TClonesArray *jets1, TClonesArray *jets2, Bool_t mc)
 {
   // Do the jet loop.
@@ -241,7 +331,7 @@ void AliJetResponseMaker::DoJetLoop(TClonesArray *jets1, TClonesArray *jets2, Bo
       continue;
     }  
 
-    if (!AcceptJet(jet1, kTRUE, mc))
+    if (!AcceptJet(jet1, kTRUE, !mc))
       continue;
 
     for (Int_t j = 0; j < nJets2; j++) {
@@ -253,7 +343,7 @@ void AliJetResponseMaker::DoJetLoop(TClonesArray *jets1, TClonesArray *jets2, Bo
        continue;
       }  
       
-      if (!AcceptJet(jet2, kTRUE, !mc))
+      if (!AcceptJet(jet2, kTRUE, mc))
        continue;
       
       Double_t deta = jet2->Eta() - jet1->Eta();
@@ -271,42 +361,6 @@ void AliJetResponseMaker::DoJetLoop(TClonesArray *jets1, TClonesArray *jets2, Bo
   }
 }
 
-//________________________________________________________________________
-void AliJetResponseMaker::ExecOnce()
-{
-  // Execute once.
-
-  if (!fMCJetsName.IsNull() && !fMCJets) {
-    fMCJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fMCJetsName));
-    if (!fMCJets) {
-      AliError(Form("%s: Could not retrieve mc jets %s!", GetName(), fMCJetsName.Data()));
-      return;
-    }
-    else if (!fMCJets->GetClass()->GetBaseClass("AliEmcalJet")) {
-      AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fMCJetsName.Data())); 
-      fMCJets = 0;
-      return;
-    }
-  }
-
-  if (!fMCTracksName.IsNull() && !fMCTracks) {
-    fMCTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fMCTracksName));
-    if (!fMCTracks) {
-      AliError(Form("%s: Could not retrieve mc tracks %s!", GetName(), fMCTracksName.Data())); 
-      return;
-    }
-    else {
-      TClass *cl = fMCTracks->GetClass();
-      if (!cl->GetBaseClass("AliVParticle") && !cl->GetBaseClass("AliEmcalParticle")) {
-       AliError(Form("%s: Collection %s does not contain AliVParticle nor AliEmcalParticle objects!", GetName(), fMCTracksName.Data())); 
-       fMCTracks = 0;
-       return;
-      }
-    }
-  }
-
-  AliAnalysisTaskEmcalJet::ExecOnce();
-}
 
 //________________________________________________________________________
 Bool_t AliJetResponseMaker::FillHistograms()
@@ -414,56 +468,3 @@ Bool_t AliJetResponseMaker::FillHistograms()
 
   return kTRUE;
 }
-
-//________________________________________________________________________
-Bool_t AliJetResponseMaker::RetrieveEventObjects()
-{
-  // Retrieve event objects.
-
-  if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects())
-    return kFALSE;
-  
-  fPythiaHeader = dynamic_cast<AliGenPythiaEventHeader*>(MCEvent()->GenEventHeader());
-
-  if (!fPythiaHeader)
-    return kFALSE;
-
-  if (fDoWeighting)
-    fEventWeight = fPythiaHeader->EventWeight();
-  else
-    fEventWeight = 1;
-
-  const Int_t ptHardLo[11] = { 0, 5,11,21,36,57, 84,117,152,191,234};
-  const Int_t ptHardHi[11] = { 5,11,21,36,57,84,117,152,191,234,1000000};
-
-  Double_t pthard = fPythiaHeader->GetPtHard();
-  
-  for (fPtHardBin = 0; fPtHardBin < 11; fPtHardBin++) {
-    if (ptHardLo[fPtHardBin] < pthard && ptHardHi[fPtHardBin] > pthard)
-      break;
-  }
-
-  fNTrials = fPythiaHeader->Trials();
-
-  return kTRUE;
-}
-
-//________________________________________________________________________
-Bool_t AliJetResponseMaker::Run()
-{
-  // Find the closest jets
-
-  fHistEvents->SetBinContent(fPtHardBin, fHistEvents->GetBinContent(fPtHardBin) + 1);
-
-  if (TMath::Abs(fVertex[2]) > fVertexCut)
-    return kFALSE;
-  
-  fHistAcceptedEvents->SetBinContent(fPtHardBin, fHistEvents->GetBinContent(fPtHardBin) + 1);
-  fHistNTrials->SetBinContent(fPtHardBin, fHistNTrials->GetBinContent(fPtHardBin) + fNTrials);
-
-  DoJetLoop(fJets, fMCJets, kFALSE);
-  DoJetLoop(fMCJets, fJets, kTRUE);
-
-  return kTRUE;
-}
-