コード例 #1
0
ファイル: SsdProcessor.cpp プロジェクト: gottardo7/pixie_scan
bool SsdProcessor::Process(RawEvent &event) {
    using namespace dammIds::ssd;
    if (!EventProcessor::Process(event))
        return false;

    static bool firstTime = true;
    static const DetectorSummary *ssdSummary[NUM_DETECTORS];

    if (firstTime) {
        ssdSummary[0] = event.GetSummary("ssd:implant");
        ssdSummary[1] = event.GetSummary("ssd:box");
        ssdSummary[2] = event.GetSummary("ssd:digisum");
        ssdSummary[3] = event.GetSummary("ssd:ssd_4");
        firstTime = false;
    }

    for (int i = 0; i < NUM_DETECTORS; i++) {
        if (ssdSummary[i]->GetMult() == 0)
            continue;
        const ChanEvent *ch = ssdSummary[i]->GetMaxEvent();
        int position = ch->GetChanID().GetLocation();
        double energy   = ch->GetCalEnergy();

        plot(DD_POSITION__ENERGY_DETX + i, energy, position);
    }

    EndProcess(); // update the processing time
    return true;
}
コード例 #2
0
ファイル: DetectorDriver.cpp プロジェクト: akeeler/pixie_scan
void DetectorDriver::ProcessEvent(RawEvent& rawev) {
    plot(dammIds::raw::D_NUMBER_OF_EVENTS, dammIds::GENERIC_CHANNEL);
    try {
        for (vector<ChanEvent*>::const_iterator it = rawev.GetEventList().begin();
            it != rawev.GetEventList().end(); ++it) {
            PlotRaw((*it));
            ThreshAndCal((*it), rawev);
            PlotCal((*it));

            string place = (*it)->GetChanID().GetPlaceName();
            if (place == "__-1")
                continue;

            if ( (*it)->IsSaturated() || (*it)->IsPileup() )
                continue;

            double time = (*it)->GetTime();
            double energy = (*it)->GetCalEnergy();
            int location = (*it)->GetChanID().GetLocation();

            EventData data(time, energy, location);
            TreeCorrelator::get()->place(place)->activate(data);
        }

        //!First round is preprocessing, where process result must be guaranteed
        //!to not to be dependent on results of other Processors.
        for (vector<EventProcessor*>::iterator iProc = vecProcess.begin();
        iProc != vecProcess.end(); iProc++)
            if ( (*iProc)->HasEvent() )
                (*iProc)->PreProcess(rawev);
        ///In the second round the Process is called, which may depend on other
        ///Processors.
        for (vector<EventProcessor *>::iterator iProc = vecProcess.begin();
        iProc != vecProcess.end(); iProc++)
            if ( (*iProc)->HasEvent() )
                (*iProc)->Process(rawev);
        // Clear all places in correlator (if of resetable type)
	for (map<string, Place*>::iterator it = 
		 TreeCorrelator::get()->places_.begin(); 
	     it != TreeCorrelator::get()->places_.end(); ++it)
	    if ((*it).second->resetable())
                (*it).second->reset();
    } catch (GeneralException &e) {
        /// Any exception in activation of basic places, PreProcess and Process
        /// will be intercepted here
        cout << "Exception caught at DetectorDriver::ProcessEvent" << endl;
        cout << "\t" << e.what() << endl;
        exit(EXIT_FAILURE);
    } catch (GeneralWarning &w) {
        cout << "Warning caught at DetectorDriver::ProcessEvent" << endl;
        cout << "\t" << w.what() << endl;
    }
}
コード例 #3
0
ファイル: ScintProcessor.cpp プロジェクト: akeeler/pixie_scan
bool ScintProcessor::PreProcess(RawEvent &event) {
    if(!EventProcessor::PreProcess(event))
        return false;

    static const int BETA_THRESHOLD = 10;

    static const vector<ChanEvent*> &scintBetaEvents =
        event.GetSummary("scint:beta")->GetList();

    for(vector<ChanEvent*>::const_iterator it = scintBetaEvents.begin();
            it != scintBetaEvents.end(); it++) {
            string place = (*it)->GetChanID().GetPlaceName();
            if(TCorrelator::get().places.count(place) == 1) {
                    double time   = (*it)->GetTime();
                    double energy = (*it)->GetEnergy();
                    if(energy > BETA_THRESHOLD) {
                            EventData data(time, true, energy);
                            TCorrelator::get().places[place]->activate(data);
                        }
                }
            else {
                    cerr << "In ScintProcessor: beta place " << place
                         << " does not exist." << endl;
                    return false;
                }
        }

    static const vector<ChanEvent*> &scintNeutrEvents =
        event.GetSummary("scint:neutr")->GetList();

    for(vector<ChanEvent*>::const_iterator it = scintNeutrEvents.begin();
            it != scintNeutrEvents.end(); it++) {
            string place = (*it)->GetChanID().GetPlaceName();
            if(TCorrelator::get().places.count(place) == 1) {
                    double time   = (*it)->GetTime();
                    double energy = (*it)->GetCalEnergy();
                    EventData data(time, true, energy);
                    TCorrelator::get().places[place]->activate(data);
                }
            else {
                    cerr << "In ScintProcessor: beta place " << place
                         << " does not exist." << endl;
                    return false;
                }
        }

    return true;
}
コード例 #4
0
bool VandleProcessor::PreProcess(RawEvent &event) {
    if (!EventProcessor::PreProcess(event))
        return false;

    ClearMaps();

    static const vector<ChanEvent*> &events =
        event.GetSummary("vandle")->GetList();

    if(events.empty() || events.size() < 2) {
        if(events.empty())
            plot(D_DEBUGGING, 27);
        if(events.size() < 2)
            plot(D_DEBUGGING, 2);
        return(false);
    }

    BarBuilder billy(events);
    bars_ = billy.GetBarMap();

    if(bars_.empty()) {
        plot(D_DEBUGGING, 25);
        return(false);
    }

    FillVandleOnlyHists();
    return(true);
}
コード例 #5
0
void ValidProcessor::OutputData(RawEvent &event)
{   
    static const vector<ChanEvent*> & validEvents = 
	event.GetSummary("valid")->GetList();

    
    //Optimize this later!!!! Spends too much time
    //in the open/close operations.
    if(fileName.str() == "") {
	char hisFileName[32];
	GetArgument(1, hisFileName, 32);
	string temp = hisFileName;
	temp = temp.substr(0, temp.find_first_of(" "));
	fileName << "monaTimeStamps-" << temp << ".dat";
    }

    ofstream data;
    data.open(fileName.str().c_str(), fstream::app);      
    
    for(vector<ChanEvent*>::const_iterator itValid = validEvents.begin();
	itValid != validEvents.end(); itValid++) {
	
        string type = (*itValid)->GetChanID().GetType();
	bool hasTag = (*itValid)->GetChanID().GetTag("output");
	unsigned int location = (*itValid)->GetChanID().GetLocation();
	unsigned int long timeLow = (*itValid)->GetQdcValue(0);
	unsigned int long timeHigh = (*itValid)->GetQdcValue(1);
	if(hasTag)
	    data << type << " " << location << " " 
		 << timeLow << " " << timeHigh << endl;
    }
    data.close();
}//void ValidProcessor::OutputData
コード例 #6
0
/** Initialize the processor if the detectors that require it are used in 
 * the analysis
 */
bool EventProcessor::Init(RawEvent& rawev) 
{
    vector<string> intersect;   
    const set<string> &usedDets = DetectorLibrary::get()->GetUsedDetectors();
    
    set_intersection(associatedTypes.begin(), associatedTypes.end(),
                     usedDets.begin(), usedDets.end(), 
                     back_inserter(intersect) );
    
    if (intersect.empty()) {
        return false;
    }

    // make the corresponding detector summary
    for (vector<string>::const_iterator it = intersect.begin();
	 it != intersect.end(); it++) {
        sumMap.insert( make_pair(*it, rawev.GetSummary(*it)) );
    }

    initDone = true;
    cout << "processor " << name << " initialized operating on " 
         << intersect.size() << " detector type(s)." << endl;

    // cout << "  adding detector summary " << iSum->first
    //	    << " at address " << &iSum->second << endl;
	    
    return true;
}
コード例 #7
0
bool NeutronProcessor::Process(RawEvent &event)
{
    if (!EventProcessor::Process(event))
        return false;

    static const vector<ChanEvent*> &scintNeutrEvents =
	event.GetSummary("scint:neutr")->GetList();

    for (vector<ChanEvent*>::const_iterator it = scintNeutrEvents.begin();
	 it != scintNeutrEvents.end(); it++) {

        ChanEvent *chan = *it;
        int loc = chan->GetChanID().GetLocation();
        double neutronEnergy = chan->GetCalEnergy();

        if (TreeCorrelator::get()->place("Beta")->status()) {
            plot(betaGated::D_ENERGY_DETX + loc, neutronEnergy);
        }
        if (TreeCorrelator::get()->place("Gamma")->status()) {
            plot(gammaGated::D_ENERGY_DETX + loc, neutronEnergy);
        }
        if (TreeCorrelator::get()->place("GammaBeta")->status()) {
            plot(betaGammaGated::D_ENERGY_DETX + loc, neutronEnergy);
        }
    }
    EndProcess();
    return true;
}
コード例 #8
0
bool TeenyVandleProcessor::PreProcess(RawEvent &event) {
    data_.clear();
    if (!EventProcessor::PreProcess(event))
        return(false);

    static const vector<ChanEvent*> & events =
        event.GetSummary("tvandle")->GetList();

    for(vector<ChanEvent*>::const_iterator it = events.begin();
        it != events.end(); it++) {
        unsigned int location = (*it)->GetChanID().GetLocation();
        string subType = (*it)->GetChanID().GetSubtype();
        TimingDefs::TimingIdentifier id(location, subType);
        data_.insert(make_pair(id, HighResTimingData(*it)));
    }

    if(data_.size() != 2)
        return(false);

    HighResTimingData right = (*data_.find(make_pair(0,"right"))).second;
    HighResTimingData left  = (*data_.find(make_pair(0,"left"))).second;

    double timeDiff = left.GetHighResTime() - right.GetHighResTime();
    double corTimeDiff = left.GetCorrectedTime() - right.GetCorrectedTime();

    plot(DD_QDCVSMAX, right.GetMaximumValue(), right.GetTraceQdc());

    if(right.GetIsValid() && left.GetIsValid()) {
            double timeRes = 50; //20 ps/bin
            double timeOff = 500;

            plot(D_TIMEDIFF, timeDiff*timeRes + timeOff);
            plot(DD_PVSP, right.GetPhase()*timeRes, left.GetPhase()*timeRes);
            plot(DD_MAXRIGHTVSTDIFF, timeDiff*timeRes+timeOff, right.GetMaximumValue());
            plot(DD_MAXLEFTVSTDIFF, timeDiff*timeRes+timeOff, left.GetMaximumValue());

            plot(DD_MAX, right.GetMaximumValue(), 0);
            plot(DD_MAX, left.GetMaximumValue(), 1);
            plot(DD_TQDC, right.GetTraceQdc(), 0);
            plot(DD_TQDC, left.GetTraceQdc(), 1);
            plot(DD_SNRANDSDEV, right.GetSignalToNoiseRatio()+50, 0);
            plot(DD_SNRANDSDEV, right.GetStdDevBaseline()*timeRes+timeOff, 1);
            plot(DD_SNRANDSDEV, left.GetSignalToNoiseRatio()+50, 2);
            plot(DD_SNRANDSDEV, left.GetStdDevBaseline()*timeRes+timeOff, 3);

            double ampDiff = fabs(right.GetMaximumValue()-left.GetMaximumValue());
            if(ampDiff <=50)
                plot(DD_MAXLVSTDIFFAMP, timeDiff*timeRes+timeOff,
                     left.GetMaximumValue());

            plot(DD_MAXLCORGATE, corTimeDiff*timeRes+timeOff,
                 left.GetMaximumValue());

            if(right.GetMaximumValue() > 2500) {
                plot(DD_MAXLVSTDIFFGATE, timeDiff*timeRes+timeOff,
                     left.GetMaximumValue());
            }
    }
    return(true);
}
コード例 #9
0
bool TwoChanTimingProcessor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return false;

    //Define a map to hold the information
    TimingMap pulserMap;

    //plot the number of times we called the function
    codes->Fill(PROCESS_CALLED);

    static const vector<ChanEvent *> &pulserEvents =
            event.GetSummary("pulser")->GetList();

    for (vector<ChanEvent *>::const_iterator itPulser = pulserEvents.begin();
         itPulser != pulserEvents.end(); itPulser++) {
        int location = (*itPulser)->GetChanID().GetLocation();
        string subType = (*itPulser)->GetChanID().GetSubtype();

        TimingDefs::TimingIdentifier key(location, subType);
        pulserMap.insert(make_pair(key, HighResTimingData(*itPulser)));
    }

    if (pulserMap.empty() || pulserMap.size() % 2 != 0) {
        //If the map is empty or size isn't even we return and increment
        // error code
        codes->Fill(WRONG_NUM);
        EndProcess();
        return false;
    }

    HighResTimingData start =
            (*pulserMap.find(make_pair(0, "start"))).second;
    HighResTimingData stop =
            (*pulserMap.find(make_pair(0, "stop"))).second;

    static int trcCounter = 0;
    int bin;
    for(vector<int>::const_iterator it = start.GetTrace()->begin(); it !=
            start.GetTrace()->end(); it++) {
        bin = (int)(it-start.GetTrace()->begin());
        traces->Fill(bin, trcCounter, *it);
        //Only output the 500th trace to make sure that we are not at the
        // beginning of the file and we're a ways into the data.
        if(trcCounter == 500)
            trcfile << bin << " " << *it << " " << sqrt(*it) << endl;
    }
    trcCounter++;

    //We only plot and analyze the data if the data is validated
    if (start.GetIsValid() && stop.GetIsValid()) {
        start.FillRootStructure(rstart);
        stop.FillRootStructure(rstop);
        tree->Fill();
        start.ZeroRootStructure(rstart);
        stop.ZeroRootStructure(rstop);
    }
    EndProcess();
    return true;
}
コード例 #10
0
void Analog_Devices_VCO::ADF4360_Device::setOutputPowerEvent(const RawEvent& evt) throw(std::exception)
{
	unsigned short oldPower = getOutputPower();
	bool oldPowerStatus = getPowerStatus();
	std::string newPower = evt.stringValue();
	bool success = false;

	if(newPower.compare("Off") == 0)
	{
		SynchronousPowerDownPrepare();
		success = true;
	}
	else if(newPower.compare("-13 dBm") == 0)
	{
		PowerUpPrepare();
		success = setOutputPower(0);
	}
	else if(newPower.compare("-11 dBm") == 0)
	{
		PowerUpPrepare();
		success = setOutputPower(1);
	}
	else if(newPower.compare("-8 dBm") == 0)
	{
		PowerUpPrepare();
		success = setOutputPower(2);
	}
	else if(newPower.compare("-6 dBm") == 0)
	{
		PowerUpPrepare();
		success = setOutputPower(3);
	}
	else
	{
		success = false;
	}

	if(!success)
	{
		throw EventParsingException(evt,
						"The ADF4360 failed to set its power to " + newPower + ".");
	}

	//copy the VCO latches into eventLatches before resetting them
	eventLatches.setLatches( getVCOLatches() );

	//reset
	if(!oldPowerStatus)	//it was off
	{
		SynchronousPowerDownPrepare();
	}
	else
	{
		PowerUpPrepare();
	}

	setOutputPower(oldPower);
}
コード例 #11
0
bool VandleProcessor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return(false);
    plot(D_DEBUGGING, 30);

    //Removing this until it can be updated with the TreeCorrelator
    // hasDecay_ =
    //     (event.GetCorrelator().GetCondition() == Correlator::VALID_DECAY);
    // if(hasDecay_)
    //     decayTime_ = event.GetCorrelator().GetDecayTime() *
    //             Globals::get()->clockInSeconds();

    geSummary_ = event.GetSummary("ge");

    static const vector<ChanEvent*> &betaStarts =
        event.GetSummary("beta_scint:beta")->GetList();
    static const vector<ChanEvent*> &liquidStarts =
        event.GetSummary("liquid:scint:start")->GetList();

    vector<ChanEvent*> startEvents;
    startEvents.insert(startEvents.end(),
		       betaStarts.begin(), betaStarts.end());
    startEvents.insert(startEvents.end(),
		       liquidStarts.begin(), liquidStarts.end());

    TimingMapBuilder bldStarts(startEvents);
    starts_ = bldStarts.GetMap();

    static const vector<ChanEvent*> &doubleBetaStarts =
        event.GetSummary("beta:double:start")->GetList();
    BarBuilder startBars(doubleBetaStarts);
    barStarts_ = startBars.GetBarMap();

    if(!doubleBetaStarts.empty())
        AnalyzeBarStarts();
    else
        AnalyzeStarts();

    EndProcess();
    return(true);
}
コード例 #12
0
ファイル: E11027Processor.cpp プロジェクト: spaulaus/paass
///Main processing of data of interest
bool E11027Processor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return (false);

    static const vector<ChanEvent *> &validEvents = event.GetSummary("valid")->GetList();

    for (vector<ChanEvent *>::const_iterator itValid = validEvents.begin(); itValid != validEvents.end(); itValid++)
        if ((*itValid)->GetChanID().HasTag("output"))
            *poutstream_ << (*itValid)->GetChanID().GetType() << " " << (*itValid)->GetChanID().GetLocation() << " "
                        << (*itValid)->GetQdc()[0] << " " << (*itValid)->GetQdc()[1] << endl;

    EndProcess();
    return (true);
}
コード例 #13
0
void Analog_Devices_VCO::ADF4360_Device::setFvcoEvent(const RawEvent& evt) throw(std::exception)
{
	double oldFreq = getFvco();
	double newFreq = evt.numberValue();

	if(!setFvco(newFreq))
	{
		throw EventParsingException(evt,
						"The ADF4360 failed to set its frequency to " + valueToString(newFreq) + ".");
	}

	//copy the VCO latches into eventLatches before resetting them
	eventLatches.setLatches( getVCOLatches() );

	setFvco(oldFreq);
}
コード例 #14
0
bool DoubleBetaProcessor::PreProcess(RawEvent &event) {
    if (!EventProcessor::PreProcess(event))
        return (false);
    lrtbars_.clear();
    bars_.clear();


    static const vector<ChanEvent *> &events =
            event.GetSummary("beta:double")->GetList();

    BarBuilder builder(events);
    builder.BuildBars();

    lrtbars_ = builder.GetLrtBarMap();
    bars_ = builder.GetBarMap();

    double resolution = 2;
    double offset = 1500;

    for (map < unsigned int, pair < double, double > >
                                            ::iterator it = lrtbars_.begin();
    it != lrtbars_.end();
    it++) {
        stringstream place;
        place << "DoubleBeta" << (*it).first;
        EventData data((*it).second.first, (*it).second.second, (*it).first);
        TreeCorrelator::get()->place(place.str())->activate(data);
    }

    for (BarMap::const_iterator it = bars_.begin(); it != bars_.end(); it++) {
        unsigned int barNum = (*it).first.first;
        histo.Plot(DD_QDC, (*it).second.GetLeftSide().GetTraceQdc(), barNum * 2);
        histo.Plot(DD_QDC, (*it).second.GetRightSide().GetTraceQdc(), barNum * 2 + 1);
        histo.Plot(DD_TDIFF, (*it).second.GetTimeDifference() * resolution + offset,
             barNum);
        if (barNum == 0) {
            histo.Plot(DD_PP, (*it).second.GetLeftSide().GetPhaseInNs() * resolution,
                 (*it).second.GetRightSide().GetPhaseInNs() * resolution);
            histo.Plot(DD_QDCTDIFF,
                 (*it).second.GetTimeDifference() * resolution + offset,
                 (*it).second.GetQdc());
        }
    }
    return (true);
}
コード例 #15
0
ファイル: BetaProcessor.cpp プロジェクト: akeeler/pixie_scan
bool BetaProcessor::PreProcess(RawEvent &event){
    if (!EventProcessor::PreProcess(event))
        return false;

    static const vector<ChanEvent*> &scintBetaEvents =
	event.GetSummary("scint:beta")->GetList();

    int multiplicity = 0;
    for (vector<ChanEvent*>::const_iterator it = scintBetaEvents.begin();
	 it != scintBetaEvents.end(); it++) {
        double energy = (*it)->GetEnergy();
        if (energy > detectors::betaThreshold)
            ++multiplicity;
        plot(D_ENERGY_BETA, energy);
    }
    plot(D_MULT_BETA, multiplicity);
    return true;
}
コード例 #16
0
bool SsdProcessor::Process(RawEvent &event) {
    using namespace dammIds::ssd;
    if (!EventProcessor::Process(event))
        return false;
    if (ssdSummary == NULL)
        ssdSummary = event.GetSummary("ssd");

    int ssdPos = UINT_MAX;
    double ssdEnergy, ssdTime = 0.;
    string ssdSubtype="";

    bool hasSsd = ssdSummary && (ssdSummary->GetMult() > 0);

    string WhichSsd = ssdSummary-> GetName();

    if (hasSsd) {
	const ChanEvent *ch = ssdSummary->GetMaxEvent();
        ssdSubtype =  ch->GetChanID().GetSubtype();

      	ssdPos    = ch->GetChanID().GetLocation();
	ssdEnergy = ch->GetCalEnergy();
	ssdTime   = ch->GetTime();
    } else
        ssdEnergy = 0.;

    if (ssdSubtype=="ssd_1")
      plot(SSD1_POSITION_ENERGY, ssdEnergy, ssdPos);

    if (ssdSubtype=="ssd_2")
      plot(SSD2_POSITION_ENERGY, ssdEnergy, ssdPos-8);

    if (ssdSubtype=="ssd_3")
      plot(SSD3_POSITION_ENERGY, ssdEnergy, ssdPos-16);

    EndProcess(); // update the processing time
    return true;
}
コード例 #17
0
bool ImplantSsdProcessor::Process(RawEvent &event)
{
    using namespace dammIds::implantSsd;

    if (!EventProcessor::Process(event)) {
        EndProcess();
	return false;
    }

    static bool firstTime = true;
    static LogicProcessor *logProc = NULL;

    static Correlator &corr = event.GetCorrelator();
    static const DetectorSummary *tacSummary  = event.GetSummary("generic:tac", true);
    static DetectorSummary *impSummary  = event.GetSummary("ssd:sum", true);
    static const DetectorSummary *mcpSummary  = event.GetSummary("logic:mcp", true);
    static const DetectorSummary *vetoSummary = event.GetSummary("ssd:veto", true);
    static const DetectorSummary *boxSummary  = event.GetSummary("ssd:box", true);
    DetectorDriver* driver = DetectorDriver::get();

    if (impSummary->GetMult() == 0) {
      EndProcess();
      return false;
    }
    if (firstTime) {
      vector<EventProcessor *> vecProc = driver->GetProcessors("logic");
      for (vector< EventProcessor * >::iterator it = vecProc.begin(); it != vecProc.end(); it++) {
	if ( (*it)->GetName() == "triggerlogic" || (*it)->GetName() == "logic" ) {
	  logProc = reinterpret_cast < LogicProcessor * >(*it);
  	  cout << "Implant SSD processor grabbed logic processor" << endl;
        }
      }
      firstTime=false;
    }

    EventInfo info;
    ChanEvent *ch  = impSummary->GetMaxEvent(true);
    info.hasVeto = ( vetoSummary && vetoSummary->GetMult() > 0 );

    int location = ch->GetChanID().GetLocation();
    if (ch->IsSaturated()) {
	info.energy = 16000; // arbitrary large number
    } else {
	info.energy  = ch->GetCalEnergy();
    }
    if (ch->GetTrace().HasValue("position")) {
	info.position = ch->GetTrace().GetValue("position");
    } // else it defaults to nan

    info.time    = ch->GetTime();
    info.beamOn  = true;

    // recect noise events
    if (info.energy < 10 || ch->GetTrace().HasValue("badqdc")) {
	EndProcess();
	return true;
    }

    if (logProc) {
	info.clockCount = logProc->StartCount(2);
	if (logProc->LogicStatus(3) || logProc->LogicStatus(4) || logProc->LogicStatus(5)) {
	    info.beamOn = true;
	    info.offTime = 0;
	} else {
	    info.beamOn = false;
	    if (!logProc->LogicStatus(3))
		info.offTime = logProc->TimeOff(3, info.time);
	    else if (!logProc->LogicStatus(4))
		info.offTime = logProc->TimeOff(4, info.time) + 300e-6;
	    else if (!logProc->LogicStatus(5))
		info.offTime = logProc->TimeOff(5, info.time) + 600e-6;
	}
	for (int i=0; i < dammIds::logic::MAX_LOGIC; i++) {
	    info.logicBits[i] = (logProc->LogicStatus(i) ? '1' : '0');
	}
    }
    double digitalTof = NAN;
    if (mcpSummary) {
	info.mcpMult = mcpSummary->GetMult();
	vector<ChanEvent*> mcpEvents = mcpSummary->GetList();

	double dtMin = DBL_MAX;

	for (vector<ChanEvent*>::iterator it = mcpEvents.begin();
	     it != mcpEvents.end(); it++) {
	    double dt = info.time - (*it)->GetTime();

	    plot(D_TDIFF_FOIL_IMPLANT, 500 + dt);
	    if (mcpEvents.size() == 1) {
		digitalTof = -10.*dt;
		plot(D_TDIFF_FOIL_IMPLANT_MULT1, 500 + dt);
	    }
	    dtMin = min(dtMin, dt);
	}
	if (dtMin != DBL_MAX)
	    info.foilTime= dtMin;
    } else {
	info.mcpMult  = 0;
	info.foilTime = NAN;
    }
    if (impSummary) {
	info.impMult = impSummary->GetMult();
    } else {
	info.impMult = 0;
    }
    if (boxSummary) {
	info.boxMult = boxSummary->GetMult();

	if (info.boxMult > 0) {
	    const ChanEvent *boxCh = boxSummary->GetMaxEvent();

	    info.energyBox = boxCh->GetCalEnergy(); //raw?
	    info.boxMax = boxCh->GetChanID().GetLocation();
	} else {
	    info.energyBox = 0;
	    info.boxMax = -1;
	}
    } else {
	info.boxMult = 0;
    }
    info.tof = NAN;
    if (tacSummary) {
	const vector<ChanEvent*> events = tacSummary->GetList();
	for (vector<ChanEvent*>::const_iterator it = events.begin(); it != events.end(); it++) {
	    int loc = (*it)->GetChanID().GetLocation();
	    if (loc == 2) {
		info.tof = (*it)->GetCalEnergy();
		info.hasTof = true;
		break;
	    }
	}
    } else {
	info.hasTof = true;
    }

    Trace &trace = ch->GetTrace();
    if (trace.HasValue("filterEnergy2")) {
	info.pileUp = true;
    }

    SetType(info);
    Correlate(corr, info, location);

    // TOF spectra update
    if (tacSummary) {
	const vector<ChanEvent*> events = tacSummary->GetList();
	for (vector<ChanEvent*>::const_iterator it = events.begin();
	     it != events.end(); it++) {
	    double tof  = (*it)->GetCalEnergy();
	    int ntof = (*it)->GetChanID().GetLocation();

	    plot(DD_ALL_ENERGY__TOFX + ntof - 1, info.energy, tof);
	    if (!isnan(digitalTof) && digitalTof > 1500. && digitalTof < 2000)
		plot(DD_ALL_ENERGY__TOFX_GATED + ntof - 1, info.energy, tof);
	    if (info.type == EventInfo::IMPLANT_EVENT) {
		plot(DD_IMPLANT_ENERGY__TOFX + ntof - 1, info.energy, tof);
	    } else if (info.type == EventInfo::PROTON_EVENT) {
		plot(DD_VETO_ENERGY__TOFX + ntof - 1, info.energy, tof);
	    }
	}
	// TAC channel 0 is missing, so use it for the digital tof
	if (!isnan(digitalTof)) {
	    plot(DD_ALL_ENERGY__TOFX, info.energy, digitalTof);
	    if (info.type == EventInfo::IMPLANT_EVENT) {
		plot(DD_IMPLANT_ENERGY__TOFX, info.energy, digitalTof);
	    } else if (info.type == EventInfo::PROTON_EVENT) {
		plot(DD_VETO_ENERGY__TOFX, info.energy, digitalTof);
	    }
	}
    }

    if (info.type == EventInfo::PROTON_EVENT) {
        const ChanEvent *chVeto = vetoSummary->GetMaxEvent();

        unsigned int posVeto = chVeto->GetChanID().GetLocation();
        double vetoEnergy = chVeto->GetCalEnergy();

        plot(DD_LOC_VETO__LOC_SSD, posVeto, location);
        plot(DD_TOTENERGY__ENERGY, vetoEnergy + info.energy, info.energy);
    }

    if (info.pileUp) {
        double trigTime = info.time;

        info.energy = driver->cali.GetCalEnergy(ch->GetChanID(),
                                              trace.GetValue("filterEnergy2"));
        info.time = trigTime + trace.GetValue("filterTime2") - trace.GetValue("filterTime");

        SetType(info);
        Correlate(corr, info, location);

        int numPulses = trace.GetValue("numPulses");

        if ( numPulses > 2 ) {
            corr.Flag(location, 1);
            cout << "Flagging triple event" << endl;
            for (int i=3; i <= numPulses; i++) {
            stringstream str;
            str << "filterEnergy" << i;
            info.energy = driver->cali.GetCalEnergy(ch->GetChanID(),
                                              trace.GetValue(str.str()));
            str.str(""); // clear it
            str << "filterTime" << i;
            info.time   = trigTime + trace.GetValue(str.str()) - trace.GetValue("filterTime");

            SetType(info);
            Correlate(corr, info, location);
            }
        }
        // corr.Flag(location, 1);
#ifdef VERBOSE
        cout << "Flagging for pileup" << endl;

        cout << "fast trace " << fastTracesWritten << " in strip " << location
            << " : " << trace.GetValue("filterEnergy") << " " << trace.GetValue("filterTime")
            << " , " << trace.GetValue("filterEnergy2") << " " << trace.GetValue("filterTime2") << endl;
        cout << "  mcp mult " << info.mcpMult << endl;
#endif // VERBOSE

        if (fastTracesWritten < numTraces) {
            trace.Plot(D_FAST_DECAY_TRACE + fastTracesWritten);
            fastTracesWritten++;
        }
    }

    if (info.energy > 10000 && !ch->IsSaturated() && !isnan(info.position) ) {
	corr.Flag(location, info.position);
    }

    if (info.energy > 8000 && !trace.empty()) {
#ifdef VERBOSE
	cout << "high energy decay of " << info.energy
	     << "(raw energy " << ch->GetEnergy() << ") with beam "
	     << (info.beamOn ? "present" : "absent") << endl;

	cout << "Flagging for high energy " << info.energy << " with trace" << endl;
#endif //VERBOSE
	// corr.Flag(location, 1);

	if (highTracesWritten < numTraces) {
	    trace.Plot(D_HIGH_ENERGY_TRACE + highTracesWritten);
	    highTracesWritten++;
	}
    }

    EndProcess(); // update the processing time
    return true;
}
コード例 #18
0
ファイル: IS600Processor.cpp プロジェクト: pixie16/paass
bool IS600Processor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return(false);
    double plotMult_ = 2;
    double plotOffset_ = 1000;

    BarMap vbars, betas;
    map<unsigned int, pair<double,double> > lrtBetas;
    vector<ChanEvent*> geEvts;
    vector<vector<AddBackEvent> > geAddback;

    if(event.GetSummary("vandle")->GetList().size() != 0)
        vbars = ((VandleProcessor*)DetectorDriver::get()->
            GetProcessor("VandleProcessor"))->GetBars();
    if(event.GetSummary("beta:double")->GetList().size() != 0) {
        betas = ((DoubleBetaProcessor*)DetectorDriver::get()->
            GetProcessor("DoubleBetaProcessor"))->GetBars();
        lrtBetas = ((DoubleBetaProcessor*)DetectorDriver::get()->
            GetProcessor("DoubleBetaProcessor"))->GetLowResBars();
    }
    if(event.GetSummary("ge")->GetList().size() != 0) {
        geEvts = ((GeProcessor*)DetectorDriver::get()->
            GetProcessor("GeProcessor"))->GetGeEvents();
        geAddback = ((GeProcessor*)DetectorDriver::get()->
            GetProcessor("GeProcessor"))->GetAddbackEvents();
    }
    static const vector<ChanEvent*> &labr3Evts =
	event.GetSummary("labr3:mrbig")->GetList();

#ifdef useroot
    vsize_->Fill(vbars.size());
#endif

    //Obtain some useful logic statuses
    double lastProtonTime =
	TreeCorrelator::get()->place("logic_t1_0")->last().time;
    bool isTapeMoving = TreeCorrelator::get()->place("TapeMove")->status();

    int bananaNum = 2;
    bool hasMultOne = vbars.size() == 1;
    bool hasMultTwo = vbars.size() == 2;
    //bool isFirst = true;

    plot(DD_DEBUGGING3, vbars.size());

    //Begin processing for VANDLE bars
    for (BarMap::iterator it = vbars.begin(); it !=  vbars.end(); it++) {
        TimingDefs::TimingIdentifier barId = (*it).first;
        BarDetector bar = (*it).second;

        if(!bar.GetHasEvent() || bar.GetType() == "small")
            continue;

        unsigned int barLoc = barId.first;
        TimingCalibration cal = bar.GetCalibration();

        for(BarMap::iterator itStart = betas.begin();
	    itStart != betas.end(); itStart++) {
	    unsigned int startLoc = (*itStart).first.first;
            BarDetector start = (*itStart).second;
            if(!start.GetHasEvent())
                continue;

            double tofOffset = cal.GetTofOffset(startLoc);
            double tof = bar.GetCorTimeAve() -
                start.GetCorTimeAve() + tofOffset;

            double corTof =
                ((VandleProcessor*)DetectorDriver::get()->
		 GetProcessor("VandleProcessor"))->
		CorrectTOF(tof, bar.GetFlightPath(), cal.GetZ0());

	    bool inPeel = histo.BananaTest(bananaNum,
            corTof*plotMult_+plotOffset_,
            bar.GetQdc());
	    bool isLowStart = start.GetQdc() < 300;

	    *outstream << tof << " " << bar.GetQdc() << endl;
#ifdef useroot
        qdctof_->Fill(tof,bar.GetQdc());
        qdc_ = bar.GetQdc();
        tof_ = tof;
        roottree_->Fill();
        qdc_ = tof_ = -9999;
#endif

	    plot(DD_DEBUGGING1, tof*plotMult_+plotOffset_, bar.GetQdc());
	    if(!isTapeMoving && !isLowStart)
		plot(DD_DEBUGGING0, corTof*plotMult_+plotOffset_,bar.GetQdc());
	    if(hasMultOne)
		plot(DD_DEBUGGING4, corTof*plotMult_+plotOffset_, bar.GetQdc());

	    ///Starting to look for 2n coincidences in VANDLE
	    BarMap::iterator itTemp = it;
	    itTemp++;

	    for (BarMap::iterator it2 = itTemp; it2 !=  vbars.end(); it2++) {
		TimingDefs::TimingIdentifier barId2 = (*it2).first;
		BarDetector bar2 = (*it2).second;

		if(!bar.GetHasEvent())
		    continue;

		unsigned int barLoc2 = barId2.first;

		bool isAdjacent = abs((int)barLoc2 - (int)barLoc) < 1;

		TimingCalibration cal2 = bar2.GetCalibration();

		double tofOffset2 = cal2.GetTofOffset(startLoc);
		double tof2 = bar2.GetCorTimeAve() -
		    start.GetCorTimeAve() + tofOffset2;

		double corTof2 =
		    ((VandleProcessor*)DetectorDriver::get()->
		     GetProcessor("VandleProcessor"))->
		    CorrectTOF(tof2, bar2.GetFlightPath(), cal2.GetZ0());

		bool inPeel2 = histo.BananaTest(bananaNum,
						corTof2*plotMult_+plotOffset_,
						bar2.GetQdc());

		if(hasMultTwo && inPeel && inPeel2 && !isAdjacent) {
		    plot(DD_DEBUGGING5, corTof*plotMult_+plotOffset_,
			 corTof2*plotMult_+plotOffset_);
		    plot(DD_DEBUGGING5, corTof2*plotMult_+plotOffset_,
			 corTof*plotMult_+plotOffset_);
		}
	    }
	    ///End 2n coincidence routine

	    // if (geSummary_ && notPrompt && hasMultOne) {
            //     if (geSummary_->GetMult() > 0) {
            //         const vector<ChanEvent *> &geList = geSummary_->GetList();
            //         for (vector<ChanEvent *>::const_iterator itGe = geList.begin();
            //             itGe != geList.end(); itGe++) {
            //             double calEnergy = (*itGe)->GetCalEnergy();
	    // 		plot(DD_DEBUGGING2, calEnergy, corTof*plotMult_+plotOffset_);
            //         }
            //     } else {
	    // 	  //plot(DD_TQDCAVEVSTOF_VETO+histTypeOffset, tof, bar.GetQdc());
	    // 	  //plot(DD_TOFBARS_VETO+histTypeOffset, tof, barPlusStartLoc);
            //     }
            //}
        } // for(TimingMap::iterator itStart
    } //(BarMap::iterator itBar
    //End processing for VANDLE bars

    //-------------- LaBr3 Processing ---------------
    for(vector<ChanEvent*>::const_iterator it = labr3Evts.begin();
	it != labr3Evts.end(); it++)
	plot(DD_DEBUGGING6, (*it)->GetEnergy());


    //------------------ Double Beta Processing --------------
    for(map<unsigned int, pair<double,double> >::iterator it = lrtBetas.begin();
	it != lrtBetas.end(); it++)
	plot(DD_PROTONBETA2TDIFF_VS_BETA2EN, it->second.second,
	     (it->second.first - lastProtonTime) /
	     (10e-3/Globals::get()->clockInSeconds()) );


    //----------------- GE Processing -------------------
    bool hasBeta = TreeCorrelator::get()->place("Beta")->status();
    double clockInSeconds = Globals::get()->clockInSeconds();
    // plot with 10 ms bins
    const double plotResolution = 10e-3 / clockInSeconds;

    for (vector<ChanEvent*>::iterator it1 = geEvts.begin();
	 it1 != geEvts.end(); ++it1) {
        ChanEvent *chan = *it1;

        double gEnergy = chan->GetCalEnergy();
        double gTime   = chan->GetCorrectedTime();
        if (gEnergy < 10.) //hard coded fix later.
            continue;

        plot(D_ENERGY, gEnergy);
	if(hasBeta)
	    plot(D_ENERGYBETA, gEnergy);
	plot(DD_PROTONGAMMATDIFF_VS_GAMMAEN, gEnergy ,
	     (gTime - lastProtonTime) / plotResolution) ;
    }

    EndProcess();
    return(true);
}
コード例 #19
0
ファイル: DetectorDriver.cpp プロジェクト: spaulaus/paass
int DetectorDriver::ThreshAndCal(ChanEvent *chan, RawEvent &rawev) {
    ChannelConfiguration chanCfg = chan->GetChanID();
    int id = chan->GetID();
    string type = chanCfg.GetType();
    string subtype = chanCfg.GetSubtype();
    set<string> tags = chanCfg.GetTags();
    bool hasStartTag = chanCfg.HasTag("start");
    Trace &trace = chan->GetTrace();

    RandomInterface *randoms = RandomInterface::get();

    double energy = 0.0;

    if (type == "ignore" || type == "")
        return (0);

    if (!trace.empty()) {
        histo_.Plot(D_HAS_TRACE, id);

        for (vector<TraceAnalyzer *>::iterator it = vecAnalyzer.begin(); it != vecAnalyzer.end(); it++)
            (*it)->Analyze(trace, chanCfg);

        //We are going to handle the filtered energies here.
        vector<double> filteredEnergies = trace.GetFilteredEnergies();
        if (filteredEnergies.empty()) {
            energy = chan->GetEnergy() + randoms->Generate();
        } else {
            energy = filteredEnergies.front();
            histo_.Plot(D_FILTER_ENERGY + id, energy);
        }

        //Saves the time in nanoseconds
        chan->SetHighResTime((trace.GetPhase() * Globals::get()->GetAdcClockInSeconds() +
                chan->GetFilterTime() * Globals::get()->GetFilterClockInSeconds()) * 1e9);
    } else {
        /// otherwise, use the Pixie on-board calculated energy and high res
        /// time is zero.
        energy = chan->GetEnergy() + randoms->Generate();
        chan->SetHighResTime(0.0);
    }

    /** Calibrate energy and apply the walk correction. */
    double time, walk_correction;
    if (chan->GetHighResTimeInNs() == 0.0) {
        time = chan->GetTime(); //time is in clock ticks
        walk_correction = walk_->GetCorrection(chanCfg, energy);
    } else {
        time = chan->GetHighResTimeInNs(); //time here is in ns
        walk_correction = walk_->GetCorrection(chanCfg, trace.GetQdc());
    }

    chan->SetCalibratedEnergy(cali_->GetCalEnergy(chanCfg, energy));
    chan->SetWalkCorrectedTime(time - walk_correction);

    rawev.GetSummary(type)->AddEvent(chan);
    DetectorSummary *summary;

    summary = rawev.GetSummary(type + ':' + subtype, false);
    if (summary != NULL)
        summary->AddEvent(chan);

    if (hasStartTag && type != "logic") {
        summary = rawev.GetSummary(type + ':' + subtype + ':' + "start", false);
        if (summary != NULL)
            summary->AddEvent(chan);
    }
    return (1);
}
コード例 #20
0
ファイル: PixieStd.cpp プロジェクト: kmiernik/pixie_scan
/** \brief event by event analysis
 *
 * ScanList() operates on the time sorted list of all channels that triggered in
 * a given spill.  Starting from the begining of the list and continuing to the
 * end, an individual channel event time is compared with the previous channel
 * event time to determine if they occur within a time period defined by the
 * diff_t variable (time is in units of 10 ns).  Depending on the answer,
 * different actions are performed:
 *   - yes - the two channels are grouped together as belonging to the same event
 *   and the current channel is added to the list of channels for the rawevent
 *   - no - the previous rawevent is sent for processing and once finished, the
 *   rawevent is zeroed and the current channel placed inside it.
 * \param [in] eventList : The event list to scan
 * \param [in] rawev : the raw event to read */
void ScanList(vector<ChanEvent*> &eventList, RawEvent& rawev) {
    unsigned long chanTime, eventTime;

    DetectorLibrary* modChan = DetectorLibrary::get();
    DetectorDriver* driver = DetectorDriver::get();
    Messenger messenger;
    stringstream ss;
    /** Rejection regions */
    vector< pair<int, int> > rejectRegions = Globals::get()->rejectRegions();

    // local variable for the detectors used in a given event
    set<string> usedDetectors;

    vector<ChanEvent*>::iterator iEvent = eventList.begin();

    // local variables for the times of the current event, previous
    // event and time difference between the two
    double diffTime = 0;

    //set last_t to the time of the first event
    double lastTime = (*iEvent)->GetTime();
    double currTime = lastTime;
    unsigned int id = (*iEvent)->GetID();

    /* KM
     * Save time of the beginning of the file,
     * this is needed for the rejection regions */
    static double firstTime = lastTime;
    HistoStats(id, diffTime, lastTime, BUFFER_START);

    //loop over the list of channels that fired in this buffer
    for(; iEvent != eventList.end(); iEvent++) {
        id = (*iEvent)->GetID();
        if (id == pixie::U_DELIMITER) {
            ss << "pattern 0 ignore";
            messenger.warning(ss.str());
            ss.str("");
            continue;
        }
        if ((*modChan)[id].GetType() == "ignore") {
            continue;
        }

        // this is a channel we're interested in
        chanTime  = (*iEvent)->GetTrigTime();
        eventTime = (*iEvent)->GetEventTimeLo();

        /* retrieve the current event time and determine the time difference
        between the current and previous events.
        */
        currTime = (*iEvent)->GetTime();
        diffTime = currTime - lastTime;

        /* KM: rejection of bad regions
         * If time (in sec) is within the 'bad' region
         * just drop the rest of this for loop and go for another buffer
         *
         * Do checks only if hasReject flag is True.
         */
        if (Globals::get()->hasReject()) {
            double bufferTime = (currTime - firstTime) *
                                 Globals::get()->clockInSeconds();
            bool rejectBuffer = false;
            for (vector< pair<int, int> >::iterator region = rejectRegions.begin();
                 region != rejectRegions.end();
                 ++region ) {
                /** If event time is within a rejection region
                 * set rejectBuffer flag true and stop checking */
                if (bufferTime > region->first &&
                    bufferTime < region->second) {
                    rejectBuffer = true;
                    break;
                }
            }
            if (rejectBuffer)
                continue;
        }
        /* end KM */

        /* if the time difference between the current and previous event is
        larger than the event width, finalize the current event, otherwise
        treat this as part of the current event
        */
        if ( diffTime > Globals::get()->eventWidth() ) {
            if(rawev.Size() > 0) {
            /* detector driver accesses rawevent externally in order to
            have access to proper detector_summaries
            */
                driver->ProcessEvent(rawev);
            }

            //after processing zero the rawevent variable
            rawev.Zero(usedDetectors);
            usedDetectors.clear();

            // Now clear all places in correlator (if resetable type)
            for (map<string, Place*>::iterator it =
                    TreeCorrelator::get()->places_.begin();
                it != TreeCorrelator::get()->places_.end(); ++it)
                if ((*it).second->resetable())
                    (*it).second->reset();
            HistoStats(id, diffTime, currTime, EVENT_START);
        } else HistoStats(id, diffTime, currTime, EVENT_CONTINUE);

        unsigned long dtimebin = 2000 + eventTime - chanTime;
        if (dtimebin < 0 || dtimebin > (unsigned)(SE)) {
            ss << "strange dtime for id " << id << ":" << dtimebin;
            messenger.warning(ss.str());
            ss.str("");
        }
        driver->plot(D_TIME + id, dtimebin);
        usedDetectors.insert((*modChan)[id].GetType());
        rawev.AddChan(*iEvent);

        // update the time of the last event
        lastTime = currTime;
    } //end loop over event list

    //process the last event in the buffer
    if (rawev.Size() > 0) {
        string mode;
        HistoStats(id, diffTime, currTime, BUFFER_END);

        driver->ProcessEvent(rawev);
        rawev.Zero(usedDetectors);
    }
}
コード例 #21
0
bool DssdProcessor::Process(RawEvent &event)
{
    using namespace dammIds::dssd;

    if (!EventProcessor::Process(event))
	return false;
    // first time through, grab the according detector summaries
    if (frontSummary == NULL)
	frontSummary = event.GetSummary("dssd_front");
    if (backSummary == NULL)
	backSummary = event.GetSummary("dssd_back");
    static Correlator &corr = event.GetCorrelator();

    int frontPos = INT_MAX, backPos = INT_MAX;
    double frontEnergy, backEnergy, frontTime = 0.;

    bool hasFront = (frontSummary->GetMult() > 0);
    bool hasBack  = (backSummary->GetMult() > 0);
    bool hasMcp   = (event.GetSummary("mcp")->GetMult() > 0);

    if (hasFront) {
	const ChanEvent *ch = frontSummary->GetMaxEvent();

	frontPos    = ch->GetChanID().GetLocation();
	frontEnergy = ch->GetCalEnergy();
	frontTime   = ch->GetTime();
    } else frontEnergy = 0.;
    if (hasBack) {
	const ChanEvent *ch = backSummary->GetMaxEvent();

	backPos    = ch->GetChanID().GetLocation();
	backEnergy = ch->GetCalEnergy();
    } else backEnergy = 0.;

    // decide whether this is an implant or a decay
    EventInfo corEvent;
    corEvent.time = frontTime;

    if (hasFront && hasBack) {
	if (frontEnergy > cutoffEnergy && backEnergy > cutoffEnergy && hasMcp) {
	    corEvent.type = EventInfo::IMPLANT_EVENT;
	} else if (frontEnergy <= cutoffEnergy && backEnergy <= cutoffEnergy &&
		   !hasMcp) {
	    corEvent.type = EventInfo::DECAY_EVENT;
	} else {
	    corEvent.type = EventInfo::UNKNOWN_EVENT;
	}
	corr.Correlate(corEvent, frontPos, backPos); 
    } else if (hasFront) {
  	if (frontEnergy > cutoffEnergy) {
	    corEvent.type = EventInfo::IMPLANT_EVENT;
	} else corEvent.type = EventInfo::DECAY_EVENT;
	   
    } else if (hasBack) {
	if (backEnergy > cutoffEnergy) {
	    corEvent.type = EventInfo::IMPLANT_EVENT;
	} else corEvent.type = EventInfo::DECAY_EVENT;
    } else corEvent.type = EventInfo::UNKNOWN_EVENT;

    // plot stuff
    if (corEvent.type == EventInfo::IMPLANT_EVENT) {
	if (hasFront)
	    plot(DD_IMPLANT_FRONT_ENERGY__POSITION, frontEnergy, frontPos);
	if (hasBack)
	    plot(DD_IMPLANT_BACK_ENERGY__POSITION, backEnergy, backPos);
	if (hasFront && hasBack)
	    plot(DD_IMPLANT_POSITION, backPos, frontPos);
    } else if (corEvent.type == EventInfo::DECAY_EVENT) {
	if (hasFront)
	    plot(DD_DECAY_FRONT_ENERGY__POSITION, frontEnergy, frontPos);
	if (hasBack)
	    plot(DD_DECAY_BACK_ENERGY__POSITION, backEnergy, backPos);
	if (hasFront && hasBack)
	    plot(DD_DECAY_POSITION, backPos, frontPos);
	if (corr.GetCondition() == Correlator::VALID_DECAY) {
	    const unsigned int NumGranularities = 8;
	    // time resolution in seconds per bin
	    const double timeResolution[NumGranularities] = 
		{10e-9, 100e-9, 400e-9, 1e-6, 100e-6, 1e-3, 10e-3, 100e-3};
	 
	    for (unsigned int i = 0; i < NumGranularities; i++) {
		int timeBin = int(corr.GetDecayTime() * pixie::clockInSeconds / 
				  timeResolution[i]);

		plot(DD_ENERGY__DECAY_TIME_GRANX + i, frontEnergy, timeBin);
	    }
	}
    }

    EndProcess(); // update the processing time
    return true;
}
コード例 #22
0
/**
 *  Process the QDC data involved in top/bottom side for a strip 
 *  Note QDC lengths are HARD-CODED at the moment for the plots and to determine the position
 */
bool PositionProcessor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return false;

    static const vector<ChanEvent*> &sumEvents = 
	event.GetSummary("ssd:sum", true)->GetList();
    static const vector<ChanEvent*> &digisumEvents =
	event.GetSummary("ssd:digisum", true)->GetList();
    static const vector<ChanEvent*> &topEvents =
	event.GetSummary("ssd:top", true)->GetList();
    static const vector<ChanEvent*> &bottomEvents =
	event.GetSummary("ssd:bottom", true)->GetList();

    vector<ChanEvent *> allEvents;
    // just add in the digisum events for now
    allEvents.insert(allEvents.begin(), digisumEvents.begin(), digisumEvents.end());
    allEvents.insert(allEvents.begin(), sumEvents.begin(), sumEvents.end());

    for (vector<ChanEvent*>::const_iterator it = allEvents.begin();
	     it != allEvents.end(); ++it) {
         ChanEvent *sumchan   = *it;

        int location = sumchan->GetChanID().GetLocation();

        // Don't waste our time with noise events
        if ( (*it)->GetEnergy() < 10. || (*it)->GetEnergy() > 16374 ) {
            using namespace dammIds::position;

            plot(D_INFO_LOCX + location, INFO_NOISE);
            plot(D_INFO_LOCX + LOC_SUM , INFO_NOISE);
            continue;
        }

        const ChanEvent *top    = FindMatchingEdge(sumchan, topEvents.begin(), topEvents.end());
        const ChanEvent *bottom = FindMatchingEdge(sumchan, bottomEvents.begin(), bottomEvents.end());


        if (top == NULL || bottom == NULL) {
            using namespace dammIds::position;

            if (top == NULL) {
                // [6] -> Missing top
                plot(D_INFO_LOCX + location, INFO_MISSING_TOP);
                plot(D_INFO_LOCX + LOC_SUM, INFO_MISSING_TOP);
            }

            if (bottom == NULL) {
                // [5] -> Missing bottom
                plot(D_INFO_LOCX + location, INFO_MISSING_BOTTOM);
                plot(D_INFO_LOCX + LOC_SUM, INFO_MISSING_BOTTOM);
            }
            continue;
        }

        /* Make sure we get the same match going backwards to insure there is only one in the vector */
        if ( FindMatchingEdge(sumchan, topEvents.rbegin(), topEvents.rend()) != top) {
            using namespace dammIds::position;
            // [4] -> Multiple top
            plot(D_INFO_LOCX + location, INFO_MULTIPLE_TOP);
            plot(D_INFO_LOCX + LOC_SUM, INFO_MULTIPLE_TOP);
            continue;
        }
        if ( FindMatchingEdge(sumchan, bottomEvents.rbegin(), bottomEvents.rend()) != bottom) {
            using namespace dammIds::position;
            // [3] -> Multiple bottom
            plot(D_INFO_LOCX + location, INFO_MULTIPLE_BOTTOM);
            plot(D_INFO_LOCX + LOC_SUM, INFO_MULTIPLE_BOTTOM);
            continue;
        }

        using namespace dammIds::position;
        
        float topQdc[numQdcs];
        float bottomQdc[numQdcs];
        float topQdcTot = 0;
        float bottomQdcTot = 0;
        float position = NAN;
        
        topQdc[0] = top->GetQdcValue(0);
        bottomQdc[0] = bottom->GetQdcValue(0);
        if (bottomQdc[0] == U_DELIMITER || topQdc[0] == U_DELIMITER) {
            // This happens naturally for traces which have double triggers
            //   Onboard DSP does not write QDCs in this case
#ifdef VERBOSE
            cout << "SSD strip edges are missing QDC information for location " << location << endl;
#endif
            if (topQdc[0] == U_DELIMITER) {
                // [2] -> Missing top QDC
                plot(D_INFO_LOCX + location, INFO_MISSING_TOP_QDC);
                plot(D_INFO_LOCX + LOC_SUM, INFO_MISSING_TOP_QDC);
                // Recreate qdc from trace
                if ( !top->GetTrace().empty() ) {
                    topQdc[0] = accumulate(top->GetTrace().begin(), top->GetTrace().begin() + qdcLen[0], 0);
                } else {
                    topQdc[0] = 0;
                }
            }
            if (bottomQdc[0] == U_DELIMITER) {
                // [1] -> Missing bottom QDC
                plot(D_INFO_LOCX + location, INFO_MISSING_BOTTOM_QDC);
                plot(D_INFO_LOCX + LOC_SUM, INFO_MISSING_BOTTOM_QDC);
                // Recreate qdc from trace
                if ( !bottom->GetTrace().empty() ) {
                    bottomQdc[0] = accumulate(bottom->GetTrace().begin(), bottom->GetTrace().begin() + qdcLen[0], 0);
                } else {
                    bottomQdc[0] = 0;
                }
            }
            if ( topQdc[0] == 0 || bottomQdc[0] == 0 ) {
                continue;
            }
        }
        // [0] -> good stuff
        plot(D_INFO_LOCX + location, INFO_OKAY);
        plot(D_INFO_LOCX + LOC_SUM, INFO_OKAY);


        for (int i = 1; i < numQdcs; ++i) {		
            if (top->GetQdcValue(i) == U_DELIMITER) {
                // Recreate qdc from trace
                topQdc[i] = accumulate(top->GetTrace().begin() + qdcPos[i-1],
                top->GetTrace().begin() + qdcPos[i], 0);
            } else {
                topQdc[i] = top->GetQdcValue(i);
            }

            topQdc[i] -= topQdc[0] * qdcLen[i] / qdcLen[0];
            topQdcTot += topQdc[i];
            topQdc[i] /= qdcLen[i];		
            
            if (bottom->GetQdcValue(i) == U_DELIMITER) {
                // Recreate qdc from trace
                bottomQdc[i] = accumulate(bottom->GetTrace().begin() + qdcPos[i-1],
                                          bottom->GetTrace().begin() + qdcPos[i], 0);
            } else {
                bottomQdc[i] = bottom->GetQdcValue(i);
            }

            bottomQdc[i] -= bottomQdc[0] * qdcLen[i] / qdcLen[0];
            bottomQdcTot += bottomQdc[i];
            bottomQdc[i] /= qdcLen[i];
            
            plot(DD_QDCN__QDCN_LOCX + QDC_JUMP * i + location, topQdc[i] + 10, bottomQdc[i] + 10);
            plot(DD_QDCN__QDCN_LOCX + QDC_JUMP * i + LOC_SUM, topQdc[i], bottomQdc[i]);
            
            float frac = topQdc[i] / (topQdc[i] + bottomQdc[i]) * 1000.; // per mil
            
            plot(D_QDCNORMN_LOCX + QDC_JUMP * i + location, frac);
            plot(D_QDCNORMN_LOCX + QDC_JUMP * i + LOC_SUM, frac);
            if (i == whichQdc) {
                position = posScale * (frac - minNormQdc[location]) / 
                    (maxNormQdc[location] - minNormQdc[location]);		
                sumchan->GetTrace().InsertValue("position", position);
                plot(DD_POSITION__ENERGY_LOCX + location, position, sumchan->GetCalEnergy());
                plot(DD_POSITION__ENERGY_LOCX + LOC_SUM, position, sumchan->GetCalEnergy());
            }
            if (i == 6 && !sumchan->IsSaturated()) {
                // compare the long qdc to the energy
                int qdcSum = topQdc[i] + bottomQdc[i];
                
                // MAGIC NUMBERS HERE, move to qdc.txt
                if (qdcSum < 1000 && sumchan->GetCalEnergy() > 15000) {
                    sumchan->GetTrace().InsertValue("badqdc", 1);
                } else if ( !isnan(position) ) {
                    plot(DD_POSITION, location, position);
                }
            }
        } // end loop over qdcs
        // KM QDC - QDC correlations
        double ratio[4] = {0};
        for (int i = 1; i < 5; ++i) {
                ratio[i - 1] = topQdc[i] / (bottomQdc[i] + topQdc[i]) * 1000.0;
        }

        plot(DD_QDCR2__QDCR1_LOCX + location, ratio[1], ratio[0]);
        plot(DD_QDCR2__QDCR3_LOCX + location, ratio[1], ratio[2]);
        plot(DD_QDCR2__QDCR4_LOCX + location, ratio[1], ratio[3]);

        plot(DD_QDC1R__POS_LOCX + location, ratio[0], position * 10.0 + 200.0);
        plot(DD_QDC2R__POS_LOCX + location, ratio[1], position * 10.0 + 200.0);
        plot(DD_QDC3R__POS_LOCX + location, ratio[2], position * 10.0 + 200.0);
        plot(DD_QDC4R__POS_LOCX + location, ratio[3], position * 10.0 + 200.0);

        topQdcTot    /= totLen;
        bottomQdcTot /= totLen;
        
        plot(DD_QDCTOT__QDCTOT_LOCX + location, topQdcTot, bottomQdcTot);
        plot(DD_QDCTOT__QDCTOT_LOCX + LOC_SUM, topQdcTot, bottomQdcTot);
    } // end iteration over sum events

   // test

    EndProcess();

    return true;
}
コード例 #23
0
ファイル: PixieStd.cpp プロジェクト: mohmd7shudif/pixie_scan
void ScanList(vector<ChanEvent*> &eventList, RawEvent& rawev) 
{
    unsigned long chanTime, eventTime;

    DetectorLibrary* modChan = DetectorLibrary::get();
    DetectorDriver* driver = DetectorDriver::get();

    // local variable for the detectors used in a given event
    set<string> usedDetectors;
    
    vector<ChanEvent*>::iterator iEvent = eventList.begin();

    // local variables for the times of the current event, previous
    // event and time difference between the two
    double diffTime = 0;
    
    //set last_t to the time of the first event
    double lastTime = (*iEvent)->GetTime();
    double currTime = lastTime;
    unsigned int id = (*iEvent)->GetID();

    HistoStats(id, diffTime, lastTime, BUFFER_START);

    //loop over the list of channels that fired in this buffer
    for(; iEvent != eventList.end(); iEvent++) { 
        id = (*iEvent)->GetID();
        if (id == U_DELIMITER) {
            cout << "pattern 0 ignore" << endl;
            continue;
        }
        if ((*modChan)[id].GetType() == "ignore") {
            continue;
        }

        // this is a channel we're interested in
        chanTime  = (*iEvent)->GetTrigTime(); 
        eventTime = (*iEvent)->GetEventTimeLo();

        /* retrieve the current event time and determine the time difference 
        between the current and previous events. 
        */
        currTime = (*iEvent)->GetTime();
        diffTime = currTime - lastTime;

        /* if the time difference between the current and previous event is 
        larger than the event width, finalize the current event, otherwise
        treat this as part of the current event
        */
        if ( diffTime > pixie::eventWidth ) {
            if(rawev.Size() > 0) {
            /* detector driver accesses rawevent externally in order to
            have access to proper detector_summaries
            */
                driver->ProcessEvent(scanMode, rawev);
            }
    
            //after processing zero the rawevent variable
            rawev.Zero(usedDetectors);
            usedDetectors.clear();	    

            // Now clear all places in correlator (if resetable type)
            for (map<string, Place*>::iterator it =
                    TreeCorrelator::get()->places_.begin();
                it != TreeCorrelator::get()->places_.end(); ++it)
                if ((*it).second->resetable())
                    (*it).second->reset();

            HistoStats(id, diffTime, currTime, EVENT_START);
        } else HistoStats(id, diffTime, currTime, EVENT_CONTINUE);

        unsigned long dtimebin = 2000 + eventTime - chanTime;
        if (dtimebin < 0 || dtimebin > (unsigned)(SE)) {
            cout << "strange dtime for id " << id << ":" << dtimebin << endl;
        }
        driver->plot(D_TIME + id, dtimebin);

        usedDetectors.insert((*modChan)[id].GetType());
        rawev.AddChan(*iEvent);

        // update the time of the last event
        lastTime = currTime; 
    } //end loop over event list

    //process the last event in the buffer
    if (rawev.Size() > 0) {
        string mode;
        HistoStats(id, diffTime, currTime, BUFFER_END);

        driver->ProcessEvent(scanMode, rawev);
        rawev.Zero(usedDetectors);
    }
}
コード例 #24
0
ファイル: DetectorDriver.cpp プロジェクト: akeeler/pixie_scan
int DetectorDriver::ThreshAndCal(ChanEvent *chan, RawEvent& rawev) {
    Identifier chanId = chan->GetChanID();
    int id            = chan->GetID();
    string type       = chanId.GetType();
    string subtype    = chanId.GetSubtype();
    map<string, int> tags = chanId.GetTagMap();
    bool hasStartTag  = chanId.HasTag("start");
    Trace &trace      = chan->GetTrace();

    RandomPool* randoms = RandomPool::get();

    double energy = 0.0;

    if (type == "ignore" || type == "")
        return(0);

    if ( !trace.empty() ) {
        plot(D_HAS_TRACE, id);

        for (vector<TraceAnalyzer *>::iterator it = vecAnalyzer.begin();
            it != vecAnalyzer.end(); it++) {
            (*it)->Analyze(trace, type, subtype, tags);
        }

        if (trace.HasValue("filterEnergy") ) {
            if (trace.GetValue("filterEnergy") > 0) {
                energy = trace.GetValue("filterEnergy");
                plot(D_FILTER_ENERGY + id, energy);
                trace.SetValue("filterEnergyCal",
                    cali.GetCalEnergy(chanId, trace.GetValue("filterEnergy")));
            } else {
                energy = 0.0;
            }

            /** Calibrate pulses numbered 2 and forth,
             * add filterEnergyXCal to the trace */
            int pulses = trace.GetValue("numPulses");
            for (int i = 1; i < pulses; ++i) {
                stringstream energyName;
                energyName << "filterEnergy" << i + 1;
                stringstream energyCalName;
                energyCalName << "filterEnergy" << i + 1 << "Cal";
                trace.SetValue(energyCalName.str(),
                    cali.GetCalEnergy(chanId,
                                      trace.GetValue(energyName.str())));
            }
        }

        if (trace.HasValue("calcEnergy") ) {
            energy = trace.GetValue("calcEnergy");
            chan->SetEnergy(energy);
        } else if (!trace.HasValue("filterEnergy")) {
            energy = chan->GetEnergy() + randoms->Get();
        }

        if (trace.HasValue("phase") ) {
	    //Saves the time in ns
            chan->SetHighResTime((trace.GetValue("phase") *
				 Globals::get()->adcClockInSeconds() +
				 chan->GetTrigTime() *
				  Globals::get()->filterClockInSeconds())*1.e9);
        }
    } else {
        /// otherwise, use the Pixie on-board calculated energy
        /// add a random number to convert an integer value to a
        ///   uniformly distributed floating point
        energy = chan->GetEnergy() + randoms->Get();
	chan->SetHighResTime(0.0);
    }

    /** Calibrate energy and apply the walk correction. */
    double time, walk_correction;
    if(chan->GetHighResTime() == 0.0) {
	time = chan->GetTime(); //time is in clock ticks
	walk_correction = walk.GetCorrection(chanId, energy);
    } else {
	time = chan->GetHighResTime(); //time here is in ns
	walk_correction = walk.GetCorrection(chanId, trace.GetValue("tqdc"));
    }

    chan->SetCalEnergy(cali.GetCalEnergy(chanId, energy));
    chan->SetCorrectedTime(time - walk_correction);

    rawev.GetSummary(type)->AddEvent(chan);
    DetectorSummary *summary;

    summary = rawev.GetSummary(type + ':' + subtype, false);
    if (summary != NULL)
        summary->AddEvent(chan);

    if(hasStartTag && type != "logic") {
        summary =
            rawev.GetSummary(type + ':' + subtype + ':' + "start", false);
        if (summary != NULL)
            summary->AddEvent(chan);
    }
    return(1);
}
コード例 #25
0
bool LiquidProcessor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return false;

    static const vector<ChanEvent*> &liquidEvents =
	event.GetSummary("scint:liquid")->GetList();
    static const vector<ChanEvent*> &betaStartEvents =
	event.GetSummary("scint:beta:start")->GetList();
    static const vector<ChanEvent*> &liquidStartEvents =
	event.GetSummary("scint:liquid:start")->GetList();

    vector<ChanEvent*> startEvents;
    startEvents.insert(startEvents.end(), betaStartEvents.begin(),
		       betaStartEvents.end());
    startEvents.insert(startEvents.end(), liquidStartEvents.begin(),
		       liquidStartEvents.end());

    static int counter = 0;
    for(vector<ChanEvent*>::const_iterator itLiquid = liquidEvents.begin();
	itLiquid != liquidEvents.end(); itLiquid++) {
        unsigned int loc = (*itLiquid)->GetChanID().GetLocation();
        HighResTimingData liquid((*itLiquid));

        if(liquid.discrimination == 0) {
            for(Trace::const_iterator i = liquid.trace.begin();
                i != liquid.trace.end(); i++)
                plot(DD_TRCLIQUID, int(i-liquid.trace.begin()),
                     counter, int(*i)-liquid.aveBaseline);
            counter++;
        }

        if(liquid.dataValid) {
            plot(DD_TQDCLIQUID, liquid.tqdc, loc);
            plot(DD_MAXLIQUID, liquid.maxval, loc);

            double discrimNorm =
                liquid.discrimination/liquid.tqdc;

            double discRes = 1000;
            double discOffset = 100;

            TimingCalibration calibration =
                TimingCalibrator::get()->GetCalibration(make_pair(loc, "liquid"));

            if(discrimNorm > 0)
                plot(DD_DISCRIM, discrimNorm*discRes+discOffset, loc);
            plot(DD_TQDCVSDISCRIM, discrimNorm*discRes+discOffset,
                 liquid.tqdc);

            if((*itLiquid)->GetChanID().HasTag("start"))
                continue;

            for(vector<ChanEvent*>::iterator itStart = startEvents.begin();
                itStart != startEvents.end(); itStart++) {
                unsigned int startLoc = (*itStart)->GetChanID().GetLocation();
                HighResTimingData start((*itStart));
                int histLoc = loc + startLoc;
                const int resMult = 2;
                const int resOffset = 2000;

                if(start.dataValid) {
                    double tofOffset;
                    if(startLoc == 0)
                        tofOffset = calibration.tofOffset0;
                    else
                        tofOffset = calibration.tofOffset1;

                    double TOF = liquid.highResTime -
                        start.highResTime - tofOffset; //in ns
                    double nEnergy = timeInfo.CalcEnergy(TOF, calibration.r0);

                    plot(DD_TOFLIQUID, TOF*resMult+resOffset, histLoc);
                    plot(DD_TOFVSDISCRIM+histLoc,
                         discrimNorm*discRes+discOffset, TOF*resMult+resOffset);
                    plot(DD_NEVSDISCRIM+histLoc, discrimNorm*discRes+discOffset, nEnergy);
                    plot(DD_TQDCVSLIQTOF+histLoc, TOF*resMult+resOffset,
                         liquid.tqdc);
                    plot(DD_TQDCVSENERGY+histLoc, nEnergy, liquid.tqdc);
                }
            } //Loop over starts
        } // Good Liquid Check
    }//end loop over liquid events
    EndProcess();
    return true;
}
コード例 #26
0
/**
 * WARNING!
 * This part was the LiquidAnalysis function in the old ScintProcessor.
 * It looks like written for some older version of code.
 * Before using, examine it carefully!
 */
bool LiquidScintProcessor::Process(RawEvent &event) {
    if (!EventProcessor::Process(event))
        return false;

    static const vector<ChanEvent *> &liquidEvents =
            event.GetSummary("liquid_scint:liquid")->GetList();
    static const vector<ChanEvent *> &betaStartEvents =
            event.GetSummary("liquid_scint:beta:start")->GetList();
    static const vector<ChanEvent *> &liquidStartEvents =
            event.GetSummary("liquid_scint:liquid:start")->GetList();

    vector<ChanEvent *> startEvents;
    startEvents.insert(startEvents.end(), betaStartEvents.begin(),
                       betaStartEvents.end());
    startEvents.insert(startEvents.end(), liquidStartEvents.begin(),
                       liquidStartEvents.end());

    for (vector<ChanEvent *>::const_iterator itLiquid = liquidEvents.begin();
         itLiquid != liquidEvents.end(); itLiquid++) {
        unsigned int loc = (*itLiquid)->GetChanID().GetLocation();
        HighResTimingData liquid(*(*itLiquid));

        if (liquid.GetDiscrimination() == 0) {
            for (Trace::const_iterator i = liquid.GetTrace().begin();
                 i != liquid.GetTrace().end(); i++)
                histo.Plot(DD_TRCLIQUID, int(i - liquid.GetTrace().begin()),
                     counter, int(*i) - liquid.GetAveBaseline());
            counter++;
        }

        if (liquid.GetIsValid()) {
            histo.Plot(DD_TQDCLIQUID, liquid.GetTraceQdc(), loc);
            histo.Plot(DD_MAXLIQUID, liquid.GetMaximumValue(), loc);

            double discrimNorm =
                    liquid.GetDiscrimination() / liquid.GetTraceQdc();

            double discRes = 1000;
            double discOffset = 100;

            TimingCalibration cal =
                    TimingCalibrator::get()->GetCalibration(
                            make_pair(loc, "liquid"));

            if (discrimNorm > 0)
                histo.Plot(DD_DISCRIM, discrimNorm * discRes + discOffset, loc);
            histo.Plot(DD_TQDCVSDISCRIM, discrimNorm * discRes + discOffset,
                 liquid.GetTraceQdc());

            if ((*itLiquid)->GetChanID().HasTag("start"))
                continue;

            for (vector<ChanEvent *>::iterator itStart = startEvents.begin();
                 itStart != startEvents.end(); itStart++) {
                unsigned int startLoc = (*itStart)->GetChanID().GetLocation();
                HighResTimingData start(*(*itStart));
                int histLoc = loc + startLoc;
                const int resMult = 2;
                const int resOffset = 2000;

                if (start.GetIsValid()) {
                    double tofOffset = cal.GetTofOffset(startLoc);
                    double TOF = liquid.GetHighResTimeInNs() -
                                 start.GetHighResTimeInNs() - tofOffset;

                    histo.Plot(DD_TOFLIQUID, TOF * resMult + resOffset, histLoc);
                    histo.Plot(DD_TOFVSDISCRIM + histLoc,
                         discrimNorm * discRes + discOffset,
                         TOF * resMult + resOffset);
                    histo.Plot(DD_TQDCVSLIQTOF + histLoc, TOF * resMult + resOffset,
                         liquid.GetTraceQdc());
                }
            }
        }
    }
    EndProcess();
    return true;
}
コード例 #27
0
void PhaseMatrixDevice::addListPoint(unsigned long point, unsigned long dwell_us, const RawEvent& listEvent)
{
	std::stringstream command;

	const unsigned long minimumDwell = 5;	//5 us
	const unsigned long maximumDwell = (4294000000);	//4294 s

	//default value
	double frequencyMHz = currentFreqHz / 1000000;	//should never need this (should be invalid syntax)
	double power = currentPower;		//used when power is not specified

	//Check syntax and parameter ranges
	if(point > 32767) {
		throw EventParsingException(listEvent,
		"Phase Matrix list memory overflow. Only 32,767 points are allowed in the list.");
	}
	if(dwell_us < minimumDwell) {
		throw EventParsingException(listEvent,
			"Invalid dwell time " + valueToString(dwell_us) 
			+ " us for list point #" + valueToString(point) 
			+ ". Minimum dwell time is 5 us.");
	}
	if(dwell_us > maximumDwell) {
		throw EventParsingException(listEvent,
			"Invalid dwell time " + valueToString(dwell_us / 1000000) 
			+ " s for list point #" + valueToString(point) 
			+ ". Maximum dwell time is 4294 s.");
	}

//	//Rounding dwell time to the nearest 5 us.
//	unsigned long dwell_us = 5 * static_cast<unsigned long>(dwell / 5000);

	//Determine the format type; check syntax
	bool isVector = (listEvent.value().getType() == MixedValue::Vector && listEvent.value().getVector().size() == 2);
	if(isVector) {
		//check vector entry format
		isVector &= (listEvent.value().getVector().at(0).getType() == MixedValue::Double 
			|| listEvent.value().getVector().at(0).getType() == MixedValue::Int) 
			&& (listEvent.value().getVector().at(1).getType() == MixedValue::Double 
			|| listEvent.value().getVector().at(1).getType() == MixedValue::Int);
	}
	bool isFrequency = (listEvent.value().getType() == MixedValue::Double 
		|| listEvent.value().getType() == MixedValue::Int);

	if( (!isVector && !isFrequency) || (isVector && isFrequency)) {
		//invalid format
		throw EventParsingException(listEvent,
			"Invalid list value format. Value must be either a frequency number or a vector of the form (frequency, power).");
	}

	//Extract point parameters
	if(isVector) {
		frequencyMHz = listEvent.value().getVector().at(0).getNumber();
		power = listEvent.value().getVector().at(1).getNumber();
		currentPower = power;	//Uses the last specified power value for the rest of the list.
	}
	if(isFrequency) {
		frequencyMHz = listEvent.value().getVector().at(0).getNumber();
	}

	//check parameter ranges
	if(frequencyMHz > 10000 || frequencyMHz < 100) {
		throw EventParsingException(listEvent,
			"Invalid frequency: " + valueToString(frequencyMHz) 
			+ " MHz. Allowed frequency range is 100 MHz - 10 GHz.");
	}

	unsigned long phaseMatrixDwell_us = static_cast<unsigned long>(phaseMatrixDwellTimeScale * dwell_us);

	command << "LIST:PVEC " 
		<< valueToString(point) << "," 
		<< valueToString(frequencyMHz) << "MHz" << "," 
		<< valueToString(power) << "dBm" << ","
		<< valueToString(phaseMatrixDwell_us) << "us" << ","
		<< "OFF,ON"
		<< "\n";
	
	serialController->queryDevice(command.str(), rs232QuerySleep_ms);
//	cout << command.str() << endl;
}
コード例 #28
0
/*
// argv[]={DisplayRawEvent, int RunNumber, int EventNumber}
int main(int argc, char* argv[]) {

   int RunNumber = (int)strtod(argv[1],0);
   int EventNumber = (int)strtod(argv[2],0);
   bool show_unflipped_plots = 0;
   
   cout<<"RunNumber = "<<RunNumber<<"\tEventNumber = "<<EventNumber<<endl;
   
   TApplication theApp("App", &argc, argv);
   //TApplication theApp2("App", &argc, argv);
*/
void DisplayRawEvent(int RunNumber, int EventNumber, bool show_unflipped_plots=0) {
   
   RawEvent rawevent = GetRawEvent(RunNumber, EventNumber, true);
   
   TCanvas *RawADCCanvas = new TCanvas("RawADCCanvas", "Telescope Reference Detectors and Diamond Detector Raw ADC Output",200, 400, 1200, 900);
   TCanvas *RawADCCanvasUnflipped = 0;
   RawADCCanvas->Divide(2,5);
   //RawADCCanvas->Connect("Closed()", "TApplication", &theApp, "Terminate()");
   
   //For Telescope Reference Detectors Plotting a Graph of ADC_value versus Strip_number
   
   TH1F *RawADCHisto[15];
   string detname[15];
   detname[0] = "D0X";
   detname[1] = "D0Y";
   detname[2] = "D1X";
   detname[3] = "D1Y";
   detname[4] = "D2X";
   detname[5] = "D2Y";
   detname[6] = "D3X";
   detname[7] = "D3Y";
   detname[8] = "Dia0";
   detname[9] = "Dia1";
   detname[10] = "D0";
   detname[11] = "D1";
   detname[12] = "D2";
   detname[13] = "D3";
   detname[14] = "Diamond";
   
   for(int det=0; det<10; det++) {
      RawADCCanvas->cd(det+1);
      if(det==8||det==9) {
         RawADCHisto[det] = new TH1F(detname[det].c_str(),detname[det].c_str(),128,-0.5,127.5);
         for(int i=0; i<128; i++) 
            RawADCHisto[det]->SetBinContent(i + 1, rawevent.GetDetector(det).GetADC(i));
      }
      else {
         RawADCHisto[det] = new TH1F(detname[det].c_str(),detname[det].c_str(),256,-0.5,255.5);
         for(int i=0; i<256; i++) 
            RawADCHisto[det]->SetBinContent(i + 1, rawevent.GetDetector(det).GetADC(i));
      }
      RawADCHisto[det]->Draw();
      RawADCHisto[det]->GetXaxis()->SetTitle("Channel");
      RawADCHisto[det]->GetXaxis()->CenterTitle();
      RawADCHisto[det]->GetYaxis()->SetTitle("Raw ADC Value");
      RawADCHisto[det]->GetYaxis()->CenterTitle();
      detname[det] += " Raw ADC";
      RawADCHisto[det]->SetTitle(detname[det].c_str());
      RawADCCanvas->cd(det+1);
   }
   RawADCCanvas->Update();
   //theApp.Run();
   
   if(show_unflipped_plots) {
      RawADCCanvasUnflipped = new TCanvas("RawADCCanvasUnflipped", "Not Flipped Telescope Reference Detectors and Diamond Detector Raw ADC Output",200, 400, 1200, 900);
      RawADCCanvasUnflipped->Divide(2,2);//1,4);
      //RawADCCanvasUnflipped->Connect("Closed()", "TApplication", &theApp, "Terminate()");
      for(int det=0; det<4; det++) {
         RawADCCanvasUnflipped->cd(det+1);
         RawADCHisto[det+10] = new TH1F(detname[det+10].c_str(),detname[det+10].c_str(),512,-0.5,511.5);
         for(int i=0; i<512; i++) 
            RawADCHisto[det+10]->SetBinContent(i+1, rawevent.GetUnflippedDetector(det)[i]);
         RawADCHisto[det+10]->Draw();
         RawADCHisto[det+10]->GetXaxis()->SetTitle("Channel");
         RawADCHisto[det+10]->GetXaxis()->CenterTitle();
         RawADCHisto[det+10]->GetYaxis()->SetTitle("Raw ADC Value");
         RawADCHisto[det+10]->GetYaxis()->CenterTitle();
         RawADCHisto[det+10]->SetMinimum(0);
         detname[det+10] += " Raw ADC (Not Flipped)";
         RawADCHisto[det+10]->SetTitle(detname[det+10].c_str());
      }
   RawADCCanvasUnflipped->Update();
   }
   //theApp.Run();

   //return 0;
}//End of Eventanalyze_final