ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerNSVFit.cc
Revision: 1.2
Committed: Thu Jun 16 11:40:20 2011 UTC (13 years, 10 months ago) by rwolf
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022
Changes since 1.1: +37 -26 lines
Log Message:
adaptations to new structures in SVfit classes

File Contents

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