]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSDigitizerV2.cxx
- Disentangle masks effect from trigger chamber efficiency estimation.
[u/mrichter/AliRoot.git] / MUON / AliMUONSDigitizerV2.cxx
index c99990100b3e945ffba5867af25ef33f7a42f381..0960c203433dcb9f298ae7cc56205a182238173c 100644 (file)
 // $Id$
 
 #include <TClonesArray.h>
+#include <TParticle.h>
+#include <TTree.h>
 
 #include "AliMUONSDigitizerV2.h"
 
-#include "AliLog.h"
 #include "AliMUON.h"
 #include "AliMUONChamber.h"
 #include "AliMUONVDigit.h"
 #include "AliMUONHit.h"
+#include "AliMUONVDigitStore.h"
+#include "AliMUONVHitStore.h"
+#include "AliMUONResponseTrigger.h"
+#include "AliMUONConstants.h"
+
+#include "AliMpCDB.h"
 #include "AliMpDEManager.h"
+
+#include "AliLog.h"
+#include "AliCDBManager.h"
 #include "AliLoader.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
-#include "AliMUONVDigitStore.h"
-#include "AliMUONVHitStore.h"
 
-///
+#include "AliHeader.h"
+#include "AliGenCocktailEventHeader.h"
+
+//-----------------------------------------------------------------------------
 /// The sdigitizer performs the transformation from hits (energy deposits by
 /// the transport code) to sdigits (equivalent of charges on pad).
 ///
 /// Please note that we do *not* merge sdigits after creation, which means
 /// that after sdigitization, a given pad can have several sdigits. This
 /// merging is taken care of later on by the digitizer(V3).
-///
+//-----------------------------------------------------------------------------
 
 ClassImp(AliMUONSDigitizerV2)
 
+Float_t  AliMUONSDigitizerV2::fgkMaxIntTime = 10.0;
+Float_t  AliMUONSDigitizerV2::fgkMaxPosTimeDif = 1.22E-6;
+Float_t  AliMUONSDigitizerV2::fgkMaxNegTimeDif = -3.5E-6;
+Float_t  AliMUONSDigitizerV2::fgkMinTimeDif = 25E-9;
+
 //_____________________________________________________________________________
 AliMUONSDigitizerV2::AliMUONSDigitizerV2() 
 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
@@ -56,6 +72,11 @@ AliMUONSDigitizerV2::AliMUONSDigitizerV2()
   ///
   /// ctor.
   ///
+
+  // Load mapping
+  if ( ! AliMpCDB::LoadMpSegmentation() ) {
+    AliFatal("Could not access mapping from OCDB !");
+  }
 }
 
 //_____________________________________________________________________________
@@ -81,13 +102,13 @@ AliMUONSDigitizerV2::Exec(Option_t*)
   
   AliDebug(1,"");
   
-  AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
+  AliRunLoader* runLoader = AliRunLoader::Instance();
   AliLoader* loader = runLoader->GetDetectorLoader("MUON");
 
   loader->LoadHits("READ");
   
   AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
-    
+  
   Int_t nofEvents(runLoader->GetNumberOfEvents());
   
   TString classname = muon->DigitStoreClassName();
@@ -99,8 +120,10 @@ 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()));
           
+  // average arrival time to chambers, for pileup studies
+
   for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent ) 
   {    
     // Loop over events.
@@ -110,6 +133,29 @@ AliMUONSDigitizerV2::Exec(Option_t*)
     AliDebug(1,Form("iEvent=%d",iEvent));
     runLoader->GetEvent(iEvent);
   
+    // for pile up studies
+    float t0=fgkMaxIntTime;  int aa=0;
+    AliHeader* header = runLoader->GetHeader();   
+    AliGenCocktailEventHeader* cocktailHeader =
+      dynamic_cast<AliGenCocktailEventHeader*>(header->GenEventHeader());
+    if (cocktailHeader) {
+      AliGenCocktailEventHeader* genEventHeader = (AliGenCocktailEventHeader*) (header->GenEventHeader());
+      TList* headers = genEventHeader->GetHeaders();
+      TIter nextH(headers);
+      AliGenEventHeader *entry; 
+      while((entry = (AliGenEventHeader*)nextH())) {
+       float t = entry->InteractionTime();     
+       if (TMath::Abs(t)<TMath::Abs(t0)) t0 = t;      
+       aa++;
+      }
+    } else {
+      AliGenEventHeader* evtHeader = 
+       (AliGenEventHeader*)(header->GenEventHeader());
+      float t = evtHeader->InteractionTime();          
+      if (TMath::Abs(t)<TMath::Abs(t0)) t0 = t;           
+      aa++;
+    }
+
     loader->MakeSDigitsContainer();
 
     TTree* treeS = loader->TreeS();
@@ -139,22 +185,40 @@ AliMUONSDigitizerV2::Exec(Option_t*)
       
       while ( ( hit = static_cast<AliMUONHit*>(next()) ) )       
       {
-        Int_t chamberId = hit->Chamber()-1;
+       Int_t chamberId = hit->Chamber()-1;
+       Float_t age = hit->Age()-t0;
+
         AliMUONChamber& chamber = muon->Chamber(chamberId);
         AliMUONResponse* response = chamber.ResponseModel();
         
         // This is the heart of this method : the dis-integration
         TList digits;        
-        response->DisIntegrate(*hit,digits);
+       if (aa>1){  // if there are pileup events
+         Float_t chamberTime = AliMUONConstants::AverageChamberT(chamberId);
+         Float_t timeDif=age-chamberTime;        
+         if (timeDif>fgkMaxPosTimeDif || timeDif<fgkMaxNegTimeDif) {
+           continue;
+         }
+         if(TMath::Abs(timeDif)>fgkMinTimeDif){
+           response->DisIntegrate(*hit,digits,timeDif);
+         }
+         else{
+           response->DisIntegrate(*hit,digits,0.);
+         }
+       }
+       else{
+         response->DisIntegrate(*hit,digits,0.);
+       }
         
-        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;
@@ -193,4 +257,5 @@ AliMUONSDigitizerV2::Exec(Option_t*)
   loader->UnloadHits();  
   
   delete sDigitStore;
+
 }