- new representation of ESD/MC data inside AliTRDtrackInfo
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 Sep 2008 15:02:46 +0000 (15:02 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 Sep 2008 15:02:46 +0000 (15:02 +0000)
- bug fix in run.C
- change name for check detector task

TRD/qaRec/AliTRDcheckDetector.cxx
TRD/qaRec/AliTRDtrackInfo/AliTRDtrackInfo.cxx
TRD/qaRec/AliTRDtrackInfo/AliTRDtrackInfo.h
TRD/qaRec/AliTRDtrackInfoGen.cxx
TRD/qaRec/run.C

index 6f039df..390cd1c 100644 (file)
@@ -33,7 +33,7 @@
 
 //_______________________________________________________
 AliTRDcheckDetector::AliTRDcheckDetector():
-  AliTRDrecoTask("detChecker", "Basic Detector Checker")
+  AliTRDrecoTask("DetChecker", "Basic Detector Checker")
   ,fPHSdetector(0x0)
   ,fPHSsector(0x0)
   ,fQCLdetector(0x0)
index 1a329c2..a99c74e 100644 (file)
@@ -20,6 +20,7 @@
 //  Reconstruction QA                                                     //
 //                                                                        //
 //  Authors:                                                              //
+//    Alex Bercuci <A.Bercuci@gsi.de>                                     //
 //    Markus Fasel <M.Fasel@gsi.de>                                       //
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 #include "AliTRDtrackInfo.h"
 
 ClassImp(AliTRDtrackInfo)
+ClassImp(AliTRDtrackInfo::AliMCinfo)
+ClassImp(AliTRDtrackInfo::AliESDinfo)
 
 //___________________________________________________
 AliTRDtrackInfo::AliTRDtrackInfo():
   TObject()
-  ,fPDG(0)
-  ,fStatus(0)
   ,fTriggerCluster(-1)
-  ,fId(-1)
-  ,fLabel(0)
-  ,fNClusters(0)
-  ,fNTrackRefs(0)
   ,fTriggerClassName("")
+  ,fNClusters(0)
   ,fTRDtrack(0x0)
   ,fOP(0x0)
+  ,fMC(0x0)
+  ,fESD()
 {
   //
   // Default constructor
   //
 
-  // Set 0-Pointers
-  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
 }
 
-//___________________________________________________
-AliTRDtrackInfo::AliTRDtrackInfo(Int_t pdg):
-  TObject()
-  ,fPDG(pdg)
-  ,fStatus(0)
-  ,fTriggerCluster(-1)
-  ,fId(-1)
-  ,fLabel(0)
-  ,fNClusters(0)
-  ,fNTrackRefs(0)
-  ,fTriggerClassName("")
-  ,fTRDtrack(0x0)
-  ,fOP(0x0)
-{
-  //
-  // PDG constructor
-  //
-
-  // Set 0-Pointers
-  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
-}
 
 //___________________________________________________
 AliTRDtrackInfo::AliTRDtrackInfo(const AliTRDtrackInfo &trdInfo):
   TObject((const TObject&)trdInfo)  
-  ,fPDG(trdInfo.fPDG)
-  ,fStatus(trdInfo.fStatus)
   ,fTriggerCluster(trdInfo.fTriggerCluster)
-  ,fId(trdInfo.fId)
-  ,fLabel(trdInfo.fLabel)
-  ,fNClusters(trdInfo.fNClusters)
-  ,fNTrackRefs(trdInfo.fNTrackRefs)
   ,fTriggerClassName(trdInfo.fTriggerClassName)
+  ,fNClusters(trdInfo.fNClusters)
   ,fTRDtrack(0x0)
   ,fOP(0x0)
+  ,fMC(new AliMCinfo(*trdInfo.fMC))
+  ,fESD(trdInfo.fESD)
 {
   //
   // copy Entries
   //
 
-  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
-  for(Int_t ien = 0; ien < 12; ien++){
-       if(trdInfo.fTrackRefs[ien])
-      fTrackRefs[ien] = new AliTrackReference(*(trdInfo.fTrackRefs[ien]));
-  }
   if(trdInfo.fOP) fOP = new AliExternalTrackParam(*trdInfo.fOP);
+
+  if(trdInfo.fMC) fMC = new AliMCinfo(*trdInfo.fMC);
+
   if(trdInfo.fTRDtrack){ 
     fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack);
     if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner();
@@ -111,6 +83,57 @@ AliTRDtrackInfo::AliTRDtrackInfo(const AliTRDtrackInfo &trdInfo):
 }
 
 //___________________________________________________
+AliTRDtrackInfo::AliMCinfo::AliMCinfo()
+  :fLabel(0)
+  ,fPDG(0)
+  ,fNTrackRefs(0)
+{
+  // Set 0-Pointers
+  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
+}
+
+//___________________________________________________
+AliTRDtrackInfo::AliMCinfo::AliMCinfo(const AliMCinfo &mc)
+  :fLabel(mc.fLabel)
+  ,fPDG(mc.fPDG)
+  ,fNTrackRefs(mc.fNTrackRefs)
+{
+  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
+  for(Int_t ien = 0; ien < 12; ien++){
+       if(mc.fTrackRefs[ien])
+      fTrackRefs[ien] = new AliTrackReference(*(mc.fTrackRefs[ien]));
+  }
+}
+
+//___________________________________________________
+AliTRDtrackInfo::AliESDinfo::AliESDinfo()
+  :fId(-1)
+  ,fStatus(0)
+  ,fTRDpidQuality(0)
+  ,fTRDnSlices(0)
+  ,fTRDslices(0x0)
+{
+  memset(fTRDr, 0, AliPID::kSPECIES*sizeof(Double32_t));
+}
+
+//___________________________________________________
+AliTRDtrackInfo::AliESDinfo::AliESDinfo(const AliESDinfo &esd)
+  :fId(esd.fId)
+  ,fStatus(esd.fStatus)
+  ,fTRDpidQuality(esd.fTRDpidQuality)
+  ,fTRDnSlices(esd.fTRDnSlices)
+  ,fTRDslices(0x0)
+{
+  memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t));
+
+  if(fTRDnSlices){
+    fTRDslices = new Double32_t[fTRDnSlices];
+    memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t));
+  }
+}
+
+
+//___________________________________________________
 AliTRDtrackInfo::~AliTRDtrackInfo()
 {
   //
@@ -118,10 +141,27 @@ AliTRDtrackInfo::~AliTRDtrackInfo()
   //
 
   if(fOP) delete fOP;
+  if(fTRDtrack) delete fTRDtrack;
+}
+
+//___________________________________________________
+AliTRDtrackInfo::AliMCinfo::~AliMCinfo()
+{
+  fNTrackRefs = 0;
   for(Int_t ien = 0; ien < 12; ien++){
     if(fTrackRefs[ien]) delete fTrackRefs[ien];
+    fTrackRefs[ien] = 0x0;
+  }
+}
+
+//___________________________________________________
+AliTRDtrackInfo::AliESDinfo::~AliESDinfo()
+{
+  if(fTRDnSlices){
+    delete [] fTRDslices;
+    fTRDslices = 0x0;
+    fTRDnSlices = 0;
   }
-  if(fTRDtrack) delete fTRDtrack;
 }
 
 
@@ -132,28 +172,24 @@ AliTRDtrackInfo& AliTRDtrackInfo::operator=(const AliTRDtrackInfo &trdInfo)
   // = Operator
   //
 
-  fPDG    = trdInfo.fPDG;
-  fStatus = trdInfo.fStatus;
-  fId     = trdInfo.fId;
-  fLabel  = trdInfo.fLabel;
   fNClusters  = trdInfo.fNClusters;
-  fNTrackRefs = trdInfo.fNTrackRefs;
+  fESD = trdInfo.fESD;
 
   // copy Entries
-  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
-  for(Int_t ien = 0; ien < 12; ien++){
-    if(trdInfo.fTrackRefs[ien])
-       if(!fTrackRefs[ien])
-               fTrackRefs[ien] = new AliTrackReference(*(trdInfo.fTrackRefs[ien]));
-       else
-               new(&fTrackRefs[ien]) AliTrackReference(*(trdInfo.fTrackRefs[ien]));
-  }
   if(trdInfo.fOP){
        if(!fOP)
                fOP = new AliExternalTrackParam(*trdInfo.fOP);
        else
                new(fOP) AliExternalTrackParam(*trdInfo.fOP);
   }
+
+  if(trdInfo.fMC){
+       if(!fMC)
+               fMC = new AliMCinfo(*trdInfo.fMC);
+       else
+               new(fMC) AliMCinfo(*trdInfo.fMC);
+  }
+
   if(trdInfo.fTRDtrack){
        if(!fTRDtrack)
                fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack);
@@ -166,25 +202,53 @@ AliTRDtrackInfo& AliTRDtrackInfo::operator=(const AliTRDtrackInfo &trdInfo)
 }
 
 //___________________________________________________
+AliTRDtrackInfo::AliMCinfo& AliTRDtrackInfo::AliMCinfo::operator=(const AliMCinfo &mc)
+{
+  fLabel      = mc.fLabel;
+  fPDG        = mc.fPDG;
+  fNTrackRefs = mc.fNTrackRefs;
+
+  AliTrackReference **itr = &fTrackRefs[0];
+  AliTrackReference* const *jtr = &mc.fTrackRefs[0];
+  for(Int_t ien = 0; ien < 12; ien++, itr++, jtr++){
+    if((*jtr)){
+      if(!(*itr)) (*itr) = new AliTrackReference(*(*jtr));
+      else new(&(*itr)) AliTrackReference(*(*jtr));
+    } else (*itr) = 0x0;
+  }
+  return *this;
+}
+
+//___________________________________________________
+AliTRDtrackInfo::AliESDinfo& AliTRDtrackInfo::AliESDinfo::operator=(const AliESDinfo &esd)
+{
+  fId          = esd.fId;
+  fStatus      = esd.fStatus; 
+  fTRDpidQuality = esd.fTRDpidQuality;
+  fTRDnSlices  = esd.fTRDnSlices;
+  fTRDslices   = 0x0;
+
+  memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t));
+
+  if(fTRDnSlices){
+    fTRDslices = new Double32_t[fTRDnSlices];
+    memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t));
+  }
+
+  return *this;
+}
+
+//___________________________________________________
 void AliTRDtrackInfo::Delete(const Option_t *)
 {
   //
   // Delete
   //
 
-  fPDG    = 0;
-  fStatus = 0;
-  fId     = -1;
-  fLabel  = 0;
   fNClusters  = 0;
-  fNTrackRefs = 0;
   if(fOP) delete fOP; fOP = 0x0;
+  if(fMC) delete fMC; fMC = 0x0;
   if(fTRDtrack) delete fTRDtrack; fTRDtrack = 0x0;
-  for(Int_t ien = 0; ien < 12; ien++){
-    if(fTrackRefs[ien])
-      delete fTrackRefs[ien];
-  }
-  memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
 }
 
 
@@ -210,12 +274,13 @@ void AliTRDtrackInfo::AddTrackRef(const AliTrackReference *tref)
   // Add track reference
   //
 
-  if(fNTrackRefs >= 12){ 
+  SetMC();
+  if(fMC->fNTrackRefs >= 12){ 
     SetCurved();
     return;
   }
   // Make a copy for the object in order to avoid ownership problems
-  fTrackRefs[fNTrackRefs++] = new AliTrackReference(*tref);
+  fMC->fTrackRefs[fMC->fNTrackRefs++] = new AliTrackReference(*tref);
 }
 
 //___________________________________________________
@@ -235,8 +300,8 @@ AliTrackReference * AliTRDtrackInfo::GetTrackRef(Int_t idx) const
   //
   // Returns a track reference
   //
-
-  return idx < 12 ? fTrackRefs[idx] : 0x0;
+  if(!fMC) return 0x0;
+  return idx < 12 ? fMC->fTrackRefs[idx] : 0x0;
 }
 
 //___________________________________________________
@@ -281,3 +346,20 @@ Int_t AliTRDtrackInfo::GetNTracklets() const
        if(!fTRDtrack) return 0x0;
        return fTRDtrack->GetNumberOfTracklets();
 }
+
+//___________________________________________________
+void AliTRDtrackInfo::SetSlices(Int_t n, Double32_t *s)
+{
+  if(fESD.fTRDnSlices != n){
+    fESD.fTRDnSlices = 0;
+    delete [] fESD.fTRDslices;
+    fESD.fTRDslices = 0x0;
+  }
+
+  if(!fESD.fTRDnSlices){
+    fESD.fTRDnSlices = n;
+    fESD.fTRDslices = new Double32_t[n];
+  }
+
+  memcpy(fESD.fTRDslices, s, n*sizeof(Double32_t));
+}
index bb65a0b..eab8719 100644 (file)
 #include "TObject.h"
 #endif
 
+#ifndef ALIPID_H
+#include "AliPID.h"
+#endif
+
 class AliTRDseedV1;
 class AliTRDtrackV1;
 class AliTrackReference;
 class AliExternalTrackParam;
 class AliTRDtrackInfo : public TObject{
 public:
+  class AliESDinfo{
+  friend class AliTRDtrackInfo;
+  public:
+    AliESDinfo();
+    AliESDinfo(const AliESDinfo&);
+    virtual ~AliESDinfo();
+    AliESDinfo& operator=(const AliESDinfo&);
+
+    Int_t       GetId() const {return fId;}
+    ULong_t     GetStatus() const {return fStatus;}
+    UChar_t     GetPidQuality() const {return fTRDpidQuality;}
+    Int_t       GetNSlices() const {return fTRDnSlices;}
+    Double32_t* GetSliceIter() const {return fTRDslices;}
+    Double32_t* GetResponseIter() {return &fTRDr[0];}
+  protected:
+    Int_t       fId;            // ESD track id
+    ULong_t     fStatus;        // ESD track status
+    Double32_t  fTRDr[AliPID::kSPECIES];  
+    UChar_t     fTRDpidQuality; // TRD PID quality
+    Int_t       fTRDnSlices;    // number of slices used for PID
+    Double32_t *fTRDslices;     //[fTRDnSlices] 
+
+    ClassDef(AliESDinfo, 1)     // ESD info related to TRD
+  };
+
+  class AliMCinfo{
+  friend class AliTRDtrackInfo;
+  public:
+    AliMCinfo();
+    AliMCinfo(const AliMCinfo&);
+    virtual ~AliMCinfo();
+    AliMCinfo& operator=(const AliMCinfo&);
+    Int_t   GetLabel() const {return fLabel;}
+    Int_t   GetNTrackRefs() const {return fNTrackRefs;}
+    Int_t   GetPDG() const {return fPDG;}
+    AliTrackReference** GetTrackRefIter() {return &fTrackRefs[0];}
+  protected:
+    Int_t   fLabel;             // MC label  
+    Int_t   fPDG;               // particle code
+    Int_t   fNTrackRefs;       // number of track refs
+    AliTrackReference  *fTrackRefs[12];        // track refs array
+    ClassDef(AliMCinfo, 1)      // MC info related to TRD
+  };
+
   AliTRDtrackInfo();
-  AliTRDtrackInfo(Int_t pdg);
   AliTRDtrackInfo(const AliTRDtrackInfo &);
   ~AliTRDtrackInfo();
   
@@ -33,14 +80,16 @@ public:
   
   void               AddTrackRef(const AliTrackReference *trackRef);
   
-  Int_t              GetTrackId() { return fId;}
+  Int_t              GetTrackId() { return fESD.fId;}
+  const AliESDinfo*  GetESDinfo() const { return &fESD; }
+  const AliMCinfo*   GetMCinfo() const { return fMC; }
   Int_t              GetNumberOfClusters() const;
   Int_t              GetNumberOfClustersRefit() const {return fNClusters;}
   Int_t              GetNTracklets() const;
-  Int_t              GetNTrackRefs() const {return fNTrackRefs;} 
-  Int_t              GetLabel() const { return fLabel; }
-  Int_t              GetPDG() const { return fPDG; }
-  ULong_t            GetStatus() const {return fStatus;}
+  Int_t              GetNTrackRefs() const {return fMC ? fMC->fNTrackRefs:0;} 
+  Int_t              GetLabel() const { return fMC ? fMC->fLabel:0; }
+  Int_t              GetPDG() const { return fMC ? fMC->fPDG : 0; }
+  ULong_t            GetStatus() const {return fESD.fStatus;}
   UChar_t            GetTriggerCluster() const {return fTriggerCluster;}
   TString            GetTriggerClassName() const {return fTriggerClassName;}
   AliTRDseedV1*      GetTracklet(Int_t entry) const;
@@ -51,37 +100,52 @@ public:
   Bool_t             IsCurved() const {return TestBit(kCurv);}
   Bool_t                                                IsPrimary() const {return TestBit(kPrim);}
        Bool_t                                           HasESDtrack() const{return ((fTRDtrack != 0x0) ||(fOP != 0));}
-       Bool_t             HasMCinfo() const { return fNTrackRefs > 0; }
+       Bool_t             HasMCinfo() const { return (Bool_t)fMC; }
 
   void               SetCurved(Bool_t curv = kTRUE) {SetBit(kCurv, curv);}
-  void               SetLabel(Int_t lab) { fLabel = lab; }
+  void               SetLabel(Int_t lab) { SetMC(); fMC->fLabel = lab; }
   void               SetNumberOfClustersRefit(Int_t n) {fNClusters = n;}
-  void               SetPDG(Int_t pdg) { fPDG = pdg; }
+  inline void        SetMC();
+  void               SetPDG(Int_t pdg) { SetMC(); fMC->fPDG = pdg; }
   void                                                  SetPrimary(Bool_t prim = kTRUE) {SetBit(kPrim, prim);}
   void               SetOuterParam(const AliExternalTrackParam *op);
-  void               SetStatus(ULong_t stat) {fStatus = stat;}
-  void               SetTrackId(Int_t id) {fId = id;}
+  void               SetStatus(ULong_t stat) {fESD.fStatus = stat;}
+  void               SetTrackId(Int_t id) {fESD.fId = id;}
   void               SetTriggerCluster(Int_t clusterPattern){fTriggerCluster = clusterPattern;}
   void               SetFiredTriggerClass(TString classname){ fTriggerClassName = classname; }
   void               SetTRDtrack(const AliTRDtrackV1 *track);
+  void               SetPidQuality(UChar_t q) { fESD.fTRDpidQuality = q;}
+  void               SetSlices(Int_t n, Double32_t*);
+  inline void        SetResponse(Double32_t *);
   
 private:
        enum{
                kCurv = 14,
                kPrim = 15
        };
-  Int_t              fPDG;             // particle code
-  ULong_t            fStatus;          // ESD track status
+  // this 2 data members have to go to ESD header.
   UChar_t            fTriggerCluster;  // Trigger cluster pattern
-  Int_t              fId;              // ESD track id
-  Int_t              fLabel;           // MC label  
-  Int_t              fNClusters;       // Numer of clusters from refit
-  Int_t              fNTrackRefs;      // number of track refs
   TString            fTriggerClassName; // Name of the fired trigger class
-  AliTrackReference  *fTrackRefs[12];  // no of track refs
-  AliTRDtrackV1      *fTRDtrack;       // no of tracklets
+
+  Int_t              fNClusters;       // Numer of clusters from refit
+  AliTRDtrackV1      *fTRDtrack;           // tracklets data array
   AliExternalTrackParam *fOP;          // outer param if no tracklets
+  AliMCinfo          *fMC;            // MC extract for TRD
+  AliESDinfo         fESD;            // ESD extract for TRD
  
-  ClassDef(AliTRDtrackInfo, 1)          // TRD track info
+  ClassDef(AliTRDtrackInfo, 2)        // TRD track info
 };
+
+//________________________________________________________
+inline void AliTRDtrackInfo::SetMC()
+{
+  if(!fMC) fMC = new AliMCinfo();
+}
+
+//________________________________________________________
+inline void AliTRDtrackInfo::SetResponse(Double32_t *r)
+{
+  memcpy(fESD.fTRDr, r, AliPID::kSPECIES*sizeof(Double32_t));
+}
+
 #endif
index 862b0ca..a1d4de2 100644 (file)
@@ -227,7 +227,8 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
         }*/
       }
 
-      new(fTrackInfo) AliTRDtrackInfo(fPdg);
+      new(fTrackInfo) AliTRDtrackInfo();
+      fTrackInfo->SetPDG(fPdg);
       fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary());
       Int_t jref = iref;//, kref = 0;
       while(jref<nRefs){
@@ -250,7 +251,8 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
       }
       if(fDebugLevel>=2) printf("NtrackRefs[%d(%d)]\n", fTrackInfo->GetNTrackRefs(), nRefs);
     } else {
-      new (fTrackInfo) AliTRDtrackInfo(fPdg);
+      new (fTrackInfo) AliTRDtrackInfo();
+      fTrackInfo->SetPDG(fPdg);
     }
 
     // copy some relevant info to TRD track info
@@ -315,7 +317,8 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
       Int_t nRefs = mcParticle->GetNumberOfTrackReferences();
       Int_t iref = 0; AliTrackReference *ref = 0x0; 
       Int_t nRefsTRD = 0;
-      new(fTrackInfo) AliTRDtrackInfo(fPdg);
+      new(fTrackInfo) AliTRDtrackInfo();
+      fTrackInfo->SetPDG(fPdg);
       while(iref<nRefs){
         ref = mcParticle->GetTrackReference(iref);
         if(fDebugLevel > 3) printf("\ttrackRef[%2d] @ %7.3f", iref, ref->LocalX());
index eae91a0..85234ae 100644 (file)
@@ -224,7 +224,7 @@ void run(Char_t *tasks="ALL", const Char_t *files=0x0, Int_t nmax=-1)
 
 
   //____________________________________________
-  // TRD pid checker
+  // TRD pid reference 
   if(TESTBIT(fSteerTask, kPIDRefMaker)){
     mgr->AddTask(task = new AliTRDpidRefMaker());
     taskPtr[(Int_t)kPIDRefMaker] = task;
@@ -234,6 +234,8 @@ void run(Char_t *tasks="ALL", const Char_t *files=0x0, Int_t nmax=-1)
     // Create containers for input/output
     mgr->ConnectInput( task, 0, coutput1);
     mgr->ConnectOutput(task, 0, mgr->CreateContainer(task->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("TRD.Task%s.root", task->GetName())));
+    mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("%sNN", task->GetName()), TTree::Class(), AliAnalysisManager::kOutputContainer, Form("TRD.Task%sNN.root", task->GetName())));
+    mgr->ConnectOutput(task, 2, mgr->CreateContainer(Form("%sLQ", task->GetName()), TTree::Class(), AliAnalysisManager::kOutputContainer, Form("TRD.Task%sLQ.root", task->GetName())));
   }