- update TRD on-line tracking QA to use ESDs as primary source for tracklets and...
authorjklein <jklein@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2012 14:42:25 +0000 (14:42 +0000)
committerjklein <jklein@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2012 14:42:25 +0000 (14:42 +0000)
- move macros to be consistent with naming

PWGPP/TRD/AliTRDonlineTrackletFilter.cxx
PWGPP/TRD/AliTRDonlineTrackletQA.cxx
PWGPP/TRD/AliTRDonlineTrackletQA.h
PWGPP/TRD/macros/AddTRDonlineTrackletFilter.C [moved from PWGPP/TRD/macros/AddTRDtrackletFilter.C with 52% similarity]
PWGPP/TRD/macros/AddTRDonlineTrackletQA.C [moved from PWGPP/TRD/macros/AddTRDtrackletQA.C with 51% similarity]

index 5da9656..40aaf88 100644 (file)
@@ -89,9 +89,11 @@ void AliTRDonlineTrackletFilter::CreateOutputObjects()
 
   OpenFile(1); 
   
-  fTrackletTree = new TTree("tracklets", "on-line tracklets");
+  fTrackletTree = new TTree("TRDtrackletfilter", "on-line tracklets");
   fTrackletTree->Branch("tracklets_sim", fTrackletsSim);
   fTrackletTree->Branch("tracklets_raw", fTrackletsRaw);
+
+  PostData(1, fTrackletTree);
 }
 
 Bool_t AliTRDonlineTrackletFilter::Notify()
@@ -101,10 +103,12 @@ Bool_t AliTRDonlineTrackletFilter::Notify()
 
   TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
 
-  AliInfo(Form("Now reading from %s", filename.Data()));
+  AliDebug(1, Form("Now reading from %s", filename.Data()));
 
   if (filename.Contains("AliAOD.root")) 
     filename.ReplaceAll("AliAOD.root", "");
+  else if (filename.Contains("NewAliESDs.root"))
+    filename.ReplaceAll("NewAliESDs.root", "");
   else if (filename.Contains("AliESDs.root"))
     filename.ReplaceAll("AliESDs.root", "");
   else if (filename.Contains("galice.root"))
@@ -117,7 +121,7 @@ Bool_t AliTRDonlineTrackletFilter::Notify()
   fTrackletFile = TFile::Open(Form("%sTRD.Tracklets.root", fPath.Data()));
 
   if (!fTrackletFile) {
-    AliError("No tracklet file");
+    AliError(Form("No tracklet file in %s", fPath.Data()));
     return kFALSE;
   }
 
@@ -158,15 +162,17 @@ void AliTRDonlineTrackletFilter::Exec(const Option_t * /* option */)
     fTrackletTreeRaw->SetBranchAddress("trkl", &trklArray);
     for (Int_t iHCidx = 0; iHCidx < fTrackletTreeRaw->GetEntries(); iHCidx++) {
       fTrackletTreeRaw->GetEntry(iHCidx);
-      for (Int_t iTracklet = 0; iTracklet < trklArray->GetEntries(); iTracklet++) {
-        AliTRDtrackletWord *trklWord = (AliTRDtrackletWord*) ((*trklArray)[iTracklet]);
-       trklWord->SetDetector(hc/2);
-        new ((*fTrackletsRaw)[fTrackletsRaw->GetEntriesFast()]) AliTRDtrackletWord(*trklWord);
+      if (trklArray) {
+       for (Int_t iTracklet = 0; iTracklet < trklArray->GetEntries(); iTracklet++) {
+         AliTRDtrackletWord *trklWord = (AliTRDtrackletWord*) ((*trklArray)[iTracklet]);
+         trklWord->SetDetector(hc/2);
+         new ((*fTrackletsRaw)[fTrackletsRaw->GetEntriesFast()]) AliTRDtrackletWord(*trklWord);
+       }
       }
     }
   }
 
-  AliInfo(Form("%i tracklets", fTrackletsSim->GetEntriesFast()));
+  AliDebug(1, Form("%i tracklets", fTrackletsSim->GetEntriesFast()));
   fTrackletTree->SetBranchAddress("tracklets_sim", &fTrackletsSim);
   fTrackletTree->SetBranchAddress("tracklets_raw", &fTrackletsRaw);
   fTrackletTree->Fill();
@@ -199,7 +205,7 @@ Bool_t AliTRDonlineTrackletFilter::LoadEvent()
   fESD = dynamic_cast<AliESDEvent*> (fInputEvent);
 
   fEvent++;
-  Int_t inew = fEvent / fNEventsPerFile;
+  Int_t inew = fNEventsPerFile > 0 ? fEvent / fNEventsPerFile : 0;
   if ( inew != fFileNumber) {
     fFileNumber++;
 
index 77b42dd..f90c26e 100644 (file)
@@ -12,6 +12,7 @@
 #include "TH2F.h"
 #include "TProfile.h"
 #include "TCanvas.h"
+#include "Math/Factory.h"
 
 #include "AliAnalysisManager.h"
 #include "AliESDEvent.h"
 #include "AliMCEventHandler.h"
 #include "AliLog.h"
 #include "AliESDTrdTrack.h"
-
+#include "AliESDTrdTracklet.h"
 #include "AliTRDtrackletMCM.h"
+#include "AliTRDtrackletWord.h"
+#include "AliTRDtrapConfig.h"
+#include "AliTRDmcmSim.h"
+#include "AliTRDcalibDB.h"
+
 #include "AliVParticle.h"
-#include "AliMCParticle.h" 
+#include "AliMCParticle.h"
 #include "AliTrackReference.h"
 #include "AliMagF.h"
 #include "TGeoGlobalMagField.h"
-#include "AliTRDtrackletWord.h"
 
 #include "AliTRDonlineTrackletQA.h"
 
@@ -43,7 +48,7 @@ AliTRDonlineTrackletQA::AliTRDonlineTrackletQA(const char *name) :
   fOutputAOD(0x0),
   fMCEvent(0x0),
   fTrackletsRaw(0x0),
-  fTrackletsSim(0x0), 
+  fTrackletsSim(0x0),
   fOutputList(0x0),
   fHistYpos(0x0),
   fHistYres(0x0),
@@ -58,14 +63,23 @@ AliTRDonlineTrackletQA::AliTRDonlineTrackletQA(const char *name) :
   fHistdYdYref(0x0),
   fHistYposRaw(0x0),
   fHistdYRaw(0x0),
-  fHistYdYRaw(0x0), 
+  fHistAlphaRaw(0x0),
+  fHistYdYRaw(0x0),
   fHistZrow(0x0),
   fHistZrowRaw(0x0),
   fHistPid(0x0),
   fHistPidRaw(0x0),
+  fHistPidDiff(0x0),
   fHistYdiff(0x0),
   fHistdYdiff(0x0),
   fHistdYdYraw(0x0),
+  fHistFitYres(0x0),
+  fHistFitDyresEven(0x0),
+  fHistFitDyresOdd(0x0),
+  fHistNoMatchSim(0x0),
+  fHistNoMatchRaw(0x0),
+  fHistResY(0x0),
+  fHistResZ(0x0),
   fTreeTracklets(0x0),
   fY(0.),
   fDY(0.),
@@ -77,15 +91,14 @@ AliTRDonlineTrackletQA::AliTRDonlineTrackletQA(const char *name) :
   fMinPt(1.),
   fGeo(new AliTRDgeometry),
   fNevent(0),
-  fTrackletTree(0x0),
-  fTrackletTreeRaw(0x0)
+  fTrackletTree(0x0)
 {
   // ctor
 
   DefineInput(0, TChain::Class());
   DefineInput(1, TTree::Class());
 
-  DefineOutput(0, TTree::Class()); 
+  DefineOutput(0, TTree::Class());
   DefineOutput(1, TList::Class());
 }
 
@@ -113,87 +126,121 @@ void AliTRDonlineTrackletQA::CreateOutputObjects()
 {
   // create output objects
 
-  OpenFile(1); 
-  
+  OpenFile(1);
+
   fOutputList = new TList();
+  fOutputList->SetOwner(kTRUE);
 
-  fHistYpos        = new TH1F("ypos", 
-                             "Tracklet (sim) y-position;y (cm);count", 
+  fHistYpos        = new TH1F("ypos",
+                             "Tracklet (sim) y-position;y (cm);count",
+                             8192/32, -4096*160e-4, 4095*160e-4);
+  fHistYposRaw     = new TH1F("ypos_raw",
+                             "Tracklet (raw) y-position;y (cm);count",
                              8192/32, -4096*160e-4, 4095*160e-4);
-  fHistYposRaw     = new TH1F("ypos-raw", 
-                             "Tracklet (raw) y-position;y (cm);count", 
-                             130, -65, 65);
-  fHistYres        = new TH1F("yres", 
-                             "Tracklet (sim) #Deltay;y_{tracklet}-y_{MC} (cm);count", 
+  fHistYres        = new TH1F("yres",
+                             "Tracklet (sim) #Deltay;y_{tracklet}-y_{MC} (cm);count",
                              8192/32, -4096/32*160e-4, 4095/32*160e-4);
-  fHistYresDy      = new TH2F("yresdy", 
-                             "Tracklet (sim) #Deltay;y_{tracklet}-y_{MC} (cm);deflection (bin)", 
+  fHistYresDy      = new TH2F("yresdy",
+                             "Tracklet (sim) #Deltay;y_{tracklet}-y_{MC} (cm);deflection (bin)",
                              8192/32, -4096/32*160e-4, 4095/32*160e-4,
                              128, -64.5, 63.5);
-  fHistYresESD     = new TH1F("yresesd", 
-                             "Tracklet #Deltay;y (cm);count", 
+  fHistYresESD     = new TH1F("yresesd",
+                             "Tracklet #Deltay;y (cm);count",
                              100, -10, 10);
-  fHistYdiff       = new TH1F("ydiff", 
-                             "Tracklet #Deltay (sim - raw);y_{sim}-y_{raw} (cm);count", 
-                             8192/32, -4096/32*160e-4, 4095/32*160e-4);
+  fHistYdiff       = new TH1F("ydiff",
+                             "Tracklet #Deltay (sim - raw);y_{sim}-y_{raw} (160 #mum);count",
+                             200, -100, 100);
   for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
-    fHistYlocal[iLayer] = new TH2F(Form("ylocal_%i", iLayer), 
+    fHistYlocal[iLayer] = new TH2F(Form("ylocal_%i", iLayer),
                                   Form("Tracklet local y, layer %i;y_{MC} (pad width);y_{trkl} (pad width)", iLayer),
                                   100, -1, 1, 100, -1, 1);
   }
 
-  fHistdY          = new TH1F("dy", 
-                             "deflection (sim);dy (140 #mum)", 
+  fHistdY          = new TH1F("dy",
+                             "deflection (sim);dy (140 #mum)",
                              128, -64.5, 63.5);
-  fHistdYRaw       = new TH1F("dy-raw", 
-                             "deflection (sim);dy (140 #mum)", 
+  fHistdYRaw       = new TH1F("dy_raw",
+                             "deflection (raw);dy (140 #mum)",
                              128, -64.5, 63.5);
-  fHistdYres       = new TH1F("dyres", 
-                             "deflection residual;dy (cm)", 
+  fHistAlphaRaw    = new TH1F("fHistAlphaRaw",
+                             "angle w.r.t. to straight line",
+                             256, -128.5, 127.5);
+  fHistdYres       = new TH1F("dyres",
+                             "deflection residual;dy (cm)",
                              128, -1., 1.);
-  fHistdYresESD    = new TH1F("dyresesd", 
-                             "deflection residual;dy (cm)", 
+  fHistdYresESD    = new TH1F("dyresesd",
+                             "deflection residual;dy (cm)",
                              128, -1., 1.);
-  fHistCanddY      = new TH1F("dycand", 
-                             "deflection;dy (140 #mum)", 
-                             128, -64.5, 63.5);
-  fHistFounddY     = new TH1F("dyfound", 
-                             "deflection;dy (140 #mum)", 
+  fHistCanddY      = new TH1F("dycand",
+                             "deflection;dy (140 #mum)",
                              128, -64.5, 63.5);
-  fHistdYdiff      = new TH1F("dydiff", 
-                             "deflection #Deltady;dy_{sim}-dy_{raw} (140 #mum)", 
+  fHistFounddY     = new TH1F("dyfound",
+                             "deflection;dy (140 #mum)",
                              128, -64.5, 63.5);
-  fHistdYdYraw     = new TH2F("dydyraw", 
+  fHistdYdiff      = new TH1F("dydiff",
+                             "deflection #Deltady;dy_{sim}-dy_{raw} (140 #mum)",
+                             100, -2., 2.);
+  fHistdYdYraw     = new TH2F("dydyraw",
                              "deflection from sim. vs raw;dy_{sim} (140 #mum);dy_{raw} (140 #mum)",
                              128, -64.5, 63.5, 128, -64.5, 63.5);
 
-  fHistTrklPerRef  = new TH1F("trklperref", 
+  fHistTrklPerRef  = new TH1F("trklperref",
                              "No. of tracklets per track reference;no. of tracklets",
                              10, -0.5, 9.5);
 
-  fHistdYdYref     = new TH2F("dydyref", 
+  fHistdYdYref     = new TH2F("dydyref",
                              "deflection vs. deflection from track reference;dy_{ref} (140 #mum);dy (140 #mum)",
                              128, -64.5, 63.5, 128, -64.5, 63.5);
 
-  fHistZrow        = new TH1F("zrow", 
-                             "z-position;pad row", 
+  fHistZrow        = new TH1F("zrow",
+                             "z-position;pad row",
                              16, -0.5, 15.5);
-  fHistZrowRaw     = new TH1F("zrow-raw", 
-                             "z-position;pad row", 
+  fHistZrowRaw     = new TH1F("zrow-raw",
+                             "z-position;pad row",
                              16, -0.5, 15.5);
 
-  fHistPid         = new TH1F("pid", 
-                             "pid", 
+  fHistPid         = new TH1F("pid",
+                             "pid",
                              256, -0.5, 255.5);
-  fHistPidRaw      = new TH1F("pid-raw", 
-                             "pid", 
+  fHistPidRaw      = new TH1F("pid-raw",
+                             "pid",
                              256, -0.5, 255.5);
+  fHistPidDiff     = new TH1F("piddiff",
+                             "piddiff",
+                             256, -127.5, 128.5);
 
-  fHistYdYRaw      = new TH2F("ydyraw", 
-                             "y vs dy (raw tracklets);y (cm);dy (140 #mum)", 
-                             8192/32, -4096*160e-4, 4095*160e-4, 
+  fHistYdYRaw      = new TH2F("ydyraw",
+                             "y vs dy (raw tracklets);y (cm);dy (140 #mum)",
+                             8192/32, -4096*160e-4, 4095*160e-4,
                              128, -64.5, 63.5);
 
+  fHistFitYres     = new TH1F("fityres",
+                             "Tracklet #Deltay;y_{tracklet}-y_{track} (cm);count",
+                             8192/32, -4096/32*160e-4, 4095/32*160e-4);
+
+  fHistFitDyresEven= new TH1F("fitdyreseven",
+                             "Tracklet #Deltady;dy_{tracklet}-dy_{track} (cm);count",
+                             100, -2., 2.);
+  fHistFitDyresOdd = new TH1F("fitdyresodd",
+                             "Tracklet #Deltady;dy_{tracklet}-dy_{track} (cm);count",
+                             100, -2., 2.);
+
+  fHistNoMatchSim  = new TH2F("nomatchsim",
+                             "Unmatched tracklets from Simulation",
+                             8192/32, -4096*160e-4, 4095*160e-4,
+                             540, -0.5, 539.5);
+  fHistNoMatchRaw  = new TH2F("nomatchraw",
+                             "Unmatched tracklets from raw data",
+                             8192/32, -4096*160e-4, 4095*160e-4,
+                             540, -0.5, 539.5);
+
+  fHistResY        = new TH1F("resy",
+                             "Residuals to GTU track",
+                             100, -10., 10.);
+  fHistResZ        = new TH1F("resz",
+                             "Residuals to GTU track",
+                             100, -20., 20.);
+
   fTreeTracklets   = new TTree("trkl", "trkl");
   fTreeTracklets->Branch("y", &fY);
   fTreeTracklets->Branch("dy", &fDY);
@@ -218,20 +265,34 @@ void AliTRDonlineTrackletQA::CreateOutputObjects()
   fOutputList->Add(fHistdYresESD);
   fOutputList->Add(fHistdYdYref);
 
-  for (Int_t iLayer = 0; iLayer < 6; iLayer++) 
+  for (Int_t iLayer = 0; iLayer < 6; iLayer++)
     fOutputList->Add(fHistYlocal[iLayer]);
 
   fOutputList->Add(fHistYposRaw);
   fOutputList->Add(fHistdYRaw);
+  fOutputList->Add(fHistAlphaRaw);
   fOutputList->Add(fHistZrowRaw);
   fOutputList->Add(fHistPidRaw);
   fOutputList->Add(fHistYdYRaw);
 
   fOutputList->Add(fHistYdiff);
   fOutputList->Add(fHistdYdiff);
+  fOutputList->Add(fHistPidDiff);
   fOutputList->Add(fHistdYdYraw);
 
+  fOutputList->Add(fHistFitYres);
+  fOutputList->Add(fHistFitDyresEven);
+  fOutputList->Add(fHistFitDyresOdd);
+
+  fOutputList->Add(fHistNoMatchSim);
+  fOutputList->Add(fHistNoMatchRaw);
+
+  fOutputList->Add(fHistResY);
+  fOutputList->Add(fHistResZ);
+
   fOutputList->Add(fTreeTracklets);
+
+  PostData(1, fOutputList);
 }
 
 void AliTRDonlineTrackletQA::Exec(const Option_t * /* option */)
@@ -240,18 +301,22 @@ void AliTRDonlineTrackletQA::Exec(const Option_t * /* option */)
 
   // connect input data
   fTrackletTree = (TTree*) GetInputData(1);
-  if (!fTrackletTree)
-    return;
+  if (fTrackletTree) {
+    fTrackletTree->SetBranchAddress("tracklets_sim", &fTrackletsSim);
+    fTrackletTree->SetBranchAddress("tracklets_raw", &fTrackletsRaw);
+    fTrackletTree->GetEntry(fTrackletTree->GetEntriesFast()-1);
+  }
 
-  fTrackletTree->SetBranchAddress("tracklets_sim", &fTrackletsSim);
-  fTrackletTree->SetBranchAddress("tracklets_raw", &fTrackletsRaw);
-  fTrackletTree->GetEntry(fTrackletTree->GetEntriesFast()-1);
+  fESD = dynamic_cast<AliESDEvent*> (fInputEvent);
+
+  TList trackletsSim[540];
+  TList trackletsRaw[540];
 
   // prepare raw tracklets for comparison
   Int_t detRaw;
-  Int_t robRaw; 
+  Int_t robRaw;
   Int_t mcmRaw;
-  Int_t yRaw; 
+  Int_t yRaw;
   Int_t dyRaw;
   TTree trklRaw("raw tracklets", "raw tracklets");
   trklRaw.Branch("det", &detRaw);
@@ -262,9 +327,9 @@ void AliTRDonlineTrackletQA::Exec(const Option_t * /* option */)
   trklRaw.SetDirectory(0x0);
   // prepare simulated tracklets for comparison
   Int_t detSim;
-  Int_t robSim; 
+  Int_t robSim;
   Int_t mcmSim;
-  Int_t ySim; 
+  Int_t ySim;
   Int_t dySim;
   TTree trklSim("sim tracklets", "sim tracklets");
   trklSim.Branch("det", &detSim);
@@ -274,77 +339,123 @@ void AliTRDonlineTrackletQA::Exec(const Option_t * /* option */)
   trklSim.Branch("dy", &dySim);
   trklSim.SetDirectory(0x0);
 
-  // ----- simulated tracklets -----
-  AliTRDtrackletMCM *trkl = 0x0;
+  // ----- read ESD tracklets -----
+  if (fESD) {
+    Int_t nTracklets = fESD->GetNumberOfTrdTracklets();
+    Int_t nTrackletsSim = 0;
+    for (Int_t iTracklet = 0; iTracklet < nTracklets; iTracklet++) {
+      AliESDTrdTracklet *tracklet = fESD->GetTrdTracklet(iTracklet);
+
+      if (tracklet) {
+       // check for tracklet from simulation (label >= -1)
+       if (tracklet->GetLabel() >= -1) {
+         fHistYpos->Fill(tracklet->GetLocalY());
+         fHistdY->Fill(tracklet->GetBinDy());
+         fHistZrow->Fill(tracklet->GetBinZ());
+         fHistPid->Fill(tracklet->GetPID());
+
+         detSim = tracklet->GetDetector();
+         robSim = tracklet->GetROB();
+         mcmSim = tracklet->GetMCM();
+         ySim   = tracklet->GetBinY();
+         dySim  = tracklet->GetBinDy();
+         trklSim.Fill();
+
+         AliDebug(1, Form("trkl sim 0x%08x in %4i (ESD)", tracklet->GetTrackletWord(), tracklet->GetHCId()));
+         ++nTrackletsSim;
+
+         if (tracklet->GetDetector() > -1) {
+           trackletsSim[tracklet->GetDetector()].Add(tracklet);
+         }
+
+         PlotMC(tracklet);
+         PlotESD(tracklet);
+       }
+       // otherwise raw tracklet
+       else {
+         if (tracklet->GetDetector() > -1)
+           trackletsRaw[tracklet->GetDetector()].Add(tracklet);
+
+         fHistYposRaw->Fill(tracklet->GetLocalY());
+         fHistdYRaw->Fill(tracklet->GetBinDy());
+         Float_t alpha = tracklet->GetBinDy() - 3./140.e-4*tracklet->GetLocalY()/GetX(tracklet);
+         fHistAlphaRaw->Fill(alpha);
+         fHistZrowRaw->Fill(tracklet->GetBinZ());
+         fHistPidRaw->Fill(tracklet->GetPID());
+         fHistYdYRaw->Fill(tracklet->GetLocalY(), tracklet->GetBinDy());
+
+         detRaw = tracklet->GetDetector();
+         robRaw = tracklet->GetROB();
+         mcmRaw = tracklet->GetMCM();
+         yRaw   = tracklet->GetBinY();
+         dyRaw  = tracklet->GetBinDy();
+         trklRaw.Fill();
+       }
+      }
+    }
+    AliDebug(1, Form("no. of simulated tracklets in ESDs: %i", nTrackletsSim));
+  }
+
+  // ----- simulated tracklet from TRD.Tracklets.root -----
   if (fTrackletsSim) {
+    AliDebug(1, Form("no. of simulated tracklets in TRD.Tracklets.root: %i", fTrackletsSim->GetEntries()));
     for (Int_t iTracklet = 0; iTracklet < fTrackletsSim->GetEntries(); iTracklet++) {
-      trkl = (AliTRDtrackletMCM*) (*fTrackletsSim)[iTracklet];
-//      Int_t label = trkl->GetLabel();
-//      if (label > -1 && label < maxTracks) 
-//     mcTrackToTrackletMCM[label].idx[mcTrackToTrackletMCM[label].size < 10 ? mcTrackToTrackletMCM[label].size++ : 0] = iTracklet;
-      fHistYpos->Fill(trkl->GetY());
-      fHistdY->Fill(trkl->GetdY());
-      fHistZrow->Fill(trkl->GetZbin());
-      fHistPid->Fill(trkl->GetPID());
-
-      detSim = trkl->GetDetector();
-      robSim = trkl->GetROB();
-      mcmSim = trkl->GetMCM();
-      ySim   = trkl->GetYbin();
-      dySim  = trkl->GetdY();
-      trklSim.Fill();
-
-      PlotMC(trkl);
-      PlotESD(trkl);
+      AliTRDtrackletMCM *trkl = (AliTRDtrackletMCM*) (*fTrackletsSim)[iTracklet];
+      AliDebug(1, Form("trkl sim 0x%08x in %4i (TRD)", trkl->GetTrackletWord(), trkl->GetHCId()));
     }
   }
 
-  // ----- raw tracklets -----
-  if (fTrackletsRaw) {
-    for (Int_t iTracklet = 0; iTracklet < fTrackletsRaw->GetEntries(); iTracklet++) {
-      AliTRDtrackletWord *trklWord = (AliTRDtrackletWord*) (*fTrackletsRaw)[iTracklet];
-      // remove unwanted chambers
-      if (trklWord->GetDetector() == 57 ||
-         trklWord->GetDetector() == 47 ||
-         trklWord->GetDetector() == 32)
-       continue;
+  // ----- match simulated and raw tracklets (detector-wise) -----
+  for (Int_t iDetector = 0; iDetector < 540; iDetector++) {
+    for (Int_t iTracklet = 0; iTracklet < trackletsRaw[iDetector].GetEntries(); iTracklet++) {
+      AliESDTrdTracklet *trackletRaw = (AliESDTrdTracklet*) trackletsRaw[iDetector].At(iTracklet);
+
+      // search for the best match
+      AliESDTrdTracklet *trackletMatch = 0x0;
+      Int_t dyMax = 20;
+      Int_t yMax = 100;
+      for (Int_t iTrackletSim = 0; iTrackletSim < trackletsSim[iDetector].GetEntries(); iTrackletSim++) {
+       AliESDTrdTracklet *trackletSim = (AliESDTrdTracklet*) trackletsSim[iDetector].At(iTrackletSim);
+       AliDebug(10, Form("comparing 0x%08x with 0x%08x, det: %i %i",
+                         trackletRaw->GetTrackletWord(), trackletSim->GetTrackletWord(),
+                         trackletRaw->GetDetector(), trackletSim->GetDetector() ));
+       // require equal z
+       if (trackletRaw->GetBinZ() != trackletSim->GetBinZ())
+         continue;
+       // match on y
+       if (TMath::Abs(trackletRaw->GetBinY() - trackletSim->GetBinY()) > yMax)
+         continue;
 
-      fHistYposRaw->Fill(trklWord->GetY());
-      fHistdYRaw->Fill(trklWord->GetdY());
-      fHistZrowRaw->Fill(trklWord->GetZbin());
-      fHistPidRaw->Fill(trklWord->GetPID());
-      fHistYdYRaw->Fill(trklWord->GetY(), trklWord->GetdY());
-
-      detRaw = trklWord->GetDetector();
-      robRaw = trklWord->GetROB();
-      mcmRaw = trklWord->GetMCM();
-      yRaw   = trklWord->GetYbin();
-      dyRaw  = trklWord->GetdY();
-      trklRaw.Fill();
+       trackletMatch = trackletSim;
+       yMax  = TMath::Abs(trackletRaw->GetBinY()  - trackletSim->GetBinY());
+       dyMax = TMath::Abs(trackletRaw->GetBinDy() - trackletSim->GetBinDy());
+      }
+      if (trackletMatch) {
+       fHistYdiff->Fill(trackletRaw->GetBinY()  - trackletMatch->GetBinY());
+       fHistdYdiff->Fill(3.*trackletRaw->GetDyDx() - 3.*trackletMatch->GetDyDx());
+       fHistdYdYraw->Fill(trackletMatch->GetBinDy(), trackletRaw->GetBinDy());
+       fHistPidDiff->Fill(trackletRaw->GetPID() - trackletMatch->GetPID());
+       trackletsSim[iDetector].Remove(trackletMatch);
+      }
+      else {
+       // store unmatched raw tracklets
+       fHistNoMatchRaw->Fill(trackletRaw->GetLocalY(), trackletRaw->GetDetector());
+       // AliInfo(Form("unmatched raw tracklet: 0x%08x", trackletRaw->GetTrackletWord()));
+      }
+    }
+    // store the unmatched sim tracklets
+    for (Int_t iTracklet = 0; iTracklet < trackletsSim[iDetector].GetEntries(); iTracklet++) {
+      AliESDTrdTracklet *tracklet = (AliESDTrdTracklet*) trackletsSim[iDetector].At(iTracklet);
+      fHistNoMatchSim->Fill(tracklet->GetLocalY(), tracklet->GetDetector());
+      // AliInfo(Form("unmatched simulated tracklet: 0x%08x", tracklet->GetTrackletWord()));
     }
   }
 
-  // ----- tracklet comparison raw to simulated -----
-  trklRaw.BuildIndex("(det+rob*540)*16+mcm", "det");
-  trklSim.BuildIndex("(det+rob*540)*16+mcm", "det");
-  trklRaw.AddFriend(&trklSim, (const char*) "sim");
-  gDirectory->Add(fHistYdiff, kFALSE);
-  Int_t ncomp = trklRaw.Draw("(sim.y-y)*160e-4>>+ydiff", "", "goff");
-  printf("----- Compared %i tracklets -----\n", ncomp);
-  gDirectory->Remove(fHistYdiff);
-  gDirectory->Add(fHistdYdiff, kFALSE);
-  trklRaw.Draw("(sim.dy-dy)>>+dydiff", "", "goff");
-  gDirectory->Remove(fHistdYdiff);
-  gDirectory->Add(fHistdYdYraw, kFALSE);
-  trklRaw.Draw("dy:sim.dy>>+dydyraw", "", "goff");
-  //  trklRaw.Scan("det:rob:mcm:y:dy:sim.dy", "sim.dy < 30 && dy > 30");
-  gDirectory->Remove(fHistdYdYraw);
-
   // ----- MC tracks and track references -----
   // determine tracklet efficiency
   if (fMCEvent) {
     Int_t nTracksMC = fMCEvent->GetNumberOfTracks();
-    AliInfo(Form("no. of MC tracks: %i", nTracksMC));
+    // AliInfo(Form("no. of MC tracks: %i", nTracksMC));
     for (Int_t iTrack = 0; iTrack < nTracksMC; iTrack++) {
       // we want primaries
       if (!fMCEvent->IsPhysicalPrimary(iTrack))
@@ -406,22 +517,24 @@ void AliTRDonlineTrackletQA::Exec(const Option_t * /* option */)
          nRef = 0;
          continue;
        }
-       
+
        // now search for tracklets belonging to this track reference
        Int_t nTrackletsPerRef(0);
        Int_t defl(0);
-       for (Int_t iTracklet = 0; iTracklet < fTrackletsSim->GetEntries(); iTracklet++) {
-         trkl = (AliTRDtrackletMCM*) (*fTrackletsSim)[iTracklet];
+       TIter nextTracklet(trackletsSim);
+       while (AliESDTrdTracklet *trkl = (AliESDTrdTracklet*) nextTracklet()) {
          // they must have the same label
-         if (!trkl->HasLabel(label)) 
+         if (trkl->GetLabel() != label)
            continue;
+
          // and be close enough in radial position
-         if (TMath::Abs(trackRef->LocalX() - trkl->GetX()) > 5.) 
+         if (TMath::Abs(trackRef->LocalX() - GetX(trkl)) > 5.)
            continue;
+
          // if they are close in position we accept it
-         if ((TMath::Abs(trackRef->LocalY() - trkl->GetY()) < 5.) &&
-             (TMath::Abs(trackRef->Z() - trkl->GetZ()) < 5.)) {
-           defl = trkl->GetdY();
+         if ((TMath::Abs(trackRef->LocalY() - trkl->GetLocalY()) < 5.) &&
+             (TMath::Abs(trackRef->Z() - GetZ(trkl)) < 5.)) {
+           defl = trkl->GetDyDx();
            nTrackletsPerRef++;
          }
        }
@@ -447,7 +560,58 @@ void AliTRDonlineTrackletQA::Exec(const Option_t * /* option */)
     }
   }
 
-  PostData(1, fOutputList);  
+  // ----- ESD TRD tracks -----
+  if (fESD) {
+    // AliTRDtrapConfig *trapcfg = AliTRDcalibDB::Instance()->GetTrapConfig();
+    AliDebug(1, Form("no. of TRD tracks: %i", fESD->GetNumberOfTrdTracks()));
+    for (Int_t iTrack = 0; iTrack < fESD->GetNumberOfTrdTracks(); iTrack++) {
+      AliESDTrdTrack *trdTrack = fESD->GetTrdTrack(iTrack);
+      AliInfo(Form("TRD track pt: %7.2f", trdTrack->Pt()));
+      // AliTRDtrackOnline track;
+      AliESDTrdTracklet tracklets[6];
+      for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
+       AliESDTrdTracklet *trkl = trdTrack->GetTracklet(iLayer);
+       if (trkl) {
+         tracklets[iLayer].SetTrackletWord(trkl->GetTrackletWord());
+         tracklets[iLayer].SetHCId(trkl->GetHCId());
+         // track.AddTracklet(&(tracklets[iLayer])); //???
+       }
+      }
+      // track.AddParametrization(new AliTRDtrackParametrizationCurved());
+      // ROOT::Math::Minimizer *minim = ROOT::Math::Factory::CreateMinimizer("Minuit");
+      // track.Fit(minim);
+      // const TList &paramList = track.GetParametrizations();
+      // TIter param(&paramList, kFALSE);
+      // while (AliTRDtrackParametrization *trackParam = (AliTRDtrackParametrization*) param()) {
+      //       trackParam->Print();
+      //       AliTRDtrackParametrizationCurved *curvedParam = dynamic_cast<AliTRDtrackParametrizationCurved*> (trackParam);
+      //       if (curvedParam) {
+      //         // calculate residuals
+      //         for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
+      //           AliESDTrdTracklet *trkl = trdTrack->GetTracklet(iLayer);
+      //           if (trkl) {
+      //             AliTRDtrackPosition pos = curvedParam->ExtrapolateToLayer(iLayer);
+      //             fHistFitYres->Fill(pos.GetY() - trkl->GetLocalY());
+      //             Int_t rob = (trkl->GetBinZ()/4) + (trkl->GetHCId() % 0x1 ? 1 : 0);
+      //             Int_t mcm = trkl->GetBinZ() & 0x3;
+      //             Float_t deflcorr = ((Int_t) trapcfg->GetDmemUnsigned(AliTRDmcmSim::fgkDmemAddrDeflCorr, trkl->GetDetector(), rob, mcm))
+      //               * (0.635 + 0.03 * iLayer)/(256.0) / 32.;
+      //             Float_t scale = 1.;
+      //             Float_t defl = (3.*trkl->GetDyDx() - deflcorr) * scale + deflcorr;
+      //             if (iLayer & 0x1) {
+      //               fHistFitDyresOdd->Fill(pos.GetdY() - defl);
+      //             }
+      //             else {
+      //               fHistFitDyresEven->Fill(pos.GetdY() - defl);
+      //             }
+      //           }
+      //         }
+      //       }
+      // }
+    }
+  }
+
+  PostData(1, fOutputList);
 }
 
 void AliTRDonlineTrackletQA::LocalInit()
@@ -476,20 +640,20 @@ void AliTRDonlineTrackletQA::Terminate(const Option_t * /* option */)
 //  }
 }
 
-void AliTRDonlineTrackletQA::PlotMC(AliTRDtrackletMCM *trkl)
+void AliTRDonlineTrackletQA::PlotMC(AliESDTrdTracklet *trkl)
 {
   // compare the given tracklet to the MC information,
   // i.e. track references
-  
+
   Int_t label = trkl->GetLabel();
 
   // check for valid label
   if (label < 0 ) {
-    AliWarning("MC tracklet has no label");
+    AliDebug(1, "MC tracklet has no label");
     return;
   }
   if (label >= fMCEvent->GetNumberOfTracks()) {
-    AliWarning("MC tracklet has invalid label");
+    AliError("MC tracklet has invalid label");
     return;
   }
 
@@ -500,7 +664,7 @@ void AliTRDonlineTrackletQA::PlotMC(AliTRDtrackletMCM *trkl)
 //    return;
 //  if (trkl->GetDetector() % 6 != 5)
 //    return;
-  
+
   // get MC particle for this tracklet
   AliMCParticle *track = (AliMCParticle*) fMCEvent->GetTrack(label);
 
@@ -518,17 +682,17 @@ void AliTRDonlineTrackletQA::PlotMC(AliTRDtrackletMCM *trkl)
       continue;
     if (trackRef->Pt() < fMinPt)
       continue;
-    
-    if (TMath::Abs(trkl->GetX() - trackRef->LocalX()) > 5.)
+
+    if (TMath::Abs(GetX(trkl) - trackRef->LocalX()) > 5.)
       continue;
 
-    tr[nTrackRefs++] = trackRef; 
+    tr[nTrackRefs++] = trackRef;
 
     if (nTrackRefs == 2)
       break;
   }
 
-  // if there were exactly 2 track references 
+  // if there were exactly 2 track references
   // (otherwise something is strange and we want to look at clean cases)
   // compare tracklet to them
   if (nTrackRefs == 2) {
@@ -538,48 +702,45 @@ void AliTRDonlineTrackletQA::PlotMC(AliTRDtrackletMCM *trkl)
     }
     // require minimal distance in X and maximum deflection in Y
     // for the track references
-    else if ((tr[1]->LocalX() - tr[0]->LocalX()) > 0.1 && TMath::Abs(tr[1]->LocalY() - tr[0]->LocalY()) < 1.) { 
+    else if ((tr[1]->LocalX() - tr[0]->LocalX()) > 0.1 && TMath::Abs(tr[1]->LocalY() - tr[0]->LocalY()) < 1.) {
       // calculate slope from track references
       // and check whether it's in the allowed range
       Float_t slope = 3. * (tr[1]->LocalY() - tr[0]->LocalY()) / (tr[1]->LocalX() - tr[0]->LocalX());
       if (TMath::Abs(slope) < 64*140e-4) {
-       AliDebug(1,Form("x1: %f, x0: %f, y1: %f, y0:%f", 
+       AliDebug(1,Form("x1: %f, x0: %f, y1: %f, y0:%f",
                        tr[1]->LocalX(), tr[0]->LocalX(), tr[1]->LocalY(), tr[0]->LocalY() ));
        // calculate y-position scaled to radial position of the tracklet
        // and consider the tilting angle of the pads
        // since the tracklets are affected by it
-       Float_t yMC     = (tr[1]->LocalY() + (-0.5+trkl->GetX() - tr[1]->LocalX()) * (tr[1]->LocalY() - tr[0]->LocalY()) / (tr[1]->LocalX() - tr[0]->LocalX()));
-       Float_t yMCtilt = yMC + (TMath::Tan(TMath::Power(-1, (trkl->GetDetector() % 6))*2.*TMath::Pi()/180.) * (tr[1]->Z() - trkl->GetZ()));
-       if (TMath::Abs(trkl->GetY() - yMCtilt) > 10.) {
-         AliError(Form("Deviation too large for tracklet: 0x%08x in det. %i at x = %f, y = %f, z = %f, alpha = %f", 
-                       trkl->GetTrackletWord(), trkl->GetDetector(), trkl->GetX(), trkl->GetY(), trkl->GetZ(), tr[0]->Alpha()));
+       Float_t yMC     = (tr[1]->LocalY() + (-0.5+GetX(trkl) - tr[1]->LocalX()) * (tr[1]->LocalY() - tr[0]->LocalY()) / (tr[1]->LocalX() - tr[0]->LocalX()));
+       Float_t yMCtilt = yMC + (TMath::Tan(TMath::Power(-1, (trkl->GetDetector() % 6))*2.*TMath::Pi()/180.) * (tr[1]->Z() - GetZ(trkl)));
+       if (TMath::Abs(trkl->GetLocalY() - yMCtilt) > 10.) {
+         AliError(Form("Deviation too large for tracklet: 0x%08x in det. %i at x = %f, y = %f, z = %f, alpha = %f",
+                       trkl->GetTrackletWord(), trkl->GetDetector(), GetX(trkl), trkl->GetLocalY(), GetZ(trkl), tr[0]->Alpha()));
        }
-       fHistYres->Fill(trkl->GetY() - yMCtilt);
-       fHistYresDy->Fill(trkl->GetY() - yMCtilt, trkl->GetdY());
+       fHistYres->Fill(trkl->GetLocalY() - yMCtilt);
+       fHistYresDy->Fill(trkl->GetLocalY() - yMCtilt, trkl->GetDyDx());
        // what about tilt correction here ???
-       fHistdYres->Fill(3. * trkl->GetdYdX() - 
+       fHistdYres->Fill(3. * trkl->GetDyDx() -
                         3. * (tr[1]->LocalY() - tr[0]->LocalY()) / (tr[1]->LocalX() - tr[0]->LocalX()));
        // plot position deviation in pad-coordinates
        // to study the influence of the position LUT
        Float_t padWidth = fGeo->GetPadPlane(trkl->GetDetector())->GetWidthIPad();
-       Float_t yMClocal = yMCtilt/padWidth - floor(yMCtilt/padWidth) - padWidth/2.; 
+       Float_t yMClocal = yMCtilt/padWidth - floor(yMCtilt/padWidth) - padWidth/2.;
        Int_t layer = trkl->GetDetector() % 6;
-       fHistYlocal[layer]->Fill(yMClocal, 
-                                trkl->GetY()/padWidth - floor(trkl->GetY()/padWidth) - padWidth/2. - yMClocal);
+       fHistYlocal[layer]->Fill(yMClocal,
+                                trkl->GetLocalY()/padWidth - floor(trkl->GetLocalY()/padWidth) - padWidth/2. - yMClocal);
        // and fill everything to the tree
-       fQ0 = trkl->GetQ0();
-       fQ1 = trkl->GetQ1();
-       fNHits = trkl->GetNHits();
-       fYdiff = trkl->GetY() - yMCtilt;
-       fDYdiff = 3. * trkl->GetdYdX() -
+       fYdiff = trkl->GetLocalY() - yMCtilt;
+       fDYdiff = 3. * trkl->GetDyDx() -
          3. * (tr[1]->LocalY() - tr[0]->LocalY()) / (tr[1]->LocalX() - tr[0]->LocalX());
-       fY = trkl->GetY();
-       fDY = trkl->GetdYdX();
+       fY = trkl->GetLocalY();
+       fDY = trkl->GetDyDx();
        fTreeTracklets->Fill();
        // output tracklets with large deviation
        if (TMath::Abs(fYdiff) > 0.5) {
-         printf("tracklet: y=%4.2f, dy=%4.2f, ydiff=%4.2f, dydiff=%4.2f, q0=%5d, q1=%5d, nhits=%2d, label=%i\n",
-                trkl->GetY(), trkl->GetdYdX(), fYdiff, fDYdiff, fQ0, fQ1, fNHits, label);
+         AliWarning(Form("tracklet: y=%4.2f, dy=%4.2f, ydiff=%4.2f, dydiff=%4.2f, q0=%5d, q1=%5d, nhits=%2d, label=%i",
+                         trkl->GetLocalY(), trkl->GetDyDx(), fYdiff, fDYdiff, fQ0, fQ1, fNHits, label));
        }
       }
     }
@@ -587,13 +748,13 @@ void AliTRDonlineTrackletQA::PlotMC(AliTRDtrackletMCM *trkl)
 }
 
 
-void AliTRDonlineTrackletQA::PlotESD(AliTRDtrackletMCM *trkl)
+void AliTRDonlineTrackletQA::PlotESD(AliESDTrdTracklet *trkl)
 {
   // plot comparison to ESD
 
-  Float_t xTrkl = trkl->GetX();
-  Float_t yTrkl = trkl->GetY();
-  Float_t zTrkl = trkl->GetZ();
+  Float_t xTrkl = GetX(trkl);
+  Float_t yTrkl = trkl->GetLocalY();
+  Float_t zTrkl = GetZ(trkl);
 
   Float_t alpha = (trkl->GetDetector() / 30) * 20. + 10.;
   alpha *= TMath::Pi() / 180.;
@@ -602,7 +763,7 @@ void AliTRDonlineTrackletQA::PlotESD(AliTRDtrackletMCM *trkl)
   if (!esdEvent)
     return;
 
-  Float_t mag = ((AliMagF*) TGeoGlobalMagField::Instance()->GetField())->SolenoidField();
+  Float_t mag = 0.5; //((AliMagF*) TGeoGlobalMagField::Instance()->GetField())->SolenoidField();
 
   for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) {
     AliESDtrack *track = esdEvent->GetTrack(iTrack);
@@ -612,20 +773,20 @@ void AliTRDonlineTrackletQA::PlotESD(AliTRDtrackletMCM *trkl)
 
     AliExternalTrackParam *param = new AliExternalTrackParam(*(track->GetOuterParam()));
 
-    AliDebug(10, Form("track %i at x = %f, y = %f", 
+    AliDebug(10, Form("track %i at x = %f, y = %f",
                      iTrack, param->GetX(), param->GetY()));
     param->Propagate(alpha, xTrkl, mag);
-    AliDebug(10, Form("after propagating track %i at x = %f, y = %f", 
+    AliDebug(10, Form("after propagating track %i at x = %f, y = %f",
                      iTrack, param->GetX(), param->GetY()));
 
     if ((TMath::Abs(xTrkl - param->GetX()) < 10.) &&
        (TMath::Abs(yTrkl - param->GetY()) < 5.) &&
        (TMath::Abs(zTrkl - param->GetZ()) < 10.)) {
-      AliInfo(Form("match of tracklet-track: %i <-> %i", 
-                  trkl->GetLabel(), track->GetLabel())); 
+      AliDebug(2, Form("match of tracklet-track: %i <-> %i",
+                      trkl->GetLabel(), track->GetLabel()));
       AliDebug(5, Form("tracklet position: det: %3i  x = %f, y = %f, z = %f, alpha = %f",
-                      trkl->GetDetector(), trkl->GetX(), trkl->GetY(), trkl->GetZ(), alpha));
-      AliDebug(5, Form("after propagating track %i at x = %f, y = %f, z = %f", 
+                      trkl->GetDetector(), GetX(trkl), trkl->GetLocalY(), GetZ(trkl), alpha));
+      AliDebug(5, Form("after propagating track %i at x = %f, y = %f, z = %f",
                      iTrack, param->GetX(), param->GetY(), param->GetZ()));
 
       fHistYresESD->Fill(yTrkl - param->GetY());
@@ -636,54 +797,6 @@ void AliTRDonlineTrackletQA::PlotESD(AliTRDtrackletMCM *trkl)
 
 }
 
-void AliTRDonlineTrackletQA::PlotESD(AliTRDtrackletWord *trkl) 
-{
-  // plot comparison to ESD
-
-  Float_t xTrkl = trkl->GetX();
-  Float_t yTrkl = trkl->GetY();
-  Float_t zTrkl = trkl->GetZ();
-
-  Float_t alpha = (trkl->GetDetector() / 30) * 20. + 10.;
-  alpha *= TMath::Pi() / 180.;
-
-  AliESDEvent *esdEvent = dynamic_cast<AliESDEvent*> (fInputEvent);
-  if (!esdEvent)
-    return;
-
-  Float_t mag = ((AliMagF*) TGeoGlobalMagField::Instance()->GetField())->SolenoidField();
-
-  for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) {
-    AliESDtrack *track = esdEvent->GetTrack(iTrack);
-
-    if (!track->GetOuterParam())
-      continue;
-
-    AliExternalTrackParam *param = new AliExternalTrackParam(*(track->GetOuterParam()));
-
-    AliDebug(10, Form("track %i at x = %f, y = %f", 
-                     iTrack, param->GetX(), param->GetY()));
-    param->Propagate(alpha, xTrkl, mag);
-    AliDebug(10, Form("after propagating track %i at x = %f, y = %f", 
-                     iTrack, param->GetX(), param->GetY()));
-
-    if ((TMath::Abs(xTrkl - param->GetX()) < 10.) &&
-       (TMath::Abs(yTrkl - param->GetY()) < 5.) &&
-       (TMath::Abs(zTrkl - param->GetZ()) < 10.)) {
-      AliDebug(5, Form("tracklet position: det: %3i  x = %f, y = %f, z = %f, alpha = %f",
-                      trkl->GetDetector(), trkl->GetX(), trkl->GetY(), trkl->GetZ(), alpha));
-      AliDebug(5, Form("after propagating track %i at x = %f, y = %f, z = %f", 
-                     iTrack, param->GetX(), param->GetY(), param->GetZ()));
-
-      fHistYresESD->Fill(yTrkl - param->GetY());
-    }
-
-    delete param;
-  }
-
-}
-
-
 Int_t AliTRDonlineTrackletQA::GetTrackletsForMC(Int_t /* label */, Int_t /*idx*/ []) const
 {
   // get tracklets for MC label
index 6716cc5..0a68845 100644 (file)
@@ -6,10 +6,17 @@
 
 #include "AliAnalysisTask.h"
 
+#include "AliTRDgeometry.h"
+#include "AliTRDpadPlane.h"
+#include "AliESDTrdTracklet.h"
+
 class TList;
+class TH1F;
+class TH2F;
 
 class AliInputEventHandler;
 class AliVEvent;
+class AliESDEvent;
 class AliAODEvent;
 class AliMCEvent;
 
@@ -30,13 +37,15 @@ class AliTRDonlineTrackletQA : public AliAnalysisTask
   void LocalInit();
   void Terminate(const Option_t *option);
 
-  void PlotMC(AliTRDtrackletMCM *trkl);
-  void PlotESD(AliTRDtrackletMCM *trkl);
-
-  void PlotESD(AliTRDtrackletWord *trkl);
+  void PlotMC(AliESDTrdTracklet *trkl);
+  void PlotESD(AliESDTrdTracklet *trkl);
 
   Int_t GetTrackletsForMC(Int_t label, Int_t idx[]) const;
 
+  Float_t GetX(AliESDTrdTracklet *trkl) { return fGeo->GetTime0(trkl->GetDetector() % 6); }
+  Float_t GetZ(AliESDTrdTracklet *trkl) { return fGeo->GetPadPlane((trkl->GetDetector() % 6) / 2, (trkl->GetDetector()/6) % 5)->GetRowPos(trkl->GetBinZ()) -
+                                           fGeo->GetPadPlane((trkl->GetDetector() % 6) / 2, (trkl->GetDetector()/6) % 5)->GetRowSize(trkl->GetBinZ()); }
+
  protected:
   AliESDEvent *fESD;                    //! current ESD event
 
@@ -64,14 +73,27 @@ class AliTRDonlineTrackletQA : public AliAnalysisTask
   TH2F                 *fHistdYdYref;    //! dy vs. dy from track reference
   TH1F                 *fHistYposRaw;    //! trkl y-position within chamber
   TH1F                 *fHistdYRaw;    //! trkl dy 
+  TH1F                 *fHistAlphaRaw; //! trkl alpha 
   TH2F                 *fHistYdYRaw;    //! y vs dy from raw
   TH1F                 *fHistZrow;      //! z-row
   TH1F                 *fHistZrowRaw;   //! z-row
   TH1F                 *fHistPid;       //! PID
   TH1F                 *fHistPidRaw;    //! PID
+  TH1F                 *fHistPidDiff;   //! PID
   TH1F                 *fHistYdiff;     //! difference in y between sim and raw
   TH1F                 *fHistdYdiff;    //! difference in dy between sim and raw
   TH2F                 *fHistdYdYraw;   //! dy sim vs. raw
+  TH1F                 *fHistFitYres;   //! trkl y-residual to track fit through
+                                       //  contributing tracklets
+  TH1F                 *fHistFitDyresEven;  //! trkl deflection residual to track fit through
+                                           //  contributing tracklets
+  TH1F                 *fHistFitDyresOdd;   //! trkl deflection residual to track fit through
+                                           //  contributing tracklets
+  TH2F                 *fHistNoMatchSim; //! simulated tracklets which were not matched to a raw one
+  TH2F                 *fHistNoMatchRaw; //! raw tracklets which were not matched to a simulated one
+
+  TH1F                 *fHistResY;      //! residuals in y w.r.t. GTU track
+  TH1F                 *fHistResZ;      //! residuals in z w.r.t. GTU track
   TTree                *fTreeTracklets; //! store tracklet information
 
   // ----- temporary storage -----
@@ -93,7 +115,6 @@ class AliTRDonlineTrackletQA : public AliAnalysisTask
   Int_t fNevent;             // current event number
 
   TTree *fTrackletTree;  //! tracklets from simulation
-  TTree *fTrackletTreeRaw; //! tracklets from raw data
 
  private:
   AliTRDonlineTrackletQA(const AliTRDonlineTrackletQA&); // not implemented
similarity index 52%
rename from PWGPP/TRD/macros/AddTRDtrackletFilter.C
rename to PWGPP/TRD/macros/AddTRDonlineTrackletFilter.C
index 7a09d4c..dd58998 100644 (file)
@@ -1,27 +1,31 @@
-AliAnalysisTask *AddTRDtrackletFilter()
+#if ! defined (__CINT__) || defined (__MAKECINT__)
+#include "TTree.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "AliAnalysisTask.h"
+#include "PWGPP/TRD/AliTRDonlineTrackletFilter.h"
+#endif
+
+AliAnalysisTask *AddTRDonlineTrackletFilter(AliAnalysisManager *mgr)
 {
-  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     cerr << "No Analysis manager available" << endl;
     return 0x0;
   }
 
-  //  gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TRD/AliTRDtaskTrackletFilter.cxx++g");
-
-  AliTRDonlineTrackletFilter *task = new AliTRDonlineTrackletFilter("tracklet-filter");
+  AliTRDonlineTrackletFilter *task = new AliTRDonlineTrackletFilter("TRDtrackletfilter");
   mgr->AddTask(task);
 
   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
   AliAnalysisDataContainer *coutput = mgr->GetCommonOutputContainer();
 
   AliAnalysisDataContainer *ctracklets =
-    mgr->CreateContainer("ctracklets", TTree::Class(),
+    mgr->CreateContainer("TRDtrackletFilter", TTree::Class(),
                         AliAnalysisManager::kOutputContainer,
-                        "tracklets.root");
+                        Form("%s:TRD_Performance", mgr->GetCommonFileName()));
 
   task->ConnectInput(0, cinput);
 
-  task->ConnectOutput(0, coutput);
   task->ConnectOutput(1, ctracklets);
 
   return task;
similarity index 51%
rename from PWGPP/TRD/macros/AddTRDtrackletQA.C
rename to PWGPP/TRD/macros/AddTRDonlineTrackletQA.C
index 14e34cc..9d21c5c 100644 (file)
@@ -1,30 +1,34 @@
-AliAnalysisTask *AddTRDtrackletQA()
+#if ! defined (__CINT__) || defined (__MAKECINT__)
+#include "TList.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+#include "AliAnalysisTask.h"
+#include "PWGPP/TRD/AliTRDonlineTrackletQA.h"
+#endif
+
+AliAnalysisTask *AddTRDonlineTrackletQA(AliAnalysisManager *mgr)
 {
-  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
     cerr << "No Analysis manager available" << endl;
     return 0x0;
   }
 
-  //  gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TRD/AliTRDtrklQA.cxx++g");
-
-  AliTRDonlineTrackletQA *task = new AliTRDonlineTrackletQA("trklQA");
+  AliTRDonlineTrackletQA *task = new AliTRDonlineTrackletQA("TRDtrackletQA");
   mgr->AddTask(task);
 
   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
   AliAnalysisDataContainer *coutput = mgr->GetCommonOutputContainer();
   AliAnalysisDataContainer *ctracklets =
-    (AliAnalysisDataContainer*) AliAnalysisManager::GetAnalysisManager()->GetContainers()->FindObject("ctracklets");
+    (AliAnalysisDataContainer*) AliAnalysisManager::GetAnalysisManager()->GetContainers()->FindObject("TRDtrackletFilter");
 
   AliAnalysisDataContainer *ctrklqa =
-    mgr->CreateContainer("ctrklqa", TList::Class(),
+    mgr->CreateContainer("TRDtrackletQA", TList::Class(),
                         AliAnalysisManager::kOutputContainer,
-                        "trkl-qa.root");
+                        Form("%s:TRD_Performance", mgr->GetCommonFileName()));
 
   task->ConnectInput(0, cinput);
   task->ConnectInput(1, ctracklets);
 
-  task->ConnectOutput(0, coutput);
   task->ConnectOutput(1, ctrklqa);
 
   return task;