ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerNSVFit.cc
Revision: 1.1
Committed: Thu May 5 12:43:25 2011 UTC (14 years ago) by rwolf
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_021, Mit_021pre2
Log Message:
added NSVfit information

File Contents

# User Rev Content
1 rwolf 1.1 // $Id: FillerNSVFit.cc,v 1.8 2011/04/26 12:14:24 mhchan Exp $
2    
3     #include "MitAna/DataTree/interface/Names.h" //?
4     #include "MitProd/ObjectService/interface/ObjectService.h" //?
5    
6     #include "MitAna/DataTree/interface/NSVFitCol.h"
7     #include "MitProd/TreeFiller/interface/FillerNSVFit.h"
8     #include "AnalysisDataFormats/TauAnalysis/interface/NSVfitEventHypothesisFwd.h"
9    
10     using namespace std;
11     using namespace edm;
12     using namespace mithep;
13    
14     //--------------------------------------------------------------------------------------------------
15     FillerNSVFit::FillerNSVFit(const ParameterSet &cfg, const char *name, bool active) :
16     BaseFiller(cfg,name,active),
17     edmName_(Conf().getUntrackedParameter<string>("edmName","")),
18     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkNSVFitBrn)),
19     hypotheses_(new mithep::NSVFitArr(16))
20     {
21     // Constructor.
22     }
23    
24     //--------------------------------------------------------------------------------------------------
25     FillerNSVFit::~FillerNSVFit()
26     {
27     // Destructor.
28    
29     delete hypotheses_;
30     }
31    
32     //--------------------------------------------------------------------------------------------------
33     void FillerNSVFit::BookDataBlock(TreeWriter &tws)
34     {
35     // Add NSVFit branch to tree.
36    
37     tws.AddBranch(mitName_,&hypotheses_);
38     OS()->add<mithep::NSVFitArr>(hypotheses_,mitName_);
39     }
40    
41     //--------------------------------------------------------------------------------------------------
42     void FillerNSVFit::FillDataBlock(const edm::Event &event,
43     const edm::EventSetup &setup)
44     {
45     // Fill NSVFit results from edm into our collection.
46    
47     hypotheses_->Delete();
48    
49     // handle for the NSVFit info collection
50     Handle<NSVfitEventHypothesisCollection> nSVfit;
51     GetProduct(edmName_, nSVfit, event);
52    
53     for(NSVfitEventHypothesisCollection::const_iterator hyp = nSVfit->begin(); hyp != nSVfit->end(); ++hyp){
54     for(edm::OwnVector<NSVfitResonanceHypothesis>::const_iterator res = hyp->resonances().begin(); res != hyp->resonances().end(); ++res){
55     mithep::NSVFit *hypothesis = hypotheses_->Allocate();
56     new (hypothesis) mithep::NSVFit();
57    
58     // fill info whether fit converged or not
59     hypothesis->SetIsValid(res->isValidSolution());
60    
61     // fill masses
62     hypothesis->SetMass(res->mass());
63     hypothesis->SetMassErrUp(res->massErrUp());
64     hypothesis->SetMassErrDown(res->massErrDown());
65    
66     hypothesis->SetMassMean(res->mass_mean());
67     hypothesis->SetMassMedian(res->mass_median());
68     hypothesis->SetMassMaximum(res->mass_maximum());
69     hypothesis->SetMassMaxInterpol(res->mass_maxInterpol());
70    
71     // fill p4 of input particles, which are the daughters of the resonance
72     for(edm::OwnVector<NSVfitSingleParticleHypothesisBase>::const_iterator daughter = res->daughters().begin(); daughter != res->daughters().end(); ++daughter){
73     hypothesis->AddDaughter(daughter->p4().pt(), daughter->p4().eta(), daughter->p4().phi(), daughter->p4().mass());
74     }
75     }
76     }
77     hypotheses_->Trim();
78     }