]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSDigitizerV2.cxx
updated vertex selection
[u/mrichter/AliRoot.git] / MUON / AliMUONSDigitizerV2.cxx
index 4a61a4dc16bc1ec8163eb395c2521d130ceaef4e..f19d0fef45f2bee26fdeade93606d19fc9188fd7 100644 (file)
 // $Id$
 
 #include <TClonesArray.h>
+#include <TParticle.h>
 
 #include "AliMUONSDigitizerV2.h"
 
-#include "AliLog.h"
 #include "AliMUON.h"
 #include "AliMUONChamber.h"
 #include "AliMUONVDigit.h"
 #include "AliMUONHit.h"
-#include "AliMpDEManager.h"
-#include "AliMpCDB.h"
-#include "AliLoader.h"
-#include "AliRun.h"
-#include "AliRunLoader.h"
 #include "AliMUONVDigitStore.h"
 #include "AliMUONVHitStore.h"
-
-#include "AliCDBManager.h"
 #include "AliMUONCalibrationData.h"
 #include "AliMUONResponseTrigger.h"
 
+#include "AliMpCDB.h"
+#include "AliMpDEManager.h"
+
+#include "AliLog.h"
+#include "AliCDBManager.h"
+#include "AliLoader.h"
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliStack.h"
+
 //-----------------------------------------------------------------------------
 /// The sdigitizer performs the transformation from hits (energy deposits by
 /// the transport code) to sdigits (equivalent of charges on pad).
@@ -61,8 +64,9 @@ AliMUONSDigitizerV2::AliMUONSDigitizerV2()
   ///
   /// ctor.
   ///
-  if ( ! AliMpCDB::LoadMpSegmentation() ) 
-  {
+
+  // Load mapping
+  if ( ! AliMpCDB::LoadMpSegmentation() ) {
     AliFatal("Could not access mapping from OCDB !");
   }
 }
@@ -90,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");
@@ -118,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 ) 
   {    
@@ -129,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();
@@ -159,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();
         
@@ -166,14 +183,15 @@ AliMUONSDigitizerV2::Exec(Option_t*)
         TList digits;        
         response->DisIntegrate(*hit,digits);
         
-        TIter next(&digits);
+        TIter nextd(&digits);
         AliMUONVDigit* d;
-        while ( ( d = (AliMUONVDigit*)next() ) )
+        while ( ( d = (AliMUONVDigit*)nextd() ) )
         {
           // 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;