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