Enable user selection of ConfigFile for jet finder and writing to a non standard...
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Jul 2008 08:41:14 +0000 (08:41 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Jul 2008 08:41:14 +0000 (08:41 +0000)
JETAN/AliAnalysisTaskJets.cxx
JETAN/AliAnalysisTaskJets.h
JETAN/AliJetFinder.cxx
JETAN/AliJetFinder.h
JETAN/ConfigJetAnalysisMC.C [new file with mode: 0644]
JETAN/JetAnalysisManagerLoc.C

index f29a4ba..ccd1c31 100644 (file)
@@ -42,15 +42,19 @@ ClassImp(AliAnalysisTaskJets)
 
 AliAnalysisTaskJets::AliAnalysisTaskJets():
     AliAnalysisTaskSE(),
-    fJetFinder(0x0),
-    fHistos(0x0),
-    fListOfHistos(0x0)
+  fConfigFile("ConfigJetAnalysis.C"),  
+  fNonStdBranch(""),  
+  fJetFinder(0x0),
+  fHistos(0x0),
+  fListOfHistos(0x0)
 {
   // Default constructor
 }
 
 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
     AliAnalysisTaskSE(name),
+    fConfigFile("ConfigJetAnalysis.C"),  
+    fNonStdBranch(""),  
     fJetFinder(0x0),
     fHistos(0x0),
     fListOfHistos(0x0)
@@ -64,15 +68,27 @@ void AliAnalysisTaskJets::UserCreateOutputObjects()
 // Create the output container
 //
     if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
-//  Connec default AOD to jet finder
 
-    fJetFinder->ConnectAOD(AODEvent());
-//
-//  Histograms
+
+    if(fNonStdBranch.Length()==0){
+      //  Connec default AOD to jet finder
+      fJetFinder->ConnectAOD(AODEvent());
+    }
+    else{
+      // Create a new branch for jets...
+      // how is this is reset cleared in the UserExec....
+      // Can this be handled by the framework?
+      TClonesArray *tca = new TClonesArray("AliAODJet", 0);
+      tca->SetName(fNonStdBranch);
+      AddAODBranch("TClonesArray",&tca);
+      fJetFinder->ConnectAODNonStd(AODEvent(),fNonStdBranch.Data());
+    }
+    //  Histograms
     OpenFile(1);
     fListOfHistos = new TList();
     fHistos       = new AliJetHistos();
     fHistos->AddHistosToList(fListOfHistos);
+    
 }
 
 void AliAnalysisTaskJets::Init()
@@ -81,7 +97,7 @@ void AliAnalysisTaskJets::Init()
     if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
 
     // Call configuration file
-    gROOT->LoadMacro("ConfigJetAnalysis.C");
+    gROOT->LoadMacro(fConfigFile);
     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
     // Initialise Jet Analysis
     fJetFinder->Init();
@@ -95,16 +111,26 @@ void AliAnalysisTaskJets::Init()
 
 void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
 {
-// Execute analysis for current event
-//
-    
-    fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
-    fJetFinder->ProcessEvent();
-
-    // Fill control histos
-    fHistos->FillHistos(AODEvent()->GetJets());
-    // Post the data
-    PostData(1, fListOfHistos);
+  // Execute analysis for current event
+  //
+
+
+  // Fill control histos
+  TClonesArray* jarray = 0;
+  if(fNonStdBranch.Length()==0){
+    jarray = AODEvent()->GetJets();
+  }
+  else{
+    jarray =  dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
+    jarray->Delete();    // this is our responsibility, clear before filling again
+  }
+
+  fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
+  fJetFinder->ProcessEvent();
+
+  fHistos->FillHistos(jarray);
+  // Post the data
+  PostData(1, fListOfHistos);
 }
 
 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
index 983ad4f..c48d00b 100644 (file)
@@ -24,16 +24,20 @@ class AliAnalysisTaskJets : public AliAnalysisTaskSE
     virtual void Init();
     virtual void LocalInit() {Init();}
     virtual void UserExec(Option_t *option);
+    virtual void SetConfigFile(const char *c){fConfigFile = c;}
+    virtual void SetNonStdBranch(const char *c){fNonStdBranch = c;}
     virtual void Terminate(Option_t *option);
  private:
   AliAnalysisTaskJets(const AliAnalysisTaskJets &det);
   AliAnalysisTaskJets &operator=(const AliAnalysisTaskJets &det);
     
  private:
-    AliJetFinder* fJetFinder;    //  Pointer to the jet finder 
-    AliJetHistos* fHistos;       //  Histogram manager class
-    TList*        fListOfHistos; //  Output list of histograms
-    ClassDef(AliAnalysisTaskJets, 2); // Analysis task for standard jet analysis
+  TString       fConfigFile;      // the name of the ConfigFile
+  TString       fNonStdBranch;    // the name of the non-std branch name
+  AliJetFinder* fJetFinder;    //  Pointer to the jet finder 
+  AliJetHistos* fHistos;       //  Histogram manager class
+  TList*        fListOfHistos; //  Output list of histograms
+  ClassDef(AliAnalysisTaskJets, 3); // Analysis task for standard jet analysis
 };
  
 #endif
index 0e2f500..5dcd87f 100644 (file)
@@ -243,7 +243,7 @@ void AliJetFinder::FinishRun()
 
 void AliJetFinder::AddJet(AliAODJet p)
 {
-// Add new jet to the list
+  // Add new jet to the list
   new ((*fAODjets)[fNAODjets++]) AliAODJet(p);
 }
 
@@ -252,3 +252,10 @@ void AliJetFinder::ConnectAOD(AliAODEvent* aod)
 // Connect to the AOD
     fAODjets = aod->GetJets();
 }
+
+void AliJetFinder::ConnectAODNonStd(AliAODEvent* aod,const char *bname)
+{
+
+  fAODjets = dynamic_cast<TClonesArray*>(aod->FindListObject(bname));
+  // how is this is reset? Cleared?
+}
index 0261d00..ec62bd1 100755 (executable)
@@ -57,6 +57,7 @@ class AliJetFinder : public TObject
   virtual void   FinishRun();
   virtual void   ConnectTree(TTree* tree, TObject* data);
   virtual void   ConnectAOD(AliAODEvent* aod);
+  virtual void   ConnectAODNonStd(AliAODEvent* aod,const char* bname);
   virtual TTree* MakeTreeJ(char* name);
   virtual void   WriteHeaders();
   virtual void   WriteJetsToFile() {;}
diff --git a/JETAN/ConfigJetAnalysisMC.C b/JETAN/ConfigJetAnalysisMC.C
new file mode 100644 (file)
index 0000000..8a0269f
--- /dev/null
@@ -0,0 +1,39 @@
+AliJetFinder*  ConfigJetAnalysis()
+{
+    //
+    // Configuration goes here
+    // 
+    printf("ConfigJetAnalysis() \n");
+    Printf("For MC events");
+    AliJetKineReaderHeader *jrh = new AliJetKineReaderHeader();
+    jrh->SetComment("MC full Kinematics");
+    jrh->SetFastSimTPC(kFALSE);
+    jrh->SetFastSimEMCAL(kFALSE);
+    jrh->SetPtCut(0.);
+
+    // Define reader and set its header
+    AliJetKineReader *er = new AliJetKineReader();
+    er->SetReaderHeader(jrh);
+   
+    // Define jet header
+    AliUA1JetHeaderV1 *jh=new AliUA1JetHeaderV1();
+    jh->SetComment("UA1 jet code with default parameters");
+    jh->BackgMode(0);
+    jh->SetRadius(1.0);
+    jh->SetEtSeed(2.);
+    jh->SetLegoNbinPhi(420.);
+    jh->SetLegoNbinEta(120.);
+    jh->SetLegoEtaMin(-1.9);
+    jh->SetLegoEtaMax(+1.9);  
+    jh->SetMinJetEt(5.);
+    
+    // Define jet finder. Set its header and reader
+    jetFinder = new AliUA1JetFinderV1();
+    jetFinder->SetJetHeader(jh);
+    jetFinder->SetJetReader(er);
+    jetFinder->SetPlotMode(kTRUE);
+    jetFinder->SetOutputFile("jetsMC.root");
+    //
+    return jetFinder;
+}
index d803856..a8328c4 100644 (file)
@@ -17,7 +17,7 @@ void JetAnalysisManagerLoc()
     //
     gROOT->LoadMacro("CreateESDChain.C");
     TChain* chain = new TChain("esdTree");
-    chain->Add("/afs/cern.ch/user/k/kleinb/public/tutorial/local/data/AliESDs.root");
+    chain->Add("~/alice/data/highpt/kPythia6Jets125_150/030/AliESDs.root");
 
     /////////////////////////////////////////////////////////////////////////////////// 
     // Create the analysis manager
@@ -73,6 +73,14 @@ void JetAnalysisManagerLoc()
 
     AliAnalysisTaskJets *jetana = new AliAnalysisTaskJets("JetAnalysis");
     jetana->SetDebugLevel(10);
+
+
+
+    AliAnalysisTaskJets *jetanaMC = new AliAnalysisTaskJets("JetAnalysisMC");
+    jetanaMC->SetDebugLevel(10);
+    jetanaMC->SetConfigFile("ConfigJetAnalysisMC.C");
+    jetanaMC->SetNonStdBranch("jetsMC");
+    mgr->AddTask(jetanaMC);
     mgr->AddTask(jetana);
 
     //
@@ -85,6 +93,9 @@ void JetAnalysisManagerLoc()
     AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histos", TList::Class(),
                                                              AliAnalysisManager::kOutputContainer, "histos.root");
 
+    AliAnalysisDataContainer *coutputMC2 = mgr->CreateContainer("histosMC", TList::Class(),
+                                                             AliAnalysisManager::kOutputContainer, "histosMC.root");
+
     mgr->ConnectInput  (esdfilter,  0, cinput1  );
     mgr->ConnectOutput (esdfilter,  0, coutput1 );
 
@@ -92,6 +103,10 @@ void JetAnalysisManagerLoc()
     mgr->ConnectOutput (jetana,     0, coutput1 );
     mgr->ConnectOutput (jetana,     1, coutput2 );
 
+    mgr->ConnectInput  (jetanaMC,     0, cinput1  );
+    mgr->ConnectOutput (jetanaMC,     0, coutput1 );
+    mgr->ConnectOutput (jetanaMC,     1, coutputMC2 );
+
 
     //
     // Run the analysis