]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrigger.cxx
Simplifying calling test, explicite functions for each type of test
[u/mrichter/AliRoot.git] / MUON / AliMUONTrigger.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 "AliLog.h"
19 #include "AliRun.h"
20 #include "AliRunLoader.h"
21 #include "AliTriggerInput.h"
22
23 #include "AliMUON.h"
24 #include "AliMUONLoader.h"
25 #include "AliMUONData.h"
26 #include "AliMUONDigit.h"
27 #include "AliMUONTriggerDecision.h"
28 #include "AliMUONTrigger.h"
29
30 //----------------------------------------------------------------------
31 ClassImp(AliMUONTrigger)
32
33 //----------------------------------------------------------------------
34 AliMUONTrigger::AliMUONTrigger()
35   : AliTriggerDetector() 
36 {
37    SetName("MUON");
38    CreateInputs();
39 }
40
41 //----------------------------------------------------------------------
42 void AliMUONTrigger::CreateInputs()
43 {
44    // inputs 
45    
46    // Do not create inputs again!!
47    if( fInputs.GetEntriesFast() > 0 ) return;
48    
49    fInputs.AddLast( new AliTriggerInput( "MUON_SPlus_LPt_L0", "Single Plus Low Pt",  0x01 ) );
50    fInputs.AddLast( new AliTriggerInput( "MUON_SPlus_HPt_L0", "Single Plus High Pt", 0x02 ) );
51    fInputs.AddLast( new AliTriggerInput( "MUON_SPlus_All_L0", "Single Plus All",     0x04 ) );
52
53    fInputs.AddLast( new AliTriggerInput( "MUON_SMinus_LPt_L0", "Single Minus Low Pt",  0x08 ) );
54    fInputs.AddLast( new AliTriggerInput( "MUON_SMinus_HPt_L0", "Single Minus High Pt", 0x10 ) );
55    fInputs.AddLast( new AliTriggerInput( "MUON_SMinus_All_L0", "Single Minus All",     0x20 ) );
56
57    fInputs.AddLast( new AliTriggerInput( "MUON_SUndef_LPt_L0", "Single Undefined Low Pt",  0x40 ) );
58    fInputs.AddLast( new AliTriggerInput( "MUON_SUndef_HPt_L0", "Single Undefined High Pt", 0x80 ) );
59    fInputs.AddLast( new AliTriggerInput( "MUON_SUndef_All_L0", "Single Undefined All",     0x100 ) );
60
61    fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_LPt_L0", "Single Unlike Sign pair Low Pt",  0x200 ) );
62    fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_HPt_L0", "Single Unlike Sign pair High Pt", 0x400 ) );
63    fInputs.AddLast( new AliTriggerInput( "MUON_Unlike_All_L0", "Single Unlike Sign pair All",     0x800 ) );
64
65    fInputs.AddLast( new AliTriggerInput( "MUON_Like_LPt_L0", "Single Like Sign pair Low Pt",  0x1000 ) );
66    fInputs.AddLast( new AliTriggerInput( "MUON_Like_HPt_L0", "Single Like Sign pair High Pt", 0x2000 ) );
67    fInputs.AddLast( new AliTriggerInput( "MUON_Like_All_L0", "Single Like Sign pair All",     0x4000 ) );
68 }
69
70 //----------------------------------------------------------------------
71 void AliMUONTrigger::Trigger()
72 {
73
74
75    AliRunLoader* runLoader = gAlice->GetRunLoader();
76
77    AliLoader * MUONLoader = runLoader->GetLoader("MUONLoader");
78    MUONLoader->LoadDigits("READ");
79    // Creating MUON data container
80    AliMUONData* MUONData = new AliMUONData(MUONLoader,"MUON","MUON");
81    MUONData->SetTreeAddress("D");
82    MUONData->GetDigits();
83    Int_t idebug = 1;
84    // Creating MUONTriggerDecision
85    AliMUONTriggerDecision* decision = new AliMUONTriggerDecision(MUONLoader ,idebug,MUONData);
86    AliMUONDigit * mDigit;
87    Int_t tracks[10];
88    Int_t charges[10];
89    Int_t digits[7];
90
91    for(Int_t ichamber=10; ichamber<14; ichamber++) {
92       Int_t idigit, ndigits;
93       ndigits = (Int_t) MUONData->Digits(ichamber)->GetEntriesFast();
94 //            printf(">>> Chamber Cathode ndigits %d %d %d\n",ichamber,icathode,ndigits);
95       for(idigit=0; idigit<ndigits; idigit++) {
96          mDigit = static_cast<AliMUONDigit*>(MUONData->Digits(ichamber)->At(idigit));
97          digits[0] = mDigit->PadX();
98          digits[1] = mDigit->PadY();
99          digits[2] = mDigit->Cathode();
100          digits[3] = mDigit->Signal();
101          digits[4] = mDigit->Physics();
102          digits[5] = mDigit->Hit();
103          digits[6] = mDigit->DetElemId();
104
105          Int_t digitindex = 0 ;
106   //       printf("ichamber ix iy %d %d %d \n",ichamber,mDigit->PadX(),mDigit->PadY());
107
108          decision->AddDigit(ichamber, tracks, charges, digits, digitindex );
109       } // loop on digits
110    } // loop on chambers
111    MUONData->ResetDigits();
112    decision->Trigger();
113    decision->ClearDigits();
114
115    // Set the trigger inputs = "global decision" 
116    Int_t singlePlus[3];  // tot num of single plus
117    Int_t singleMinus[3]; // tot num of single minus
118    Int_t singleUndef[3]; // tot num of single undefined
119    Int_t pairUnlike[3];  // tot num of unlike-sign pairs
120    Int_t pairLike[3];    // tot num of like-sign pairs
121    decision->GetGlobalTrigger(singlePlus, singleMinus, singleUndef, pairUnlike, pairLike);
122
123    if( singlePlus[0] )  SetInput("MUON_SPlus_LPt_L0");
124    if( singlePlus[1] )  SetInput("MUON_SPlus_HPt_L0");
125    if( singlePlus[2] )  SetInput("MUON_SPlus_All_L0");
126    
127    if( singleMinus[0] ) SetInput("MUON_SMinus_LPt_L0");
128    if( singleMinus[1] ) SetInput("MUON_SMinus_HPt_L0");
129    if( singleMinus[2] ) SetInput("MUON_SMinus_All_L0");
130    
131    if( singleUndef[0] ) SetInput("MUON_SUndef_LPt_L0");
132    if( singleUndef[1] ) SetInput("MUON_SUndef_HPt_L0");
133    if( singleUndef[2] ) SetInput("MUON_SUndef_All_L0");
134    
135    if( pairUnlike[0] )  SetInput("MUON_Unlike_LPt_L0");
136    if( pairUnlike[1] )  SetInput("MUON_Unlike_HPt_L0");
137    if( pairUnlike[2] )  SetInput("MUON_Unlike_All_L0");
138    
139    if( pairLike[0] )    SetInput("MUON_Like_LPt_L0");
140    if( pairLike[1] )    SetInput("MUON_Like_HPt_L0");
141    if( pairLike[2] )    SetInput("MUON_Like_All_L0");
142 }