Use TF1 or TH1 as weight for beauty (Diego)
authorpcrochet <Philippe.Crochet@cern.ch>
Tue, 29 Apr 2014 13:40:23 +0000 (15:40 +0200)
committerpcrochet <Philippe.Crochet@cern.ch>
Tue, 29 Apr 2014 13:40:23 +0000 (15:40 +0200)
PWG/muon/AliAnalysisTaskSingleMu.cxx
PWG/muondep/AccEffTemplates/GenPythia8.C [new file with mode: 0644]
PWG/muondep/rootlogon.C [new file with mode: 0644]

index 23d15c1..74b0964 100644 (file)
@@ -43,6 +43,7 @@
 #include "TStyle.h"
 //#include "TMCProcess.h"
 #include "TArrayI.h"
+#include "TArrayD.h"
 #include "TPaveStats.h"
 #include "TFitResultPtr.h"
 #include "TFile.h"
@@ -225,8 +226,6 @@ void AliAnalysisTaskSingleMu::ProcessEvent(TString physSel, const TObjArray& sel
     ((TH1*)GetMergeableObject(physSel, trigClassName, centrality, "hIpVtx"))->Fill(ipVz);
   }
   
-  TF1* beautyMuWgt = static_cast<TF1*>(GetWeight("beautyMu"));
-
   // Bool_t isPileupFromSPD = ( fAODEvent && ! fAODEvent->GetTracklets() ) ? InputEvent()->IsPileupFromSPD(3, 0.8, 3., 2., 5.) : InputEvent()->IsPileupFromSPDInMultBins(); // Avoid break when reading Muon AODs (tracklet info is not present and IsPileupFromSPDInMultBins crashes // UNCOMMENT TO REJECT PILEUP
   // if ( isPileupFromSPD ) return; // UNCOMMENT TO REJECT PILEUP
   
@@ -239,7 +238,7 @@ void AliAnalysisTaskSingleMu::ProcessEvent(TString physSel, const TObjArray& sel
     
     TObjArray selectedTracks(nTracks);
     TArrayI trackSources(nTracks);
-    TArrayF trackWgt(nTracks);
+    TArrayD trackWgt(nTracks);
     trackWgt.Reset(1.);
     for (Int_t itrack = 0; itrack < nTracks; itrack++) {
       track = ( istep == kStepReconstructed ) ? AliAnalysisMuonUtility::GetTrack(itrack,InputEvent()) : MCEvent()->GetTrack(itrack);
@@ -255,9 +254,16 @@ void AliAnalysisTaskSingleMu::ProcessEvent(TString physSel, const TObjArray& sel
       selectedTracks.AddAt(track,itrack);
       trackSources[itrack] = GetParticleType(track);
       
-      if ( trackSources[itrack] == kBeautyMu && beautyMuWgt ) {
-        AliVParticle* mcTrack = ( kStepReconstructed ) ? MCEvent()->GetTrack(track->GetLabel()) : track;
-        trackWgt[itrack] = beautyMuWgt->Eval(mcTrack->Pt());
+      TObject* wgtObj = GetWeight(fSrcKeys->At(trackSources[itrack])->GetName());
+      
+      if ( wgtObj  ) {
+        AliVParticle* mcTrack = ( istep == kStepReconstructed ) ? MCEvent()->GetTrack(track->GetLabel()) : track;
+        if ( wgtObj->IsA() == TF1::Class() ) trackWgt[itrack] = static_cast<TF1*>(wgtObj)->Eval(mcTrack->Pt());
+        else if ( wgtObj->IsA()->InheritsFrom(TH1::Class()) ) {
+          TH1* wgtHisto = static_cast<TH1*>(wgtObj);
+          trackWgt[itrack] = wgtHisto->GetBinContent(wgtHisto->GetXaxis()->FindBin(mcTrack->Pt()));
+        }
+        AliDebug(3,Form("Apply weights %s:  pt %g  gen pt %g  weight %g",wgtObj->GetName(),track->Pt(),mcTrack->Pt(),trackWgt[itrack]));
 //        Int_t iancestor = fUtilityMuonAncestor->GetAncestor(track,MCEvent());
 //        AliVParticle* motherPart = MCEvent()->GetTrack(iancestor);
 //        trackWgt[itrack] = beautyMuWgt->GetBinContent(beautyMuWgt->GetXaxis()->FindBin(motherPart->Pt()));
diff --git a/PWG/muondep/AccEffTemplates/GenPythia8.C b/PWG/muondep/AccEffTemplates/GenPythia8.C
new file mode 100644 (file)
index 0000000..16c0169
--- /dev/null
@@ -0,0 +1,29 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <Riostream.h>
+#include "TRandom.h"
+#include "AliGenPythiaPlus.h"
+#include "AliPythia8.h"
+#include "TSystem.h"
+#endif
+
+AliGenerator* GenPythia8()
+{
+  AliGenPythiaPlus* generator = new AliGenPythiaPlus(AliPythia8::Instance());
+  generator->SetProcess(kPyMbDefault);
+  
+  //   Centre of mass energy
+  generator->SetEnergyCMS(VAR_PYTHIA8_CMS_ENERGY);
+  
+  generator->SetTrackingFlag(1);
+
+  
+  Int_t seed = atoi(gSystem->Getenv("CONFIG_SEED"));
+  
+  seed = seed%900000000;
+  (AliPythia8::Instance())->ReadString("Random:setSeed = on");
+  (AliPythia8::Instance())->ReadString(Form("Random:seed = %d", seed));
+  
+  std::cout << "Pythia8 seed set to " << seed << std::endl;
+  
+  return generator;
+}
diff --git a/PWG/muondep/rootlogon.C b/PWG/muondep/rootlogon.C
new file mode 100644 (file)
index 0000000..f4a7c0a
--- /dev/null
@@ -0,0 +1,46 @@
+{
+
+// sample rootlogon to be used with AliMuonAccEffSubmitter. Feel free to adapt to your needs
+
+gSystem->Load("libVMC");
+gSystem->Load("libTree");
+gSystem->Load("libProofPlayer");
+gSystem->Load("libPhysics");
+gSystem->Load("libMatrix");
+gSystem->Load("libMinuit");
+gSystem->Load("libXMLParser");
+gSystem->Load("libGui");
+gSystem->Load("libSTEERBase");
+gSystem->Load("libESD");
+gSystem->Load("libAOD");
+gSystem->Load("libANALYSIS");
+gSystem->Load("libRAWDatabase");
+gSystem->Load("libCDB");
+gSystem->Load("libSTEER");
+gSystem->Load("libANALYSISalice");
+gSystem->Load("libCORRFW");
+
+gSystem->Load("libPWGmuon");
+
+gSystem->Load("libMUONcore");
+gSystem->Load("libMUONmapping");
+gSystem->Load("libMUONcalib");
+gSystem->Load("libMUONgeometry");
+gSystem->Load("libMUONtrigger");  
+gSystem->Load("libRAWDatabase");
+gSystem->Load("libMUONraw");
+gSystem->Load("libMUONbase");
+gSystem->Load("libMUONshuttle");
+gSystem->Load("libMUONrec");
+gSystem->Load("libMUONgraphics");
+  
+gSystem->Load("libPWGmuondep");
+
+gSystem->Load("libEVGEN");
+
+gSystem->SetIncludePath("-I. -I$ALICE_INSTALL/include -I$ALICE_ROOT/PWG/muon -I$ALICE_ROOT/PWG/muondep -I$ALICE_ROOT/MUON");
+  
+gStyle->SetPalette(1);
+
+}
+