]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTrigger.C
New class AliMUONRecoParamto handle reconstruction parameters
[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 "AliMUONLoader.h"
27 #include "AliMUONData.h"
28 #include "AliMUONDigit.h"
29 #include "AliMUONTriggerElectronics.h"
30 #include "AliMUONCalibrationData.h"
31 #include "AliCDBManager.h"
32 #include <TClonesArray.h>
33 #endif
34 void MUONTrigger(char * FileNameSim="galice_sim.root", char * FileName="galice.root")
35 {
36     // Creating Run Loader and openning file containing Digits 
37     AliRunLoader * RunLoader = AliRunLoader::Open(FileName,"MUONLoader","UPDATE");
38     if (RunLoader ==0x0) {
39         printf(">>> Error : Error Opening %s file \n",FileName);
40         return;
41     }
42     // Loading AliRun master
43     if (RunLoader->GetAliRun() == 0x0) RunLoader->LoadgAlice();
44     gAlice = RunLoader->GetAliRun();
45     
46     // Loading MUON subsystem
47     AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
48     MUONLoader->LoadDigits("READ");
49     MUONLoader->LoadRecPoints("UPDATE"); // absolutely essential !!!
50     
51     Int_t nevents;
52     nevents = RunLoader->GetNumberOfEvents();
53     
54     // Creating MUON data container
55     AliMUONData* MUONData = new AliMUONData(MUONLoader,"MUON","MUON");
56     
57     // Creating MUONTriggerDecision
58     TTask *TriggerProcessor;
59     AliCDBManager* cdbManager = AliCDBManager::Instance();
60     cdbManager->SetDefaultStorage("local://$ALICE_ROOT");
61     Int_t runnumber = gAlice->GetRunNumber();
62     AliMUONCalibrationData *CalibrationData = new AliMUONCalibrationData(runnumber);
63     TriggerProcessor = new AliMUONTriggerElectronics(MUONData,CalibrationData);
64     
65     // Testing if Trigger has already been done
66     RunLoader->GetEvent(0);    
67     if (MUONLoader->TreeR()) {
68         if (MUONData->IsTriggerBranchesInTree()) {
69             MUONLoader->UnloadRecPoints();
70             MUONLoader->LoadRecPoints("RECREATE");
71             printf("Recreating recpoints files\n");
72         }
73     }
74     
75     AliMUONDigit * mDigit;    
76     Float_t digits[7];
77     
78     for(Int_t ievent = 0; ievent < nevents; ievent++) {
79         printf(">>> Event %i out of %i \n",ievent,nevents);
80         RunLoader->GetEvent(ievent);
81         MUONData->SetTreeAddress("D");
82         
83         MUONData->GetDigits();
84         for(Int_t ichamber=10; ichamber<14; ichamber++) {           
85             Int_t ndigits = (Int_t) MUONData->Digits(ichamber)->GetEntriesFast();
86             for(Int_t idigit=0; idigit<ndigits; idigit++) {
87                 mDigit = static_cast<AliMUONDigit*>(MUONData->Digits(ichamber)->At(idigit));             
88                 
89                 digits[0] = mDigit->PadX();
90                 digits[1] = mDigit->PadY();
91                 digits[2] = mDigit->Cathode();
92                 digits[3] = mDigit->Charge();
93                 digits[4] = mDigit->Physics();
94                 digits[5] = mDigit->Hit();
95                 digits[6] = mDigit->DetElemId();
96                 
97 //              printf("ichamber ix iy %d %d %d \n",ichamber,mDigit->PadX(),mDigit->PadY());
98                 
99             } // loop on digits
100         } // loop on chambers
101         
102         
103         if (MUONLoader->TreeR() == 0x0) {       
104             MUONLoader->MakeRecPointsContainer();
105         } else {
106             if (MUONData->IsTriggerBranchesInTree()){ 
107                 if (ievent==0) MUONLoader->UnloadRecPoints();
108                 MUONLoader->MakeRecPointsContainer();
109                 cout << "Recreating RecPointsContainer and deleting previous ones" << "\n";
110             }
111         }       
112         
113         MUONData->MakeBranch("TC");     
114         MUONData->SetTreeAddress("TC");
115         TriggerProcessor->ExecuteTask();
116
117         MUONData->Fill("TC");
118         MUONLoader->WriteRecPoints("OVERWRITE");  
119         MUONData->ResetDigits();
120
121     } // loop on events
122     MUONLoader->UnloadDigits();
123     MUONLoader->UnloadRecPoints();
124 }
125