CMS 3D CMS Logo

RPCSeedrecHitFinder.cc
Go to the documentation of this file.
1 
9 
10 using namespace std;
11 using namespace edm;
12 
13 // Comparator function must be global function?
14 // Could not be included in .h file, or there will be 2 lessPhi() functions in both RPCSeedGenerator and RPCSeedFinder module
17  // Don't need to use value() in Geom::Phi to short
18  return (it1->globalPosition().phi() < it2->globalPosition().phi());
19 }
20 
22  // Initiate the member
23  isLayerset = false;
24  isConfigured = false;
25  isInputset = false;
26  isOutputset = false;
27  BxRange = 0;
28  MaxDeltaPhi = 0;
29  ClusterSet.clear();
30  LayersinRPC.clear();
31  therecHits.clear();
32 }
33 
35 
37  // Set the configuration
38  BxRange = iConfig.getParameter<unsigned int>("BxRange");
39  MaxDeltaPhi = iConfig.getParameter<double>("MaxDeltaPhi");
40  ClusterSet = iConfig.getParameter<std::vector<int> >("ClusterSet");
41 
42  // Set the signal open
43  isConfigured = true;
44 }
45 
47  for (unsigned int i = 0; i < RPCLayerNumber; i++)
48  recHitsRPC[i] = &recHits[i];
49  isInputset = true;
50 }
51 
52 void RPCSeedrecHitFinder::unsetInput() { isInputset = false; }
54  theSeed = Seed;
55  isOutputset = true;
56 }
57 
58 void RPCSeedrecHitFinder::setLayers(const std::vector<unsigned int>& Layers) {
59  LayersinRPC = Layers;
60  isLayerset = true;
61 }
62 
64  if (isLayerset == false || isConfigured == false || isOutputset == false || isInputset == false) {
65  cout << "Not set the IO or not configured yet" << endl;
66  return;
67  }
68  cout << "Now fill recHits from Layers: ";
69  for (unsigned int k = 0; k < LayersinRPC.size(); k++)
70  cout << LayersinRPC[k] << " ";
71  cout << endl;
72  unsigned int LayerIndex = 0;
73  therecHits.clear();
74  complete(LayerIndex);
75 
76  // Unset the signal
77  LayersinRPC.clear();
78  therecHits.clear();
79  isLayerset = false;
80 }
81 
82 void RPCSeedrecHitFinder::complete(unsigned int LayerIndex) {
83  for (MuonRecHitContainer::const_iterator it = recHitsRPC[LayersinRPC[LayerIndex]]->begin();
84  it != recHitsRPC[LayersinRPC[LayerIndex]]->end();
85  it++) {
86  cout << "Completing layer[" << LayersinRPC[LayerIndex] << "]." << endl;
87 
88  // Check validation
89  if (!(*it)->isValid())
90  continue;
91 
92  // Check BX range, be sure there is only RPCRecHit in the MuonRecHitContainer when use the dynamic_cast
93  TrackingRecHit* thisTrackingRecHit = (*it)->hit()->clone();
94  // Should also delete the RPCRecHit object cast by dynamic_cast<> ?
95  RPCRecHit* thisRPCRecHit = dynamic_cast<RPCRecHit*>(thisTrackingRecHit);
96  int BX = thisRPCRecHit->BunchX();
97  int ClusterSize = thisRPCRecHit->clusterSize();
98  delete thisTrackingRecHit;
99  // Check BX
100  if ((unsigned int)abs(BX) > BxRange)
101  continue;
102  // Check cluster size
103  bool Clustercheck = false;
104  if (ClusterSet.empty())
105  Clustercheck = true;
106  for (std::vector<int>::const_iterator CluIter = ClusterSet.begin(); CluIter != ClusterSet.end(); CluIter++)
107  if (ClusterSize == (*CluIter))
108  Clustercheck = true;
109  if (Clustercheck != true)
110  continue;
111  // Check the recHits Phi range
112  GlobalPoint pos = (*it)->globalPosition();
113  double Phi = pos.phi();
114  cout << "Phi: " << Phi << endl;
115  // The recHits should locate in some phi range
116  therecHits.push_back(*it);
117  double deltaPhi = getdeltaPhifromrecHits();
118  cout << "Delta phi: " << deltaPhi << endl;
119  therecHits.pop_back();
120  if (deltaPhi > MaxDeltaPhi)
121  continue;
122 
123  // If pass all, add to the seed
124  therecHits.push_back(*it);
125  cout << "RecHit's global position: " << pos.x() << ", " << pos.y() << ", " << pos.z() << endl;
126 
127  // Check if this recHit is the last one in the seed
128  // If it is the last one, calculate the seed
129  if (LayerIndex == (LayersinRPC.size() - 1)) {
130  cout << "Check and fill one seed." << endl;
131  checkandfill();
132  }
133  // If it is not the last one, continue to fill the seed from other layers
134  else
135  complete(LayerIndex + 1);
136 
137  // Remember to pop the recHit before add another one from the same layer!
138  therecHits.pop_back();
139  }
140 }
141 
143  ConstMuonRecHitContainer sortRecHits = therecHits;
144  sort(sortRecHits.begin(), sortRecHits.end(), lessPhi);
145  cout << "Sorted recHit's Phi: ";
146  for (ConstMuonRecHitContainer::const_iterator iter = sortRecHits.begin(); iter != sortRecHits.end(); iter++)
147  cout << (*iter)->globalPosition().phi() << ", ";
148  cout << endl;
149  // Calculate the deltaPhi, take care Geom::Phi always in range [-pi,pi)
150  // In case of some deltaPhi larger then Pi, use value() in Geom::Phi to get the true value in radians of Phi, then do the calculation
151  double deltaPhi = 0;
152  if (sortRecHits.size() <= 1)
153  return deltaPhi;
154  if (sortRecHits.size() == 2) {
155  ConstMuonRecHitContainer::const_iterator iter1 = sortRecHits.begin();
156  ConstMuonRecHitContainer::const_iterator iter2 = sortRecHits.begin();
157  iter2++;
158  deltaPhi = (((*iter2)->globalPosition().phi().value() - (*iter1)->globalPosition().phi().value()) > M_PI)
159  ? (2 * M_PI - ((*iter2)->globalPosition().phi().value() - (*iter1)->globalPosition().phi().value()))
160  : ((*iter2)->globalPosition().phi().value() - (*iter1)->globalPosition().phi().value());
161  return deltaPhi;
162  } else {
163  deltaPhi = 2 * M_PI;
164  int n = 0;
165  for (ConstMuonRecHitContainer::const_iterator iter = sortRecHits.begin(); iter != sortRecHits.end(); iter++) {
166  cout << "Before this loop deltaPhi is " << deltaPhi << endl;
167  n++;
168  double deltaPhi_more = 0;
169  double deltaPhi_less = 0;
170  if (iter == sortRecHits.begin()) {
171  cout << "Calculateing frist loop..." << endl;
172  ConstMuonRecHitContainer::const_iterator iter_more = ++iter;
173  --iter;
174  ConstMuonRecHitContainer::const_iterator iter_less = sortRecHits.end();
175  --iter_less;
176  cout << "more_Phi: " << (*iter_more)->globalPosition().phi()
177  << ", less_Phi: " << (*iter_less)->globalPosition().phi()
178  << ", iter_Phi: " << (*iter)->globalPosition().phi() << endl;
179  deltaPhi_more =
180  (2 * M_PI) - ((*iter_more)->globalPosition().phi().value() - (*iter)->globalPosition().phi().value());
181  deltaPhi_less = (*iter_less)->globalPosition().phi().value() - (*iter)->globalPosition().phi().value();
182  } else if (iter == (--sortRecHits.end())) {
183  cout << "Calculateing last loop..." << endl;
184  ConstMuonRecHitContainer::const_iterator iter_less = --iter;
185  ++iter;
186  ConstMuonRecHitContainer::const_iterator iter_more = sortRecHits.begin();
187  cout << "more_Phi: " << (*iter_more)->globalPosition().phi()
188  << ", less_Phi: " << (*iter_less)->globalPosition().phi()
189  << ", iter_Phi: " << (*iter)->globalPosition().phi() << endl;
190  deltaPhi_less =
191  (2 * M_PI) - ((*iter)->globalPosition().phi().value() - (*iter_less)->globalPosition().phi().value());
192  deltaPhi_more = (*iter)->globalPosition().phi().value() - (*iter_more)->globalPosition().phi().value();
193  } else {
194  cout << "Calculateing " << n << "st loop..." << endl;
195  ConstMuonRecHitContainer::const_iterator iter_less = --iter;
196  ++iter;
197  ConstMuonRecHitContainer::const_iterator iter_more = ++iter;
198  --iter;
199  cout << "more_Phi: " << (*iter_more)->globalPosition().phi()
200  << ", less_Phi: " << (*iter_less)->globalPosition().phi()
201  << ", iter_Phi: " << (*iter)->globalPosition().phi() << endl;
202  deltaPhi_less =
203  (2 * M_PI) - ((*iter)->globalPosition().phi().value() - (*iter_less)->globalPosition().phi().value());
204  deltaPhi_more =
205  (2 * M_PI) - ((*iter_more)->globalPosition().phi().value() - (*iter)->globalPosition().phi().value());
206  }
207  if (deltaPhi > deltaPhi_more)
208  deltaPhi = deltaPhi_more;
209  if (deltaPhi > deltaPhi_less)
210  deltaPhi = deltaPhi_less;
211 
212  cout << "For this loop deltaPhi_more is " << deltaPhi_more << endl;
213  cout << "For this loop deltaPhi_less is " << deltaPhi_less << endl;
214  cout << "For this loop deltaPhi is " << deltaPhi << endl;
215  }
216  return deltaPhi;
217  }
218 }
219 
221  if (therecHits.size() >= 3) {
222  theSeed->setrecHits(therecHits);
223  theSeed->seed();
224  } else
225  cout << "Layer less than 3, could not fill a RPCSeedFinder" << endl;
226 }
mps_fire.i
i
Definition: mps_fire.py:428
MuonTransientTrackingRecHit::ConstMuonRecHitPointer
std::shared_ptr< MuonTransientTrackingRecHit const > ConstMuonRecHitPointer
Definition: MuonTransientTrackingRecHit.h:22
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
RPCSeedrecHitFinder.h
RPCSeedrecHitFinder::getdeltaPhifromrecHits
double getdeltaPhifromrecHits()
Definition: RPCSeedrecHitFinder.cc:142
RPCSeedrecHitFinder::fillrecHits
void fillrecHits()
Definition: RPCSeedrecHitFinder.cc:63
RPCSeedrecHitFinder::~RPCSeedrecHitFinder
~RPCSeedrecHitFinder()
Definition: RPCSeedrecHitFinder.cc:34
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackingRecHit::hit
virtual TrackingRecHit const * hit() const
Definition: TrackingRecHit.h:75
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
RPCRecHit::BunchX
int BunchX() const
Definition: RPCRecHit.h:73
RPCSeedrecHitFinder::setOutput
void setOutput(RPCSeedFinder *Seed)
Definition: RPCSeedrecHitFinder.cc:53
RPCSeedrecHitFinder::checkandfill
void checkandfill()
Definition: RPCSeedrecHitFinder.cc:220
RPCSeedFinder::isOutputset
bool isOutputset
Definition: RPCSeedFinder.h:44
TrackingRecHit.h
RPCLayerNumber
#define RPCLayerNumber
Definition: RPCCosmicSeedrecHitFinder.h:18
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
RPCRecHit
Definition: RPCRecHit.h:14
RPCSeedrecHitFinder::unsetInput
void unsetInput()
Definition: RPCSeedrecHitFinder.cc:52
RPCSeedFinder
Definition: RPCSeedFinder.h:23
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Point3DBase< float, GlobalTag >
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
RPCSeedrecHitFinder::MuonRecHitContainer
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
Definition: RPCSeedrecHitFinder.h:30
edm::ParameterSet
Definition: ParameterSet.h:47
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
RPCRecHit::clusterSize
int clusterSize() const
Definition: RPCRecHit.h:77
RPCSeedrecHitFinder::setInput
void setInput(MuonRecHitContainer(&recHits)[12])
Definition: RPCSeedrecHitFinder.cc:46
PixelTestBeamValidation_cfi.ClusterSize
ClusterSize
Definition: PixelTestBeamValidation_cfi.py:93
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
RPCSeedrecHitFinder::RPCSeedrecHitFinder
RPCSeedrecHitFinder()
Definition: RPCSeedrecHitFinder.cc:21
RPCSeedrecHitFinder::ConstMuonRecHitContainer
MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer
Definition: RPCSeedrecHitFinder.h:31
TrackingRecHit::clone
virtual TrackingRecHit * clone() const =0
TrackingRecHit
Definition: TrackingRecHit.h:21
RPCSeedrecHitFinder::complete
void complete(unsigned int LayerIndex)
Definition: RPCSeedrecHitFinder.cc:82
std
Definition: JetResolutionObject.h:76
RPCRecHit.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L1TStage2uGTEmulatorClient_cff.BX
BX
Definition: L1TStage2uGTEmulatorClient_cff.py:9
lessPhi
bool lessPhi(const MuonTransientTrackingRecHit::ConstMuonRecHitPointer &it1, const MuonTransientTrackingRecHit::ConstMuonRecHitPointer &it2)
Definition: RPCSeedrecHitFinder.cc:15
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RPCSeedrecHitFinder::setLayers
void setLayers(const std::vector< unsigned int > &Layers)
Definition: RPCSeedrecHitFinder.cc:58
trklet::Seed
Seed
Definition: Settings.h:49
RPCSeedFinder::isConfigured
bool isConfigured
Definition: RPCSeedFinder.h:43
RPCSeedrecHitFinder::configure
void configure(const edm::ParameterSet &iConfig)
Definition: RPCSeedrecHitFinder.cc:36