]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONResponseTrigger.cxx
Updates (N. Bastid)
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseTrigger.cxx
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
16 /* $Id$ */
17
18
19 #include "AliMUONResponseTrigger.h"
20
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"
33
34 ClassImp(AliMUONResponseTrigger)
35
36 namespace
37 {
38   AliMUON* muon()
39   {
40     return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
41   }
42
43   void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
44                   Double_t& xl, Double_t& yl, Double_t& zl)
45   {  
46   // ideally should be : 
47   // Double_t x,y,z;
48   // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
49   // but while waiting for this geometry singleton, let's go through
50   // AliMUON still.
51   
52     const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
53     transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
54   }
55
56   AliMUONSegmentation* Segmentation()
57   {
58     static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
59     return segmentation;
60   }
61 }
62
63 const Float_t 
64 AliMUONResponseTrigger::fgkTofLimit = 75E-9;
65
66 //------------------------------------------------------------------   
67 AliMUONResponseTrigger::AliMUONResponseTrigger()
68   : AliMUONResponse()
69 {
70 // Default constructor
71 }
72
73 //------------------------------------------------------------------   
74 Int_t AliMUONResponseTrigger::DigitResponse(Int_t digit, 
75                                             AliMUONTransientDigit* /*where*/) const
76 {
77 //  only digital (0/1) information available
78
79   if (digit) 
80     return kTRUE; 
81   else 
82     return digit;
83
84 }
85
86
87 //_____________________________________________________________________________
88 void 
89 AliMUONResponseTrigger::DisIntegrate(const AliMUONHit& hit, TList& digits)
90 {
91   //
92   // Generate 2 digits (one on each cathode) from 1 hit, i.e. no cluster-size
93   // generation (simplest response case).
94   //
95   
96   digits.Clear();
97   
98   Float_t xhit = hit.X();
99   Float_t yhit = hit.Y();
100   Float_t zhit = 0; // FIXME : should it be hit.Z() ?
101   Int_t detElemId = hit.DetElemId();  
102   
103   Double_t x,y,z;
104   Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
105   
106   Float_t tof = hit.Age();
107   Int_t twentyNano(100);
108   if (tof<fgkTofLimit)
109   {
110     twentyNano=1;
111   }
112   
113   for ( Int_t cath = 0; cath < 2; ++cath )
114   {
115     const AliMpVSegmentation* seg = Segmentation()->GetMpSegmentation(detElemId,cath);
116     
117     AliMpPad pad = seg->PadByPosition(TVector2(x,y),kFALSE);
118     Int_t ix = pad.GetIndices().GetFirst();
119     Int_t iy = pad.GetIndices().GetSecond();
120     
121     AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",
122                     xhit,yhit,x,y,z,ix,iy));
123     
124     if ( !pad.IsValid() )
125     {
126       AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z "
127                       "%e,%e,%e ix,iy=%d,%d",detElemId,
128                       cath,
129                       xhit,yhit,x,y,z,ix,iy));
130       continue;
131     }
132     AliMUONDigit* d = new AliMUONDigit;
133     d->SetDetElemId(detElemId);
134 /* pc 09/02/06 no need for that anymore : trigger is in local numbering
135
136     //FIXME: >> the following code to get the ixGlo and iyGlo is a bad hack 
137     // because trigger has not yet switched to local numbering of its indices !
138     // We should be able to use directly the (local) ix,iy from the pad !
139     const AliMUONTriggerSegmentationV2* old = 
140       dynamic_cast<const AliMUONTriggerSegmentationV2*>
141         (Segmentation()->GetDESegmentation(detElemId,cath));
142     if ( !old )
143     {
144       AliFatal("Got a wrong TriggerSegmentation object! Check that!");
145     }
146     Int_t ixGlo;
147     Int_t iyGlo;
148     old->ILoc2IGlo(ix,iy,ixGlo,iyGlo);
149     if ( xhit < 0 ) ixGlo = -ixGlo;
150     // << end of bad hack.
151     d->SetPadX(ixGlo);
152     d->SetPadY(iyGlo);
153 */
154     d->SetPadX(ix);
155     d->SetPadY(iy);
156
157     d->SetSignal(twentyNano);
158     d->AddPhysicsSignal(d->Signal());
159     d->SetCathode(cath);
160     digits.Add(d);   
161  //   AliDebug(1,Form("Adding digit DE %d Cathode %d (%d,%d) signal %d",
162 //                    detElemId,cath,ixGlo,iyGlo,twentyNano));
163   }
164   
165 //  StdoutToAliDebug(1,digits.Print();); 
166 //  AliDebug(1,Form("Number of digits for detelem %d track %d : %d",
167 //                  hit.DetElemId(),hit.Track(),digits.GetSize()));
168 //   
169 }
170
171
172
173
174