]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- Fix problem with event mixing (TRef annoing stuff ...) by jens
authorjbook <jbook@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 29 Nov 2012 14:45:36 +0000 (14:45 +0000)
committerjbook <jbook@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 29 Nov 2012 14:45:36 +0000 (14:45 +0000)
- add KFparticle/pair creation of gammas (MC)

PWGDQ/dielectron/AliDielectron.cxx
PWGDQ/dielectron/AliDielectronEvent.cxx
PWGDQ/dielectron/AliDielectronEvent.h
PWGDQ/dielectron/AliDielectronMixingHandler.cxx
PWGDQ/dielectron/AliDielectronMixingHandler.h
PWGDQ/dielectron/AliDielectronPair.cxx
PWGDQ/dielectron/AliDielectronPair.h

index 0f54a71fb7da44b91e4ea58c5b9385f39242875d..5e92632df029415ee237163da3074d5c57002881 100644 (file)
@@ -957,6 +957,14 @@ void AliDielectron::FillPairArrays(Int_t arr1, Int_t arr2)
       candidate->SetLabel(label);
       if (label>-1) candidate->SetPdgCode(fPdgMother);
 
+      // check for gamma kf particle
+      label=AliDielectronMC::Instance()->GetLabelMotherWithPdg(candidate,22);
+      if (label>-1) {
+       candidate->SetGammaTracks(static_cast<AliVTrack*>(arrTracks1.UncheckedAt(itrack1)), fPdgLeg1,
+                                 static_cast<AliVTrack*>(arrTracks2.UncheckedAt(itrack2)), fPdgLeg2);
+      // should we set the pdgmothercode and the label
+      }
+
       //pair cuts
       UInt_t cutMask=fPairFilter.IsSelected(candidate);
       
index 3700f43eea2c753f9a8602a8d03b9cce386bfe37..fdb054613a59f418a0ca05e8cb1d5187a2f68b9d 100644 (file)
@@ -26,7 +26,8 @@ Detailed description
 ///////////////////////////////////////////////////////////////////////////
 
 #include <TObjArray.h>
-#include <TMap.h>
+#include <TExMap.h>
+#include <TProcessID.h>
 
 #include <AliVTrack.h>
 #include <AliESDtrack.h>
@@ -42,11 +43,12 @@ AliDielectronEvent::AliDielectronEvent() :
   fArrTrackN(),
   fArrVertex("AliAODVertex",1000),
   fArrPairs("AliKFParticle",0),
-  fMapStoredVertices(0x0),
   fNTracksP(0),
   fNTracksN(0),
   fIsAOD(kFALSE),
-  fEventData()
+  fEventData(),
+  fPID(0x0),
+  fPIDIndex(0)
 {
   //
   // Default Constructor
@@ -61,11 +63,12 @@ AliDielectronEvent::AliDielectronEvent(const char* name, const char* title) :
   fArrTrackN(),
   fArrVertex("AliAODVertex",1000),
   fArrPairs("AliKFParticle",0),
-  fMapStoredVertices(0x0),
   fNTracksP(0),
   fNTracksN(0),
   fIsAOD(kFALSE),
-  fEventData()
+  fEventData(),
+  fPID(0x0),
+  fPIDIndex(0)
 {
   //
   // Named Constructor
@@ -82,8 +85,6 @@ AliDielectronEvent::~AliDielectronEvent()
   fArrTrackN.Delete();
   fArrVertex.Delete();
   fArrPairs.Delete();
-
-  delete fMapStoredVertices;
 }
 
 //______________________________________________
@@ -108,6 +109,8 @@ void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN,
     fArrTrackN.Expand(arrN.GetSize());
   }
 
+  TExMap mapStoredVertices;
+  fPIDIndex=TProcessID::GetPIDs()->IndexOf(fPID);
   // fill particles
   Int_t tracks=0;
   for (Int_t itrack=0; itrack<arrP.GetEntriesFast(); ++itrack){
@@ -127,13 +130,14 @@ void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN,
       // most particles will be assiciated to the primary vertex ...
       AliAODVertex *vtx=track->GetProdVertex();
       AliAODVertex *cvertex = 0x0;
-      if (fMapStoredVertices->FindObject(vtx)) {
-        cvertex = (AliAODVertex*)fMapStoredVertices->GetValue(vtx);
-      } else {
-        if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
-        if (vtx){
+      if (vtx){
+        cvertex = reinterpret_cast<AliAODVertex*>(mapStoredVertices.GetValue(reinterpret_cast<ULong64_t>(vtx)));
+        if (!cvertex) {
+          if (mapStoredVertices.Capacity()<=mapStoredVertices.GetSize()) mapStoredVertices.Expand(2*mapStoredVertices.GetSize());
+          if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
           cvertex = new (fArrVertex[fArrVertex.GetEntriesFast()]) AliAODVertex(*vtx);
-          fMapStoredVertices->Add(vtx,cvertex);
+          AssignID(cvertex);
+          mapStoredVertices.Add(reinterpret_cast<ULong64_t>(vtx),reinterpret_cast<ULong64_t>(cvertex));
         }
       }
       ctrack->SetProdVertex(cvertex);
@@ -160,13 +164,14 @@ void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN,
       // most particles will be assiciated to the primary vertex ...
       AliAODVertex *vtx=track->GetProdVertex();
       AliAODVertex *cvertex = 0x0;
-      if (fMapStoredVertices->FindObject(vtx)) {
-        cvertex = (AliAODVertex*)fMapStoredVertices->GetValue(vtx);
-      } else {
-        if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
-        if (vtx) {
+      if (vtx){
+        cvertex = reinterpret_cast<AliAODVertex*>(mapStoredVertices.GetValue(reinterpret_cast<ULong64_t>(vtx)));
+        if (!cvertex) {
+          if (mapStoredVertices.Capacity()<=mapStoredVertices.GetSize()) mapStoredVertices.Expand(2*mapStoredVertices.GetSize());
+          if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
           cvertex = new (fArrVertex[fArrVertex.GetEntriesFast()]) AliAODVertex(*vtx);
-          fMapStoredVertices->Add(vtx,cvertex);
+          AssignID(cvertex);
+          mapStoredVertices.Add(reinterpret_cast<ULong64_t>(vtx),reinterpret_cast<ULong64_t>(cvertex));
         }
       }
       ctrack->SetProdVertex(cvertex);
@@ -200,9 +205,6 @@ void AliDielectronEvent::Clear(Option_t *opt)
   }
   
   fArrPairs.Clear(opt);
-  
-  if (fMapStoredVertices) fMapStoredVertices->Clear();
-  
 }
 
 //______________________________________________
@@ -214,7 +216,6 @@ void AliDielectronEvent::SetAOD()
   fArrTrackP.SetClass("AliAODTrack",1000);
   fArrTrackN.SetClass("AliAODTrack",1000);
   fIsAOD=kTRUE;
-  if (!fMapStoredVertices) fMapStoredVertices=new TMap;
 }
 
 //______________________________________________
@@ -236,3 +237,18 @@ void AliDielectronEvent::SetEventData(const Double_t data[AliDielectronVarManage
   //
   for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues;++i) fEventData[i]=data[i];
 }
+
+//______________________________________________
+void AliDielectronEvent::AssignID(TObject *obj)
+{
+  //
+  // Custom function to assign a uid to an object with an own process id
+  // to avoid problems buffering the vertices
+  //
+  UInt_t uid=1;
+  if (fPID->GetObjects()) uid=fPID->GetObjects()->GetEntriesFast();
+  uid+=(fPIDIndex<<24);
+  obj->SetBit(kIsReferenced);
+  obj->SetUniqueID(uid);
+  fPID->PutObjectWithID(obj);
+}
index f5e102cd15b740410fb3200acbaffe9aa6194cc2..dad1f022dfb8772ffe709c091e1765d772fcec96 100644 (file)
@@ -20,7 +20,7 @@
 
 
 class TObjArray;
-class TMap;
+class TProcessID;
 
 class AliDielectronEvent : public TNamed {
 public:
@@ -43,6 +43,9 @@ public:
 
   Int_t GetNTracksP() const { return fNTracksP; }
   Int_t GetNTracksN() const { return fNTracksN; }
+
+  void SetProcessID(TProcessID *pid) { fPID=pid;    }
+  const TProcessID* GetProcessID()   { return fPID; }
   
 virtual void Clear(Option_t *opt="C");
 
@@ -54,8 +57,6 @@ private:
 
   TClonesArray fArrPairs;       //Pair array
 
-  TMap *fMapStoredVertices;//! already buffered vertices in AOD
-  
   Int_t fNTracksP;              //number of positive tracks
   Int_t fNTracksN;              //number of negative tracks
 
@@ -63,9 +64,13 @@ private:
 
   Double_t fEventData[AliDielectronVarManager::kNMaxValues]; // event informaion from the var manager
 
+  TProcessID *fPID;             //! internal PID for references to buffered objects
+  UInt_t      fPIDIndex;        //! index of PID
+
   AliDielectronEvent(const AliDielectronEvent &c);
   AliDielectronEvent &operator=(const AliDielectronEvent &c);
 
+  void AssignID(TObject *obj);
   
   ClassDef(AliDielectronEvent,1)         // Dielectron Event
 };
index 1109455c5675c256a6abd2acfc124ebb954229a2..3292ff0138500a213697b4890b3ce071a41d9003 100644 (file)
@@ -48,7 +48,8 @@ AliDielectronMixingHandler::AliDielectronMixingHandler() :
   fAxes(kMaxCuts),
   fMixType(kOSonly),
   fMixIncomplete(kTRUE),
-  fMoveToSameVertex(kFALSE)
+  fMoveToSameVertex(kFALSE),
+  fPID(0x0)
 {
   //
   // Default Constructor
@@ -67,7 +68,8 @@ AliDielectronMixingHandler::AliDielectronMixingHandler(const char* name, const c
   fAxes(kMaxCuts),
   fMixType(kOSonly),
   fMixIncomplete(kTRUE),
-  fMoveToSameVertex(kFALSE)
+  fMoveToSameVertex(kFALSE),
+  fPID(0x0)
 {
   //
   // Named Constructor
@@ -85,6 +87,7 @@ AliDielectronMixingHandler::~AliDielectronMixingHandler()
   // Default Destructor
   //
   fAxes.Delete();
+  delete fPID;
 }
 
 //________________________________________________________________
@@ -165,6 +168,7 @@ void AliDielectronMixingHandler::Fill(const AliVEvent *ev, AliDielectron *diele)
   if(ev->IsA() == AliAODEvent::Class()) event->SetAOD();
   else event->SetESD();
 
+  event->SetProcessID(fPID);
   event->SetTracks(*diele->GetTrackArray(0), *diele->GetTrackArray(1), *diele->GetPairArray(1));
   event->SetEventData(values);
 
@@ -370,6 +374,10 @@ void AliDielectronMixingHandler::Init(const AliDielectron *diele)
       values+=Form("%.2f, ",(*bins)[irow]);
     }
   }
+  
+  if (!fPID){
+    fPID=TProcessID::AddProcessID();
+  }
 
   AliDebug(10,values.Data());
 }
index 6516bf3fc26dd8d1aeec814f26960ef68f158654..6750d35d9c41673c15055062f9e937712f85828b 100644 (file)
@@ -72,7 +72,9 @@ private:
 
   Bool_t fMixIncomplete;  // whether to mix uncomplete bins at the end of the processing
   Bool_t fMoveToSameVertex; //whether to move the mixed tracks to the same vertex position
-
+  
+  TProcessID *fPID;             //! internal PID for references to buffered objects
+  
   void DoMixing(TClonesArray &pool, AliDielectron *diele);
 
   AliDielectronMixingHandler(const AliDielectronMixingHandler &c);
index 4dec2d2da20d0a0c9481ee5a8a476e79c0af38cc..1497a56387b672cb15dbb845dd22af3b099783d6 100644 (file)
@@ -128,6 +128,35 @@ void AliDielectronPair::SetTracks(AliVTrack * const particle1, Int_t pid1,
     fD2+=kf1;
   }
 }
+//______________________________________________
+void AliDielectronPair::SetGammaTracks(AliVTrack * const particle1, Int_t pid1,
+                                      AliVTrack * const particle2, Int_t pid2)
+{
+  //
+  // Sort particles by pt, first particle larget Pt
+  // set AliKF daughters and a GAMMA pair
+  // refParticle1 and 2 are the original tracks. In the case of track rotation
+  // they are needed in the framework
+  //
+  fD1.Initialize();
+  fD2.Initialize();
+
+  AliKFParticle kf1(*particle1,pid1);
+  AliKFParticle kf2(*particle2,pid2);
+  fPair.ConstructGamma(kf1,kf2);
+
+  if (particle1->Pt()>particle2->Pt()){
+    fRefD1 = particle1;
+    fRefD2 = particle2;
+    fD1+=kf1;
+    fD2+=kf2;
+  } else {
+    fRefD1 = particle2;
+    fRefD2 = particle1;
+    fD1+=kf2;
+    fD2+=kf1;
+  }
+}
 
 //______________________________________________
 void AliDielectronPair::SetTracks(const AliKFParticle * const particle1,
index 9c3f916bb2ed896f2292eb29a75a8dbc973e8855..08714be89bf7285855548a013051a2f4d765532a 100644 (file)
@@ -52,6 +52,10 @@ public:
   void SetTracks(AliVTrack * const particle1, Int_t pid1,
                  AliVTrack * const particle2, Int_t pid2);
 
+  void SetGammaTracks(AliVTrack * const particle1, Int_t pid1,
+                     AliVTrack * const particle2, Int_t pid2);
+
+
   void SetTracks(const AliKFParticle * const particle1,
                  const AliKFParticle * const particle2,
                  AliVTrack * const refParticle1,