ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitEdm/Producers/src/ProducerV2SS.cc
Revision: 1.10
Committed: Thu Nov 13 17:08:31 2008 UTC (16 years, 6 months ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006b, Mit_006a, Mit_006
Changes since 1.9: +39 -41 lines
Log Message:
Optimized MultiVertexFitter'D'.

File Contents

# User Rev Content
1 paus 1.10 // $Id: ProducerV2SS.cc,v 1.9 2008/11/03 16:03:21 bendavid Exp $
2 loizides 1.7
3 mrudolph 1.3 #include "DataFormats/Common/interface/Handle.h"
4     #include "DataFormats/TrackReco/interface/Track.h"
5     #include "DataFormats/TrackReco/interface/TrackFwd.h"
6 bendavid 1.8 #include "MitEdm/Producers/interface/HitDropperRecord.h"
7     #include "MitEdm/Producers/interface/HitDropper.h"
8 mrudolph 1.3 #include "MitEdm/DataFormats/interface/Types.h"
9 mrudolph 1.4 #include "MitEdm/DataFormats/interface/Collections.h"
10 mrudolph 1.3 #include "MitEdm/DataFormats/interface/DecayPart.h"
11     #include "MitEdm/DataFormats/interface/StablePart.h"
12 bendavid 1.5 #include "MitEdm/DataFormats/interface/StableData.h"
13 mrudolph 1.3 #include "MitEdm/VertexFitInterface/interface/MvfInterface.h"
14     #include "MitEdm/VertexFitInterface/interface/HisInterface.h"
15     #include "MitEdm/Producers/interface/ProducerV2SS.h"
16    
17     using namespace std;
18     using namespace edm;
19     using namespace mitedm;
20 bendavid 1.5 using namespace mithep;
21 mrudolph 1.3
22     //--------------------------------------------------------------------------------------------------
23     ProducerV2SS::ProducerV2SS(const ParameterSet& cfg) :
24     ProducerD2SS(cfg),
25 paus 1.10 rhoMin_ (cfg.getUntrackedParameter<double>("minRadius", 0.0)),
26     massMin_ (cfg.getUntrackedParameter<double>("minMass", 0.0)),
27     massMax_ (cfg.getUntrackedParameter<double>("maxMass", 3.0)),
28     dZMax_ (cfg.getUntrackedParameter<double>("maxZDistance",5.0))
29 mrudolph 1.3 {
30     }
31    
32     //--------------------------------------------------------------------------------------------------
33     ProducerV2SS::~ProducerV2SS()
34     {
35     }
36    
37     //--------------------------------------------------------------------------------------------------
38     void ProducerV2SS::produce(Event &evt, const EventSetup &setup)
39     {
40     // Create the output collection
41     auto_ptr<DecayPartCol> pD(new DecayPartCol());
42    
43     // First input collection
44     Handle<StablePartCol> hStables1;
45     Handle<StablePartCol> hStables2;
46     if (!GetProduct(iStables1_, hStables1, evt) ) {
47     cout << "Couldn't get in collection in Producer V2SS" << endl;
48     evt.put(pD);
49     return;
50     }
51 loizides 1.7 const StablePartCol *pS1 = hStables1.product();
52 mrudolph 1.3
53 loizides 1.7 // Second input collection
54 mrudolph 1.3 if(!GetProduct(iStables2_, hStables2, evt)) {
55     cout << "Couldn't get in collection in Producer V2SS" << endl;
56     evt.put(pD);
57     return;
58     }
59     const StablePartCol *pS2 = hStables2.product();
60 bendavid 1.8
61     //get hit dropper
62     ESHandle<HitDropper> hDropper;
63     setup.get<HitDropperRecord>().get("HitDropper",hDropper);
64     const HitDropper *dropper = hDropper.product();
65 mrudolph 1.3
66     // -----------------------------------------------------------------------------------------------
67     // Simple double loop
68     // -----------------------------------------------------------------------------------------------
69 loizides 1.7 if (0)
70     cout << "Starting V finder loop" << endl;
71 mrudolph 1.3
72 loizides 1.7 //sX_y: X= pion or proton collection.
73     //i, j = 2 loop particles.
74     //ex.: s1_i and s2_i are same particle as pion and proton
75 mrudolph 1.3 for (UInt_t i=0; i<pS1->size(); ++i) {
76     const StablePart &s1 = pS1->at(i);
77    
78     UInt_t j;
79     if (iStables1_ == iStables2_)
80     j = i+1;
81     else
82     j = 0;
83    
84     for (; j<pS2->size(); ++j) {
85     const StablePart &s2 = pS2->at(j);
86    
87     if(s1.charge() + s2.charge() != 0) continue;
88    
89     //Do fast helix fit to check if there's any hope
90     const reco::Track * t1 = s1.track();
91     const reco::Track * t2 = s2.track();
92     HisInterface hisInt(t1,t2);
93     const mithep::HelixIntersector *his = hisInt.hISector();
94     double dZ0 = -999;
95     double dR0 = -999;
96     dZ0 = his->IntersectionI(0).DeltaZ();
97     dR0 = sqrt(his->IntersectionI(0).Location().X()*his->IntersectionI(0).Location().X()+
98     his->IntersectionI(0).Location().Y()*his->IntersectionI(0).Location().Y());
99    
100     TVector3 v1, v2;
101     v1 = his->IntersectionI(0).TrackParamsI(0).Momentum();
102     v2 = his->IntersectionI(0).TrackParamsI(1).Momentum();
103    
104     double e1 = sqrt(v1.Mag()*v1.Mag() +s1.mass()*s1.mass());
105     double x1 = v1.X();
106     double y1 = v1.Y();
107     double z1 = v1.Z();
108    
109     double e2 = sqrt(v2.Mag()*v2.Mag()+s2.mass()*s2.mass());
110     double x2 = v2.X();
111     double y2 = v2.Y();
112     double z2 = v2.Z();
113    
114     FourVector sum(x1+x2, y1+y2, z1+z2, e1+e2);
115    
116     double mass0 = sqrt(sum.M2());
117    
118     //Basic cuts on helix intersection
119     if(mass0 > massMax_ || mass0<massMin_ || fabs(dZ0) > dZMax_ || dR0 < rhoMin_) continue;
120    
121     // -------------------------------------------------------------------------------------------
122     // Do vertex fit for all pairs
123 loizides 1.7 // -------------------------------------------------------------------------------------------
124 paus 1.10 mithep::MultiVertexFitterD fit;
125 loizides 1.7 fit.init(3.8); // Reset to the MC magnetic field of 3.8 Tesla
126 mrudolph 1.3 fit.setChisqMax(100);
127     MvfInterface fitInt(&fit);
128 paus 1.10 fitInt.addTrack(s1.track(),1,s1.mass(),mithep::MultiVertexFitterD::VERTEX_1);
129     fitInt.addTrack(s2.track(),2,s2.mass(),mithep::MultiVertexFitterD::VERTEX_1);
130 mrudolph 1.3
131    
132     if (fit.fit()){
133    
134     DecayPart *d = new DecayPart(oPid_,DecayPart::Fast);
135 bendavid 1.5
136     // Update temporarily some of the quantities (prob, chi2, nDoF, mass, lxy, pt, fourMomentum)
137     d->setProb(fit.prob());
138     d->setChi2(fit.chisq());
139     d->setNdof(fit.ndof());
140    
141     FourVector p4Fitted(0.,0.,0.,0.);
142     p4Fitted += fit.getTrackP4(1);
143     p4Fitted += fit.getTrackP4(2);
144     d->setFourMomentum(p4Fitted);
145 paus 1.10 d->setPosition (fit.getVertex (MultiVertexFitterD::VERTEX_1));
146     d->setError (fit.getErrorMatrix(MultiVertexFitterD::VERTEX_1));
147 bendavid 1.5 float mass, massErr;
148     const int trksIds[2] = { 1, 2 };
149     mass = fit.getMass(2,trksIds,massErr);
150    
151     ThreeVector p3Fitted(p4Fitted.px(), p4Fitted.py(), p4Fitted.pz());
152    
153     //Get decay length in xy plane
154     float dl, dlErr;
155 paus 1.10 dl = fit.getDecayLength (MultiVertexFitterD::PRIMARY_VERTEX, MultiVertexFitterD::VERTEX_1,
156     p3Fitted, dlErr);
157 bendavid 1.5
158     //Get Z decay length
159     float dlz, dlzErr;
160 paus 1.10 dlz = fit.getZDecayLength(MultiVertexFitterD::PRIMARY_VERTEX, MultiVertexFitterD::VERTEX_1,
161     p3Fitted, dlzErr);
162 bendavid 1.5
163     //get impact parameter
164     float dxy, dxyErr;
165 paus 1.10 dxy = fit.getImpactPar (MultiVertexFitterD::PRIMARY_VERTEX, MultiVertexFitterD::VERTEX_1,
166     p3Fitted, dxyErr);
167 bendavid 1.5
168 bendavid 1.8 BasePartPtr ptr1(hStables1,i);
169     BasePartPtr ptr2(hStables2,j);
170    
171 paus 1.10 StableData c1(fit.getTrackP4(1).px(),fit.getTrackP4(1).py(), fit.getTrackP4(1).pz(), ptr1);
172     StableData c2(fit.getTrackP4(2).px(),fit.getTrackP4(2).py(), fit.getTrackP4(2).pz(), ptr2);
173 bendavid 1.8
174 paus 1.10 const ThreeVector vtxPos = fit.getVertex(MultiVertexFitterD::VERTEX_1);
175     const ThreeVector trkMom1(fit.getTrackP4(1).px(),fit.getTrackP4(1).py(),
176     fit.getTrackP4(1).pz());
177     const ThreeVector trkMom2(fit.getTrackP4(2).px(),fit.getTrackP4(2).py(),
178     fit.getTrackP4(2).pz());
179 bendavid 1.8
180     //build corrected HitPattern for StableData, removing hits before the fit vertex
181     reco::HitPattern hits1 = dropper->CorrectedHits(s1.track(), vtxPos, trkMom1, dlErr, dlzErr);
182     reco::HitPattern hits2 = dropper->CorrectedHits(s2.track(), vtxPos, trkMom2, dlErr, dlzErr);
183    
184     c1.SetHits(hits1);
185     c2.SetHits(hits2);
186 bendavid 1.9 c1.SetHitsFilled();
187     c2.SetHitsFilled();
188 bendavid 1.8
189 paus 1.10 d->addStableChild (c1);
190     d->addStableChild (c2);
191     d->setFittedMass (mass);
192 bendavid 1.5 d->setFittedMassError(massErr);
193 paus 1.10 d->setLxy (dl);
194     d->setLxyError (dlErr);
195     d->setLxyToPv (dl);
196     d->setLxyToPvError (dlErr);
197     d->setLz (dlz);
198     d->setLzError (dlzErr);
199     d->setLzToPv (dlz);
200     d->setLzToPvError (dlzErr);
201     d->setDxy (dxy);
202     d->setDxyError (dxyErr);
203     d->setDxyToPv (dxy);
204     d->setDxyToPvError (dxyErr);
205    
206 mrudolph 1.3 // Put the result into our collection
207     pD->push_back(*d);
208     } //done processing fit
209 loizides 1.7 } //end j loop
210 mrudolph 1.3 } //end i loop
211    
212     // -----------------------------------------------------------------------------------------------
213     // Write the collection even if it is empty
214     // -----------------------------------------------------------------------------------------------
215 loizides 1.7 if (0)
216     cout << " V2SS::produce - " << pD->size() << " entries collection created -"
217     << " (Pid: " << oPid_ << ")\n";
218 mrudolph 1.3 evt.put(pD);
219     }
220    
221     //define this as a plug-in
222     DEFINE_FWK_MODULE(ProducerV2SS);
223