CMS 3D CMS Logo

CTPPSLocalTrackLiteProducer.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 * Laurent Forthomme
7 *
8 ****************************************************************************/
9 
15 
19 
21 
22 //----------------------------------------------------------------------------------------------------
23 
28 {
29  public:
32 
33  virtual void produce( edm::Event&, const edm::EventSetup& ) override;
35 
36  private:
39 
42  bool doNothing_;
43 };
44 
45 //----------------------------------------------------------------------------------------------------
46 
48  doNothing_( iConfig.getParameter<bool>( "doNothing" ) )
49 {
50  if ( doNothing_ ) return;
51 
52  siStripTrackToken_ = consumes< edm::DetSetVector<TotemRPLocalTrack> > ( iConfig.getParameter<edm::InputTag>("tagSiStripTrack") );
53  diamondTrackToken_ = consumes< edm::DetSetVector<CTPPSDiamondLocalTrack> >( iConfig.getParameter<edm::InputTag>("tagDiamondTrack") );
54 
55  produces< std::vector<CTPPSLocalTrackLite> >();
56 }
57 
58 //----------------------------------------------------------------------------------------------------
59 
60 void
62 {
63  if ( doNothing_ )
64  return;
65 
66  // prepare output
67  std::unique_ptr< std::vector<CTPPSLocalTrackLite> > pOut( new std::vector<CTPPSLocalTrackLite>() );
68 
69  //----- TOTEM strips
70 
71  // get input from Si strips
73  iEvent.getByToken( siStripTrackToken_, inputSiStripTracks );
74 
75  // process tracks from Si strips
76  for ( const auto& rpv : *inputSiStripTracks ) {
77  const uint32_t rpId = rpv.detId();
78  for ( const auto& trk : rpv ) {
79  if ( !trk.isValid() ) continue;
80  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma() );
81  }
82  }
83 
84  //----- diamond detectors
85 
86  // get input from diamond detectors
88  iEvent.getByToken( diamondTrackToken_, inputDiamondTracks );
89 
90  // process tracks from diamond detectors
91  for ( const auto& rpv : *inputDiamondTracks ) {
92  const unsigned int rpId = rpv.detId();
93  for ( const auto& trk : rpv ) {
94  if ( !trk.isValid() ) continue;
95  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma(), trk.getT() );
96  }
97  }
98 
99  // save output to event
100  iEvent.put( std::move( pOut ) );
101 }
102 
103 //----------------------------------------------------------------------------------------------------
104 
105 void
107 {
109 
110  desc.add<edm::InputTag>( "tagSiStripTrack", edm::InputTag( "totemRPLocalTrackFitter" ) )
111  ->setComment( "input TOTEM strips' local tracks collection to retrieve" );
112  desc.add<edm::InputTag>( "tagDiamondTrack", edm::InputTag( "ctppsDiamondLocalTracks" ) )
113  ->setComment( "input diamond detectors' local tracks collection to retrieve" );
114  desc.add<bool>( "doNothing", true ) // disable the module by default
115  ->setComment( "disable the module" );
116 
117  descr.add( "ctppsLocalTrackLiteDefaultProducer", desc );
118 }
119 
120 //----------------------------------------------------------------------------------------------------
121 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
virtual void produce(edm::Event &, const edm::EventSetup &) override
CTPPSLocalTrackLiteProducer(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Distills the essential track data from all RPs.
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondLocalTrack > > diamondTrackToken_
edm::EDGetTokenT< edm::DetSetVector< TotemRPLocalTrack > > siStripTrackToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
def move(src, dest)
Definition: eostools.py:510