more macros
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Apr 2008 13:04:06 +0000 (13:04 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Apr 2008 13:04:06 +0000 (13:04 +0000)
test/QA/CheckESD.C [new file with mode: 0644]
test/QA/DB.tgz [new file with mode: 0644]
test/QA/recqa.C
test/QA/rootlogon.C [new file with mode: 0644]
test/QA/simrun.C [new file with mode: 0644]
test/QA/simrun.sh [new file with mode: 0755]
test/QA/tag.C [new file with mode: 0644]

diff --git a/test/QA/CheckESD.C b/test/QA/CheckESD.C
new file mode 100644 (file)
index 0000000..fe50acc
--- /dev/null
@@ -0,0 +1,699 @@
+#if !defined( __CINT__) || defined(__MAKECINT__)\r
+#include <TFile.h>\r
+#include <TError.h>\r
+#include <TH1.h>\r
+#include <TH2.h>\r
+#include <TF1.h>\r
+#include <TCanvas.h>\r
+#include <TVector3.h>\r
+#include <TPDGCode.h>\r
+#include <TParticle.h>\r
+\r
+#include "AliRunLoader.h"\r
+#include "AliLoader.h"\r
+#include "AliESDEvent.h"\r
+#include "AliRun.h"\r
+#include "AliStack.h"\r
+#include "AliHeader.h"\r
+#include "AliGenEventHeader.h"\r
+#include "AliPID.h"\r
+#else\r
+const Int_t kXiMinus = 3312;\r
+const Int_t kOmegaMinus = 3334;\r
+#endif\r
+\r
+\r
+TH1F* CreateHisto(const char* name, const char* title, \r
+                 Int_t nBins, Double_t xMin, Double_t xMax,\r
+                 const char* xLabel = NULL, const char* yLabel = NULL)\r
+{\r
+// create a histogram\r
+\r
+  TH1F* result = new TH1F(name, title, nBins, xMin, xMax);\r
+  result->SetOption("E");\r
+  if (xLabel) result->GetXaxis()->SetTitle(xLabel);\r
+  if (yLabel) result->GetYaxis()->SetTitle(yLabel);\r
+  result->SetMarkerStyle(kFullCircle);\r
+  return result;\r
+}\r
+\r
+TH1F* CreateEffHisto(TH1F* hGen, TH1F* hRec)\r
+{\r
+// create an efficiency histogram\r
+\r
+  Int_t nBins = hGen->GetNbinsX();\r
+  TH1F* hEff = (TH1F*) hGen->Clone("hEff");\r
+  hEff->SetTitle("");\r
+  hEff->SetStats(kFALSE);\r
+  hEff->SetMinimum(0.);\r
+  hEff->SetMaximum(110.);\r
+  hEff->GetYaxis()->SetTitle("#epsilon [%]");\r
+\r
+  for (Int_t iBin = 0; iBin <= nBins; iBin++) {\r
+    Double_t nGen = hGen->GetBinContent(iBin);\r
+    Double_t nRec = hRec->GetBinContent(iBin);\r
+    if (nGen > 0) {\r
+      Double_t eff = nRec/nGen;\r
+      hEff->SetBinContent(iBin, 100. * eff);\r
+      Double_t error = sqrt(eff*(1.-eff) / nGen);\r
+      if (error == 0) error = 0.0001;\r
+      hEff->SetBinError(iBin, 100. * error);\r
+    } else {\r
+      hEff->SetBinContent(iBin, -100.);\r
+      hEff->SetBinError(iBin, 0);\r
+    }\r
+  }\r
+\r
+  return hEff;\r
+}\r
+\r
+Bool_t FitHisto(TH1* histo, Double_t& res, Double_t& resError)\r
+{\r
+// fit a gaussian to a histogram\r
+\r
+  static TF1* fitFunc = new TF1("fitFunc", "gaus");\r
+  fitFunc->SetLineWidth(2);\r
+  fitFunc->SetFillStyle(0);\r
+  Double_t maxFitRange = 2;\r
+\r
+  if (histo->Integral() > 50) {\r
+    Float_t mean = histo->GetMean();\r
+    Float_t rms = histo->GetRMS();\r
+    fitFunc->SetRange(mean - maxFitRange*rms, mean + maxFitRange*rms);\r
+    fitFunc->SetParameters(mean, rms);\r
+    histo->Fit(fitFunc, "QRI0");\r
+    histo->GetFunction("fitFunc")->ResetBit(1<<9);\r
+    res = TMath::Abs(fitFunc->GetParameter(2));\r
+    resError = TMath::Abs(fitFunc->GetParError(2));\r
+    return kTRUE;\r
+  }\r
+\r
+  return kFALSE;\r
+}\r
+\r
+\r
+Bool_t CheckESD(const char* gAliceFileName = "galice.root", \r
+               const char* esdFileName = "AliESDs.root")\r
+{\r
+// check the content of the ESD\r
\r
+  // check values\r
+  Int_t    checkNGenLow = 1;\r
+\r
+  Double_t checkEffLow = 0.5;\r
+  Double_t checkEffSigma = 3;\r
+  Double_t checkFakeHigh = 0.5;\r
+  Double_t checkFakeSigma = 3;\r
+\r
+  Double_t checkResPtInvHigh = 5;\r
+  Double_t checkResPtInvSigma = 3;\r
+  Double_t checkResPhiHigh = 10;\r
+  Double_t checkResPhiSigma = 3;\r
+  Double_t checkResThetaHigh = 10;\r
+  Double_t checkResThetaSigma = 3;\r
+\r
+  Double_t checkPIDEffLow = 0.5;\r
+  Double_t checkPIDEffSigma = 3;\r
+  Double_t checkResTOFHigh = 500;\r
+  Double_t checkResTOFSigma = 3;\r
+\r
+  Double_t checkPHOSNLow = 5;\r
+  Double_t checkPHOSEnergyLow = 0.3;\r
+  Double_t checkPHOSEnergyHigh = 1.0;\r
+  Double_t checkEMCALNLow = 50;\r
+  Double_t checkEMCALEnergyLow = 0.05;\r
+  Double_t checkEMCALEnergyHigh = 1.0;\r
+\r
+  Double_t checkMUONNLow = 1;\r
+  Double_t checkMUONPtLow = 0.5;\r
+  Double_t checkMUONPtHigh = 10.;\r
+\r
+  Double_t cutPtV0 = 0.3;\r
+  Double_t checkV0EffLow = 0.02;\r
+  Double_t checkV0EffSigma = 3;\r
+  Double_t cutPtCascade = 0.5;\r
+  Double_t checkCascadeEffLow = 0.01;\r
+  Double_t checkCascadeEffSigma = 3;\r
+\r
+  // open run loader and load gAlice, kinematics and header\r
+  AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);\r
+  if (!runLoader) {\r
+    Error("CheckESD", "getting run loader from file %s failed", \r
+           gAliceFileName);\r
+    return kFALSE;\r
+  }\r
+  runLoader->LoadgAlice();\r
+  gAlice = runLoader->GetAliRun();\r
+  if (!gAlice) {\r
+    Error("CheckESD", "no galice object found");\r
+    return kFALSE;\r
+  }\r
+  runLoader->LoadKinematics();\r
+  runLoader->LoadHeader();\r
+\r
+  // open the ESD file\r
+  TFile* esdFile = TFile::Open(esdFileName);\r
+  if (!esdFile || !esdFile->IsOpen()) {\r
+    Error("CheckESD", "opening ESD file %s failed", esdFileName);\r
+    return kFALSE;\r
+  }\r
+  AliESDEvent* esd = new AliESDEvent;\r
+  TTree* tree = (TTree*) esdFile->Get("esdTree");\r
+  if (!tree) {\r
+    Error("CheckESD", "no ESD tree found");\r
+    return kFALSE;\r
+  }\r
+  esd->ReadFromTree(tree);\r
+\r
+  // efficiency and resolution histograms\r
+  Int_t nBinsPt = 15;\r
+  Float_t minPt = 0.1;\r
+  Float_t maxPt = 3.1;\r
+  TH1F* hGen = CreateHisto("hGen", "generated tracks", \r
+                          nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");\r
+  TH1F* hRec = CreateHisto("hRec", "reconstructed tracks", \r
+                          nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");\r
+  Int_t nGen = 0;\r
+  Int_t nRec = 0;\r
+  Int_t nFake = 0;\r
+\r
+  TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10, \r
+           "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N");\r
+  TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20, \r
+                             "#phi_{rec}-#phi_{sim} [mrad]", "N");\r
+  TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20, \r
+                               "#theta_{rec}-#theta_{sim} [mrad]", "N");\r
+\r
+  // PID\r
+  Int_t partCode[] = \r
+    {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};\r
+  const char* partName[] = \r
+    {"electron", "muon", "pion", "kaon", "proton", "other"};\r
+  Double_t partFrac[] = \r
+    {0.01, 0.01, 0.85, 0.10, 0.05};\r
+  Int_t identified[6][5];\r
+  for (Int_t iGen = 0; iGen < 6; iGen++) {\r
+    for (Int_t iRec = 0; iRec < 5; iRec++) {\r
+      identified[iGen][iRec] = 0;\r
+    }\r
+  }\r
+  Int_t nIdentified = 0;\r
+\r
+  // dE/dx and TOF\r
+  TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400);\r
+  hDEdxRight->SetStats(kFALSE);\r
+  hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]");\r
+  hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}");\r
+  hDEdxRight->SetMarkerStyle(kFullCircle);\r
+  hDEdxRight->SetMarkerSize(0.4);\r
+  TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400);\r
+  hDEdxWrong->SetStats(kFALSE);\r
+  hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]");\r
+  hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}");\r
+  hDEdxWrong->SetMarkerStyle(kFullCircle);\r
+  hDEdxWrong->SetMarkerSize(0.4);\r
+  hDEdxWrong->SetMarkerColor(kRed);\r
+  TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000, \r
+                                  "t_{TOF}-t_{track} [ps]", "N");\r
+  TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000, \r
+                                  "t_{TOF}-t_{track} [ps]", "N");\r
+  hResTOFWrong->SetLineColor(kRed);\r
+\r
+  // calorimeters\r
+  TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 5, "E [GeV]", "N");\r
+  TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N");\r
+\r
+  // muons\r
+  TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20, \r
+                             "p_{t} [GeV/c]", "N");\r
+\r
+  // V0s and cascades\r
+  TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6, \r
+                             "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N");\r
+  TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2, \r
+                                 "M(p#pi^{-}) [GeV/c^{2}]", "N");\r
+  TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}", \r
+                                    100, 1.0, 1.2, \r
+                                    "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N");\r
+  Int_t nGenV0s = 0;\r
+  Int_t nRecV0s = 0;\r
+  TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5, \r
+                             "M(#Lambda#pi) [GeV/c^{2}]", "N");\r
+  TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8, \r
+                                "M(#LambdaK) [GeV/c^{2}]", "N");\r
+  Int_t nGenCascades = 0;\r
+  Int_t nRecCascades = 0;\r
+\r
+  // loop over events\r
+  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {\r
+    runLoader->GetEvent(iEvent);\r
+\r
+    // select simulated primary particles, V0s and cascades\r
+    AliStack* stack = gAlice->Stack();\r
+    Int_t nParticles = stack->GetNtrack();\r
+    TArrayF vertex(3);\r
+    runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex);\r
+    TObjArray selParticles;\r
+    TObjArray selV0s;\r
+    TObjArray selCascades;\r
+    for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {\r
+      TParticle* particle = stack->Particle(iParticle);\r
+      if (!particle) continue;\r
+      if (particle->Pt() < 0.001) continue;\r
+      if (TMath::Abs(particle->Eta()) > 0.9) continue;\r
+      TVector3 dVertex(particle->Vx() - vertex[0], \r
+                      particle->Vy() - vertex[1],\r
+                      particle->Vz() - vertex[2]);\r
+      if (dVertex.Mag() > 0.0001) continue;\r
+\r
+      switch (TMath::Abs(particle->GetPdgCode())) {\r
+      case kElectron:\r
+      case kMuonMinus:\r
+      case kPiPlus:\r
+      case kKPlus:\r
+      case kProton: {\r
+       if (particle->Pt() > minPt) {\r
+         selParticles.Add(particle);\r
+         nGen++;\r
+         hGen->Fill(particle->Pt());\r
+       }\r
+       break;\r
+      }\r
+      case kK0Short:\r
+      case kLambda0: {\r
+       if (particle->Pt() > cutPtV0) {\r
+         nGenV0s++;\r
+         selV0s.Add(particle);\r
+       }\r
+       break;\r
+      }\r
+      case kXiMinus:\r
+      case kOmegaMinus: {\r
+       if (particle->Pt() > cutPtCascade) {\r
+         nGenCascades++;\r
+         selCascades.Add(particle);\r
+       }\r
+       break;\r
+      }\r
+      default: break;\r
+      }\r
+    }\r
+\r
+    // get the event summary data\r
+    tree->GetEvent(iEvent);\r
+    if (!esd) {\r
+      Error("CheckESD", "no ESD object found for event %d", iEvent);\r
+      return kFALSE;\r
+    }\r
+\r
+    // loop over tracks\r
+    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {\r
+      AliESDtrack* track = esd->GetTrack(iTrack);\r
+\r
+      // select tracks of selected particles\r
+      Int_t label = TMath::Abs(track->GetLabel());\r
+      if (label > stack->GetNtrack()) continue;     // background\r
+      TParticle* particle = stack->Particle(label);\r
+      if (!selParticles.Contains(particle)) continue;\r
+      if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;\r
+      if (track->GetConstrainedChi2() > 1e9) continue;\r
+      selParticles.Remove(particle);   // don't count multiple tracks\r
+\r
+      nRec++;\r
+      hRec->Fill(particle->Pt());\r
+      if (track->GetLabel() < 0) nFake++;\r
+\r
+      // resolutions\r
+      Double_t p[3];\r
+      track->GetConstrainedPxPyPz(p);\r
+      TVector3 pTrack(p);\r
+      hResPtInv->Fill(100. * (1./pTrack.Pt() - 1./particle->Pt()) * \r
+                     particle->Pt());\r
+      hResPhi->Fill(1000. * (pTrack.Phi() - particle->Phi()));\r
+      hResTheta->Fill(1000. * (pTrack.Theta() - particle->Theta()));\r
+\r
+      // PID\r
+      if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue;\r
+      Int_t iGen = 5;\r
+      for (Int_t i = 0; i < 5; i++) {\r
+       if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i;\r
+      }\r
+      Double_t probability[5];\r
+      track->GetESDpid(probability);\r
+      Double_t pMax = 0;\r
+      Int_t iRec = 0;\r
+      for (Int_t i = 0; i < 5; i++) {\r
+       probability[i] *= partFrac[i];\r
+       if (probability[i] > pMax) {\r
+         pMax = probability[i];\r
+         iRec = i;\r
+       }\r
+      }\r
+      identified[iGen][iRec]++;\r
+      if (iGen == iRec) nIdentified++;\r
+\r
+      // dE/dx and TOF\r
+      Double_t time[5];\r
+      track->GetIntegratedTimes(time);\r
+      if (iGen == iRec) {\r
+       hDEdxRight->Fill(pTrack.Mag(), track->GetTPCsignal());\r
+        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {\r
+         hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]);\r
+       }\r
+      } else {\r
+       hDEdxWrong->Fill(pTrack.Mag(), track->GetTPCsignal());\r
+        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {\r
+         hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]);\r
+       }\r
+      }\r
+    }\r
+\r
+    // loop over muon tracks\r
+    {\r
+    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) {\r
+      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);\r
+      Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum());\r
+      if (ptInv > 0.001) {\r
+       hPtMUON->Fill(1./ptInv);\r
+      }\r
+    }\r
+    }\r
+\r
+    // loop over V0s\r
+    for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {\r
+      AliESDv0* v0 = esd->GetV0(iV0);\r
+      if (v0->GetOnFlyStatus()) continue;\r
+      v0->ChangeMassHypothesis(kK0Short);\r
+      hMassK0->Fill(v0->GetEffMass());\r
+      v0->ChangeMassHypothesis(kLambda0);\r
+      hMassLambda->Fill(v0->GetEffMass());\r
+      v0->ChangeMassHypothesis(kLambda0Bar);\r
+      hMassLambdaBar->Fill(v0->GetEffMass());\r
+\r
+      Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel());\r
+      if (negLabel > stack->GetNtrack()) continue;     // background\r
+      Int_t negMother = stack->Particle(negLabel)->GetMother(0);\r
+      if (negMother < 0) continue;\r
+      Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel());\r
+      if (posLabel > stack->GetNtrack()) continue;     // background\r
+      Int_t posMother = stack->Particle(posLabel)->GetMother(0);\r
+      if (negMother != posMother) continue;\r
+      TParticle* particle = stack->Particle(negMother);\r
+      if (!selV0s.Contains(particle)) continue;\r
+      selV0s.Remove(particle);\r
+      nRecV0s++;\r
+    }\r
+\r
+    // loop over Cascades\r
+    for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades(); \r
+        iCascade++) {\r
+      AliESDcascade* cascade = esd->GetCascade(iCascade);\r
+      Double_t v0q;\r
+      cascade->ChangeMassHypothesis(v0q,kXiMinus);\r
+      hMassXi->Fill(cascade->GetEffMass());\r
+      cascade->ChangeMassHypothesis(v0q,kOmegaMinus);\r
+      hMassOmega->Fill(cascade->GetEffMass());\r
+\r
+      Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex())\r
+                                 ->GetLabel());\r
+      if (negLabel > stack->GetNtrack()) continue;     // background\r
+      Int_t negMother = stack->Particle(negLabel)->GetMother(0);\r
+      if (negMother < 0) continue;\r
+      Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex())\r
+                                 ->GetLabel());\r
+      if (posLabel > stack->GetNtrack()) continue;     // background\r
+      Int_t posMother = stack->Particle(posLabel)->GetMother(0);\r
+      if (negMother != posMother) continue;\r
+      Int_t v0Mother = stack->Particle(negMother)->GetMother(0);\r
+      if (v0Mother < 0) continue;\r
+      Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex())\r
+                                 ->GetLabel());\r
+      if (bacLabel > stack->GetNtrack()) continue;     // background\r
+      Int_t bacMother = stack->Particle(bacLabel)->GetMother(0);\r
+      if (v0Mother != bacMother) continue;\r
+      TParticle* particle = stack->Particle(v0Mother);\r
+      if (!selCascades.Contains(particle)) continue;\r
+      selCascades.Remove(particle);\r
+      nRecCascades++;\r
+    }\r
+\r
+    // loop over the calorimeters clusters\r
+    {\r
+    Int_t nCaloCluster  = esd->GetNumberOfCaloClusters();\r
+    cout<<"CaloClusters "<<nCaloCluster<<endl;\r
+    for (Int_t iCluster=0; iCluster<nCaloCluster; iCluster++){\r
+      if(esd->GetCaloCluster(iCluster)->IsPHOS()) \r
+       hEPHOS->Fill(esd->GetCaloCluster(iCluster)->E());\r
+      if(esd->GetCaloCluster(iCluster)->GetClusterType()==AliESDCaloCluster::kEMCALClusterv1) {\r
+       hEEMCAL->Fill(esd->GetCaloCluster(iCluster)->E());\r
+       //cout<<esd->GetCaloCluster(iCluster)->E()<<endl;\r
+      }\r
+    }\r
+    }\r
+  }\r
+\r
+  // perform checks\r
+  if (nGen < checkNGenLow) {\r
+    Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen));\r
+  }\r
+\r
+  TH1F* hEff = CreateEffHisto(hGen, hRec);\r
+\r
+  Info("CheckESD", "%d out of %d tracks reconstructed including %d "\r
+        "fake tracks", nRec, nGen, nFake);\r
+  if (nGen > 0) {\r
+    // efficiency\r
+    Double_t eff = nRec*1./nGen;\r
+    Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen);\r
+    Double_t fake = nFake*1./nGen;\r
+    Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen);\r
+    Info("CheckESD", "eff = (%.1f +- %.1f) %%  fake = (%.1f +- %.1f) %%",\r
+        100.*eff, 100.*effError, 100.*fake, 100.*fakeError);\r
+\r
+    if (eff < checkEffLow - checkEffSigma*effError) {\r
+      Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%", \r
+             100.*eff, 100.*effError);\r
+    }\r
+    if (fake > checkFakeHigh + checkFakeSigma*fakeError) {\r
+      Warning("CheckESD", "high fake: (%.1f +- %.1f) %%", \r
+             100.*fake, 100.*fakeError);\r
+    }\r
+\r
+    // resolutions\r
+    Double_t res, resError;\r
+    if (FitHisto(hResPtInv, res, resError)) {\r
+      Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%",\r
+          res, resError);\r
+      if (res > checkResPtInvHigh + checkResPtInvSigma*resError) {\r
+       Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%", \r
+               res, resError);\r
+      }\r
+    }\r
+\r
+    if (FitHisto(hResPhi, res, resError)) {\r
+      Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError);\r
+      if (res > checkResPhiHigh + checkResPhiSigma*resError) {\r
+       Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad", \r
+               res, resError);\r
+      }\r
+    }\r
+\r
+    if (FitHisto(hResTheta, res, resError)) {\r
+      Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad", \r
+          res, resError);\r
+      if (res > checkResThetaHigh + checkResThetaSigma*resError) {\r
+       Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad", \r
+               res, resError);\r
+      }\r
+    }\r
+\r
+    // PID\r
+    if (nRec > 0) {\r
+      Double_t eff = nIdentified*1./nRec;\r
+      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec);\r
+      Info("CheckESD", "PID eff = (%.1f +- %.1f) %%", \r
+          100.*eff, 100.*effError);\r
+      if (eff < checkPIDEffLow - checkPIDEffSigma*effError) {\r
+       Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%", \r
+               100.*eff, 100.*effError);\r
+      }\r
+    }\r
+\r
+    printf("%9s:", "gen\\rec");\r
+    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {\r
+      printf("%9s", partName[iRec]);\r
+    }\r
+    printf("\n");\r
+    for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {\r
+      printf("%9s:", partName[iGen]);\r
+      for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {\r
+       printf("%9d", identified[iGen][iRec]);\r
+      }\r
+      printf("\n");\r
+    }\r
+\r
+    if (FitHisto(hResTOFRight, res, resError)) {\r
+      Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError);\r
+      if (res > checkResTOFHigh + checkResTOFSigma*resError) {\r
+       Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps", \r
+               res, resError);\r
+      }\r
+    }\r
+\r
+    // calorimeters\r
+    if (hEPHOS->Integral() < checkPHOSNLow) {\r
+      Warning("CheckESD", "low number of PHOS particles: %d", \r
+             Int_t(hEPHOS->Integral()));\r
+    } else {\r
+      Double_t mean = hEPHOS->GetMean();\r
+      if (mean < checkPHOSEnergyLow) {\r
+       Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean);\r
+      } else if (mean > checkPHOSEnergyHigh) {\r
+       Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean);\r
+      }\r
+    }\r
+\r
+    if (hEEMCAL->Integral() < checkEMCALNLow) {\r
+      Warning("CheckESD", "low number of EMCAL particles: %d", \r
+             Int_t(hEEMCAL->Integral()));\r
+    } else {\r
+      Double_t mean = hEEMCAL->GetMean();\r
+      if (mean < checkEMCALEnergyLow) {\r
+       Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean);\r
+      } else if (mean > checkEMCALEnergyHigh) {\r
+       Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean);\r
+      }\r
+    }\r
+\r
+    // muons\r
+    if (hPtMUON->Integral() < checkMUONNLow) {\r
+      Warning("CheckESD", "low number of MUON particles: %d", \r
+             Int_t(hPtMUON->Integral()));\r
+    } else {\r
+      Double_t mean = hPtMUON->GetMean();\r
+      if (mean < checkMUONPtLow) {\r
+       Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean);\r
+      } else if (mean > checkMUONPtHigh) {\r
+       Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean);\r
+      }\r
+    }\r
+\r
+    // V0s\r
+    if (nGenV0s > 0) {\r
+      Double_t eff = nRecV0s*1./nGenV0s;\r
+      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s);\r
+      if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s);\r
+      Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%", \r
+          100.*eff, 100.*effError);\r
+      if (eff < checkV0EffLow - checkV0EffSigma*effError) {\r
+       Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%", \r
+               100.*eff, 100.*effError);\r
+      }\r
+    }\r
+\r
+    // Cascades\r
+    if (nGenCascades > 0) {\r
+      Double_t eff = nRecCascades*1./nGenCascades;\r
+      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades);\r
+      if (effError == 0) effError = checkV0EffLow / \r
+                          TMath::Sqrt(1.*nGenCascades);\r
+      Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%", \r
+          100.*eff, 100.*effError);\r
+      if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) {\r
+       Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%", \r
+               100.*eff, 100.*effError);\r
+      }\r
+    }\r
+  }\r
+\r
+  // draw the histograms if not in batch mode\r
+  if (!gROOT->IsBatch()) {\r
+    new TCanvas;\r
+    hEff->DrawCopy();\r
+    new TCanvas;\r
+    hResPtInv->DrawCopy("E");\r
+    new TCanvas;\r
+    hResPhi->DrawCopy("E");\r
+    new TCanvas;\r
+    hResTheta->DrawCopy("E");\r
+    new TCanvas;\r
+    hDEdxRight->DrawCopy();\r
+    hDEdxWrong->DrawCopy("SAME");\r
+    new TCanvas;\r
+    hResTOFRight->DrawCopy("E");\r
+    hResTOFWrong->DrawCopy("SAME");\r
+    new TCanvas;\r
+    hEPHOS->DrawCopy("E");\r
+    new TCanvas;\r
+    hEEMCAL->DrawCopy("E");\r
+    new TCanvas;\r
+    hPtMUON->DrawCopy("E");\r
+    new TCanvas;\r
+    hMassK0->DrawCopy("E");\r
+    new TCanvas;\r
+    hMassLambda->DrawCopy("E");\r
+    new TCanvas;\r
+    hMassLambdaBar->DrawCopy("E");\r
+    new TCanvas;\r
+    hMassXi->DrawCopy("E");\r
+    new TCanvas;\r
+    hMassOmega->DrawCopy("E");\r
+  }\r
+\r
+  // write the output histograms to a file\r
+  TFile* outputFile = TFile::Open("check.root", "recreate");\r
+  if (!outputFile || !outputFile->IsOpen()) {\r
+    Error("CheckESD", "opening output file check.root failed");\r
+    return kFALSE;\r
+  }\r
+  hEff->Write();\r
+  hResPtInv->Write();\r
+  hResPhi->Write();\r
+  hResTheta->Write();\r
+  hDEdxRight->Write();\r
+  hDEdxWrong->Write();\r
+  hResTOFRight->Write();\r
+  hResTOFWrong->Write();\r
+  hEPHOS->Write();\r
+  hEEMCAL->Write();\r
+  hPtMUON->Write();\r
+  hMassK0->Write();\r
+  hMassLambda->Write();\r
+  hMassLambdaBar->Write();\r
+  hMassXi->Write();\r
+  hMassOmega->Write();\r
+  outputFile->Close();\r
+  delete outputFile;\r
+\r
+  // clean up\r
+  delete hGen;\r
+  delete hRec;\r
+  delete hEff;\r
+  delete hResPtInv;\r
+  delete hResPhi;\r
+  delete hResTheta;\r
+  delete hDEdxRight;\r
+  delete hDEdxWrong;\r
+  delete hResTOFRight;\r
+  delete hResTOFWrong;\r
+  delete hEPHOS;\r
+  delete hEEMCAL;\r
+  delete hPtMUON;\r
+  delete hMassK0;\r
+  delete hMassLambda;\r
+  delete hMassLambdaBar;\r
+  delete hMassXi;\r
+  delete hMassOmega;\r
+\r
+  delete esd;\r
+  esdFile->Close();\r
+  delete esdFile;\r
+\r
+  runLoader->UnloadHeader();\r
+  runLoader->UnloadKinematics();\r
+  delete runLoader;\r
+\r
+  // result of check\r
+  Info("CheckESD", "check of ESD was successfull");\r
+  return kTRUE;\r
+}\r
diff --git a/test/QA/DB.tgz b/test/QA/DB.tgz
new file mode 100644 (file)
index 0000000..9dd31d4
Binary files /dev/null and b/test/QA/DB.tgz differ
index b387f64..731326c 100644 (file)
@@ -5,8 +5,7 @@ void recqa()
   AliCDBManager * man = AliCDBManager::Instance();
   //man->SetDefaultStorage("alien://Folder=/alice/simulation/2007/PDC07_v4-09-Rev-00/Ideal/CDB/");
   man->SetDefaultStorage("local://$ALICE_ROOT");
-  //TString detectors("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD ZDC PMD T0 VZERO");
-  TString detectors("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD PMD T0 VZERO");
+  TString detectors("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD ZDC PMD T0 VZERO");
   AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), kYear)) ;
   AliQA::SetQARefDataDirName("Sim") ; //Data, Pedestals, BlackEvent, .....
    
diff --git a/test/QA/rootlogon.C b/test/QA/rootlogon.C
new file mode 100644 (file)
index 0000000..fae9b46
--- /dev/null
@@ -0,0 +1,12 @@
+{
+  printf("\nWELCOME to ALICE QA\n\n"); 
+  gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/TRD -I$ALICE_ROOT/RAW") ; 
+  //load library neccesary for TPC alone 
+//  gSystem->Load("$(ROOTSYS)/lib/libEG");
+//  gSystem->Load("$(ROOTSYS)/lib/libGeom");  
+//  gSystem->Load("$(ROOTSYS)/lib/libVMC");
+  //gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libTRACKING");
+  
+  
+}
+
diff --git a/test/QA/simrun.C b/test/QA/simrun.C
new file mode 100644 (file)
index 0000000..6ad7853
--- /dev/null
@@ -0,0 +1,111 @@
+//#define VERBOSEARGS
+
+{
+  // set job and simulation variables as :
+  // root run.C  --run <x> --event <y> --process <proc> --minhard <min> --maxhard <max> --minpt <minpt>
+  
+  int nrun = 0;
+  int nevent = 0;
+  int seed = 0;
+  
+  char sseed[1024];
+  char srun[1024];
+  char sevent[1024];
+  char sprocess[1024];
+  char sminpthard[1024];
+  char smaxpthard[1024];
+  char sminptgammapi0[1024];
+  char squench[1024];
+  char sqhat[1024];
+
+  sprintf(srun,"");
+  sprintf(sevent,"");
+  sprintf(sprocess,"");
+  sprintf(sminpthard,"");
+  sprintf(smaxpthard,"");
+  sprintf(sminptgammapi0,"");
+  sprintf(squench,"");
+  sprintf(sqhat,"");
+
+  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),"--minhard")))
+      sprintf(sminpthard,gApplication->Argv(i+1));
+    
+    if (!(strcmp(gApplication->Argv(i),"--maxhard")))
+      sprintf(smaxpthard,gApplication->Argv(i+1));
+    
+    if (!(strcmp(gApplication->Argv(i),"--minpt")))
+      sprintf(sminptgammapi0,gApplication->Argv(i+1));
+
+    if (!(strcmp(gApplication->Argv(i),"--quench")))
+      sprintf(squench,gApplication->Argv(i+1));
+
+    if (!(strcmp(gApplication->Argv(i),"--qhat")))
+      sprintf(sqhat,gApplication->Argv(i+1));
+
+  }
+  char cmd[200] ; 
+  sprintf(cmd, ".! tar zxvf DB.tgz") ; 
+  gROOT->ProcessLine(cmd) ; 
+  
+  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("DC_RUN",srun);
+  gSystem->Setenv("DC_EVENT",sevent);
+  gSystem->Setenv("DC_RUN_TYPE",sprocess);//"kPyGammaJetPHOS");
+  gSystem->Setenv("PTHARDMIN",sminpthard);//"20");
+  gSystem->Setenv("PTHARDMAX",smaxpthard);//"30");
+
+  gSystem->Setenv("PTGAMMAPI0MIN",sminptgammapi0);//"1");
+  gSystem->Setenv("QUENCHING",squench);
+  gSystem->Setenv("QHAT",sqhat);
+
+
+  gSystem->Setenv("ECMS","14000");
+  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") 
+         << " Process "    << gSystem->Getenv("DC_RUN_TYPE") 
+         << " minpthard " << gSystem->Getenv("PTHARDMIN") 
+         << " maxpthard " << gSystem->Getenv("PTHARDMAX") 
+         << " minpt "     << gSystem->Getenv("PTGAMMAPI0MIN") 
+         << endl;
+  //gSystem->Exec("cp $ROOTSYS/etc/system.rootrc .rootrc");
+  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");
+
+}
diff --git a/test/QA/simrun.sh b/test/QA/simrun.sh
new file mode 100755 (executable)
index 0000000..f5ac7b1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+cd $WORK/QATest
+rm -f *.root *.C *.log
+ln -si $ALICE_ROOT/test/QA/Config.C Config.C
+aliroot -b -q $ALICE_ROOT/test/QA/sim.C > sim.log 2>&1
+alienroot -b -q $ALICE_ROOT/test/QA/simqa.C > simqa.log 2>&1
+aliroot -b -q $ALICE_ROOT/test/QA/rec.C > rec.log 2>&1
+alienroot -b -q $ALICE_ROOT/test/QA/recqa.C > recqa.log 2>&1
+alienroot -b -q $ALICE_ROOT/test/QA/tag.C > tag.log 2>&1
+cd $WORK/QATest/data
+aliroot -b -q  > rawqa.log 2>&1 << EOF
+.x  $ALICE_ROOT/test/QA/rootlogon.C
+.L $ALICE_ROOT/test/QA/rawqa.C+
+rawqa(21950, 1)
+EOF
+exit
\ No newline at end of file
diff --git a/test/QA/tag.C b/test/QA/tag.C
new file mode 100644 (file)
index 0000000..749a839
--- /dev/null
@@ -0,0 +1,108 @@
+void tag() {\r
+  const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");\r
+  TString fESDFileName = "alien://";\r
+  fESDFileName += turl;\r
+  fESDFileName += "/AliESDs.root";\r
+\r
+  TString fGUID = 0;\r
+  GetGUID(fGUID);\r
+\r
+  TString fAliroot, fRoot, fGeant;\r
+  GetVersions(fAliroot,fRoot,fGeant);\r
+\r
+  UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID);\r
+}\r
+\r
+//_____________________________________//\r
+GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {\r
+  const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");\r
+  TString fS = fver;\r
+  Int_t fFirst = fS.First("#");\r
+\r
+  while(fFirst != -1) {\r
+    Int_t fTotalLength = fS.Length();\r
+    TString tmp = fS;\r
+    TString fS1 = fS(0,fFirst);\r
+    tmp = fS(fFirst+2,fTotalLength);\r
+    fS = tmp;\r
+\r
+    if(fS1.Contains("Root")) fAliroot = fS1;\r
+    if(fS1.Contains("ROOT")) froot = fS1;\r
+    if(fS1.Contains("GEANT")) fgeant = fS1;\r
+\r
+    if(tmp.Contains("Root")) fAliroot = tmp;\r
+    if(tmp.Contains("ROOT")) froot = tmp;\r
+    if(tmp.Contains("GEANT")) fgeant = tmp;\r
+\r
+    fFirst = tmp.First("#");\r
+  }\r
+}\r
+\r
+//_____________________________________//\r
+GetGUID(TString &guid) {\r
+  ofstream myfile ("guid.txt");\r
+  if (myfile.is_open()) {\r
+    TFile *f = TFile::Open("AliESDs.root","read");\r
+    if(f->IsOpen()) {\r
+      guid = f->GetUUID().AsString();\r
+      myfile << "AliESDs.root \t"<<f->GetUUID().AsString();\r
+      cout<<guid.Data()<<endl;\r
+      myfile.close();\r
+    }\r
+    else cout<<"Input file not found"<<endl;\r
+  }\r
+  else cout<<"Output file can't be created..."<<endl;\r
+}\r
+\r
+\r
+//_____________________________________//\r
+Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {\r
+  cout<<"Updating tags....."<<endl;\r
+\r
+  const char * tagPattern = "tag.root";\r
+  // Open the working directory\r
+  void * dirp = gSystem->OpenDirectory(gSystem->pwd());\r
+  const char * name = 0x0;\r
+  // Add all files matching *pattern* to the chain\r
+  while((name = gSystem->GetDirEntry(dirp))) {\r
+    if (strstr(name,tagPattern)) {\r
+      TFile *f = TFile::Open(name,"read") ;\r
+\r
+      AliRunTag *tag = new AliRunTag;\r
+      AliEventTag *evTag = new AliEventTag;\r
+      TTree *fTree = (TTree *)f->Get("T");\r
+      fTree->SetBranchAddress("AliTAG",&tag);\r
+\r
+      //Defining new tag objects\r
+      AliRunTag *newTag = new AliRunTag();\r
+      TTree ttag("T","A Tree with event tags");\r
+      TBranch * btag = ttag.Branch("AliTAG", &newTag);\r
+      btag->SetCompressionLevel(9);\r
+      for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {\r
+       fTree->GetEntry(iTagFiles);\r
+       newTag->SetRunId(tag->GetRunId());\r
+       newTag->SetAlirootVersion(faliroot);\r
+       newTag->SetRootVersion(froot);\r
+       newTag->SetGeant3Version(fgeant);\r
+       const TClonesArray *tagList = tag->GetEventTags();\r
+       for(Int_t j = 0; j < tagList->GetEntries(); j++) {\r
+         evTag = (AliEventTag *) tagList->At(j);\r
+         evTag->SetTURL(turl);\r
+         evTag->SetGUID(guid);\r
+         newTag->AddEventTag(*evTag);\r
+       }\r
+       ttag.Fill();\r
+       newTag->Clear();\r
+      }//tag file loop\r
+\r
+      TFile* ftag = TFile::Open(name, "recreate");\r
+      ftag->cd();\r
+      ttag.Write();\r
+      ftag->Close();\r
+\r
+      delete tag;\r
+      delete newTag;\r
+    }//pattern check\r
+  }//directory loop\r
+  return kTRUE;\r
+}\r