Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:32

0001 #pragma once
0002 /**
0003 U4Simtrace.h
0004 ==============
0005 
0006 
0007 
0008 **/
0009 
0010 #include <iostream>
0011 #include "U4Navigator.h"
0012 #include "SEvt.hh"
0013 #include "U4Tree.h"
0014 #include "ssys.h"
0015 
0016 struct U4Simtrace
0017 {
0018     static constexpr const char* U4Simtrace__level = "U4Simtrace__level" ;
0019     static void EndOfRunAction(const U4Tree* tree);
0020     static void Scan(const U4Tree* tree);
0021 };
0022 
0023 /**
0024 U4Simtrace::EndOfRunAction
0025 ---------------------------
0026 
0027 Invoked from U4Recorder::EndOfRunAction when configured by envvar
0028 
0029 **/
0030 
0031 
0032 inline void U4Simtrace::EndOfRunAction(const U4Tree* tree)
0033 {
0034     int level = ssys::getenvint(U4Simtrace__level, 0);
0035     if(level > 0) std::cout << "[U4Simtrace::EndOfRunAction\n" ;
0036     Scan(tree);
0037     if(level > 0) std::cout << "]U4Simtrace::EndOfRunAction\n" ;
0038 }
0039 
0040 inline void U4Simtrace::Scan(const U4Tree* tree)
0041 {
0042     int level = ssys::getenvint(U4Simtrace__level, 0);
0043 
0044     int eventID = 998 ;
0045 
0046     SEvt* evt = SEvt::CreateSimtraceEvent();
0047     evt->beginOfEvent(eventID);
0048 
0049     int num_simtrace = int(evt->simtrace.size()) ;
0050     if(level > 0) std::cout << "[U4Simtrace::Scan num_simtrace " << num_simtrace <<  "\n" ;
0051 
0052     U4Navigator nav(tree);
0053 
0054     for(int i=0 ; i < num_simtrace ; i++)
0055     {
0056         quad4& p = evt->simtrace[i] ;
0057         nav.simtrace(p);
0058         if( level > 1 && i % 1000 == 0 ) std::cout
0059            << "-U4Simtrace::Scan "
0060            << " i " << std::setw(10) << i
0061            << " : " << nav.isect.desc()
0062            << "\n"
0063            ;
0064     }
0065     if(level > 0) std::cout << "-U4Simtrace::Scan nav.stats.desc\n" << nav.stats.desc() << "\n" ;
0066 
0067 
0068     evt->gather();        // follow QSim::simulate
0069     evt->topfold->concat();
0070     evt->topfold->clear_subfold();
0071 
0072     evt->endOfEvent(eventID);
0073 
0074     if(level > 0) std::cout << "]U4Simtrace::Scan num_simtrace " << num_simtrace <<  "\n" ;
0075 }
0076 
0077