Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file DamageClassifier.cc 28 /// \brief Implementation of the DamageClassifier class 29 30 #include "DamageClassifier.hh" 31 32 #include <iostream> 33 #include <algorithm> 34 35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 36 37 std::vector<ClassifiedDamage> DamageClassifier::MakeCluster( 38 std::vector<Damage>& pListDamage,unsigned int pDSBLength, bool pBase) 39 { 40 unsigned long int copyNb; 41 unsigned long int lastCopyNb = -pDSBLength-1; 42 43 // sort the list of damage by ascending bp 44 std::sort(pListDamage.begin(), pListDamage.end(), 45 [](const Damage& a, const Damage& b) { 46 return a.GetCopyNb() < b.GetCopyNb(); 47 }); 48 49 std::vector<ClassifiedDamage> listClassifiedDamage; 50 ClassifiedDamage classDamage; 51 52 for(auto it=pListDamage.begin();it!=pListDamage.end();it++) 53 { 54 classDamage.SetIncludeBase(pBase); 55 Damage tempDamage = (*it); 56 57 if(tempDamage.GetDamageType()==Damage::DamageType::fBackbone) 58 { 59 60 copyNb=tempDamage.GetCopyNb(); 61 62 if(classDamage.GetNumDamage()<=0) 63 { 64 classDamage.AddDamage(tempDamage); 65 lastCopyNb = copyNb; 66 } 67 else 68 { 69 // New Damage 70 if(copyNb>lastCopyNb+pDSBLength) 71 { 72 classDamage.ComputeBp(); 73 classDamage.ComputeType(); 74 classDamage.ComputeComplexity(); 75 listClassifiedDamage.push_back(classDamage); 76 classDamage.Reset(); 77 } 78 79 classDamage.AddDamage(tempDamage); 80 lastCopyNb = copyNb; 81 } 82 } 83 } 84 85 if(classDamage.GetNumDamage()>0) 86 { 87 classDamage.ComputeBp(); 88 classDamage.ComputeType(); 89 classDamage.ComputeComplexity(); 90 listClassifiedDamage.push_back(classDamage); 91 } 92 93 // TODO: include base damage if include base (pBase) is true 94 95 return listClassifiedDamage; 96 } 97 98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 99 100 unsigned int DamageClassifier::GetNumSSB( 101 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const 102 { 103 unsigned int numSSB = 0; 104 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++) 105 { 106 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fSSB) 107 { 108 numSSB++; 109 } 110 } 111 return numSSB; 112 } 113 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 115 116 unsigned int DamageClassifier::GetNumDSB( 117 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const 118 { 119 unsigned int numDSB = 0; 120 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++) 121 { 122 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB) 123 { 124 numDSB++; 125 } 126 } 127 return numDSB; 128 } 129 130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 131 132 unsigned int DamageClassifier::GetNumComplexDSB( 133 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const 134 { 135 unsigned int numComplexDSB = 0; 136 137 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++) 138 { 139 if(((it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB))&&(it->GetComplexity()>1)) 140 { 141 numComplexDSB++; 142 } 143 } 144 return numComplexDSB; 145 } 146 147 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 149 150 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > DamageClassifier::SortDamageByEvent( 151 const std::vector<Damage>& pListDamage) 152 { 153 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > mapDamage; 154 for(auto it=pListDamage.begin();it!=pListDamage.end();it++) 155 { 156 mapDamage[it->GetEvt()][it->GetChromo()].push_back((*it)); 157 } 158 return mapDamage; 159 } 160 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 162 163 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > DamageClassifier::SortDamageByChromo( 164 const std::vector<Damage>& pListDamage) 165 { 166 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > mapDamage; 167 for(auto it=pListDamage.begin();it!=pListDamage.end();it++) 168 { 169 mapDamage[it->GetChromo()][it->GetEvt()].push_back((*it)); 170 } 171 return mapDamage; 172 } 173 174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 175 176 unsigned int DamageClassifier::GetNumDSBwithDirectDamage( 177 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const 178 { 179 unsigned int numDSBwDir = 0; 180 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++) 181 { 182 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB && 183 it->GetIsThereDirectComponentContribution()) 184 { 185 numDSBwDir++; 186 } 187 } 188 return numDSBwDir; 189 } 190 191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 192 193 unsigned int DamageClassifier::GetNumDSBwithIndirectDamage( 194 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const 195 { 196 unsigned int numDSBwIn = 0; 197 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++) 198 { 199 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB && 200 it->GetIsThereIndirectComponentContribution()) 201 { 202 numDSBwIn++; 203 } 204 } 205 return numDSBwIn; 206 } 207 208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 209 210 unsigned int DamageClassifier::GetNumDSBwithBothDirectIndirectDamage( 211 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const 212 { 213 unsigned int numDSBwDirIn = 0; 214 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++) 215 { 216 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB && 217 it->GetIsThereDirectComponentContribution() && 218 it->GetIsThereIndirectComponentContribution()) 219 { 220 numDSBwDirIn++; 221 } 222 } 223 return numDSBwDirIn; 224 } 225 226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......