CMS 3D CMS Logo

TrackletParametersMemory.cc
Go to the documentation of this file.
5 #include <iomanip>
6 #include <filesystem>
7 
8 using namespace std;
9 using namespace trklet;
10 
11 TrackletParametersMemory::TrackletParametersMemory(string name, Settings const& settings, unsigned int iSector)
12  : MemoryBase(name, settings, iSector) {}
13 
15  for (auto& tracklet : tracklets_) {
16  delete tracklet;
17  }
18  tracklets_.clear();
19 }
20 
21 void TrackletParametersMemory::writeMatches(Globals* globals, int& matchesL1, int& matchesL3, int& matchesL5) {
22  ofstream& out = globals->ofstream("nmatches.txt");
23  for (auto& tracklet : tracklets_) {
24  if ((tracklet->nMatches() + tracklet->nMatchesDisk()) > 0) {
25  if (tracklet->layer() == 1)
26  matchesL1++;
27  if (tracklet->layer() == 3)
28  matchesL3++;
29  if (tracklet->layer() == 5)
30  matchesL5++;
31  }
32  out << tracklet->layer() << " " << tracklet->disk() << " " << tracklet->nMatches() << " "
33  << tracklet->nMatchesDisk() << endl;
34  }
35 }
36 
38  const string dirTP = settings_.memPath() + "TrackletParameters/";
39 
40  std::ostringstream oss;
41  oss << dirTP << "TrackletParameters_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
42  << ".dat";
43  auto const& fname = oss.str();
44 
45  if (first) {
46  bx_ = 0;
47  event_ = 1;
48 
49  if (not std::filesystem::exists(dirTP)) {
50  int fail = system((string("mkdir -p ") + dirTP).c_str());
51  if (fail)
52  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirTP;
53  }
54  out_.open(fname);
55  if (out_.fail())
56  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
57 
58  } else
59  out_.open(fname, std::ofstream::app);
60 
61  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
62 
63  for (unsigned int j = 0; j < tracklets_.size(); j++) {
64  string tpar = tracklets_[j]->trackletparstr();
65  out_ << "0x";
66  out_ << std::setfill('0') << std::setw(2);
67  out_ << hex << j << dec;
68  out_ << " " << tpar << " " << trklet::hexFormat(tpar) << endl;
69  }
70  out_.close();
71 
72  bx_++;
73  event_++;
74  if (bx_ > 7)
75  bx_ = 0;
76 }
Settings.h
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
trklet::Settings
Definition: Settings.h:31
TrackletParametersMemory.h
trklet::Settings::memPath
std::string const & memPath() const
Definition: Settings.h:169
trklet::MemoryBase::event_
int event_
Definition: MemoryBase.h:48
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
trklet::TrackletParametersMemory::writeTPAR
void writeTPAR(bool first)
Definition: TrackletParametersMemory.cc:37
trklet::Globals
Definition: Globals.h:32
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::TrackletParametersMemory::writeMatches
void writeMatches(Globals *globals, int &matchesL1, int &matchesL3, int &matchesL5)
Definition: TrackletParametersMemory.cc:21
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
trklet::MemoryBase
Definition: MemoryBase.h:13
Globals.h
trklet::TrackletParametersMemory::clean
void clean() override
Definition: TrackletParametersMemory.cc:14
trklet
Definition: AllProjectionsMemory.h:9
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
std
Definition: JetResolutionObject.h:76
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:15
cms::Exception
Definition: Exception.h:70
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
Tracklet.h
trklet::TrackletParametersMemory::tracklets_
std::vector< Tracklet * > tracklets_
Definition: TrackletParametersMemory.h:36
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44