16 |
inherits form {\bf PamCut} and provides an implementation for the pure virtual |
inherits form {\bf PamCut} and provides an implementation for the pure virtual |
17 |
method {\bf Check}. |
method {\bf Check}. |
18 |
A special derived class is {\bf PamCutCollection}. This is a sort of a |
A special derived class is {\bf PamCutCollection}. This is a sort of a |
19 |
container for basic cuts, and is considered as a single cut. Its {\bf Check} |
container for basic cuts, and is considered as a single cut. It has an {\bf |
20 |
|
AddCut} method which will add a cut to the collection. Its {\bf Check} |
21 |
implementation simply invokes all the {\bf Check}s of the single cuts, and it |
implementation simply invokes all the {\bf Check}s of the single cuts, and it |
22 |
is successful if all the single cuts are succesful. |
is successful if all the single cuts are succesful. {\bf PamCut} also provides |
23 |
{\bf PamCut} also provides the interface for two methods for post-processing: |
the interface for two methods for post-processing: {\bf OnGood} and {\bf |
24 |
{\bf OnGood} and {\bf OnBad}. In derived classes these can contain specific |
OnBad}. In derived classes these can contain specific tasks to be performed |
25 |
tasks to be performed whenever an event satisfy the {\bf Check} condition or |
whenever an event satisfy the {\bf Check} condition or not. The method {\bf |
26 |
not. The method {\bf ApplyCut} takes care of invoking {\bf Check} and |
ApplyCut} takes care of invoking {\bf Check} and subsequently calls {\bf |
27 |
subsequently calls {\bf OnGood} or {\bf OnBad} according to the result of {\bf Check}. |
OnGood} or {\bf OnBad} according to the result of {\bf Check}. Summarizing, |
28 |
Summarizing, {\bf Check}ing an event simply means to ask the object if the |
{\bf Check}ing an event simply means to ask the object if the event satisfy |
29 |
event satisfy the selection criteria; applying a cut means to check and then |
the selection criteria; applying a cut means to check and then perform |
30 |
perform post-selection tasks. The cut can be applied to a bunch of events by |
post-selection tasks. The cut can be applied to a bunch of events by means of |
31 |
means of the {\bf Process} method. |
the {\bf Process} method. |
32 |
|
|
33 |
\subsection{More on collections} |
\subsection{More on collections} |
34 |
A collection is an object which inherits from {\bf PamCutCollection}, which in |
A collection is an object which inherits from {\bf PamCutCollection}, which in |
68 |
{\bf PamCutCollection}. See the Doxygen html documentation for more info about |
{\bf PamCutCollection}. See the Doxygen html documentation for more info about |
69 |
{\bf BlindCutCollection} and other specific cut implementations. |
{\bf BlindCutCollection} and other specific cut implementations. |
70 |
|
|
71 |
|
\subsection{Collections and memory management} |
72 |
|
|
73 |
|
Regarding to cuts ownership, a collection will by default own its cuts. This |
74 |
|
means that when you add a cut to a collection calling {\bf AddCut} with a |
75 |
|
pointer to the cut as argument, the collection will store this pointer and |
76 |
|
will take charge of deleting it. This is done by the collection's destructor. |
77 |
|
This way, a user can simply add a cut to a collection and forget about |
78 |
|
deleting it. However, sometimes this feature is not desirable, so it can be |
79 |
|
turned off by passing a proper value to the collection's constructor. In this |
80 |
|
case, the user is in charge of managing the memory allocated for the cuts. |
81 |
|
|
82 |
|
|
83 |
\section{Actions and the SmartCollection} |
\section{Actions and the SmartCollection} |
84 |
When performing an analysis, each time an event is selected as good some |
When performing an analysis, each time an event is selected as good some |
85 |
actions are likely to be performed, like filling histograms or writing a |
actions are likely to be performed, like filling histograms or writing a |
94 |
implementations will be called actions.\\ |
implementations will be called actions.\\ |
95 |
Actions are automatically handled by the {\bf SmartCollection} class. It |
Actions are automatically handled by the {\bf SmartCollection} class. It |
96 |
inherits from {PamCutCollection}, and contains a vector of {\bf |
inherits from {PamCutCollection}, and contains a vector of {\bf |
97 |
CollectionAction} objects. These actions can be added using {\bf |
CollectionAction} objects. These actions can be added calling {\bf |
98 |
SmartCollection::AddAction}; for each of them, the collection will take care of |
SmartCollection::AddAction}; for each of them, the collection will take care of |
99 |
calling {\bf Setup} at the beginning of the analysis, {\bf OnGood} and {\bf |
calling {\bf Setup} at the beginning of the analysis, {\bf OnGood} and {\bf |
100 |
OnBad} for every event (depending on the selection result), and {\bf Finalize} |
OnBad} for every event (depending on the selection result), and {\bf Finalize} |
130 |
event. If a certain cut in a bunch fails, then {\bf OnBad} is called for the |
event. If a certain cut in a bunch fails, then {\bf OnBad} is called for the |
131 |
actions of the bunch, but successive bunches are ignored; the current event is |
actions of the bunch, but successive bunches are ignored; the current event is |
132 |
discarded and the focus switches on the next one (the {\bf |
discarded and the focus switches on the next one (the {\bf |
133 |
SmartBlindCollection} behaves a little different; see the Doxygen |
SmartBlindCollection} behaves a little differently; see the Doxygen |
134 |
documentation for more details.) |
documentation for more details.) |
135 |
\\ |
\\ |
136 |
Loosely speaking, after defining an action one simply has to instantiate it, |
Loosely speaking, after defining an action one simply has to instantiate it, |
137 |
add it to a {\bf SmartCollection} and launch the analysis. |
add it to a {\bf SmartCollection} and launch the analysis. |
138 |
|
|
139 |
|
\subsection{SmartCollections and memory management} |
140 |
|
Like the standard collection, SmartCollection can handle the memory management |
141 |
|
for actions. This works exactly as for cuts. Cuts and actions have to be |
142 |
|
managed uniformly, ie., one cannot turn off ownership only for cuts or only for |
143 |
|
actions. |
144 |
|
|
145 |
\section{The software organization} |
\section{The software organization} |
146 |
The software is organized in a tree of directories. The idea is that each node |
The software is organized in a tree of directories. The idea is that each node |
147 |
of this tree must provide the necessary informations about the sub-branches. In |
of this tree must provide the necessary informations about the sub-branches. In |
292 |
\verb1 http://www.stack.nl/~dimitri/doxygen/manual.html1 |
\verb1 http://www.stack.nl/~dimitri/doxygen/manual.html1 |
293 |
|
|
294 |
\vspace{.5cm} |
\vspace{.5cm} |
295 |
Once the header has been prepared, it's time to implement the cut into {\it |
Once the header has been prepared, it's time to implement the cut in {\it |
296 |
DummyCut.cpp}: |
DummyCut.cpp}: |
297 |
|
|
298 |
\begin{verbatim} |
\begin{verbatim} |
582 |
. |
. |
583 |
. |
. |
584 |
|
|
585 |
PamCutCollection collection; |
PamCutCollection collection("Collection"); |
586 |
|
|
587 |
DummyCut1 dummy1; |
DummyCut1 *dummy1 = new DummyCut1("name1"); |
588 |
collection.AddCut(dummy1); |
collection.AddCut(dummy1); |
589 |
DummyCut2 dummy2(param); |
// The two lines above can be summarized also as: |
590 |
|
// collection.AddCut(new DummyCut1("name1")); |
591 |
|
|
592 |
|
DummyCut2 *dummy2 = new DummyCut2("name2", <eventual params>); |
593 |
collection.AddCut(dummy2); |
collection.AddCut(dummy2); |
594 |
|
|
595 |
collection.Process(event, 0, event->GetEntries()-1); |
collection.Process(event, 0, event->GetEntries()-1); |
649 |
be automatically executed every time you set your PAMELA environment. |
be automatically executed every time you set your PAMELA environment. |
650 |
|
|
651 |
\section{Usage summary} |
\section{Usage summary} |
652 |
Here's a short summary on how to develop a cut, build and use it. If one only |
Here's a short summary on how to develop a cut, build and use it. |
653 |
\begin{enumerate} |
\begin{enumerate} |
654 |
\item Obtain the code (from tarball, repository\ldots) and go in the root |
\item Obtain the code (from tarball, repository\ldots) and go in the root |
655 |
code directory. |
code directory. |
656 |
\item Check if the \verb1C++1 option in the Build section of {\it makefile} |
\item Check if the \verb1C++1 option in the Build section of {\it makefile} |
657 |
is correctly set with the C++ compiler name present in your system (for many |
is correctly set with the C++ compiler name present in your system (for many |
658 |
Linux platform, \verb1g++1 is a safe choice). |
Linux platforms, \verb1g++1 is a safe choice). |
659 |
\item Create a directory named as the cut class you want to develop. |
\item Create a directory named as the cut class you want to develop. |
660 |
\item Place inside the newly created directory a {\it .h} file and a {\it |
\item Place inside the newly created directory a {\it .h} file and a {\it |
661 |
.cpp} file, named as the direcory; edit the files to define and implement the |
.cpp} file, named as the direcory; edit the files to define and implement the |
679 |
\item Develop the analysis code |
\item Develop the analysis code |
680 |
\end{enumerate} |
\end{enumerate} |
681 |
|
|
682 |
|
\section{Online documentation} |
683 |
|
The code is provided with a full set of Doxygen tags; documentation can then be |
684 |
|
built using the doxygen documentation system. However, an online documentation |
685 |
|
is availbale at: |
686 |
|
\newline |
687 |
|
\newline |
688 |
|
\verb1 http://hep.fi.infn.it/PAMELA/documents/PamCut_documentation/1 |
689 |
|
|
690 |
|
\vspace{.5cm} |
691 |
|
It is updated frequently, but it may lack the description of the most recent |
692 |
|
features. Please notify any fault in the online documentation for a quick fix. |
693 |
|
|
694 |
|
|
695 |
\section{Some advices and suggestions} |
\section{Some advices and suggestions} |
696 |
\begin{itemize} |
\begin{itemize} |
697 |
\item Derive your cuts. Try to define a new class every time you need a new |
\item Derive your cuts. Try to define a new class every time you need a new |
742 |
likely to be used and modified by other people, please take your time to |
likely to be used and modified by other people, please take your time to |
743 |
write the documentation. Documenting the code is a boring and time-consuming |
write the documentation. Documenting the code is a boring and time-consuming |
744 |
task, but can save you and your colleagues a lot of headaches and |
task, but can save you and your colleagues a lot of headaches and |
745 |
misunderstandings. The better a code is documented, the lesser are the |
misunderstandings. The better a code is documented, the lesser the |
746 |
questions other people will ask you. |
questions other people will ask you. |
747 |
\end{itemize} |
\end{itemize} |
748 |
|
|