Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:46

0001 #include "ShallowTracksProducer.h"
0002 
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "DataFormats/TrackReco/interface/Track.h"
0006 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0007 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0008 
0009 ShallowTracksProducer::ShallowTracksProducer(const edm::ParameterSet& iConfig)
0010     : tracks_token_(consumes<edm::View<reco::Track>>(iConfig.getParameter<edm::InputTag>("Tracks"))),
0011       Prefix(iConfig.getParameter<std::string>("Prefix")),
0012       Suffix(iConfig.getParameter<std::string>("Suffix")),
0013       numberPut_(produces<unsigned int>(Prefix + "number" + Suffix)),
0014       chi2Put_(produces<std::vector<double>>(Prefix + "chi2" + Suffix)),
0015       ndofPut_(produces<std::vector<double>>(Prefix + "ndof" + Suffix)),
0016       chi2ndofPut_(produces<std::vector<double>>(Prefix + "chi2ndof" + Suffix)),
0017       chargePut_(produces<std::vector<float>>(Prefix + "charge" + Suffix)),
0018       momentumPut_(produces<std::vector<float>>(Prefix + "momentum" + Suffix)),
0019       ptPut_(produces<std::vector<float>>(Prefix + "pt" + Suffix)),
0020       pterrPut_(produces<std::vector<float>>(Prefix + "pterr" + Suffix)),
0021       hitsvalidPut_(produces<std::vector<unsigned int>>(Prefix + "hitsvalid" + Suffix)),
0022       hitslostPut_(produces<std::vector<unsigned int>>(Prefix + "hitslost" + Suffix)),
0023       thetaPut_(produces<std::vector<double>>(Prefix + "theta" + Suffix)),
0024       thetaerrPut_(produces<std::vector<double>>(Prefix + "thetaerr" + Suffix)),
0025       phiPut_(produces<std::vector<double>>(Prefix + "phi" + Suffix)),
0026       phierrPut_(produces<std::vector<double>>(Prefix + "phierr" + Suffix)),
0027       etaPut_(produces<std::vector<double>>(Prefix + "eta" + Suffix)),
0028       etaerrPut_(produces<std::vector<double>>(Prefix + "etaerr" + Suffix)),
0029       dxyPut_(produces<std::vector<double>>(Prefix + "dxy" + Suffix)),
0030       dxyerrPut_(produces<std::vector<double>>(Prefix + "dxyerr" + Suffix)),
0031       dszPut_(produces<std::vector<double>>(Prefix + "dsz" + Suffix)),
0032       dszerrPut_(produces<std::vector<double>>(Prefix + "dszerr" + Suffix)),
0033       qoverpPut_(produces<std::vector<double>>(Prefix + "qoverp" + Suffix)),
0034       qoverperrPut_(produces<std::vector<double>>(Prefix + "qoverperr" + Suffix)),
0035       vxPut_(produces<std::vector<double>>(Prefix + "vx" + Suffix)),
0036       vyPut_(produces<std::vector<double>>(Prefix + "vy" + Suffix)),
0037       vzPut_(produces<std::vector<double>>(Prefix + "vz" + Suffix)),
0038       algoPut_(produces<std::vector<int>>(Prefix + "algo" + Suffix)) {}
0039 
0040 void ShallowTracksProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0041   edm::Handle<edm::View<reco::Track>> tracks;
0042   iEvent.getByToken(tracks_token_, tracks);
0043 
0044   unsigned int number = tracks->size();
0045   std::vector<double> chi2;
0046   chi2.reserve(number);
0047   std::vector<double> ndof;
0048   ndof.reserve(number);
0049   std::vector<double> chi2ndof;
0050   chi2ndof.reserve(number);
0051   std::vector<float> charge;
0052   charge.reserve(number);
0053   std::vector<float> momentum;
0054   momentum.reserve(number);
0055   std::vector<float> pt;
0056   pt.reserve(number);
0057   std::vector<float> pterr;
0058   pterr.reserve(number);
0059   std::vector<unsigned int> hitsvalid;
0060   hitsvalid.reserve(number);
0061   std::vector<unsigned int> hitslost;
0062   hitslost.reserve(number);
0063   std::vector<double> theta;
0064   theta.reserve(number);
0065   std::vector<double> thetaerr;
0066   thetaerr.reserve(number);
0067   std::vector<double> phi;
0068   phi.reserve(number);
0069   std::vector<double> phierr;
0070   phierr.reserve(number);
0071   std::vector<double> eta;
0072   eta.reserve(number);
0073   std::vector<double> etaerr;
0074   etaerr.reserve(number);
0075   std::vector<double> dxy;
0076   dxy.reserve(number);
0077   std::vector<double> dxyerr;
0078   dxyerr.reserve(number);
0079   std::vector<double> dsz;
0080   dsz.reserve(number);
0081   std::vector<double> dszerr;
0082   dszerr.reserve(number);
0083   std::vector<double> qoverp;
0084   qoverp.reserve(number);
0085   std::vector<double> qoverperr;
0086   qoverperr.reserve(number);
0087   std::vector<double> vx;
0088   vx.reserve(number);
0089   std::vector<double> vy;
0090   vy.reserve(number);
0091   std::vector<double> vz;
0092   vz.reserve(number);
0093   std::vector<int> algo;
0094   algo.reserve(number);
0095 
0096   for (auto const& track : *tracks) {
0097     chi2.push_back(track.chi2());
0098     ndof.push_back(track.ndof());
0099     chi2ndof.push_back(track.chi2() / track.ndof());
0100     charge.push_back(track.charge());
0101     momentum.push_back(track.p());
0102     pt.push_back(track.pt());
0103     pterr.push_back(track.ptError());
0104     hitsvalid.push_back(track.numberOfValidHits());
0105     hitslost.push_back(track.numberOfLostHits());
0106     theta.push_back(track.theta());
0107     thetaerr.push_back(track.thetaError());
0108     phi.push_back(track.phi());
0109     phierr.push_back(track.phiError());
0110     eta.push_back(track.eta());
0111     etaerr.push_back(track.etaError());
0112     dxy.push_back(track.dxy());
0113     dxyerr.push_back(track.dxyError());
0114     dsz.push_back(track.dsz());
0115     dszerr.push_back(track.dszError());
0116     qoverp.push_back(track.qoverp());
0117     qoverperr.push_back(track.qoverpError());
0118     vx.push_back(track.vx());
0119     vy.push_back(track.vy());
0120     vz.push_back(track.vz());
0121     algo.push_back((int)track.algo());
0122   }
0123 
0124   iEvent.emplace(numberPut_, number);
0125   iEvent.emplace(chi2Put_, std::move(chi2));
0126   iEvent.emplace(ndofPut_, std::move(ndof));
0127   iEvent.emplace(chi2ndofPut_, std::move(chi2ndof));
0128   iEvent.emplace(chargePut_, std::move(charge));
0129   iEvent.emplace(momentumPut_, std::move(momentum));
0130   iEvent.emplace(ptPut_, std::move(pt));
0131   iEvent.emplace(pterrPut_, std::move(pterr));
0132   iEvent.emplace(hitsvalidPut_, std::move(hitsvalid));
0133   iEvent.emplace(hitslostPut_, std::move(hitslost));
0134   iEvent.emplace(thetaPut_, std::move(theta));
0135   iEvent.emplace(thetaerrPut_, std::move(thetaerr));
0136   iEvent.emplace(phiPut_, std::move(phi));
0137   iEvent.emplace(phierrPut_, std::move(phierr));
0138   iEvent.emplace(etaPut_, std::move(eta));
0139   iEvent.emplace(etaerrPut_, std::move(etaerr));
0140   iEvent.emplace(dxyPut_, std::move(dxy));
0141   iEvent.emplace(dxyerrPut_, std::move(dxyerr));
0142   iEvent.emplace(dszPut_, std::move(dsz));
0143   iEvent.emplace(dszerrPut_, std::move(dszerr));
0144   iEvent.emplace(qoverpPut_, std::move(qoverp));
0145   iEvent.emplace(qoverperrPut_, std::move(qoverperr));
0146   iEvent.emplace(vxPut_, std::move(vx));
0147   iEvent.emplace(vyPut_, std::move(vy));
0148   iEvent.emplace(vzPut_, std::move(vz));
0149   iEvent.emplace(algoPut_, std::move(algo));
0150 }