~formateursroot/formationroot/trunk

« back to all changes in this revision

Viewing changes to Jour5/Solutions/ExoJ2Step1_ORI.C

  • Committer: Daniel CUSSOL
  • Date: 2009-04-08 12:37:31 UTC
  • Revision ID: cussol@in2p3.fr-20090408123731-15oduvlcruyn65bt
Ajout des repertoires des solutions et des fichiers des solutions aux exercices

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define ExoJ2Step1_cxx
 
2
// The class definition in ExoJ2Step1.h has been generated automatically
 
3
// by the ROOT utility TTree::MakeSelector(). This class is derived
 
4
// from the ROOT class TSelector. For more information on the TSelector
 
5
// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
 
6
 
 
7
// The following methods are defined in this file:
 
8
//    Begin():        called every time a loop on the tree starts,
 
9
//                    a convenient place to create your histograms.
 
10
//    SlaveBegin():   called after Begin(), when on PROOF called only on the
 
11
//                    slave servers.
 
12
//    Process():      called for each event, in this function you decide what
 
13
//                    to read and fill your histograms.
 
14
//    SlaveTerminate: called at the end of the loop on the tree, when on PROOF
 
15
//                    called only on the slave servers.
 
16
//    Terminate():    called at the end of the loop on the tree,
 
17
//                    a convenient place to draw/fit your histograms.
 
18
//
 
19
// To use this file, try the following session on your Tree T:
 
20
//
 
21
// Root > T->Process("ExoJ2Step1.C")
 
22
// Root > T->Process("ExoJ2Step1.C","some options")
 
23
// Root > T->Process("ExoJ2Step1.C+")
 
24
//
 
25
 
 
26
 
 
27
// 
 
28
// Ce TSelector correspond a l'etape 1 de l'exercice. 
 
29
//
 
30
 
 
31
#include "ExoJ2Step1.h"
 
32
#include <TH2.h>
 
33
#include <TStyle.h>
 
34
 
 
35
 
 
36
void ExoJ2Step1::Begin(TTree * /*tree*/)
 
37
{
 
38
   // The Begin() function is called at the start of the query.
 
39
   // When running with PROOF Begin() is only called on the client.
 
40
   // The tree argument is deprecated (on PROOF 0 is passed).
 
41
 
 
42
   TString option = GetOption();
 
43
 
 
44
   //
 
45
   // Declaration des histogrammes
 
46
   // Dans cette solution, les pointeurs sur les histogrammes ont ete declares 
 
47
   // comme attributs (champs) proteges de la classe d'analyse. Ils seront donc
 
48
   // "visibles" depuis n'importe quelle methode de la classe. De meme, on a
 
49
   // defini un attribut "saveFile" qui va contenir le pointeur du fichier de 
 
50
   // sauvegarde. Ces attributs sont definis dans le fichier ExoJ2Step1.h. Les 
 
51
   // entetes de declaration des classes (fichier "include" avec l'extension ".h")
 
52
   // inclus dans le fichier ExoJ2Step1.h.
 
53
   // Cette technique permet d'eviter les appels a gROOT->FindObject("nomDObjet)) qui
 
54
   // sont couteux en temps.  
 
55
   //
 
56
 
 
57
   saveFile=new TFile("exo_j2.root","recreate"); // on cree le fichier ROOT "exo_j2.root"
 
58
   // A partir d'ici, les histogrammes et les TTree qui seront crees seront associes au
 
59
   // fichier "exo_j2.root".
 
60
 
 
61
   hxy=new TH2F("hxy","y vs x",50,-25,25,50,-25,25); // on declare un bidim Y vs X
 
62
   hxy->SetOption("zcol");      // on met son option d'affichage par defaut a "ZCOL"
 
63
   hz=new TH1F("hz","Z",50,0,10); // on declare le monodim de la distribution de Z                      
 
64
   hex=new TProfile("hex","e vs x",50,-25,25,-1.e10,1.e10); // on declare le profile <E> vs X
 
65
   hey=new TProfile("hey","e vs y",50,-25,25,-1.e10,1.e10); // on declare le profile <E> vs Y
 
66
 
 
67
   hzx=new TH2F("hzx","z vs x",50,-25,25,50,-25,25); // on declare un bidim Z vs X
 
68
   hzx->SetOption("zcol");      // on met son option d'affichage par defaut a "ZCOL"
 
69
   hzy=new TH2F("hzy","z vs y",50,-25,25,50,-25,25); // on declare un bidim Z vs Y
 
70
   hzy->SetOption("zcol");      // on met son option d'affichage par defaut a "ZCOL"
 
71
 
 
72
   hxyz=new TH3F("hxyz","z vs y vs x",25,-25,25,25,-25,25,10,-3,7); // on declare le tridim Z vs Y vs X
 
73
   heyz=new TH3F("heyz","z vs y vs x",25,-25,25,25,-25,25,25,-500,2500); // on declare le tridim E vs Y vs X
 
74
 
 
75
}
 
76
 
 
77
void ExoJ2Step1::SlaveBegin(TTree * /*tree*/)
 
78
{
 
79
   // The SlaveBegin() function is called after the Begin() function.
 
80
   // When running with PROOF SlaveBegin() is called on each slave server.
 
81
   // The tree argument is deprecated (on PROOF 0 is passed).
 
82
 
 
83
   TString option = GetOption();
 
84
 
 
85
}
 
86
 
 
87
Bool_t ExoJ2Step1::Process(Long64_t entry)
 
88
{
 
89
   // The Process() function is called for each entry in the tree (or possibly
 
90
   // keyed object in the case of PROOF) to be processed. The entry argument
 
91
   // specifies which entry in the currently loaded tree is to be processed.
 
92
   // It can be passed to either ExoJ2Step1::GetEntry() or TBranch::GetEntry()
 
93
   // to read either all or the required parts of the data. When processing
 
94
   // keyed objects with PROOF, the object is already loaded and is available
 
95
   // via the fObject pointer.
 
96
   //
 
97
   // This function should contain the "body" of the analysis. It can contain
 
98
   // simple or elaborate selection criteria, run algorithms on the data
 
99
   // of the event and typically fill histograms.
 
100
   //
 
101
   // The processing can be stopped by calling Abort().
 
102
   //
 
103
   // Use fStatus to set the return value of TTree::Process().
 
104
   //
 
105
   // The return value is currently not used.
 
106
 
 
107
   
 
108
   // Cette methode est appelee pour chaque entree (evenement) de l'arbre
 
109
   
 
110
   GetEntry(entry); // Lecture de la (entry+1)eme entree de l'arbre
 
111
                    // a ce niveau, la valeur des variables x, y, z et e
 
112
                    // sont ajustees aux valkeurs coirrespondant a cet evenement
 
113
   hz->Fill(z,1);    // on remplit le TH1F
 
114
   hxy->Fill(x,y,1); // on remplit un TH2F
 
115
   hex->Fill(x,e,1); // on remplit un TProfile
 
116
   hey->Fill(y,e,1); // on remplit un TProfile
 
117
   hzx->Fill(x,z,1); // on remplit un TH2F
 
118
   hzy->Fill(y,z,1); // on remplit un TH2F
 
119
   hxyz->Fill(x,y,z,1); // on remplit un TH3F
 
120
   heyz->Fill(x,y,e,1); // on remplit un TH3F
 
121
                     
 
122
   return kTRUE;
 
123
}
 
124
 
 
125
void ExoJ2Step1::SlaveTerminate()
 
126
{
 
127
   // The SlaveTerminate() function is called after all entries or objects
 
128
   // have been processed. When running with PROOF SlaveTerminate() is called
 
129
   // on each slave server.
 
130
 
 
131
}
 
132
 
 
133
void ExoJ2Step1::Terminate()
 
134
{
 
135
   // The Terminate() function is the last function to be called during
 
136
   // a query. It always runs on the client, it can be used to present
 
137
   // the results graphically or save the results to file.
 
138
 
 
139
   saveFile->Write(); // on ecrit tous les histogrammes associes au
 
140
                      // fichier ROOT.
 
141
   saveFile->Close(); // on ferme le fichier ROOT
 
142
 
 
143
 
 
144
}