/// @file getoutput.cc /// @brief Executable for retrieving output from Allpix in the Pixelman format. // GEANT4 include statements. #include "G4ios.hh" #include "G4String.hh" // ROOT include statements. #include "TFile.h" #include "TDirectory.h" #include "TTree.h" // Standard include statements. #include #include #include #include #include // Allpix include statements. #include "Frames.h" using namespace std; // Forward declarations. class FrameStruct; void checkflags(int,char**); /// @brief The main function for retrieving Pixelman format data files. int main(int argc, char** argv) { G4cout <<"|===================="<Get("MPXTree"); // Set up the frame branch ready for retrieving from the TTree. FrameStruct * m_frame = new FrameStruct("testdata"); TBranch * b_frame = 0; tree->SetBranchAddress("FramesData", &m_frame, &b_frame); // //std::map m_frameXC_TruthE; // Map of the "true" energies. std::map m_frameXC; // Loop over the TTree. Long64_t nentries = tree->GetEntries(); //G4cout << "| * Number of entries in the TTree is " << nentries << G4endl; //std::map::iterator it; std::map::iterator it; for (Long64_t i = 0; i < nentries; i++) { // Get a new data file name. datafilename.str(""); datafilename << outputPath << "/data" << setw(10) << setfill('0') << currentFrame << ".txt"; // Open the new file. of.open(datafilename.str().c_str(), ofstream::out); //m_frameXC_TruthE.clear(); m_frameXC.clear(); // Fill the branch from the TTree. b_frame->GetEntry(i); // Get the pixels. //m_frameXC_TruthE = m_frame->Get_FrameXC_TruthE(); m_frameXC = m_frame->GetPixelCounts(); //G4cout << "| *--> Size of frameXC_TruthE = " << m_frameXC_TruthE.size() << G4endl; //G4cout << "| *--> Size of frameXC = " << m_frameXC.size() << G4endl; // Loop over the pixels. //it = m_frameXC_TruthE.begin(); it = m_frameXC.begin(); //for (; it!=m_frameXC_TruthE.end(); ++it) { for (; it!=m_frameXC.end(); ++it) { //G4cout << "| *----> " << it->first << " " << it->second << G4endl; //G4cout << "| *----> " << it->first << " " << it->second << G4endl; G4int X = it->first; G4int x = X % 256; G4int y = X / 256; //G4double E = it->second; G4int C = it->second; //if (E > 2) { // G4int C = (a * E) + b - (c / (E - t)); // //G4cout << X << " " << Y << " " << C << " (E = " << E << ")" << G4endl; // of << X << "\t" << Y << "\t" << C << endl; //} //end of threshold check. // Output the x, y and C values for the pixel. of << x << "\t" << y << "\t" << C << endl; //G4cout << x << " " << y << " " << C << G4endl; }//end of loop over the pixels. // Create a new Pixelman data file. of.close(); // Increment the frame counter. currentFrame++; }// end of loop over the tree entries. // Tidy up. f->Close(); of.close(); }//end of main function. // // checkflags helper function. // void checkflags(int argc, char** argv) { if (argc < 3) { G4cout << "* ERROR: Use: " << G4endl << "$ " << argv[0] << " " << "[input file name] " << "[output path] " << G4endl; exit(1); } } //end of checkflags function.