Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIMULATION] Applying code checks/format #46213

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions DataFormats/GeometryVector/src/print.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#include <iostream>


namespace geometryDetails {
std::ostream & print3D(std::ostream& s, double x, double y, double z) {
std::ostream& print3D(std::ostream& s, double x, double y, double z) {
return s << " (" << x << ',' << y << ',' << z << ") ";
}
std::ostream & print2D(std::ostream& s, double x, double y) {
return s << " (" << x << ',' << y << ") ";
}
}
std::ostream& print2D(std::ostream& s, double x, double y) { return s << " (" << x << ',' << y << ") "; }

}
} // namespace geometryDetails
110 changes: 52 additions & 58 deletions SimCalorimetry/EcalElectronicsEmulation/bin/recycleTccEmu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,110 +20,104 @@ uint16_t mem[nChs][nEvts];
* general the number of initial events is choosen as a divider of 2048.
*/

int main(int argc, char* argv[]){
if((argc>=2 && ( (strcmp(argv[1],"-h")==0) || (strcmp(argv[1],"--help")==0) ))
|| argc!=3){
int main(int argc, char* argv[]) {
if ((argc >= 2 && ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0))) || argc != 3) {
cout << "Usage: recycleTccEmu infile outfile\n";
return 1;
}

string ifilename = argv[1];
string ofilename = argv[2];
for(int iCh=0; iCh<nChs; ++iCh){
for(int iEvts = 0; iEvts<nEvts; ++iEvts){

for (int iCh = 0; iCh < nChs; ++iCh) {
for (int iEvts = 0; iEvts < nEvts; ++iEvts) {
mem[iCh][iEvts] = 0xFFFF;
}
}

ifstream in(ifilename.c_str());
int chnb;
int bcnb;
int val ;
int dummy ;
int oldLineCnt = 0;
int val;
int dummy;
int oldLineCnt = 0;

//reads input file:
if(in){
while(!in.eof()) {
in >>dec>> chnb >> bcnb >>hex>> val >> dummy ;
mem[chnb-1][bcnb] = val&0x7FF;
if(mem[chnb-1][bcnb]!=val){
cout << "Invalid Et value at line " << oldLineCnt+1 << ".\n";
exit(1);
if (in) {
while (!in.eof()) {
in >> dec >> chnb >> bcnb >> hex >> val >> dummy;
mem[chnb - 1][bcnb] = val & 0x7FF;
if (mem[chnb - 1][bcnb] != val) {
cout << "Invalid Et value at line " << oldLineCnt + 1 << ".\n";
exit(1);
}
// cout<<"Channel: "<< dec <<chnb <<", BX: "
// << dec << bcnb << " filled with val:"<< hex<< mem[chnb-1][bcnb]
// << dec << endl;
++oldLineCnt;
}
} else{
} else {
cout << "Failed to open file " << ifilename << "\n";
}

in.close();
ofstream out(ofilename.c_str());

if(!out){
cout << "Failed to open file '" << ofilename
<< "' in write mode.\n";

if (!out) {
cout << "Failed to open file '" << ofilename << "' in write mode.\n";
return 1;
}



bool singleOldEventCnt = true;
int oldEventCnt[nChs];
//fills output file:
for(int iCh = 0; iCh<nChs; ++iCh){
for (int iCh = 0; iCh < nChs; ++iCh) {
int evtcnt = 0;
//find first not initialized events:
while(evtcnt<nEvts && mem[iCh][evtcnt]!=0xFFFF){++evtcnt;}
while (evtcnt < nEvts && mem[iCh][evtcnt] != 0xFFFF) {
++evtcnt;
}
//cout << "ch " << iCh << " event count: " << evtcnt << "\n";
oldEventCnt[iCh] = evtcnt;
if(oldEventCnt[0]!=oldEventCnt[iCh]) singleOldEventCnt = false;
if(evtcnt==0){
cout << "Error: no data found for channel "<< iCh << "\n";
if (oldEventCnt[0] != oldEventCnt[iCh])
singleOldEventCnt = false;
if (evtcnt == 0) {
cout << "Error: no data found for channel " << iCh << "\n";
}
//clones data of channel iCh
for(int ievt = evtcnt; ievt<nEvts; ++ievt){
if(mem[iCh][ievt]!=0xFFFF){
cout << "Error: memory offset of channel " << iCh
<< " events are not contiguous.\n";
exit(1);
for (int ievt = evtcnt; ievt < nEvts; ++ievt) {
if (mem[iCh][ievt] != 0xFFFF) {
cout << "Error: memory offset of channel " << iCh << " events are not contiguous.\n";
exit(1);
}
mem[iCh][ievt] = mem[iCh][ievt%evtcnt];
mem[iCh][ievt] = mem[iCh][ievt % evtcnt];
}

for(int ievt=0; ievt<nEvts; ++ievt){
out << iCh+1 << "\t" << ievt
<< "\t" << hex << "0x" << setfill('0') << setw(4)
<< mem[iCh][ievt]
<< setfill(' ') << dec << "\t0"
<< "\n";

for (int ievt = 0; ievt < nEvts; ++ievt) {
out << iCh + 1 << "\t" << ievt << "\t" << hex << "0x" << setfill('0') << setw(4) << mem[iCh][ievt] << setfill(' ')
<< dec << "\t0"
<< "\n";
}
}

//warning for aperiodic case:
if(singleOldEventCnt && (nEvts%oldEventCnt[0]!=0)){
if (singleOldEventCnt && (nEvts % oldEventCnt[0] != 0)) {
cout << "Warning: ouput event count (2048) is not a mulitple of input "
"event counts\n" ;
"event counts\n";
}
if(!singleOldEventCnt){
if (!singleOldEventCnt) {
stringstream s;
for(int iCh=0; iCh<nChs; ++iCh){
if(nEvts%oldEventCnt[iCh]){
s << (s.str().empty()?"":", ") << iCh;
for (int iCh = 0; iCh < nChs; ++iCh) {
if (nEvts % oldEventCnt[iCh]) {
s << (s.str().empty() ? "" : ", ") << iCh;
}
}
if(!s.str().empty())
cout << "Warning: ouput event count (2048) for channel"
<< (s.str().size()>1?"s":"") << " "
<< s.str()
<< " is not a mulitple of input event counts\n" ;
if (!s.str().empty())
cout << "Warning: ouput event count (2048) for channel" << (s.str().size() > 1 ? "s" : "") << " " << s.str()
<< " is not a mulitple of input event counts\n";
}
if(!singleOldEventCnt){

if (!singleOldEventCnt) {
cout << "Info: in the input file the event count depends on the channel";
}
}