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:
40 
43 
46 
47  std::vector<double> pixelTrackTxRange_;
48  std::vector<double> pixelTrackTyRange_;
51  bool doNothing_;
52 };
53 
54 //----------------------------------------------------------------------------------------------------
55 
57  doNothing_( iConfig.getParameter<bool>( "doNothing" ) )
58 {
59  if ( doNothing_ ) return;
60 
61  includeStrips_ = iConfig.getParameter<bool>("includeStrips");
62  siStripTrackToken_ = consumes< edm::DetSetVector<TotemRPLocalTrack> > ( iConfig.getParameter<edm::InputTag>("tagSiStripTrack") );
63 
64  includeDiamonds_ = iConfig.getParameter<bool>("includeDiamonds");
65  diamondTrackToken_ = consumes< edm::DetSetVector<CTPPSDiamondLocalTrack> >( iConfig.getParameter<edm::InputTag>("tagDiamondTrack") );
66 
67  includePixels_ = iConfig.getParameter<bool>("includePixels");
68  auto tagPixelTrack = iConfig.getParameter<edm::InputTag>("tagPixelTrack");
69  if (not tagPixelTrack.label().empty()){
70  pixelTrackToken_ = consumes< edm::DetSetVector<CTPPSPixelLocalTrack> > (tagPixelTrack);
71  }
72 
73  pixelTrackTxRange_ = iConfig.getParameter<std::vector<double> >("pixelTrackTxRange");
74  pixelTrackTyRange_ = iConfig.getParameter<std::vector<double> >("pixelTrackTyRange");
75  produces< std::vector<CTPPSLocalTrackLite> >();
76 }
77 
78 //----------------------------------------------------------------------------------------------------
79 
80 void
82 {
83  if ( doNothing_ )
84  return;
85 
86  // prepare output
87  std::unique_ptr< std::vector<CTPPSLocalTrackLite> > pOut( new std::vector<CTPPSLocalTrackLite>() );
88 
89  //----- TOTEM strips
90 
91  // get input from Si strips
92  if (includeStrips_)
93  {
95  iEvent.getByToken( siStripTrackToken_, inputSiStripTracks );
96 
97  // process tracks from Si strips
98  for ( const auto& rpv : *inputSiStripTracks ) {
99  const uint32_t 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() );
103  }
104  }
105  }
106 
107  //----- diamond detectors
108 
109  if (includeDiamonds_)
110  {
111  // get input from diamond detectors
113  iEvent.getByToken( diamondTrackToken_, inputDiamondTracks );
114 
115  // process tracks from diamond detectors
116  for ( const auto& rpv : *inputDiamondTracks ) {
117  const unsigned int rpId = rpv.detId();
118  for ( const auto& trk : rpv ) {
119  if ( !trk.isValid() ) continue;
120  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma(), trk.getT() );
121  }
122  }
123  }
124 
125 
126  //----- pixel detectors
127 
128  if (includePixels_)
129  {
130  // get input from pixel detectors
131  if(pixelTrackTxRange_.size() != 2 || pixelTrackTyRange_.size() != 2) throw cms::Exception("CTPPSLocalTrackLiteProducer")
132  << "Wrong number of parameters in pixel track Tx/Ty range";
135  iEvent.getByToken( pixelTrackToken_, inputPixelTracks );
136 
137  // process tracks from pixels
138  for ( const auto& rpv : *inputPixelTracks ) {
139  const uint32_t rpId = rpv.detId();
140  for ( const auto& trk : rpv ) {
141  if ( !trk.isValid() ) continue;
142  if(trk.getTx()>pixelTrackTxRange_.at(0) && trk.getTx()<pixelTrackTxRange_.at(1)
143  && trk.getTy()>pixelTrackTyRange_.at(0) && trk.getTy()<pixelTrackTyRange_.at(1) )
144  pOut->emplace_back( rpId, trk.getX0(), trk.getX0Sigma(), trk.getY0(), trk.getY0Sigma() );
145  }
146  }
147  }
148  }
149 
150  // save output to event
151  iEvent.put( std::move( pOut ) );
152 }
153 
154 //----------------------------------------------------------------------------------------------------
155 
156 void
158 {
160 
161  desc.add<bool>("includeStrips", true)->setComment("whether tracks from Si strips should be included");
162  desc.add<edm::InputTag>( "tagSiStripTrack", edm::InputTag( "totemRPLocalTrackFitter" ) )
163  ->setComment( "input TOTEM strips' local tracks collection to retrieve" );
164 
165  desc.add<bool>("includeDiamonds", true)->setComment("whether tracks from diamonds strips should be included");
166  desc.add<edm::InputTag>( "tagDiamondTrack", edm::InputTag( "ctppsDiamondLocalTracks" ) )
167  ->setComment( "input diamond detectors' local tracks collection to retrieve" );
168 
169  desc.add<bool>("includePixels", true)->setComment("whether tracks from pixels should be included");
170  desc.add<edm::InputTag>( "tagPixelTrack" , edm::InputTag( "ctppsPixelLocalTracks" ) )
171  ->setComment( "input pixel detectors' local tracks collection to retrieve" );
172  desc.add<bool>( "doNothing", true ) // disable the module by default
173  ->setComment( "disable the module" );
174 
175  desc.add<std::vector<double> >("pixelTrackTxRange",std::vector<double>({-0.03,0.03}) );
176  desc.add<std::vector<double> >("pixelTrackTyRange",std::vector<double>({-0.04,0.04}) );
177 
178  descr.add( "ctppsLocalTrackLiteDefaultProducer", desc );
179 }
180 
181 //----------------------------------------------------------------------------------------------------
182 
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:511