CMS 3D CMS Logo

TotemTimingLocalTrackFitter.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of CTPPS offline software.
4  * Authors:
5  * Laurent Forthomme (laurent.forthomme@cern.ch)
6  * Nicola Minafra (nicola.minafra@cern.ch)
7  * Mateusz Szpyrka (mateusz.szpyrka@cern.ch)
8  *
9  ****************************************************************************/
10 
11 #include <memory>
12 #include <utility>
13 
18 
21 
23 
27 
29 
31 {
32  public:
34 
36 
37  private:
38  void produce( edm::Event&, const edm::EventSetup& ) override;
39 
42  std::map<TotemTimingDetId,TotemTimingTrackRecognition> trk_algo_map_;
43 };
44 
46  recHitsToken_( consumes<edm::DetSetVector<TotemTimingRecHit> >( iConfig.getParameter<edm::InputTag>( "recHitsTag" ) ) ),
47  maxPlaneActiveChannels_( iConfig.getParameter<int>( "maxPlaneActiveChannels" ) )
48 {
49  produces<edm::DetSetVector<TotemTimingLocalTrack> >();
50 
51  for ( unsigned short armNo = 0; armNo < 2; armNo++ )
52  for ( unsigned short rpNo = 0; rpNo < 2; rpNo++ ) {
53  TotemTimingDetId id( armNo, 1, rpNo, 0, 0 );
54  TotemTimingTrackRecognition trk_algo( iConfig.getParameter<edm::ParameterSet>( "trackingAlgorithmParams" ) );
55  trk_algo_map_.insert( std::make_pair( id, trk_algo ) );
56  }
57 }
58 
59 void
61 {
62  auto pOut = std::make_unique<edm::DetSetVector<TotemTimingLocalTrack> >();
63 
65  iEvent.getByToken( recHitsToken_, recHits );
66 
67  for ( const auto& trk_algo_entry : trk_algo_map_ )
68  pOut->find_or_insert( trk_algo_entry.first );
69 
70  std::map<TotemTimingDetId,int> planeActivityMap;
71 
72  auto motherId = []( const edm::det_id_type& detid ) {
73  TotemTimingDetId out( detid );
74  out.setStation( 1 );
75  out.setChannel( 0 );
76  return out;
77  };
78 
79  for ( const auto& vec: *recHits )
80  planeActivityMap[motherId(vec.detId())] += vec.size();
81 
82  // feed hits to the track producers
83  for ( const auto& vec : *recHits ) {
84  auto detId = motherId( vec.detId() );
85  if ( planeActivityMap[detId] > maxPlaneActiveChannels_ )
86  continue;
87 
88  detId.setPlane( 0 );
89  for ( const auto& hit : vec ) {
90  if ( trk_algo_map_.find( detId ) == trk_algo_map_.end() )
91  throw cms::Exception("TotemTimingLocalTrackFitter")
92  << "Invalid detId for rechit: arm=" << detId.arm() << ", rp=" << detId.rp();
93  trk_algo_map_.find( detId )->second.addHit( hit );
94  }
95  }
96 
97  // retrieves tracks for all hit sets
98  for ( auto& trk_algo_entry : trk_algo_map_ )
99  trk_algo_entry.second.produceTracks( pOut->operator[]( trk_algo_entry.first ) );
100 
101  iEvent.put( std::move( pOut ) );
102 
103  // remove all hits from the track producers to prepare for the next event
104  for ( auto& trk_algo_entry : trk_algo_map_ )
105  trk_algo_entry.second.clear();
106 }
107 
108 void
110 {
112  desc.add<edm::InputTag>( "recHitsTag", edm::InputTag( "totemTimingRecHits" ) )
113  ->setComment( "input rechits collection to retrieve" );
114  desc.add<int>( "maxPlaneActiveChannels", 2 )
115  ->setComment( "threshold for discriminating noisy planes" );
116 
117  edm::ParameterSetDescription trackingAlgoParams;
118  trackingAlgoParams.add<double>( "threshold", 1.5 )
119  ->setComment( "minimal number of rechits to be observed before launching the track recognition algorithm" );
120  trackingAlgoParams.add<double>( "thresholdFromMaximum", 0.5 )
121  ->setComment( "threshold relative to hit profile function local maximum for determining the width of the track" );
122  trackingAlgoParams.add<double>( "resolution", 0.01 /* mm */ )
123  ->setComment( "spatial resolution on the horizontal coordinate (in mm)" );
124  trackingAlgoParams.add<double>( "sigma", 0. )
125  ->setComment( "pixel efficiency function parameter determining the smoothness of the step" );
126  trackingAlgoParams.add<double>( "tolerance", 0.1 /* mm */)
127  ->setComment( "tolerance used for checking if the track contains certain hit" );
128 
129  trackingAlgoParams.add<std::string>( "pixelEfficiencyFunction", "(x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]" )
130  ->setComment( "efficiency function for single pixel\n"
131  "can be defined as:\n"
132  " * Precise: (TMath::Erf((x-[0]+0.5*([1]-0.05))/([2]/4)+2)+1)*TMath::Erfc((x-[0]-0.5*([1]-0.05))/([2]/4)-2)/4\n"
133  " * Fast: (x>[0]-0.5*([1]-0.05))*(x<[0]+0.5*([1]-0.05))+((x-[0]+0.5*([1]-0.05)+[2])/[2])*(x>[0]-0.5*([1]-0.05)-[2])*(x<[0]-0.5*([1]-0.05))+(2-(x-[0]-0.5*([1]-0.05)+[2])/[2])*(x>[0]+0.5*([1]-0.05))*(x<[0]+0.5*([1]-0.05)+[2])\n"
134  " * Legacy: (1/(1+exp(-(x-[0]+0.5*([1]-0.05))/[2])))*(1/(1+exp((x-[0]-0.5*([1]-0.05))/[2])))\n"
135  " * Default (sigma ignored): (x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]\n"
136  "with:\n"
137  " [0]: centre of pad\n"
138  " [1]: width of pad\n"
139  " [2]: sigma: distance between efficiency ~100 -> 0 outside width" );
140 
141  trackingAlgoParams.add<double>( "yPosition", 0.0 )
142  ->setComment( "vertical offset of the outcoming track centre" );
143  trackingAlgoParams.add<double>( "yWidth", 0.0 )
144  ->setComment( "vertical track width" );
145  desc.add<edm::ParameterSetDescription>( "trackingAlgorithmParams", trackingAlgoParams )
146  ->setComment( "list of parameters associated to the track recognition algorithm" );
147 
148  descr.add( "totemTimingLocalTracks", desc );
149 }
150 
152 
T getParameter(std::string const &) const
TotemTimingLocalTrackFitter(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void setChannel(uint32_t channel)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setStation(uint32_t station)
Definition: CTPPSDetId.h:60
uint32_t det_id_type
Definition: DetSet.h:21
static void fillDescriptions(edm::ConfigurationDescriptions &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< edm::DetSetVector< TotemTimingRecHit > > recHitsToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:511
std::map< TotemTimingDetId, TotemTimingTrackRecognition > trk_algo_map_
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...