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