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