ATLAS Offline Software
WTACone2PassMaker.h
Go to the documentation of this file.
1 #ifndef WTACone2PassMaker_h
2 #define WTACone2PassMaker_h
3 
4 #include <iostream>
5 #include <algorithm>
6 #include <map>
7 #include "./WTAConeMaker.h" // Use the parent class
8 
9 class WTACone2PassMaker : public WTAConeMaker{ // The 2Pass maker class
10  public:
11  WTACone2PassMaker(unsigned int RollOffBufferSize = 155)
12  : WTAConeMaker(), // Calls WTAConeMaker constructor
13  m_RollOffBufferSize(RollOffBufferSize) // Initialize with infinite RollOffBufferSize
14  {}; // Constructor
15  ~WTACone2PassMaker () {}; // Destructor
16 
17  void FillLists(const std::vector<WTATrigObj>& InputTowers) override; // Overwrite the WTAConeMaker::FillLists()
18  void SeedCleaning() override; // Overwrite the WTAConeMaker::SeedCleaning()
19  void MergeConstsToSeeds() override; // Overwrite the WTAConeMaker::MergeConstsToSeeds()
20  void SetRollOffBufferSize(int rolloff_buffersize){m_RollOffBufferSize = rolloff_buffersize;}
22 
23  const std::vector<WTATrigObj>& GetRollOffList() const {return m_RollOffList;}; // Access the RollOffList
24 
25  private:
26  std::vector<WTATrigObj> m_RollOffList; // For 2-Pass
27  unsigned int m_RollOffBufferSize; // For 2-Pass
28 };
29 
30 inline void WTACone2PassMaker::FillLists(const std::vector<WTATrigObj>& InputTowers) // 2Pass FillLists()
31 {
32  m_ConstituentList.clear(); m_SeedSortingList.clear(); m_RollOffList.clear();
33  const unsigned int MaxSeedSortingN = m_WTAConeMakerParameter.GetMaxSeedSortingN();
34  const unsigned int MaxConstN = m_WTAConeMakerParameter.GetMaxConstN();
35  for(auto tower: InputTowers)
36  {
37  if(tower.pt() < m_WTAConeMakerParameter.GetConstEtCut())continue; // Skip Et < 2GeV
38  if(tower.pt() >= m_WTAConeMakerParameter.GetSeedEtCut())// Harmonize >=
39  {
40  m_SeedSortingList.insert(m_SeedSortingList.begin(), tower); // Insert incoming tower at the beginning of the sorting list
41  SortByPt(m_SeedSortingList); // Do et-sorting as tower comes in, definition of 2-Pass, using std::stable_sort()
42  while (m_SeedSortingList.size() > MaxSeedSortingN) // It only runs when m_SeedSortingList.size() = m_MaxSeedSortingN + 1 though
43  {
44  m_RollOffList.push_back(m_SeedSortingList.back()); // Then, Fill the Roll-Off list
45  m_SeedSortingList.pop_back(); // Discard the 51st seed tower
46  }
47  }
48  else m_ConstituentList.push_back(tower); // Always put soft tower at the back of the m_ConstituentList
49  }
50  if(m_ConstituentList.size() > MaxConstN)m_ConstituentList.resize(MaxConstN); // Truncate the Constituent list
51  if(m_RollOffList.size() > m_RollOffBufferSize)m_RollOffList.resize(m_RollOffBufferSize); // Truncate the Roll-Off list
52 }
53 
54 inline void WTACone2PassMaker::SeedCleaning() // 2Pass
55 {
56  m_SeedList.clear();
57  if(m_DEBUG)std::cout << "HighEtMerge2Pass Seed Cleaning......" << std::endl;
58  int seed_N = m_SeedSortingList.size(); // Default: Max 50
59  for(int i = 0; i < seed_N; i++){
60  WTATrigObj seed = m_SeedSortingList.at(i);
61  unsigned int jet_N = m_SeedList.size();
62  if(jet_N == 0)m_SeedList.push_back(WTATrigObjToWTAJet(seed)); // Take first seed as jet
63  else
64  {
65  int MaxPtIndex = -1; // MaxPtIndex will be -1 in 2Pass by construction, et-sorted m_SeedSortingList
66  std::vector<int> associate_bit = GetAssociateBits(seed, MaxPtIndex); // Associate_bit filling done
67  if(std::find(associate_bit.begin(), associate_bit.end(), 1) != associate_bit.end())
68  { // When there is at least one association between incoming tower vs existing seeds
69  for(unsigned int j = 0; j < jet_N; j++) // Read high-et seed first
70  {
71  if(associate_bit.at(j) == 1)
72  {
73  m_SeedList.at(j).MergeConstituent(seed);
74  break; // Done, move to the next tower-object
75  }
76  }
77  }
78  else
79  { // No Association
80  if(jet_N < m_WTAConeMakerParameter.GetMaxSeedN()) // There is a slot in the seed list
81  {
82  m_SeedList.push_back(WTATrigObjToWTAJet(seed)); // Insert seed-object to the end of the seed list
83  } // Discard if there is no open slot in the seed list
84  }
85  } // Main loop
86  // No need to pt sort the SeedList. It is sorted by construction
87  // No need to resize the SeedList. Only insert the seed-object if(jet_n < m_MaxSeedN)
88  if(m_VERBOSE)PrintSeedList(); // Print SeedList, for debug
89  } // seed loop
90  if(m_DEBUG){
91  PrintSeedList();
92  std::cout << "HighEtMerge2Pass Seed Cleaning Done......" << std::endl;
93  }
94 }
95 
97 {
98  if(m_RollOffList.size() > 0)
99  {
100  for (auto off_seed: m_RollOffList)InsertToConstList(off_seed); // m_AddConstFirst is true by default
101  }
102  for(auto constituent: m_ConstituentList)
103  {
104  for(unsigned int j = 0; j < m_SeedList.size(); j++) // Assume Jets are pT sorted, WTA means more energetic jet eats constituent first
105  {
106  IntOrFloat dR2 = constituent.dR2(m_SeedList.at(j));
107  if(constituent.IsAssocdR(m_SeedList.at(j), m_WTAConeMakerParameter.GetJet_dR2()) && dR2!=0) // Thistime, the condition is m_JetArea, the usual R2Par, **WARNING: dR2!=0 IS TEMPORARY FOR INT-SIM. NEED TO KNOW TOPOTOWER CREATION
108  {
109  m_SeedList.at(j).MergeConstituent(constituent);
110  ResizeThisJetConstituents(m_SeedList.at(j)); // Check JetConstituent N
111  break; // Break the jet loop, move to the next constituent
112  }
113  }
114  }
115 }
116 
117 #endif
WTACone2PassMaker::GetRollOffList
const std::vector< WTATrigObj > & GetRollOffList() const
Definition: WTACone2PassMaker.h:23
WTAConeMaker::m_ConstituentList
std::vector< WTATrigObj > m_ConstituentList
Definition: WTAConeMaker.h:92
WTAParameters::GetSeedEtCut
IntOrFloat GetSeedEtCut()
Definition: WTAConeMaker.h:31
WTACone2PassMaker::m_RollOffList
std::vector< WTATrigObj > m_RollOffList
Definition: WTACone2PassMaker.h:23
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
WTACone2PassMaker::~WTACone2PassMaker
~WTACone2PassMaker()
Definition: WTACone2PassMaker.h:15
WTAConeMaker::GetAssociateBits
std::vector< int > GetAssociateBits(WTATrigObj incoming_seed, int &max_pt_index)
Definition: WTAConeMaker.h:210
WTAParameters::GetJet_dR2
IntOrFloat GetJet_dR2()
Definition: WTAConeMaker.h:33
WTACone2PassMaker::SetRollOffBufferSize
void SetRollOffBufferSize(int rolloff_buffersize)
Definition: WTACone2PassMaker.h:20
WTACone2PassMaker
Definition: WTACone2PassMaker.h:9
WTAConeMaker::m_WTAConeMakerParameter
WTAParameters m_WTAConeMakerParameter
Definition: WTAConeMaker.h:87
WTACone2PassMaker::MergeConstsToSeeds
void MergeConstsToSeeds() override
Definition: WTACone2PassMaker.h:96
WTAConeMaker.h
WTACone2PassMaker::m_RollOffBufferSize
unsigned int m_RollOffBufferSize
Definition: WTACone2PassMaker.h:27
WTAConeMaker::m_DEBUG
bool m_DEBUG
Definition: WTAConeMaker.h:96
WTAConeMaker::PrintSeedList
void PrintSeedList()
Definition: WTAConeMaker.h:149
lumiFormat.i
int i
Definition: lumiFormat.py:85
WTAConeMaker::ResizeThisJetConstituents
void ResizeThisJetConstituents(WTAJet &jet)
Definition: WTAConeMaker.h:179
WTACone2PassMaker::WTACone2PassMaker
WTACone2PassMaker(unsigned int RollOffBufferSize=155)
Definition: WTACone2PassMaker.h:11
WTAParameters::GetConstEtCut
IntOrFloat GetConstEtCut()
Definition: WTAConeMaker.h:30
WTATrigObj
Definition: WTAObject.h:33
WTACone2PassMaker::GetRollOffBufferSize
int GetRollOffBufferSize()
Definition: WTACone2PassMaker.h:21
WTACone2PassMaker::FillLists
void FillLists(const std::vector< WTATrigObj > &InputTowers) override
Definition: WTACone2PassMaker.h:30
WTAConeMaker::m_VERBOSE
bool m_VERBOSE
Definition: WTAConeMaker.h:97
WTAConeMaker::InsertToConstList
void InsertToConstList(WTATrigObj obj)
Definition: WTAConeMaker.h:161
WTAConeMaker::m_SeedSortingList
std::vector< WTATrigObj > m_SeedSortingList
Definition: WTAConeMaker.h:93
WTACone2PassMaker::SeedCleaning
void SeedCleaning() override
Definition: WTACone2PassMaker.h:54
WTAConeMaker::m_SeedList
std::vector< WTAJet > m_SeedList
Definition: WTAConeMaker.h:94
WTAConeMaker::WTATrigObjToWTAJet
WTAJet WTATrigObjToWTAJet(const WTATrigObj &obj)
Definition: WTAConeMaker.h:198
WTAConeMaker
Definition: WTAConeMaker.h:54
WTAParameters::GetMaxSeedN
unsigned int GetMaxSeedN()
Definition: WTAConeMaker.h:36
WTAParameters::GetMaxSeedSortingN
unsigned int GetMaxSeedSortingN()
Definition: WTAConeMaker.h:35
WTAParameters::GetMaxConstN
unsigned int GetMaxConstN()
Definition: WTAConeMaker.h:34