AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MUONTrigger.C
Go to the documentation of this file.
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 
26 
27 #if !defined(__CINT__) || defined(__MAKECINT__)
28 #include "AliRun.h"
29 #include "AliMUON.h"
30 #include "AliMUONDigit.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/OCDB");
63 
64  Int_t runnumber = 0;
65  cdbManager->SetRun(runnumber);
67 
68  AliMUONCalibrationData *CalibrationData = new AliMUONCalibrationData(runnumber);
69  AliMUONTriggerElectronics *TriggerProcessor = new AliMUONTriggerElectronics(CalibrationData);
70 
71  Int_t nevents = RunLoader->GetNumberOfEvents();
72  AliMUONVDigitStore* digitStore=0x0;
73  AliMUONVTriggerStore* triggerStore=0x0;
74 
75  for(Int_t ievent = 0; ievent < nevents; ievent++) {
76  printf(">>> Event %i out of %i \n",ievent,nevents);
77  RunLoader->GetEvent(ievent);
78 
79  MUONLoader->LoadRecPoints("update");
80  MUONLoader->CleanRecPoints();
81  MUONLoader->MakeRecPointsContainer();
82  TTree* clustersTree = MUONLoader->TreeR();
83  TFile* cfile = clustersTree->GetCurrentFile();
84  if ( !cfile )
85  {
86  cout << " could not find Cluster file " << endl;
87  return;
88  }
89 
90  MUONLoader->LoadDigits("read");
91  TTree* digitsTree = MUONLoader->TreeD();
92  TFile* dfile = digitsTree->GetCurrentFile();
93  if ( !dfile )
94  {
95  cout << " could not find Digit file " << endl;
96  return;
97  }
98 
99 // here start reconstruction
100  if (!digitStore) digitStore = AliMUONVDigitStore::Create(*digitsTree);
101  if (!triggerStore) triggerStore = AliMUONVTriggerStore::Create(*digitsTree);
102  // insure we start with empty stores
103  if ( digitStore )
104  {
105  digitStore->Clear();
106  Bool_t alone = ( triggerStore ? kFALSE : kTRUE );
107  Bool_t ok = digitStore->Connect(*digitsTree,alone);
108  if (!ok)
109  {
110  cerr << "Could not connect digitStore to digitsTree \n";
111  return;
112  }
113  } else {
114  cerr << "digitStore does not exist " << "\n";
115  return;
116  }
117 
118  digitsTree->GetEvent(0);
119 
120 // process trigger response
121  TriggerProcessor->Digits2Trigger(*digitStore,*triggerStore);
122 
123  //triggerStore->Print();
124 
125  Bool_t ok(kFALSE);
126  if ( triggerStore ) {
127  ok = triggerStore->Connect(*clustersTree,kTRUE);
128  if (!ok)
129  {
130  cerr << "Could not create triggerStore branches in TreeR " << "\n";
131  return;
132  }
133  } else {
134  cerr << "triggerStore does not exist " << "\n";
135  return;
136  }
137 
138 // fill TreeR
139  clustersTree->Fill();
140  MUONLoader->UnloadDigits();
141  MUONLoader->WriteRecPoints("OVERWRITE");
142  MUONLoader->UnloadRecPoints();
143 
144  } // loop on events
145 
146 }
147 
148 
149 
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TFile * Open(const char *filename, Long64_t &nevents)
Interface for a digit container.
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
Base class of a trigger information store.
void MUONTrigger(const char *filename)
Definition: MUONTrigger.C:43
Manager class for muon trigger electronics.
virtual AliMUONVDigitStore * Create() const =0
Create an (empty) object of the same concrete class as *this.
virtual AliMUONVStore * Create() const =0
Create an empty copy of this.
AliRun * gAlice
Single entry point to access MUON calibration data.
virtual void Clear(Option_t *opt="")=0
Clear ourselves (i.e. Reset)
virtual void Digits2Trigger(const AliMUONVDigitStore &digitStore, AliMUONVTriggerStore &triggerStore)
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)