Exemplo n.º 1
0
//____________________________________
int
GenericUnpackPRDF::process_event(PHCompositeNode *topNode)
{
  _event = findNode::getClass<Event>(topNode, "PRDF");
  if (_event == NULL)
    {
      if (Verbosity() >= VERBOSITY_SOME)
        cout << "GenericUnpackPRDF::Process_Event - Event not found" << endl;
      return Fun4AllReturnCodes::DISCARDEVENT;
    }

  if (verbosity >= VERBOSITY_SOME)
    _event->identify();

  map<int, Packet_hbd_fpgashort*> packet_list;

  for (hbd_channel_map::const_iterator it = _hbd_channel_map.begin();
      it != _hbd_channel_map.end(); ++it)
    {

      const int packet_id = it->first.first;
      const int channel = it->first.second;
      const int tower_id = it->second;

      if (packet_list.find(packet_id) == packet_list.end())
        {
          packet_list[packet_id] =
              dynamic_cast<Packet_hbd_fpgashort*>(_event->getPacket(packet_id));
        }

      Packet_hbd_fpgashort * packet = packet_list[packet_id];

      if (!packet)
        {
//          if (Verbosity() >= VERBOSITY_SOME)
          cout << "GenericUnpackPRDF::process_event - failed to locate packet "
              << packet_id << endl;
          continue;
        }
      assert(packet);

      packet->setNumSamples(PROTOTYPE2_FEM::NSAMPLES);

      RawTower_Prototype2 *tower =
          dynamic_cast<RawTower_Prototype2*>(_towers->getTower(tower_id));
      if (!tower)
        {
          tower = new RawTower_Prototype2();
          tower->set_energy(NAN);
          _towers->AddTower(tower_id, tower);
        }
      tower->set_HBD_channel_number(channel);
      for (int isamp = 0; isamp < PROTOTYPE2_FEM::NSAMPLES; isamp++)
        {
          tower->set_signal_samples(isamp, packet->iValue(channel, isamp));
        }
    }

  for (map<int, Packet_hbd_fpgashort*>::iterator it = packet_list.begin();
      it != packet_list.end(); ++it)
    {
      if (it->second)
        delete it->second;
    }

  return Fun4AllReturnCodes::EVENT_OK;
}
Exemplo n.º 2
0
int tileHelper::evLoop(int run, int evToProcess, int fToProcess){
  hLabHelper * hlHelper = hLabHelper::getInstance();
  hlHelper             -> setPRDFRun(run);
  tileTree::getInstance();

  int OK;


  Eventiterator *it =  new fileEventiterator(hlHelper->prdfName, OK);
  if (OK)
    {
      cout <<"<evLoop> Couldn't open input file " << hlHelper->prdfName << endl;
      delete(it);
      return 0;
    }

  Event *evt;
  int eventseq(0);
  // Loop over events
  while ( (evt = it->getNextEvent()) != 0 )
    {
      hlHelper->eventseq = evt->getEvtSequence();

      if ( evt->getEvtType() != 1 ) {
	cout << "eventseq " << hlHelper->eventseq << " event type = " << evt->getEvtType() << endl;
	continue;
      }
      // ev_display->Divide(nx_c,ny_c);
      // ev_display->SetBit(TPad::kClearAfterCR);

      // Get sPHENIX Packet
      Packet_hbd_fpgashort *spacket = dynamic_cast<Packet_hbd_fpgashort*>( evt->getPacket(21101) );
      if ( spacket )
	{
	  spacket->setNumSamples( NSAMPLES );
	  //	  int nmod_per_fem = spacket->iValue(0,"NRMODULES");
	  //cout << "nmod_per_fem " << nmod_per_fem << endl;
	  if(hlHelper->eventsread%1000==0)  cout <<"RUN  "<<hlHelper->runnumber<<"  EVENT "<<hlHelper->eventseq <<" - "<<hlHelper->eventsread<<endl;
	  hlHelper->eventsread++;
	  for (int ich=0; ich<ACTIVECHANNELS; ich++)    {
	    for (int is=0; is<NSAMPLES; is++)   	{
	      hlHelper->adc[ich][is] =  spacket->iValue(hlHelper->active[ich],is);
	      //	      cout<<"<evLoop  Event "<< hclt->eventseq<<"  ich/is/adc  "<<ich<<" - "<<is<<" - "<< hlHelper->adc[ich][is]<<" active "<<hlHelper->active[ich]<<endl;
	    }
	  }
	  hlHelper->collect();
	  collectTileSummary();
	  tileTiming();
	  delete spacket;
	}

      delete evt;
      hlHelper-> thcl -> Fill();
      if ((evToProcess>0&&hlHelper->eventsread>=evToProcess)||hlHelper->eventsread>270000) break;
    }
  // Normalize trigger histogramm to get per event hit count (number of channels above threshold) 
  int nbs = runsum.trhits->GetNbinsX()-1;
  for(int bx = 1; bx<=nbs; bx++){
    float normx = runsum.trhits->GetBinContent(bx);
    if(normx<=0.) continue;
    for (int threshold = 1; threshold<=CHANNELTHRESHOLDS; threshold++) {
      float cont = runsum.hits_tpc->GetBinContent(bx,threshold);
      runsum.hits_tpc->SetBinContent(bx, threshold, cont/normx);    
    }
  }
  
  if (hlHelper->eventsread>1) runsum.hits_tpc->Scale(1./(Double_t)hlHelper->eventsread);
  // status();
  cout<<"ALLDONE for RUN  "<<hlHelper->runnumber<<"  Events "<<hlHelper->eventsread<<endl;
  delete it;
  hlHelper->thcl -> Write();
  hlHelper->fhcl -> Write();
  hlHelper->fhcl -> Close();

  //  closeLoop();
  return eventseq;

}