//-------------------------------------------------------------------------- // File and Version Information: // $Id: ExampleSourceAnalysis.cc,v 1.1 2008/11/20 16:27:29 lysak Exp $ // // Description: // Class MyModule. This is a simple example of a user module. It // books a few histograms, fills them. // // The "event" entry point is where you should add code to // process event data; define histograms & ntuples in "beginJob" // // Environment: // Software developed for CDF. // // Author List: // Ken Bloom // //------------------------------------------------------------------------ //----------------------- // This Class's Header -- //----------------------- #include "ExampleSourceAnalysis.hh" //------------- // C Headers -- //------------- #include #include //--------------- // C++ Headers -- //--------------- //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "AbsEnv/AbsEnv.hh" #include "HepTuple/HepHist1D.h" #include "HepTuple/HepHBookNtuple.h" #include "Edm/EventRecord.hh" #include "Edm/ConstHandle.hh" #include "RawDataBanks/PHAD_StorableBank.hh" #include "RawDataBanks/MRKD_StorableBank.hh" //class AbsEvent; //----------------------------------------------------------------------- // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- //----------------------------------------------------------------------- static const char rcsid[] = "$Id: ExampleSourceAnalysis.cc,v 1.1 2008/11/20 16:27:29 lysak Exp $"; //---------------- // Constructors -- //---------------- ExampleSourceAnalysis::ExampleSourceAnalysis( const char* const theName, const char* const theDescription ) : HepHistModule( theName, theDescription ), _nphiCut("phiCut",this,0), _nSubphiCut("SubphiCut",this,0), _naverage("naver",this,0) { commands()->append(&_nphiCut); _nphiCut.addDescription("\tSave event if phi equals this value."); commands()->append(&_nSubphiCut); _nSubphiCut.addDescription("\tSave event if sub phi equals this value."); commands()->append(&_naverage); _naverage.addDescription("\tAverage every naverage events."); } //-------------- // Destructor -- //-------------- ExampleSourceAnalysis::~ExampleSourceAnalysis( ) { } //-------------- // Operations -- //-------------- AppResult ExampleSourceAnalysis::beginJob( AbsEvent* aJob ) { //First get access to the object that manages histogram memory space. HepFileManager* manager = fileManager( ); //Book an ntuple. _ntuple = &manager->ntuple("Source",1); _ntuple->setColumnWise(); _ntuple->column("event",(int)0,(int)0); _ntuple->column("wpep",(int)0,(int)0); _ntuple->column("energy",(float)0.,(float)0.); _ntuple->column("index",(int)0,(int)0); _ntuple->column("reel",(int)0,(int)0); _ntuple->column("status1",(int)0,(int)0); // _ntuple->column("status2",(int)0,(int)0); // _ntuple->clearData(); //Book histograms. Note that we let the file manager assign histogram IDs. return AppResult::OK; } AppResult ExampleSourceAnalysis::event( AbsEvent* anEvent ) { float energy; float avg; static float sumsig[2][24][22][2]; int iwe,ieta,iphi,ipmt,sector; int iwpep; static int nev; static int chan[8], reel[8]; static int stat1[8], stat2[8]; //By default, this event fails the filter. bool filter_pass = false; // eventnum = gblEnv->trigNumber(); // Look for MRKD bank to pick up reel/index/status info // The constructor sets the iterator to point // at the first MRKD_StorableBank EventRecord::ConstIterator iMRKD(anEvent,"MRKD_StorableBank") ; // Check to see if there is a MRKD bank if ( iMRKD.is_valid() ) { // Construct a handle to the MRKD bank from the iterator ConstHandle MRKD( iMRKD ); // Loop over the blocks in the bank for (MRKD_StorableBank::ConstBankIter block(MRKD) ; block.is_valid() ; ++block) { for (MRKD_StorableBank::ConstBlockIter card(block) ; card.is_valid() ; ++card) { // Access the card // Get the number of 4 byte words in the card section int size = MRKD->card_data_size(card); // Get the first word for a card // Type = 4 for plug sourcing int type = MRKD->get_type(card) ; if( type == 4) { int index ; // Fill chan with index count for 8 drivers for (index = 1; index <= 8; index++) chan[index-1] = MRKD->data_word(card, index); // Fill reel with reel count for 8 drivers for (index = 9; index <= 16; index++) reel[index-9] = MRKD->data_word(card, index); // Fill stat1 with first status word for 8 drivers for (index = 17; index <= 24; index++) stat1[index-17] = MRKD->data_word(card, index); // Fill stat2 with second status word for 8 drivers for (index = 25; index <= 32; index++) stat2[index-25] = MRKD->data_word(card, index); } } } } //loop over all _bankname banks for(EventRecord::ConstIterator iter(anEvent,"PHAD_StorableBank") ; iter.is_valid() ; ++iter) { nev++; // if(_verbose) cout << "PHAD hits: " << endl; ConstHandle handle(iter); // Loop over all data channels in the bank (if any) for(PHAD_StorableBank::ConstGrandBankIter granditer(handle) ; granditer.is_valid() ; ++granditer) { // Access this channel's energy and fill it into histogram energy = handle->get_energy(granditer); ieta = handle->get_eta(granditer); iphi = handle->get_phi(granditer); ipmt = handle->get_pmt(granditer); iwe = handle->get_we(granditer); sector = 4*iwe + iphi/6; // cout << "eventnum " << eventnum << " nev " << nev // << " iwe " << iwe << " iphi " << iphi // << "ieta " <trigNumber()); _ntuple->capture("wpep",iwpep); _ntuple->capture("energy",avg); _ntuple->capture("index",chan[sector]); _ntuple->capture("reel",reel[sector]); _ntuple->capture("status1",stat1[sector]); // _ntuple->capture("status2",stat2[sector]); _ntuple->storeCapturedData(); _ntuple->clearData(); } } } } } this->setPassed(filter_pass); return AppResult::OK; } AppModule* ExampleSourceAnalysis::clone(const char* cloneName) { return new ExampleSourceAnalysis(cloneName,"this module is a clone ExampleSourceAnalysis"); } AppResult ExampleSourceAnalysis::endRun( AbsEvent* anEvent ) { return AppResult::OK; } const char * ExampleSourceAnalysis::rcsId( ) const { return rcsid; }