1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <TClonesArray.h>
21 #include "AliRunLoader.h"
23 #include "AliVZEROTrigger.h"
25 //______________________________________________________________________
26 ClassImp(AliVZEROTrigger)
27 ////////////////////////////////////////////////////////////////////////
33 ////////////////////////////////////////////////////////////////////////
35 //______________________________________________________________________
36 AliVZEROTrigger::AliVZEROTrigger()
37 :AliTriggerDetector(),
39 fTimeWindowWidth(50.0)
49 //______________________________________________________________________
50 void AliVZEROTrigger::CreateInputs()
54 // Do not create inputs again!!
55 if( fInputs.GetEntriesFast() > 0 ) return;
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 ) );
62 fInputs.AddLast( new AliTriggerInput( "VZERO_BEAMGAS", "VZERO", 0 ) );
65 //______________________________________________________________________
66 void AliVZEROTrigger::Trigger()
69 // ********** Get run loader for the current event **********
70 AliRunLoader* runLoader = gAlice->GetRunLoader();
72 AliVZEROLoader* loader = (AliVZEROLoader* )runLoader->GetLoader( "VZEROLoader" );
74 loader->LoadDigits("READ");
75 TTree* vzeroDigitsTree = loader->TreeD();
76 if (!vzeroDigitsTree) return;
78 TClonesArray* vzeroDigits = new TClonesArray("AliVZEROdigit",1000);
79 TBranch* digitBranch = vzeroDigitsTree->GetBranch("VZERODigit");
80 digitBranch->SetAddress(&vzeroDigits);
82 // number of hits in left/right
87 Float_t firstTimeLeft = 9999.0;
88 Float_t firstTimeRight = 9999.0;
89 Float_t TimeHalfWidth = fTimeWindowWidth/2.0;
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);
96 Int_t nDigits = vzeroDigits->GetEntriesFast();
98 for (Int_t d=0; d<nDigits; d++) {
99 // vzeroDigitsTree->GetEvent(d);
100 AliVZEROdigit* digit = (AliVZEROdigit*)vzeroDigits->At(d);
102 Int_t PMNumber = digit->PMNumber();
103 Float_t adc = digit->ADC();
104 Float_t tdc = digit->Time(); // in 100 of picoseconds
106 if (PMNumber<=31 && adc>fAdcThresHold) {
107 if (tdc>(29.0-TimeHalfWidth) && tdc<(29.0+TimeHalfWidth)) nRightDig++;
108 if (tdc<firstTimeRight) firstTimeRight = tdc;
110 if (PMNumber>=32 && adc>fAdcThresHold) {
111 if (tdc>(112.0-TimeHalfWidth) && tdc<(112.0+TimeHalfWidth)) nLeftDig++;
112 if (tdc<firstTimeLeft) firstTimeLeft = tdc;
115 } // end of loop over digits
116 } // end of loop over events in digits tree
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 ...
124 if (TMath::Abs(TMath::Abs(firstTimeLeft - firstTimeRight)-143) < 20) // time window of 2 ns
125 SetInput( "VZERO_BEAMGAS" );
128 SetInput( "VZERO_LEFT" );
131 SetInput( "VZERO_RIGHT" );
133 if (nLeftDig>0 || nRightDig>0) {
134 SetInput( "VZERO_OR" );
136 if (nLeftDig>0 && nRightDig>0) {
137 SetInput( "VZERO_AND" );
141 AliDebug(1,Form("VZERO PMs fired: %d (left) %d (right)", nLeftDig, nRightDig));