#include "UserAlg.h" #include #include #include using std::cout; using std::endl; using std::vector; using std::string; using std::map; UserAlg::UserAlg(Event* event, Geometry* geo, Headers* runHeader):SystemAlg( event,geo,runHeader){ m_event = event; m_geo = geo; m_runHeader = runHeader; // create the new System Alg Objects m_clusterBuilder = new HecClusterBuildAlg(m_event, m_geo, m_runHeader); m_plotAllCells = new PlotAllCellsAlg(m_event, m_geo, m_runHeader); m_hecEnergyLayer = new HecEnergyLayerAlg(m_event,m_geo,m_runHeader); vector algVector; //push the algorithms onto the list //algVector.push_back(m_clusterBuilder); //algVector.push_back(m_plotAllCells); m_hecEnergyLayer->setInteractive(false); //algVector.push_back(m_hecEnergyLayer); SystemAlg::setAlgs(algVector); } // initialize any variables here bool UserAlg::initialize(){ SystemAlg::initialize(); //do NOT remove this line m_cell29 = new TH1F("cell29", "cell29",100,0,0); //create a histogram will 100 bins that autoscales //print out the FEB Numbers numbers of all the HEC Connected channels for(int i = m_runHeader->hec()->getFirstCh(); i <= m_runHeader->hec()->getLastCh(); i++){ if(m_geo->hec_isConnected(i)){ cout << "Hec Channel " << i << " is connected" << endl; } } //print out the FEB Numbers numbers of all the Emec Connected channe for(int i = m_runHeader->emec()->getFirstCh(); i <= m_runHeader->emec()->getLastCh(); i++){ if(m_geo->emec_isConnected(i)){ cout << "Emec Channel " << i << " is connected" << endl; } } return true; } // put any code you want executed per event here bool UserAlg::execute(){ SystemAlg::execute(); //do NOT remove this line m_cell29->Fill(m_event->hecCell(29)->signal());// fill our histogram return true; } //put any code here that you want executed after all the events have been processed. bool UserAlg::finalize(){ SystemAlg::finalize();//do NOT remove this line TCanvas* can = new TCanvas("cell29histo", "Histogram of Cells 29",800,600); // create a canvas to draw out histogram on m_cell29->Draw(); // draw the histogram //Lets get a list of the nearest neighbors to cell 29 multimap nearTo29 = m_geo->hec_nearestNeighbors(m_geo->hec_TBCenter(29)); for(multimap::iterator it = nearTo29.begin(); it != nearTo29.end(); it++){ cout << "Cell " << it->second << " is " << it->first << " cm from cell 29" << endl; } return true; }