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