]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROTrigger.cxx
silvermy@ornl.gov - missed in 1st round; filled MetaData and Id fields also now
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTrigger.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 /* $Id$ */
17
18 #include <TClonesArray.h>
19
20 #include "AliRun.h"
21 #include "AliRunLoader.h"
22
23 #include "AliVZEROTrigger.h"
24
25 //______________________________________________________________________
26 ClassImp(AliVZEROTrigger)
27 ////////////////////////////////////////////////////////////////////////
28 //
29 // Version 1
30 //
31 // AliVZEROTrigger: 
32 //
33 ////////////////////////////////////////////////////////////////////////
34
35 //______________________________________________________________________
36 AliVZEROTrigger::AliVZEROTrigger()
37   :AliTriggerDetector(),
38    fAdcThresHold(0.0),
39    fTimeWindowWidth(50.0)
40    
41 {
42    SetName("VZERO");
43    CreateInputs();
44
45    SetAdcThreshold();
46    SetTimeWindowWidth();
47 }
48
49 //______________________________________________________________________
50 void 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", "VZERO", 0 ) );
58    fInputs.AddLast( new AliTriggerInput( "VZERO_RIGHT","VZERO", 0 ) );
59    fInputs.AddLast( new AliTriggerInput( "VZERO_AND",  "VZERO", 0 ) );
60    fInputs.AddLast( new AliTriggerInput( "VZERO_OR",   "VZERO", 0 ) );
61
62    fInputs.AddLast( new AliTriggerInput( "VZERO_BEAMGAS", "VZERO", 0 ) );
63 }
64
65 //______________________________________________________________________
66 void 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();
76   if (!vzeroDigitsTree) return;
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 
87   Float_t firstTimeLeft  = 9999.0;
88   Float_t firstTimeRight = 9999.0;
89   Float_t TimeHalfWidth  = fTimeWindowWidth/2.0;
90  
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++) {
99       //      vzeroDigitsTree->GetEvent(d);
100       AliVZEROdigit* digit = (AliVZEROdigit*)vzeroDigits->At(d);
101       
102       Int_t   PMNumber   = digit->PMNumber();
103       Float_t adc        = digit->ADC();
104       Float_t tdc        = digit->Time(); // in 100 of picoseconds
105       
106       if (PMNumber<=31 && adc>fAdcThresHold) {
107         if (tdc>(29.0-TimeHalfWidth) && tdc<(29.0+TimeHalfWidth)) nRightDig++;
108         if (tdc<firstTimeRight) firstTimeRight = tdc;
109       }      
110       if (PMNumber>=32 && adc>fAdcThresHold) {
111         if (tdc>(112.0-TimeHalfWidth) && tdc<(112.0+TimeHalfWidth)) nLeftDig++;
112         if (tdc<firstTimeLeft) firstTimeLeft = tdc;
113       } 
114       
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)
128       SetInput( "VZERO_LEFT" );
129
130   if (nRightDig > 0)
131       SetInput( "VZERO_RIGHT" );
132   
133   if (nLeftDig>0 || nRightDig>0) {
134       SetInput( "VZERO_OR" );
135
136     if (nLeftDig>0 && nRightDig>0) {
137         SetInput( "VZERO_AND" );   
138     }
139   }
140   
141   AliDebug(1,Form("VZERO PMs fired: %d (left) %d (right)", nLeftDig, nRightDig));
142  
143   return;
144 }
145
146