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 
42  std::vector<double> pixelTrackTxRange_;
43  std::vector<double> pixelTrackTyRange_;
46  bool doNothing_;
47 };
48 
49 //----------------------------------------------------------------------------------------------------
50 
52  doNothing_( iConfig.getParameter<bool>( "doNothing" ) )
53 {
54  if ( doNothing_ ) return;
55 
56  siStripTrackToken_ = consumes< edm::DetSetVector<TotemRPLocalTrack> > ( iConfig.getParameter<edm::InputTag>("tagSiStripTrack") );
57  diamondTrackToken_ = consumes< edm::DetSetVector<CTPPSDiamondLocalTrack> >( iConfig.getParameter<edm::InputTag>("tagDiamondTrack") );
58  auto tagPixelTrack = iConfig.getParameter<edm::InputTag>("tagPixelTrack");
59  if (not tagPixelTrack.label().empty()){
60  pixelTrackToken_ = consumes< edm::DetSetVector<CTPPSPixelLocalTrack> > (tagPixelTrack);
61  }
62 
63  pixelTrackTxRange_ = iConfig.getParameter<std::vector<double> >("pixelTrackTxRange");
64  pixelTrackTyRange_ = iConfig.getParameter<std::vector<double> >("pixelTrackTyRange");
65  produces< std::vector<CTPPSLocalTrackLite> >();
66 }
67 
68 //----------------------------------------------------------------------------------------------------
69 
70 void
72 {
73  if ( doNothing_ )
74  return;
75 
76 // prepare output
77  std::unique_ptr< std::vector<CTPPSLocalTrackLite> > pOut( new std::vector<CTPPSLocalTrackLite>() );
78 
79 //----- TOTEM strips
80 
81 // get input from Si strips
83  iEvent.getByToken( siStripTrackToken_, inputSiStripTracks );
84 
85 // process tracks from Si strips
86  for ( const auto& rpv : *inputSiStripTracks ) {
87  const uint32_t rpId = rpv.detId();
88  for ( const auto& trk : rpv ) {
89  if ( !trk.isValid() ) continue;
90  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma() );
91  }
92  }
93 
94 //----- diamond detectors
95 
96 // get input from diamond detectors
98  iEvent.getByToken( diamondTrackToken_, inputDiamondTracks );
99 
100 // process tracks from diamond detectors
101  for ( const auto& rpv : *inputDiamondTracks ) {
102  const unsigned int rpId = rpv.detId();
103  for ( const auto& trk : rpv ) {
104  if ( !trk.isValid() ) continue;
105  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma(), trk.getT() );
106  }
107  }
108 
109 
110 //----- pixel detectors
111 
112 // get input from pixel detectors
113  if(pixelTrackTxRange_.size() != 2 || pixelTrackTyRange_.size() != 2) throw cms::Exception("CTPPSLocalTrackLiteProducer")
114  << "Wrong number of parameters in pixel track Tx/Ty range";
117  iEvent.getByToken( pixelTrackToken_, inputPixelTracks );
118 
119  // process tracks from pixels
120  for ( const auto& rpv : *inputPixelTracks ) {
121  const uint32_t rpId = rpv.detId();
122  for ( const auto& trk : rpv ) {
123  if ( !trk.isValid() ) continue;
124  if(trk.getTx()>pixelTrackTxRange_.at(0) && trk.getTx()<pixelTrackTxRange_.at(1)
125  && trk.getTy()>pixelTrackTyRange_.at(0) && trk.getTy()<pixelTrackTyRange_.at(1) )
126  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma() );
127  }
128  }
129  }
130 // save output to event
131  iEvent.put( std::move( pOut ) );
132 }
133 
134 //----------------------------------------------------------------------------------------------------
135 
136 void
138 {
140 
141  desc.add<edm::InputTag>( "tagSiStripTrack", edm::InputTag( "totemRPLocalTrackFitter" ) )
142  ->setComment( "input TOTEM strips' local tracks collection to retrieve" );
143  desc.add<edm::InputTag>( "tagDiamondTrack", edm::InputTag( "ctppsDiamondLocalTracks" ) )
144  ->setComment( "input diamond detectors' local tracks collection to retrieve" );
145  desc.add<edm::InputTag>( "tagPixelTrack" , edm::InputTag( "ctppsPixelLocalTracks" ) )
146  ->setComment( "input pixel detectors' local tracks collection to retrieve" );
147  desc.add<bool>( "doNothing", true ) // disable the module by default
148  ->setComment( "disable the module" );
149 
150  desc.add<std::vector<double> >("pixelTrackTxRange",std::vector<double>({-0.03,0.03}) );
151  desc.add<std::vector<double> >("pixelTrackTyRange",std::vector<double>({-0.04,0.04}) );
152 
153  descr.add( "ctppsLocalTrackLiteDefaultProducer", desc );
154 }
155 
156 //----------------------------------------------------------------------------------------------------
157 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#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