]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONTrigger.C
Update rawdata format for trigger (Christian)
[u/mrichter/AliRoot.git] / MUON / MUONTrigger.C
CommitLineData
a653f08b 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
d6ea26eb 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
19// TreeR.
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.
24//
25// usage: (to be compiled)
26// MUONTrigger("galice.root",0) -> Default Trigger Code
27// MUONTrigger("galice.root",1) -> New Trigger Code
a653f08b 28
29#if !defined(__CINT__) || defined(__MAKECINT__)
30#include "AliRun.h"
31#include "AliMUON.h"
32#include "AliMUONLoader.h"
33#include "AliMUONData.h"
34#include "AliMUONDigit.h"
d6ea26eb 35#include "AliMUONTriggerDecisionV1.h"
36#include "AliMUONTriggerElectronics.h"
37#include "AliMUONCalibrationData.h"
38#include "AliCDBManager.h"
a653f08b 39#endif
d6ea26eb 40void MUONTrigger(char * FileName="galice.root", Int_t NewTriggerCode=0)
a653f08b 41{
42 // Creating Run Loader and openning file containing Digits
43 AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"MUONLoader","UPDATE");
44 if (RunLoader ==0x0) {
29348618 45 printf(">>> Error : Error Opening %s file \n",FileName);
46 return;
a653f08b 47 }
48 // Loading AliRun master
49 if (RunLoader->GetAliRun() == 0x0) RunLoader->LoadgAlice();
50 gAlice = RunLoader->GetAliRun();
51
52 // Loading MUON subsystem
a653f08b 53 AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
54 MUONLoader->LoadDigits("READ");
d6ea26eb 55 MUONLoader->LoadRecPoints("UPDATE"); // absolutely essential !!!
56
57 Int_t nevents;
58 nevents = RunLoader->GetNumberOfEvents();
59
a653f08b 60 // Creating MUON data container
61 AliMUONData* MUONData = new AliMUONData(MUONLoader,"MUON","MUON");
d6ea26eb 62
a653f08b 63 // Creating MUONTriggerDecision
d6ea26eb 64 TTask *TriggerProcessor;
65 if (NewTriggerCode == 0) {
66 cout << " using default trigger code " << "\n";
67 TriggerProcessor = new AliMUONTriggerDecisionV1(MUONData);
68 } else {
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);
75 }
76
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");
84 }
85 }
86
87 AliMUONDigit * mDigit;
a653f08b 88 Int_t digits[7];
89
90 for(Int_t ievent = 0; ievent < nevents; ievent++) {
d6ea26eb 91 printf(">>> Event %i out of %i \n",ievent,nevents);
92 RunLoader->GetEvent(ievent);
93 MUONData->SetTreeAddress("D");
94
29348618 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();
d6ea26eb 99
29348618 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();
109
29348618 110 printf("ichamber ix iy %d %d %d \n",ichamber,mDigit->PadX(),mDigit->PadY());
111
29348618 112 } // loop on digits
113 } // loop on chambers
d6ea26eb 114
115 if (MUONLoader->TreeR() == 0x0) {
116 MUONLoader->MakeRecPointsContainer();
117 } else {
118 if (MUONData->IsTriggerBranchesInTree()){
119 if (ievent==0) MUONLoader->UnloadRecPoints();
120 MUONLoader->MakeRecPointsContainer();
121 cout << "Recreating RecPointsContainer and deleting previous ones" << "\n";
122 }
123 }
124
125 MUONData->MakeBranch("TC");
126 MUONData->SetTreeAddress("TC");
127 TriggerProcessor->ExecuteTask();
128
129 MUONData->Fill("TC");
130 MUONLoader->WriteRecPoints("OVERWRITE");
29348618 131 MUONData->ResetDigits();
d6ea26eb 132
a653f08b 133 } // loop on events
134 MUONLoader->UnloadDigits();
d6ea26eb 135 MUONLoader->UnloadRecPoints();
a653f08b 136}
d6ea26eb 137