]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
updated macros for train
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 20 May 2009 13:22:32 +0000 (13:22 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 20 May 2009 13:22:32 +0000 (13:22 +0000)
PWG2/RESONANCES/macros/AddAnalysisTaskRsn.C [new file with mode: 0644]
PWG2/RESONANCES/macros/alien/RsnMergeAlien.C [new file with mode: 0644]
PWG2/RESONANCES/macros/alien/rsn-merge.jdl [new file with mode: 0644]
PWG2/RESONANCES/macros/alien/rsn-merge.sh [new file with mode: 0755]

diff --git a/PWG2/RESONANCES/macros/AddAnalysisTaskRsn.C b/PWG2/RESONANCES/macros/AddAnalysisTaskRsn.C
new file mode 100644 (file)
index 0000000..8832907
--- /dev/null
@@ -0,0 +1,344 @@
+//
+// Macro to create the full analysis manager for Resonances
+//
+
+static Double_t  cov11 = 2;
+static Double_t  cov22 = 2;
+static Double_t  cov33 = 0.5;
+static Double_t  cov44 = 0.5;
+static Double_t  cov55 = 2;
+static Double_t  nSigmaToVertex = 4;
+static Double_t  dcaToVertex = 3.0;
+static Double_t  maxChi2PerClusterTPC = 3.5;
+static Bool_t    requireTPCRefit = kTRUE;
+static Bool_t    requireSigmaToVertex = kTRUE;
+static Bool_t    acceptKinkDaughters = kFALSE;
+static Int_t     minNClustersTPC = 50;
+
+Bool_t AddAnalysisTaskRsn(const char *outFile = "rsn.root", Bool_t useKine = kTRUE)
+{
+  // Retrieve analysis manager.
+  // Since it is usually created in the steering macro,
+  // then we don't ever need to initialize a new one
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+
+  // create handlers for input and MonteCarlo
+  AliMCEventHandler  *mcHandler  = new AliMCEventHandler();
+  AliESDInputHandler *esdHandler = new AliESDInputHandler();
+  //AliAODHandler      *aodHandler = new AliAODHandler();
+  //aodHandler->SetOutputFileName("AliAOD.root");
+  if (useKine) mgr->SetMCtruthEventHandler(mcHandler);
+  mgr->SetInputEventHandler(esdHandler);
+  //mgr->SetOutputEventHandler(aodHandler);
+
+  // initialize task
+  AliRsnAnalysisSE *task = new AliRsnAnalysisSE("AliRsnAnalysisSE");
+
+  // set prior probabilities for PID
+  task->SetPriorProbability(AliPID::kElectron, 0.02);
+  task->SetPriorProbability(AliPID::kMuon,     0.02);
+  task->SetPriorProbability(AliPID::kPion,     0.83);
+  task->SetPriorProbability(AliPID::kKaon,     0.07);
+  task->SetPriorProbability(AliPID::kProton,   0.06);
+  task->DumpPriors();
+
+  // initialize analysis manager with pairs from config
+  AliRsnAnalysisManager *anaMgr = task->GetAnalysisManager("MyAnalysisSE");
+  anaMgr->Add(CreatePairsNoPID("PHI_NoPID_0"   , 333, AliPID::kKaon, AliPID::kKaon, 10000.0));
+  anaMgr->Add(CreatePairsNoPID("PHI_NoPID_10"  , 333, AliPID::kKaon, AliPID::kKaon,     0.1));
+  anaMgr->Add(CreatePairsNoPID("PHI_NoPID_20"  , 333, AliPID::kKaon, AliPID::kKaon,     0.2));
+  anaMgr->Add(CreatePairsPID  ("PHI_PID"       , 333, AliPID::kKaon, AliPID::kKaon));
+  anaMgr->Add(CreatePairsNoPID("KSTAR_NoPID_0" , 313, AliPID::kKaon, AliPID::kPion, 10000.0));
+  anaMgr->Add(CreatePairsNoPID("KSTAR_NoPID_10", 313, AliPID::kKaon, AliPID::kPion,     0.1));
+  anaMgr->Add(CreatePairsNoPID("KSTAR_NoPID_20", 313, AliPID::kKaon, AliPID::kPion,     0.2));
+  anaMgr->Add(CreatePairsPID  ("KSTAR_PID"     , 313, AliPID::kKaon, AliPID::kPion));
+
+  // setup cuts
+  AliESDtrackCuts *esdCuts = new AliESDtrackCuts;
+  esdCuts->SetMaxCovDiagonalElements(cov11, cov22, cov33, cov44, cov55);
+  esdCuts->SetRequireSigmaToVertex(requireSigmaToVertex);
+  if (requireSigmaToVertex) esdCuts->SetMaxNsigmaToVertex(nSigmaToVertex);
+  else
+  {
+    esdCuts->SetDCAToVertexZ(dcaToVertex);
+    esdCuts->SetDCAToVertexXY(dcaToVertex);
+  }
+  esdCuts->SetRequireTPCRefit(requireTPCRefit);
+  esdCuts->SetAcceptKinkDaughters(acceptKinkDaughters);
+  esdCuts->SetMinNClustersTPC(minNClustersTPC);
+  esdCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+  task->SetESDtrackCuts(esdCuts);
+
+  // add the task to manager
+  mgr->AddTask(task);
+
+  // initialize container for the output
+  // (input container is common)
+  AliAnalysisDataContainer *out = mgr->CreateContainer("RSN", TList::Class(), AliAnalysisManager::kOutputContainer, outFile);
+
+  // connect input and output slots for this task
+  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
+  mgr->ConnectOutput(task, 1, out);
+}
+
+void AddRsnFunctionsToPair(AliRsnPair *pair)
+{
+//
+// In general, for all processed pairs in one analysis the same functions are computed.
+// Then, they are defined separately here and added in the same way to all pairs.
+//
+
+  // define histogram templates
+  AliRsnHistoDef *hdIM   = new AliRsnHistoDef(1000,  0.0,   2.0);
+  AliRsnHistoDef *hdPt   = new AliRsnHistoDef(  10,  0.0,  10.0);
+  AliRsnHistoDef *hdMult = new AliRsnHistoDef(   8,  0.0, 200.0);
+
+  // define functions:
+  // -- one computed w.r. to Pt and Mult
+  // -- one computed w.r. to Eta and Mult
+  AliRsnFunction *fcnIM1 = new AliRsnFunction(AliRsnFunction::kInvMass, AliRsnFunction::kBinPairPt, AliRsnFunction::kBinEventMult, hdIM, hdPt, hdMult);
+
+  // add to pair
+  pair->AddFunction(fcnIM1);
+}
+
+AliRsnPairManager* CreatePairsNoPID
+(
+  const char            *pairMgrName,    // name for the pair manager
+  Int_t                  resonancePDG,   // PDG code of resonance (for true pairs)
+  AliPID::EParticleType  type1,          // PID of one member of decay (+)
+  AliPID::EParticleType  type2,          // PID of other member of decay (-)
+  Double_t               bbCut = 10000.0 // cut on Bethe-Bloch
+)
+{
+//
+// Creates an AliRsnPairMgr for a specified resonance, which contains:
+// - signal (inv. mass)
+// - event mixing (inv. mass)
+// - like-sign (inv. mass)
+// - true pairs (inv. mass, resolution)
+//
+// For all pairs, a binning in Pt and Eta is provided, and a cut in multiplicity
+// which defines a multiplicity bin where the analysis is computed.
+//
+// Arguments define how the pair manager must be built, and are explained above
+//
+
+  AliRsnPairManager  *pairMgr  = new AliRsnPairManager(pairMgrName);
+
+  // === PAIR DEFINITIONS =========================================================================
+
+  // if particle #1 and #2 are different, two histograms must be built
+  // for each scheme (signal, true, mixed, like-sign) exchanging both particles and signs
+  Int_t i, j, nArray = 1;
+  if (type1 != type2) nArray = 2;
+
+  AliRsnPairDef *defUnlike[2] = {0, 0};
+  AliRsnPairDef *defLikePP[2] = {0, 0};
+  AliRsnPairDef *defLikeMM[2] = {0, 0};
+
+  defUnlike[0] = new AliRsnPairDef(type1, '+', type2, '-', resonancePDG);
+  defLikePP[0] = new AliRsnPairDef(type1, '+', type2, '+', resonancePDG);
+  defLikeMM[0] = new AliRsnPairDef(type1, '-', type2, '-', resonancePDG);
+
+  defUnlike[1] = new AliRsnPairDef(type2, '+', type1, '-', resonancePDG);
+  defLikePP[1] = new AliRsnPairDef(type2, '+', type1, '+', resonancePDG);
+  defLikeMM[1] = new AliRsnPairDef(type2, '-', type1, '-', resonancePDG);
+
+  // === PAIR ANALYSIS ENGINES ====================================================================
+
+  // define null (dummy) objects and initialize only the ones which are needed,
+  // depending again on particle types;
+  // array is organized as follows:
+  // [0] - true pairs
+  // [1] - signal
+  // [2] - like PP
+  // [3] - like MM
+  AliRsnPair *noPID[2][4] = {0,0,0,0,0,0,0,0};
+
+  for (i = 0; i < nArray; i++) {
+    noPID[i][0] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+    noPID[i][1] = new AliRsnPair(AliRsnPair::kNoPID, defUnlike[i]);
+    noPID[i][2] = new AliRsnPair(AliRsnPair::kNoPID, defLikePP[i]);
+    noPID[i][3] = new AliRsnPair(AliRsnPair::kNoPID, defLikeMM[i]);
+  }
+
+  // === CUTS =====================================================================================
+
+  // cuts for tracks:
+  // -- Bethe-Bloch & required kaon PID
+  AliRsnCutStd *cutReqKaon = new AliRsnCutStd("cutReqKaon", AliRsnCutStd::kRequiredPID, (Int_t)AliPID::kKaon);
+  AliRsnCutBetheBloch *cutKaonBB = new AliRsnCutBetheBloch("cutKaon", bbCut, AliPID::kKaon);
+  cutKaonBB->SetCalibConstant(0, 0.76176e-1);
+  cutKaonBB->SetCalibConstant(1, 10.632);
+  cutKaonBB->SetCalibConstant(2, 0.13279e-4);
+  cutKaonBB->SetCalibConstant(3, 1.8631);
+  cutKaonBB->SetCalibConstant(4, 1.9479);
+
+  // cuts on pairs:
+  // -- true daughters of a phi resonance (only for true pairs histogram)cutSetPairTrue->AddCut(cutTrue);
+  AliRsnCutStd *cutTruePair = new AliRsnCutStd("cutTrue", AliRsnCutStd::kTruePair, resonancePDG);
+
+  // cut set definition for all pairs
+  AliRsnCutSet *cutSetParticle = new AliRsnCutSet("trackCuts");
+  cutSetParticle->AddCut(cutKaonBB);
+  cutSetParticle->AddCut(cutReqKaon);
+  cutSetParticle->SetCutScheme("(cutReqKaon&cutKaonBB)|(!cutReqKaon)");
+
+  // cut set definition for true pairs
+  AliRsnCutSet *cutSetPairTrue = new AliRsnCutSet("truePairs");
+  cutSetPairTrue->AddCut(cutTruePair);
+  cutSetPairTrue->SetCutScheme("cutTrue");
+
+  // cut manager for all pairs
+  AliRsnCutMgr *cutMgrAll = new AliRsnCutMgr("std", "All");
+  cutMgrAll->SetCutSet(AliRsnCut::kParticle, cutSetParticle);
+
+  // cut manager for all pairs
+  AliRsnCutMgr *cutMgrTrue = new AliRsnCutMgr("true", "True");
+  cutMgrTrue->SetCutSet(AliRsnCut::kParticle, cutSetParticle);
+  cutMgrTrue->SetCutSet(AliRsnCut::kPair, cutSetPairTrue);
+
+  for (i = 0; i < nArray; i++) {
+    noPID[i][0]->SetCutMgr(cutMgrTrue);
+    for (j = 1; j < 4; j++) {
+      noPID[i][j]->SetCutMgr(cutMgrAll);
+    }
+  }
+
+  // === FUNCTIONS ================================================================================
+
+  for (i = 0; i < nArray; i++) {
+    for (j = 0; j < 4; j++) {
+      AddRsnFunctionsToPair(noPID[i][j]);
+    }
+  }
+
+  // === ADD TO PAIR MANAGER ======================================================================
+
+  for (i = 0; i < nArray; i++) {
+    for (j = 0; j < 4; j++) {
+      pairMgr->AddPair(noPID[i][j]);
+    }
+  }
+
+  return pairMgr;
+}
+
+AliRsnPairManager* CreatePairsPID
+(
+  const char            *pairMgrName,    // name for the pair manager
+  Int_t                  resonancePDG,   // PDG code of resonance (for true pairs)
+  AliPID::EParticleType  type1,          // PID of one member of decay (+)
+  AliPID::EParticleType  type2           // PID of other member of decay (-)
+)
+{
+//
+// Creates an AliRsnPairMgr for a specified resonance, which contains:
+// - signal (inv. mass)
+// - event mixing (inv. mass)
+// - like-sign (inv. mass)
+// - true pairs (inv. mass, resolution)
+//
+// For all pairs, a binning in Pt and Eta is provided, and a cut in multiplicity
+// which defines a multiplicity bin where the analysis is computed.
+//
+// Arguments define how the pair manager must be built, and are explained above
+//
+
+  AliRsnPairManager  *pairMgr  = new AliRsnPairManager(pairMgrName);
+
+  // === PAIR DEFINITIONS =========================================================================
+
+  // if particle #1 and #2 are different, two histograms must be built
+  // for each scheme (signal, true, mixed, like-sign) exchanging both particles and signs
+  Int_t i, j, nArray = 1;
+  if (type1 != type2) nArray = 2;
+
+  AliRsnPairDef *defUnlike[2] = {0, 0};
+  AliRsnPairDef *defLikePP[2] = {0, 0};
+  AliRsnPairDef *defLikeMM[2] = {0, 0};
+
+  defUnlike[0] = new AliRsnPairDef(type1, '+', type2, '-', resonancePDG);
+  defLikePP[0] = new AliRsnPairDef(type1, '+', type2, '+', resonancePDG);
+  defLikeMM[0] = new AliRsnPairDef(type1, '-', type2, '-', resonancePDG);
+
+  defUnlike[1] = new AliRsnPairDef(type2, '+', type1, '-', resonancePDG);
+  defLikePP[1] = new AliRsnPairDef(type2, '+', type1, '+', resonancePDG);
+  defLikeMM[1] = new AliRsnPairDef(type2, '-', type1, '-', resonancePDG);
+
+  // === PAIR ANALYSIS ENGINES ====================================================================
+
+  // define null (dummy) objects and initialize only the ones which are needed,
+  // depending again on particle types;
+  // array is organized as follows:
+  // [0] - true pairs
+  // [1] - signal
+  // [2] - like PP
+  // [3] - like MM
+  AliRsnPair *perfectPID[2][4]   = {0,0,0,0,0,0,0,0};
+  AliRsnPair *realisticPID[2][4] = {0,0,0,0,0,0,0,0};
+
+  for (i = 0; i < nArray; i++) {
+    perfectPID[i][0] = new AliRsnPair(AliRsnPair::kPerfectPID, defUnlike[i]);
+    perfectPID[i][1] = new AliRsnPair(AliRsnPair::kPerfectPID, defUnlike[i]);
+    perfectPID[i][2] = new AliRsnPair(AliRsnPair::kPerfectPID, defLikePP[i]);
+    perfectPID[i][3] = new AliRsnPair(AliRsnPair::kPerfectPID, defLikeMM[i]);
+
+    realisticPID[i][0] = new AliRsnPair(AliRsnPair::kRealisticPID, defUnlike[i]);
+    realisticPID[i][1] = new AliRsnPair(AliRsnPair::kRealisticPID, defUnlike[i]);
+    realisticPID[i][2] = new AliRsnPair(AliRsnPair::kRealisticPID, defLikePP[i]);
+    realisticPID[i][3] = new AliRsnPair(AliRsnPair::kRealisticPID, defLikeMM[i]);
+  }
+
+  // === CUTS =====================================================================================
+
+  // cuts for tracks:
+  // -- nothing
+
+  // cuts on pairs:
+  // -- true daughters of a phi resonance (only for true pairs histogram)cutSetPairTrue->AddCut(cutTrue);
+  AliRsnCutStd *cutTruePair = new AliRsnCutStd("cutTrue", AliRsnCutStd::kTruePair, resonancePDG);
+
+  // cut set definition for true pairs
+  AliRsnCutSet *cutSetPairTrue = new AliRsnCutSet("truePairs");
+  cutSetPairTrue->AddCut(cutTruePair);
+  cutSetPairTrue->SetCutScheme("cutTrue");
+
+  // cut manager for all pairs
+  AliRsnCutMgr *cutMgrAll = new AliRsnCutMgr("std", "All");
+
+  // cut manager for all pairs
+  AliRsnCutMgr *cutMgrTrue = new AliRsnCutMgr("true", "True");
+  cutMgrTrue->SetCutSet(AliRsnCut::kPair, cutSetPairTrue);
+
+  for (i = 0; i < nArray; i++) {
+    perfectPID[i][0]->SetCutMgr(cutMgrTrue);
+    realisticPID[i][0]->SetCutMgr(cutMgrTrue);
+    for (j = 1; j < 4; j++) {
+      perfectPID[i][j]->SetCutMgr(cutMgrAll);
+      realisticPID[i][j]->SetCutMgr(cutMgrAll);
+    }
+  }
+
+  // === FUNCTIONS ================================================================================
+
+  for (i = 0; i < nArray; i++) {
+    for (j = 0; j < 4; j++) {
+      AddRsnFunctionsToPair(perfectPID[i][j]);
+      AddRsnFunctionsToPair(realisticPID[i][j]);
+    }
+  }
+
+  // === ADD TO PAIR MANAGER ======================================================================
+
+  for (i = 0; i < nArray; i++) {
+    for (j = 0; j < 4; j++) {
+      pairMgr->AddPair(perfectPID[i][j]);
+      pairMgr->AddPair(realisticPID[i][j]);
+    }
+  }
+
+  return pairMgr;
+}
+
diff --git a/PWG2/RESONANCES/macros/alien/RsnMergeAlien.C b/PWG2/RESONANCES/macros/alien/RsnMergeAlien.C
new file mode 100644 (file)
index 0000000..c99d4d0
--- /dev/null
@@ -0,0 +1,36 @@
+void RsnMergeAlien()
+{
+  // evaluate necessary arguments
+  char   searchpath[1024];
+  char   searchpattern[1024];
+  char   outputfile[1024];
+  char   username[1024];
+  char   masterjob[1024];
+  for (int i=0; i< gApplication->Argc();i++)
+  {
+    if (!(strcmp(gApplication->Argv(i), "--path")))       sprintf(searchpath, "%s", gApplication->Argv(i+1));
+    if (!(strcmp(gApplication->Argv(i), "--name")))       sprintf(searchpattern,"%s", gApplication->Argv(i+1));
+    if (!(strcmp(gApplication->Argv(i), "--out")))        sprintf(outputfile, "%s", gApplication->Argv(i+1));
+    if (!(strcmp(gApplication->Argv(i), "--user")))       sprintf(username, "%s", gApplication->Argv(i+1));
+    if (!(strcmp(gApplication->Argv(i), "--masterjob")))  sprintf(masterjob, "%s", gApplication->Argv(i+1));
+  }
+
+  // connect to grid
+  TGrid::Connect("alien://");
+
+  // query the grid to find all files in a given pattern
+  TGridResult* result = gGrid->Query(searchpath, searchpattern);
+
+  // initialize the file merger
+  TFileMerger merger;
+  merger.OutputFile(outputfile);
+
+  // loop on query result to merge
+  Int_t nMerged = 0;
+  while (result->GetKey(nMerged, "turl"))
+  {
+    merger.AddFile(result->GetKey(nMerged, "turl"));
+    nMerged++;
+  }
+  if (nMerged) merger.Merge();
+}
diff --git a/PWG2/RESONANCES/macros/alien/rsn-merge.jdl b/PWG2/RESONANCES/macros/alien/rsn-merge.jdl
new file mode 100644 (file)
index 0000000..e7d727e
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# Arguments are the ones which must be passed to script:
+# -- $1 = root path containing all sub-paths with files to merge
+# -- $2 = name of the files to be merged
+# -- $3 = name of output file
+#
+
+Executable="rsn-merge.sh";
+Arguments="$1 $2 $3";
+
+Packages={
+  "APISCONFIG::V2.4",
+  "VO_ALICE@ROOT::v5-23-02"
+};
+
+TTL="40000";
+
+InputFile="LF:/alice/cern.ch/user/p/pulvir/pdc09/RsnMergeAlien.C";
+
+OutputDir="/alice/cern.ch/user/p/pulvir/$1/merge";
+OutputArchive={"$3.zip:$3.*@ALICE::Catania::dpm"};
diff --git a/PWG2/RESONANCES/macros/alien/rsn-merge.sh b/PWG2/RESONANCES/macros/alien/rsn-merge.sh
new file mode 100755 (executable)
index 0000000..3b5e71f
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Calls the merging macro and passes to it the two required arguments
+# -- $1 = root path containing all sub-paths with files to merge
+# -- $2 = name of the files to be merged
+# -- $3 = name of output file
+
+path=/alice/cern.ch/user/p/pulvir/$1
+outName=$3.root
+logName=$3.log
+inName=$2.root
+
+exec root -b -q -l -x RsnMergeAlien.C --path "$path" --name "$inName" --out "$outName" >& $logName
+echo >> $logName
+echo >> $logName
+echo -n 'Executed in: ' >> $logName
+hostname -f >> $logName