]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSDigitizerV2.cxx
updated vertex selection
[u/mrichter/AliRoot.git] / MUON / AliMUONSDigitizerV2.cxx
index 015c7c9ecf12302a6a03ae7afba591fd92a88bef..f19d0fef45f2bee26fdeade93606d19fc9188fd7 100644 (file)
@@ -16,6 +16,7 @@
 // $Id$
 
 #include <TClonesArray.h>
+#include <TParticle.h>
 
 #include "AliMUONSDigitizerV2.h"
 
@@ -36,6 +37,7 @@
 #include "AliLoader.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
+#include "AliStack.h"
 
 //-----------------------------------------------------------------------------
 /// The sdigitizer performs the transformation from hits (energy deposits by
@@ -92,7 +94,7 @@ AliMUONSDigitizerV2::Exec(Option_t*)
   
   AliDebug(1,"");
   
-  AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
+  AliRunLoader* runLoader = AliRunLoader::Instance();
   AliLoader* loader = runLoader->GetDetectorLoader("MUON");
 
   loader->LoadHits("READ");
@@ -120,7 +122,7 @@ AliMUONSDigitizerV2::Exec(Option_t*)
     AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
   }
   
-  AliInfo(Form("Will use digitStore of type %s",sDigitStore->ClassName()));
+  AliDebug(1,Form("Will use digitStore of type %s",sDigitStore->ClassName()));
           
   for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent ) 
   {    
@@ -131,6 +133,17 @@ AliMUONSDigitizerV2::Exec(Option_t*)
     AliDebug(1,Form("iEvent=%d",iEvent));
     runLoader->GetEvent(iEvent);
   
+    // for pile up studies
+    runLoader->LoadKinematics();
+    AliStack* stack = runLoader->Stack();
+    Int_t nparticles = (Int_t) stack->GetNtrack();
+    float T0=10;    // time of the triggered event 
+    // loop to find the time of the triggered event (this may change)
+    for (Int_t iparticle=0; iparticle<nparticles; ++iparticle) {
+      float t = stack->Particle(iparticle)->T();
+      if (TMath::Abs(t)<TMath::Abs(T0)) T0 = t;
+    }
+
     loader->MakeSDigitsContainer();
 
     TTree* treeS = loader->TreeS();
@@ -161,6 +174,8 @@ AliMUONSDigitizerV2::Exec(Option_t*)
       while ( ( hit = static_cast<AliMUONHit*>(next()) ) )       
       {
         Int_t chamberId = hit->Chamber()-1;
+       Float_t age = hit->Age()-T0;
+
         AliMUONChamber& chamber = muon->Chamber(chamberId);
         AliMUONResponse* response = chamber.ResponseModel();
         
@@ -175,7 +190,8 @@ AliMUONSDigitizerV2::Exec(Option_t*)
           // Update some sdigit information that could not be known
           // by the DisIntegrate method
           d->SetHit(ihit);
-          d->AddTrack(iTrack,d->Charge());
+         d->SetTime(age);
+          d->AddTrack(hit->GetTrack(),d->Charge());
           tdlist.Add(d);
         }
         ++ihit;