ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/interface/SkimMod.h
Revision: 1.2
Committed: Thu Mar 29 23:41:56 2012 UTC (13 years, 1 month ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, HEAD
Changes since 1.1: +7 -7 lines
Log Message:
Version with working skimming and last 4.4 tag.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: SkimMod.h,v 1.1 2012/03/28 12:15:35 paus Exp $
3 //
4 // SkimMod
5 //
6 // This module simply publishes an ObjArray and copies all marked data objects from the mother
7 // branch into this published ObjArray. It assumes that all marking is completed and the references
8 // will thus all resolve properly.
9 //
10 // Authors: C.Paus
11 //--------------------------------------------------------------------------------------------------
12
13 #ifndef MITANA_PHYSICSMOD_SKIMMOD_H
14 #define MITANA_PHYSICSMOD_SKIMMOD_H
15
16 #include "MitAna/DataCont/interface/ObjArray.h"
17 #include "MitAna/TreeMod/interface/BaseMod.h"
18
19 namespace mithep
20 {
21 template<class T>
22 class SkimMod : public BaseMod
23 {
24 public:
25 SkimMod(const char *name = "SkimMod",
26 const char *title = "Skim module");
27 ~SkimMod();
28
29 const char *GetBranchName() const { return fBranchName; }
30 void SetBranchName(const char *n) { fBranchName = n; }
31
32 protected:
33 TString fBranchName; //name of collection
34
35 const Collection<T> *fCol; //!pointer to collection (in - branch)
36 ObjArray<T> *fColSkm; //!pointer to collection (skm - published object)
37
38 void Process();
39 void SlaveBegin();
40 void SlaveTerminate();
41
42 ClassDef(SkimMod, 1) // Skim module
43 };
44 }
45
46 //--------------------------------------------------------------------------------------------------
47 template<class T>
48 mithep::SkimMod<T>::SkimMod(const char *name, const char *title) :
49 BaseMod (name,title),
50 fBranchName("SkmSetMe"),
51 fCol (0),
52 fColSkm (0)
53 {
54 // Constructor.
55 }
56
57 template<class T>
58 mithep::SkimMod<T>::~SkimMod()
59 {
60 // Destructor.
61 if (fColSkm)
62 delete fColSkm;
63 }
64
65 //--------------------------------------------------------------------------------------------------
66 template<class T>
67 void mithep::SkimMod<T>::Process()
68 {
69 // make sure the collection is empty before starting
70 fColSkm->Reset();
71
72 // load the branch with the properly marked objects
73 LoadBranch(GetBranchName());
74 const UInt_t entries = fCol->GetEntries();
75
76 for (UInt_t i=0; i<entries; ++i) {
77 if (fCol->At(i)->IsMarked()) {
78 // Make sure the mark is not written to file
79 fCol->At(i)->UnmarkMe();
80 fColSkm->Add(fCol->At(i));
81 //if (fCol->At(i)->GetUniqueID() == 0)
82 // printf(" SkimMod -- WARNING -- UID ZERO: %d %d %s\n",
83 // fCol->At(i)->GetUniqueID(),
84 // fCol->At(i)->GetUniqueID()&0xfffff,
85 // fCol->GetName());
86 }
87 }
88 }
89
90 //--------------------------------------------------------------------------------------------------
91 template<class T>
92 void mithep::SkimMod<T>::SlaveBegin()
93 {
94 // Request the marked input branch
95 ReqBranch(GetBranchName(), fCol);
96 // Request the branch to be published
97 fColSkm = new mithep::ObjArray<T>(0,TString("Skm")+GetBranchName());
98 PublishObj(fColSkm);
99 }
100
101 //--------------------------------------------------------------------------------------------------
102 template<class T>
103 void mithep::SkimMod<T>::SlaveTerminate()
104 {
105 }
106 #endif