]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
new task to check TRD tracking performances at ESD-MC (only) level.
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Feb 2009 12:23:37 +0000 (12:23 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Feb 2009 12:23:37 +0000 (12:23 +0000)
  - No friend information is used
  - analysis based on ESD reconstruction bit map

TRD/TRDqaRecLinkDef.h
TRD/qaRec/AliTRDcheckESD.cxx [new file with mode: 0644]
TRD/qaRec/AliTRDcheckESD.h [new file with mode: 0644]
TRD/qaRec/run.C

index 22b9a73b0c17ecbcf3fc687b55f9cbc9ec6387a0..ecdb004b1774056a96098db3932886b69f41a094 100644 (file)
 #pragma link C++ class  AliTRDeventInfo+;
 #pragma link C++ class  AliTRDtrackInfo::AliESDinfo+;
 #pragma link C++ class  AliTRDtrackInfo::AliMCinfo+;
+#pragma link C++ class  AliTRDcheckESD+;
 #pragma link C++ class  AliTRDtrackInfoGen+;
 #pragma link C++ class  AliTRDrecoTask+;
 #pragma link C++ class  AliTRDcheckDetector+;
 #pragma link C++ class  AliTRDtrackingResolution+;
 #pragma link C++ class  AliTRDtrackingEfficiency+;
 #pragma link C++ class  AliTRDtrackingEfficiencyCombined+;
-#pragma link C++ class  AliTRDalignmentTask+;
-#pragma link C++ class  AliTRDcalibration+;
 #pragma link C++ class  AliTRDpidChecker+;
-#pragma link C++ class  AliTRDpidRefMaker+;
 
 // reconstruction calibration tasks
 #pragma link C++ class  AliTRDclusterResolution+;
+#pragma link C++ class  AliTRDalignmentTask+;
+#pragma link C++ class  AliTRDcalibration+;
+#pragma link C++ class  AliTRDpidRefMaker+;
 
 #endif
diff --git a/TRD/qaRec/AliTRDcheckESD.cxx b/TRD/qaRec/AliTRDcheckESD.cxx
new file mode 100644 (file)
index 0000000..752061a
--- /dev/null
@@ -0,0 +1,238 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+
+#include <TClonesArray.h>
+#include <TObjArray.h>
+#include <TObject.h>
+#include <TH2I.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TROOT.h>
+#include <TChain.h>
+#include <TParticle.h>
+
+#include "AliLog.h"
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h"
+#include "AliMCEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEventHandler.h"
+
+#include "AliESDtrack.h"
+#include "AliMCParticle.h"
+#include "AliPID.h"
+#include "AliStack.h"
+#include "AliTrackReference.h"
+#include "AliTRDgeometry.h"
+
+#include "AliTRDcheckESD.h"
+
+ClassImp(AliTRDcheckESD)
+
+const Float_t AliTRDcheckESD::xTPC = 290.;
+const Float_t AliTRDcheckESD::xTOF = 365.;
+
+//____________________________________________________________________
+AliTRDcheckESD::AliTRDcheckESD():
+  AliAnalysisTask("ESDchecker", "TRD checker @ ESD level")
+  ,fStatus(0)
+  ,fESD(0x0)
+  ,fMC(0x0)
+  ,fHistos(0x0)
+{
+  //
+  // Default constructor
+  //
+
+  DefineInput(0, TChain::Class());
+  DefineOutput(0, TObjArray::Class());
+}
+
+//____________________________________________________________________
+AliTRDcheckESD::~AliTRDcheckESD()
+{
+  if(fHistos){
+    //fHistos->Delete();
+    delete fHistos;
+  }
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::ConnectInputData(Option_t *)
+{
+  //
+  // Link the Input Data
+  //
+  TTree *tree = dynamic_cast<TChain*>(GetInputData(0));
+  if(tree) tree->SetBranchStatus("Tracks", 1);
+
+  AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+  fESD = esdH ? esdH->GetEvent() : 0x0;
+
+  if(!HasMC()) return;
+  AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+  fMC = mcH ? mcH->MCEvent() : 0x0;
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::CreateOutputObjects()
+{      
+  //
+  // Create Output Containers (TObjectArray containing 1D histograms)
+  //
+  OpenFile(0, "RECREATE");  
+  fHistos = new TObjArray(5);
+  //fHistos->SetOwner(kTRUE);
+  
+  TH1 *h = 0x0;
+
+  // clusters per tracklet
+  if(!(h = (TH1I*)gROOT->FindObject("hNCl"))){
+    h = new TH1I("hNCl", "Clusters per TRD track", 100, 0., 200.);
+    h->GetXaxis()->SetTitle("N_{cl}^{TRD}");
+    h->GetYaxis()->SetTitle("entries");
+  } else h->Reset();
+  fHistos->AddAt(h, kNCl);
+
+  // TPC out
+  if(!(h = (TH2I*)gROOT->FindObject("hTRDstat"))){
+    h = new TH2I("hTRDstat", "TRD status bits", 100, 0., 20., 4, -.5, 3.5);
+    h->GetXaxis()->SetTitle("p_{T} [GeV/c]");
+    h->GetYaxis()->SetTitle("status bits");
+    h->GetZaxis()->SetTitle("entries");
+  } else h->Reset();
+  fHistos->AddAt(h, kTRDstat);
+}
+
+//____________________________________________________________________
+void AliTRDcheckESD::Exec(Option_t *){
+  //
+  // Run the Analysis
+  //
+  if(!fESD){
+    AliError("ESD not found");
+    return;
+  }
+
+  // Get MC information if available
+  AliStack * fStack = 0x0;
+  if(HasMC() && !fMC){ 
+    AliWarning("Monte Carlo Event not available");
+    SetMC(kFALSE);
+  } else {
+    if(!(fStack = fMC->Stack())){
+      AliWarning("Cannot get the Monte Carlo Stack");
+      SetMC(kFALSE);
+    }
+  }
+  Bool_t TPCout(0), TRDin(0), TRDout(0), TRDpid(0);
+
+
+  Int_t nTRD = 0, nTPC = 0;
+  //Int_t nTracks = fESD->GetNumberOfTracks();
+  AliESDtrack *esdTrack = 0x0;
+  for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){
+    TPCout=0;TRDin=0;TRDout=0;TRDpid=0;
+    esdTrack = fESD->GetTrack(itrk);
+    if(esdTrack->GetNcls(1)) nTPC++;
+    if(esdTrack->GetNcls(2)) nTRD++;
+
+    // track status
+    ULong_t status = esdTrack->GetStatus();
+
+    // TRD PID
+    Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p);
+    // pid quality
+    esdTrack->GetTRDpidQuality();
+    // kink index
+    esdTrack->GetKinkIndex(0);
+    // TPC clusters
+    esdTrack->GetNcls(1);
+
+    // look at external track param
+    const AliExternalTrackParam *op = esdTrack->GetOuterParam();
+    Double_t xyz[3];
+    if(op){
+      op->GetXYZ(xyz);
+      op->Global2LocalPosition(xyz, op->GetAlpha());
+      //printf("op @ X[%7.3f]\n", xyz[0]);
+    }
+
+    // read MC info
+    if(!HasMC()) continue;
+
+    Int_t fLabel = esdTrack->GetLabel();
+    if(TMath::Abs(fLabel) > fStack->GetNtrack()) continue; 
+    
+    // read MC particle
+    AliMCParticle *mcParticle = 0x0; 
+    if(!(mcParticle = fMC->GetTrack(TMath::Abs(fLabel)))){
+      AliWarning(Form("MC particle missing for ESD fLabel %d.", fLabel));
+      continue;
+    }
+
+    AliTrackReference *ref = 0x0; 
+    Int_t nRefs = mcParticle->GetNumberOfTrackReferences();
+    Int_t iref = 0;
+    while(iref<nRefs){
+      ref = mcParticle->GetTrackReference(iref);
+      if(ref->LocalX() > xTPC) break;
+      ref=0x0; iref++;
+    }
+
+    // read TParticle
+    TParticle *tParticle = mcParticle->Particle(); 
+    Int_t fPdg = tParticle->GetPdgCode();
+    //tParticle->IsPrimary();
+
+    //printf("[%c] ref[%2d]=", tParticle->IsPrimary() ? 'P' : 'S', iref);
+
+    TPCout=1;
+    if(ref){
+      if(ref->LocalX() > xTOF){ 
+        //printf("  TOF   [");
+        ref = mcParticle->GetTrackReference(iref-1);
+      } else {
+        //printf("%7.2f [", ref->LocalX());
+        TRDin=1;
+        if(esdTrack->GetNcls(2)) TRDout=1;
+        if(esdTrack->GetTRDpidQuality()) TRDpid=1;
+      }
+    } else { 
+      //printf("  TPC   [");
+      ref = mcParticle->GetTrackReference(iref-1);
+    }
+    Float_t pt = ref->Pt();
+    //printf("%f]\n", pt);
+    
+    TH2 *h = (TH2I*)fHistos->At(kTRDstat);
+    if(/*status & AliESDtrack::k*/TPCout) h->Fill(pt, 0);
+    if(/*status & AliESDtrack::k*/TRDin) h->Fill(pt, 1);
+    if(/*status & AliESDtrack::k*/TRDout){ 
+      ((TH1*)fHistos->At(kNCl))->Fill(esdTrack->GetNcls(2));
+      h->Fill(pt, 2);
+    }
+    if(/*status & AliESDtrack::k*/TRDpid) h->Fill(pt, 3);
+  }  
+
+  PostData(0, fHistos);
+}
+
+
+//____________________________________________________________________
+void AliTRDcheckESD::Terminate(Option_t *)
+{
+}
diff --git a/TRD/qaRec/AliTRDcheckESD.h b/TRD/qaRec/AliTRDcheckESD.h
new file mode 100644 (file)
index 0000000..7f617f1
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef AliTRDcheckESD_H
+#define AliTRDcheckESD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliTRDcheckESD.h 27496 2008-07-22 08:35:45Z cblume $ */
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  Reconstruction QA                                                     //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef ALIANALYSISTASK_H
+#include "AliAnalysisTask.h"
+#endif
+
+class AliESDEvent;
+class AliMCEvent;
+class TObjArray;
+class AliTRDcheckESD : public AliAnalysisTask {
+public:
+  enum ETRDcheckESDstatus {
+    kMC = BIT(0)
+  };
+  enum ETRDcheckESDhistos {
+    kNCl     = 0   // number of clusters per track
+   ,kTRDstat = 2   // TRD tracks status
+  };
+  AliTRDcheckESD();
+  virtual ~AliTRDcheckESD();
+  
+  void    ConnectInputData(Option_t *);
+  void    CreateOutputObjects();
+
+  Bool_t  HasMC() const { return TESTBIT(fStatus, kMC);}
+
+  void    Exec(Option_t *);
+  void    SetMC(Bool_t mc = kTRUE) { mc ? SETBIT(fStatus, kMC) : CLRBIT(fStatus, kMC);}
+  void    Terminate(Option_t *);
+
+  static const Float_t xTPC;
+  static const Float_t xTOF;
+
+private:
+  AliTRDcheckESD(const AliTRDcheckESD&);
+  AliTRDcheckESD& operator=(const AliTRDcheckESD&);
+  Int_t            fStatus;            // bit mask for controlling the task
+  AliESDEvent      *fESD;              // ESD event
+  AliMCEvent       *fMC;               // MC event
+  TObjArray        *fHistos;           // QA histos
+  ClassDef(AliTRDcheckESD, 1)          // user oriented TRD analysis based on ESD-MC data
+};
+#endif
index 8841fc3bcea6454b2b94798f57c12645d0b5744c..5bf0dd79fbf25ab5ef40ccdd81aa842946bded9b 100644 (file)
@@ -59,6 +59,7 @@
 #include "TRD/AliTRDtrackerV1.h"
 #include "TRD/AliTRDcalibDB.h"
 #include "TRD/qaRec/AliTRDtrackInfo/AliTRDeventInfo.h"
+#include "TRD/qaRec/AliTRDcheckESD.h"
 #include "TRD/qaRec/AliTRDtrackInfoGen.h"
 #include "TRD/qaRec/AliTRDtrackingEfficiency.h"
 #include "TRD/qaRec/AliTRDtrackingEfficiencyCombined.h"
@@ -176,14 +177,19 @@ void run(Char_t *tasks="ALL", const Char_t *files=0x0)
   if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler());
   //mgr->SetDebugLevel(10);
 
+  //____________________________________________
+  // TRD check ESD
+  AliTRDcheckESD *checkESD = new AliTRDcheckESD();
+  mgr->AddTask(checkESD);
+  checkESD->SetMC(fHasMCdata);
+  mgr->ConnectInput(checkESD, 0, mgr->GetCommonInputContainer());  mgr->ConnectOutput(checkESD, 0, mgr->CreateContainer(checkESD->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("TRD.Task%s.root", checkESD->GetName())));
+
   //____________________________________________
   // TRD track summary generator
   mgr->AddTask(task = new AliTRDtrackInfoGen());
   taskPtr[(Int_t)kInfoGen] = task;
   task->SetDebugLevel(0);
   task->SetMCdata(fHasMCdata);
-  // Create containers for input/output
-  //AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("data", TChain::Class(), AliAnalysisManager::kInputContainer);
   mgr->ConnectInput( task, 0, mgr->GetCommonInputContainer());
   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("trackInfo", TObjArray::Class(), AliAnalysisManager::kExchangeContainer);
   AliAnalysisDataContainer *coutput1a = mgr->CreateContainer("eventInfo", AliTRDeventInfo::Class(), AliAnalysisManager::kExchangeContainer);