1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // This macro is to be used to check the trigger algorithm w/o having to
17 // (re-)perform simulation and digitalization.
18 // It loads the digits, erase TreeR and store the current trigger output in
20 // The different trigger outputs can be compared by looking at the GLT branch
21 // of TreeD (filled during simulation) and the TC branch of TreeR (filled from
22 // a copy of TreeD during reconstruction or with this macro).
23 // Note: rec points from tracking chamber will be lost.
25 // usage: (to be compiled)
26 // MUONTrigger("galice.root",0) -> Default Trigger Code
27 // MUONTrigger("galice.root",1) -> New Trigger Code
29 #if !defined(__CINT__) || defined(__MAKECINT__)
32 #include "AliMUONLoader.h"
33 #include "AliMUONData.h"
34 #include "AliMUONDigit.h"
35 #include "AliMUONTriggerDecisionV1.h"
36 #include "AliMUONTriggerElectronics.h"
37 #include "AliMUONCalibrationData.h"
38 #include "AliCDBManager.h"
40 void MUONTrigger(char * FileName="galice.root", Int_t NewTriggerCode=0)
42 // Creating Run Loader and openning file containing Digits
43 AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"MUONLoader","UPDATE");
44 if (RunLoader ==0x0) {
45 printf(">>> Error : Error Opening %s file \n",FileName);
48 // Loading AliRun master
49 if (RunLoader->GetAliRun() == 0x0) RunLoader->LoadgAlice();
50 gAlice = RunLoader->GetAliRun();
52 // Loading MUON subsystem
53 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
54 MUONLoader->LoadDigits("READ");
55 MUONLoader->LoadRecPoints("UPDATE"); // absolutely essential !!!
58 nevents = RunLoader->GetNumberOfEvents();
60 // Creating MUON data container
61 AliMUONData* MUONData = new AliMUONData(MUONLoader,"MUON","MUON");
63 // Creating MUONTriggerDecision
64 TTask *TriggerProcessor;
65 if (NewTriggerCode == 0) {
66 cout << " using default trigger code " << "\n";
67 TriggerProcessor = new AliMUONTriggerDecisionV1(MUONData);
69 cout << " using new trigger code " << "\n";
70 AliCDBManager* cdbManager = AliCDBManager::Instance();
71 cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
72 Int_t runnumber = gAlice->GetRunNumber();
73 AliMUONCalibrationData *CalibrationData = new AliMUONCalibrationData(runnumber);
74 TriggerProcessor = new AliMUONTriggerElectronics(MUONData,CalibrationData);
77 // Testing if Trigger has already been done
78 RunLoader->GetEvent(0);
79 if (MUONLoader->TreeR()) {
80 if (MUONData->IsTriggerBranchesInTree()) {
81 MUONLoader->UnloadRecPoints();
82 MUONLoader->LoadRecPoints("RECREATE");
83 printf("Recreating recpoints files\n");
87 AliMUONDigit * mDigit;
90 for(Int_t ievent = 0; ievent < nevents; ievent++) {
91 printf(">>> Event %i out of %i \n",ievent,nevents);
92 RunLoader->GetEvent(ievent);
93 MUONData->SetTreeAddress("D");
95 MUONData->GetDigits();
96 for(Int_t ichamber=10; ichamber<14; ichamber++) {
97 Int_t idigit, ndigits;
98 ndigits = (Int_t) MUONData->Digits(ichamber)->GetEntriesFast();
100 for(idigit=0; idigit<ndigits; idigit++) {
101 mDigit = static_cast<AliMUONDigit*>(MUONData->Digits(ichamber)->At(idigit));
102 digits[0] = mDigit->PadX();
103 digits[1] = mDigit->PadY();
104 digits[2] = mDigit->Cathode();
105 digits[3] = mDigit->Signal();
106 digits[4] = mDigit->Physics();
107 digits[5] = mDigit->Hit();
108 digits[6] = mDigit->DetElemId();
110 printf("ichamber ix iy %d %d %d \n",ichamber,mDigit->PadX(),mDigit->PadY());
113 } // loop on chambers
115 if (MUONLoader->TreeR() == 0x0) {
116 MUONLoader->MakeRecPointsContainer();
118 if (MUONData->IsTriggerBranchesInTree()){
119 if (ievent==0) MUONLoader->UnloadRecPoints();
120 MUONLoader->MakeRecPointsContainer();
121 cout << "Recreating RecPointsContainer and deleting previous ones" << "\n";
125 MUONData->MakeBranch("TC");
126 MUONData->SetTreeAddress("TC");
127 TriggerProcessor->ExecuteTask();
129 MUONData->Fill("TC");
130 MUONLoader->WriteRecPoints("OVERWRITE");
131 MUONData->ResetDigits();
134 MUONLoader->UnloadDigits();
135 MUONLoader->UnloadRecPoints();