50 edm::LogVerbatim(
"ME0SegAlgoMM") <<
"[ME0SegAlgoMM::run] build segments in chamber " << enId;
53 std::vector<ME0Segment> segments_temp;
54 std::vector<ME0Segment> segments;
62 rechits_clusters = this->
chainHits( rechits );
69 for(
auto sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits ) {
71 segments_temp.clear();
75 segments.insert( segments.end(), segments_temp.begin(), segments_temp.end() );
94 float dXclus_box = 0.0;
95 float dYclus_box = 0.0;
100 std::vector<float> running_meanX;
101 std::vector<float> running_meanY;
103 std::vector<float> seed_minX;
104 std::vector<float> seed_maxX;
105 std::vector<float> seed_minY;
106 std::vector<float> seed_maxY;
111 for(
unsigned int i = 0;
i < rechits.size(); ++
i) {
113 temp.push_back(rechits[
i]);
114 seeds.push_back(temp);
119 running_meanX.push_back( rechits[i]->localPosition().
x() );
120 running_meanY.push_back( rechits[i]->localPosition().
y() );
123 seed_minX.push_back( rechits[i]->localPosition().
x() );
124 seed_maxX.push_back( rechits[i]->localPosition().
x() );
125 seed_minY.push_back( rechits[i]->localPosition().
y() );
126 seed_maxY.push_back( rechits[i]->localPosition().
y() );
131 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
132 for(
size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) {
134 LogDebug(
"ME0SegAlgoMM") <<
"[ME0SegAlgoMM::clusterHits]: ALARM! Skipping used seeds, this should not happen - inform developers!";
142 if ( running_meanX[NNN] > running_meanX[MMM] ) dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
143 else dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
144 if ( running_meanY[NNN] > running_meanY[MMM] ) dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
145 else dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
153 if(seeds[NNN].
size()+seeds[MMM].
size() != 0) {
154 running_meanX[MMM] = (running_meanX[NNN]*seeds[NNN].size() + running_meanX[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
155 running_meanY[MMM] = (running_meanY[NNN]*seeds[NNN].size() + running_meanY[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
159 if ( seed_minX[NNN] < seed_minX[MMM] ) seed_minX[MMM] = seed_minX[NNN];
160 if ( seed_maxX[NNN] > seed_maxX[MMM] ) seed_maxX[MMM] = seed_maxX[NNN];
161 if ( seed_minY[NNN] < seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN];
162 if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN];
165 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
180 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
182 rechits_clusters.push_back(seeds[NNN]);
185 return rechits_clusters;
196 std::vector <bool> usedCluster;
201 for(
unsigned int i = 0;
i < rechits.size(); ++
i) {
203 temp.push_back(rechits[
i]);
204 seeds.push_back(temp);
205 usedCluster.push_back(
false);
209 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
210 for(
size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) {
211 if(usedCluster[MMM] || usedCluster[NNN]){
231 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
234 usedCluster[NNN] =
true;
247 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
248 if(usedCluster[NNN])
continue;
249 rechits_chains.push_back(seeds[NNN]);
254 return rechits_chains;
259 std::vector<float> phi_new, eta_new, phi_old, eta_old;
260 std::vector<int> layer_new, layer_old;
262 for(
size_t iRH_new = 0;iRH_new<newChain.size();++iRH_new){
264 layer_new.push_back(newChain[iRH_new]->me0Id().layer());
265 phi_new.push_back(pos_new.
phi());
266 eta_new.push_back(pos_new.
eta());
268 for(
size_t iRH_old = 0;iRH_old<oldChain.size();++iRH_old){
270 layer_old.push_back(oldChain[iRH_old]->me0Id().layer());
271 phi_old.push_back(pos_old.
phi());
272 eta_old.push_back(pos_old.
eta());
275 for(
size_t jRH_new = 0; jRH_new<phi_new.size(); ++jRH_new){
276 for(
size_t jRH_old = 0; jRH_old<phi_old.size(); ++jRH_old){
288 bool etaRequirementOK = fabs(eta_new[jRH_new]-eta_old[jRH_old]) <
dEtaChainBoxMax;
290 bool layerRequirementOK =
abs(layer_new[jRH_new]-layer_old[jRH_old]) < (
theEnsemble.first->id().nlayers()-1);
292 if(layerRequirementOK && phiRequirementOK && etaRequirementOK){
305 std::vector<ME0Segment> me0segs;
309 for (
auto rh=rechits.begin(); rh!=rechits.end();rh++){
319 edm::LogVerbatim(
"ME0SegAlgoMM") <<
"[ME0SegAlgoMM::buildSegments] ME0Segment fit done";
325 double protoChi2 =
sfit_->chi2();
328 float averageTime=0.;
329 for (
auto rh=rechits.begin(); rh!=rechits.end(); ++rh){
330 averageTime += (*rh)->tof();
332 if(rechits.size() != 0) averageTime=averageTime/(rechits.size());
334 for (
auto rh=rechits.begin(); rh!=rechits.end(); ++rh){
335 timeUncrt +=
pow((*rh)->tof()-averageTime,2);
337 if(rechits.size() > 1) timeUncrt=timeUncrt/(rechits.size()-1);
338 timeUncrt =
sqrt(timeUncrt);
341 edm::LogVerbatim(
"ME0SegAlgoMM") <<
"[ME0SegAlgoMM::buildSegments] will now try to make ME0Segment from collection of "<<rechits.size()<<
" ME0 RecHits";
344 edm::LogVerbatim(
"ME0SegAlgoMM") <<
"[ME0SegAlgoMM::buildSegments] ME0Segment made";
347 me0segs.push_back(tmp);
std::vector< const ME0RecHit * > EnsembleHitContainer
Typedefs.
T getParameter(std::string const &) const
ProtoSegments clusterHits(const EnsembleHitContainer &rechits)
Utility functions.
T getUntrackedParameter(std::string const &, T const &) const
std::vector< EnsembleHitContainer > ProtoSegments
Geom::Phi< T > phi() const
bool preClustering_useChaining
ME0SegAlgoMM(const edm::ParameterSet &ps)
Constructor.
std::pair< const ME0EtaPartition *, std::map< uint32_t, const ME0EtaPartition * > > ME0Ensemble
std::unique_ptr< ME0SegFit > sfit_
bool isGoodToMerge(const EnsembleHitContainer &newChain, const EnsembleHitContainer &oldChain)
unsigned int minHitsPerSegment
std::vector< ME0Segment > run(const ME0Ensemble &ensemble, const EnsembleHitContainer &rechits)
Abs< T >::type abs(const T &t)
ProtoSegments chainHits(const EnsembleHitContainer &rechits)
std::vector< ME0Segment > buildSegments(const EnsembleHitContainer &rechits)
double deltaPhi(double phi1, double phi2)
EnsembleHitContainer proto_segment
std::vector< std::vector< double > > tmp
virtual ~ME0SegAlgoMM()
Destructor.
CLHEP::HepSymMatrix AlgebraicSymMatrix
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)