]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSTrigger.cxx
Corrected call to the static method AliBitPacking::UnpackWord
[u/mrichter/AliRoot.git] / ITS / AliITSTrigger.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
17 /* $Id$ */
18
19
20 #include "AliLog.h"
21 #include "AliRun.h"
22 #include "AliRunLoader.h"
23 #include "AliTriggerInput.h"
24
25 #include "AliITSTrigger.h"
26 #include "AliITSdigitSPD.h"
27 #include "AliITSgeom.h"
28 #include "AliITSLoader.h"
29
30 //______________________________________________________________________
31 ClassImp(AliITSTrigger)
32 ////////////////////////////////////////////////////////////////////////
33 //
34 // Version 1
35 // Modified by D. Elia, C. Jorgensen
36 // March 2006
37 //
38 // Version 0
39 // Written by J. Conrad, E. Lopez Torres 
40 // October 2005
41 //
42 // AliITSTrigger: implementation of the SPD Fast-OR based triggers.
43 //
44 ////////////////////////////////////////////////////////////////////////
45
46 //______________________________________________________________________
47 AliITSTrigger::AliITSTrigger()
48   : AliTriggerDetector()
49 {
50    SetName("ITS");
51    CreateInputs();
52
53    // set parameters to define trigger condition thresholds
54    fGlobalFOThreshold = 1;
55    fHighMultFOThreshold = 100; 
56 }
57
58 //______________________________________________________________________
59 void AliITSTrigger::CreateInputs()
60 {
61    // inputs
62
63    // Do not create inputs again!!
64    if( fInputs.GetEntriesFast() > 0 ) return;
65    
66    fInputs.AddLast( new AliTriggerInput( "ITS_SPD_GFO_L0",     "Global, Fast OR all detectors", 0x01 ) );
67    fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HMULT_L0",   "High Multiplicity",             0x02 ) );
68
69 }
70
71 //______________________________________________________________________
72 void AliITSTrigger::Trigger()
73 {
74
75   //  ********** Get run loader for the current event **********
76   AliRunLoader* runLoader = gAlice->GetRunLoader();
77
78   AliITSLoader* loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
79   AliITSgeom* geom = loader->GetITSgeom();
80   loader->LoadDigits("READ");
81   TTree *treeD = loader->TreeD();
82
83   TObjArray *digDet = 0;
84   digDet = new TObjArray(3);
85
86
87   // Cut on Signal In the Pixel Detector
88   TBranch* br = treeD->GetBranch( "ITSDigitsSPD" );
89   br->SetAddress( &((*digDet)[0]) );
90   ((TClonesArray*)(digDet->At(0)))->Clear();
91
92   MultiplicityTriggers(digDet, treeD, geom);
93   //  GeometryTriggers(digDet, treeD, geom);
94
95   // Debug : FIX change to AliLog
96 //  cout << "=================================================" << endl;
97 //  cout << "  Pixel Trigger Mask ( " << hex << "0x" << GetMask() << " )" << endl << endl;
98 //  cout << " Global Fast OR        " << "0x" << GetInput( "ITS_SPD_GFO_L0"      )->GetValue() << endl;
99 //  cout << " High Multiplicity     " << "0x" << GetInput( "ITS_SPD_HMULT_L0"      )->GetValue() << endl;
100 //  cout << "=================================================" << endl << endl;
101
102 }
103
104 //______________________________________________________________________
105 void AliITSTrigger::MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
106 {
107   // simple FO triggers that only cares about the multiplicity
108
109   Int_t startSPD = geom->GetStartSPD();
110   Int_t lastSPD  = geom->GetLastSPD();
111
112   Int_t totalNumberOfFO = 0;
113   Int_t ndigitsInChip[5];
114
115   // loop over modules (ladders)
116   for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD; moduleIndex++) {
117     treeD->GetEvent(moduleIndex);
118     TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
119     
120     // get number of digits in this module
121     Int_t ndigitsInModule = digits->GetEntriesFast();
122
123     // get number of digits in each chip of the module
124     for( Int_t iChip=0; iChip<5; iChip++ ) {
125         ndigitsInChip[iChip]=0;
126     }   
127     for( Int_t iDig=0; iDig<ndigitsInModule; iDig++ ) {
128         AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(iDig);
129         Int_t column = dp->GetCoord1();
130         Int_t isChip = Int_t(column/32.);
131         ndigitsInChip[isChip]++;
132     }
133     // get number of FOs in the module
134     for( Int_t ifChip=0; ifChip<5; ifChip++ ) {
135         if( ndigitsInChip[ifChip] >= 1 ) {
136                 totalNumberOfFO++;
137         }       
138     }
139   // end of loop over modules
140   }
141
142   // produce input trigger condition
143   if (totalNumberOfFO>=fGlobalFOThreshold) 
144     SetInput( "ITS_SPD_GFO_L0" );
145
146   if (totalNumberOfFO>=fHighMultFOThreshold) 
147     SetInput( "ITS_SPD_HMULT_L0" );
148
149   return;
150
151 }
152
153 //______________________________________________________________________
154 // void AliITSTrigger::GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
155 void AliITSTrigger::GeometryTriggers()
156 {
157
158 //   //   const Int_t nlay = 2;      // not used
159 //   //   const Int_t nlad = 240;    // not used
160 //   //   const Int_t nstave = 40;   // not used
161 //   //   const Int_t ndet = 4;      // not used
162 //   //   const Int_t nchip = 5;     // not used
163 //   //   const Int_t ntotal = 1200;
164   
165 //   Int_t ndigA[5];
166 //   Int_t iFOperlayer[2];
167 //   Int_t iFOperladder[240];
168 //   Int_t iFOperstave[40][2];
169 //   //   Int_t iFOperchip[ntotal];   // not used
170 //   Int_t iFOperChipinStave[20][40][2];
171   
172 //   for (Int_t m=startSPD;m<lastSPD;m++) {
173 //     iFOperladder[m] = 0;
174 //   }
175
176 //   for (Int_t k = 0;k<2;k++){
177 //     iFOperlayer[k] = 0;
178 //     for (Int_t o=0; o<40; o++) {
179 //       iFOperstave[o][k] = 0;
180 //       for (Int_t ich=0; ich<20; ich++) {
181 //      iFOperChipinStave[ich][o][k] = 0;
182 //       }
183 //     }
184 //   }
185
186 //   // nFO = 0.0;
187 //   Int_t mInStaveCounter = 0;
188 //   Int_t checkStave = 0;
189   
190 //   // loop over modules
191 //   for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD; moduleIndex++) {
192 //     treeD->GetEvent(moduleIndex);
193 //     TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
194
195 //     Int_t lay, stav, det;
196 //     geom->GetModuleId(moduleIndex,lay,stav,det);
197
198 //     ndig = digits->GetEntriesFast();
199
200 //     for( Int_t l=0; l<5; l++ ) {
201 //       ndigA[l] = 0 ;
202 //     }
203 //     for( Int_t dig=0; dig<ndig; dig++) {
204 //       AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(dig);
205 //       Int_t column = dp->GetCoord1();
206 //       //   Int_t row = dp->GetCoord2();
207 //       Int_t chip = Int_t(column/32.);
208 //       ndigA[chip]++;
209 //     }
210     
211 //     if (checkStave != stav) {
212 //       mInStaveCounter = 0;
213 //     } else {
214 //       mInStaveCounter += 1;
215 //     }
216
217 //     // m 0,.., 239
218 //     // stav 1,..,40
219 //     // mInStave 0,..,3
220 //     // chipInStave 0,..,19
221     
222 //     //cout << "m " << m << " stav "  << stav  << " mInStave " << mInStaveCounter << " " <<lay << endl;
223     
224 //     for (Int_t ichip=0; ichip<5; ichip++) {
225 //       //Int_t seq = (m*5+ichip);
226 //       Int_t chipInStave = (mInStaveCounter *5) + ichip;
227       
228 //       if (ndigA[ichip] >= 1) {
229 //      iFOperladder[moduleIndex]++;
230 //      iFOperlayer[lay-1]++;
231 //      iFOperstave[stav-1][lay-1]++;
232 //      //iFOperHstave[hstav-1][lay-1]++;
233 //      iFOperChipinStave[chipInStave][stav-1][lay-1]++;
234 //         //    nFO++;
235 //       }
236 //     }
237 //     // SIMPLE FO ---> ANY HIT TRIGGERS
238 //     ndigfo += ndig;
239 //     checkStave = stav;
240 //   } // endl loop over SPD's
241
242
243
244 //    if ( ndigfo >= singhitthreshold ) {
245 //       // Set input GLOBAL FO
246 //       SetInput( "ITS_SPD_GFO_L0" );
247 //       // or SetInput( "0x01" );
248 //       // or ((AliTriggerInput*)fInputs.At(0))->Set();
249 //       // bit1 |= (1 << 1);
250 //    }
251
252    // return bit1;
253 }