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