]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSDigitizerV2.cxx
bookkeep pt hard info when generating on-the-fly pythia events
[u/mrichter/AliRoot.git] / MUON / AliMUONSDigitizerV2.cxx
index a4d596df9cdd90a7b478389b2f7ddff40eaeb65b..6dc06e05bd07180da0444b321b1d9ab3108534b1 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <TClonesArray.h>
 #include <TParticle.h>
+#include <TTree.h>
 
 #include "AliMUONSDigitizerV2.h"
 
@@ -26,7 +27,6 @@
 #include "AliMUONHit.h"
 #include "AliMUONVDigitStore.h"
 #include "AliMUONVHitStore.h"
-#include "AliMUONCalibrationData.h"
 #include "AliMUONResponseTrigger.h"
 #include "AliMUONConstants.h"
 
@@ -67,7 +67,7 @@ Float_t  AliMUONSDigitizerV2::fgkMinTimeDif = 25E-9;
 
 //_____________________________________________________________________________
 AliMUONSDigitizerV2::AliMUONSDigitizerV2() 
-: TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
+: TNamed("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
 {
   ///
   /// ctor.
@@ -89,7 +89,7 @@ AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
 
 //_____________________________________________________________________________
 void
-AliMUONSDigitizerV2::Exec(Option_t*)
+AliMUONSDigitizerV2::Digitize(Option_t*)
 {
   ///
   /// Go from hits to sdigits.
@@ -104,20 +104,10 @@ AliMUONSDigitizerV2::Exec(Option_t*)
   
   AliRunLoader* runLoader = AliRunLoader::Instance();
   AliLoader* loader = runLoader->GetDetectorLoader("MUON");
-
+  
   loader->LoadHits("READ");
   
   AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
-
-  AliMUONCalibrationData *calibrationData = 0x0;
-
-  if(muon->GetTriggerEffCells()){
-    Int_t runnumber = AliCDBManager::Instance()->GetRun();
-    calibrationData = new AliMUONCalibrationData(runnumber);
-    for (Int_t chamber = 10; chamber < 14; chamber++) {
-      ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency
-    }
-  }
   
   Int_t nofEvents(runLoader->GetNumberOfEvents());
   
@@ -131,9 +121,9 @@ AliMUONSDigitizerV2::Exec(Option_t*)
   }
   
   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.
@@ -142,43 +132,52 @@ 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());
+    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++;
+        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++;
+      (AliGenEventHeader*)(header->GenEventHeader());
+      if (evtHeader)
+      {  
+        float t = evtHeader->InteractionTime();                
+        if (TMath::Abs(t)<TMath::Abs(t0)) t0 = t;           
+        aa++;
+      }
+      else
+      {
+        // some generators may not offer a header, if which
+        // case we cannot get the interaction time, so we assume zero
+        t0 = 0.;
+      }
     }
-
+    
     loader->MakeSDigitsContainer();
-
+    
     TTree* treeS = loader->TreeS();
-
+    
     if ( !treeS )
     {
       AliFatal("");
     }
-
+    
     sDigitStore->Connect(*treeS);
     
     TTree* treeH = loader->TreeH();
-
+    
     AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
     hitStore->Connect(*treeH);
     
@@ -188,37 +187,37 @@ AliMUONSDigitizerV2::Exec(Option_t*)
     {
       // Loop over the tracks of this event.
       treeH->GetEvent(iTrack);
-
+      
       AliMUONHit* hit;
       TIter next(hitStore->CreateIterator());
       Int_t ihit(0);
       
       while ( ( hit = static_cast<AliMUONHit*>(next()) ) )       
       {
-       Int_t chamberId = hit->Chamber()-1;
-       Float_t age = hit->Age()-t0;
-
+        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;        
-       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.);
-       }
+        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 nextd(&digits);
         AliMUONVDigit* d;
@@ -227,7 +226,7 @@ AliMUONSDigitizerV2::Exec(Option_t*)
           // Update some sdigit information that could not be known
           // by the DisIntegrate method
           d->SetHit(ihit);
-         d->SetTime(age);
+          d->SetTime(age);
           d->AddTrack(hit->GetTrack(),d->Charge());
           tdlist.Add(d);
         }
@@ -241,17 +240,15 @@ AliMUONSDigitizerV2::Exec(Option_t*)
     
     while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
     {
-      if ( d->Charge() > 0 ) // that check would be better in the disintegrate
-        // method, but to compare with old sdigitizer, it has to be there.
+      d->ChargeInFC(kTRUE);
+      
+      AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
+      if (!added)
       {
-        AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
-        if (!added)
-        {
-          AliError("Could not add digit to digitStore");
-        }
+        AliError("Could not add digit to digitStore");
       }
     }
-
+    
     treeS->Fill();
     
     loader->WriteSDigits("OVERWRITE");
@@ -267,6 +264,5 @@ AliMUONSDigitizerV2::Exec(Option_t*)
   loader->UnloadHits();  
   
   delete sDigitStore;
-
-  if(calibrationData) delete calibrationData;
+  
 }