adding production request
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Sep 2009 08:56:36 +0000 (08:56 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 18 Sep 2009 08:56:36 +0000 (08:56 +0000)
prod/LHC09c1/CheckESD.C [new file with mode: 0644]
prod/LHC09c1/Config.C [new file with mode: 0644]
prod/LHC09c1/CreateAODfromESD.C [new file with mode: 0644]
prod/LHC09c1/JDL [new file with mode: 0644]
prod/LHC09c1/rec.C [new file with mode: 0644]
prod/LHC09c1/sim.C [new file with mode: 0644]
prod/LHC09c1/simrun.C [new file with mode: 0644]
prod/LHC09c1/tag.C [new file with mode: 0644]

diff --git a/prod/LHC09c1/CheckESD.C b/prod/LHC09c1/CheckESD.C
new file mode 100644 (file)
index 0000000..1f700d3
--- /dev/null
@@ -0,0 +1,693 @@
+#if !defined( __CINT__) || defined(__MAKECINT__)
+#include <TROOT.h>
+#include <TFile.h>
+#include <TError.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TF1.h>
+#include <TCanvas.h>
+#include <TVector3.h>
+#include <TPDGCode.h>
+#include <TParticle.h>
+
+#include "AliRunLoader.h"
+#include "AliLoader.h"
+#include "AliESDEvent.h"
+#include "AliESDv0.h"
+#include "AliESDcascade.h"
+#include "AliESDMuonTrack.h"
+#include "AliESDCaloCluster.h"
+#include "AliRun.h"
+#include "AliStack.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+#include "AliPID.h"
+#endif
+
+TH1F* CreateHisto(const char* name, const char* title, 
+                 Int_t nBins, Double_t xMin, Double_t xMax,
+                 const char* xLabel = NULL, const char* yLabel = NULL)
+{
+// create a histogram
+
+  TH1F* result = new TH1F(name, title, nBins, xMin, xMax);
+  result->SetOption("E");
+  if (xLabel) result->GetXaxis()->SetTitle(xLabel);
+  if (yLabel) result->GetYaxis()->SetTitle(yLabel);
+  result->SetMarkerStyle(kFullCircle);
+  return result;
+}
+
+TH1F* CreateEffHisto(TH1F* hGen, TH1F* hRec)
+{
+// create an efficiency histogram
+
+  Int_t nBins = hGen->GetNbinsX();
+  TH1F* hEff = (TH1F*) hGen->Clone("hEff");
+  hEff->SetTitle("");
+  hEff->SetStats(kFALSE);
+  hEff->SetMinimum(0.);
+  hEff->SetMaximum(110.);
+  hEff->GetYaxis()->SetTitle("#epsilon [%]");
+
+  for (Int_t iBin = 0; iBin <= nBins; iBin++) {
+    Double_t nGen = hGen->GetBinContent(iBin);
+    Double_t nRec = hRec->GetBinContent(iBin);
+    if (nGen > 0) {
+      Double_t eff = nRec/nGen;
+      hEff->SetBinContent(iBin, 100. * eff);
+      Double_t error = sqrt(eff*(1.-eff) / nGen);
+      if (error == 0) error = 0.0001;
+      hEff->SetBinError(iBin, 100. * error);
+    } else {
+      hEff->SetBinContent(iBin, -100.);
+      hEff->SetBinError(iBin, 0);
+    }
+  }
+
+  return hEff;
+}
+
+Bool_t FitHisto(TH1* histo, Double_t& res, Double_t& resError)
+{
+// fit a gaussian to a histogram
+
+  static TF1* fitFunc = new TF1("fitFunc", "gaus");
+  fitFunc->SetLineWidth(2);
+  fitFunc->SetFillStyle(0);
+  Double_t maxFitRange = 2;
+
+  if (histo->Integral() > 50) {
+    Float_t mean = histo->GetMean();
+    Float_t rms = histo->GetRMS();
+    fitFunc->SetRange(mean - maxFitRange*rms, mean + maxFitRange*rms);
+    fitFunc->SetParameters(mean, rms);
+    histo->Fit(fitFunc, "QRI0");
+    histo->GetFunction("fitFunc")->ResetBit(1<<9);
+    res = TMath::Abs(fitFunc->GetParameter(2));
+    resError = TMath::Abs(fitFunc->GetParError(2));
+    return kTRUE;
+  }
+
+  return kFALSE;
+}
+
+
+Bool_t CheckESD(const char* gAliceFileName = "galice.root", 
+               const char* esdFileName = "AliESDs.root")
+{
+// check the content of the ESD
+  // check values
+  Int_t    checkNGenLow = 1;
+
+  Double_t checkEffLow = 0.5;
+  Double_t checkEffSigma = 3;
+  Double_t checkFakeHigh = 0.5;
+  Double_t checkFakeSigma = 3;
+
+  Double_t checkResPtInvHigh = 5;
+  Double_t checkResPtInvSigma = 3;
+  Double_t checkResPhiHigh = 10;
+  Double_t checkResPhiSigma = 3;
+  Double_t checkResThetaHigh = 10;
+  Double_t checkResThetaSigma = 3;
+
+  Double_t checkPIDEffLow = 0.5;
+  Double_t checkPIDEffSigma = 3;
+  Double_t checkResTOFHigh = 500;
+  Double_t checkResTOFSigma = 3;
+
+  Double_t checkPHOSNLow = 5;
+  Double_t checkPHOSEnergyLow = 0.3;
+  Double_t checkPHOSEnergyHigh = 1.0;
+  Double_t checkEMCALNLow = 50;
+  Double_t checkEMCALEnergyLow = 0.05;
+  Double_t checkEMCALEnergyHigh = 1.0;
+
+  Double_t checkMUONNLow = 1;
+  Double_t checkMUONPtLow = 0.5;
+  Double_t checkMUONPtHigh = 10.;
+
+  Double_t cutPtV0 = 0.3;
+  Double_t checkV0EffLow = 0.02;
+  Double_t checkV0EffSigma = 3;
+  Double_t cutPtCascade = 0.5;
+  Double_t checkCascadeEffLow = 0.01;
+  Double_t checkCascadeEffSigma = 3;
+
+  // open run loader and load gAlice, kinematics and header
+  AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);
+  if (!runLoader) {
+    Error("CheckESD", "getting run loader from file %s failed", 
+           gAliceFileName);
+    return kFALSE;
+  }
+  runLoader->LoadgAlice();
+  gAlice = runLoader->GetAliRun();
+  if (!gAlice) {
+    Error("CheckESD", "no galice object found");
+    return kFALSE;
+  }
+  runLoader->LoadKinematics();
+  runLoader->LoadHeader();
+
+  // open the ESD file
+  TFile* esdFile = TFile::Open(esdFileName);
+  if (!esdFile || !esdFile->IsOpen()) {
+    Error("CheckESD", "opening ESD file %s failed", esdFileName);
+    return kFALSE;
+  }
+  AliESDEvent * esd = new AliESDEvent;
+  TTree* tree = (TTree*) esdFile->Get("esdTree");
+  if (!tree) {
+    Error("CheckESD", "no ESD tree found");
+    return kFALSE;
+  }
+  esd->ReadFromTree(tree);
+
+  // efficiency and resolution histograms
+  Int_t nBinsPt = 15;
+  Float_t minPt = 0.1;
+  Float_t maxPt = 3.1;
+  TH1F* hGen = CreateHisto("hGen", "generated tracks", 
+                          nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
+  TH1F* hRec = CreateHisto("hRec", "reconstructed tracks", 
+                          nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
+  Int_t nGen = 0;
+  Int_t nRec = 0;
+  Int_t nFake = 0;
+
+  TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10, 
+           "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N");
+  TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20, 
+                             "#phi_{rec}-#phi_{sim} [mrad]", "N");
+  TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20, 
+                               "#theta_{rec}-#theta_{sim} [mrad]", "N");
+
+  // PID
+  Int_t partCode[AliPID::kSPECIES] = 
+    {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
+  const char* partName[AliPID::kSPECIES+1] = 
+    {"electron", "muon", "pion", "kaon", "proton", "other"};
+  Double_t partFrac[AliPID::kSPECIES] = 
+    {0.01, 0.01, 0.85, 0.10, 0.05};
+  Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES];
+  for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
+    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
+      identified[iGen][iRec] = 0;
+    }
+  }
+  Int_t nIdentified = 0;
+
+  // dE/dx and TOF
+  TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400);
+  hDEdxRight->SetStats(kFALSE);
+  hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]");
+  hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}");
+  hDEdxRight->SetMarkerStyle(kFullCircle);
+  hDEdxRight->SetMarkerSize(0.4);
+  TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400);
+  hDEdxWrong->SetStats(kFALSE);
+  hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]");
+  hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}");
+  hDEdxWrong->SetMarkerStyle(kFullCircle);
+  hDEdxWrong->SetMarkerSize(0.4);
+  hDEdxWrong->SetMarkerColor(kRed);
+  TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000, 
+                                  "t_{TOF}-t_{track} [ps]", "N");
+  TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000, 
+                                  "t_{TOF}-t_{track} [ps]", "N");
+  hResTOFWrong->SetLineColor(kRed);
+
+  // calorimeters
+  TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 50, "E [GeV]", "N");
+  TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N");
+
+  // muons
+  TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20, 
+                             "p_{t} [GeV/c]", "N");
+
+  // V0s and cascades
+  TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6, 
+                             "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N");
+  TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2, 
+                                 "M(p#pi^{-}) [GeV/c^{2}]", "N");
+  TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}", 
+                                    100, 1.0, 1.2, 
+                                    "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N");
+  Int_t nGenV0s = 0;
+  Int_t nRecV0s = 0;
+  TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5, 
+                             "M(#Lambda#pi) [GeV/c^{2}]", "N");
+  TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8, 
+                                "M(#LambdaK) [GeV/c^{2}]", "N");
+  Int_t nGenCascades = 0;
+  Int_t nRecCascades = 0;
+
+  // loop over events
+  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
+    runLoader->GetEvent(iEvent);
+
+    // select simulated primary particles, V0s and cascades
+    AliStack* stack = runLoader->Stack();
+    Int_t nParticles = stack->GetNtrack();
+    TArrayF vertex(3);
+    runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex);
+    TObjArray selParticles;
+    TObjArray selV0s;
+    TObjArray selCascades;
+    for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
+      TParticle* particle = stack->Particle(iParticle);
+      if (!particle) continue;
+      if (particle->Pt() < 0.001) continue;
+      if (TMath::Abs(particle->Eta()) > 0.9) continue;
+      TVector3 dVertex(particle->Vx() - vertex[0], 
+                      particle->Vy() - vertex[1],
+                      particle->Vz() - vertex[2]);
+      if (dVertex.Mag() > 0.0001) continue;
+
+      switch (TMath::Abs(particle->GetPdgCode())) {
+      case kElectron:
+      case kMuonMinus:
+      case kPiPlus:
+      case kKPlus:
+      case kProton: {
+       if (particle->Pt() > minPt) {
+         selParticles.Add(particle);
+         nGen++;
+         hGen->Fill(particle->Pt());
+       }
+       break;
+      }
+      case kK0Short:
+      case kLambda0: {
+       if (particle->Pt() > cutPtV0) {
+         nGenV0s++;
+         selV0s.Add(particle);
+       }
+       break;
+      }
+      case kXiMinus:
+      case kOmegaMinus: {
+       if (particle->Pt() > cutPtCascade) {
+         nGenCascades++;
+         selCascades.Add(particle);
+       }
+       break;
+      }
+      default: break;
+      }
+    }
+
+    // get the event summary data
+    tree->GetEvent(iEvent);
+    if (!esd) {
+      Error("CheckESD", "no ESD object found for event %d", iEvent);
+      return kFALSE;
+    }
+
+    // loop over tracks
+    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
+      AliESDtrack* track = esd->GetTrack(iTrack);
+
+      // select tracks of selected particles
+      Int_t label = TMath::Abs(track->GetLabel());
+      if (label > stack->GetNtrack()) continue;     // background
+      TParticle* particle = stack->Particle(label);
+      if (!selParticles.Contains(particle)) continue;
+      if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;
+      if (track->GetConstrainedChi2() > 1e9) continue;
+      selParticles.Remove(particle);   // don't count multiple tracks
+
+      nRec++;
+      hRec->Fill(particle->Pt());
+      if (track->GetLabel() < 0) nFake++;
+
+      // resolutions
+      hResPtInv->Fill(100. * (TMath::Abs(track->GetSigned1Pt()) - 1./particle->Pt()) * 
+                     particle->Pt());
+      hResPhi->Fill(1000. * (track->Phi() - particle->Phi()));
+      hResTheta->Fill(1000. * (track->Theta() - particle->Theta()));
+
+      // PID
+      if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue;
+      Int_t iGen = 5;
+      for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
+       if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i;
+      }
+      Double_t probability[AliPID::kSPECIES];
+      track->GetESDpid(probability);
+      Double_t pMax = 0;
+      Int_t iRec = 0;
+      for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
+       probability[i] *= partFrac[i];
+       if (probability[i] > pMax) {
+         pMax = probability[i];
+         iRec = i;
+       }
+      }
+      identified[iGen][iRec]++;
+      if (iGen == iRec) nIdentified++;
+
+      // dE/dx and TOF
+      Double_t time[AliPID::kSPECIES];
+      track->GetIntegratedTimes(time);
+      if (iGen == iRec) {
+       hDEdxRight->Fill(particle->P(), track->GetTPCsignal());
+        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
+         hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]);
+       }
+      } else {
+       hDEdxWrong->Fill(particle->P(), track->GetTPCsignal());
+        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
+         hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]);
+       }
+      }
+    }
+
+    // loop over muon tracks
+    {
+    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) {
+      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
+      Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum());
+      if (ptInv > 0.001) {
+       hPtMUON->Fill(1./ptInv);
+      }
+    }
+    }
+
+    // loop over V0s
+    for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
+      AliESDv0* v0 = esd->GetV0(iV0);
+      if (v0->GetOnFlyStatus()) continue;
+      v0->ChangeMassHypothesis(kK0Short);
+      hMassK0->Fill(v0->GetEffMass());
+      v0->ChangeMassHypothesis(kLambda0);
+      hMassLambda->Fill(v0->GetEffMass());
+      v0->ChangeMassHypothesis(kLambda0Bar);
+      hMassLambdaBar->Fill(v0->GetEffMass());
+
+      Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel());
+      if (negLabel > stack->GetNtrack()) continue;     // background
+      Int_t negMother = stack->Particle(negLabel)->GetMother(0);
+      if (negMother < 0) continue;
+      Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel());
+      if (posLabel > stack->GetNtrack()) continue;     // background
+      Int_t posMother = stack->Particle(posLabel)->GetMother(0);
+      if (negMother != posMother) continue;
+      TParticle* particle = stack->Particle(negMother);
+      if (!selV0s.Contains(particle)) continue;
+      selV0s.Remove(particle);
+      nRecV0s++;
+    }
+
+    // loop over Cascades
+    for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades(); 
+        iCascade++) {
+      AliESDcascade* cascade = esd->GetCascade(iCascade);
+      Double_t v0q;
+      cascade->ChangeMassHypothesis(v0q,kXiMinus);
+      hMassXi->Fill(cascade->GetEffMassXi());
+      cascade->ChangeMassHypothesis(v0q,kOmegaMinus);
+      hMassOmega->Fill(cascade->GetEffMassXi());
+
+      Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex())
+                                 ->GetLabel());
+      if (negLabel > stack->GetNtrack()) continue;     // background
+      Int_t negMother = stack->Particle(negLabel)->GetMother(0);
+      if (negMother < 0) continue;
+      Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex())
+                                 ->GetLabel());
+      if (posLabel > stack->GetNtrack()) continue;     // background
+      Int_t posMother = stack->Particle(posLabel)->GetMother(0);
+      if (negMother != posMother) continue;
+      Int_t v0Mother = stack->Particle(negMother)->GetMother(0);
+      if (v0Mother < 0) continue;
+      Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex())
+                                 ->GetLabel());
+      if (bacLabel > stack->GetNtrack()) continue;     // background
+      Int_t bacMother = stack->Particle(bacLabel)->GetMother(0);
+      if (v0Mother != bacMother) continue;
+      TParticle* particle = stack->Particle(v0Mother);
+      if (!selCascades.Contains(particle)) continue;
+      selCascades.Remove(particle);
+      nRecCascades++;
+    }
+
+    // loop over the clusters
+    {
+      for (Int_t iCluster=0; iCluster<esd->GetNumberOfCaloClusters(); iCluster++) {
+       AliESDCaloCluster * clust = esd->GetCaloCluster(iCluster);
+       if (clust->IsPHOS()) hEPHOS->Fill(clust->E());
+       if (clust->IsEMCAL()) hEEMCAL->Fill(clust->E());
+      }
+    }
+
+  }
+
+  // perform checks
+  if (nGen < checkNGenLow) {
+    Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen));
+  }
+
+  TH1F* hEff = CreateEffHisto(hGen, hRec);
+
+  Info("CheckESD", "%d out of %d tracks reconstructed including %d "
+        "fake tracks", nRec, nGen, nFake);
+  if (nGen > 0) {
+    // efficiency
+    Double_t eff = nRec*1./nGen;
+    Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen);
+    Double_t fake = nFake*1./nGen;
+    Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen);
+    Info("CheckESD", "eff = (%.1f +- %.1f) %%  fake = (%.1f +- %.1f) %%",
+        100.*eff, 100.*effError, 100.*fake, 100.*fakeError);
+
+    if (eff < checkEffLow - checkEffSigma*effError) {
+      Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%", 
+             100.*eff, 100.*effError);
+    }
+    if (fake > checkFakeHigh + checkFakeSigma*fakeError) {
+      Warning("CheckESD", "high fake: (%.1f +- %.1f) %%", 
+             100.*fake, 100.*fakeError);
+    }
+
+    // resolutions
+    Double_t res, resError;
+    if (FitHisto(hResPtInv, res, resError)) {
+      Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%",
+          res, resError);
+      if (res > checkResPtInvHigh + checkResPtInvSigma*resError) {
+       Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%", 
+               res, resError);
+      }
+    }
+
+    if (FitHisto(hResPhi, res, resError)) {
+      Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError);
+      if (res > checkResPhiHigh + checkResPhiSigma*resError) {
+       Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad", 
+               res, resError);
+      }
+    }
+
+    if (FitHisto(hResTheta, res, resError)) {
+      Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad", 
+          res, resError);
+      if (res > checkResThetaHigh + checkResThetaSigma*resError) {
+       Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad", 
+               res, resError);
+      }
+    }
+
+    // PID
+    if (nRec > 0) {
+      Double_t eff = nIdentified*1./nRec;
+      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec);
+      Info("CheckESD", "PID eff = (%.1f +- %.1f) %%", 
+          100.*eff, 100.*effError);
+      if (eff < checkPIDEffLow - checkPIDEffSigma*effError) {
+       Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%", 
+               100.*eff, 100.*effError);
+      }
+    }
+
+    printf("%9s:", "gen\\rec");
+    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
+      printf("%9s", partName[iRec]);
+    }
+    printf("\n");
+    for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
+      printf("%9s:", partName[iGen]);
+      for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
+       printf("%9d", identified[iGen][iRec]);
+      }
+      printf("\n");
+    }
+
+    if (FitHisto(hResTOFRight, res, resError)) {
+      Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError);
+      if (res > checkResTOFHigh + checkResTOFSigma*resError) {
+       Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps", 
+               res, resError);
+      }
+    }
+
+    // calorimeters
+    if (hEPHOS->Integral() < checkPHOSNLow) {
+      Warning("CheckESD", "low number of PHOS particles: %d", 
+             Int_t(hEPHOS->Integral()));
+    } else {
+      Double_t mean = hEPHOS->GetMean();
+      if (mean < checkPHOSEnergyLow) {
+       Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean);
+      } else if (mean > checkPHOSEnergyHigh) {
+       Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean);
+      }
+    }
+
+    if (hEEMCAL->Integral() < checkEMCALNLow) {
+      Warning("CheckESD", "low number of EMCAL particles: %d", 
+             Int_t(hEEMCAL->Integral()));
+    } else {
+      Double_t mean = hEEMCAL->GetMean();
+      if (mean < checkEMCALEnergyLow) {
+       Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean);
+      } else if (mean > checkEMCALEnergyHigh) {
+       Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean);
+      }
+    }
+
+    // muons
+    if (hPtMUON->Integral() < checkMUONNLow) {
+      Warning("CheckESD", "low number of MUON particles: %d", 
+             Int_t(hPtMUON->Integral()));
+    } else {
+      Double_t mean = hPtMUON->GetMean();
+      if (mean < checkMUONPtLow) {
+       Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean);
+      } else if (mean > checkMUONPtHigh) {
+       Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean);
+      }
+    }
+
+    // V0s
+    if (nGenV0s > 0) {
+      Double_t eff = nRecV0s*1./nGenV0s;
+      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s);
+      if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s);
+      Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%", 
+          100.*eff, 100.*effError);
+      if (eff < checkV0EffLow - checkV0EffSigma*effError) {
+       Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%", 
+               100.*eff, 100.*effError);
+      }
+    }
+
+    // Cascades
+    if (nGenCascades > 0) {
+      Double_t eff = nRecCascades*1./nGenCascades;
+      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades);
+      if (effError == 0) effError = checkV0EffLow / 
+                          TMath::Sqrt(1.*nGenCascades);
+      Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%", 
+          100.*eff, 100.*effError);
+      if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) {
+       Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%", 
+               100.*eff, 100.*effError);
+      }
+    }
+  }
+
+  // draw the histograms if not in batch mode
+  if (!gROOT->IsBatch()) {
+    new TCanvas;
+    hEff->DrawCopy();
+    new TCanvas;
+    hResPtInv->DrawCopy("E");
+    new TCanvas;
+    hResPhi->DrawCopy("E");
+    new TCanvas;
+    hResTheta->DrawCopy("E");
+    new TCanvas;
+    hDEdxRight->DrawCopy();
+    hDEdxWrong->DrawCopy("SAME");
+    new TCanvas;
+    hResTOFRight->DrawCopy("E");
+    hResTOFWrong->DrawCopy("SAME");
+    new TCanvas;
+    hEPHOS->DrawCopy("E");
+    new TCanvas;
+    hEEMCAL->DrawCopy("E");
+    new TCanvas;
+    hPtMUON->DrawCopy("E");
+    new TCanvas;
+    hMassK0->DrawCopy("E");
+    new TCanvas;
+    hMassLambda->DrawCopy("E");
+    new TCanvas;
+    hMassLambdaBar->DrawCopy("E");
+    new TCanvas;
+    hMassXi->DrawCopy("E");
+    new TCanvas;
+    hMassOmega->DrawCopy("E");
+  }
+
+  // write the output histograms to a file
+  TFile* outputFile = TFile::Open("check.root", "recreate");
+  if (!outputFile || !outputFile->IsOpen()) {
+    Error("CheckESD", "opening output file check.root failed");
+    return kFALSE;
+  }
+  hEff->Write();
+  hResPtInv->Write();
+  hResPhi->Write();
+  hResTheta->Write();
+  hDEdxRight->Write();
+  hDEdxWrong->Write();
+  hResTOFRight->Write();
+  hResTOFWrong->Write();
+  hEPHOS->Write();
+  hEEMCAL->Write();
+  hPtMUON->Write();
+  hMassK0->Write();
+  hMassLambda->Write();
+  hMassLambdaBar->Write();
+  hMassXi->Write();
+  hMassOmega->Write();
+  outputFile->Close();
+  delete outputFile;
+
+  // clean up
+  delete hGen;
+  delete hRec;
+  delete hEff;
+  delete hResPtInv;
+  delete hResPhi;
+  delete hResTheta;
+  delete hDEdxRight;
+  delete hDEdxWrong;
+  delete hResTOFRight;
+  delete hResTOFWrong;
+  delete hEPHOS;
+  delete hEEMCAL;
+  delete hPtMUON;
+  delete hMassK0;
+  delete hMassLambda;
+  delete hMassLambdaBar;
+  delete hMassXi;
+  delete hMassOmega;
+
+  delete esd;
+  esdFile->Close();
+  delete esdFile;
+
+  runLoader->UnloadHeader();
+  runLoader->UnloadKinematics();
+  delete runLoader;
+
+  // result of check
+  Info("CheckESD", "check of ESD was successfull");
+  return kTRUE;
+}
diff --git a/prod/LHC09c1/Config.C b/prod/LHC09c1/Config.C
new file mode 100644 (file)
index 0000000..09f18d2
--- /dev/null
@@ -0,0 +1,633 @@
+//\r
+// Configuration for the first physics production 2008\r
+//\r
+\r
+// One can use the configuration macro in compiled mode by\r
+// root [0] gSystem->Load("libgeant321");\r
+// root [0] gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include\\r
+//                   -I$ALICE_ROOT -I$ALICE/geant3/TGeant3");\r
+// root [0] .x grun.C(1,"Config.C++")\r
+\r
+#if !defined(__CINT__) || defined(__MAKECINT__)\r
+#include <Riostream.h>\r
+#include <TRandom.h>\r
+#include <TDatime.h>\r
+#include <TSystem.h>\r
+#include <TVirtualMC.h>\r
+#include <TGeant3TGeo.h>\r
+#include "STEER/AliRunLoader.h"\r
+#include "STEER/AliRun.h"\r
+#include "STEER/AliConfig.h"\r
+#include "PYTHIA6/AliDecayerPythia.h"\r
+#include "PYTHIA6/AliGenPythia.h"\r
+#include "TDPMjet/AliGenDPMjet.h"\r
+#include "STEER/AliMagFCheb.h"\r
+#include "STRUCT/AliBODY.h"\r
+#include "STRUCT/AliMAG.h"\r
+#include "STRUCT/AliABSOv3.h"\r
+#include "STRUCT/AliDIPOv3.h"\r
+#include "STRUCT/AliHALLv3.h"\r
+#include "STRUCT/AliFRAMEv2.h"\r
+#include "STRUCT/AliSHILv3.h"\r
+#include "STRUCT/AliPIPEv3.h"\r
+#include "ITS/AliITSv11Hybrid.h"\r
+#include "TPC/AliTPCv2.h"\r
+#include "TOF/AliTOFv6T0.h"\r
+#include "HMPID/AliHMPIDv3.h"\r
+#include "ZDC/AliZDCv3.h"\r
+#include "TRD/AliTRDv1.h"\r
+#include "TRD/AliTRDgeometry.h"\r
+#include "FMD/AliFMDv1.h"\r
+#include "MUON/AliMUONv1.h"\r
+#include "PHOS/AliPHOSv1.h"\r
+#include "PHOS/AliPHOSSimParam.h"\r
+#include "PMD/AliPMDv1.h"\r
+#include "T0/AliT0v1.h"\r
+#include "EMCAL/AliEMCALv2.h"\r
+#include "ACORDE/AliACORDEv1.h"\r
+#include "VZERO/AliVZEROv7.h"\r
+#endif\r
+\r
+\r
+enum PDC06Proc_t \r
+{\r
+  kPythia6, kPhojet, kRunMax\r
+};\r
+\r
+const char * pprRunName[] = {\r
+  "kPythia6", "kPhojet"\r
+};\r
+\r
+enum Mag_t\r
+{\r
+  kNoField, k5kG, kFieldMax\r
+};\r
+\r
+const char * pprField[] = {\r
+  "kNoField", "k5kG"\r
+};\r
+\r
+//--- Functions ---\r
+class AliGenPythia;\r
+AliGenerator *MbPythia();\r
+AliGenerator *MbPhojet();\r
+void ProcessEnvironmentVars();\r
+\r
+// Geterator, field, beam energy\r
+static PDC06Proc_t   proc     = kPythia6;\r
+static Mag_t         mag      = k5kG;\r
+static Float_t       energy   = 900; // energy in CMS\r
+//========================//\r
+// Set Random Number seed //\r
+//========================//\r
+TDatime dt;\r
+static UInt_t seed    = dt.Get();\r
+\r
+// Comment line\r
+static TString comment;\r
+\r
+void Config()\r
+{\r
+    \r
+\r
+  // Get settings from environment variables\r
+  ProcessEnvironmentVars();\r
+\r
+  gRandom->SetSeed(seed);\r
+  cerr<<"Seed for random number generation= "<<seed<<endl; \r
+\r
+  // Libraries required by geant321\r
+#if defined(__CINT__)\r
+  gSystem->Load("liblhapdf");      // Parton density functions\r
+  gSystem->Load("libEGPythia6");   // TGenerator interface\r
+  gSystem->Load("libpythia6");     // Pythia\r
+  gSystem->Load("libAliPythia6");  // ALICE specific implementations\r
+  gSystem->Load("libgeant321");\r
+#endif\r
+\r
+  new TGeant3TGeo("C++ Interface to Geant3");\r
+\r
+  //=======================================================================\r
+  //  Create the output file\r
+\r
+   \r
+  AliRunLoader* rl=0x0;\r
+\r
+  cout<<"Config.C: Creating Run Loader ..."<<endl;\r
+  rl = AliRunLoader::Open("galice.root",\r
+                         AliConfig::GetDefaultEventFolderName(),\r
+                         "recreate");\r
+  if (rl == 0x0)\r
+    {\r
+      gAlice->Fatal("Config.C","Can not instatiate the Run Loader");\r
+      return;\r
+    }\r
+  rl->SetCompressionLevel(2);\r
+  rl->SetNumberOfEventsPerFile(1000);\r
+  gAlice->SetRunLoader(rl);\r
+  // gAlice->SetGeometryFromFile("geometry.root");\r
+  // gAlice->SetGeometryFromCDB();\r
+  \r
+  // Set the trigger configuration: proton-proton\r
+  gAlice->SetTriggerDescriptor("p-p");\r
+\r
+  //\r
+  //=======================================================================\r
+  // ************* STEERING parameters FOR ALICE SIMULATION **************\r
+  // --- Specify event type to be tracked through the ALICE setup\r
+  // --- All positions are in cm, angles in degrees, and P and E in GeV\r
+\r
+\r
+    gMC->SetProcess("DCAY",1);\r
+    gMC->SetProcess("PAIR",1);\r
+    gMC->SetProcess("COMP",1);\r
+    gMC->SetProcess("PHOT",1);\r
+    gMC->SetProcess("PFIS",0);\r
+    gMC->SetProcess("DRAY",0);\r
+    gMC->SetProcess("ANNI",1);\r
+    gMC->SetProcess("BREM",1);\r
+    gMC->SetProcess("MUNU",1);\r
+    gMC->SetProcess("CKOV",1);\r
+    gMC->SetProcess("HADR",1);\r
+    gMC->SetProcess("LOSS",2);\r
+    gMC->SetProcess("MULS",1);\r
+    gMC->SetProcess("RAYL",1);\r
+\r
+    Float_t cut = 1.e-3;        // 1MeV cut by default\r
+    Float_t tofmax = 1.e10;\r
+\r
+    gMC->SetCut("CUTGAM", cut);\r
+    gMC->SetCut("CUTELE", cut);\r
+    gMC->SetCut("CUTNEU", cut);\r
+    gMC->SetCut("CUTHAD", cut);\r
+    gMC->SetCut("CUTMUO", cut);\r
+    gMC->SetCut("BCUTE",  cut); \r
+    gMC->SetCut("BCUTM",  cut); \r
+    gMC->SetCut("DCUTE",  cut); \r
+    gMC->SetCut("DCUTM",  cut); \r
+    gMC->SetCut("PPCUTM", cut);\r
+    gMC->SetCut("TOFMAX", tofmax); \r
+\r
+\r
+\r
+\r
+  //======================//\r
+  // Set External decayer //\r
+  //======================//\r
+  TVirtualMCDecayer* decayer = new AliDecayerPythia();\r
+  decayer->SetForceDecay(kAll);\r
+  decayer->Init();\r
+  gMC->SetExternalDecayer(decayer);\r
+\r
+  //=========================//\r
+  // Generator Configuration //\r
+  //=========================//\r
+  AliGenerator* gener = 0x0;\r
+  \r
+  if (proc == kPythia6) {\r
+      gener = MbPythia();\r
+  } else if (proc == kPhojet) {\r
+      gener = MbPhojet();\r
+  }\r
+  \r
+  \r
+\r
+  // PRIMARY VERTEX\r
+  //\r
+  gener->SetOrigin(0., 0., 0.);    // vertex position\r
+  //\r
+  //\r
+  // Size of the interaction diamond\r
+  // Longitudinal\r
+  Float_t sigmaz  = 5.4 / TMath::Sqrt(2.); // [cm]\r
+  if (energy == 900)\r
+    sigmaz  = 10.5 / TMath::Sqrt(2.); // [cm]\r
+  if (energy == 7000)\r
+    sigmaz  = 6.3 / TMath::Sqrt(2.); // [cm]\r
+  //\r
+  // Transverse\r
+  Float_t betast  = 10;                 // beta* [m]\r
+  Float_t eps     = 3.75e-6;            // emittance [m]\r
+  Float_t gamma   = energy / 2.0 / 0.938272;  // relativistic gamma [1]\r
+  Float_t sigmaxy = TMath::Sqrt(eps * betast / gamma) / TMath::Sqrt(2.) * 100.;  // [cm]\r
+  printf("\n \n Diamond size x-y: %10.3e z: %10.3e\n \n", sigmaxy, sigmaz);\r
+    \r
+  gener->SetSigma(sigmaxy, sigmaxy, sigmaz);      // Sigma in (X,Y,Z) (cm) on IP position\r
+  gener->SetCutVertexZ(3.);        // Truncate at 3 sigma\r
+  gener->SetVertexSmear(kPerEvent);\r
+\r
+  gener->Init();\r
+\r
+  // FIELD\r
+  //\r
+  AliMagF* field = 0x0;\r
+  if (mag == kNoField) {\r
+    comment = comment.Append(" | L3 field 0.0 T");\r
+    field = new AliMagF("Maps","Maps", 2, 0., 0., 10., AliMagF::k2kG,\r
+                       "$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root",\r
+                       AliMagF::kBeamTypepp, energy/2.0);\r
+  } else if (mag == k5kG) {\r
+    comment = comment.Append(" | L3 field 0.5 T");\r
+    field = new AliMagF("Maps","Maps", 2, 1., 1., 10., AliMagF::k5kG,\r
+                       "$(ALICE_ROOT)/data/maps/mfchebKGI_sym.root",\r
+                       AliMagF::kBeamTypepp, energy/2.0);\r
+  }\r
+  printf("\n \n Comment: %s \n \n", comment.Data());\r
+\r
+  TGeoGlobalMagField::Instance()->SetField(field);\r
+    \r
+  rl->CdGAFile();\r
+  \r
+  Int_t iABSO  = 1;\r
+  Int_t iACORDE= 0;\r
+  Int_t iDIPO  = 1;\r
+  Int_t iEMCAL = 1;\r
+  Int_t iFMD   = 1;\r
+  Int_t iFRAME = 1;\r
+  Int_t iHALL  = 1;\r
+  Int_t iITS   = 1;\r
+  Int_t iMAG   = 1;\r
+  Int_t iMUON  = 1;\r
+  Int_t iPHOS  = 1;\r
+  Int_t iPIPE  = 1;\r
+  Int_t iPMD   = 1;\r
+  Int_t iHMPID = 1;\r
+  Int_t iSHIL  = 1;\r
+  Int_t iT0    = 1;\r
+  Int_t iTOF   = 1;\r
+  Int_t iTPC   = 1;\r
+  Int_t iTRD   = 1;\r
+  Int_t iVZERO = 1;\r
+  Int_t iZDC   = 1;\r
+  \r
+\r
+    //=================== Alice BODY parameters =============================\r
+    AliBODY *BODY = new AliBODY("BODY", "Alice envelop");\r
+\r
+\r
+    if (iMAG)\r
+    {\r
+        //=================== MAG parameters ============================\r
+        // --- Start with Magnet since detector layouts may be depending ---\r
+        // --- on the selected Magnet dimensions ---\r
+        AliMAG *MAG = new AliMAG("MAG", "Magnet");\r
+    }\r
+\r
+\r
+    if (iABSO)\r
+    {\r
+        //=================== ABSO parameters ============================\r
+        AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");\r
+    }\r
+\r
+    if (iDIPO)\r
+    {\r
+        //=================== DIPO parameters ============================\r
+\r
+        AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");\r
+    }\r
+\r
+    if (iHALL)\r
+    {\r
+        //=================== HALL parameters ============================\r
+\r
+        AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");\r
+    }\r
+\r
+\r
+    if (iFRAME)\r
+    {\r
+        //=================== FRAME parameters ============================\r
+\r
+        AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");\r
+       FRAME->SetHoles(1);\r
+    }\r
+\r
+    if (iSHIL)\r
+    {\r
+        //=================== SHIL parameters ============================\r
+\r
+        AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");\r
+    }\r
+\r
+\r
+    if (iPIPE)\r
+    {\r
+        //=================== PIPE parameters ============================\r
+\r
+        AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");\r
+    }\r
\r
+    if (iITS)\r
+    {\r
+        //=================== ITS parameters ============================\r
+\r
+       AliITS *ITS  = new AliITSv11Hybrid("ITS","ITS v11Hybrid");\r
+    }\r
+\r
+    if (iTPC)\r
+    {\r
+      //============================ TPC parameters =====================\r
+\r
+        AliTPC *TPC = new AliTPCv2("TPC", "Default");\r
+    }\r
+\r
+\r
+    if (iTOF) {\r
+        //=================== TOF parameters ============================\r
+\r
+       AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");\r
+    }\r
+\r
+\r
+    if (iHMPID)\r
+    {\r
+        //=================== HMPID parameters ===========================\r
+\r
+        AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");\r
+\r
+    }\r
+\r
+\r
+    if (iZDC)\r
+    {\r
+        //=================== ZDC parameters ============================\r
+\r
+        AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");\r
+    }\r
+\r
+    if (iTRD)\r
+    {\r
+        //=================== TRD parameters ============================\r
+\r
+        AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");\r
+        AliTRDgeometry *geoTRD = TRD->GetGeometry();\r
+       // Partial geometry: modules at 0,1,7,8,9,16,17\r
+       // starting at 3h in positive direction\r
+       geoTRD->SetSMstatus(2,0);\r
+       geoTRD->SetSMstatus(3,0);\r
+       geoTRD->SetSMstatus(4,0);\r
+        geoTRD->SetSMstatus(5,0);\r
+       geoTRD->SetSMstatus(6,0);\r
+        geoTRD->SetSMstatus(10,0);\r
+        geoTRD->SetSMstatus(11,0);\r
+        geoTRD->SetSMstatus(12,0);\r
+        geoTRD->SetSMstatus(13,0);\r
+        geoTRD->SetSMstatus(14,0);\r
+        geoTRD->SetSMstatus(15,0);\r
+    }\r
+\r
+    if (iFMD)\r
+    {\r
+        //=================== FMD parameters ============================\r
+\r
+       AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");\r
+   }\r
+\r
+    if (iMUON)\r
+    {\r
+        //=================== MUON parameters ===========================\r
+        // New MUONv1 version (geometry defined via builders)\r
+\r
+        AliMUON *MUON = new AliMUONv1("MUON", "default");\r
+    }\r
+\r
+    if (iPHOS)\r
+    {\r
+        //=================== PHOS parameters ===========================\r
+\r
+        AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");\r
+        //Set simulation parameters different from the default ones.\r
+        AliPHOSSimParam* simEmc = AliPHOSSimParam::GetInstance() ;\r
+  \r
+        // APD noise of warm (+20C) PHOS:\r
+        // a2 = a1*(Y1/Y2)*(M1/M2), where a1 = 0.012 is APD noise at -25C,\r
+        // Y1 = 4.3 photo-electrons/MeV, Y2 = 1.7 p.e/MeV - light yields at -25C and +20C,\r
+        // M1 = 50, M2 = 50 - APD gain factors chosen for t1 = -25C and t2 = +20C,\r
+        // Y = MeanLightYield*APDEfficiency.\r
+\r
+        Float_t apdNoise = 0.012*2.5; \r
+        simEmc->SetAPDNoise(apdNoise);\r
+\r
+        //Raw Light Yield at +20C\r
+        simEmc->SetMeanLightYield(18800);\r
+\r
+        //ADC channel width at +18C.\r
+        simEmc->SetADCchannelW(0.0125);\r
+    }\r
+\r
+\r
+    if (iPMD)\r
+    {\r
+        //=================== PMD parameters ============================\r
+\r
+        AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");\r
+    }\r
+\r
+    if (iT0)\r
+    {\r
+        //=================== T0 parameters ============================\r
+        AliT0 *T0 = new AliT0v1("T0", "T0 Detector");\r
+    }\r
+\r
+    if (iEMCAL)\r
+    {\r
+        //=================== EMCAL parameters ============================\r
+\r
+        AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETE");\r
+    }\r
+\r
+     if (iACORDE)\r
+    {\r
+        //=================== ACORDE parameters ============================\r
+\r
+        AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");\r
+    }\r
+\r
+     if (iVZERO)\r
+    {\r
+        //=================== ACORDE parameters ============================\r
+\r
+        AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");\r
+    }\r
+}\r
+//\r
+//           PYTHIA\r
+//\r
+\r
+AliGenerator* MbPythia()\r
+{\r
+      comment = comment.Append(Form(" pp at %d GeV: Pythia low-pt", (Int_t) energy));\r
+//\r
+//    Pythia\r
+      AliGenPythia* pythia = new AliGenPythia(-1); \r
+      pythia->SetMomentumRange(0, 999999.);\r
+      pythia->SetThetaRange(0., 180.);\r
+      pythia->SetYRange(-12.,12.);\r
+      pythia->SetPtRange(0,1000.);\r
+      pythia->SetProcess(kPyMb);\r
+      pythia->SetEnergyCMS(energy);\r
+      \r
+      // set high multiplicity trigger\r
+      \r
+      // this weight achieves a flat multiplicity distribution\r
+      TH1 *weight = new TH1D("weight","weight",201,-0.5,200.5);\r
+      weight->SetBinContent(1,5.557943);\r
+      weight->SetBinContent(2,8.987494);\r
+      weight->SetBinContent(5,0.2770979);\r
+      weight->SetBinContent(6,0.1434399);\r
+      weight->SetBinContent(7,0.8892316);\r
+      weight->SetBinContent(8,0.6610603);\r
+      weight->SetBinContent(9,0.5973895);\r
+      weight->SetBinContent(10,1.57095);\r
+      weight->SetBinContent(11,0.8407031);\r
+      weight->SetBinContent(12,1.676689);\r
+      weight->SetBinContent(13,1.381264);\r
+      weight->SetBinContent(14,1.209133);\r
+      weight->SetBinContent(15,1.326467);\r
+      weight->SetBinContent(16,1.248326);\r
+      weight->SetBinContent(17,1.396646);\r
+      weight->SetBinContent(18,0.7155231);\r
+      weight->SetBinContent(19,0.262448);\r
+      weight->SetBinContent(20,1.804454);\r
+      weight->SetBinContent(21,0.5723247);\r
+      weight->SetBinContent(22,1.279835);\r
+      weight->SetBinContent(23,0.285018);\r
+      weight->SetBinContent(24,1.239206);\r
+      weight->SetBinContent(25,0.628233);\r
+      weight->SetBinContent(26,1.91724);\r
+      weight->SetBinContent(28,1.130583);\r
+      weight->SetBinContent(29,0.9052101);\r
+      weight->SetBinContent(31,0.4293885);\r
+      weight->SetBinContent(32,1);\r
+      weight->SetBinContent(33,0.9999998);\r
+      weight->SetBinContent(34,0.9999998);\r
+      weight->SetBinContent(35,0.9999999);\r
+      weight->SetBinContent(36,1);\r
+      weight->SetBinContent(37,1);\r
+      weight->SetBinContent(38,1);\r
+      weight->SetBinContent(39,0.9999999);\r
+      weight->SetBinContent(40,0.9999998);\r
+      weight->SetBinContent(41,0.9999998);\r
+      weight->SetBinContent(42,0.9999998);\r
+      weight->SetBinContent(43,0.9999999);\r
+      weight->SetBinContent(44,0.9999999);\r
+      weight->SetBinContent(45,0.9999997);\r
+      weight->SetBinContent(46,0.9999997);\r
+      weight->SetBinContent(47,0.9999997);\r
+      weight->SetBinContent(48,0.9999997);\r
+      weight->SetBinContent(49,0.9999993);\r
+      weight->SetBinContent(50,0.9999997);\r
+      weight->SetBinContent(51,0.9999997);\r
+      weight->SetBinContent(52,0.9999996);\r
+      weight->SetBinContent(53,0.9999995);\r
+      weight->SetBinContent(54,1);\r
+      weight->SetBinContent(55,1);\r
+      weight->SetBinContent(56,1);\r
+      weight->SetBinContent(57,0.9999999);\r
+      weight->SetBinContent(58,0.9999997);\r
+      weight->SetBinContent(59,1);\r
+      weight->SetBinContent(60,1);\r
+      weight->SetBinContent(61,1);\r
+      weight->SetBinContent(62,1);\r
+      weight->SetBinContent(63,0.9999999);\r
+      weight->SetBinContent(64,0.9999999);\r
+      weight->SetBinContent(65,0.9999998);\r
+      weight->SetBinContent(66,0.9999997);\r
+      weight->SetBinContent(67,0.9999999);\r
+      weight->SetBinContent(68,0.9999997);\r
+      weight->SetBinContent(69,0.9999997);\r
+      weight->SetBinContent(70,0.9999997);\r
+      weight->SetBinContent(71,0.9999995);\r
+      weight->SetBinContent(72,0.9999997);\r
+      weight->SetBinContent(73,0.9999997);\r
+      weight->SetBinContent(74,0.9999997);\r
+      weight->SetBinContent(75,0.9999997);\r
+      weight->SetBinContent(76,0.9999997);\r
+      weight->SetBinContent(77,0.9999998);\r
+      weight->SetBinContent(78,0.9999998);\r
+      weight->SetBinContent(79,0.9999997);\r
+      weight->SetBinContent(80,0.9999998);\r
+      weight->SetBinContent(81,0.9999999);\r
+      weight->SetBinContent(82,0.9999999);\r
+      weight->SetBinContent(83,0.9999999);\r
+      weight->SetBinContent(84,0.9999998);\r
+      weight->SetBinContent(85,0.9999996);\r
+      weight->SetBinContent(86,0.9999998);\r
+      weight->SetBinContent(87,0.9999998);\r
+      weight->SetBinContent(88,0.9999999);\r
+      weight->SetBinContent(89,0.9999997);\r
+      weight->SetBinContent(90,0.9999997);\r
+      weight->SetBinContent(91,0.9999997);\r
+      weight->SetBinContent(92,0.9999996);\r
+      weight->SetBinContent(93,0.9999996);\r
+      weight->SetBinContent(94,0.9999995);\r
+      weight->SetBinContent(95,0.9999999);\r
+      weight->SetBinContent(96,0.9999999);\r
+      weight->SetBinContent(97,0.9999998);\r
+      weight->SetBinContent(98,0.9999998);\r
+      weight->SetBinContent(99,0.9999998);\r
+      weight->SetBinContent(100,0.9999998);\r
+      weight->SetEntries(507);      \r
+        \r
+      Int_t limit = weight->GetRandom();\r
+      pythia->SetTriggerChargedMultiplicity(limit, 1.4);\r
+      \r
+      comment = comment.Append(Form(" multiplicity threshold set to %d in |eta| < 1.4", limit));\r
+          \r
+      return pythia;\r
+}\r
+\r
+AliGenerator* MbPhojet()\r
+{\r
+      comment = comment.Append(" pp at 14 TeV: Phojet low-pt");\r
+//\r
+//    DPMJET\r
+#if defined(__CINT__)\r
+  gSystem->Load("libdpmjet");      // Parton density functions\r
+  gSystem->Load("libTDPMjet");      // Parton density functions\r
+#endif\r
+      AliGenDPMjet* dpmjet = new AliGenDPMjet(-1); \r
+      dpmjet->SetMomentumRange(0, 999999.);\r
+      dpmjet->SetThetaRange(0., 180.);\r
+      dpmjet->SetYRange(-12.,12.);\r
+      dpmjet->SetPtRange(0,1000.);\r
+      dpmjet->SetProcess(kDpmMb);\r
+      dpmjet->SetEnergyCMS(energy);\r
+\r
+      return dpmjet;\r
+}\r
+\r
+void ProcessEnvironmentVars()\r
+{\r
+    // Run type\r
+    if (gSystem->Getenv("CONFIG_RUN_TYPE")) {\r
+      for (Int_t iRun = 0; iRun < kRunMax; iRun++) {\r
+       if (strcmp(gSystem->Getenv("CONFIG_RUN_TYPE"), pprRunName[iRun])==0) {\r
+         proc = (PDC06Proc_t)iRun;\r
+         cout<<"Run type set to "<<pprRunName[iRun]<<endl;\r
+       }\r
+      }\r
+    }\r
+\r
+    // Field\r
+    if (gSystem->Getenv("CONFIG_FIELD")) {\r
+      for (Int_t iField = 0; iField < kFieldMax; iField++) {\r
+       if (strcmp(gSystem->Getenv("CONFIG_FIELD"), pprField[iField])==0) {\r
+         mag = (Mag_t)iField;\r
+         cout<<"Field set to "<<pprField[iField]<<endl;\r
+       }\r
+      }\r
+    }\r
+\r
+    // Energy\r
+    if (gSystem->Getenv("CONFIG_ENERGY")) {\r
+      energy = atoi(gSystem->Getenv("CONFIG_ENERGY"));\r
+      cout<<"Energy set to "<<energy<<" GeV"<<endl;\r
+    }\r
+\r
+    // Random Number seed\r
+    if (gSystem->Getenv("CONFIG_SEED")) {\r
+      seed = atoi(gSystem->Getenv("CONFIG_SEED"));\r
+    }\r
+}\r
diff --git a/prod/LHC09c1/CreateAODfromESD.C b/prod/LHC09c1/CreateAODfromESD.C
new file mode 100644 (file)
index 0000000..9c41487
--- /dev/null
@@ -0,0 +1,137 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TChain.h>
+#include <TSystem.h>
+#include "AliAnalysisManager.h"
+#include "AliESDInputHandler.h"
+#include "AliAODHandler.h"
+#include "AliAnalysisTaskESDfilter.h"
+#include "AliAnalysisDataContainer.h"
+#endif
+
+void CreateAODfromESD(const char *inFileName = "AliESDs.root",
+                     const char *outFileName = "AliAODs.root",
+                     Bool_t bKineFilter = kTRUE) 
+{
+  
+    gSystem->Load("libTree");
+    gSystem->Load("libGeom");
+    gSystem->Load("libPhysics");
+    gSystem->Load("libVMC");
+    gSystem->Load("libSTEERBase");
+    gSystem->Load("libESD");
+    gSystem->Load("libAOD");
+    
+    gSystem->Load("libANALYSIS");
+    gSystem->Load("libANALYSISalice");
+    gSystem->Load("libCORRFW");
+    gSystem->Load("libPWG3muon");
+
+    TChain *chain = new TChain("esdTree");
+    // Steering input chain
+    chain->Add(inFileName);
+    AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");
+
+    // Input
+    AliESDInputHandler* inpHandler = new AliESDInputHandler();
+    inpHandler->SetReadTags();
+    mgr->SetInputEventHandler  (inpHandler);
+    // Output
+    AliAODHandler* aodHandler   = new AliAODHandler();
+    aodHandler->SetOutputFileName(outFileName);
+    mgr->SetOutputEventHandler(aodHandler);
+
+    // MC Truth
+    if(bKineFilter){
+       AliMCEventHandler* mcHandler = new AliMCEventHandler();
+       mgr->SetMCtruthEventHandler(mcHandler);
+    }
+
+
+    // Tasks
+    // Filtering of MC particles (decays conversions etc)
+    // this task is also needed to set the MCEventHandler
+    // to the AODHandler, this will not be needed when
+    // AODHandler goes to ANALYSISalice
+    AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
+    if (bKineFilter) mgr->AddTask(kinefilter);
+    
+    // Barrel Tracks
+    AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
+    mgr->AddTask(filter);
+    // Muons
+    AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
+    mgr->AddTask(esdmuonfilter);
+
+    // Cuts on primary tracks
+    AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
+    esdTrackCutsL->SetMinNClustersTPC(50);
+    esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
+    esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
+    esdTrackCutsL->SetRequireTPCRefit(kTRUE);
+    esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
+    esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
+    esdTrackCutsL->SetDCAToVertex2D(kTRUE);
+    esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
+    esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
+    // ITS stand-alone tracks
+    AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
+    esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);
+
+    AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
+    trackFilter->AddCuts(esdTrackCutsL);
+    trackFilter->AddCuts(esdTrackCutsITSsa);
+
+    // Cuts on V0s
+    AliESDv0Cuts*   esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
+    esdV0Cuts->SetMinRadius(0.2);
+    esdV0Cuts->SetMaxRadius(200);
+    esdV0Cuts->SetMinDcaPosToVertex(0.05);
+    esdV0Cuts->SetMinDcaNegToVertex(0.05);
+    esdV0Cuts->SetMaxDcaV0Daughters(1.0);
+    esdV0Cuts->SetMinCosinePointingAngle(0.99);
+    AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
+    v0Filter->AddCuts(esdV0Cuts);
+
+
+//
+    filter->SetTrackFilter(trackFilter);
+    filter->SetV0Filter(v0Filter);
+
+
+//  Create AOD Tags
+    AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
+    mgr->AddTask(tagTask);
+
+    // Pipelining
+    AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();    
+    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
+    
+    
+    AliAnalysisDataContainer *coutputT
+       = mgr->CreateContainer("cTag",  TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");
+
+    coutput1->SetSpecialOutput();
+    coutputT->SetSpecialOutput();
+    
+    if(bKineFilter) {
+       mgr->ConnectInput  (kinefilter,     0, cinput1  );
+       mgr->ConnectOutput (kinefilter,     0, coutput1 );
+    }
+
+    mgr->ConnectInput (filter, 0, cinput1 );
+    mgr->ConnectOutput(filter, 0, coutput1);
+
+    mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
+//    mgr->ConnectOutput(esdmuonfilter, 0, coutput1);
+
+    mgr->ConnectInput (tagTask, 0, cinput1);
+    mgr->ConnectOutput(tagTask, 1, coutputT);
+
+    //
+    // Run the analysis
+    //
+    mgr->InitAnalysis();
+    mgr->PrintStatus();
+    mgr->StartAnalysis("local", chain);
+}
+
diff --git a/prod/LHC09c1/JDL b/prod/LHC09c1/JDL
new file mode 100644 (file)
index 0000000..3c64da2
--- /dev/null
@@ -0,0 +1,30 @@
+Executable = "aliroot_new";\r
+Jobtag={"comment:First physics (2009 - stage 3) pp, Pythia6, 0.5T, 900GeV, flat multiplicity, ID #127"};\r
+\r
+Packages={"VO_ALICE@AliRoot::v4-17-Rev-09","VO_ALICE@GEANT3::v1-11","VO_ALICE@ROOT::v5-24-00","VO_ALICE@APISCONFIG::V2.4"};\r
+\r
+TTL = "72000";\r
+\r
+Requirements =  member(other.GridPartitions,"PDC08_2");\r
+\r
+Validationcommand ="/alice/cern.ch/user/a/aliprod/prod2007/configs_pbpb_hijing/validation.sh";\r
+\r
+InputFile= {"LF:/alice/cern.ch/user/a/aliprod/LHC09c1/CheckESD.C",\r
+            "LF:/alice/cern.ch/user/a/aliprod/LHC09c1/Config.C",\r
+            "LF:/alice/cern.ch/user/a/aliprod/LHC09c1/rec.C",\r
+            "LF:/alice/cern.ch/user/a/aliprod/LHC09c1/sim.C",\r
+            "LF:/alice/cern.ch/user/a/aliprod/LHC09c1/simrun.C",\r
+            "LF:/alice/cern.ch/user/a/aliprod/LHC09c1/tag.C",\r
+            "LF:/alice/cern.ch/user/a/aliprod/LHC09c1/CreateAODfromESD.C"};\r
+\r
+OutputArchive={"log_archive:*.log,stdout,stderr@ALICE::Subatech::SE,ALICE::JINR::SE","root_archive.zip:galice.root,Kinematics.root,TrackRefs.root,AliESDs.root,AliESDfriends.root,AliAODs.root,*QA*.root,ITS.RecPoints.root,Run*.root@ALICE::CERN::ALICEDISK,ALICE::FZK::SE"};\r
+\r
+OutputDir="/alice/sim/PDC_09/LHC09c1/$1/#alien_counter_03i#";\r
+\r
+JDLVariables={"Packages", "OutputDir"};\r
+GUIDFILE="guid.txt";\r
+\r
+splitarguments="simrun.C --run $1 --event #alien_counter# --process kPythia6 --field k5kG --energy 900" ;\r
+split="production:1-1000";\r
+\r
+Workdirectorysize={"10000MB"};\r
diff --git a/prod/LHC09c1/rec.C b/prod/LHC09c1/rec.C
new file mode 100644 (file)
index 0000000..d611e3f
--- /dev/null
@@ -0,0 +1,20 @@
+void rec() {\r
+\r
+  AliReconstruction reco;\r
+  \r
+  reco.SetWriteESDfriend();\r
+  reco.SetWriteAlignmentData();\r
+\r
+  reco.SetDefaultStorage("alien://Folder=/alice/simulation/2008/v4-15-Release/Residual/");\r
+//   reco.SetSpecificStorage("GRP/GRP/Data",\r
+//                       Form("local://%s",gSystem->pwd()));\r
+  // We store the object in AliEn during the simulation\r
+  reco.SetSpecificStorage("GRP/GRP/Data",\r
+                         "alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/");\r
+\r
+  TStopwatch timer;\r
+  timer.Start();\r
+  reco.Run();\r
+  timer.Stop();\r
+  timer.Print();\r
+}\r
diff --git a/prod/LHC09c1/sim.C b/prod/LHC09c1/sim.C
new file mode 100644 (file)
index 0000000..4672058
--- /dev/null
@@ -0,0 +1,20 @@
+void sim(Int_t nev=200) {\r
+\r
+  AliSimulation simulator;\r
+  simulator.SetMakeSDigits("TRD TOF PHOS HMPID EMCAL MUON FMD ZDC PMD T0 VZERO");\r
+  simulator.SetMakeDigitsFromHits("ITS TPC");\r
+\r
+  // The raw data are not written due to the huge increase of the \r
+  // virtual memory in HLT\r
+  //  simulator.SetWriteRawData("ALL","raw.root",kTRUE);\r
+\r
+  simulator.SetDefaultStorage("alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/");\r
+//   simulator.SetSpecificStorage("GRP/GRP/Data",\r
+//                            Form("local://%s",gSystem->pwd()));\r
\r
+  TStopwatch timer;\r
+  timer.Start();\r
+  simulator.Run(nev);\r
+  timer.Stop();\r
+  timer.Print();\r
+}\r
diff --git a/prod/LHC09c1/simrun.C b/prod/LHC09c1/simrun.C
new file mode 100644 (file)
index 0000000..0e54a25
--- /dev/null
@@ -0,0 +1,90 @@
+// #define VERBOSEARGS
+// simrun.C
+{
+// set job and simulation variables as :
+// root.exe -b -q simrun.C  --run <x> --event <y> --process <kPythia6/kPhojet> --field <kNoField/k5kG> --energy <900/10000>
+
+  int nrun = 0;
+  int nevent = 0;
+  int seed = 0;
+
+  char sseed[1024];
+  char srun[1024];
+  char sevent[1024];
+  char sprocess[1024];
+  char sfield[1024];
+  char senergy[1024];
+
+  sprintf(srun,"");
+  sprintf(sevent,"");
+  sprintf(sprocess,"");
+  sprintf(sfield,"");
+  sprintf(senergy,"");
+
+  for (int i=0; i< gApplication->Argc();i++){
+#ifdef VERBOSEARGS
+    printf("Arg  %d:  %s\n",i,gApplication->Argv(i));
+#endif
+    if (!(strcmp(gApplication->Argv(i),"--run")))
+      nrun = atoi(gApplication->Argv(i+1));
+    sprintf(srun,"%d",nrun);
+
+    if (!(strcmp(gApplication->Argv(i),"--event")))
+      nevent = atoi(gApplication->Argv(i+1));
+    sprintf(sevent,"%d",nevent);
+
+    if (!(strcmp(gApplication->Argv(i),"--process")))
+      sprintf(sprocess, gApplication->Argv(i+1));
+
+    if (!(strcmp(gApplication->Argv(i),"--field")))
+      sprintf(sfield,gApplication->Argv(i+1));
+
+    if (!(strcmp(gApplication->Argv(i),"--energy")))
+      sprintf(senergy,gApplication->Argv(i+1));
+
+  }
+
+  seed = nrun * 100000 + nevent;
+  sprintf(sseed,"%d",seed);
+
+  if (seed==0) {
+    fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+    fprintf(stderr,"!!!!  WARNING! Seeding variable for MC is 0          !!!!\n");
+    fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+  } else {
+    fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+    fprintf(stdout,"!!!  MC Seed is %d \n",seed);
+    fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+  }
+  
+// set the seed environment variable
+  gSystem->Setenv("CONFIG_SEED",sseed);
+  gSystem->Setenv("CONFIG_RUN_TYPE",sprocess); // kPythia6 or kPhojet
+  gSystem->Setenv("CONFIG_FIELD",sfield);      // kNoField or k5kG
+  gSystem->Setenv("CONFIG_ENERGY",senergy);    // 900 or 10000 (GeV)
+  gSystem->Setenv("DC_RUN",srun); // Not used in Config.C
+  gSystem->Setenv("DC_EVENT",sevent); // Not used in Config.C
+  
+// Needed to produce simulated RAW data
+  gSystem->Setenv("ALIMDC_RAWDB1","./mdc1");
+  gSystem->Setenv("ALIMDC_RAWDB2","./mdc2");
+  gSystem->Setenv("ALIMDC_TAGDB","./mdc1/tag");
+  gSystem->Setenv("ALIMDC_RUNDB","./mdc1/meta");
+  cout<< "SIMRUN:: Run " << gSystem->Getenv("DC_RUN") << " Event " << gSystem->Getenv("DC_EVENT")
+         << " Generator "    << gSystem->Getenv("CONFIG_RUN_TYPE")
+         << " Field " << gSystem->Getenv("CONFIG_FIELD")
+         << " Energy " << gSystem->Getenv("CONFIG_ENERGY")
+         << endl;
+
+  cout<<">>>>> SIMULATION <<<<<"<<endl;
+  gSystem->Exec("aliroot -b -q sim.C > sim.log 2>&1");
+  cout<<">>>>> RECONSTRUCTION <<<<<"<<endl;
+  gSystem->Exec("aliroot -b -q rec.C > rec.log 2>&1");
+  cout<<">>>>> TAG <<<<<"<<endl;
+  gSystem->Exec("aliroot -b -q tag.C > tag.log 2>&1");
+  cout<<">>>>> CHECK ESD <<<<<"<<endl;
+  gSystem->Exec("aliroot -b -q CheckESD.C > check.log 2>&1");
+  cout<<">>>>> AOD <<<<<"<<endl;
+  gSystem->Exec("aliroot -b -q CreateAODfromESD.C > aod.log 2>&1");
+
+}
diff --git a/prod/LHC09c1/tag.C b/prod/LHC09c1/tag.C
new file mode 100644 (file)
index 0000000..668d95a
--- /dev/null
@@ -0,0 +1,108 @@
+void tag() {
+  const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
+  TString fESDFileName = "alien://";
+  fESDFileName += turl;
+  fESDFileName += "/AliESDs.root";
+
+  TString fGUID = 0;
+  GetGUID(fGUID);
+
+  TString fAliroot, fRoot, fGeant;
+  GetVersions(fAliroot,fRoot,fGeant);
+
+  UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID);
+}
+
+//_____________________________________//
+GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
+  const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
+  TString fS = fver;
+  Int_t fFirst = fS.First("#");
+
+  while(fFirst != -1) {
+    Int_t fTotalLength = fS.Length();
+    TString tmp = fS;
+    TString fS1 = fS(0,fFirst);
+    tmp = fS(fFirst+2,fTotalLength);
+    fS = tmp;
+
+    if(fS1.Contains("Root")) fAliroot = fS1;
+    if(fS1.Contains("ROOT")) froot = fS1;
+    if(fS1.Contains("GEANT")) fgeant = fS1;
+
+    if(tmp.Contains("Root")) fAliroot = tmp;
+    if(tmp.Contains("ROOT")) froot = tmp;
+    if(tmp.Contains("GEANT")) fgeant = tmp;
+
+    fFirst = tmp.First("#");
+  }
+}
+
+//_____________________________________//
+GetGUID(TString &guid) {
+  ofstream myfile ("guid.txt");
+  if (myfile.is_open()) {
+    TFile *f = TFile::Open("AliESDs.root","read");
+    if(f->IsOpen()) {
+      guid = f->GetUUID().AsString();
+      myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
+      cout<<guid.Data()<<endl;
+      myfile.close();
+    }
+    else cout<<"Input file not found"<<endl;
+  }
+  else cout<<"Output file can't be created..."<<endl;
+}
+
+
+//_____________________________________//
+Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {
+  cout<<"Updating tags....."<<endl;
+
+  const char * tagPattern = "tag.root";
+  // Open the working directory
+  void * dirp = gSystem->OpenDirectory(gSystem->pwd());
+  const char * name = 0x0;
+  // Add all files matching *pattern* to the chain
+  while((name = gSystem->GetDirEntry(dirp))) {
+    if (strstr(name,tagPattern)) {
+      TFile *f = TFile::Open(name,"read") ;
+
+      AliRunTag *tag = new AliRunTag;
+      AliEventTag *evTag = new AliEventTag;
+      TTree *fTree = (TTree *)f->Get("T");
+      fTree->SetBranchAddress("AliTAG",&tag);
+
+      //Defining new tag objects
+      AliRunTag *newTag = new AliRunTag();
+      TTree ttag("T","A Tree with event tags");
+      TBranch * btag = ttag.Branch("AliTAG", &newTag);
+      btag->SetCompressionLevel(9);
+      for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {
+       fTree->GetEntry(iTagFiles);
+       newTag->SetRunId(tag->GetRunId());
+       newTag->SetAlirootVersion(faliroot);
+       newTag->SetRootVersion(froot);
+       newTag->SetGeant3Version(fgeant);
+       const TClonesArray *tagList = tag->GetEventTags();
+       for(Int_t j = 0; j < tagList->GetEntries(); j++) {
+         evTag = (AliEventTag *) tagList->At(j);
+         evTag->SetTURL(turl);
+         evTag->SetGUID(guid);
+         newTag->AddEventTag(*evTag);
+       }
+       ttag.Fill();
+       newTag->Clear();
+      }//tag file loop
+
+      TFile* ftag = TFile::Open(name, "recreate");
+      ftag->cd();
+      ttag.Write();
+      ftag->Close();
+
+      delete tag;
+      delete newTag;
+    }//pattern check
+  }//directory loop
+  return kTRUE;
+}