Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:59

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file DamageClassifier.cc
0028 /// \brief Implementation of the DamageClassifier class
0029 
0030 #include "DamageClassifier.hh"
0031 
0032 #include <iostream>
0033 #include <algorithm>
0034 
0035 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0036 
0037 std::vector<ClassifiedDamage> DamageClassifier::MakeCluster(
0038     std::vector<Damage>& pListDamage,unsigned int pDSBLength, bool pBase)
0039 {
0040     unsigned long int copyNb;
0041     unsigned long int lastCopyNb = -pDSBLength-1;
0042 
0043     // sort the list of damage by ascending bp
0044     std::sort(pListDamage.begin(), pListDamage.end(),
0045         [](const Damage& a, const Damage& b) {
0046             return a.GetCopyNb() < b.GetCopyNb();
0047         });
0048 
0049     std::vector<ClassifiedDamage> listClassifiedDamage;
0050     ClassifiedDamage classDamage;
0051 
0052     for(auto it=pListDamage.begin();it!=pListDamage.end();it++)
0053     {
0054         classDamage.SetIncludeBase(pBase);
0055         Damage tempDamage = (*it);
0056 
0057         if(tempDamage.GetDamageType()==Damage::DamageType::fBackbone)
0058         {
0059 
0060             copyNb=tempDamage.GetCopyNb();
0061 
0062             if(classDamage.GetNumDamage()<=0)
0063             {
0064                 classDamage.AddDamage(tempDamage);
0065                 lastCopyNb = copyNb;
0066             }
0067             else
0068             {
0069                 // New Damage
0070                 if(copyNb>lastCopyNb+pDSBLength)
0071                 {
0072                     classDamage.ComputeBp();
0073                     classDamage.ComputeType();
0074                     classDamage.ComputeComplexity();
0075                     listClassifiedDamage.push_back(classDamage);
0076                     classDamage.Reset();
0077                 }
0078 
0079                 classDamage.AddDamage(tempDamage);
0080                 lastCopyNb = copyNb;
0081             }
0082         }
0083     }
0084 
0085     if(classDamage.GetNumDamage()>0)
0086     {
0087         classDamage.ComputeBp();
0088         classDamage.ComputeType();
0089         classDamage.ComputeComplexity();
0090         listClassifiedDamage.push_back(classDamage);
0091     }
0092 
0093     // TODO: include base damage if include base (pBase) is true
0094 
0095     return listClassifiedDamage;
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 unsigned int DamageClassifier::GetNumSSB(
0101     const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0102 {
0103     unsigned int numSSB = 0;
0104     for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0105     {
0106         if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fSSB)
0107         {
0108             numSSB++;
0109         }
0110     }
0111     return numSSB;
0112 }
0113 
0114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0115 
0116 unsigned int DamageClassifier::GetNumDSB(
0117     const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0118 {
0119     unsigned int numDSB = 0;
0120     for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0121     {
0122         if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB)
0123         {
0124             numDSB++;
0125         }
0126     }
0127     return numDSB;
0128 }
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0131 
0132 unsigned int DamageClassifier::GetNumComplexDSB(
0133     const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0134 {
0135     unsigned int numComplexDSB = 0;
0136 
0137     for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0138     {
0139         if(((it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB))&&(it->GetComplexity()>1))
0140         {
0141             numComplexDSB++;
0142         }
0143     }
0144     return numComplexDSB;
0145 }
0146 
0147 
0148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0149 
0150 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > DamageClassifier::SortDamageByEvent(
0151     const std::vector<Damage>& pListDamage)
0152 {
0153     std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > mapDamage;
0154     for(auto it=pListDamage.begin();it!=pListDamage.end();it++)
0155     {
0156         mapDamage[it->GetEvt()][it->GetChromo()].push_back((*it));
0157     }
0158     return mapDamage;
0159 }
0160 
0161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0162 
0163 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > DamageClassifier::SortDamageByChromo(
0164     const std::vector<Damage>& pListDamage)
0165 {
0166     std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > mapDamage;
0167     for(auto it=pListDamage.begin();it!=pListDamage.end();it++)
0168     {
0169         mapDamage[it->GetChromo()][it->GetEvt()].push_back((*it));
0170     }
0171     return mapDamage;
0172 }
0173 
0174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0175 
0176 unsigned int DamageClassifier::GetNumDSBwithDirectDamage(
0177     const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0178 {
0179     unsigned int numDSBwDir = 0;
0180     for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0181     {
0182         if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB && 
0183             it->GetIsThereDirectComponentContribution())
0184         {
0185             numDSBwDir++;
0186         }
0187     }
0188     return numDSBwDir;
0189 }
0190 
0191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0192 
0193 unsigned int DamageClassifier::GetNumDSBwithIndirectDamage(
0194     const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0195 {
0196     unsigned int numDSBwIn = 0;
0197     for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0198     {
0199         if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB && 
0200             it->GetIsThereIndirectComponentContribution())
0201         {
0202             numDSBwIn++;
0203         }
0204     }
0205     return numDSBwIn;
0206 }
0207 
0208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0209 
0210 unsigned int DamageClassifier::GetNumDSBwithBothDirectIndirectDamage(
0211     const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0212 {
0213     unsigned int numDSBwDirIn = 0;
0214     for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0215     {
0216         if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB && 
0217             it->GetIsThereDirectComponentContribution() && 
0218             it->GetIsThereIndirectComponentContribution())
0219         {
0220             numDSBwDirIn++;
0221         }
0222     }
0223     return numDSBwDirIn;
0224 }
0225 
0226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......