]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROTrigger.cxx
V0A position according to TB decision 13/12/2005.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTrigger.cxx
CommitLineData
7ca4655f 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#include <TClonesArray.h>
19
360938ba 20#include "AliRun.h"
21#include "AliRunLoader.h"
22
23#include "AliVZEROTrigger.h"
24
25//______________________________________________________________________
26ClassImp(AliVZEROTrigger)
27////////////////////////////////////////////////////////////////////////
28//
29// Version 1
30//
31// AliVZEROTrigger:
32//
33////////////////////////////////////////////////////////////////////////
34
35//______________________________________________________________________
36AliVZEROTrigger::AliVZEROTrigger()
0b2bea8b 37 :AliTriggerDetector(),
38 fAdcThresHold(0.0),
39 fTimeWindowWidth(50.0)
40
360938ba 41{
42 SetName("VZERO");
43 CreateInputs();
44
45 SetAdcThreshold();
0b2bea8b 46 SetTimeWindowWidth();
360938ba 47}
48
49//______________________________________________________________________
50void AliVZEROTrigger::CreateInputs()
51{
52 // inputs
53
54 // Do not create inputs again!!
55 if( fInputs.GetEntriesFast() > 0 ) return;
56
57 fInputs.AddLast( new AliTriggerInput( "VZERO_LEFT", "At least one hit in the left VZERO", 0x01 ) );
58 fInputs.AddLast( new AliTriggerInput( "VZERO_RIGHT","At least one hit in the right VZERO", 0x02 ) );
b9d46458 59 fInputs.AddLast( new AliTriggerInput( "VZERO_AND", "At least one hit in the each (left and right) VZERO", 0x04 ) );
60 fInputs.AddLast( new AliTriggerInput( "VZERO_OR", "At least one hit in the one (left one right) VZERO", 0x08 ) );
360938ba 61
b9d46458 62 fInputs.AddLast( new AliTriggerInput( "VZERO_BEAMGAS", "Beam gas VZERO trigger ", 0x010 ) );
360938ba 63}
64
65//______________________________________________________________________
66void AliVZEROTrigger::Trigger()
67{
68
69 // ********** Get run loader for the current event **********
70 AliRunLoader* runLoader = gAlice->GetRunLoader();
71
72 AliVZEROLoader* loader = (AliVZEROLoader* )runLoader->GetLoader( "VZEROLoader" );
73
74 loader->LoadDigits("READ");
75 TTree* vzeroDigitsTree = loader->TreeD();
698b2e52 76 if (!vzeroDigitsTree) return;
360938ba 77
78 TClonesArray* vzeroDigits = new TClonesArray("AliVZEROdigit",1000);
79 TBranch* digitBranch = vzeroDigitsTree->GetBranch("VZERODigit");
80 digitBranch->SetAddress(&vzeroDigits);
81
82 // number of hits in left/right
83 Int_t nLeftDig = 0;
84 Int_t nRightDig = 0;
85
86 // first time
0b2bea8b 87 Float_t firstTimeLeft = 9999.0;
88 Float_t firstTimeRight = 9999.0;
89 Float_t TimeHalfWidth = fTimeWindowWidth/2.0;
2ff50a8f 90
360938ba 91 // loop over vzero entries
92 Int_t nEntries = (Int_t)vzeroDigitsTree->GetEntries();
93 for (Int_t e=0; e<nEntries; e++) {
94 vzeroDigitsTree->GetEvent(e);
95
96 Int_t nDigits = vzeroDigits->GetEntriesFast();
97
98 for (Int_t d=0; d<nDigits; d++) {
dcace375 99 // vzeroDigitsTree->GetEvent(d);
360938ba 100 AliVZEROdigit* digit = (AliVZEROdigit*)vzeroDigits->At(d);
101
20277079 102 Int_t PMNumber = digit->PMNumber();
360938ba 103 Float_t adc = digit->ADC();
104 Float_t tdc = digit->Time(); // in 100 of picoseconds
105
20277079 106 if (PMNumber<=31 && adc>fAdcThresHold) {
c299dbe4 107 if (tdc>(29.0-TimeHalfWidth) && tdc<(29.0+TimeHalfWidth)) nRightDig++;
0b2bea8b 108 if (tdc<firstTimeRight) firstTimeRight = tdc;
109 }
110 if (PMNumber>=32 && adc>fAdcThresHold) {
c299dbe4 111 if (tdc>(112.0-TimeHalfWidth) && tdc<(112.0+TimeHalfWidth)) nLeftDig++;
360938ba 112 if (tdc<firstTimeLeft) firstTimeLeft = tdc;
113 }
0b2bea8b 114
360938ba 115 } // end of loop over digits
116 } // end of loop over events in digits tree
117
118 // Beam gas trigger set from the time difference. The time it takes
119 // to travel between the two counters is ~14.3 ns = 143 * 100 ps.
120 // NB: this should be defined
121 // from time windows relative to the time of the bunch crossing!
122 // beam gas comming from the left ...
123
124 if (TMath::Abs(TMath::Abs(firstTimeLeft - firstTimeRight)-143) < 20) // time window of 2 ns
125 SetInput( "VZERO_BEAMGAS" );
126
127 if (nLeftDig > 0)
0b2bea8b 128 SetInput( "VZERO_LEFT" );
360938ba 129
130 if (nRightDig > 0)
0b2bea8b 131 SetInput( "VZERO_RIGHT" );
360938ba 132
133 if (nLeftDig>0 || nRightDig>0) {
0b2bea8b 134 SetInput( "VZERO_OR" );
360938ba 135
136 if (nLeftDig>0 && nRightDig>0) {
0b2bea8b 137 SetInput( "VZERO_AND" );
360938ba 138 }
139 }
140
2ff50a8f 141 AliDebug(1,Form("VZERO PMs fired: %d (left) %d (right)", nLeftDig, nRightDig));
142
360938ba 143 return;
144}
145
146