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