BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
BesGeoSelector.cxx
Go to the documentation of this file.
1/*
2 * 2018/5/11 Long Peixun IHEP
3 * Geometry Selection for EventDisplay
4*/
5
7#include "GaudiKernel/Bootstrap.h"
9#include <algorithm>
10#include <iostream>
11using namespace std;
12
14{}
15
16void BesGeoSelector::addGeomFile(const char* fname, int startno)
17{
18 cout << "BesGeoSelector: " << fname << " start phase " << startno << endl;
19 fgeom.push_back(GeomFileInfo(fname, startno));
20 sort(fgeom.begin(), fgeom.end());
21}
22
24{
25 fgeom.clear();
26}
27
28//Given run number, select a suitable geometry file, and return file name.
30{
31 DetVerSvc dvs("DetVerSvc", Gaudi::svcLocator()); //For converting runno to phase
32 dvs.initialize();
33 int absno = (run_no >= 0 ? run_no : -run_no);
34
35 for (vector<GeomFileInfo>::reverse_iterator i = fgeom.rbegin(); i != fgeom.rend(); ++i)
36 {
37 // if (absno >= i->startno)
38 // {
39 // return i->filename.c_str();
40 // }
41
42 //In BOSS 7.0.3, use DecVerSvc package to choose geometry
43 int phase = dvs.fromRun(absno);
44 if (phase >= i->startno)
45 {
46 return i->filename.c_str();
47 }
48 }
49 cout << "BesGeoSelector Error: There is no suitable detector geometry!" << endl;
50 return "";
51}
52
53//Given file name, find whether the list contains this file.
54bool BesGeoSelector::hasGeomFile(const char* fname)
55{
56 string filename(fname);
57 for (vector<GeomFileInfo>::iterator i = fgeom.begin(); i != fgeom.end(); ++i)
58 {
59 if (filename == i->filename) return true;
60 }
61 return false;
62}
const char * getGeomFileNameFromRunNo(int run_no)
bool hasGeomFile(const char *fname)
void addGeomFile(const char *fname, int startno)
int fromRun(unsigned int run)
Definition: DetVerSvc.cxx:84
virtual StatusCode initialize()
Definition: DetVerSvc.cxx:33