//======================================================================= // Level3_ValidationModule.cc // Author: Farrukh Azfar 6th September 2000. //======================================================================= //------------------ // include files //------------------ #include "Level3Mods/Level3_ValidationModule.hh" #include "AbsEnv/AbsEnv.hh" #include "Edm/ConstHandle.hh" #include "Edm/EventRecord.hh" #include "Edm/GenericConstHandle.hh" #include "Edm/Handle.hh" #include #include #include #include #include using std::ostream; using std::setw; using std::setprecision; using std::cout; using std::endl; using std::set; #include "HepTuple/HepHBookNtuple.h" #include "HepTuple/HepHBookFileManager.h" #include "TriggerObjects/TL3D_StorableBank.hh" #include "HepTuple/HepHist1D.h" #include "Level3Objects/Level3ModuleMap.hh" #include "Level3Objects/Level3ModuleResults.hh" //************************************************************************** //--------------- // Constructor //--------------- Level3_ValidationModule::Level3_ValidationModule(const char* const theName, const char* const theDescription ) : HepHistModule(theName, theDescription) { std::cerr << "Level3_ValidationModule constructor" << std::endl; // Store path pass summary in ascii file : path_pass_data = new std::ofstream("path_pass_data"); } //------------- // Destructor //------------- Level3_ValidationModule::~Level3_ValidationModule() { path_pass_data->close(); } //************************************************************************** //=================================== // Job-related member functions //=================================== AppResult Level3_ValidationModule::bookHistograms( ) { std::cout << "Level3_ValidationModule::bookHistograms" << std::endl; HepFileManager* manager = fileManager( ); assert( 0 != manager ); _decisionFromFirstTL3D = &manager->hist1D("Decision First TL3D",6,0.0,6.0,90); assert( 0 != _decisionFromFirstTL3D); _sameResult = &manager->hist1D( "Same Result",6,0.0,6.0,100); assert( 0 != _sameResult ); _differentResult = &manager->hist1D( "Different Result",6,0.0,6.0,101); assert( 0 != _differentResult ); return AppResult::OK; } AppResult Level3_ValidationModule::beginRun(AbsEvent* anEvent) { std::cout << "Level3_ValidationModule::beginRun" << std::endl; for (EventRecord::ConstIterator L3MM_iter(anEvent, "Level3ModuleMap"); L3MM_iter.is_valid(); ++L3MM_iter) { ConstHandle l3mm(L3MM_iter); cout << "Found Level3ModuleMap" << endl; l3mm->print(cout); const std::vector& paths = l3mm->L3Paths(); for (std::vector::const_iterator pi = paths.begin(); pi != paths.end(); ++pi) { L3Path path = *pi; *path_pass_data << path.pathIndex() << " " << path.pathName() << endl; } } return AppResult::OK; } //-------- // event //-------- AppResult Level3_ValidationModule::fillHistograms(AbsEvent* anEvent) { int nRun = AbsEnv::instance()->runNumber(); int nEvent = AbsEnv::instance()->trigNumber(); // did a particular module pass according to the first TL3D bank : // bool didModPass1 = false; // bool didModPass2 = false; // did a particular path pass according to the second TL3D bank : // bool didPathPass1 = false; // bool didPathPass2 = false; // int count_tl3d = 0; // NEW LEVEL3MODULERESULTS LOGIC : // =============================== for (EventRecord::ConstIterator L3MR_iter(anEvent, "Level3ModuleResults"); L3MR_iter.is_valid(); ++L3MR_iter) { ConstHandle l3mr(L3MR_iter); cout << "Found Level3ModuleResults" << endl; // l3mr->print(cout); *path_pass_data << nRun << " " << nEvent << " "; std::vector pathIndices = l3mr->executedPathIndices(); for (std::vector::const_iterator pi = pathIndices.begin(); pi != pathIndices.end(); ++pi) { L3Index index = *pi; *path_pass_data << l3mr->thisEventPassedPath(index) << " "; } *path_pass_data << endl; } // OLD TL3D LOGIC FOR COMPARING MULTIPLE BANKS IN THE SAME EVENT : // =============================================================== // TL3D_Bank_format myTL3Dstruct; // int nPathsIndex = myTL3Dstruct.nPaths_index; // int nModuleSeqIndex = myTL3Dstruct.nModuleSequences_index; // int physics_table = 0; // int calib_job_set = 0; // int exe_version = 0; // int nPath = 1; // hardwired for now... // int* TL3D_PathResults1 = new int [nPath]; // int* TL3D_PathResults2 = new int [nPath]; // for(int pc = 0; pc < nPath; pc++) // { // TL3D_PathResults1[pc] = 0; // TL3D_PathResults2[pc] = 0; // } // std::cout << "*** Level3_ValidationModule::event *** Run = " << nRun // << " Event = " << nEvent << std::endl; // for (EventRecord::ConstIterator TL3D_iter(anEvent, "TL3D_StorableBank"); TL3D_iter.is_valid(); ++TL3D_iter) // { // ConstHandle h(TL3D_iter); // const TL3D_StorableBank & tl3d = *h; // count_tl3d++; // physics_table = tl3d.getPhysicsTable(); // calib_job_set = tl3d.getCalibJobSet(); // exe_version = tl3d.getExeVersion(); // // nPath = tl3d.nPaths(); // std::cout << "Physics Table Version: " << physics_table << std::endl; // std::cout << "Calib Job Set: " << calib_job_set << std::endl; // std::cout << "Executable Version: " << exe_version << std::endl; // if (count_tl3d > 2) // { // std::cout << "Aborting ! More than 2 TL3d Banks in Event !!" // << std::endl; // this->abortJob(anEvent); // } // } // count_tl3d = 0; // for (EventRecord::ConstIterator TL3D_iter(anEvent, "TL3D_StorableBank"); TL3D_iter.is_valid(); ++TL3D_iter) // { // ConstHandle h(TL3D_iter); // const TL3D_StorableBank & tl3d = *h; // count_tl3d++; // for(int pc = 0; pc < nPath; pc++) // { // if(count_tl3d==1) // { // didPathPass1=tl3d.didPathPass(pc); // if (didPathPass1) TL3D_PathResults1[pc]=1; // } // if(count_tl3d==2) // { // didPathPass2=tl3d.didPathPass(pc); // if (didPathPass2) TL3D_PathResults2[pc]=1; // } // } // } // for(int pc = 0; pc < nPath; pc++) // { // if (TL3D_PathResults1[pc]) _decisionFromFirstTL3D->accumulate(pc+0.5); // if (TL3D_PathResults1[pc]==TL3D_PathResults2[pc]) // { // _sameResult->accumulate(pc+0.5); // std::cout << " Path " << pc << " : TL3D Banks agree " << std::endl; // } // else // { // _differentResult->accumulate(pc+0.5); // std::cout << " Path " << pc << " : TL3D Banks disagree " << std::endl; // } // } // delete [] TL3D_PathResults1; // delete [] TL3D_PathResults2; return AppResult::OK; } // end event //--------- // endJob //--------- //----------- // abortJob //----------- AppResult Level3_ValidationModule::abortJob(AbsEvent* aJob) { std::cout << "*** Level3_ValidationModule::abortJob *** " << std::endl; return AppResult::OK; } // end abort Job