ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitEdm/Producers/src/ProducerConversions.cc
Revision: 1.2
Committed: Fri Sep 19 12:00:05 2008 UTC (16 years, 7 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.1: +4 -2 lines
Log Message:
Added daughter momenta from fit

File Contents

# User Rev Content
1 bendavid 1.2 // $Id: ProducerConversions.cc,v 1.1 2008/09/17 12:49:48 bendavid Exp $
2 bendavid 1.1
3     #include "DataFormats/Common/interface/Handle.h"
4     #include "DataFormats/TrackReco/interface/Track.h"
5     #include "DataFormats/TrackReco/interface/TrackFwd.h"
6    
7     #include "MitEdm/DataFormats/interface/Types.h"
8     #include "MitEdm/DataFormats/interface/CollectionsEdm.h"
9     #include "MitEdm/DataFormats/interface/DecayPart.h"
10     #include "MitEdm/DataFormats/interface/StablePart.h"
11     #include "MitEdm/VertexFitInterface/interface/MvfInterface.h"
12     #include "MitEdm/Producers/interface/ProducerConversions.h"
13    
14     using namespace std;
15     using namespace edm;
16     using namespace reco;
17     using namespace mitedm;
18     using namespace mithep;
19    
20     //--------------------------------------------------------------------------------------------------
21     ProducerConversions::ProducerConversions(const ParameterSet& cfg) :
22     BaseCandidate(cfg),
23     iStables1_ (cfg.getUntrackedParameter<string>("iStables1","" )),
24     iStables2_ (cfg.getUntrackedParameter<string>("iStables2","" )),
25     convConstraint_ (cfg.getUntrackedParameter<bool>("convConstraint",false )),
26 bendavid 1.2 convConstraint3D_ (cfg.getUntrackedParameter<bool>("convConstraint3D",true )),
27 bendavid 1.1 rhoMin_ (cfg.getUntrackedParameter<double>("rhoMin",0.0 ))
28     {
29     produces<DecayPartCol>();
30     }
31    
32     //--------------------------------------------------------------------------------------------------
33     ProducerConversions::~ProducerConversions()
34     {
35     }
36    
37     //--------------------------------------------------------------------------------------------------
38     void ProducerConversions::produce(Event &evt, const EventSetup &setup)
39     {
40     // -----------------------------------------------------------------------------------------------
41     // Get the input
42     // -----------------------------------------------------------------------------------------------
43     // First input collection
44     Handle<StablePartCol> hStables1;
45     if (!GetProduct(iStables1_, hStables1, evt))
46     return;
47     const StablePartCol *pS1 = hStables1.product();
48     // Second input collection
49     Handle<StablePartCol> hStables2;
50     if (!GetProduct(iStables2_, hStables2, evt))
51     return;
52     const StablePartCol *pS2 = hStables2.product();
53    
54     // -----------------------------------------------------------------------------------------------
55     // Create the output collection
56     // -----------------------------------------------------------------------------------------------
57     auto_ptr<DecayPartCol> pD(new DecayPartCol());
58    
59     // -----------------------------------------------------------------------------------------------
60     // Simple double loop
61     // -----------------------------------------------------------------------------------------------
62     for (UInt_t i = 0; i<pS1->size(); ++i) {
63     const StablePart &s1 = pS1->at(i);
64    
65     UInt_t j;
66     if (iStables1_ == iStables2_)
67     j = i+1;
68     else
69     j = 0;
70    
71     for (; j<pS2->size(); ++j) {
72     const StablePart &s2 = pS2->at(j);
73    
74     // Vertex fit now, possibly with conversion constraint
75     MultiVertexFitter fit;
76     if (convConstraint3D_)
77     fit.conversion_3d(MultiVertexFitter::VERTEX_1);
78     else if (convConstraint_)
79     fit.conversion_2d(MultiVertexFitter::VERTEX_1);
80     fit.init(3.8); // Reset to the MC magnetic field of 4 Tesla
81     MvfInterface fitInt(&fit);
82     fitInt.addTrack(s1.track(),1,s1.mass(),MultiVertexFitter::VERTEX_1);
83     fitInt.addTrack(s2.track(),2,s2.mass(),MultiVertexFitter::VERTEX_1);
84     if (fit.fit()) {
85     DecayPart *d = new DecayPart(oPid_,DecayPart::Fast);
86    
87     RefToBaseProd<BasePart> baseRef1(hStables1);
88     RefToBaseProd<BasePart> baseRef2(hStables2);
89     BasePartBaseRef ref1(baseRef1,i);
90     BasePartBaseRef ref2(baseRef2,j);
91     d->addChild(ref1);
92     d->addChild(ref2);
93 bendavid 1.2 d->addChildMom(fit.getTrackP4(1));
94     d->addChildMom(fit.getTrackP4(2));
95 bendavid 1.1 // Update temporarily some of the quantities (prob, chi2, nDoF, mass, lxy, pt, fourMomentum)
96     d->setProb(fit.prob());
97     d->setChi2(fit.chisq());
98     d->setNdof(fit.ndof());
99    
100     FourVector p4Fitted(0.,0.,0.,0.);
101     p4Fitted += fit.getTrackP4(1);
102     p4Fitted += fit.getTrackP4(2);
103     d->setFourMomentum(p4Fitted);
104     d->setPosition(fit.getVertex (MultiVertexFitter::VERTEX_1));
105     d->setError (fit.getErrorMatrix(MultiVertexFitter::VERTEX_1));
106     float mass, massErr;
107     const int trksIds[2] = { 1, 2 };
108     mass = fit.getMass(2,trksIds,massErr);
109    
110     if(0) {
111     const reco::Track *p1 = s1.track();
112     const reco::Track *p2 = s2.track();
113    
114     //// create the dimuon system
115     FourVector mu1(p1->px(),p1->py(),p1->pz(),sqrt(p1->p()*p1->p()+0.105658357*0.105658357));
116     FourVector mu2(p2->px(),p2->py(),p2->pz(),sqrt(p2->p()*p2->p()+0.105658357*0.105658357));
117     FourVector diMu = mu1+mu2;
118    
119     //// for convenience and economy
120     double mass4Vec = sqrt(diMu.M2());
121    
122     printf(" Generated mass: ....\n");
123     printf(" Four vector mass: %14.6f\n",mass4Vec);
124     printf(" Fitted mass: %14.6f +- %14.6f\n",mass,massErr);
125     }
126    
127     d->setFittedMass (mass);
128     d->setFittedMassError(massErr);
129     // Put the result into our collection
130     if (d->position().rho() > rhoMin_)
131     pD->push_back(*d);
132     delete d;
133     }
134     }
135     }
136    
137     // -----------------------------------------------------------------------------------------------
138     // Write the collection even if it is empty
139     // -----------------------------------------------------------------------------------------------
140     // cout << " ProducerConversions::produce - " << pD->size() << " entries collection created -"
141     // << " (Pid: " << oPid_ << ")\n";
142     evt.put(pD);
143     }
144    
145     //--------------------------------------------------------------------------------------------------
146     void ProducerConversions::beginJob(const EventSetup &setup)
147     {
148     }
149    
150     //--------------------------------------------------------------------------------------------------
151     void ProducerConversions::endJob()
152     {
153     }
154    
155     //define this as a plug-in
156     DEFINE_FWK_MODULE(ProducerConversions);