ATLAS Offline Software
check_xsections.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 // For PMG centralized tool's wrapper tool handles
11 
12 #include <string>
13 #include <iostream>
14 
15 #include <TSystem.h>
16 #include <TString.h>
17 #include <TError.h>
18 
19 int main( int argc, char* argv[] ) {
20 
21  if(argc < 2){
22  ::Error("main()","Please provide a DSID to be checked!");
23  return 0;
24  }
25 
26  bool valfile = false;
27  bool genmode = false;
28  if(argc > 2){
29  if(atoi(argv[2]) == 1){
30  std::cout << "--- File Validation Mode ----" << std::endl;
31  valfile = true;
32  }
33  else if(atoi(argv[2]) == 2){
34  std::cout << "--- Generator info Mode ----" << std::endl;
35  genmode = true;
36  }
37  }
38  if(!valfile)
39  std::cout << "--- Wrapper Validation Mode ----" << std::endl;
40 
41  //*** Tools
42  //SUSYTools
43  SUSY::CrossSectionDB my_XsecDB(gSystem->ExpandPathName("$ROOTCOREBIN/data/SUSYTools/mc15_13TeV/"));
44 
45  //PMG tool
47  pmgxs.setTypeAndName("PMGTools::PMGCrossSectionTool/PMGCrossSectionTool");
48  pmgxs.retrieve().ignore(); // Ignore the status code
49  pmgxs->readInfosFromDir(gSystem->ExpandPathName("$ROOTCOREBIN/data/PMGTools/"));
50 
51  //STPMG wrapper
52  SUSY::CrossSectionDBPMG my_XsecDBPMG(gSystem->ExpandPathName("$ROOTCOREBIN/data/PMGTools/"));
53 
54 
55  //--- Validation Wrapper Mode
56  //*** check settings for a given sample as from SUSYTools, PMG, and SUSYToolsPMG wrapper
57  if(!valfile){
58 
59  int dsid = atoi( argv[1] );
60 
61  //ST
62  std::cout << "ST_CrossSection name : " << my_XsecDB.name(dsid) << std::endl;
63  std::cout << "ST_CrossSection xs : " << my_XsecDB.xsectTimesEff(dsid) << std::endl;
64  std::cout << "ST_CrossSection raw : " << my_XsecDB.rawxsect(dsid) << std::endl;
65  std::cout << "ST_CrossSection k : " << my_XsecDB.kfactor(dsid) << std::endl;
66  std::cout << "ST_CrossSection eff : " << my_XsecDB.efficiency(dsid) << std::endl;
67 
68  //PMG
69  std::cout << "PMG_CrossSection name : " << pmgxs->getSampleName(dsid) << std::endl;
70  std::cout << "PMG_CrossSection xs : " << pmgxs->getSampleXsection(dsid) << std::endl;
71  std::cout << "PMG_CrossSection (AMI) : " << pmgxs->getAMIXsection(dsid) << std::endl;
72  std::cout << "PMG_CrossSection (k) : " << pmgxs->getKfactor(dsid) << std::endl;
73  std::cout << "PMG_CrossSection (eff) : " << pmgxs->getFilterEff(dsid) << std::endl;
74 
75  //ST-PMG Wrapper
76  std::cout << "STPMG_CrossSection name : " << my_XsecDBPMG.name(dsid) << std::endl;
77  std::cout << "STPMG_CrossSection xs : " << my_XsecDBPMG.xsectTimesEff(dsid) << std::endl;
78  std::cout << "STPMG_CrossSection raw : " << my_XsecDBPMG.rawxsect(dsid) << std::endl;
79  std::cout << "STPMG_CrossSection k : " << my_XsecDBPMG.kfactor(dsid) << std::endl;
80  std::cout << "STPMG_CrossSection eff : " << my_XsecDBPMG.efficiency(dsid) << std::endl;
81 
82  }
83 
84  else if (genmode){
85  std::vector<int> ids = pmgxs->getLoadedDSIDs();
86  for(auto id : ids){
87  std::string genname="SHOWER";
88  std::cout << id << "\t"
89  << genname << std::endl;
90  }
91  }
92 
93  else if (valfile){
94  //--- Validation File Mode
95  //*** compare settings for all samples in provided file as from PMG vs SUSYTools
96 
97  std::vector<int> ids = pmgxs->getLoadedDSIDs();
98 
99  for(auto id : ids){
100 
101  //check if in SUSYTools
102  if(my_XsecDB.xsectTimesEff(id) < 0) continue;
103 
104  TString cmd = Form("grep \"%d\" PMGTools/data/*.txt | cut -d: -f1 >> PMG_id_file.txt", id);
105  gSystem->Exec(cmd);
106 
107  std::string shortname = pmgxs->getSampleName(id).erase(0,18);
108  std::string delim="\t";
109  //std::string delim=","; // csv format
110  std::cout << id << delim
111  << shortname << delim
112  << my_XsecDB.xsectTimesEff(id) << delim
113  << pmgxs->getSampleXsection(id) << delim
114  << my_XsecDB.rawxsect(id) << delim
115  << pmgxs->getAMIXsection(id) << delim
116  << my_XsecDB.kfactor(id) << delim
117  << pmgxs->getKfactor(id) << delim
118  << my_XsecDB.efficiency(id) << delim
119  << pmgxs->getFilterEff(id) //* pmgxs->getBR(id)
120  << std::endl;
121  }
122  }
123 
124 
125  return 0;
126 }
SUSY::CrossSectionDBPMG::rawxsect
float rawxsect(int id) const
Definition: SUSYCrossSectionPMG.h:31
asg::AnaToolHandle< PMGTools::IPMGCrossSectionTool >
SUSYCrossSectionPMG.h
asg::AnaToolHandle::retrieve
StatusCode retrieve()
initialize the tool
SUSY::CrossSectionDBPMG
Definition: SUSYCrossSectionPMG.h:24
SUSY::CrossSectionDBPMG::kfactor
float kfactor(int id) const
Definition: SUSYCrossSectionPMG.h:32
SUSY::CrossSectionDB::kfactor
float kfactor(int id, int proc=0) const
Definition: SUSYCrossSection.h:101
rerun_display.cmd
string cmd
Definition: rerun_display.py:67
SUSY::CrossSectionDBPMG::xsectTimesEff
float xsectTimesEff(int id) const
Definition: SUSYCrossSectionPMG.h:30
asg::AnaToolHandle::setTypeAndName
void setTypeAndName(const std::string &val_typeAndName)
set the value of type and name
PMGTools::IPMGCrossSectionTool::getSampleXsection
virtual double getSampleXsection(const int dsid) const =0
return the sample cross-section for DSID (can we find a more descriptive name for this,...
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
SUSY::CrossSectionDB::efficiency
float efficiency(int id, int proc=0) const
Definition: SUSYCrossSection.h:103
SUSY::CrossSectionDBPMG::efficiency
float efficiency(int id) const
Definition: SUSYCrossSectionPMG.h:34
SUSY::CrossSectionDB::name
std::string name(int id) const
Definition: SUSYCrossSection.h:111
PMGTools::IPMGCrossSectionTool::getLoadedDSIDs
virtual std::vector< int > getLoadedDSIDs() const =0
get a list of the DSID for the loaded samples
PMGTools::IPMGCrossSectionTool::readInfosFromDir
virtual bool readInfosFromDir(const std::string &inputDir)=0
read infos from all files in dir
Generate_dsid_ranseed.dsid
dsid
Definition: Generate_dsid_ranseed.py:6
PMGTools::IPMGCrossSectionTool::getFilterEff
virtual double getFilterEff(const int dsid) const =0
return filter efficiency for DSID
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
SUSYCrossSection.h
AnaToolHandle.h
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
main
int main(int argc, char *argv[])
Definition: check_xsections.cxx:19
SUSY::CrossSectionDB
Definition: SUSYCrossSection.h:29
SUSY::CrossSectionDB::rawxsect
float rawxsect(int id, int proc=0) const
Definition: SUSYCrossSection.h:99
PMGTools::IPMGCrossSectionTool::getSampleName
virtual std::string getSampleName(const int dsid) const =0
return the sample name for DSID
PMGTools::IPMGCrossSectionTool::getKfactor
virtual double getKfactor(const int dsid) const =0
return the k-factor for DSID
IPMGCrossSectionTool.h
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
SUSY::CrossSectionDBPMG::name
std::string name(int id) const
Definition: SUSYCrossSectionPMG.h:39
SUSY::CrossSectionDB::xsectTimesEff
float xsectTimesEff(int id, int proc=0) const
Definition: SUSYCrossSection.h:94
PMGTools::IPMGCrossSectionTool::getAMIXsection
virtual double getAMIXsection(const int dsid) const =0
return the AMI cross-section for DSID