CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 public:
33 
35 
36 private:
37  void produce(edm::Event&, const edm::EventSetup&) override;
38 
41  std::map<TotemTimingDetId, TotemTimingTrackRecognition> trk_algo_map_;
42 };
43 
45  : recHitsToken_(consumes<edm::DetSetVector<TotemTimingRecHit> >(iConfig.getParameter<edm::InputTag>("recHitsTag"))),
46  maxPlaneActiveChannels_(iConfig.getParameter<int>("maxPlaneActiveChannels")) {
47  produces<edm::DetSetVector<TotemTimingLocalTrack> >();
48 
49  for (unsigned short armNo = 0; armNo < 2; armNo++)
50  for (unsigned short rpNo = 0; rpNo < 2; rpNo++) {
51  TotemTimingDetId id(armNo, 1, rpNo, 0, 0);
52  TotemTimingTrackRecognition trk_algo(iConfig.getParameter<edm::ParameterSet>("trackingAlgorithmParams"));
53  trk_algo_map_.insert(std::make_pair(id, trk_algo));
54  }
55 }
56 
58  auto pOut = std::make_unique<edm::DetSetVector<TotemTimingLocalTrack> >();
59 
61  iEvent.getByToken(recHitsToken_, recHits);
62 
63  for (const auto& trk_algo_entry : trk_algo_map_)
64  pOut->find_or_insert(trk_algo_entry.first);
65 
66  std::map<TotemTimingDetId, int> planeActivityMap;
67 
68  auto motherId = [](const edm::det_id_type& detid) {
69  TotemTimingDetId out(detid);
70  out.setStation(1);
71  out.setChannel(0);
72  return out;
73  };
74 
75  for (const auto& vec : *recHits)
76  planeActivityMap[motherId(vec.detId())] += vec.size();
77 
78  // feed hits to the track producers
79  for (const auto& vec : *recHits) {
80  auto detId = motherId(vec.detId());
81  if (planeActivityMap[detId] > maxPlaneActiveChannels_)
82  continue;
83 
84  detId.setPlane(0);
85  for (const auto& hit : vec) {
86  if (trk_algo_map_.find(detId) == trk_algo_map_.end())
87  throw cms::Exception("TotemTimingLocalTrackFitter")
88  << "Invalid detId for rechit: arm=" << detId.arm() << ", rp=" << detId.rp();
89  trk_algo_map_.find(detId)->second.addHit(hit);
90  }
91  }
92 
93  // retrieves tracks for all hit sets
94  for (auto& trk_algo_entry : trk_algo_map_)
95  trk_algo_entry.second.produceTracks(pOut->operator[](trk_algo_entry.first));
96 
97  iEvent.put(std::move(pOut));
98 
99  // remove all hits from the track producers to prepare for the next event
100  for (auto& trk_algo_entry : trk_algo_map_)
101  trk_algo_entry.second.clear();
102 }
103 
106  desc.add<edm::InputTag>("recHitsTag", edm::InputTag("totemTimingRecHits"))
107  ->setComment("input rechits collection to retrieve");
108  desc.add<int>("maxPlaneActiveChannels", 2)->setComment("threshold for discriminating noisy planes");
109 
110  edm::ParameterSetDescription trackingAlgoParams;
111  trackingAlgoParams.add<double>("threshold", 1.5)
112  ->setComment("minimal number of rechits to be observed before launching the track recognition algorithm");
113  trackingAlgoParams.add<double>("thresholdFromMaximum", 0.5)
114  ->setComment("threshold relative to hit profile function local maximum for determining the width of the track");
115  trackingAlgoParams.add<double>("resolution", 0.01 /* mm */)
116  ->setComment("spatial resolution on the horizontal coordinate (in mm)");
117  trackingAlgoParams.add<double>("sigma", 0.)
118  ->setComment("pixel efficiency function parameter determining the smoothness of the step");
119  trackingAlgoParams.add<double>("tolerance", 0.1 /* mm */)
120  ->setComment("tolerance used for checking if the track contains certain hit");
121 
122  trackingAlgoParams.add<std::string>("pixelEfficiencyFunction", "(x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]")
123  ->setComment(
124  "efficiency function for single pixel\n"
125  "can be defined as:\n"
126  " * Precise: "
127  "(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"
128  " * Fast: "
129  "(x>[0]-0.5*([1]-0.05))*(x<[0]+0.5*([1]-0.05))+((x-[0]+0.5*([1]-0.05)+[2])/"
130  "[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])/"
131  "[2])*(x>[0]+0.5*([1]-0.05))*(x<[0]+0.5*([1]-0.05)+[2])\n"
132  " * Legacy: (1/(1+exp(-(x-[0]+0.5*([1]-0.05))/[2])))*(1/(1+exp((x-[0]-0.5*([1]-0.05))/[2])))\n"
133  " * Default (sigma ignored): (x>[0]-0.5*[1]-0.05)*(x<[0]+0.5*[1]-0.05)+0*[2]\n"
134  "with:\n"
135  " [0]: centre of pad\n"
136  " [1]: width of pad\n"
137  " [2]: sigma: distance between efficiency ~100 -> 0 outside width");
138 
139  trackingAlgoParams.add<double>("yPosition", 0.0)->setComment("vertical offset of the outcoming track centre");
140  trackingAlgoParams.add<double>("yWidth", 0.0)->setComment("vertical track width");
141  desc.add<edm::ParameterSetDescription>("trackingAlgorithmParams", trackingAlgoParams)
142  ->setComment("list of parameters associated to the track recognition algorithm");
143 
144  descr.add("totemTimingLocalTracks", desc);
145 }
146 
T getParameter(std::string const &) const
void setComment(std::string const &value)
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:131
void setChannel(uint32_t channel)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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.
std::map< TotemTimingDetId, TotemTimingTrackRecognition > trk_algo_map_
def move(src, dest)
Definition: eostools.py:511
Detector ID class for CTPPS Totem Timing detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bits ...