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 
20 
22 
23 //----------------------------------------------------------------------------------------------------
24 
29 {
30 public:
33 
34  void produce( edm::Event&, const edm::EventSetup& ) override;
36 
37 private:
41 
44  bool doNothing_;
45 };
46 
47 //----------------------------------------------------------------------------------------------------
48 
50  doNothing_( iConfig.getParameter<bool>( "doNothing" ) )
51 {
52  if ( doNothing_ ) return;
53 
54  siStripTrackToken_ = consumes< edm::DetSetVector<TotemRPLocalTrack> > ( iConfig.getParameter<edm::InputTag>("tagSiStripTrack") );
55  diamondTrackToken_ = consumes< edm::DetSetVector<CTPPSDiamondLocalTrack> >( iConfig.getParameter<edm::InputTag>("tagDiamondTrack") );
56  auto tagPixelTrack = iConfig.getParameter<edm::InputTag>("tagPixelTrack");
57  if (not tagPixelTrack.label().empty()){
58  pixelTrackToken_ = consumes< edm::DetSetVector<CTPPSPixelLocalTrack> > (tagPixelTrack);
59  }
60 
61 
62  produces< std::vector<CTPPSLocalTrackLite> >();
63 }
64 
65 //----------------------------------------------------------------------------------------------------
66 
67 void
69 {
70  if ( doNothing_ )
71  return;
72 
73 // prepare output
74  std::unique_ptr< std::vector<CTPPSLocalTrackLite> > pOut( new std::vector<CTPPSLocalTrackLite>() );
75 
76 //----- TOTEM strips
77 
78 // get input from Si strips
80  iEvent.getByToken( siStripTrackToken_, inputSiStripTracks );
81 
82 // process tracks from Si strips
83  for ( const auto& rpv : *inputSiStripTracks ) {
84  const uint32_t rpId = rpv.detId();
85  for ( const auto& trk : rpv ) {
86  if ( !trk.isValid() ) continue;
87  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma() );
88  }
89  }
90 
91 //----- diamond detectors
92 
93 // get input from diamond detectors
95  iEvent.getByToken( diamondTrackToken_, inputDiamondTracks );
96 
97 // process tracks from diamond detectors
98  for ( const auto& rpv : *inputDiamondTracks ) {
99  const unsigned int rpId = rpv.detId();
100  for ( const auto& trk : rpv ) {
101  if ( !trk.isValid() ) continue;
102  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma(), trk.getT() );
103  }
104  }
105 
106 
107 //----- pixel detectors
108 
109 // get input from pixel detectors
112  iEvent.getByToken( pixelTrackToken_, inputPixelTracks );
113 
114  // process tracks from pixels
115  for ( const auto& rpv : *inputPixelTracks ) {
116  const uint32_t rpId = rpv.detId();
117  for ( const auto& trk : rpv ) {
118  if ( !trk.isValid() ) continue;
119  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma() );
120  }
121  }
122  }
123 // save output to event
124  iEvent.put( std::move( pOut ) );
125 }
126 
127 //----------------------------------------------------------------------------------------------------
128 
129 void
131 {
133 
134  desc.add<edm::InputTag>( "tagSiStripTrack", edm::InputTag( "totemRPLocalTrackFitter" ) )
135  ->setComment( "input TOTEM strips' local tracks collection to retrieve" );
136  desc.add<edm::InputTag>( "tagDiamondTrack", edm::InputTag( "ctppsDiamondLocalTracks" ) )
137  ->setComment( "input diamond detectors' local tracks collection to retrieve" );
138  desc.add<edm::InputTag>( "tagPixelTrack" , edm::InputTag( "ctppsPixelLocalTracks" ) )
139  ->setComment( "input pixel detectors' local tracks collection to retrieve" );
140  desc.add<bool>( "doNothing", true ) // disable the module by default
141  ->setComment( "disable the module" );
142 
143  descr.add( "ctppsLocalTrackLiteDefaultProducer", desc );
144 }
145 
146 //----------------------------------------------------------------------------------------------------
147 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
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< CTPPSPixelLocalTrack > > pixelTrackToken_
bool isUninitialized() const
Definition: EDGetToken.h:73
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