Trigger Lut generation analysis task and how to (Bogdan)
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Apr 2008 13:43:03 +0000 (13:43 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Apr 2008 13:43:03 +0000 (13:43 +0000)
PWG3/AliAnalysisTaskLUT.cxx [new file with mode: 0644]
PWG3/AliAnalysisTaskLUT.h [new file with mode: 0644]
PWG3/PWG3baseLinkDef.h
PWG3/READMEmuon [new file with mode: 0644]
PWG3/analysisTaskLUTNT.C [new file with mode: 0644]
PWG3/createLUTNT.jdl [new file with mode: 0644]
PWG3/libPWG3base.pkg
PWG3/rootlutnt.sh [new file with mode: 0644]
PWG3/runCreateLUTNT.C [new file with mode: 0644]

diff --git a/PWG3/AliAnalysisTaskLUT.cxx b/PWG3/AliAnalysisTaskLUT.cxx
new file mode 100644 (file)
index 0000000..3129b28
--- /dev/null
@@ -0,0 +1,147 @@
+//===================================================================
+//  Class AliAnalysisTaskLUT
+//
+//  Extract ESD muon tracks information and store in ntuple.
+//  Used for offline calculation/adjustment of Look-up-Tables for the
+//  trigger chambers.
+//
+//  Clermont-Ferrand 2008
+//===================================================================
+
+#define AliAnalysisTaskLUT_cxx
+
+#include "Riostream.h"
+#include "TChain.h"
+#include "TTree.h"
+#include "TNtuple.h"
+
+#include "AliESDEvent.h"
+#include "AliESDVertex.h"
+#include "AliESDMuonTrack.h"
+
+#include "AliAnalysisTask.h"
+#include "AliAnalysisTaskLUT.h"
+
+ClassImp(AliAnalysisTaskLUT)
+
+//________________________________________________________________________
+AliAnalysisTaskLUT::AliAnalysisTaskLUT(const char *name) :
+  AliAnalysisTask(name,""), 
+  fESDEvent(0), 
+  fTracksLUT(0)
+{
+  // Constructor.
+  // Input slot #0 works with a TChain
+  DefineInput(0, TChain::Class());
+
+  // Output slot #0 writes into a TNtuple container
+  DefineOutput(0, TNtuple::Class());
+
+}
+
+//___________________________________________________________________________
+void AliAnalysisTaskLUT::ConnectInputData(Option_t *) 
+{
+  // Input ESD tree
+  printf("   ConnectInputData of task %s\n", GetName());
+
+  TTree *tinput = (TTree*)GetInputData(0);
+  fESDEvent = new AliESDEvent();
+  fESDEvent->ReadFromTree(tinput);
+
+}
+
+//___________________________________________________________________________
+void AliAnalysisTaskLUT::CreateOutputObjects() 
+{
+  // Output object (TNtuple)
+  printf("   CreateOutputObjects of task %s\n", GetName());
+  
+  fTracksLUT = new TNtuple("ntTracksLUT","ntTracksLUT","TrigMask:VertZ:NHit:Circ:StripX:StripY:Dev:Lpt:Hpt:Chi2:Chi2trg:Z:P:Pt:Phi:The:TrackZ:PU:PtU:PhiU:TheU:TrackZU");
+
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskLUT::Exec(Option_t *) 
+{
+  // Execution
+  Float_t ntvar[22];
+
+  Float_t px, py, pz, pt;
+  Float_t zVertex;
+  Int_t dev;
+
+  if (!fESDEvent) return;
+  
+  Int_t nTracks = fESDEvent->GetNumberOfMuonTracks();
+
+  AliESDVertex* vertex = (AliESDVertex*) fESDEvent->GetVertex();
+  zVertex = 0.0;
+  if (vertex) {
+    zVertex = vertex->GetZv();
+  }
+  ULong64_t mask = fESDEvent->GetTriggerMask();
+
+  ntvar[ 0] = mask;
+  ntvar[ 1] = zVertex;
+
+  for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
+
+    AliESDMuonTrack* muonTrack = fESDEvent->GetMuonTrack(iTracks);
+    if (muonTrack == 0x0) continue;
+
+    if (!muonTrack->GetMatchTrigger()) continue;
+
+    dev  = muonTrack->LoDev();
+    dev *= (Int_t)(TMath::Sign(1.0,muonTrack->GetInverseBendingMomentum()));
+    dev += 15;
+
+    ntvar[ 2] = muonTrack->GetNHit();
+    ntvar[ 3] = muonTrack->LoCircuit();
+    ntvar[ 4] = muonTrack->LoStripX();
+    ntvar[ 5] = muonTrack->LoStripY();
+    ntvar[ 6] = dev;
+    ntvar[ 7] = muonTrack->LoLpt();
+    ntvar[ 8] = muonTrack->LoHpt();
+    ntvar[ 9] = muonTrack->GetChi2() / (2.0 * muonTrack->GetNHit() - 5);
+    ntvar[10] = muonTrack->GetChi2MatchTrigger();
+    ntvar[11] = TMath::Sign(1.,muonTrack->GetInverseBendingMomentum());
+
+    // corrected to vertex
+
+    px = muonTrack->Px();
+    py = muonTrack->Py();
+    pz = muonTrack->Pz();
+    pt = TMath::Sqrt(px*px+py*py);
+    ntvar[12] = muonTrack->P();
+    ntvar[13] = TMath::Sqrt(px*px+py*py);
+    ntvar[14] = TMath::ATan2(py,px)*180./TMath::Pi();
+    ntvar[15] = TMath::ATan2(pt,pz)*180./TMath::Pi();
+    ntvar[16] = muonTrack->GetZ();
+
+    // uncorrected
+
+    px = muonTrack->PxUncorrected();
+    py = muonTrack->PyUncorrected();
+    pz = muonTrack->PzUncorrected();
+    pt = TMath::Sqrt(px*px+py*py);
+    ntvar[17] = muonTrack->PUncorrected();
+    ntvar[18] = TMath::Sqrt(px*px+py*py);
+    ntvar[19] = TMath::ATan2(py,px)*180./TMath::Pi();
+    ntvar[20] = TMath::ATan2(pt,pz)*180./TMath::Pi();
+    ntvar[21] = muonTrack->GetZUncorrected();
+
+    fTracksLUT->Fill(ntvar);
+
+  } // end ESD track loop
+
+  // Post final data. It will be written to a file with option "RECREATE"
+  PostData(0, fTracksLUT);
+  
+}      
+
+//________________________________________________________________________
+void AliAnalysisTaskLUT::Terminate(Option_t *) {
+  // End function, empty
+}
+
diff --git a/PWG3/AliAnalysisTaskLUT.h b/PWG3/AliAnalysisTaskLUT.h
new file mode 100644 (file)
index 0000000..edc4b12
--- /dev/null
@@ -0,0 +1,36 @@
+//===================================================================
+//  Class AliAnalysisTaskLUT
+//
+//  Extract ESD muon tracks information and store in ntuple.
+//  Used for offline calculation/adjustment of Look-up-Tables for the
+//  trigger chambers.
+//
+//  Clermont-Ferrand 2008
+//===================================================================
+
+#include "AliAnalysisTask.h"
+
+class TNtuple;
+class AliESDEvent;
+
+class AliAnalysisTaskLUT : public AliAnalysisTask {
+ public:
+  AliAnalysisTaskLUT(const char *name);
+  virtual ~AliAnalysisTaskLUT() {}
+  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  
+ private:
+
+  AliAnalysisTaskLUT(const AliAnalysisTaskLUT& atlut);
+  AliAnalysisTaskLUT& operator=(const AliAnalysisTaskLUT& atlut);
+
+  AliESDEvent  *fESDEvent;    // ESD main tree object
+  TNtuple      *fTracksLUT;   // ntuple object, ESD tracks for LUT calculation
+
+  ClassDef(AliAnalysisTaskLUT, 0); // analysis task for extracting tracks used for LUT calculation
+};
+
index 76347a0..f0bd794 100644 (file)
@@ -20,7 +20,7 @@
 #pragma link C++ class AliAODEventInfo+;
 #pragma link C++ class AliAnalysisTaskMuonAODfromGeneral+;
 #pragma link C++ class AliAnalysisTaskSingleMu+;
-
+#pragma link C++ class AliAnalysisTaskLUT+;
 #endif
 
 
diff --git a/PWG3/READMEmuon b/PWG3/READMEmuon
new file mode 100644 (file)
index 0000000..5604afa
--- /dev/null
@@ -0,0 +1,26 @@
+Analysis task for the calculation of the Look-up-Tables used by the MUON
+trigger algorithm
+
+Purpose: extract from ESD files track information (ESD track parameters and
+matched local trigger decisions) and store in TNtuple; the ntuple is used
+for building 2D histograms (transverse momentum / local deviation) which
+afterwards enter calculation/optimization procedures for the selection of
+LUT cuts for individual local boards and several transverse momenta.
+
+This version is prepared for the use on the grid, see the JDL file.
+
+Files:
+
+AliAnalysisTaskLUT.cxx   - source files of the analysis task
+AliAnalysisTaskLUT.h
+
+rootlutnt.sh             - executable (script)
+
+runCreateLUTNT.C         - macro for setting the libraries environment and
+                           execution of the main macro
+
+analysisTaskLUTNT.C      - main macro for the analysis
+
+createLUTNT.jdl          - JDL file
+
+
diff --git a/PWG3/analysisTaskLUTNT.C b/PWG3/analysisTaskLUTNT.C
new file mode 100644 (file)
index 0000000..e26cd8a
--- /dev/null
@@ -0,0 +1,55 @@
+//________________________________________________________________________
+void analysisTaskLUTNT() {
+
+  TChain* chain = new TChain("esdTree");
+
+  TAlienCollection* coll = TAlienCollection::Open("wn.xml");
+
+  TGridResult* result = coll->GetGridResult("",0,0);
+  Int_t nFiles = 0;
+  for(Int_t i = 0; i < result->GetEntries(); i++) {
+    printf("TURL = %s \n",result->GetKey(i,"turl"));
+    chain->Add(result->GetKey(i,"turl"));
+    nFiles++;
+    //if (nFiles == 10) break;
+  }
+
+  //____________________________________________//
+  // Make the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("AnalysisManager");
+
+  //____________________________________________//
+  // ntuple task
+  AliAnalysisTaskLUT *task = new AliAnalysisTaskLUT("TaskLUT");
+  mgr->AddTask(task);
+
+  // Create containers for input/output
+
+  // input
+  AliAnalysisDataContainer *cinput = mgr->CreateContainer("cchain",TChain::Class(),AliAnalysisManager::kInputContainer);
+
+  Char_t text[256];
+  sprintf(text,"Ntuple.LUT.root");
+  printf("Analysis output in %s \n",text);
+
+  // output
+  AliAnalysisDataContainer *coutput = mgr->CreateContainer("cntuple", TNtuple::Class(),AliAnalysisManager::kOutputContainer,text);
+
+  //____________________________________________//
+  mgr->ConnectInput(task,0,cinput);
+  mgr->ConnectOutput(task,0,coutput);
+
+  if (mgr->InitAnalysis()) {
+    mgr->PrintStatus();
+
+    TStopwatch timer;
+    timer.Start();
+
+    mgr->StartAnalysis("local",chain);
+
+    timer.Stop();
+    timer.Print();
+
+  }
+}                         
+                      
diff --git a/PWG3/createLUTNT.jdl b/PWG3/createLUTNT.jdl
new file mode 100644 (file)
index 0000000..b010653
--- /dev/null
@@ -0,0 +1,45 @@
+# this is the startup process for root
+Executable="rootlutnt.sh";
+Jobtag={"comment:create lut ntuples from esd tracks"};
+
+# we split per storage element
+Split="se";
+
+# we want each job to read XXX input files
+SplitMaxInputFileNumber="1000";
+
+Validationcommand ="/alice/cern.ch/user/b/bogdan/prod2007/configs_pp/validation_blind.sh";
+
+# we need ROOT and the API service configuration package
+Packages={"VO_ALICE@APISCONFIG::V2.4","VO_ALICE@ROOT::v5-16-00"};
+
+TTL = "10000";
+
+#ROOT will read this collection file to know, which files to analyze
+InputDataList="wn.xml";
+
+#ROOT requires the collection file in the xml-single format
+InputDataListFormat="merge:/alice/cern.ch/user/b/bogdan/prod2007/XMLColl/$1/collection.xml";
+
+# this is our collection file containing the files to be analyzed
+InputDataCollection="LF:/alice/cern.ch/user/b/bogdan/prod2007/XMLColl/$1/collection.xml,nodownload";
+
+InputFile= {"LF:/alice/cern.ch/user/b/bogdan/prod2007/configs_pp/runCreateLUTNT.C",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/configs_pp/analysisTaskLUTNT.C",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/configs_pp/AliAnalysisTaskLUT.cxx",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/configs_pp/AliAnalysisTaskLUT.h",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/par/ANALYSIS.par",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/par/STEERBase.par",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/par/AOD.par",
+            "LF:/alice/cern.ch/user/b/bogdan/prod2007/par/ESD.par"};
+
+OutputFile= {"Ntuple.LUT.root@Alice::CERN::se,noarchive"};
+
+# Output archive           
+OutputArchive={"log_archive:stdout,stderr@Alice::CERN::se"};
+
+# Output directory
+OutputDir="/alice/cern.ch/user/b/bogdan/prod2007/LUTNT/$1";
+
+# email
+#Email="vulpescu@clermont.in2p3.fr";
index c8c6df3..1d00846 100644 (file)
@@ -7,7 +7,8 @@ SRCS:= AliQuarkoniaAcceptance.cxx \
        AliAnalysisTaskSEVertexingHF.cxx \
        AliAnalysisTaskSESelectHF.cxx \
        AliAODDimuon.cxx AliAODEventInfo.cxx \
-       AliAnalysisTaskMuonAODfromGeneral.cxx AliAnalysisTaskSingleMu.cxx
+       AliAnalysisTaskMuonAODfromGeneral.cxx AliAnalysisTaskSingleMu.cxx \
+       AliAnalysisTaskLUT.cxx
      
 HDRS:= $(SRCS:.cxx=.h)
 
diff --git a/PWG3/rootlutnt.sh b/PWG3/rootlutnt.sh
new file mode 100644 (file)
index 0000000..41c204a
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+export GCLIENT_SERVER_LIST="pcapiserv04.cern.ch:10000|pcapiserv05.cern.ch:10000|pcapiserv06.cern.ch:10000|pcapiserv07.cern.ch:10000"
+echo ===========================
+echo $PATH 
+echo $ROOTSYS
+echo $LD_LIBRARY_PATH
+echo ==========================
+
+root -b -x runCreateLUTNT.C;
+
diff --git a/PWG3/runCreateLUTNT.C b/PWG3/runCreateLUTNT.C
new file mode 100644 (file)
index 0000000..013ebea
--- /dev/null
@@ -0,0 +1,77 @@
+void runCreateLUTNT() {
+
+  gSystem->Load("libVMC.so");
+  gSystem->Load("libMinuit.so");
+
+  printf("*** Connect to AliEn ***\n");
+  TGrid::Connect("alien://");
+  gSystem->Load("libProofPlayer.so");
+
+  //____________________________________________________//
+  //_____________Setting up STEERBase.par_____________________//
+  //____________________________________________________//
+  setupPar("STEERBase");
+
+  //____________________________________________________//
+  //_____________Setting up ESD.par_____________________//
+  //____________________________________________________//
+  setupPar("ESD");
+
+  //____________________________________________________//
+  //_____________Setting up AOD.par_____________________//
+  //____________________________________________________//
+  setupPar("AOD");
+
+  //_____________________________________________________________//
+  //_____________Setting up ANALYSIS.par_________________________//
+  //_____________________________________________________________//
+  setupPar("ANALYSIS");
+  
+  gROOT->LoadMacro("AliAnalysisTaskLUT.cxx+");
+  gROOT->LoadMacro("analysisTaskLUTNT.C");
+
+  TStopwatch timer;
+  timer.Start();
+
+  analysisTaskLUTNT();
+
+  timer.Stop();
+  timer.Print();
+
+}
+
+Int_t setupPar(const char* pararchivename) {
+  ///////////////////
+  // Setup PAR File//
+  ///////////////////
+  if (pararchivename) {
+    char processline[1024];
+    sprintf(processline,".! tar xvzf %s.par",pararchivename);
+    gROOT->ProcessLine(processline);
+    const char* ocwd = gSystem->WorkingDirectory();
+    gSystem->ChangeDirectory(pararchivename);
+                                                                                                                                               
+    // check for BUILD.sh and execute
+    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
+      printf("*******************************\n");
+      printf("*** Building PAR archive    ***\n");
+      printf("*******************************\n");
+                                                                                                                                               
+      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
+        Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
+        return -1;
+      }
+    }
+    // check for SETUP.C and execute
+    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
+      printf("*******************************\n");
+      printf("*** Setup PAR archive       ***\n");
+      printf("*******************************\n");
+      gROOT->Macro("PROOF-INF/SETUP.C");
+    }
+                                                                                                                                               
+    gSystem->ChangeDirectory("../");
+  }                                                                                                                                               
+  return 1;
+}