diff --git a/include/MEventTypeClassifier.h b/include/MEventTypeClassifier.h new file mode 100644 index 00000000..f9bd605b --- /dev/null +++ b/include/MEventTypeClassifier.h @@ -0,0 +1,65 @@ +/* + * MEventTypeClassifier.h + * + * Copyright (C) by Andreas Zoglauer, WingYeung Ma. + * All rights reserved. + * + * Please see the source-file for the copyright-notice. + * + */ + + +#ifndef __MEventTypeClassifier__ +#define __MEventTypeClassifier__ + + +//////////////////////////////////////////////////////////////////////////////// + + +// Standard libs: +#include + +// ROOT libs: + +// MEGAlib libs: +#include "MGlobal.h" + +// Nuclearizer libs: +#include "MReadOutAssembly.h" + +// Forward declarations: + + +//////////////////////////////////////////////////////////////////////////////// + + +//! Determines the event type (ETYPE) of an event from its strip hits and veto flags +class MEventTypeClassifier +{ + // public interface: + public: + //! Default constructor + MEventTypeClassifier() {} + //! Default destructor + virtual ~MEventTypeClassifier() {} + + //! Return the event type 0x00-0x0C of the event: + //! If the event has an on-board event type, return it unchanged, otherwise determine it: + //! 0x00-0x02 multi-detector Compton, single-detector Compton, single site, without veto, + //! 0x03-0x05 the same with guard ring veto + //! 0x09-0x0B the same with (soft) shield veto, + //! and 0x0C for a guard ring veto without any strip hit + static uint8_t Classify(MReadOutAssembly* Event); + + +#ifdef ___CLING___ + public: + ClassDef(MEventTypeClassifier, 0) // Determines the FEE event type of an event +#endif + +}; + +#endif + + +//////////////////////////////////////////////////////////////////////////////// diff --git a/include/MReadOutAssembly.h b/include/MReadOutAssembly.h index 257bb540..515df887 100644 --- a/include/MReadOutAssembly.h +++ b/include/MReadOutAssembly.h @@ -114,6 +114,13 @@ class MReadOutAssembly : public MReadOutSequence //! Get the shield veto flag bool GetShieldVeto() const { return m_ShieldVeto; } + //! Set the event type (ETYPE) + void SetOnboardEventType(unsigned int EventType) { m_OnboardEventType = EventType; } + //! Get the event type (ETYPE), g_UnsignedIntNotDefined if not available + unsigned int GetOnboardEventType() const { return m_OnboardEventType; } + //! Return true if the event type (ETYPE) is available + bool HasOnboardEventType() const { return m_OnboardEventType != g_UnsignedIntNotDefined; } + //! Set the triggered flag void SetTrigger(bool Trigger = true) { m_Trigger = Trigger; } //! Return the trigger flag @@ -372,6 +379,9 @@ class MReadOutAssembly : public MReadOutSequence //! Shield veto flag bool m_ShieldVeto; + //! event type (ETYPE), g_UnsignedIntNotDefined if not available + unsigned int m_OnboardEventType; + //! Trigger flag of this event bool m_Trigger; diff --git a/src/MEventTypeClassifier.cxx b/src/MEventTypeClassifier.cxx new file mode 100644 index 00000000..adcbae77 --- /dev/null +++ b/src/MEventTypeClassifier.cxx @@ -0,0 +1,119 @@ +/* + * MEventTypeClassifier.cxx + * + * + * Copyright (C) by Andreas Zoglauer, WingYeung Ma. + * All rights reserved. + * + * + * This code implementation is the intellectual property of + * Andreas Zoglauer. + * + * By copying, distributing or modifying the Program (or any work + * based on the Program) you indicate your acceptance of this statement, + * and all its terms. + * + */ + + +//////////////////////////////////////////////////////////////////////////////// +// +// MEventTypeClassifier +// +//////////////////////////////////////////////////////////////////////////////// + + +// Include the header: +#include "MEventTypeClassifier.h" + +// Standard libs: +#include +#include +#include +using namespace std; + +// ROOT libs: + +// MEGAlib libs: + +// Nuclearizer libs: +#include "MStripHit.h" + + +//////////////////////////////////////////////////////////////////////////////// + + +#ifdef ___CLING___ +ClassImp(MEventTypeClassifier) +#endif + + +//////////////////////////////////////////////////////////////////////////////// + + +uint8_t MEventTypeClassifier::Classify(MReadOutAssembly* Event) +{ + // Event types from COSI-ICD-011 (FEE), Table 36: + // 0x00 Multi-detector Compton, no veto 0x03 / 0x06 / 0x09 the same with GR / hard shield / soft shield veto + // 0x01 Single-detector Compton, no veto 0x04 / 0x07 / 0x0A the same with GR / hard shield / soft shield veto + // 0x02 Single site, no veto 0x05 / 0x08 / 0x0B the same with GR / hard shield / soft shield veto + // 0x0C GR event + + if (Event->HasOnboardEventType() == true) { + return (uint8_t) Event->GetOnboardEventType(); + } + + set Detectors; + vector LVStrips; + vector HVStrips; + + for (unsigned int h = 0; h < Event->GetNStripHits(); ++h) { + + MStripHit* Hit = Event->GetStripHit(h); + if (Hit->IsGuardRing() == true) continue; + + if (Hit->IsNearestNeighbor() == true) continue; + + Detectors.insert(Hit->GetDetectorID()); + + if (Hit->IsLowVoltageStrip() == true) { + LVStrips.push_back(Hit->GetStripID()); + } else { + HVStrips.push_back(Hit->GetStripID()); + } + + } + + // A guard ring veto without any strip hit is a GR event + if (Detectors.empty() == true && Event->GetGuardRingVeto() == true) { + return 0x0C; + } + + // Category: 0 = multi-detector, 1 = single-detector Compton, 2 = single site + uint8_t Category = 2; + if (Detectors.size() >= 2) { + Category = 0; + } else if (Detectors.size() == 1) { + bool HasComptonGap = false; + for (vector* Strips : { &LVStrips, &HVStrips }) { + sort(Strips->begin(), Strips->end()); + for (size_t s = 1; s < Strips->size(); ++s) { + if ((*Strips)[s] - (*Strips)[s-1] >= 3) { + HasComptonGap = true; + } + } + } + if (HasComptonGap == true) Category = 1; + } + + if (Event->GetGuardRingVeto() == true) { + return 0x03 + Category; + } else if (Event->GetShieldVeto() == true) { + return 0x09 + Category; + } + return Category; +} + + +// MEventTypeClassifier.cxx: the end... +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/MFITSWriterL1a.cxx b/src/MFITSWriterL1a.cxx index 265d23d7..e0c4391a 100644 --- a/src/MFITSWriterL1a.cxx +++ b/src/MFITSWriterL1a.cxx @@ -34,6 +34,7 @@ // MEGAlib libs: #include "MStripHit.h" #include "MStreams.h" +#include "MEventTypeClassifier.h" using namespace std; using namespace CCfits; @@ -166,6 +167,7 @@ bool MFITSWriterL1a::Create(const MString& FileName) m_Table->addKey("CREATOR", "Nuclearizer", "Software that create 1st the file"); m_Table->addKey("PROCVER", "00.00.00.00", "Processing version"); // MM.XX.YY.NN; ICD reserves MM=00 for development/testing m_Table->addKey("CALDBVER", "cs20230401", "CALDB index version used"); // provisional value per ICD until first CALDB ingestion + m_Table->addKey("TLM2FITS", "TBD", "Telemetry converter FITS version"); // TODO: TBD m_Table->addKey("SEQPNUM", 0, "Times the dataset has been processed"); m_Table->addKey("ORIGIN", "SSL", "Origin of the FITS files"); @@ -222,7 +224,7 @@ bool MFITSWriterL1a::Write(MReadOutAssembly* Event) m_BatchTIME.push_back(time); m_BatchEVENTID.push_back((uint32_t)Event->GetID()); - m_BatchEVENTTYPE.push_back(0); // TODO + m_BatchEVENTTYPE.push_back(MEventTypeClassifier::Classify(Event)); m_BatchNUMSTRIPHIT.push_back(nStripHits); m_BatchHITTYPE.push_back(hittype); m_BatchDETID.push_back(detid); diff --git a/src/MModuleLoaderMeasurementsFITS.cxx b/src/MModuleLoaderMeasurementsFITS.cxx index f6eade4e..d141072f 100644 --- a/src/MModuleLoaderMeasurementsFITS.cxx +++ b/src/MModuleLoaderMeasurementsFITS.cxx @@ -325,13 +325,18 @@ bool MModuleLoaderMeasurementsFITS::AnalyzeEvent(MReadOutAssembly* Event) // Extract event-level data double eventTime = m_BatchTIME[idx]; - // uint8_t eventType = m_BatchEVENTTYPE[idx]; //unused variable + uint8_t eventType = m_BatchEVENTTYPE[idx]; uint8_t numStripHit = m_BatchNUMSTRIPHIT[idx]; // Set event-level properties Event->SetID(static_cast(m_BatchEVENTID[idx])); Event->SetTimeRTS(eventTime); // Mission time in seconds since Jan 1, 2025 + // determine guard-ring, hard shield, and soft shield vetoes from event types + Event->SetGuardRingVeto((eventType >= 0x03 && eventType <= 0x05) || eventType == 0x0C); + Event->SetShieldVeto(eventType >= 0x06 && eventType <= 0x0B); + Event->SetOnboardEventType(eventType); + // Loop through strip hits and create MStripHit objects for (uint8_t hitIdx = 0; hitIdx < numStripHit; ++hitIdx) { // Extract hit data from arrays diff --git a/src/MModuleLoaderMeasurementsL0.cxx b/src/MModuleLoaderMeasurementsL0.cxx index a4a3ce54..be86d3df 100644 --- a/src/MModuleLoaderMeasurementsL0.cxx +++ b/src/MModuleLoaderMeasurementsL0.cxx @@ -144,6 +144,9 @@ MModuleLoaderMeasurementsL0::~MModuleLoaderMeasurementsL0() bool MModuleLoaderMeasurementsL0::Initialize() { + if (m_InFile.is_open()) m_InFile.close(); + m_InFile.clear(); + m_StripMapLoaded = false; m_PacketsRead = 0; if (m_FileName == "") { @@ -319,6 +322,11 @@ bool MModuleLoaderMeasurementsL0::ReadNextPacket(MReadOutAssembly* Event) MTime gpsTime((long int)pktSeconds, pktNanoseconds); Event->SetTimeRTS(Event->ComputeRTSfromGPSTime(gpsTime)); + // event types distinguish guard-ring, hard shield, and soft shield vetoes. + Event->SetGuardRingVeto((etype >= 0x03 && etype <= 0x05) || etype == 0x0C); + Event->SetShieldVeto(etype >= 0x06 && etype <= 0x0B); + Event->SetOnboardEventType(etype); + // Decode the bit-packed HIT_DATA into individual MStripHit objects on the event if (DecodeHitData(hitData, hits, Event) == false) { return false; @@ -370,9 +378,9 @@ bool MModuleLoaderMeasurementsL0::DecodeHitData(const std::vector& hitD tac = br.ReadBits(10); isNeighbor = true; } else if (hitType == 0x2) { - // Guard ring: 5 + 14 + 1(pad) = 20 more bits + // Guard ring: 5-bit strip id + 14-bit energy + 1 pad bit. if (br.BitsRemaining() < 20) break; - stripID = br.ReadBits(5); + stripID = 2048 + br.ReadBits(5); adc = br.ReadBits(14); (void)br.ReadBits(1); // pad isGuardRing = true; diff --git a/src/MModuleSaverMeasurementsFITS.cxx b/src/MModuleSaverMeasurementsFITS.cxx index 38b3d78e..757ae38a 100644 --- a/src/MModuleSaverMeasurementsFITS.cxx +++ b/src/MModuleSaverMeasurementsFITS.cxx @@ -42,6 +42,7 @@ using namespace std; #include "MPhysicalEventHit.h" #include "MComptonEvent.h" #include "MPhotoEvent.h" +#include "MEventTypeClassifier.h" //////////////////////////////////////////////////////////////////////////////// @@ -212,7 +213,7 @@ bool MModuleSaverMeasurementsFITS::CreateFITSFile(MString FileName) {"TIME", "1D", "s", "Mission Time in sec since 01 Jan 2025 00:00:00", false}, {"EVENTID", "1J", "", "Event ID, unique number that starts at 1 each day", false}, {"EVENTTYPE", "1B", "", "Type of event", true }, - {"EVENTCLASS", "1B", "", "0=Compton, 1=photoabsor, 2=charge particle, 4=pair, 5=unknown", false}, + {"EVENTCLASS", "1B", "", "0=Compton, 1=photoabsor, 2=tracked Compton, 3=charge particle, 4=pair, 5=unknown", false}, {"NUMHIT", "1B", "", "Number of Hits", false}, {"STATTEST", "8E", "", "Statistical Test", true }, {"VETO", "1B", "", "Veto flag: 0=none, 1=hard ACD veto, 2=soft ACD veto, 3=guard ring veto", true }, @@ -352,14 +353,21 @@ bool MModuleSaverMeasurementsFITS::AnalyzeEvent(MReadOutAssembly* Event) } // Event-level metadata defaults - uint8_t eventType = 0; // TODO: 0 = unknown/default + uint8_t eventType = MEventTypeClassifier::Classify(Event); // EVENTCLASS per HEASARC Tech Agreement v1.1 // 0 = Compton, 1 = photoabsorption, 2 = tracked Compton, 3 = charge particle, 4 = pair, 5 = unknown. uint8_t eventClass = 5; // 5 = unknown uint32_t eventID = (uint32_t)Event->GetID(); - uint8_t veto = Event->IsVeto() ? 1 : 0; + // VETO: 0 = none, 1 = hard ACD veto, 2 = soft ACD veto, 3 = guard ring veto + // Hard and soft shield veto are told apart by the event type (0x06-0x08 hard, 0x09-0x0B soft) + uint8_t veto = 0; + if (Event->GetGuardRingVeto() == true) { + veto = 3; + } else if (Event->GetShieldVeto() == true) { + veto = (eventType >= 0x06 && eventType <= 0x08) ? 1 : 2; + } std::string quality_flag; // L2: fixed-length 10 hit arrays, zero-padded diff --git a/src/MModuleSaverMeasurementsL0.cxx b/src/MModuleSaverMeasurementsL0.cxx index 472f9c6f..145321ad 100644 --- a/src/MModuleSaverMeasurementsL0.cxx +++ b/src/MModuleSaverMeasurementsL0.cxx @@ -27,9 +27,7 @@ #include "MModuleSaverMeasurementsL0.h" // Standard libs: -#include #include -#include using namespace std; // ROOT libs: @@ -40,6 +38,7 @@ using namespace std; // Nuclearizer libs: #include "MGUIOptionsSaverMeasurementsL0.h" +#include "MEventTypeClassifier.h" //////////////////////////////////////////////////////////////////////////////// @@ -296,103 +295,7 @@ uint32_t MModuleSaverMeasurementsL0::EncodeGuardRingHit(int stripID, int adc) uint8_t MModuleSaverMeasurementsL0::GetEventType(MReadOutAssembly* Event) { - // Compute event type based on Table 32 from COSI-ICD-011-FEE PL-REV-A - - // Event type depends on: number of detectors hit + veto status - // Type Value (hex) | Type Description - // 0x00 | Multi-detector Compton, no veto - // 0x01 | Single-detector Compton, no veto - // 0x02 | Single-site, no veto - // 0x03 | Multi-detector event with GR veto - // 0x04 | Single-detector event with GR veto - // 0x05 | Single site with GR veto - // 0x06 | Multi-detector event with hard Shield veto - // 0x07 | Single-detector event with hard Shield veto - // 0x08 | Single site with hard Shield veto - // 0x09 | Multi-detector event with soft Shield veto - // 0x0A | Single-detector event with soft Shield veto - // 0x0B | Single site with soft Shield veto - // 0x0C | GR event - // 0x0D | FEE debug event - - // Count unique detectors and collect strip IDs by side - set uniqueDetectors; - vector lvStrips; // LV side strip IDs - vector hvStrips; // HV side strip IDs - - unsigned int numHits = Event->GetNStripHits(); - for (unsigned int i = 0; i < numHits; ++i) { - MStripHit* hit = Event->GetStripHit(i); - uniqueDetectors.insert(hit->GetDetectorID()); - - if (hit->IsLowVoltageStrip()) { - lvStrips.push_back(hit->GetStripID()); - } else { - hvStrips.push_back(hit->GetStripID()); - } - } - int nDetectors = uniqueDetectors.size(); - - // Determine detector category: - // 0 = multi-detector (Multi-detector Compton event is at least two simultaneous hits in different detectors, - // but not more than a programmable maximum number, nominally 20 (all hits, >20 is a shower)) - // 1 = single-detector Compton (Single-detector Compton event is two triggered strips on one side of the detector that are - // separated by at least 2 (TBD, but programmable) strips, and at least 1 strip on the other side. Event type 0x15 counts - // events with multiple triggered strips on one detector that are not neighboring and also don’t meet the minimum separation.) - // 2 = single-site (Single-site is >=1 triggered strip on each side of a detector, multiple triggered strips are allowed if they’re neighboring) - // Note: - // * Soft Guard ring (GR) veto, any hit or event that has a simultaneous hit on the guard ring in any detector (no hard veto possible) - // * Hard veto from shields, interrupts GeD data taking when simultaneous hit is measured in BGO - // * Soft veto from shields, when at least one ACS ASIC is busy, any new GeD events are flagged to be filtered out - - int detectorCategory; - if (nDetectors >= 2) { - detectorCategory = 0; // Multi-detector - } else if (nDetectors == 1) { - // Check if any strips on same side are separated by >= 2 - // Single-detector Compton: two triggered strips separated by at least 2 strips - // Single-site: all strips neighboring - - bool hasComptonGap = false; - - // Check LV side for gaps - if (lvStrips.size() >= 2) { - sort(lvStrips.begin(), lvStrips.end()); - for (size_t i = 1; i < lvStrips.size(); ++i) { - if (lvStrips[i] - lvStrips[i-1] >= 2) { - hasComptonGap = true; - break; - } - } - } - - // Check HV side for gaps - if (!hasComptonGap && hvStrips.size() >= 2) { - sort(hvStrips.begin(), hvStrips.end()); - for (size_t i = 1; i < hvStrips.size(); ++i) { - if (hvStrips[i] - hvStrips[i-1] >= 2) { - hasComptonGap = true; - break; - } - } - } - - detectorCategory = hasComptonGap ? 1 : 2; - } else { - detectorCategory = 2; // detector == 0, default to single-site - } - - // Determine veto status and return event type - if (Event->GetGuardRingVeto()) { - // GR veto: 0x03, 0x04, 0x05 - return 0x03 + detectorCategory; - } else if (Event->GetShieldVeto()) { - // Shield veto (using soft veto codes): 0x09, 0x0A, 0x0B - return 0x09 + detectorCategory; - } else { - // No veto: 0x00, 0x01, 0x02 - return 0x00 + detectorCategory; - } + return MEventTypeClassifier::Classify(Event); } @@ -430,18 +333,32 @@ bool MModuleSaverMeasurementsL0::AnalyzeEvent(MReadOutAssembly* Event) std::vector hitData; int bitOffset = 0; int totalBits = 0; + unsigned int numWrittenHits = 0; for (unsigned int i = 0; i < numHits; ++i) { MStripHit* hit = Event->GetStripHit(i); // Get strip info - int detID = hit->GetDetectorID() & 0xF; // 4 bits (0-15) - int side = hit->IsLowVoltageStrip() ? 0 : 1; // 1 bit - int stripNum = hit->GetStripID() & 0x3F; // 6 bits (0-63) - int stripID = 0; - if (m_StripMap.HasROIDetSideStrip(detID, hit->IsLowVoltageStrip(), stripNum)) { - stripID = (int)m_StripMap.GetReadOutID(detID, hit->IsLowVoltageStrip(), stripNum); + unsigned int detID = hit->GetDetectorID(); + unsigned int stripNum = hit->GetStripID(); + + if (detID > 15) { + if (g_Verbosity >= c_Error) { + cout<GetID()<<": hit has invalid detector ID "<IsLowVoltageStrip(), stripNum) == false) { + if (g_Verbosity >= c_Warning) { + cout<GetID()<<": detector "<IsLowVoltageStrip() ? " LV" : " HV") + <<" strip "<IsLowVoltageStrip(), stripNum); + ++numWrittenHits; bool fastTiming = hit->HasFastTiming(); int adc = (int)hit->GetADCUnits(); int tac = (int)hit->GetTAC(); @@ -461,12 +378,20 @@ bool MModuleSaverMeasurementsL0::AnalyzeEvent(MReadOutAssembly* Event) } } + // The HITS field has only 6 bits: if an event has more than 63 hits, it cannot fit in one event + if (numWrittenHits > 63) { + if (g_Verbosity >= c_Error) { + cout<GetID()<<" has "<GetNStripHits() == 2) { Passed = Evaluate("AnalyzeEvent()", "event 2", "The strip hits are in detector 1", R->GetStripHit(0)->GetDetectorID(), 1u) && Passed; } - Passed = ExpectedToFail(EvaluateTrue("AnalyzeEvent()", "event 2", "The shield veto encoded in the event type survives", R->GetShieldVeto())) && Passed; + Passed = EvaluateTrue("AnalyzeEvent()", "event 2", "The shield veto encoded in the event type survives", R->GetShieldVeto()) && Passed; } if (Read.size() >= 3) { MReadOutAssembly* R = Read[2]; - Passed = ExpectedToFail(EvaluateTrue("AnalyzeEvent()", "event 3", "The guard ring veto survives", R->GetGuardRingVeto())) && Passed; - Passed = ExpectedToFail(Evaluate("AnalyzeEvent()", "event 3", "Both strip hits survive including the guard ring hit", R->GetNStripHits(), 2u)) && Passed; + Passed = EvaluateTrue("AnalyzeEvent()", "event 3", "The guard ring veto survives", R->GetGuardRingVeto()) && Passed; + Passed = Evaluate("AnalyzeEvent()", "event 3", "Both strip hits survive including the guard ring hit", R->GetNStripHits(), 2u) && Passed; bool FoundGR = false; for (unsigned int i = 0; i < R->GetNStripHits(); ++i) { MStripHit* S = R->GetStripHit(i); if (S->IsGuardRing() == true && S->GetDetectorID() == 0 && S->GetStripID() == 64) FoundGR = true; } - Passed = ExpectedToFail(EvaluateTrue("AnalyzeEvent()", "event 3", "The guard ring hit keeps its detector and strip ID", FoundGR)) && Passed; + Passed = EvaluateTrue("AnalyzeEvent()", "event 3", "The guard ring hit keeps its detector and strip ID", FoundGR) && Passed; } for (MReadOutAssembly* E : Written) delete E; @@ -560,9 +560,9 @@ bool UTNModuleLoaderMeasurementsL0::TestReinitialize() Passed = EvaluateTrue("Initialize()", "first time", "Initialize succeeds", Init[0]) && Passed; Passed = Evaluate("AnalyzeEvent()", "first pass", "Two events are read", Counts[0], 2u) && Passed; - Passed = ExpectedToFail(EvaluateTrue("Initialize()", "second time without Finalize", "Initialize succeeds again", Init[1])) && Passed; - Passed = ExpectedToFail(Evaluate("AnalyzeEvent()", "second pass", "Two events are read again", Counts[1], 2u)) && Passed; - Passed = ExpectedToFail(Evaluate("AnalyzeEvent()", "second pass", "The event IDs restart at 1", LastID[1], (unsigned long) 2)) && Passed; + Passed = EvaluateTrue("Initialize()", "second time without Finalize", "Initialize succeeds again", Init[1]) && Passed; + Passed = Evaluate("AnalyzeEvent()", "second pass", "Two events are read again", Counts[1], 2u) && Passed; + Passed = Evaluate("AnalyzeEvent()", "second pass", "The event IDs restart at 1", LastID[1], (unsigned long) 2) && Passed; return Passed; } diff --git a/unittests/UTNModuleSaverMeasurementsFITS.cxx b/unittests/UTNModuleSaverMeasurementsFITS.cxx index 39cea071..da580736 100644 --- a/unittests/UTNModuleSaverMeasurementsFITS.cxx +++ b/unittests/UTNModuleSaverMeasurementsFITS.cxx @@ -538,7 +538,7 @@ bool UTNModuleSaverMeasurementsFITS::TestL1b() // VETO: 0 = none, 1 = hard ACD veto, 2 = soft ACD veto, 3 = guard ring veto Passed = Evaluate("AnalyzeEvent()", "L1b", "VETO has one element per event", ColumnShape(Veto), Scalar) && Passed; if (ColumnShape(Veto) == Scalar) { - Passed = ExpectedToFail(EvaluateNear("AnalyzeEvent()", "L1b event 1 with guard ring veto", "VETO is 3 for a guard ring veto", Veto[0][0], 3.0, 1e-12)) && Passed; + Passed = EvaluateNear("AnalyzeEvent()", "L1b event 1 with guard ring veto", "VETO is 3 for a guard ring veto", Veto[0][0], 3.0, 1e-12) && Passed; Passed = EvaluateNear("AnalyzeEvent()", "L1b event 2 without veto", "VETO is 0 without veto", Veto[1][0], 0.0, 1e-12) && Passed; Passed = EvaluateTrue("AnalyzeEvent()", "L1b event 3 with shield veto", "VETO is an ACD veto (1 or 2) for a shield veto", Veto[2][0] == 1.0 || Veto[2][0] == 2.0) && Passed; } diff --git a/unittests/UTNModuleSaverMeasurementsL0.cxx b/unittests/UTNModuleSaverMeasurementsL0.cxx index e56add01..6d43e255 100644 --- a/unittests/UTNModuleSaverMeasurementsL0.cxx +++ b/unittests/UTNModuleSaverMeasurementsL0.cxx @@ -127,7 +127,7 @@ bool UTNModuleSaverMeasurementsL0::Run() MString UTNModuleSaverMeasurementsL0::WriteStripMap() { - // Detector 0: LV strips 0-9 = ROI 100-109, HV strips 0-9 = ROI 200-209, LV guard ring strip 64 = ROI 300 + // Detector 0: LV strips 0-9 = ROI 100-109, HV strips 0-9 = ROI 200-209, LV guard ring strip 64 = ROI 2049 // Detector 1: LV strips 0-9 = ROI 400-409, HV strips 0-9 = ROI 500-509 MString C = "# Columns are strip_id, detector, side (0=LV, 1=HV), strip\n"; for (unsigned int s = 0; s < 10; ++s) { @@ -136,7 +136,7 @@ MString UTNModuleSaverMeasurementsL0::WriteStripMap() C += MString("") + (400 + s) + " 1 0 " + s + "\n"; C += MString("") + (500 + s) + " 1 1 " + s + "\n"; } - C += "300 0 0 64\n"; + C += "2049 0 0 64\n"; MString FileName = GetTemporaryFileName("l0.stripmap.map"); // An empty name makes Initialize() fail, which the callers check @@ -408,7 +408,7 @@ bool UTNModuleSaverMeasurementsL0::TestEventType() AddStripHit(E, 0, 3, true); AddStripHit(E, 0, 5, true); AddStripHit(E, 0, 5, false); - Passed = ExpectedToFail(EvaluateTrue("GetEventType()", "one detector, LV strips 3 and 5", "Strips separated by only one strip are not a single-detector Compton event", M.CallGetEventType(&E) != 0x01)) && Passed; + Passed = EvaluateTrue("GetEventType()", "one detector, LV strips 3 and 5", "Strips separated by only one strip are not a single-detector Compton event", M.CallGetEventType(&E) != 0x01) && Passed; } { MReadOutAssembly E; @@ -440,7 +440,7 @@ bool UTNModuleSaverMeasurementsL0::TestEventType() MStripHit* GR = AddStripHit(E, 0, 64, true); GR->IsGuardRing(true); E.SetGuardRingVeto(true); - Passed = ExpectedToFail(Evaluate("GetEventType()", "single site plus LV guard ring hit, GR veto", "Single site with GR veto is 0x05", (unsigned int) M.CallGetEventType(&E), 0x05u)) && Passed; + Passed = Evaluate("GetEventType()", "single site plus LV guard ring hit, GR veto", "Single site with GR veto is 0x05", (unsigned int) M.CallGetEventType(&E), 0x05u) && Passed; } return Passed; @@ -507,7 +507,7 @@ bool UTNModuleSaverMeasurementsL0::TestGuardRingReadOutID() { bool Passed = true; - // The strip map assigns read-out ID 300 to the LV guard ring (strip 64) of detector 0; strip 0 has read-out ID 100 + // The strip map assigns read-out ID 2049 to the LV guard ring (strip 64) of detector 0; strip 0 has read-out ID 100 MReadOutAssembly E; E.SetTimeRTS(MTime(1000, 0)); MStripHit* GR = AddStripHit(E, 0, 64, true, 3000); @@ -521,7 +521,7 @@ bool UTNModuleSaverMeasurementsL0::TestGuardRingReadOutID() if (IsSinglePacket(B) == true && B.size() >= 24) { vector Hit(B.begin() + 21, B.begin() + 24); Passed = Evaluate("AnalyzeEvent()", "LV guard ring of detector 0", "The hit type is 0x2 (guard ring)", (unsigned int) ExtractBits(Hit, 0, 4), 2u) && Passed; - Passed = ExpectedToFail(Evaluate("AnalyzeEvent()", "LV guard ring of detector 0", "The 5-bit read-out ID is that of the guard ring (300 & 0x1F = 12), not that of strip 0 (100 & 0x1F = 4)", (unsigned int) ExtractBits(Hit, 4, 5), 12u)) && Passed; + Passed = Evaluate("AnalyzeEvent()", "LV guard ring of detector 0", "The 5-bit read-out ID is that of the guard ring (2049 & 0x1F = 1), not that of strip 0 (100 & 0x1F = 4)", (unsigned int) ExtractBits(Hit, 4, 5), 1u) && Passed; } return Passed; @@ -548,7 +548,7 @@ bool UTNModuleSaverMeasurementsL0::TestFormatLimits() if (ManyResult == true) { Passed = EvaluateTrue("AnalyzeEvent()", "64 strip hits", "A complete packet is written", IsSinglePacket(BM)) && Passed; if (IsSinglePacket(BM) == true) { - Passed = ExpectedToFail(Evaluate("AnalyzeEvent()", "64 strip hits", "A written packet must contain the correct number of hits", (unsigned int) (BM[18] >> 2), 64u)) && Passed; + Passed = Evaluate("AnalyzeEvent()", "64 strip hits", "A written packet must contain the correct number of hits", (unsigned int) (BM[18] >> 2), 64u) && Passed; } } else { Passed = Evaluate("AnalyzeEvent()", "64 strip hits", "A rejected event writes nothing", (unsigned int) BM.size(), 0u) && Passed; @@ -566,7 +566,7 @@ bool UTNModuleSaverMeasurementsL0::TestFormatLimits() // If a packet is written, the unknown strip must not appear in it under any read-out ID Passed = EvaluateTrue("AnalyzeEvent()", "strip not in the strip map", "A complete packet is written", IsSinglePacket(BU)) && Passed; if (IsSinglePacket(BU) == true) { - Passed = ExpectedToFail(Evaluate("AnalyzeEvent()", "strip not in the strip map", "A strip which is not in the strip map is not silently written with another read-out ID", (unsigned int) (BU[18] >> 2), 0u)) && Passed; + Passed = Evaluate("AnalyzeEvent()", "strip not in the strip map", "A strip which is not in the strip map is not silently written with another read-out ID", (unsigned int) (BU[18] >> 2), 0u) && Passed; } } else { Passed = EvaluateFalse("AnalyzeEvent()", "strip not in the strip map", "An event which writes nothing reports a failure", UnknownResult) && Passed;