AliMpSegFactory replaced with AliMpSegmentation
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseTrigger.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
30178c30 18
a9e2aefa 19#include "AliMUONResponseTrigger.h"
a9e2aefa 20
885d501b 21#include "AliLog.h"
22#include "AliMUON.h"
23#include "AliMUONDigit.h"
24#include "AliMUONGeometryTransformer.h"
25#include "AliMUONHit.h"
26#include "AliMUONSegmentation.h"
27#include "AliMpPad.h"
28#include "AliMpPlaneType.h"
29#include "AliMpVSegmentation.h"
30#include "AliRun.h"
31#include "TList.h"
32#include "AliMUONTriggerSegmentationV2.h"
d344444e 33#include "AliMUONConstants.h"
885d501b 34
a9e2aefa 35ClassImp(AliMUONResponseTrigger)
36
885d501b 37namespace
38{
885d501b 39 AliMUON* muon()
40 {
41 return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
42 }
43
44 void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
45 Double_t& xl, Double_t& yl, Double_t& zl)
46 {
47 // ideally should be :
48 // Double_t x,y,z;
49 // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
50 // but while waiting for this geometry singleton, let's go through
51 // AliMUON still.
52
53 const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
54 transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
55 }
56
57 AliMUONSegmentation* Segmentation()
58 {
59 static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
60 return segmentation;
61 }
62}
63
a9e2aefa 64//------------------------------------------------------------------
30178c30 65AliMUONResponseTrigger::AliMUONResponseTrigger()
7e4a628d 66 : AliMUONResponse()
30178c30 67{
68// Default constructor
925e6570 69}
30178c30 70
885d501b 71//_____________________________________________________________________________
72void
73AliMUONResponseTrigger::DisIntegrate(const AliMUONHit& hit, TList& digits)
74{
75 //
76 // Generate 2 digits (one on each cathode) from 1 hit, i.e. no cluster-size
77 // generation (simplest response case).
78 //
79
80 digits.Clear();
81
82 Float_t xhit = hit.X();
83 Float_t yhit = hit.Y();
84 Float_t zhit = 0; // FIXME : should it be hit.Z() ?
85 Int_t detElemId = hit.DetElemId();
86
87 Double_t x,y,z;
88 Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
89
90 Float_t tof = hit.Age();
91 Int_t twentyNano(100);
d344444e 92 if (tof<AliMUONConstants::TriggerTofLimit())
885d501b 93 {
94 twentyNano=1;
95 }
96
97 for ( Int_t cath = 0; cath < 2; ++cath )
98 {
99 const AliMpVSegmentation* seg = Segmentation()->GetMpSegmentation(detElemId,cath);
100
101 AliMpPad pad = seg->PadByPosition(TVector2(x,y),kFALSE);
102 Int_t ix = pad.GetIndices().GetFirst();
103 Int_t iy = pad.GetIndices().GetSecond();
104
105 AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",
106 xhit,yhit,x,y,z,ix,iy));
107
108 if ( !pad.IsValid() )
109 {
110 AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z "
111 "%e,%e,%e ix,iy=%d,%d",detElemId,
112 cath,
113 xhit,yhit,x,y,z,ix,iy));
114 continue;
115 }
116 AliMUONDigit* d = new AliMUONDigit;
117 d->SetDetElemId(detElemId);
0a04ebd2 118/* pc 09/02/06 no need for that anymore : trigger is in local numbering
119
885d501b 120 //FIXME: >> the following code to get the ixGlo and iyGlo is a bad hack
121 // because trigger has not yet switched to local numbering of its indices !
122 // We should be able to use directly the (local) ix,iy from the pad !
123 const AliMUONTriggerSegmentationV2* old =
124 dynamic_cast<const AliMUONTriggerSegmentationV2*>
125 (Segmentation()->GetDESegmentation(detElemId,cath));
126 if ( !old )
127 {
128 AliFatal("Got a wrong TriggerSegmentation object! Check that!");
129 }
130 Int_t ixGlo;
131 Int_t iyGlo;
132 old->ILoc2IGlo(ix,iy,ixGlo,iyGlo);
133 if ( xhit < 0 ) ixGlo = -ixGlo;
134 // << end of bad hack.
135 d->SetPadX(ixGlo);
136 d->SetPadY(iyGlo);
0a04ebd2 137*/
138 d->SetPadX(ix);
139 d->SetPadY(iy);
140
885d501b 141 d->SetSignal(twentyNano);
142 d->AddPhysicsSignal(d->Signal());
143 d->SetCathode(cath);
144 digits.Add(d);
145 // AliDebug(1,Form("Adding digit DE %d Cathode %d (%d,%d) signal %d",
146// detElemId,cath,ixGlo,iyGlo,twentyNano));
147 }
148
149// StdoutToAliDebug(1,digits.Print(););
150// AliDebug(1,Form("Number of digits for detelem %d track %d : %d",
151// hit.DetElemId(),hit.Track(),digits.GetSize()));
152//
153}
154
a9e2aefa 155
156
157
158