Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:46

0001 #include "L1Trigger/DTTriggerPhase2/interface/DTPattern.h"
0002 #include "L1Trigger/DTTriggerPhase2/interface/constants.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include <iostream>
0006 
0007 //------------------------------------------------------------------
0008 //--- Constructors and destructor
0009 //------------------------------------------------------------------
0010 DTPattern::DTPattern() {}
0011 
0012 DTPattern::DTPattern(RefDTPatternHit seedUp, RefDTPatternHit seedDown) : seedUp_(seedUp), seedDown_(seedDown) {
0013   //On creation, pattern is based on seeds, with no hits. Due to traslational simmetry we only need the superlayer indexes as well as the cell index difference
0014   id_ = std::make_tuple(std::get<0>(seedUp), std::get<0>(seedDown), std::get<1>(seedUp) - std::get<1>(seedDown));
0015   if (debug_)
0016     LogDebug("DTPattern") << "Pattern id: " << std::get<0>(id_) << " , " << std::get<1>(id_) << " , "
0017                           << std::get<2>(id_);
0018 }
0019 
0020 DTPattern::DTPattern(int SL1, int SL2, int diff) {
0021   //On creation, pattern is based on seeds, with no hits. Due to traslational simmetry we only need the superlayer indexes as well as the cell index difference
0022   seedUp_ = std::make_tuple(SL1, 0, 0);
0023   seedDown_ = std::make_tuple(SL2, diff, 0);
0024   id_ = std::make_tuple(SL1, SL2, diff);
0025   if (debug_)
0026     LogDebug("DTPattern") << "Pattern id: " << std::get<0>(id_) << " , " << std::get<1>(id_) << " , "
0027                           << std::get<2>(id_);
0028 }
0029 
0030 void DTPattern::addHit(RefDTPatternHit hit) {
0031   //Add additional gen level hits in the gen pattern coordinates (untranslated)
0032   genHits_.push_back(hit);
0033   if (debug_)
0034     LogDebug("DTPattern") << "Added gen hit: " << std::get<0>(hit) << " , " << std::get<1>(hit) << " , "
0035                           << std::get<2>(hit);
0036 }
0037 
0038 int DTPattern::latHitIn(int slId, int chId, int allowedVariance) const {
0039   //Check if a hit is inside of the pattern for a given pattern width
0040   int temp = -999;
0041   for (auto it = this->genHits_.begin(); it != this->genHits_.end(); ++it) {
0042     if (slId == (std::get<0>(*it) - 1)) {
0043       if (chId == (std::get<1>(*it) + recoseedDown_)) {
0044         return std::get<2>(*it);
0045       }
0046       //This is equivalent to an allowed discrete width of the pattern (configured)
0047       else if ((chId <= (std::get<1>(*it) + recoseedDown_ + allowedVariance)) &&
0048                (chId >= (std::get<1>(*it) + recoseedDown_ - allowedVariance))) {
0049         temp = -10;
0050       }
0051     }
0052   }
0053   return temp;
0054 }
0055 
0056 std::ostream &operator<<(std::ostream &out, DTPattern const &p) {
0057   //Friend for printing pattern information trough iostream
0058   out << "Pattern id: " << std::get<0>(p.id()) << " , " << std::get<1>(p.id()) << " , " << std::get<2>(p.id())
0059       << std::endl;
0060   std::vector<RefDTPatternHit> thegenHits = p.genHits();
0061   out << "Pattern hits: " << std::endl;
0062 
0063   for (std::vector<RefDTPatternHit>::iterator itHit = thegenHits.begin(); itHit != thegenHits.end(); itHit++) {
0064     out << "[" << std::get<0>(*itHit) << " , " << std::get<1>(*itHit) << " , " << std::get<2>(*itHit) << "]";
0065   }
0066   return out;
0067 }
0068 
0069 DTPattern::~DTPattern() {}