]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONResponseTrigger.cxx
Adding a reminder for coders
[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 //-----------------------------------------------------------------------------
20 // Class AliMUONResponseTrigger
21 // -------------------------------
22 // Implementation 
23 // of RPC response
24 //-----------------------------------------------------------------------------
25
26
27 #include "AliMUONResponseTrigger.h"
28 #include "AliMUON.h"
29 #include "AliMUONDigit.h"
30 #include "AliMUONGeometryTransformer.h"
31 #include "AliMUONHit.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONTriggerEfficiencyCells.h"
34 #include "AliMUONTriggerChamberEfficiency.h"
35
36 #include "AliMpPad.h"
37 #include "AliMpCathodType.h"
38 #include "AliMpPlaneType.h"
39 #include "AliMpSegmentation.h"
40 #include "AliMpVSegmentation.h"
41
42 #include "AliRun.h"
43 #include "AliLog.h"
44 #include "TList.h"
45
46 /// \cond CLASSIMP
47 ClassImp(AliMUONResponseTrigger)
48 /// \endcond
49
50 namespace
51 {
52   AliMUON* muon()
53   {
54     return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
55   }
56
57   void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg,
58                   Double_t& xl, Double_t& yl, Double_t& zl)
59   {  
60   // ideally should be : 
61   // Double_t x,y,z;
62   // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
63   // but while waiting for this geometry singleton, let's go through
64   // AliMUON still.
65   
66     const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
67     transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
68   }
69 }
70
71 //------------------------------------------------------------------   
72 AliMUONResponseTrigger::AliMUONResponseTrigger()
73   : AliMUONResponse(),
74     fTriggerEfficiency(0x0)
75 {
76 /// Default constructor
77 }
78
79 //------------------------------------------------------------------   
80 AliMUONResponseTrigger::~AliMUONResponseTrigger()
81 {
82 /// Destructor
83 }
84
85 //_____________________________________________________________________________
86 void 
87 AliMUONResponseTrigger::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t /*timeDif*/)
88 {
89   /// Generate 2 digits (one on each cathode) from 1 hit, i.e. no cluster-size
90   /// generation (simplest response case).
91   
92   digits.Clear();
93   
94   Float_t xhit = hit.X();
95   Float_t yhit = hit.Y();
96   Float_t zhit = hit.Z();
97   Int_t detElemId = hit.DetElemId();  
98   
99   Double_t x,y,z;
100   Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
101   
102   Float_t tof = hit.Age();
103   Int_t twentyNano(100);
104   if (tof<AliMUONConstants::TriggerTofLimit())
105   {
106     twentyNano=1;
107   }
108
109   Bool_t isTrig[2]={kTRUE,kTRUE};
110   Int_t nboard=0;
111
112   for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
113   {
114     const AliMpVSegmentation* seg 
115       = AliMpSegmentation::Instance()
116         ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
117     
118     AliMpPad pad = seg->PadByPosition(x,y,kFALSE);
119     Int_t ix = pad.GetIx();
120     Int_t iy = pad.GetIy();
121     
122     AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",
123                     xhit,yhit,x,y,z,ix,iy));
124     
125     if ( !pad.IsValid() )
126     {
127       AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z "
128                       "%e,%e,%e ix,iy=%d,%d",detElemId,
129                       cath,
130                       xhit,yhit,x,y,z,ix,iy));
131       continue;
132     }
133     
134     if(fTriggerEfficiency){
135       if(cath==0){
136         nboard = pad.GetLocalBoardId(0);
137         fTriggerEfficiency->IsTriggered(detElemId, nboard, 
138                                         isTrig[0], isTrig[1]);
139       }
140       if(!isTrig[cath]) continue;
141     }    
142     
143     AliMUONDigit* d = new AliMUONDigit(detElemId,pad.GetLocalBoardId(0),
144                                        pad.GetLocalBoardChannel(0),cath);
145     d->SetPadXY(ix,iy);
146
147     //FIXME : a trigger digit can have several locations. 
148     //this is not currently supported by the digit class. Change that or not ?
149     d->SetCharge(twentyNano);
150
151
152     digits.Add(d);   
153   }
154   
155   if ( fTriggerEfficiency ) AliDebug(1,Form("MTReff: DetElemId %i  Board %3i  Fired %i %i", detElemId, nboard, isTrig[0], isTrig[1]));
156 }
157
158
159 //_____________________________________________________________________________
160 void
161 AliMUONResponseTrigger::InitTriggerEfficiency(AliMUONTriggerEfficiencyCells *triggerEfficiency)
162 {
163 /// Initialize trigger chamber efficiency (on demand)
164
165   if ( triggerEfficiency )
166   {
167     AliDebug(1, "Will apply trigger efficiency");
168   }
169   else
170   {
171     AliFatal("I was requested to apply trigger efficiency, but I could "
172              "not get it !");
173   }
174   fTriggerEfficiency = new AliMUONTriggerChamberEfficiency(triggerEfficiency);
175   
176 }