16 | | == The !ControlPlots class and its subclasses == |
| 18 | !AnalysisEvent is an interface to the tree data. It provides new functionality w.r.t. the bare access: |
| 19 | * **A list of event products used in the analysis** \\ |
| 20 | It allows to centralize the definition of the collections to use, and provides convenient aliases that you can use in your analysis to access the various objects/products. |
| 21 | * **A list of "producers" of analysis high-level quantities** \\ |
| 22 | This is sometimes known as “Analysis on demand”. You don't have to explicitly call the analysis routines that were previously declared. Once registered, they are run when needed. Results are cached, so that the methods are called once per event. That functionality reduces a lot the number of import statements and contributes to the optimization of the analysis code. |
| 23 | * **A centralized weight infrastructure** \\ |
| 24 | The user can define a set of weight classes where an event weight is computed based on event quantities. !AnalysisEvent keeps track of every weight and caches the intermediate and final values. |
| 25 | Beware that the caching mechanism for weights is based on the arguments passed to them... don't use object quantities that may change. |
| 26 | * **A volatile dictionary to cache temporarily reconstructed products** \\ |
| 27 | Any high-level quantity can be “put in the event” and retrieved when needed. |
| 28 | This means that if your analysis is split into modules, there is no need to pass many arguments to the various functions. Just pass the event instance and use the event to store what is needed. |
| 29 | |
| 30 | {{{ |
| 31 | #!div style="font-size: 80%" |
| 32 | {{{#!python |
| 33 | hello = lambda: "world" |
| 34 | }}} |
| 35 | }}} |
| 36 | |
| 37 | == The !BaseControlPlots class and its subclasses == |
| 38 | |
| 39 | That class allows to define/fill/save a set of histograms or ntuple variables, following the traditional scheme in such cases. Still, it makes use of a simplified and unified approach to minimize the amount of code needed while maintaining all the functionality of the ROOT back-end. |
| 40 | |
| 41 | As a user, you must create a derived class where the following two methods are implemented: |
| 42 | beginJob(self):: That method is called before the event loop. You should declare the histograms, using self.add(/*TH1 arguments*/), and do any needed initialization. |
| 43 | process(self,event):: That method is called for each event. A proper implement should do the processing, taking all information from the input event. Remember to take benefit from the caching, producers, and other features of !AnalysisEvent. The method must return a dictionary varName:value(s) that will be used internally by the framework to fill histograms or ntuple variables. It can be a list of values when more than one entry per event, but this is then only supported for histograms, not for ntuples (the corresponding ntuple branches will be empty). |
| 44 | |
| 45 | {{{ |
| 46 | #!div style="font-size: 80%" |
| 47 | {{{#!python |
| 48 | hello = lambda: "world" |
| 49 | }}} |
| 50 | }}} |
| 51 | |
| 52 | == The !BaseWeight class == |
| 53 | |
| 54 | That class has to be subclassed to compute event weights. The base class itself does nothing... it is mostly there as a documentation of what you have to implement in a subclass. Namely, |
| 55 | the constructor:: A simple constructor should be implemented, with any needed parameters to initialize the calculation. |
| 56 | weight(self,event):: Method returning the weight value for the current event. The implementation should be based on the event content and on a set of options passed as argument. Beware that the caching mechanism for weights is based on the arguments passed to them... don't use quantities that may change during the event processing. |
| 57 | |
| 58 | {{{ |
| 59 | #!div style="font-size: 80%" |
| 60 | {{{#!python |
| 61 | hello = lambda: "world" |
| 62 | }}} |
| 63 | }}} |
| 67 | The EventSelection module contains the set of functions needed to select and classify events. A proper implementation of the event selection will at least define the following: |
| 68 | categoryNames:: an ordered list of the names of each category. |
| 69 | eventCategory(event):: a method that computes a tuple containing the data needed to sort events in the categories named above in its simplest form. It can be a tuple of bools, or may contain more detailed information but should always be kept simple to make the isInCategory method fast. |
| 70 | isInCategory(cat, categoryData):: that method returns a boolean to tell if the event is in the category cat, definition, from category data contained in categoryData. |
| 71 | |
| 72 | {{{ |
| 73 | #!div style="font-size: 80%" |
| 74 | {{{#!python |
| 75 | hello = lambda: "world" |
| 76 | }}} |
| 77 | }}} |
| 78 | |
| 79 | == Steering code and Configuration file == |
| 80 | |
| 81 | The framework is contained in python/DelphesAnalsys. No file in that directory should ever be modified. |
| 82 | |
| 83 | The main script is ControlPlots. |
| 84 | |
| 85 | DumpEventInfo is another script that will output all the information available on a given event. |
| 86 | |
| 87 | All that is configured through a simple configuration script. |
| 88 | |
| 97 | |
| 98 | The release includes two examples. |
| 99 | * Simple analysis. |
| 100 | * simpleConfig.py |
| 101 | * !SimpleEventSelection.py |
| 102 | * !LeptonControlPlots.py |
| 103 | * Basic ttbar analysis |
| 104 | * topConfig.py |
| 105 | * !TtbarEventSelection.py |
| 106 | * !TopReconstruction.py |
| 107 | * !JetControlPlots.py |
| 108 | * !LeptonControlPlots.py |
| 109 | * !TopControlPlots.py |
| 110 | |
| 111 | The following commands can be run from the Delphes ROOT directory: |
| 112 | {{{#!sh |
| 113 | # setup path |
| 114 | . ./DelphesEnv.sh |
| 115 | cd python |
| 116 | # run the analysis |
| 117 | DelphesAnalysis/ControlPlots.py -i ../files/ -o controlPlots_demo.root --all -c topConfig.py |
| 118 | # dump a list of events in category 5 (ttbar candidates) |
| 119 | export DelphesAnalysisCfg="topConfig.py" |
| 120 | python DelphesAnalysis/DumpEventList.py 5 ../delphes_output.root |
| 121 | # for each of them, print details |
| 122 | for i in `cat eventlist.txt| cut -d' ' -f 2`; { python DelphesAnalysis/DumpEventInfo.py $i ../delphes_output.root; } |
| 123 | }}} |