2 #include "AliRunLoader.h"
4 #include "AliVZEROTrigger.h"
6 //______________________________________________________________________
7 ClassImp(AliVZEROTrigger)
8 ////////////////////////////////////////////////////////////////////////
14 ////////////////////////////////////////////////////////////////////////
16 //______________________________________________________________________
17 AliVZEROTrigger::AliVZEROTrigger()
18 :AliTriggerDetector(),
20 fTimeWindowWidth(50.0)
30 //______________________________________________________________________
31 void AliVZEROTrigger::CreateInputs()
35 // Do not create inputs again!!
36 if( fInputs.GetEntriesFast() > 0 ) return;
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 ) );
43 fInputs.AddLast( new AliTriggerInput( "VZERO_BEAMGAS", "Beam gas VZERO trigger ", 0x010 ) );
46 //______________________________________________________________________
47 void AliVZEROTrigger::Trigger()
50 // ********** Get run loader for the current event **********
51 AliRunLoader* runLoader = gAlice->GetRunLoader();
53 AliVZEROLoader* loader = (AliVZEROLoader* )runLoader->GetLoader( "VZEROLoader" );
55 loader->LoadDigits("READ");
56 TTree* vzeroDigitsTree = loader->TreeD();
57 if (!vzeroDigitsTree) return;
59 TClonesArray* vzeroDigits = new TClonesArray("AliVZEROdigit",1000);
60 TBranch* digitBranch = vzeroDigitsTree->GetBranch("VZERODigit");
61 digitBranch->SetAddress(&vzeroDigits);
63 // number of hits in left/right
68 Float_t firstTimeLeft = 9999.0;
69 Float_t firstTimeRight = 9999.0;
70 Float_t TimeHalfWidth = fTimeWindowWidth/2.0;
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);
77 Int_t nDigits = vzeroDigits->GetEntriesFast();
79 for (Int_t d=0; d<nDigits; d++) {
80 // vzeroDigitsTree->GetEvent(d);
81 AliVZEROdigit* digit = (AliVZEROdigit*)vzeroDigits->At(d);
83 Int_t PMNumber = digit->PMNumber();
84 Float_t adc = digit->ADC();
85 Float_t tdc = digit->Time(); // in 100 of picoseconds
87 if (PMNumber<=31 && adc>fAdcThresHold) {
88 if (tdc>(29.0-TimeHalfWidth) && tdc<(29.0+TimeHalfWidth)) nRightDig++;
89 if (tdc<firstTimeRight) firstTimeRight = tdc;
91 if (PMNumber>=32 && adc>fAdcThresHold) {
92 if (tdc>(112.0-TimeHalfWidth) && tdc<(112.0+TimeHalfWidth)) nLeftDig++;
93 if (tdc<firstTimeLeft) firstTimeLeft = tdc;
96 } // end of loop over digits
97 } // end of loop over events in digits tree
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 ...
105 if (TMath::Abs(TMath::Abs(firstTimeLeft - firstTimeRight)-143) < 20) // time window of 2 ns
106 SetInput( "VZERO_BEAMGAS" );
109 SetInput( "VZERO_LEFT" );
112 SetInput( "VZERO_RIGHT" );
114 if (nLeftDig>0 || nRightDig>0) {
115 SetInput( "VZERO_OR" );
117 if (nLeftDig>0 && nRightDig>0) {
118 SetInput( "VZERO_AND" );
122 AliDebug(1,Form("VZERO PMs fired: %d (left) %d (right)", nLeftDig, nRightDig));