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