]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTrigger.C
In case the selected VTrackerData does not offer data at the channel level, we disabl...
[u/mrichter/AliRoot.git] / MUON / MUONTrigger.C
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 /// \ingroup macros
19 /// \file MUONTrigger.C
20 /// \brief This macro is to be used to check the trigger algorithm w/o having to
21 /// (re-)perform simulation and digitalization. 
22 ///
23 /// See full description on the \ref README_trigger page.
24 ///
25 /// \author P.Crochet (LPC)
26
27 #if !defined(__CINT__) || defined(__MAKECINT__)
28 #include "AliRun.h"
29 #include "AliMUON.h"
30 #include "AliMUONDigit.h"
31 #include "AliMUONTriggerElectronics.h"
32 #include "AliMUONCalibrationData.h"
33 #include "AliCDBManager.h"
34 #include "AliMUONDataInterface.h"
35 #include "AliMUONMCDataInterface.h"
36 #include "AliMUONVTriggerStore.h"
37 #include "AliMUONDigitStoreV1.h"
38 #include <TClonesArray.h>
39 #include "AliMpCDB.h"
40 #include <TFile.h>
41 #endif
42
43 void MUONTrigger(const char* filename)
44 {
45     // Creating Run Loader and openning file containing Digits 
46     AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONLoader","UPDATE");
47     if (RunLoader ==0x0) {
48         printf(">>> Error : Error Opening %s file \n",filename);
49         return;
50     }
51     // Loading AliRun master
52     if (RunLoader->GetAliRun() == 0x0) RunLoader->LoadgAlice();
53     gAlice = RunLoader->GetAliRun();
54     
55     // Loading MUON subsystem
56     AliLoader* MUONLoader = RunLoader->GetDetectorLoader("MUON");
57     MUONLoader->LoadDigits("READ");
58     MUONLoader->LoadRecPoints("UPDATE"); // absolutely essential !!!    
59     
60     // Creating MUONTriggerDecision
61     AliCDBManager* cdbManager = AliCDBManager::Instance();
62     cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
63     
64     Int_t runnumber = cdbManager->GetRun();
65     AliMpCDB::LoadDDLStore();
66     
67     AliMUONCalibrationData *CalibrationData = new AliMUONCalibrationData(runnumber);
68     AliMUONTriggerElectronics *TriggerProcessor = new AliMUONTriggerElectronics(CalibrationData);
69     
70     Int_t nevents = RunLoader->GetNumberOfEvents();
71     AliMUONVDigitStore* digitStore=0x0;
72     AliMUONVTriggerStore* triggerStore=0x0;
73     
74     for(Int_t ievent = 0; ievent < nevents; ievent++) {
75         printf(">>> Event %i out of %i \n",ievent,nevents);
76         RunLoader->GetRunLoader()->GetEvent(ievent);
77         
78         MUONLoader->LoadRecPoints("update");
79         MUONLoader->CleanRecPoints();
80         MUONLoader->MakeRecPointsContainer();
81         TTree* clustersTree = MUONLoader->TreeR();
82         TFile* cfile = clustersTree->GetCurrentFile();
83         if ( !cfile ) 
84         {
85             cout << " could not find Cluster file " << endl;
86             return;
87         }
88         
89         MUONLoader->LoadDigits("read");
90         TTree* digitsTree = MUONLoader->TreeD();
91         TFile* dfile = digitsTree->GetCurrentFile();
92         if ( !dfile ) 
93         {
94             cout << " could not find Digit file " << endl;
95             return;
96         }
97         
98 // here start reconstruction    
99         if (!digitStore) digitStore = AliMUONVDigitStore::Create(*digitsTree);  
100         if (!triggerStore) triggerStore = AliMUONVTriggerStore::Create(*digitsTree);
101         // insure we start with empty stores
102         if ( digitStore ) 
103         {
104             digitStore->Clear(); 
105             Bool_t alone = ( triggerStore ? kFALSE : kTRUE );
106             Bool_t ok = digitStore->Connect(*digitsTree,alone);
107             if (!ok)
108             {
109                 cerr << "Could not connect digitStore to digitsTree \n";
110                 return;
111             }
112         } else {
113             cerr << "digitStore does not exist " << "\n";
114             return;
115         }
116         
117         digitsTree->GetEvent(0);
118         
119 // process trigger response
120         TriggerProcessor->Digits2Trigger(*digitStore,*triggerStore);
121         
122         //triggerStore->Print();
123         
124         Bool_t ok(kFALSE);
125         if ( triggerStore ) {
126             ok = triggerStore->Connect(*clustersTree,kTRUE);
127             if (!ok)
128             {
129                 cerr << "Could not create triggerStore branches in TreeR " << "\n";
130                 return;
131             }
132         } else {
133             cerr << "triggerStore does not exist " << "\n";
134             return;
135         }
136
137 // fill TreeR
138         clustersTree->Fill();
139         MUONLoader->UnloadDigits();
140         MUONLoader->WriteRecPoints("OVERWRITE");
141         MUONLoader->UnloadRecPoints();
142
143     }  // loop on events
144
145 }
146
147
148