]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDETrigger.cxx
Update responsibles for MCH, MTR, HMP
[u/mrichter/AliRoot.git] / ACORDE / AliACORDETrigger.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 #include <Riostream.h>
17 #include <TTree.h>
18 #include <TClonesArray.h>
19
20 #include "AliRun.h"
21 #include "AliRunLoader.h"
22 #include "AliACORDETrigger.h"
23 #include "AliACORDEConstants.h"
24
25 //______________________________________________________________________
26 using std::cout;
27 using std::endl;
28 ClassImp(AliACORDETrigger)
29
30 AliACORDETrigger::AliACORDETrigger()
31   :AliTriggerDetector(),
32    fSingleMuon(0),
33    fMultiMuon(0)
34 {
35
36   cout << " ================>>>>>>>>>>>>>>>>> AliACORDETrigger" << endl;
37    SetName("ACORDE");
38    CreateInputs();
39    for (Int_t i=0; i<60; i++) fModuleFired[i]=kFALSE;
40 }
41
42 void AliACORDETrigger::CreateInputs()
43 {
44   // Do not create inputs again!!
45   if( fInputs.GetEntriesFast() > 0 ) return;
46
47   // two acorde triggers, single muon and multicoincidence
48   fInputs.AddLast( new 
49                    AliTriggerInput( "0ASL", 
50                                     "ACORDE", 0 ) );
51   fInputs.AddLast( new 
52                    AliTriggerInput( "0AMU",
53                                     "ACORDE", 0 ) );
54 }
55
56 void AliACORDETrigger::Trigger()
57 {
58   
59   // 1.- Get loaders and pointers
60   // 2.- Loop over all entries
61   //     set temporal variables to default values
62   //     start the loop
63   // 3.- Loop over all digits in an entrie
64   //     Fill temporal arrays
65   //     Find module with lowest time
66   // 4.- Loop over temporal arrays
67   //     Find number of modules within the time window
68   // 5.- Set the relevant trigger
69
70   // 1.- Get loaders and pointers
71   AliRunLoader* runLoader = AliRunLoader::Instance();
72   AliACORDELoader* loader = 
73     (AliACORDELoader* )runLoader->GetLoader( "ACORDELoader" );
74   loader->LoadDigits("READ");
75   TTree* acordeDigitsTree = loader->TreeD();
76   if (!acordeDigitsTree) return;
77   TClonesArray* acordeDigits = new TClonesArray("AliACORDEdigit",1000);
78   TBranch* digitBranch = acordeDigitsTree->GetBranch("ACORDEdigit");
79   digitBranch->SetAddress(&acordeDigits);
80
81   // 2.- Loop over all entries
82   //     set temporal variables to default values
83
84   Int_t MultiMin = AliACORDEConstants::Instance()->MultiMuonThreshold();
85   Float_t time_window = AliACORDEConstants::Instance()->MultiMuonWindow();
86   Int_t MinTimeModule = -1;
87   Float_t MinTime = 1e10;
88   Float_t ModuleTimes[60];
89   for (Int_t i=0; i<60; i++) ModuleTimes[i] = -1.0;
90
91   //     start the loop
92   Int_t nEntries = (Int_t)acordeDigitsTree->GetEntries();
93   cout << " ===AliACORDETrigger=== nEntries  " <<nEntries << endl; 
94   for (Int_t e=0; e<nEntries; e++) {
95     acordeDigitsTree->GetEvent(e);
96     // 3.- Loop over all digits in an entrie
97     //     Fill temporal arrays
98     //     Find module with lowest time
99     Int_t nDigits = acordeDigits->GetEntriesFast();
100     cout << " ===AliACORDETrigger=== nDigits  " <<nDigits << endl; 
101     for (Int_t d=0; d<nDigits; d++) {
102       AliACORDEdigit* digit = (AliACORDEdigit*)acordeDigits->At(d);
103       Int_t module = digit->GetModule();
104       Float_t mod_time = digit->GetTime();
105       ModuleTimes[module-1]=mod_time;
106       if (mod_time < MinTime) {
107         MinTime = mod_time;
108         MinTimeModule = module;
109       }
110     } // end of loop over digits
111   } // end of loop over events in digits tree
112
113   // 4.- Loop over temporal arrays
114   //     Find number of modules within the time window
115   if (MinTimeModule == -1) return;
116   for (Int_t i=0; i<60; i++) {
117     if (ModuleTimes[i]<0) continue;
118     Float_t diff = ModuleTimes[i]-MinTime;
119     if (diff<time_window) {
120       fMultiMuon++;
121       fModuleFired[i]=kTRUE;
122     }
123   }
124   cout << " fSingleMuon " << fSingleMuon
125        << " MinTime " << MinTime
126        << " fMultiMuon " << fMultiMuon << endl;
127   // 5.- Set the relevant trigger
128   fSingleMuon = MinTimeModule;
129   SetInput( "0ASL" );
130   if (fMultiMuon>=MultiMin) SetInput( "0AMU" );
131   return;
132 }