]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTriggerChamberEfficiency.C
No more misaligned_geometry
[u/mrichter/AliRoot.git] / MUON / MUONTriggerChamberEfficiency.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 #if !defined(__CINT__) || defined(__MAKECINT__)
19 // ROOT includes
20 #include "TFile.h"
21 #include "TTree.h"
22
23 // MUON includes
24 #include "AliMUONCDB.h"
25 #include "AliMUONTriggerChamberEff.h"
26 #include "AliMUONTriggerEfficiencyCells.h"
27
28 #include "Riostream.h"
29
30 #endif
31
32 // Macro to view and save the trigger chamber efficiency map 
33 // calculated during reconstruction.
34 // Efficiency map can be made available for next simulation.
35
36 // Arguments:
37 //
38 // addMapInSimulation (default kFALSE):
39 //    kTRUE: creates file MUON/Calib/TriggerEfficiency/Run0_99999999_v0_s?.root
40 //           with calculated chamber efficiency which can be used in the next simulation
41 //
42 // inputDir (default "."):
43 //    path to AliESDs.root
44 // outDir (default 0x0)
45 //    directory where to store output file "MUON.TriggerEfficiencyMap.root"
46 //    (if not set outDir=inputDir is assumed)
47
48 void MUONTriggerChamberEfficiency(Bool_t addMapInSimulation=kFALSE,
49                                   const char *inputDir=".",
50                                   const char *outDir=0x0)
51 {
52     char filename[150], outfileDir[150];
53     sprintf(filename,"%s/AliESDs.root",inputDir);
54
55     TFile *file = new TFile(filename,"read");
56     if(!file){
57         cerr << "Cannot find " << filename << "\nExit!" << endl;
58         return;
59     }
60     
61     TTree *esdTree = (TTree*)file->Get("esdTree");
62     if(!esdTree){
63         cerr << "Cannot find esdTree in " << filename << "\nExit!" << endl;
64         return;
65     }
66     
67     AliMUONTriggerChamberEff *chEff = (AliMUONTriggerChamberEff*)esdTree->GetUserInfo()->FindObject("AliMUONTriggerChamberEff");
68     if(!chEff){
69         cerr << "Cannot find AliMUONTriggerChamberEff in esdTree.\nExit!" << endl;
70         return;
71     }
72
73     if(!outDir) sprintf(outfileDir,"%s",inputDir);
74     else sprintf(outfileDir,"%s",outDir);
75
76     chEff->WriteEfficiencyMap(outfileDir);
77     chEff->DisplayEfficiency();
78
79     if(!addMapInSimulation) return;
80
81     char outFileName[150];
82     sprintf(outFileName,"%s/MUON.TriggerEfficiencyMap.root",outfileDir);
83     
84     AliMUONTriggerEfficiencyCells *effCells = new AliMUONTriggerEfficiencyCells(outFileName);
85     AliMUONCDB muonCDB;
86     muonCDB.WriteToCDB("MUON/Calib/TriggerEfficiency",effCells,0,99999999,true);
87 }