]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONResponseTrigger.cxx
Separating run-dependent mapping data from data, which are not
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseTrigger.cxx
index 352fd4023f51de79f88f688734ea46aac9ef2159..c46d286ac26dffc958e10afb79137afd6390924f 100644 (file)
 /* $Id$ */
 
 
+//-----------------------------------------------------------------------------
+// Class AliMUONResponseTrigger
+// -------------------------------
+// Implementation 
+// of RPC response
+//-----------------------------------------------------------------------------
+
+
 #include "AliMUONResponseTrigger.h"
+#include "AliMUON.h"
+#include "AliMUONDigit.h"
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONHit.h"
+#include "AliMUONConstants.h"
+#include "AliMUONTriggerEfficiencyCells.h"
+
+#include "AliMpPad.h"
+#include "AliMpCathodType.h"
+#include "AliMpPlaneType.h"
+#include "AliMpSegmentation.h"
+#include "AliMpVSegmentation.h"
 
+#include "AliRun.h"
+#include "AliLog.h"
+#include "TList.h"
+
+/// \cond CLASSIMP
 ClassImp(AliMUONResponseTrigger)
+/// \endcond
 
-//------------------------------------------------------------------   
-AliMUONResponseTrigger::AliMUONResponseTrigger()
-  : AliMUONResponse()
+namespace
 {
-// Default constructor
+  AliMUON* muon()
+  {
+    return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
+  }
+
+  void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
+                  Double_t& xl, Double_t& yl, Double_t& zl)
+  {  
+  // ideally should be : 
+  // Double_t x,y,z;
+  // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
+  // but while waiting for this geometry singleton, let's go through
+  // AliMUON still.
+  
+    const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
+    transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
+  }
 }
 
 //------------------------------------------------------------------   
-Int_t AliMUONResponseTrigger::SetGenerCluster(){
-// nothing to be done except return 0
-  return 0; 
-} 
+AliMUONResponseTrigger::AliMUONResponseTrigger()
+  : AliMUONResponse(),
+    fTriggerEfficiency(0x0)
+{
+/// Default constructor
+}
 
 //------------------------------------------------------------------   
-Int_t AliMUONResponseTrigger::DigitResponse(Int_t digit, 
-                                           AliMUONTransientDigit* /*where*/){
-//  only digital (0/1) information available
-  if (digit) digit=1;
-  return digit;
+AliMUONResponseTrigger::~AliMUONResponseTrigger()
+{
+/// Destructor
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONResponseTrigger::DisIntegrate(const AliMUONHit& hit, TList& digits)
+{
+  /// Generate 2 digits (one on each cathode) from 1 hit, i.e. no cluster-size
+  /// generation (simplest response case).
+  
+  digits.Clear();
+  
+  Float_t xhit = hit.X();
+  Float_t yhit = hit.Y();
+  Float_t zhit = 0; // FIXME : should it be hit.Z() ?
+  Int_t detElemId = hit.DetElemId();  
+  
+  Double_t x,y,z;
+  Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
+  
+  Float_t tof = hit.Age();
+  Int_t twentyNano(100);
+  if (tof<AliMUONConstants::TriggerTofLimit())
+  {
+    twentyNano=1;
+  }
 
+  Bool_t isTrig[2]={kTRUE,kTRUE};
 
+  for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
+  {
+    const AliMpVSegmentation* seg 
+      = AliMpSegmentation::Instance()
+        ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
+    
+    AliMpPad pad = seg->PadByPosition(TVector2(x,y),kFALSE);
+    Int_t ix = pad.GetIndices().GetFirst();
+    Int_t iy = pad.GetIndices().GetSecond();
+    
+    AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",
+                    xhit,yhit,x,y,z,ix,iy));
+    
+    if ( !pad.IsValid() )
+    {
+      AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z "
+                      "%e,%e,%e ix,iy=%d,%d",detElemId,
+                      cath,
+                      xhit,yhit,x,y,z,ix,iy));
+      continue;
+    }
+    AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetLocation(0).GetFirst(),
+                                       pad.GetLocation(0).GetSecond(),cath);
+    d->SetPadXY(ix,iy);
 
+    //FIXME : a trigger digit can have several locations. 
+    //this is not currently supported by the digit class. Change that or not ?
+    d->SetCharge(twentyNano);
 
+    if(fTriggerEfficiency){
+      if(cath==0){
+       Int_t nboard = pad.GetLocation(0).GetFirst();
+       fTriggerEfficiency->IsTriggered(detElemId, nboard, 
+                                       isTrig[0], isTrig[1]);
+      }
+      if(!isTrig[cath]) continue;
+    }
+
+    digits.Add(d);   
+  }
+  
+}
 
+
+//_____________________________________________________________________________
+void
+AliMUONResponseTrigger::InitTriggerEfficiency(AliMUONTriggerEfficiencyCells *triggerEfficiency)
+{
+/// Initialize trigger chamber efficiency (on demand)
+
+  fTriggerEfficiency = triggerEfficiency;
+  if ( fTriggerEfficiency )
+  {
+    AliDebug(1, "Will apply trigger efficiency");
+  }
+  else
+  {
+    AliFatal("I was requested to apply trigger efficiency, but I could "
+            "not get it !");
+  }
+}