]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONResponseTrigger.cxx
Introduced new DE names unique to each det element;
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseTrigger.cxx
index b115bd50275d4357bdcc9ba96e7d643d60ac30ea..f48217a47530c27a758e665cf22916372b7fdbcc 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.5  2002/10/23 07:24:56  alibrary
-Introducing Riostream.h
+/* $Id$ */
 
-Revision 1.4  2000/11/20 21:44:17  pcrochet
-some modifications to account for the new class AliMUONResponseTriggerV1
+// -------------------------------
+// Class AliMUONResponseTrigger
+// -------------------------------
+// Implementation 
+// of RPC response
 
-Revision 1.3  2000/07/03 11:54:57  morsch
-AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
-The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
-
-Revision 1.2  2000/06/15 07:58:48  morsch
-Code from MUON-dev joined
-
-Revision 1.1.2.1  2000/06/09 21:48:28  morsch
-Code from AliMUONSegResTrigger.cxx
-
-*/
 
 #include "AliMUONResponseTrigger.h"
-#include "AliSegmentation.h"
-#include <TMath.h>
-#include <TRandom.h>
-#include <Riostream.h> 
-
+#include "AliMUON.h"
+#include "AliMUONDigit.h"
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONHit.h"
+#include "AliMUONSegmentation.h"
+#include "AliMUONTriggerSegmentation.h"
+#include "AliMUONConstants.h"
+
+#include "AliMpPad.h"
+#include "AliMpPlaneType.h"
+#include "AliMpSegmentation.h"
+#include "AliMpVSegmentation.h"
+
+#include "AliRun.h"
+#include "AliLog.h"
+#include "TList.h"
+
+/// \cond CLASSIMP
 ClassImp(AliMUONResponseTrigger)
+/// \endcond
+
+namespace
+{
+  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);
+  }
+
+  AliMUONSegmentation* Segmentation()
+  {
+    static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
+    return segmentation;
+  }
+}
 
 //------------------------------------------------------------------   
-Int_t AliMUONResponseTrigger::SetGenerCluster(){
-// nothing to be done except return 0
-  return 0;
-} 
+AliMUONResponseTrigger::AliMUONResponseTrigger()
+  : AliMUONResponse()
+{
+/// 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;
+  }
+  
+  for ( Int_t cath = 0; cath < 2; ++cath )
+  {
+    const AliMpVSegmentation* seg 
+      = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,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;
+    d->SetDetElemId(detElemId);
+/* pc 09/02/06 no need for that anymore : trigger is in local numbering
+
+    //FIXME: >> the following code to get the ixGlo and iyGlo is a bad hack 
+    // because trigger has not yet switched to local numbering of its indices !
+    // We should be able to use directly the (local) ix,iy from the pad !
+    const AliMUONTriggerSegmentationV2* old = 
+      dynamic_cast<const AliMUONTriggerSegmentationV2*>
+        (Segmentation()->GetDESegmentation(detElemId,cath));
+    if ( !old )
+    {
+      AliFatal("Got a wrong TriggerSegmentation object! Check that!");
+    }
+    Int_t ixGlo;
+    Int_t iyGlo;
+    old->ILoc2IGlo(ix,iy,ixGlo,iyGlo);
+    if ( xhit < 0 ) ixGlo = -ixGlo;
+    // << end of bad hack.
+    d->SetPadX(ixGlo);
+    d->SetPadY(iyGlo);
+*/
+    d->SetPadX(ix);
+    d->SetPadY(iy);
+
+    d->SetSignal(twentyNano);
+    d->AddPhysicsSignal(d->Signal());
+    d->SetCathode(cath);
+    digits.Add(d);   
+ //   AliDebug(1,Form("Adding digit DE %d Cathode %d (%d,%d) signal %d",
+//                    detElemId,cath,ixGlo,iyGlo,twentyNano));
+  }
+  
+//  StdoutToAliDebug(1,digits.Print();); 
+//  AliDebug(1,Form("Number of digits for detelem %d track %d : %d",
+//                  hit.DetElemId(),hit.Track(),digits.GetSize()));
+//   
+}