From 38d397b9e41ff8278660fc9d0908a685985cc6d6 Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Fri, 10 Jun 2016 10:18:41 +0900 Subject: [PATCH 01/28] Changed rcnp gitmodule address --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 929fa390..54c2ad88 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "GRAnalyzer"] path = GRAnalyzer - url = https://github.com/CAGRA-GrandRaiden/GRAnalyzer + url = sullivan@nsclgw1.nscl.msu.edu:~/ceclub/sullivan/cagragr/GRUTinizer/GRAnalyzer From 1cd275a8bd0e80e87fa849007d5c8233414ed4bb Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Tue, 14 Jun 2016 15:02:13 +0900 Subject: [PATCH 02/28] Temporarily changing the submodule path for work at RCNP --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 54c2ad88..55248cee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "GRAnalyzer"] path = GRAnalyzer - url = sullivan@nsclgw1.nscl.msu.edu:~/ceclub/sullivan/cagragr/GRUTinizer/GRAnalyzer + url = sullivan@nsclgw1.nscl.msu.edu:~/ceclub/sullivan/cagragr/GRAnalyzer From 4762c7565b161c7c8d176ca6709b5b7354514f30 Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Wed, 15 Jun 2016 11:20:48 +0900 Subject: [PATCH 03/28] Timestamps bath was absolute, and added to TCaeser.h which is needed in 4.9.3 --- include/TCaesar.h | 1 + libraries/TRawFormat/TRCNPSource.cxx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/TCaesar.h b/include/TCaesar.h index ad5f39f2..d35b3d1a 100644 --- a/include/TCaesar.h +++ b/include/TCaesar.h @@ -16,6 +16,7 @@ #include "TEnv.h" //For easy parsing of detector positions #include +#include class TCaesar : public TDetector { diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 6d5da10f..e98c584a 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -88,7 +88,7 @@ std::string TRCNPSource::SourceDescription() const {return "File: "+std::string( void TRCNPSource::LoadFakeTimestamps() { std::string line; std::stringstream stream; ULong_t ts; - ifstream file ("/projects/ceclub/sullivan/cagragr/GRUTinizer/timestamps.dat"); + ifstream file ("./timestamps.dat"); if (file.is_open()) { while ( getline (file,line) ) From 6b11058040ab071015aa5e0518a19fcd357294a2 Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Fri, 17 Jun 2016 10:25:22 +0900 Subject: [PATCH 04/28] Changed gitmodules url for submodule to GitHub ssh --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 55248cee..f9e620d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "GRAnalyzer"] path = GRAnalyzer - url = sullivan@nsclgw1.nscl.msu.edu:~/ceclub/sullivan/cagragr/GRAnalyzer + url = git@github.com:CAGRA-GrandRaiden/GRAnalyzer.git From 0a099032d72dc11df0ac989a468753f34bc5187c Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Fri, 17 Jun 2016 12:35:59 +0900 Subject: [PATCH 05/28] Added functionality for ANL firmware v1.8 (June 2015). July 2015 additions will be necessary. --- include/TRawBanks.h | 54 +++++++++++- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 23 +++++ libraries/TRawFormat/TRawBanks.cxx | 92 ++++++++++++++++---- util/simpleread_anl.cxx | 34 ++++++++ 4 files changed, 187 insertions(+), 16 deletions(-) diff --git a/include/TRawBanks.h b/include/TRawBanks.h index bf383e86..65822a73 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -276,7 +276,7 @@ struct GEBMode3Data { friend std::ostream& operator<<(std::ostream& os, const GEBMode3Data &data); static void SwapMode3Data(GEBMode3Data &data); -enum ArgonneType { LEDv10, LEDv11, CFDv11 }; +enum ArgonneType { LEDv10, LEDv11, CFDv11, LEDv18, CFDv18 }; struct GEBArgonneHead { UShort_t GA_packetlength; @@ -333,9 +333,61 @@ struct GEBArgonneLEDv11 { UShort_t PileUpFlag() const; }__attribute__((__packed__)); +struct GEBArgonneLEDv18 { + UShort_t led_low_prev; + UShort_t flags; + UInt_t led_high_prev; + UInt_t sampled_baseline; + UInt_t _blank_; + UInt_t postrise_sum_low_prerise_sum; + UShort_t timestamp_peak_low; + UShort_t postrise_sum_high; + // begin differences from v11 // + UShort_t timestamp_trigger_low; + UShort_t last_postrise_enter_sample; + // old: UInt_t timestamp_peak_high; + UShort_t last_postrise_leave_sample; + UShort_t postrise_leave_sample; + // old: UShort_t postrise_end_sample; + // old: UShort_t postrise_begin_sample; + UShort_t prerise_enter_sample; + UShort_t prerise_leave_sample; + // old: UShort_t prerise_end_sample; + // old: UShort_t prerise_begin_sample; + UShort_t base_sample; + UShort_t peak_sample; + ULong_t GetPreviousLED() const; + UInt_t GetBaseline() const; + UInt_t GetPreRiseE() const; + UInt_t GetPostRiseE() const; + // need changes + ULong_t GetTrigTimestamp() const; + UShort_t GetLastPostRiseEnterSample() const; + UShort_t GetLastPostRiseLeaveSample() const; + UShort_t GetPostRiseLeaveSample() const; + UShort_t GetPreRiseEnterSample() const; + UShort_t GetPreRiseLeaveSample() const; + // no change needed + UShort_t GetBaseSample() const; + UShort_t GetPeakSample() const; + + UShort_t WriteFlag() const; + UShort_t VetoFlag() const; + UShort_t ExternalDiscFlag() const; + UShort_t PeakValidFlag() const; + UShort_t OffsetFlag() const; + UShort_t SyncErrorFlag() const; + UShort_t GeneralErrorFlag() const; + UShort_t PileUpOnlyFlag() const; + UShort_t PileUpFlag() const; +}__attribute__((__packed__)); + friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv11& data); static void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv18& data); +static void SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data); + struct GEBS800Header { Int_t total_size; UShort_t total_size2; diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index 2f6b2747..cb1c50e7 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -60,6 +60,29 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { "void TANLEvent::BuildFrom(TSmartBuffer buf) :: ArgonneType::CFDv11 is not implemented."); break; } + case TRawEvent::ArgonneType::LEDv18: { + // auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); + // buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); + // // Swap big endian for little endian + // TRawEvent::SwapArgonneLEDv11(*data); + // // Extract data from payload + // led_prev = data->GetPreviousLED(); + // flags = data->flags; + // prerise_energy = data->GetPreRiseE(); + // postrise_energy = data->GetPostRiseE(); + // postrise_begin_sample = data->GetPostRiseSampleBegin(); + // prerise_begin_sample = data->GetPreRiseSampleBegin(); + // postrise_end_sample = data->GetPostRiseSampleEnd(); + // prerise_end_sample = data->GetPreRiseSampleEnd(); + + // // ignore waveform data + // size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); + // buf.Advance(wave_bytes); + + break; + } + case TRawEvent::ArgonneType::CFDv18: + break; } } diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index ebcdb6b0..f43c161f 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -157,6 +157,31 @@ UShort_t TRawEvent::GEBArgonneLEDv11::GeneralErrorFlag() const { return ((flags UShort_t TRawEvent::GEBArgonneLEDv11::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } UShort_t TRawEvent::GEBArgonneLEDv11::PileUpFlag() const { return ((flags & 0x8000)>>15); } +ULong_t TRawEvent::GEBArgonneLEDv18::GetPreviousLED() const { return (((ULong_t)led_high_prev) << 16) + ((ULong_t)led_low_prev); } +UInt_t TRawEvent::GEBArgonneLEDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } +UInt_t TRawEvent::GEBArgonneLEDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } +UInt_t TRawEvent::GEBArgonneLEDv18::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } +// New +ULong_t TRawEvent::GEBArgonneLEDv18::GetTrigTimestamp() const { return ((ULong_t)timestamp_trigger_low) /*+ (((ULong_t)timestamp_trigger_high)<<16)*/; } // not fully implemented +UShort_t TRawEvent::GEBArgonneLEDv18::GetLastPostRiseEnterSample() const { return (last_postrise_enter_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetLastPostRiseLeaveSample() const { return (last_postrise_leave_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPostRiseLeaveSample() const { return (postrise_leave_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPreRiseEnterSample() const { return (prerise_enter_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPreRiseLeaveSample() const { return (prerise_leave_sample & 0x3fff); } + +UShort_t TRawEvent::GEBArgonneLEDv18::GetBaseSample() const { return (base_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv18::GetPeakSample() const { return (peak_sample & 0x3fff); } + +UShort_t TRawEvent::GEBArgonneLEDv18::WriteFlag() const { return ((flags & 0x20)>>5); } +UShort_t TRawEvent::GEBArgonneLEDv18::VetoFlag() const { return ((flags & 0x40)>>6); } +UShort_t TRawEvent::GEBArgonneLEDv18::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } +UShort_t TRawEvent::GEBArgonneLEDv18::PeakValidFlag() const { return ((flags & 0x200)>>9); } +UShort_t TRawEvent::GEBArgonneLEDv18::OffsetFlag() const { return ((flags & 0x400)>>10); } +UShort_t TRawEvent::GEBArgonneLEDv18::SyncErrorFlag() const { return ((flags & 0x1000)>>12); } +UShort_t TRawEvent::GEBArgonneLEDv18::GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } +UShort_t TRawEvent::GEBArgonneLEDv18::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } +UShort_t TRawEvent::GEBArgonneLEDv18::PileUpFlag() const { return ((flags & 0x8000)>>15); } + void TRawEvent::SwapArgonneHead(TRawEvent::GEBArgonneHead& header) { header.GA_packetlength = SwapShort(header.GA_packetlength); header.ud_channel = SwapShort(header.ud_channel); @@ -180,6 +205,24 @@ void TRawEvent::SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data) { data.base_sample = SwapShort(data.base_sample); data.peak_sample = SwapShort(data.peak_sample); } +void TRawEvent::SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data) { + data.led_low_prev = SwapShort(data.led_low_prev); + data.flags = SwapShort(data.flags); + data.led_high_prev = SwapInt(data.led_high_prev); + data.sampled_baseline = SwapInt(data.sampled_baseline); + data.postrise_sum_low_prerise_sum = SwapInt(data.postrise_sum_low_prerise_sum); + data.timestamp_peak_low = SwapShort(data.timestamp_peak_low); + data.postrise_sum_high = SwapShort(data.postrise_sum_high); + //data.timestamp_peak_high = SwapInt(data.timestamp_peak_high); + data.timestamp_trigger_low = SwapShort(data.timestamp_trigger_low); // not fully implemented + data.last_postrise_enter_sample = SwapShort(data.last_postrise_enter_sample); + data.last_postrise_leave_sample = SwapShort(data.last_postrise_leave_sample); + data.postrise_leave_sample = SwapShort(data.postrise_leave_sample); + data.prerise_enter_sample = SwapShort(data.prerise_enter_sample); + data.prerise_leave_sample = SwapShort(data.prerise_leave_sample); + data.base_sample = SwapShort(data.base_sample); + data.peak_sample = SwapShort(data.peak_sample); +} #define STR(x) "\t GEBArgonne "<< #x <<": " << x std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneHead& header) { @@ -192,21 +235,40 @@ std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneHead& head } std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv11& data) { return os << "-- Argonne LEDv11 data packet --" - << STR(data.led_low_prev) << "\n" - << STR(data.flags) << "\n" - << STR(data.led_high_prev) << "\n" - << STR(data.sampled_baseline) << "\n" - << STR(data._blank_) << "\n" - << STR(data.postrise_sum_low_prerise_sum) << "\n" - << STR(data.timestamp_peak_low) << "\n" - << STR(data.postrise_sum_high) << "\n" - << STR(data.timestamp_peak_high) << "\n" - << STR(data.postrise_end_sample) << "\n" - << STR(data.postrise_begin_sample) << "\n" - << STR(data.prerise_end_sample) << "\n" - << STR(data.prerise_begin_sample) << "\n" - << STR(data.base_sample) << "\n" - << STR(data.peak_sample) << std::endl; + << STR(data.led_low_prev) << "\n" + << STR(data.flags) << "\n" + << STR(data.led_high_prev) << "\n" + << STR(data.sampled_baseline) << "\n" + << STR(data._blank_) << "\n" + << STR(data.postrise_sum_low_prerise_sum) << "\n" + << STR(data.timestamp_peak_low) << "\n" + << STR(data.postrise_sum_high) << "\n" + << STR(data.timestamp_peak_high) << "\n" + << STR(data.postrise_end_sample) << "\n" + << STR(data.postrise_begin_sample) << "\n" + << STR(data.prerise_end_sample) << "\n" + << STR(data.prerise_begin_sample) << "\n" + << STR(data.base_sample) << "\n" + << STR(data.peak_sample) << std::endl; +} +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv18& data) { + return os << "-- Argonne LEDv18 data packet --" + << STR(data.led_low_prev) << "\n" + << STR(data.flags) << "\n" + << STR(data.led_high_prev) << "\n" + << STR(data.sampled_baseline) << "\n" + << STR(data._blank_) << "\n" + << STR(data.postrise_sum_low_prerise_sum) << "\n" + << STR(data.timestamp_peak_low) << "\n" + << STR(data.postrise_sum_high) << "\n" + << STR(data.timestamp_trigger_low) << "\n" + << STR(data.last_postrise_enter_sample) << "\n" + << STR(data.last_postrise_leave_sample) << "\n" + << STR(data.postrise_leave_sample) << "\n" + << STR(data.prerise_enter_sample) << "\n" + << STR(data.prerise_leave_sample) << "\n" + << STR(data.base_sample) << "\n" + << STR(data.peak_sample) << std::endl; } #undef STR diff --git a/util/simpleread_anl.cxx b/util/simpleread_anl.cxx index eb57d8c2..2d782299 100644 --- a/util/simpleread_anl.cxx +++ b/util/simpleread_anl.cxx @@ -73,6 +73,40 @@ struct ANL_LED_v11 { uint16_t peak_sample; }__attribute__((__packed__)); +struct ANL_LED_v18 { + uint32_t type; + uint32_t length; + uint64_t timestamp; + uint16_t ga_packetlength; + uint16_t ud_channel; + uint32_t led_low; + uint16_t hdrlength_evttype_hdrtype; + + uint16_t led_high; + uint16_t led_low_prev; + uint16_t flags; + uint32_t led_high_prev; + uint32_t sampled_baseline; + uint32_t blank; + uint32_t postrise_sum_low_prerise_sum; + uint16_t timestamp_peak_low; + uint16_t postrise_sum_high; + + uint16_t timestamp_trigger_low; // not fully implemented yet + uint16_t last_postrise_enter_sample; + // old: uint32_t timestamp_peak_high; + + uint16_t last_postrise_leave_sample; + uint16_t postrise_leave_sample; + // old: uint16_t postrise_end_sample; + // old: uint16_t postrise_begin_sample; + uint16_t prerise_enter_sample; + uint16_t prereise_leave_sample; + // old: uint16_t prerise_end_sample; + // old: uint16_t prerise_begin_sample; + uint16_t base_sample; + uint16_t peak_sample; +}__attribute__((__packed__)); int main (int argc, char **argv) { From 149948e57a87c7fec23597fe81a766c07523deb6 Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Sat, 18 Jun 2016 10:01:04 +0900 Subject: [PATCH 06/28] Major: Added void* fDataPtr to TRawEvent. This allows for TRawEvent to hold user information other than what is in the TSmartBuffer, which the user is responsible for cleaning up in one of their TDetector systems. --- include/TGrandRaidenHit.h | 7 +++++-- include/TRawEvent.h | 4 ++++ libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 2 +- .../TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx | 8 +++++--- libraries/TRawFormat/TRCNPSource.cxx | 13 ++++++------- libraries/TRawFormat/TRawEvent.cxx | 7 ++++++- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index 6a8c6c04..53f5fc1f 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -7,6 +7,7 @@ class TGrandRaidenHit : public TDetectorHit { public: TGrandRaidenHit(); + TGrandRaidenHit(void* ptr); ~TGrandRaidenHit(); virtual void Copy(TObject& obj) const; @@ -23,12 +24,14 @@ class TGrandRaidenHit : public TDetectorHit { //void SetADC(Int_t chan, const Double_t& val) { ADC[chan] = val; } Long_t Timestamp; - private: Double_t ADC[4]; Double_t RF; - ClassDef(TGrandRaidenHit,1); + + + void* fDataPtr; //! do not save + ClassDef(TGrandRaidenHit,1); }; diff --git a/include/TRawEvent.h b/include/TRawEvent.h index 522ac07e..332a671f 100644 --- a/include/TRawEvent.h +++ b/include/TRawEvent.h @@ -50,11 +50,15 @@ class TRawEvent : public TObject { void SetFragmentTimestamp(long timestamp) { fTimestamp = timestamp; } + void SetDataPtr(void* ptr) { fDataPtr = ptr; } + void* GetDataPtr() { return fDataPtr; } + protected: RawHeader fEventHeader; kFileType fFileType; long fTimestamp; TSmartBuffer fBody; + void* fDataPtr; ClassDef(TRawEvent,0) diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index e9b1ad1f..1a37cac3 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -24,7 +24,7 @@ void TGrandRaiden::InsertHit(const TDetectorHit& hit){ int TGrandRaiden::BuildHits(std::vector& raw_data){ for(auto& event : raw_data){ SetTimestamp(event.GetTimestamp()); - TGrandRaidenHit hit; + TGrandRaidenHit hit(event.GetDataPtr()); auto buf = event.GetBuffer(); hit.BuildFrom(buf); hit.SetTimestamp(event.GetTimestamp()); diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 9929bcea..951576e7 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -7,7 +7,10 @@ ClassImp(TGrandRaidenHit) -TGrandRaidenHit::TGrandRaidenHit() { +TGrandRaidenHit::TGrandRaidenHit() : fDataPtr(nullptr) { + memset(&ADC[0],0,sizeof(Double_t)); +} +TGrandRaidenHit::TGrandRaidenHit(void* ptr) : fDataPtr(ptr) { memset(&ADC[0],0,sizeof(Double_t)); } @@ -32,7 +35,7 @@ void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ // if (event) delete event; - auto event = *reinterpret_cast(const_cast(buf.GetData())); + auto event = reinterpret_cast(fDataPtr); auto adc = event->GR_ADC(); if (adc != nullptr) { std::copy(adc->begin(),adc->end(),&ADC[0]); @@ -42,7 +45,6 @@ void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ buf.Advance(sizeof(event)); if (event) delete event; - } diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index e98c584a..64eee248 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -21,6 +21,7 @@ TRCNPSource::TRCNPSource(const char* Command, kFileType file_type) } int TRCNPSource::GetEvent(TRawEvent& event) { + event.SetFileType(fFileType); // TRCNPEvent* rcnp_evt = new TRCNPEvent; RCNPEvent* rcnp;// = new RCNPEvent; @@ -55,13 +56,11 @@ int TRCNPSource::GetEvent(TRawEvent& event) { } - // event = *rcnp_evt; - event.SetFileType(fFileType); - - char* ptrbytes = (char*)calloc(1,sizeof(rcnp)); - *reinterpret_cast(ptrbytes) = rcnp; - auto eventbuffer = new TSmartBuffer(ptrbytes,sizeof(rcnp)); - event.SetData(*eventbuffer); + //char* ptrbytes = (char*)calloc(1,sizeof(rcnp)); + //*reinterpret_cast(ptrbytes) = rcnp; + //TSmartBuffer eventbuffer(ptrbytes,sizeof(rcnp)); + //event.SetData(eventbuffer); + event.SetDataPtr((void*)rcnp); // set the timestamp of the ttree event if (timestamps.size()==0) { diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index fd455894..659d29df 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -18,6 +18,7 @@ TRawEvent::TRawEvent() { fEventHeader.datum2 = 0; fFileType = kFileType::UNKNOWN_FILETYPE; fTimestamp = -1; + fDataPtr = nullptr; } void TRawEvent::Copy(TObject &rhs) const { @@ -25,7 +26,8 @@ void TRawEvent::Copy(TObject &rhs) const { ((TRawEvent&)rhs).fEventHeader = fEventHeader; ((TRawEvent&)rhs).fBody = fBody; ((TRawEvent&)rhs).fFileType = fFileType; - ((TRawEvent&)rhs).fTimestamp = fTimestamp; + ((TRawEvent&)rhs).fTimestamp = fTimestamp; + ((TRawEvent&)rhs).fDataPtr = fDataPtr; } TRawEvent::TRawEvent(const TRawEvent &rhs) @@ -46,6 +48,7 @@ TRawEvent &TRawEvent::operator=(const TRawEvent &rhs) { fBody = rhs.fBody; fFileType = rhs.fFileType; fTimestamp = rhs.fTimestamp; + fDataPtr = rhs.fDataPtr; return *this; } @@ -88,6 +91,8 @@ Int_t TRawEvent::GetBodySize() const { case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->size() + sizeof(Long_t); //Size in gretinadaq is exclusive, plus timestamp + case RCNP_BLD: + return sizeof(void*); default: return 0; From 085d425ce965333b11e21cda965fb49a46bb7c6c Mon Sep 17 00:00:00 2001 From: CAGRAGR RCNP User Date: Sun, 19 Jun 2016 22:59:12 +0900 Subject: [PATCH 07/28] Now RCNPEvent is carried through to the rootfile in TGrandRaidenHit. No copies are done, since the copy constructor of RCNPEvent performs a swap on it's underlying data map. Updated histograms loop to include GR histosgrams as discussed with Guillaume on 6/19. Since the RCNPEvent is saved with each hit, the output root tree can be sorted without rerunning the analyzer, which is useful for calibration steps. --- GRAnalyzer | 2 +- histos/MakeANLHistos.cxx | 69 ++++++++++-- include/TGrandRaidenHit.h | 44 ++++++-- .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 17 +-- .../TGrandRaiden/TGrandRaidenHit.cxx | 104 ++++++++---------- libraries/TRawFormat/TRCNPSource.cxx | 10 +- util/granalyzer.cxx | 6 +- 7 files changed, 151 insertions(+), 101 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index 57a0a3a5..d106a2bb 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 57a0a3a5de3fc2c86a2b90f2364bf737c4dab2af +Subproject commit d106a2bbc5286122336c62b2e88050df655c8493 diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 17fc34eb..26138bd8 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -56,9 +56,9 @@ void MakeHistograms(TRuntimeObjects& obj) { ncoin+=totalhits; //cout << "Coin: " << ncoin << endl; } else if (gr) { - for (auto& hit : *gr) { + //for (auto& hit : *gr) { //cout <<"Single GR: " << hit.Timestamp << endl; - } + //} } @@ -72,22 +72,66 @@ void MakeHistograms(TRuntimeObjects& obj) { if (gr) { for (auto& hit : *gr) { - auto adc = hit.GetADC(); - if (adc) { + + auto& rcnp = hit.GR(); + + + auto adc = rcnp.GR_ADC(); + + + + + if (rcnp.GR_ADC()) { + auto& adc = *rcnp.GR_ADC(); for (int i=0; i<4; i++) { stream.str(""); stream << "GR_ADC" << i; obj.FillHistogram(stream.str().c_str(), 1000,0,1000, adc[i]); } - auto rf = hit.GetRF(); - if (rf != BAD_NUM) { - obj.FillHistogram("GR_RF",1000,0,0,rf); - - auto first = TMath::Sqrt(adc[0]*adc[1]); - auto second = TMath::Sqrt(adc[2]*adc[3]); - obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first); - obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second); + obj.FillHistogram("MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram("MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2()); + } + if (rcnp.GR_TDC()) { + auto& tdc = *rcnp.GR_TDC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_TDC" << i; + obj.FillHistogram(stream.str().c_str(), 1000,-40000,40000, tdc[i]); } + obj.FillHistogram("MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1()); + obj.FillHistogram("MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2()); + } + if (rcnp.QTC_LEADING_TDC()) { + auto& qtc_leading = *rcnp.QTC_LEADING_TDC(); + auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH(); + + for (int i=0; i< qtc_leading_chan.size(); i++) { + int channum = qtc_leading_chan[i]; + stream.str(""); stream << "LaBrLeading" << channum; + obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + } + } + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth" << channum; + obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); } + obj.FillHistogram("RayID",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR_X",1200,-600,600, rcnp.GR_RAYID(0)); + obj.FillHistogram("GR_Y",200,-100,100, rcnp.GR_RAYID(0)); + obj.FillHistogram("GR_Theta",100,-1,1, rcnp.GR_RAYID(0)); // need to learn + obj.FillHistogram("GR_Phi",100,-1,1, rcnp.GR_RAYID(0)); // from hist.def + } + auto rf = rcnp.GR_RF(0); + if (rf != BAD_NUM) { + obj.FillHistogram("GR_RF",1000,0,0,rf); + } + + // obj.FillHistogram("GR_RF",1000,0,0,rf); + // auto first = TMath::Sqrt(adc[0]*adc[1]); + // auto second = TMath::Sqrt(adc[2]*adc[3]); + // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first); + // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second); + // } } } @@ -117,4 +161,5 @@ void MakeHistograms(TRuntimeObjects& obj) { if(numobj!=list->GetSize()) list->Sort(); + } diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index 53f5fc1f..ce7a6a37 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -3,11 +3,17 @@ #include "TDetector.h" #include "TDetectorHit.h" +#include "RCNPEvent.h" + +#include + +struct LaBrHit; class TGrandRaidenHit : public TDetectorHit { public: - TGrandRaidenHit(); - TGrandRaidenHit(void* ptr); + TGrandRaidenHit(); // TODO: move to private + TGrandRaidenHit(RCNPEvent& rcnpevent); + TGrandRaidenHit(const TGrandRaidenHit& gr); ~TGrandRaidenHit(); virtual void Copy(TObject& obj) const; @@ -15,24 +21,38 @@ class TGrandRaidenHit : public TDetectorHit { virtual void Print(Option_t *opt = "") const; virtual void Clear(Option_t *opt = ""); - void BuildFrom(TSmartBuffer& buf); + void BuildFrom(); - Double_t* GetADC() { return &ADC[0]; } - Double_t GetADC(const Int_t& i) const { return ADC[i]; } - const Double_t& GetRF() { return RF; } - //void SetADC(Int_t chan, const Double_t& val) { ADC[chan] = val; } - Long_t Timestamp; - private: - Double_t ADC[4]; - Double_t RF; + const std::vector& GetLaBr() { return labr_hits; } + const Double_t& GetMeanPlastE1() { return madc1; } + const Double_t& GetMeanPlastE2() { return madc2; } + const Double_t& GetMeanPlastPos1() { return tpos1; } + const Double_t& GetMeanPlastPos2() { return tpos2; } + const Long_t& GetTimestamp() { return Timestamp; } + RCNPEvent& GR() { return rcnp; } +private: + // Double_t ADC[4]; + // Double_t RF; + // Double_t QTCLead; + + std::vector labr_hits; + Double_t madc1; + Double_t madc2; + Double_t tpos1; + Double_t tpos2; + Long_t Timestamp; + RCNPEvent rcnp; - void* fDataPtr; //! do not save ClassDef(TGrandRaidenHit,1); }; +struct LaBrHit { + Int_t channel; + Double_t width; +}; #endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index 1a37cac3..f4508739 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -24,21 +24,12 @@ void TGrandRaiden::InsertHit(const TDetectorHit& hit){ int TGrandRaiden::BuildHits(std::vector& raw_data){ for(auto& event : raw_data){ SetTimestamp(event.GetTimestamp()); - TGrandRaidenHit hit(event.GetDataPtr()); - auto buf = event.GetBuffer(); - hit.BuildFrom(buf); + auto rcnp = reinterpret_cast(event.GetDataPtr()); + TGrandRaidenHit hit(*rcnp); + hit.BuildFrom(); hit.SetTimestamp(event.GetTimestamp()); InsertHit(hit); - - //auto rcnp_evt = (TRCNPEvent&)event; - //std::cout << std::hex << (long)rcnp_evt.event << std::endl; - //std::cin.get(); - // SetTimestamp(rcnp_evt.GetTimestamp()); - // TGrandRaidenHit hit; - // //auto buf = rcnp_evt.GetBuffer(); - // //hit.BuildFrom(buf); - // hit.SetTimestamp(rcnp_evt.GetTimestamp()); - // InsertHit(hit); + delete rcnp; } return Size(); } diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 951576e7..1e6838d2 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -1,50 +1,72 @@ -#ifdef RCNP #include "TGrandRaidenHit.h" #include "TGRUTOptions.h" #include "RCNPEvent.h" #include "TSmartBuffer.h" +#include "TMath.h" ClassImp(TGrandRaidenHit) -TGrandRaidenHit::TGrandRaidenHit() : fDataPtr(nullptr) { - memset(&ADC[0],0,sizeof(Double_t)); +TGrandRaidenHit::TGrandRaidenHit() { + madc1=0; madc2=0; tpos1=0; tpos2=0; } -TGrandRaidenHit::TGrandRaidenHit(void* ptr) : fDataPtr(ptr) { - memset(&ADC[0],0,sizeof(Double_t)); +TGrandRaidenHit::TGrandRaidenHit(const TGrandRaidenHit& gr) { + labr_hits = gr.labr_hits; + madc1 = gr.madc1; + madc2 = gr.madc2; + tpos1 = gr.tpos1; + tpos2 = gr.tpos2; + Timestamp = gr.Timestamp; + rcnp = gr.rcnp; +} +TGrandRaidenHit::TGrandRaidenHit(RCNPEvent& rcnpevent) : + rcnp(rcnpevent) { + madc1=0; madc2=0; tpos1=0; tpos2=0; } - TGrandRaidenHit::~TGrandRaidenHit() { - } - -void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ +void TGrandRaidenHit::BuildFrom(){ Clear(); + Timestamp = rcnp.GetTimestamp(); + + auto adc = rcnp.GR_ADC(); + auto tdc = rcnp.GR_TDC(); + + auto qtc_le_tdc = rcnp.QTC_LEADING_TDC(); + auto qtc_le_chan = rcnp.QTC_LEADING_CH(); + auto qtc_tr_tdc = rcnp.QTC_TRAILING_TDC(); + auto qtc_tr_chan = rcnp.QTC_TRAILING_CH(); + + if (qtc_le_tdc && qtc_tr_tdc) { + + for (auto i=0u; isize(); i++) { + for (auto j=0u; jsize(); j++) { + if ((*qtc_le_chan)[i]==(*qtc_tr_chan)[j]) { - // auto event = *reinterpret_cast(const_cast(buf.GetData())); - // auto adc = event->GR_ADC(); - // if (adc != nullptr) { - // std::copy(adc->begin(),adc->end(),&ADC[0]); - // } - // Timestamp = event->GetTimestamp(); - // RF = event->GR_RF(0); + LaBrHit temphit; + temphit.channel = (*qtc_le_chan)[i]; + temphit.width = (*qtc_le_tdc)[i] - (*qtc_tr_tdc)[j]; + labr_hits.push_back(temphit); - // buf.Advance(sizeof(event)); - // if (event) delete event; + //labr_hits.emplace_back({(*qtc_le_chan)[i],(*qtc_le_tdc)[i] - (*qtc_tr_tdc)[j]}); // =( + } + } + } + } - auto event = reinterpret_cast(fDataPtr); - auto adc = event->GR_ADC(); - if (adc != nullptr) { - std::copy(adc->begin(),adc->end(),&ADC[0]); + if (adc) { + madc1 = TMath::Sqrt((*adc)[0]*(*adc)[1]); + madc2 = TMath::Sqrt((*adc)[2]*(*adc)[3]); + } + if (tdc) { + tpos1 = TMath::Sqrt((*tdc)[0]*(*tdc)[1]); + tpos2 = TMath::Sqrt((*tdc)[2]*(*tdc)[3]); } - Timestamp = event->GetTimestamp(); - RF = event->GR_RF(0); - buf.Advance(sizeof(event)); - if (event) delete event; + } @@ -77,33 +99,3 @@ void TGrandRaidenHit::Clear(Option_t *opt) { - - -#else - - -#include "TGrandRaidenHit.h" - -ClassImp(TGrandRaidenHit) - -TGrandRaidenHit::TGrandRaidenHit() { - memset(&ADC[0],0,sizeof(Double_t)); -} - -TGrandRaidenHit::~TGrandRaidenHit() { ; } - -void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ - Clear(); -} - -void TGrandRaidenHit::Copy(TObject& obj) const { - TDetectorHit::Copy(obj); -} - -void TGrandRaidenHit::Print(Option_t *opt) const { ; } - -void TGrandRaidenHit::Clear(Option_t *opt) { - TDetectorHit::Clear(opt); -} - -#endif diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 64eee248..76502d50 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -100,14 +100,16 @@ void TRCNPSource::LoadFakeTimestamps() { //std::cout << ts << std::endl; } file.close(); + } else { + throw std::runtime_error("./timestamps.dat not found"); } } -template<> -int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { - return event.data.size(); -} +// template<> +// int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { +// return event.data.size(); +// } template<> int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) { diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index 0aa905b0..57ab1b4a 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -12,13 +12,13 @@ using namespace std; int main() { const char* filename = "./datatest/run6106.bld"; - ThreadsafeQueue gr_queue(500000); + ThreadsafeQueue gr_queue(500000); atomic sig(0); stringstream stream; stream.str(""); stream << "cat " << filename; std::thread grloop(StartGRAnalyzer,stream.str().c_str(),&sig,[&](RCNPEvent* event){ - gr_queue.Push(*event); + gr_queue.Push(event); },false); - RCNPEvent data; + RCNPEvent* data; static int count = 0; while (gr_queue.Pop(data,0)) { count++; From 0af3713cfd5fb3524198e993488ec28e1d9ca392 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 21 Jun 2016 12:01:21 +0900 Subject: [PATCH 08/28] Improved makefile to check the hist.def file and also added RCNP=1 to makefile. Also added runtime checkt that the hist.def file has not changed from when it was first compiled --- GRAnalyzer | 2 +- .../TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx | 5 +++++ libraries/TRawFormat/TRCNPSource.cxx | 15 ++++++++------- makefile | 10 ++++++---- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index d106a2bb..5f2226d1 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit d106a2bbc5286122336c62b2e88050df655c8493 +Subproject commit 5f2226d1cce95c7cdbaf7e210d25a059d3fa7f86 diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 1e6838d2..b870d361 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -27,6 +27,11 @@ TGrandRaidenHit::~TGrandRaidenHit() { } void TGrandRaidenHit::BuildFrom(){ + static bool once = true; + if (once) { + RCNPEvent::HistDefCheckSum(); + once = false; + } Clear(); Timestamp = rcnp.GetTimestamp(); diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 76502d50..9f9704b7 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -63,13 +63,14 @@ int TRCNPSource::GetEvent(TRawEvent& event) { event.SetDataPtr((void*)rcnp); // set the timestamp of the ttree event - if (timestamps.size()==0) { - std::cout << "End of time stamps" << std::endl; - return -1; - } - rcnp->SetTimestamp(timestamps.front()); - event.SetFragmentTimestamp(timestamps.front()); - timestamps.pop(); + // if (timestamps.size()==0) { + // std::cout << "End of time stamps" << std::endl; + // return -1; + // } + static Long_t counter = 0; + rcnp->SetTimestamp(counter); + event.SetFragmentTimestamp(counter); + counter+=1001; return sizeof(rcnp); } diff --git a/makefile b/makefile index e7b05956..b92bef1e 100644 --- a/makefile +++ b/makefile @@ -2,6 +2,8 @@ .SECONDARY: .SECONDEXPANSION: +RCNP=1 + PLATFORM:=$(PLATFORM) # EDIT THIS SECTION @@ -27,7 +29,7 @@ SHAREDSWITCH = -shared -Wl,-soname,# NO ENDING SPACE endif # When compiling and linking against RCNP analyzer routines -ifeq ($(RCNP),) +ifeq ($(RCNP),1) RCNPANAPATH = ./GRAnalyzer/analyzer RCNPANALYZER = $(realpath $(RCNPANAPATH)/../lib) RCNPFLAGS = -DRCNP @@ -103,10 +105,10 @@ docs: bin/%: util/% | bin @ln -sf ../$< $@ -bin/grutinizer: $(MAIN_O_FILES) | $(LIBRARY_OUTPUT) libGRAnalyzer bin +bin/grutinizer: $(MAIN_O_FILES) | $(LIBRARY_OUTPUT)bin $(call run_and_test,$(CPP) $^ -o $@ $(LINKFLAGS) $(RCNPLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) -bin/%: .build/util/%.o | $(LIBRARY_OUTPUT) libGRAnalyzer bin +bin/%: .build/util/%.o | $(LIBRARY_OUTPUT) bin $(call run_and_test,$(CPP) $< -o $@ $(LINKFLAGS) $(RCNPLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) bin: @@ -134,7 +136,7 @@ lib_dictionary = $(patsubst %/LinkDef.h,.build/%/LibDictionary.o,$(call lib_lin libraries/lib%.so: $$(call lib_o_files,%) $$(call lib_dictionary,%) $(call run_and_test,$(CPP) -fPIC $^ $(SHAREDSWITCH)lib$*.so $(ROOT_LIBFLAGS) -o $@,$@,$(BLD_COLOR),$(BLD_STRING),$(OBJ_COLOR) ) -.build/%.o: %.$(SRC_SUFFIX) +.build/%.o: %.$(SRC_SUFFIX) libGRAnalyzer @mkdir -p $(dir $@) $(call run_and_test,$(CPP) -fPIC -c $< -o $@ $(CFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) From dfc670ae3f05ebca720215fbbc521d7cdfce706b Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 00:55:11 +0900 Subject: [PATCH 09/28] Added MPIEventLoop submodule for parallel analysis. Also added fake timestamps back, added histo cut on gr_x. --- .gitmodules | 3 +++ MPIEventLoop | 1 + histos/MakeANLHistos.cxx | 6 ++++++ libraries/TRawFormat/TRCNPSource.cxx | 15 +++++++-------- 4 files changed, 17 insertions(+), 8 deletions(-) create mode 160000 MPIEventLoop diff --git a/.gitmodules b/.gitmodules index f9e620d6..ed0450da 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "GRAnalyzer"] path = GRAnalyzer url = git@github.com:CAGRA-GrandRaiden/GRAnalyzer.git +[submodule "MPIEventLoop"] + path = MPIEventLoop + url = git@github.com:csullivan/MPIEventLoop.git diff --git a/MPIEventLoop b/MPIEventLoop new file mode 160000 index 00000000..27f2e4c2 --- /dev/null +++ b/MPIEventLoop @@ -0,0 +1 @@ +Subproject commit 27f2e4c266423c9143acef01643ee8dc27f0107c diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 26138bd8..94aa7677 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -102,11 +102,17 @@ void MakeHistograms(TRuntimeObjects& obj) { if (rcnp.QTC_LEADING_TDC()) { auto& qtc_leading = *rcnp.QTC_LEADING_TDC(); auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH(); + auto x = rcnp.GR_X(0); for (int i=0; i< qtc_leading_chan.size(); i++) { int channum = qtc_leading_chan[i]; stream.str(""); stream << "LaBrLeading" << channum; obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + // gate on gr_x + if (x < 100 && x > 0) { + stream.str(""); stream << "LaBrLead"<< channum << "_GateX"; + obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + } } } for (auto const& labr_hit : hit.GetLaBr()) { diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 9f9704b7..76502d50 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -63,14 +63,13 @@ int TRCNPSource::GetEvent(TRawEvent& event) { event.SetDataPtr((void*)rcnp); // set the timestamp of the ttree event - // if (timestamps.size()==0) { - // std::cout << "End of time stamps" << std::endl; - // return -1; - // } - static Long_t counter = 0; - rcnp->SetTimestamp(counter); - event.SetFragmentTimestamp(counter); - counter+=1001; + if (timestamps.size()==0) { + std::cout << "End of time stamps" << std::endl; + return -1; + } + rcnp->SetTimestamp(timestamps.front()); + event.SetFragmentTimestamp(timestamps.front()); + timestamps.pop(); return sizeof(rcnp); } From 533f076ed1eddf3aef945542fa098c909c06f230 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 15:17:09 +0900 Subject: [PATCH 10/28] Fixed error in makefile, and added onlin.bld check to TRawEventSource::EventSource to start RCNP ana in online mode --- GRAnalyzer | 2 +- libraries/TRawFormat/TRawEventSource.cxx | 3 ++- makefile | 2 +- online.bld | 0 util/granalyzer.cxx | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 online.bld diff --git a/GRAnalyzer b/GRAnalyzer index 5f2226d1..5b98642e 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 5f2226d1cce95c7cdbaf7e210d25a059d3fa7f86 +Subproject commit 5b98642e350c5a94e8d5b2f13be6d5a6e54eac80 diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index c7330de4..4c5c81d9 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -95,7 +95,8 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type); } else if (hasSuffix(filename,".bld")){ std::string command; - if (is_online) { + if (string(filename) == "online.bld") { + std::cout << "Going online with TRCNPSource..." < gr_queue(500000); atomic sig(0); stringstream stream; stream.str(""); stream << "cat " << filename; From 9d24d7d06eaf56f774815a5f809a1fd406644333 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 19:14:40 +0900 Subject: [PATCH 11/28] Implemented new CFDv18. Untested --- include/TANLEvent.h | 1 + include/TRawBanks.h | 52 ++++++++++- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 26 +++++- libraries/TRawFormat/TRawBanks.cxx | 94 ++++++++++++++++++-- 4 files changed, 161 insertions(+), 12 deletions(-) diff --git a/include/TANLEvent.h b/include/TANLEvent.h index 43fabdb0..27037221 100644 --- a/include/TANLEvent.h +++ b/include/TANLEvent.h @@ -48,6 +48,7 @@ class TANLEvent : public TObject { ULong_t led_prev; + ULong_t cfd_prev; UInt_t flags; //UInt_t sampled_baseline; UInt_t prerise_energy; diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 65822a73..358bd4b7 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -281,9 +281,9 @@ enum ArgonneType { LEDv10, LEDv11, CFDv11, LEDv18, CFDv18 }; struct GEBArgonneHead { UShort_t GA_packetlength; UShort_t ud_channel; - UInt_t led_low; + UInt_t disc_low; UShort_t hdrlength_evttype_hdrtype; - UShort_t led_high; + UShort_t disc_high; UShort_t GetGA() const; UShort_t GetLength() const; UShort_t GetBoardID() const; @@ -291,7 +291,7 @@ struct GEBArgonneHead { UInt_t GetHeaderType() const; UShort_t GetEventType() const; UShort_t GetHeaderLength() const; - ULong_t GetLED() const; + ULong_t GetDisc() const; }__attribute__((__packed__)); friend std::ostream& operator<<(std::ostream& os, const GEBArgonneHead &header); @@ -382,12 +382,58 @@ struct GEBArgonneLEDv18 { UShort_t PileUpFlag() const; }__attribute__((__packed__)); +struct GEBArgonneCFDv18 { + UShort_t cfd_low_prev; + UShort_t flags; + Short_t cfd_sample0; // signed + UShort_t cfd_mid_prev; // bits 16:29 + UInt_t sampled_baseline; + Short_t cfd_sample2; + Short_t cfd_sample1; + UInt_t postrise_sum_low_prerise_sum; + UShort_t timestamp_peak_low; + UShort_t postrise_sum_high; + UShort_t timestamp_trigger_low; + UShort_t last_postrise_enter_sample; + UShort_t postrise_end_sample; + UShort_t postrise_begin_sample; + UShort_t prerise_end_sample; + UShort_t prerise_begin_sample; + UShort_t base_sample; + UShort_t peak_sample; + ULong_t GetPrevCFD(const GEBArgonneHead*) const; + UInt_t GetBaseline() const; + UInt_t GetPreRiseE() const; + UInt_t GetPostRiseE() const; + ULong_t GetTrigTimestamp() const; + UShort_t GetLastPostRiseEnterSample() const; + UShort_t GetPostRiseSampleBegin() const; + UShort_t GetPostRiseSampleEnd() const; + UShort_t GetPreRiseSampleBegin() const; + UShort_t GetPreRiseSampleEnd() const; + UShort_t GetBaseSample() const; + UShort_t GetPeakSample() const; + UShort_t WriteFlag() const; + UShort_t VetoFlag() const; + UShort_t TSMatchFlag() const; + UShort_t ExternalDiscFlag() const; + UShort_t PeakValidFlag() const; + UShort_t OffsetFlag() const; + UShort_t SyncErrorFlag() const; + UShort_t GeneralErrorFlag() const; + UShort_t PileUpOnlyFlag() const; + UShort_t PileUpFlag() const; +}__attribute__((__packed__)); + friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv11& data); static void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv18& data); static void SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data); +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv18& data); +static void SwapArgonneCFDv18(TRawEvent::GEBArgonneCFDv18& data); + struct GEBS800Header { Int_t total_size; UShort_t total_size2; diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index cb1c50e7..73c9254d 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -61,6 +61,9 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { break; } case TRawEvent::ArgonneType::LEDv18: { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer buf) :: ArgonneType::LEDv18 is not implemented."); + break; // auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); // buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); // // Swap big endian for little endian @@ -81,9 +84,30 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { break; } - case TRawEvent::ArgonneType::CFDv18: + case TRawEvent::ArgonneType::CFDv18: { + auto data = (TRawEvent::GEBArgonneCFDv18*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBArgonneCFDv18)); + // Swap big endian for little endian + TRawEvent::SwapArgonneCFDv18(*data); + // Extract data from payload + cfd = data->GetCFD0(); // this should be a function to interpolate the zero crossing + cfd_prev = data->GetPrevCFD(header); + flags = data->flags; + prerise_energy = data->GetPreRiseE(); + postrise_energy = data->GetPostRiseE(); + postrise_begin_sample = data->GetPostRiseSampleBegin(); + prerise_begin_sample = data->GetPreRiseSampleBegin(); + postrise_end_sample = data->GetPostRiseSampleEnd(); + prerise_end_sample = data->GetPreRiseSampleEnd(); + + // ignore waveform data + size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); + buf.Advance(wave_bytes); + + break; } + } } diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index f43c161f..45ee556c 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -136,7 +136,7 @@ UShort_t TRawEvent::GEBArgonneHead::GetChannel() const { return (ud_channel & 0x UInt_t TRawEvent::GEBArgonneHead::GetHeaderType() const { return (hdrlength_evttype_hdrtype & 0xf); } UShort_t TRawEvent::GEBArgonneHead::GetEventType() const { return ((hdrlength_evttype_hdrtype & 0x380) >> 7); } UShort_t TRawEvent::GEBArgonneHead::GetHeaderLength() const { return ((hdrlength_evttype_hdrtype & 0xfc00) >> 10); } -ULong_t TRawEvent::GEBArgonneHead::GetLED() const { return (((ULong_t)led_high) << 32) + ((ULong_t)led_low); } +ULong_t TRawEvent::GEBArgonneHead::GetDisc() const { return (((ULong_t)disc_high) << 32) + ((ULong_t)disc_low); } ULong_t TRawEvent::GEBArgonneLEDv11::GetPreviousLED() const { return (((ULong_t)led_high_prev) << 16) + ((ULong_t)led_low_prev); } UInt_t TRawEvent::GEBArgonneLEDv11::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } @@ -161,17 +161,14 @@ ULong_t TRawEvent::GEBArgonneLEDv18::GetPreviousLED() const { return (((ULong_t UInt_t TRawEvent::GEBArgonneLEDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } UInt_t TRawEvent::GEBArgonneLEDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } UInt_t TRawEvent::GEBArgonneLEDv18::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } -// New ULong_t TRawEvent::GEBArgonneLEDv18::GetTrigTimestamp() const { return ((ULong_t)timestamp_trigger_low) /*+ (((ULong_t)timestamp_trigger_high)<<16)*/; } // not fully implemented UShort_t TRawEvent::GEBArgonneLEDv18::GetLastPostRiseEnterSample() const { return (last_postrise_enter_sample & 0x3fff); } UShort_t TRawEvent::GEBArgonneLEDv18::GetLastPostRiseLeaveSample() const { return (last_postrise_leave_sample & 0x3fff); } UShort_t TRawEvent::GEBArgonneLEDv18::GetPostRiseLeaveSample() const { return (postrise_leave_sample & 0x3fff); } UShort_t TRawEvent::GEBArgonneLEDv18::GetPreRiseEnterSample() const { return (prerise_enter_sample & 0x3fff); } UShort_t TRawEvent::GEBArgonneLEDv18::GetPreRiseLeaveSample() const { return (prerise_leave_sample & 0x3fff); } - UShort_t TRawEvent::GEBArgonneLEDv18::GetBaseSample() const { return (base_sample & 0x3fff); } UShort_t TRawEvent::GEBArgonneLEDv18::GetPeakSample() const { return (peak_sample & 0x3fff); } - UShort_t TRawEvent::GEBArgonneLEDv18::WriteFlag() const { return ((flags & 0x20)>>5); } UShort_t TRawEvent::GEBArgonneLEDv18::VetoFlag() const { return ((flags & 0x40)>>6); } UShort_t TRawEvent::GEBArgonneLEDv18::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } @@ -182,12 +179,50 @@ UShort_t TRawEvent::GEBArgonneLEDv18::GeneralErrorFlag() const { return ((flags UShort_t TRawEvent::GEBArgonneLEDv18::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } UShort_t TRawEvent::GEBArgonneLEDv18::PileUpFlag() const { return ((flags & 0x8000)>>15); } + +//ULong_t TRawEvent::GEBArgonneCFDv18::GetPreviousCFD() const { return (((ULong_t)cfd_high_prev) << 16) + ((ULong_t)cfd_low_prev); } +Int_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return (cfd_sample0 & 0x3fff); } +ULong_t TRawEvent::GEBArgonneCFDv18::GetPrevCFD(const GEBArgonneHead* header) const { + if (TSMatchFlag() == 1) { + ULong_t current_cfd= header->GetDisc(); + return ((current_cfd & 0x00ffffc0000000) + (((ULong_t)(cfd_mid_prev & 0x3fff)) << 16) + (ULong_t)cfd_low_prev); + } else { + return 0xffffffffffffffff; + } +} +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return (cfd_sample0 & 0x3fff); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD1() const { return (cfd_sample1 & 0x3fff); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD2() const { return (cfd_sample2 & 0x3fff); } + +UInt_t TRawEvent::GEBArgonneCFDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } +UInt_t TRawEvent::GEBArgonneCFDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } +UInt_t TRawEvent::GEBArgonneCFDv18::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } +ULong_t TRawEvent::GEBArgonneCFDv18::GetTrigTimestamp() const { return ((ULong_t)timestamp_trigger_low) /*+ (((ULong_t)timestamp_trigger_high)<<16)*/; } // not fully implemented +UShort_t TRawEvent::GEBArgonneCFDv18::GetLastPostRiseEnterSample() const { return (last_postrise_enter_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPostRiseSampleBegin() const { return (postrise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPostRiseSampleEnd() const { return (postrise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPreRiseSampleBegin() const { return (prerise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPreRiseSampleEnd() const { return (prerise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetBaseSample() const { return (base_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::GetPeakSample() const { return (peak_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneCFDv18::WriteFlag() const { return ((flags & 0x20)>>5); } +UShort_t TRawEvent::GEBArgonneCFDv18::VetoFlag() const { return ((flags & 0x40)>>6); } +UShort_t TRawEvent::GEBArgonneCFDv18::TSMatchFlag() const { return ((flags & 0x80)>>7); } +UShort_t TRawEvent::GEBArgonneCFDv18::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } +UShort_t TRawEvent::GEBArgonneCFDv18::PeakValidFlag() const { return ((flags & 0x200)>>9); } +UShort_t TRawEvent::GEBArgonneCFDv18::OffsetFlag() const { return ((flags & 0x400)>>10); } +UShort_t TRawEvent::GEBArgonneCFDv18::CFDValidFlag() const { return ((flags & 0x800)>>11); } +UShort_t TRawEvent::GEBArgonneCFDv18::SyncErrorFlag() const { return ((flags & 0x1000)>>12); } +UShort_t TRawEvent::GEBArgonneCFDv18::GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } +UShort_t TRawEvent::GEBArgonneCFDv18::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } +UShort_t TRawEvent::GEBArgonneCFDv18::PileUpFlag() const { return ((flags & 0x8000)>>15); } + void TRawEvent::SwapArgonneHead(TRawEvent::GEBArgonneHead& header) { header.GA_packetlength = SwapShort(header.GA_packetlength); header.ud_channel = SwapShort(header.ud_channel); - header.led_low = SwapInt(header.led_low); + header.disc_low = SwapInt(header.disc_low); header.hdrlength_evttype_hdrtype = SwapShort(header.hdrlength_evttype_hdrtype); - header.led_high = SwapShort(header.led_high); + header.disc_high = SwapShort(header.disc_high); } void TRawEvent::SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data) { data.led_low_prev = SwapShort(data.led_low_prev); @@ -224,14 +259,35 @@ void TRawEvent::SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data) { data.peak_sample = SwapShort(data.peak_sample); } +void TRawEvent::SwapArgonneCFDv18(TRawEvent::GEBArgonneCFDv18& data) { + data.cfd_low_prev = SwapShort(data.cfd_low_prev); + data.flags = SwapShort(data.flags); + data.cfd_sample0 = SwapShort(data.cfd_sample0); + data.cfd_mid_prev = SwapShort(data.cfd_mid_prev); + data.sampled_baseline = SwapInt(data.sampled_baseline); + data.cfd_sample2 = SwapShort(data.cfd_sample2); + data.cfd_sample1 = SwapShort(data.cfd_sample1); + data.postrise_sum_low_prerise_sum = SwapInt(data.postrise_sum_low_prerise_sum); + data.timestamp_peak_low = SwapShort(data.timestamp_peak_low); + data.postrise_sum_high = SwapShort(data.postrise_sum_high); + data.timestamp_trigger_low = SwapShort(data.timestamp_trigger_low); + data.last_postrise_enter_sample = SwapShort(data.last_postrise_enter_sample); + data.postrise_end_sample = SwapShort(data.postrise_end_sample); + data.postrise_begin_sample = SwapShort(data.postrise_begin_sample); + data.prerise_end_sample = SwapShort(data.prerise_end_sample); + data.prerise_begin_sample = SwapShort(data.prerise_begin_sample); + data.base_sample = SwapShort(data.base_sample); + data.peak_sample = SwapShort(data.peak_sample); +} + #define STR(x) "\t GEBArgonne "<< #x <<": " << x std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneHead& header) { return os << "-- Argonne header packet -- \n" << STR(header.GA_packetlength) << "\n" << STR(header.ud_channel) << "\n" - << STR(header.led_low) << "\n" + << STR(header.disc_low) << "\n" << STR(header.hdrlength_evttype_hdrtype) << "\n" - << STR(header.led_high) << std::endl; + << STR(header.disc_high) << std::endl; } std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv11& data) { return os << "-- Argonne LEDv11 data packet --" @@ -270,6 +326,28 @@ std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv18& da << STR(data.base_sample) << "\n" << STR(data.peak_sample) << std::endl; } +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv18& data) { + return os << "-- Argonne CFDv18 data packet --" + + << STR(cfd_low_prev) << "\n" + << STR(flags) << "\n" + << STR(cfd_sample0) << "\n" + << STR(cfd_mid_prev) << "\n" + << STR(sampled_baseline) << "\n" + << STR(cfd_sample2) << "\n" + << STR(cfd_sample1) << "\n" + << STR(postrise_sum_low_prerise_sum) << "\n" + << STR(timestamp_peak_low) << "\n" + << STR(postrise_sum_high) << "\n" + << STR(timestamp_trigger_low) << "\n" + << STR(last_postrise_enter_sample) << "\n" + << STR(postrise_end_sample) << "\n" + << STR(postrise_begin_sample) << "\n" + << STR(prerise_end_sample) << "\n" + << STR(prerise_begin_sample) << "\n" + << STR(base_sample) << "\n" + << STR(peak_sample) << std::endl; +} #undef STR std::ostream& operator<<(std::ostream& os,const TRawEvent::GEBS800Header &head) { From e8ee7bb5cfc2cef393d79507a3743c2edf4ccfc3 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 19:27:26 +0900 Subject: [PATCH 12/28] Fixed compile time issues with name mixups between LEDv18 and CFDv18. --- include/TANLEvent.h | 14 ++----- include/TRawBanks.h | 6 ++- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 11 +++--- libraries/TRawFormat/TRawBanks.cxx | 39 ++++++++++---------- 4 files changed, 33 insertions(+), 37 deletions(-) diff --git a/include/TANLEvent.h b/include/TANLEvent.h index 27037221..02bc8989 100644 --- a/include/TANLEvent.h +++ b/include/TANLEvent.h @@ -11,15 +11,12 @@ class TANLEvent : public TObject { TANLEvent(TSmartBuffer& buf); ~TANLEvent(); - - - Long_t GetLED() const { return led; } - Long_t GetCFD() const { return cfd; } + Long_t GetDiscriminator() const { return discriminator; } Int_t GetPreE() const { return prerise_energy; } Int_t GetPostE() const { return postrise_energy; } UShort_t GetBoardID() const { return board_id; } UShort_t GetChannel() const { return channel; } - Long_t GetPrevLED() const { return led_prev; } + Long_t GetPrevDisc() const { return disc_prev; } UShort_t GetPostBegin() const { return postrise_begin_sample; } UShort_t GetPostEnd() const { return postrise_end_sample; } UShort_t GetPreBegin() const { return prerise_begin_sample; } @@ -43,12 +40,9 @@ class TANLEvent : public TObject { UShort_t global_addr; UShort_t board_id; UShort_t channel; - ULong_t led; - ULong_t cfd; - + ULong_t discriminator; - ULong_t led_prev; - ULong_t cfd_prev; + ULong_t disc_prev; UInt_t flags; //UInt_t sampled_baseline; UInt_t prerise_energy; diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 358bd4b7..8f6bc8cf 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -401,6 +401,9 @@ struct GEBArgonneCFDv18 { UShort_t prerise_begin_sample; UShort_t base_sample; UShort_t peak_sample; + Short_t GetCFD0() const; + Short_t GetCFD1() const; + Short_t GetCFD2() const; ULong_t GetPrevCFD(const GEBArgonneHead*) const; UInt_t GetBaseline() const; UInt_t GetPreRiseE() const; @@ -416,6 +419,7 @@ struct GEBArgonneCFDv18 { UShort_t WriteFlag() const; UShort_t VetoFlag() const; UShort_t TSMatchFlag() const; + UShort_t CFDValidFlag() const; UShort_t ExternalDiscFlag() const; UShort_t PeakValidFlag() const; UShort_t OffsetFlag() const; @@ -431,7 +435,7 @@ static void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv18& data); static void SwapArgonneLEDv18(TRawEvent::GEBArgonneLEDv18& data); -friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv18& data); +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneCFDv18& data); static void SwapArgonneCFDv18(TRawEvent::GEBArgonneCFDv18& data); struct GEBS800Header { diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index 73c9254d..a2085677 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -24,8 +24,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { global_addr = header->GetGA(); board_id = header->GetBoardID(); channel = header->GetChannel(); - led = header->GetLED(); - cfd = 0; + discriminator = header->GetDisc(); // Extract payload data. Two versions LED and CFD, with small changes for different FW versions switch( static_cast(header->GetHeaderType()) ) { @@ -40,7 +39,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { // Swap big endian for little endian TRawEvent::SwapArgonneLEDv11(*data); // Extract data from payload - led_prev = data->GetPreviousLED(); + disc_prev = data->GetPreviousLED(); flags = data->flags; prerise_energy = data->GetPreRiseE(); postrise_energy = data->GetPostRiseE(); @@ -69,7 +68,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { // // Swap big endian for little endian // TRawEvent::SwapArgonneLEDv11(*data); // // Extract data from payload - // led_prev = data->GetPreviousLED(); + // disc_prev = data->GetPreviousLED(); // flags = data->flags; // prerise_energy = data->GetPreRiseE(); // postrise_energy = data->GetPostRiseE(); @@ -90,8 +89,8 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { // Swap big endian for little endian TRawEvent::SwapArgonneCFDv18(*data); // Extract data from payload - cfd = data->GetCFD0(); // this should be a function to interpolate the zero crossing - cfd_prev = data->GetPrevCFD(header); + discriminator = data->GetCFD0(); // this should be a function to interpolate the zero crossing + disc_prev = data->GetPrevCFD(header); flags = data->flags; prerise_energy = data->GetPreRiseE(); postrise_energy = data->GetPostRiseE(); diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index 45ee556c..5d39aaec 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -181,7 +181,6 @@ UShort_t TRawEvent::GEBArgonneLEDv18::PileUpFlag() const { return ((flags & 0x80 //ULong_t TRawEvent::GEBArgonneCFDv18::GetPreviousCFD() const { return (((ULong_t)cfd_high_prev) << 16) + ((ULong_t)cfd_low_prev); } -Int_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return (cfd_sample0 & 0x3fff); } ULong_t TRawEvent::GEBArgonneCFDv18::GetPrevCFD(const GEBArgonneHead* header) const { if (TSMatchFlag() == 1) { ULong_t current_cfd= header->GetDisc(); @@ -326,27 +325,27 @@ std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv18& da << STR(data.base_sample) << "\n" << STR(data.peak_sample) << std::endl; } -std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneLEDv18& data) { +std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneCFDv18& data) { return os << "-- Argonne CFDv18 data packet --" - << STR(cfd_low_prev) << "\n" - << STR(flags) << "\n" - << STR(cfd_sample0) << "\n" - << STR(cfd_mid_prev) << "\n" - << STR(sampled_baseline) << "\n" - << STR(cfd_sample2) << "\n" - << STR(cfd_sample1) << "\n" - << STR(postrise_sum_low_prerise_sum) << "\n" - << STR(timestamp_peak_low) << "\n" - << STR(postrise_sum_high) << "\n" - << STR(timestamp_trigger_low) << "\n" - << STR(last_postrise_enter_sample) << "\n" - << STR(postrise_end_sample) << "\n" - << STR(postrise_begin_sample) << "\n" - << STR(prerise_end_sample) << "\n" - << STR(prerise_begin_sample) << "\n" - << STR(base_sample) << "\n" - << STR(peak_sample) << std::endl; + << STR(data.cfd_low_prev) << "\n" + << STR(data.flags) << "\n" + << STR(data.cfd_sample0) << "\n" + << STR(data.cfd_mid_prev) << "\n" + << STR(data.sampled_baseline) << "\n" + << STR(data.cfd_sample2) << "\n" + << STR(data.cfd_sample1) << "\n" + << STR(data.postrise_sum_low_prerise_sum) << "\n" + << STR(data.timestamp_peak_low) << "\n" + << STR(data.postrise_sum_high) << "\n" + << STR(data.timestamp_trigger_low) << "\n" + << STR(data.last_postrise_enter_sample) << "\n" + << STR(data.postrise_end_sample) << "\n" + << STR(data.postrise_begin_sample) << "\n" + << STR(data.prerise_end_sample) << "\n" + << STR(data.prerise_begin_sample) << "\n" + << STR(data.base_sample) << "\n" + << STR(data.peak_sample) << std::endl; } #undef STR From 500723d9b94d0c785e755c190f2e4bcaf22d2566 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 21:21:35 +0900 Subject: [PATCH 13/28] CFDv1.8 seems to be working, but need more rigourous checks, mainly with data --- config/rcnpchannels.cal | 251 +++++++++++++++++++++++++++++++++------ histos/MakeANLHistos.cxx | 5 +- util/simpleread_anl.cxx | 4 +- 3 files changed, 223 insertions(+), 37 deletions(-) diff --git a/config/rcnpchannels.cal b/config/rcnpchannels.cal index 77103536..23e9c6dc 100644 --- a/config/rcnpchannels.cal +++ b/config/rcnpchannels.cal @@ -1,68 +1,251 @@ -// Central contacts - -CLO01AP00 { - Address: 0x01007100 - EnergyCoeff: -11.571 1.38547587 -} - -CLO01BP00 { - Address: 0x01007101 - EnergyCoeff: -15.376 1.16580939 -} - -CLO01CP00 { - Address: 0x01007102 - EnergyCoeff: -17.096 1.20797241 -} - -CLO01DP00 { - Address: 0x01007103 - EnergyCoeff: -16.151 1.06947565 -} - - // Other channels - +EXT00AP00 { + Address: 0x01006500 + EnergyCoeff: 0 1 +} EXT01AP00 { - Address: 0x01007200 + Address: 0x01006501 EnergyCoeff: 0 1 } EXT02AP00 { - Address: 0x01007201 + Address: 0x01006502 EnergyCoeff: 0 1 } EXT03AP00 { - Address: 0x01007202 + Address: 0x01006503 EnergyCoeff: 0 1 } EXT04AP00 { - Address: 0x01007203 + Address: 0x01006504 EnergyCoeff: 0 1 } - EXT05AP00 { - Address: 0x01007300 + Address: 0x01006505 EnergyCoeff: 0 1 } EXT06AP00 { - Address: 0x01007301 + Address: 0x01006506 EnergyCoeff: 0 1 } EXT07AP00 { - Address: 0x01007302 + Address: 0x01006507 EnergyCoeff: 0 1 } EXT08AP00 { - Address: 0x01007303 + Address: 0x01006508 EnergyCoeff: 0 1 } EXT09AP00 { - Address: 0x01007304 + Address: 0x01006509 + EnergyCoeff: 0 1 +} +EXT10AP00 { + Address: 0x01006600 + EnergyCoeff: 0 1 +} +EXT11AP00 { + Address: 0x01006601 + EnergyCoeff: 0 1 +} +EXT12AP00 { + Address: 0x01006602 + EnergyCoeff: 0 1 +} +EXT13AP00 { + Address: 0x01006603 + EnergyCoeff: 0 1 +} +EXT14AP00 { + Address: 0x01006604 + EnergyCoeff: 0 1 +} +EXT15AP00 { + Address: 0x01006605 + EnergyCoeff: 0 1 +} +EXT16AP00 { + Address: 0x01006606 + EnergyCoeff: 0 1 +} +EXT17AP00 { + Address: 0x01006607 + EnergyCoeff: 0 1 +} +EXT18AP00 { + Address: 0x01006608 + EnergyCoeff: 0 1 +} +EXT19AP00 { + Address: 0x01006609 + EnergyCoeff: 0 1 +} +EXT20AP00 { + Address: 0x01006700 + EnergyCoeff: 0 1 +} +EXT21AP00 { + Address: 0x01006701 + EnergyCoeff: 0 1 +} +EXT22AP00 { + Address: 0x01006702 + EnergyCoeff: 0 1 +} +EXT23AP00 { + Address: 0x01006703 + EnergyCoeff: 0 1 +} +EXT24AP00 { + Address: 0x01006704 + EnergyCoeff: 0 1 +} +EXT25AP00 { + Address: 0x01006705 + EnergyCoeff: 0 1 +} +EXT26AP00 { + Address: 0x01006706 + EnergyCoeff: 0 1 +} +EXT27AP00 { + Address: 0x01006707 + EnergyCoeff: 0 1 +} +EXT28AP00 { + Address: 0x01006708 + EnergyCoeff: 0 1 +} +EXT29AP00 { + Address: 0x01006709 + EnergyCoeff: 0 1 +} +EXT30AP00 { + Address: 0x01006800 + EnergyCoeff: 0 1 +} +EXT31AP00 { + Address: 0x01006801 + EnergyCoeff: 0 1 +} +EXT32AP00 { + Address: 0x01006802 + EnergyCoeff: 0 1 +} +EXT33AP00 { + Address: 0x01006803 + EnergyCoeff: 0 1 +} +EXT34AP00 { + Address: 0x01006804 + EnergyCoeff: 0 1 +} +EXT35AP00 { + Address: 0x01006805 + EnergyCoeff: 0 1 +} +EXT36AP00 { + Address: 0x01006806 + EnergyCoeff: 0 1 +} +EXT37AP00 { + Address: 0x01006807 + EnergyCoeff: 0 1 +} +EXT38AP00 { + Address: 0x01006808 + EnergyCoeff: 0 1 +} +EXT39AP00 { + Address: 0x01006809 EnergyCoeff: 0 1 } +// // Central contacts + +// CLO01AP00 { +// Address: 0x01006500 +// EnergyCoeff: 0 1 +// } + +// CLO01BP00 { +// Address: 0x01006501 +// EnergyCoeff: 0 1 +// } + +// CLO01CP00 { +// Address: 0x01006502 +// EnergyCoeff: 0 1 +// } + +// CLO01DP00 { +// Address: 0x01006503 +// EnergyCoeff: 0 1 +// } + +// CLO01EP00 { +// Address: 0x01006504 +// EnergyCoeff: 0 1 +// } + +// // left +// CLO01AN01 { +// Address: 0x01006505 +// EnergyCoeff: 0 1 +// } + +// // center +// CLO01AN02 { +// Address: 0x01006506 +// EnergyCoeff: 0 1 +// } + +// //right +// CLO01AN03 { +// Address: 0x01006507 +// EnergyCoeff: 0 1 +// } + +// EXT11AP00 { +// Address: 0x01607200 +// EnergyCoeff: 0 1 +// } +// EXT02AP00 { +// Address: 0x01007201 +// EnergyCoeff: 0 1 +// } +// EXT03AP00 { +// Address: 0x01007202 +// EnergyCoeff: 0 1 +// } +// EXT04AP00 { +// Address: 0x01007203 +// EnergyCoeff: 0 1 +// } + +// EXT05AP00 { +// Address: 0x01007300 +// EnergyCoeff: 0 1 +// } +// EXT06AP00 { +// Address: 0x01007301 +// EnergyCoeff: 0 1 +// } +// EXT07AP00 { +// Address: 0x01007302 +// EnergyCoeff: 0 1 +// } +// EXT08AP00 { +// Address: 0x01007303 +// EnergyCoeff: 0 1 +// } +// EXT09AP00 { +// Address: 0x01007304 +// EnergyCoeff: 0 1 +// } + + // // Segments diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 94aa7677..4a1a653c 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -151,7 +151,10 @@ void MakeHistograms(TRuntimeObjects& obj) { stream << "PostE_BoardID" << hit.GetBoardID() << "_Chan" << hit.GetChannel(); obj.FillHistogram(stream.str(),10000,0,0,hit.Charge()); - if (hit.GetBoardID() == 0x71) { + obj.FillHistogram("DigitizerHits",4,101,104,hit.GetBoardID(),10,0,9,hit.GetChannel()); + //cout << hit.GetBoardID() << " " << hit.GetChannel() << endl; + + if (hit.GetBoardID() == 0x65) { stream.str(""); stream << "Leaf" << hit.GetChannel(); diff --git a/util/simpleread_anl.cxx b/util/simpleread_anl.cxx index 2d782299..6aa7c2fb 100644 --- a/util/simpleread_anl.cxx +++ b/util/simpleread_anl.cxx @@ -148,8 +148,8 @@ int main (int argc, char **argv) { //if (nevents>10) break; auto head = (GEB_HEADER*)header; - //cout << head->length << endl; - //cin.get(); + cout << head->length << endl; + cin.get(); datasize = head->length; if (fread(payload,datasize,1,fd) == 1) { From 7e894039c9062c7101efb600b2440adf98c3f285 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 23:01:51 +0900 Subject: [PATCH 14/28] Updated DigitizerHits histogram. New firmware looks pretty good. Need test with detector and calibration. --- histos/MakeANLHistos.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 4a1a653c..5b2d7aba 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -151,7 +151,7 @@ void MakeHistograms(TRuntimeObjects& obj) { stream << "PostE_BoardID" << hit.GetBoardID() << "_Chan" << hit.GetChannel(); obj.FillHistogram(stream.str(),10000,0,0,hit.Charge()); - obj.FillHistogram("DigitizerHits",4,101,104,hit.GetBoardID(),10,0,9,hit.GetChannel()); + obj.FillHistogram("DigitizerHits",12,97,109,hit.GetBoardID(),12,-1,11,hit.GetChannel()); //cout << hit.GetBoardID() << " " << hit.GetChannel() << endl; if (hit.GetBoardID() == 0x65) { From 944720e6423fd167150737a29769de4d90a8c79d Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 11:33:47 +0900 Subject: [PATCH 15/28] Now export the discriminator time to TCagraHit. Need to export previous time too for time difference between events. --- histos/MakeANLHistos.cxx | 3 ++- include/TCagraHit.h | 4 +++- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 4 +++- libraries/TDetSystems/TArgonne/TCagra.cxx | 1 + libraries/TRawFormat/TRawBanks.cxx | 7 ++++--- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 5b2d7aba..735183d2 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -146,7 +146,8 @@ void MakeHistograms(TRuntimeObjects& obj) { //cout << "Size: " << cagra->Size() << endl; for (auto& hit : *cagra) { - //cout << hit.Timestamp() << endl; + //cout << hit.Timestamp() << " " << hit.GetDiscTime() << endl; + stream.str(""); stream << "PostE_BoardID" << hit.GetBoardID() << "_Chan" << hit.GetChannel(); obj.FillHistogram(stream.str(),10000,0,0,hit.Charge()); diff --git a/include/TCagraHit.h b/include/TCagraHit.h index 3333173b..ccac293f 100644 --- a/include/TCagraHit.h +++ b/include/TCagraHit.h @@ -43,10 +43,12 @@ class TCagraHit : public TDetectorHit { const TVector3& particle_vec = TVector3(0,0,1), const TVector3& cagra_offset = TVector3(0,0,0)) const; + void SetDiscTime(const ULong_t t) { time = t; } + ULong_t GetDiscTime() { return time; } private: std::vector fSegments; - + ULong_t time; ClassDef(TCagraHit,1); }; diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index a2085677..01187e9b 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -89,7 +89,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { // Swap big endian for little endian TRawEvent::SwapArgonneCFDv18(*data); // Extract data from payload - discriminator = data->GetCFD0(); // this should be a function to interpolate the zero crossing + //discriminator = data->GetCFD0(); // this should be a function to interpolate the zero crossing disc_prev = data->GetPrevCFD(header); flags = data->flags; prerise_energy = data->GetPreRiseE(); @@ -99,6 +99,8 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { postrise_end_sample = data->GetPostRiseSampleEnd(); prerise_end_sample = data->GetPreRiseSampleEnd(); + //std:: cout << data->GetCFD0() << " " << data->GetCFD1() << " " << data->GetCFD2() << std::endl; + // ignore waveform data size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); buf.Advance(wave_bytes); diff --git a/libraries/TDetSystems/TArgonne/TCagra.cxx b/libraries/TDetSystems/TArgonne/TCagra.cxx index 6beded5f..3e7ad3de 100644 --- a/libraries/TDetSystems/TArgonne/TCagra.cxx +++ b/libraries/TDetSystems/TArgonne/TCagra.cxx @@ -81,6 +81,7 @@ int TCagra::BuildHits(std::vector& raw_data){ if(segnum==0){ hit->SetAddress(address); hit->SetTimestamp(event.GetTimestamp()); + hit->SetDiscTime(anl.GetDiscriminator()); hit->SetCharge(anl.GetEnergy()); } else { TCagraSegmentHit& seg = hit->MakeSegmentByAddress(address); diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index 5d39aaec..e30efa36 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -189,9 +189,10 @@ ULong_t TRawEvent::GEBArgonneCFDv18::GetPrevCFD(const GEBArgonneHead* header) c return 0xffffffffffffffff; } } -Short_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return (cfd_sample0 & 0x3fff); } -Short_t TRawEvent::GEBArgonneCFDv18::GetCFD1() const { return (cfd_sample1 & 0x3fff); } -Short_t TRawEvent::GEBArgonneCFDv18::GetCFD2() const { return (cfd_sample2 & 0x3fff); } + +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return (cfd_sample0 & 0x3fff); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD1() const { return (cfd_sample1 & 0x3fff); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD2() const { return (cfd_sample2 & 0x3fff); } UInt_t TRawEvent::GEBArgonneCFDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } UInt_t TRawEvent::GEBArgonneCFDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } From d4183c6d4251ad341d769818c85c5477759bebe0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 13:20:15 +0900 Subject: [PATCH 16/28] Started to implement pole zero and asymptotic baseline corrections. Needs more work. --- include/TCagraHit.h | 2 ++ libraries/TDetSystems/TArgonne/TCagraHit.cxx | 14 ++++++++++++++ libraries/TGRUTUtil/TChannel.cxx | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/include/TCagraHit.h b/include/TCagraHit.h index ccac293f..49de2640 100644 --- a/include/TCagraHit.h +++ b/include/TCagraHit.h @@ -45,6 +45,8 @@ class TCagraHit : public TDetectorHit { void SetDiscTime(const ULong_t t) { time = t; } ULong_t GetDiscTime() { return time; } + double GetBLCorrectedE() const; + private: std::vector fSegments; diff --git a/libraries/TDetSystems/TArgonne/TCagraHit.cxx b/libraries/TDetSystems/TArgonne/TCagraHit.cxx index 75403ceb..0829e9fb 100644 --- a/libraries/TDetSystems/TArgonne/TCagraHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCagraHit.cxx @@ -6,6 +6,7 @@ #include #include "TString.h" +#include "TRandom.h" #include "GCanvas.h" #include "GValue.h" @@ -139,3 +140,16 @@ Int_t TCagraHit::Charge() const { return fCharge; } } + +double TCagraHit::GetBLCorrectedE() const { + if(!std::isnan(fEnergy)) + return fEnergy; + TChannel* chan = TChannel::GetChannel(fAddress); + if(!chan){ + fEnergy = Charge() + gRandom->Uniform(); + //return Charge() + gRandom->Uniform(); + } else { + fEnergy = chan->CalEnergy(Charge(), fTimestamp); + } + return fEnergy; +} diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index 5916a717..3705b06f 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -545,6 +545,10 @@ int TChannel::ParseInputData(std::string &input,Option_t *opt) { channel->SetEnergyCoeff(ParseListOfDoubles(ss), ParseStartTime(type)); + } else if(type.find("POLEZERO")==0) { + //channel->SetEnergyCoeff(ParseListOfDoubles(ss), + //ParseStartTime(type)); + } else if(type == "PEDESTAL") { int val = 0; ss >> val; channel->SetPedestal(val); From bffd05fd61979ae1dd0a242401935698a0a97391 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 14:38:29 +0900 Subject: [PATCH 17/28] Removed fake timestamp routine as we now have the myriad clock in GR --- GRAnalyzer | 2 +- include/TRCNPSource.h | 4 +-- libraries/TRawFormat/TRCNPSource.cxx | 39 +++++----------------------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index 5b98642e..5743b280 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 5b98642e350c5a94e8d5b2f13be6d5a6e54eac80 +Subproject commit 5743b280eaf9e9a00fa7dcd07d159f6e30faf037 diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h index c39c3a83..7668de44 100644 --- a/include/TRCNPSource.h +++ b/include/TRCNPSource.h @@ -39,7 +39,7 @@ class TRCNPSource : public TRawEventSource { protected: void SetFileSize(long file_size) { fFileSize = file_size; } - void LoadFakeTimestamps(); + //void LoadFakeTimestamps(); private: TRCNPSource() {;} @@ -53,7 +53,7 @@ class TRCNPSource : public TRawEventSource { #endif ThreadsafeQueue rcnp_queue; - std::queue timestamps; + //std::queue timestamps; ClassDef(TRCNPSource,0); }; diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 76502d50..976199ea 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -17,7 +17,8 @@ TRCNPSource::TRCNPSource(const char* Command, kFileType file_type) }, TGRUTOptions::Get()->SaveRCNPTree()); - LoadFakeTimestamps(); + //LoadFakeTimestamps(); + std::this_thread::sleep_for(std::chrono::seconds(4)); } int TRCNPSource::GetEvent(TRawEvent& event) { @@ -60,17 +61,13 @@ int TRCNPSource::GetEvent(TRawEvent& event) { //*reinterpret_cast(ptrbytes) = rcnp; //TSmartBuffer eventbuffer(ptrbytes,sizeof(rcnp)); //event.SetData(eventbuffer); - event.SetDataPtr((void*)rcnp); - // set the timestamp of the ttree event - if (timestamps.size()==0) { - std::cout << "End of time stamps" << std::endl; - return -1; - } - rcnp->SetTimestamp(timestamps.front()); - event.SetFragmentTimestamp(timestamps.front()); - timestamps.pop(); + event.SetDataPtr((void*)rcnp); + double time = rcnp->GR_MYRIAD(0); + if (time == -441441) { time = 11; } + rcnp->SetTimestamp(time); + event.SetFragmentTimestamp(time); return sizeof(rcnp); } @@ -84,28 +81,6 @@ std::string TRCNPSource::Status() const { std::string TRCNPSource::SourceDescription() const {return "File: "+std::string("RCNP_BLD: ")+fCommand;} -void TRCNPSource::LoadFakeTimestamps() { - - std::string line; std::stringstream stream; ULong_t ts; - ifstream file ("./timestamps.dat"); - if (file.is_open()) - { - while ( getline (file,line) ) - { - stream << line; - stream >> ts; - timestamps.push(ts); - stream.str(""); - stream.clear(); - //std::cout << ts << std::endl; - } - file.close(); - } else { - throw std::runtime_error("./timestamps.dat not found"); - } -} - - // template<> // int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { // return event.data.size(); From f09d65135eaf56d10dcd406649bd1be3d0e9eca4 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 19:31:51 +0900 Subject: [PATCH 18/28] Added fast-forward flag and functionality, which will fast-forward to the end of online raw input files. (enabled with -F) This functionality is nice when you are in online mode (-g) and you want to skip to the end of a file to view only the newest data as it comes. --- GRAnalyzer | 2 +- include/TGRUTOptions.h | 4 +++- include/TRawSource.h | 3 +++ libraries/TGRUTint/TGRUTOptions.cxx | 3 +++ libraries/TRawFormat/TRawEventFileSource.cxx | 8 ++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index 5743b280..36a72ae9 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 5743b280eaf9e9a00fa7dcd07d159f6e30faf037 +Subproject commit 36a72ae906cda33e7ff13840181e3d4d9b897a22 diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index e53c845c..02d91199 100644 --- a/include/TGRUTOptions.h +++ b/include/TGRUTOptions.h @@ -47,6 +47,8 @@ class TGRUTOptions : public TObject { bool SortMultiple() const { return fSortMultiple; } bool TreeSource() const { return fTreeSource; } bool SaveRCNPTree() const { return fSaveRCNPTree; } + bool FastForwardRawFile() const { return fFastForwardRaw; } + bool IsOnline() const { return fIsOnline; } @@ -105,7 +107,7 @@ class TGRUTOptions : public TObject { int fBuildWindow; bool fShouldExit; - + bool fFastForwardRaw; bool fSaveRCNPTree; ClassDef(TGRUTOptions,0); diff --git a/include/TRawSource.h b/include/TRawSource.h index 5746ea9d..bc277c2f 100644 --- a/include/TRawSource.h +++ b/include/TRawSource.h @@ -193,7 +193,10 @@ class TRawEventFileSource : public TRawEventByteSource { virtual void Reset(); virtual std::string SourceDescription() const; + private: + void FastForward(); + std::string fFilename; FILE* fFile; diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index 89dd3760..849d38e2 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -130,6 +130,9 @@ void TGRUTOptions::Load(int argc, char** argv) { parser.option("g start-gui",&fStartGui) .description("Start the GUI") .default_value(false); + parser.option("F fast-forward",&fFastForwardRaw) + .description("Seek to the end of all raw files that are added so as to read freshly saved data in online mode.") + .default_value(false); parser.option("w gretina-waves",&fExtractWaves) .description("Extract wave forms to data class when available.") .default_value(false); diff --git a/libraries/TRawFormat/TRawEventFileSource.cxx b/libraries/TRawFormat/TRawEventFileSource.cxx index 009ee059..cda7dc8d 100644 --- a/libraries/TRawFormat/TRawEventFileSource.cxx +++ b/libraries/TRawFormat/TRawEventFileSource.cxx @@ -6,6 +6,10 @@ TRawEventFileSource::TRawEventFileSource(const std::string& filename, kFileType : TRawEventByteSource(file_type), fFilename(filename) { fFile = fopen(filename.c_str(),"rb"); SetFileSize(FindFileSize(filename.c_str())); + + if (TGRUTOptions::Get()->FastForwardRawFile() && TGRUTOptions::Get()->StartGUI()) { + FastForward(); + } } TRawEventFileSource::~TRawEventFileSource() { @@ -17,6 +21,10 @@ void TRawEventFileSource::Reset() { fseek(fFile, 0, SEEK_SET); } +void TRawEventFileSource::FastForward() { + fseek(fFile, 0, SEEK_END); +} + int TRawEventFileSource::ReadBytes(char* buf, size_t size){ size_t output = fread(buf, 1, size, fFile); if(output != size){ From 6f4e64aed4412ecd933fe2aa758cd82de3395bb4 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 27 Jun 2016 00:48:18 +0900 Subject: [PATCH 19/28] Added TGlobRawFile which looks in a directory for new files and attaches to them as they appears. --- include/TGlobRawFile.h | 52 +++++++++++++++++++++++++++ libraries/TRawFormat/TGlobRawFile.cxx | 45 +++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 include/TGlobRawFile.h create mode 100644 libraries/TRawFormat/TGlobRawFile.cxx diff --git a/include/TGlobRawFile.h b/include/TGlobRawFile.h new file mode 100644 index 00000000..a409c110 --- /dev/null +++ b/include/TGlobRawFile.h @@ -0,0 +1,52 @@ +#ifndef _TGLOBRAWFILE_H_ +#define _TGLOBRAWFILE_H_ + +#ifndef __CINT__ +#include +#endif + +#include + +#include "TRawSource.h" +#include "TMultiRawFile.h" + +class TGlobRawFile : public TRawEventSource { +public: + TGlobRawFile(std::string pattern); + + virtual std::string SourceDescription(bool long_description=false) const { + return fWrapped.SourceDescription(long_description); + } + virtual std::string Status(bool long_description = false) const { + return fWrapped.Status(long_description); + } + + virtual int GetLastErrno() const { return fWrapped.GetLastErrno(); } + virtual std::string GetLastError() const { return fWrapped.GetLastError(); } + + virtual void Reset() { + TRawEventSource::Reset(); + fWrapped.Reset(); + } + + +private: + virtual int GetEvent(TRawEvent& outevent) { + CheckForFiles(); + return fWrapped.Read(outevent); + } + + void CheckForFiles(); + + std::string fPattern; + std::set fFilesAdded; +#ifndef __CINT__ + std::chrono::system_clock::time_point fPreviousCheck; +#endif + + TMultiRawFile fWrapped; + + ClassDef(TGlobRawFile, 0); +}; + +#endif /* _TGLOBRAWFILE_H_ */ diff --git a/libraries/TRawFormat/TGlobRawFile.cxx b/libraries/TRawFormat/TGlobRawFile.cxx new file mode 100644 index 00000000..fab894b2 --- /dev/null +++ b/libraries/TRawFormat/TGlobRawFile.cxx @@ -0,0 +1,45 @@ +#include "TGlobRawFile.h" + +#include + +namespace { + // From http://stackoverflow.com/a/8615450/2689797 + std::vector glob(const std::string& pattern) { + glob_t glob_result; + glob(pattern.c_str(), GLOB_TILDE, NULL, &glob_result); + + std::vector output; + for(unsigned int i=0; i time_between_checks) { + return; + } + + for(auto& filename : glob(fPattern)) { + if(fFilesAdded.count(filename) == 0) { + auto new_file = TRawEventSource::EventSource(filename.c_str()); + fWrapped.AddFile(new_file); + fFilesAdded.insert(filename); + } + } + + + fPreviousCheck = now; +} From a01cb3ef0e35e179a9e8e1a283a86b65eaf7476f Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 27 Jun 2016 01:25:32 +0900 Subject: [PATCH 20/28] Updated GRUTinizer options to utilize TGlobRawFile. --- include/TGRUTOptions.h | 2 ++ include/TGlobRawFile.h | 10 ++++++---- libraries/TGRUTint/TGRUTOptions.cxx | 3 +++ libraries/TGRUTint/TGRUTint.cxx | 7 +++++++ libraries/TRawFormat/LinkDef.h | 3 ++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index 02d91199..2db88079 100644 --- a/include/TGRUTOptions.h +++ b/include/TGRUTOptions.h @@ -45,6 +45,7 @@ class TGRUTOptions : public TObject { bool StartGUI() const { return fStartGui; } bool MakeHistos() const { return fMakeHistos; } bool SortMultiple() const { return fSortMultiple; } + std::string SortMultipleGlob() const { return fGlobRaw; } bool TreeSource() const { return fTreeSource; } bool SaveRCNPTree() const { return fSaveRCNPTree; } bool FastForwardRawFile() const { return fFastForwardRaw; } @@ -109,6 +110,7 @@ class TGRUTOptions : public TObject { bool fFastForwardRaw; bool fSaveRCNPTree; + std::string fGlobRaw; ClassDef(TGRUTOptions,0); }; diff --git a/include/TGlobRawFile.h b/include/TGlobRawFile.h index a409c110..d2be5a78 100644 --- a/include/TGlobRawFile.h +++ b/include/TGlobRawFile.h @@ -13,12 +13,14 @@ class TGlobRawFile : public TRawEventSource { public: TGlobRawFile(std::string pattern); + virtual ~TGlobRawFile(){;} - virtual std::string SourceDescription(bool long_description=false) const { - return fWrapped.SourceDescription(long_description); + + virtual std::string SourceDescription() const { + return fWrapped.SourceDescription(); } - virtual std::string Status(bool long_description = false) const { - return fWrapped.Status(long_description); + virtual std::string Status() const { + return fWrapped.Status(); } virtual int GetLastErrno() const { return fWrapped.GetLastErrno(); } diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index 849d38e2..500331f0 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -130,6 +130,9 @@ void TGRUTOptions::Load(int argc, char** argv) { parser.option("g start-gui",&fStartGui) .description("Start the GUI") .default_value(false); + parser.option("G glob-raw",&fGlobRaw) + .description("Open files according to a pattern and continuously look for new files.") + .default_value(""); parser.option("F fast-forward",&fFastForwardRaw) .description("Seek to the end of all raw files that are added so as to read freshly saved data in online mode.") .default_value(false); diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx index 26af2278..5635c774 100644 --- a/libraries/TGRUTint/TGRUTint.cxx +++ b/libraries/TGRUTint/TGRUTint.cxx @@ -32,6 +32,7 @@ #include "TOrderedRawFile.h" #include "TRawSource.h" #include "TMultiRawFile.h" +#include "TGlobRawFile.h" #include "TSequentialRawFile.h" #include "GrutNotifier.h" @@ -241,6 +242,12 @@ void TGRUTint::ApplyOptions() { } source = multi_source; + } else if(opt->SortMultipleGlob() != "") { + // Open multiple files, read from all at the same time. + TGlobRawFile* glob_multi_source = new TGlobRawFile(opt->SortMultipleGlob()); + std::cout << opt->SortMultipleGlob() << std::endl; std::cin.get(); + source = glob_multi_source; + } else if(!opt->SortMultiple() && ( opt->RawInputFiles().size() > 1 || opt->RootInputFiles().size() > 1 || diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index 6ba2550b..e2be2d1b 100644 --- a/libraries/TRawFormat/LinkDef.h +++ b/libraries/TRawFormat/LinkDef.h @@ -1,4 +1,4 @@ -// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TOrderedRawFile.h TSequentialRawFile.h TTreeSource.h TRCNPSource.h +// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TGlobRawFile.h TOrderedRawFile.h TSequentialRawFile.h TTreeSource.h TRCNPSource.h #ifdef __CINT__ @@ -26,6 +26,7 @@ #pragma link C++ class TRawFileIn+; #pragma link C++ class TMultiRawFile+; +#pragma link C++ class TGlobRawFile+; #pragma link C++ class TOrderedRawFile+; #pragma link C++ class TSequentialRawFile+; From 81d328611c324fb786619e50763bf3428f81509b Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 29 Jun 2016 15:12:11 +0900 Subject: [PATCH 21/28] Fully added TGlobRawFile, and removed stalled source functionality as it was preventing the sorting of multiple CAGRA data files. This option should have a flag, so that it can be used when each file represents a unique source, but not used when each source produces multiple files and they all need to be sorted. --- GRAnalyzer | 2 +- Readme.md | 144 +++++++++++++++++- config/rcnpchannels.cal | 12 +- histos/RCNPHistos.cxx | 88 ----------- include/TANLEvent.h | 1 + include/TGRUTOptions.h | 2 + libraries/TDetSystems/TArgonne/TANLEvent.cxx | 27 +++- .../TGrandRaiden/TGrandRaidenHit.cxx | 2 +- libraries/TGRUTint/TGRUTOptions.cxx | 3 + libraries/TGRUTint/TGRUTint.cxx | 4 +- libraries/TRawFormat/TMultiRawFile.cxx | 25 ++- libraries/TRawFormat/TRCNPSource.cxx | 26 +++- libraries/TRawFormat/TRawBanks.cxx | 13 +- 13 files changed, 241 insertions(+), 108 deletions(-) delete mode 100644 histos/RCNPHistos.cxx diff --git a/GRAnalyzer b/GRAnalyzer index 36a72ae9..54c6c041 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 36a72ae906cda33e7ff13840181e3d4d9b897a22 +Subproject commit 54c6c0414dcdd93579c44a6ab5220b15b1e9bcad diff --git a/Readme.md b/Readme.md index c40c14aa..c6b2f225 100644 --- a/Readme.md +++ b/Readme.md @@ -5,6 +5,148 @@ A generic unpacker and analysis package for gamma-ray spectroscopy. The doxygen documentation can be found [here](https://pcbend.github.io/GRUTinizer). +Tutorial for July RCNP Test Experiment 2016: +-- +The most important thing to know is that in order to use GRUTinizer, you must *first* run the ```grutsh``` command in your shell session. (e.g. after you have logged in to cagragr@miho-1 or aino-1, you type ```grutsh```. This will source a number of need scripts and directories to correctly setup your environment to compile and run GRUTinizer. -generic comments. +Next, copy the ```~/ana/template/``` directory to your own analysis space. Compile it with + +``` make -j15 ``` + +Note, you do not need to ```make clean``` unless except in rare instances. Make should handle the dependencies for you. + + + +Key program options (flags) for running GRUTinizer: + +Options: + +arg Input file(s) + +**-H [ --histos ] attempt to run events through MakeHisto lib.** + +**-m [ --sort-multiple ] If passed multiple raw data files, treat them as one file.** + +**-s [ --sort ] Attempt to loop through root files.** + +**--build-window arg Build window, timestamp units** + +**-g [ --start-gui ] Start the GUI** + +**-o [ --output ] arg Root output file** + +**-S [ --gr-singles ] Ignore GR timestamps and take singles.** + +**--hist-output arg Output file for histograms** + +**-q [ --quit ] Run in batch mode** + +**-h -? [ --help ] Show this help message** + + +Online CAGRA example: +-- +``` ./bin/grutinizer -Hmg config/rcnpchannels.cal libraries/libRCNPhistos.so cagra_data/data1/run_1018.gtd01_000_010* -o /dev/null ``` +* Above, -H specifies that a histogram library will be used. For each built event, the function MakeHistograms in ```./histos/RCNPhistos.cxx ``` will be called. Any new *.cxx files put in ./histos will be automatically compiled into a corresponding library and put in ./libraries. + +* Above -m indicates that multiple raw files will be sorted simultaneously and attempted to event correlated. This flag should almost always be present when multiple raw files to be sorted. + +* -g launches the graphical user interface. Some helper functions and key commands are described in the Interactive Analysis section below. + +* -o /dev/null indicates that the output root tree will not be created, and only histograms will be made for online monitoring + +Online Grand Raiden example: +-- +``` ./bin/grutinizer -Hg config/rcnpchannels.cal libraries/libRCNPhistos.so online.bld -o /dev/null ``` +* All options here are similar to those found above, but now we are using a special online.bld file to indicate that GRUTinizer should utilize the online functionality of the GRAnalyzer to retrieve GR event data. Note that online mode only works when you are running GRUTinizer from *aino-1*, since this is the computer on which the Grand Raiden DAQ is run. + + +Offline CAGRA example: +-- +``` ./bin/grutinizer -Hmq config/rcnpchannels.cal libraries/libRCNPhistos.so cagra_data/data1/run_1018.gtd01_000_010* -o run1018.root ``` + +* The only difference here is that a -o specifies the name of the rootfile that will contain the built root tree from the raw data (ie, we are not skipping this step as in the previous example). This can be nice for calibrations as this root tree can be read in just like any other raw file and analyzed, without needing to resort all the data. + +* -q specifies that we want to close GRUTinizer when analysis and sorting is done. Note that in this mode, the GUI is not opened. + + +Offline Grand Raiden example: +-- +``` ./bin/grutinizer -SHg config/rcnpchannels.cal libraries/libRCNPhistos.so ~/data/run1016.bld ``` + +* In this case, we are running the graphical interface in offline mode, while sorting data from a file that was produced at some point in the past. Since we did not specify an output filename, the file should detect the run number and name it appropriately (note that this doesnt yet work CAGRA, I think). + +* -S here is a special flag to indicate GR singles mode. This is necessarry if for some reason, the MYRIAD timestamp module is not functioning, but looking at the raw singles data is still desired. This flag can be used in offline or online mode. + + +Coincident CAGRA + GR example: + +``` ./bin/grutinizer -Hmg config/rcnpchannels.cal libraries/libRCNPhistos.so online.bld cagra_data/data1/run_1018.gtd01_000_010* -o /dev/null ``` + +* Here we attach online to both GR and to raw CAGRA data + +* In this setting -m is critical as it indicates that the different raw sources should be built together. + + + + +**INTERACTIVE ANALYSIS** +-- + + +In addition to the many libraries in TGRUTAnalysis to make analysis easier, GRUTinizer also takes control of some of the behind the scene functions of ROOT to make analysis a bit easier. + +To take advantage of these features all one has to do is start GRUTinizer! They are implemented when examining and natural root classes, whether the where draw from a tree, made fresh or load from a file. + +* **GlobalFunctions**
+ +* **GCanvas**
The most notable difference, is the replacement of the TCanvas with GCanvas. This replacement is done naturally - no changes from either existing ROOT scripts or GRUTinizer scripts are needed to take advantage of the GCanvas default behavior. + +## Universal Commands + +| Key | Action | +|:-----|:------| +| **F2** | Show/Hide Editor Tab | + +## TH1 Commands +| Key | Action | +|:------|:------| +| | All normal root commands/interactions.| +| **m** | Toggle on/off marker mode; when on, the histogram will remember and display the last four clicks as marks on the histogram.| +| **p** | If the 1d hist was made using the global ProjectionX/ProjectionY; gating the original 2D matrix this histogram came from is possible by placing markers around the gate and pressing p. The gates spectra is immediately drawn. | +| **B** | Cycle through types of automatic background subtraction used when projecting with **p**. Current types include: No subtraction, Fraction of the total, subtract gate from the 3rd marker (gate size set to the distance between marker 1 and 2). | +| **b** | Set the background, how it is set depends on **B**.| +| **n** | Remove all markers / functions drawn on the histogram (not gates!).| +| **e** | Expand the x-axis range between the last two markers.| +| **E** | Bring up dialogue box used to set desired x-axis range.| +| **o** | Unzoom the entire histogram.| +| **Arrow Left/Right** | When zoomed in, mover the display region to the left/right by one half of the region currently displayed.| +| **Arrow Up/Down** | Quickly display the next histogram stored in memory, especially useful when gating to go back and forth between gates and the total projection. (currently only available in GH1D) | +| **f** | Ryan D's TPeak Fit (proper skewd gaus for gamma-rays with automatic bg) with minimum output. | +| **g** | Gaus fit with linear background, displays results of the fit **RESULTS STILL NEED TO BE VERIFIED** | +| **i** | Raw integral of counts between the two markers | +| **s** | Show peak values. | +| **S** | Remove peak values. | +| **l** | Toggle y-axis linear. | + + +## GH2I Commands +| Key | Action | +|:------|:------| +| | All normal root commands/interactions.| +| middle-click | Select the current pad, current pad is outlined by a red border. | +| **e** | Expand the x-axis range between the two markers.| +| **g** | Create a TCuG on the canvas, name scheme is _cut# where # is tracked from the start of the program.| +| **o** | Unzoom the entire histogram, x and y.| +| **x** | Make and display a total projection of the x-axis.| +| **X** | Make and display a one bin projection of the x-axis, arrow up/down will cycle through all bins.| +| **y** | Make and display a total projection of the y-axis.| +| **Y** | Make and display a one bin projection of the y-axis, arrow up/down will cycle through all bins.| + + +## TGraph/TGraphErrors Commands +| Key | Action |: +|:------|:------| +| | All normal root commands/interactions.| +| **p** | Print the graph to the terminal. diff --git a/config/rcnpchannels.cal b/config/rcnpchannels.cal index 23e9c6dc..ea4a914f 100644 --- a/config/rcnpchannels.cal +++ b/config/rcnpchannels.cal @@ -82,15 +82,15 @@ EXT19AP00 { } EXT20AP00 { Address: 0x01006700 - EnergyCoeff: 0 1 + EnergyCoeff: -23.996 1.5685 } EXT21AP00 { Address: 0x01006701 - EnergyCoeff: 0 1 + EnergyCoeff: -7.5781 1.5026 } EXT22AP00 { Address: 0x01006702 - EnergyCoeff: 0 1 + EnergyCoeff: -31.6613 1.5664 } EXT23AP00 { Address: 0x01006703 @@ -122,15 +122,15 @@ EXT29AP00 { } EXT30AP00 { Address: 0x01006800 - EnergyCoeff: 0 1 + EnergyCoeff: -18.3471 0.8697 } EXT31AP00 { Address: 0x01006801 - EnergyCoeff: 0 1 + EnergyCoeff: -7.7967 0.8227 } EXT32AP00 { Address: 0x01006802 - EnergyCoeff: 0 1 + EnergyCoeff: -23.9436 0.8553 } EXT33AP00 { Address: 0x01006803 diff --git a/histos/RCNPHistos.cxx b/histos/RCNPHistos.cxx deleted file mode 100644 index b9b14ed3..00000000 --- a/histos/RCNPHistos.cxx +++ /dev/null @@ -1,88 +0,0 @@ - -#include "TRuntimeObjects.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "TCagra.h" -#include "TGrandRaiden.h" - -//#include "TChannel.h" -//#include "GValue.h" - -#define PRINT(x) std::cout << #x" = " << x << std::endl -#define STR(x) #x << " = " << x - -using namespace std; - - -string name; -stringstream stream; - -// extern "C" is needed to prevent name mangling. -// The function signature must be exactly as shown here, -// or else bad things will happen. -extern "C" -void MakeHistograms(TRuntimeObjects& obj) { - auto cagra = obj.GetDetector(); - auto gr = obj.GetDetector(); - - TList *list = &(obj.GetObjects()); - int numobj = list->GetSize(); - - // if(!gr) { cout << "NO GR" << endl; return; } - // for(int y=0;ySize();y++) { - // auto grhit = gr->GetGrandRaidenHit(y); - // cout << grhit.Timestamp << endl; - // } - - - - //if(!cagra) { return; } - - // if (cagra) { cout << "yay" << endl; } - // return; - - - if(!cagra || !gr) { return; } - //cout << "Coincidence!!!" << endl; - - /* - for(int y=0;ySize();y++) { - TCagraHit hit = cagra->GetCagraHit(y); - - if(hit.GetBoardID() == 113) { - - stream.str(""); - stream << "Crystal" << hit.GetChannel(); - float Energy = ((hit.GetPostE() - hit.GetPreE())/350.0); - obj.FillHistogram(stream.str(),10000,0,20000,Energy); - } - - - - - // PRINT(hit.GetBoardID()); - // if (hit.GetChannel() > 2) PRINT(hit.GetChannel()); - // PRINT(hit.GetLED()); - // PRINT(hit.GetPostE()); - // PRINT(hit.GetPreE()); - // PRINT((hit.GetPostE() - hit.GetPreE())/350.0); - //std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - - } - */ - - if(numobj!=list->GetSize()) - list->Sort(); - -} diff --git a/include/TANLEvent.h b/include/TANLEvent.h index 02bc8989..bb2cce10 100644 --- a/include/TANLEvent.h +++ b/include/TANLEvent.h @@ -54,6 +54,7 @@ class TANLEvent : public TObject { UShort_t prerise_begin_sample; //UShort_t base_sample; //UShort_t peak_sample; + std::vector wave_data; ClassDef(TANLEvent,0); }; diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index 2db88079..cd4b9d12 100644 --- a/include/TGRUTOptions.h +++ b/include/TGRUTOptions.h @@ -49,6 +49,7 @@ class TGRUTOptions : public TObject { bool TreeSource() const { return fTreeSource; } bool SaveRCNPTree() const { return fSaveRCNPTree; } bool FastForwardRawFile() const { return fFastForwardRaw; } + bool GRSingles() const { return fGRSingles; } bool IsOnline() const { return fIsOnline; } @@ -111,6 +112,7 @@ class TGRUTOptions : public TObject { bool fFastForwardRaw; bool fSaveRCNPTree; std::string fGlobRaw; + bool fGRSingles; ClassDef(TGRUTOptions,0); }; diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index 01187e9b..91f934a1 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -99,13 +99,34 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { postrise_end_sample = data->GetPostRiseSampleEnd(); prerise_end_sample = data->GetPreRiseSampleEnd(); - //std:: cout << data->GetCFD0() << " " << data->GetCFD1() << " " << data->GetCFD2() << std::endl; - // ignore waveform data - size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); + size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); // labr 1.52us + // // trace analysis here + // for (auto i=0u; iInputRing().length() || opt->RawInputFiles().size() + || opt->SortMultipleGlob().length() || (opt->RootInputFiles().size() && opt->TreeSource())) && !missing_file && opt->SortRaw()) { @@ -242,10 +243,9 @@ void TGRUTint::ApplyOptions() { } source = multi_source; - } else if(opt->SortMultipleGlob() != "") { + } else if(opt->SortMultipleGlob().length()) { // Open multiple files, read from all at the same time. TGlobRawFile* glob_multi_source = new TGlobRawFile(opt->SortMultipleGlob()); - std::cout << opt->SortMultipleGlob() << std::endl; std::cin.get(); source = glob_multi_source; } else if(!opt->SortMultiple() && ( diff --git a/libraries/TRawFormat/TMultiRawFile.cxx b/libraries/TRawFormat/TMultiRawFile.cxx index c19c7190..e52eff24 100644 --- a/libraries/TRawFormat/TMultiRawFile.cxx +++ b/libraries/TRawFormat/TMultiRawFile.cxx @@ -67,12 +67,31 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){ // If another event exists, put it back into the list FileEvent next; next.file = output.file; + int bytes_read = next.file->Read(next.next_event); if(bytes_read > 0){ fFileEvents.insert(next); - } else if (!TGRUTOptions::Get()->ExitAfterSorting()) { - stalled_source = next.file; - } else { // otherwise delete the source from the file list + } // else if (!TGRUTOptions::Get()->ExitAfterSorting()) { + // // // if in online mode and the current source is at its end, delete it + // // std::cout << next.file->Status() << std::endl; + // // TRawEventFileSource* filein = dynamic_cast(next.file); + // // if (filein) { + // // std::cout << filein->SourceDescription() << " : " << (filein->GetFileSize() - filein->GetBytesGiven()) << std::endl; + // // if ((filein->GetFileSize() - filein->GetBytesGiven()) == 0) { + // // std::lock_guard lock(fFileListMutex); + // // delete output.file; + // // fFileList.erase(output.file); + // // } + // // } else { // otherwise it is a stalled source and we should wait until data is available for coincidence building + // // stalled_source = next.file; + // // } + // } + else { // otherwise delete the source from the file list + std::cout << "######################################\n"; + std::cout << std::endl << "Deleting source: " << next.file->SourceDescription() << std::endl; + std::cout << next.file->Status() << std::endl << std::endl; + std::cout << "######################################\n"; + std::lock_guard lock(fFileListMutex); delete output.file; fFileList.erase(output.file); diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 976199ea..bc5b93e6 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -62,12 +62,34 @@ int TRCNPSource::GetEvent(TRawEvent& event) { //TSmartBuffer eventbuffer(ptrbytes,sizeof(rcnp)); //event.SetData(eventbuffer); + double time = 0; event.SetDataPtr((void*)rcnp); - double time = rcnp->GR_MYRIAD(0); - if (time == -441441) { time = 11; } + if (TGRUTOptions::Get()->GRSingles()) { + // singles (ignoring myriad timestamp) + static ULong_t counter = 0; + counter += TGRUTOptions::Get()->BuildWindow()*1.5; + time = counter; + } + else { + // normal, use the GR myriad timestamp and if it's not present set the time to a random constant + time = rcnp->GR_MYRIAD(0); + if (time == -441441) { + + static int not_found = 0; + if (not_found < 100) { + std::cout << "GR Myriad timestamp not found!!!" << std::endl; + if (not_found == 99) { + std::cout << "More than 100 GR events are missing a timestamp. This warning is being supressed, but you should probably investigate this." << std::endl; + } + } + + time = 2112; + } + } rcnp->SetTimestamp(time); event.SetFragmentTimestamp(time); + return sizeof(rcnp); } diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index e30efa36..63ae08a3 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -346,7 +346,18 @@ std::ostream& operator<<(std::ostream& os, const TRawEvent::GEBArgonneCFDv18& da << STR(data.prerise_end_sample) << "\n" << STR(data.prerise_begin_sample) << "\n" << STR(data.base_sample) << "\n" - << STR(data.peak_sample) << std::endl; + << STR(data.peak_sample) << "\n" + << STR(data.WriteFlag()) << "\n" + << STR(data.VetoFlag()) << "\n" + << STR(data.TSMatchFlag()) << "\n" + << STR(data.ExternalDiscFlag()) << "\n" + << STR(data.PeakValidFlag()) << "\n" + << STR(data.OffsetFlag()) << "\n" + << STR(data.CFDValidFlag()) << "\n" + << STR(data.SyncErrorFlag()) << "\n" + << STR(data.GeneralErrorFlag()) << "\n" + << STR(data.PileUpOnlyFlag()) << "\n" + << STR(data.PileUpFlag()) << std::endl; } #undef STR From 8b19a409f27248cc9187677ff29af451238b52b2 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 30 Jun 2016 17:40:12 +0900 Subject: [PATCH 22/28] Many updates: - Reinstated stalled source. In the future there needs to be a distinction for online analysis between sources which produce multiple files and (per run), and those which produce only a single file per run. The problem was that with the stalled_source paradigm in TMultiRawFile, if a detector system produced a set of files sequentially (after reaching 2Gb, for example), each of those data files are only from a single physical source, but the TMultiRawFile would interpret them as independent physical sources, and would stall when it finished sorting the first 2Gb file (e.g.). - I have implemented trace analysis into TCagraHit for use with the LaBr detector in the Test Experiment. Seems to be functioning well. - I have added a CFD zero finder (rudimentary) for use with the 3 CFD trace pts provided per data header. --- include/TANLEvent.h | 8 +- include/TCagra.h | 2 + include/TCagraHit.h | 14 ++- include/TCagraSegmentHit.h | 6 +- include/TRawBanks.h | 9 +- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 18 ++-- libraries/TDetSystems/TArgonne/TCagra.cxx | 5 +- libraries/TDetSystems/TArgonne/TCagraHit.cxx | 86 +++++++++++++++++++ .../TDetSystems/TArgonne/TCagraSegmentHit.cxx | 7 ++ libraries/TRawFormat/TMultiRawFile.cxx | 5 +- libraries/TRawFormat/TRawBanks.cxx | 24 +++++- 11 files changed, 163 insertions(+), 21 deletions(-) diff --git a/include/TANLEvent.h b/include/TANLEvent.h index bb2cce10..f73663cb 100644 --- a/include/TANLEvent.h +++ b/include/TANLEvent.h @@ -5,6 +5,8 @@ #include "TSmartBuffer.h" +#include + class TANLEvent : public TObject { public: @@ -34,6 +36,8 @@ class TANLEvent : public TObject { // TODO: add to input calibrations file for second order corrections // e.g. pole zero etc. double GetEnergy() const { return ((GetPostE() - GetPreE())/350.0); } + Double_t GetCFD() const { return (Double_t)discriminator + d_cfd; } + std::vector& GetTrace() { return wave_data; } private: @@ -42,6 +46,8 @@ class TANLEvent : public TObject { UShort_t channel; ULong_t discriminator; + Double_t d_cfd; + ULong_t disc_prev; UInt_t flags; //UInt_t sampled_baseline; @@ -54,7 +60,7 @@ class TANLEvent : public TObject { UShort_t prerise_begin_sample; //UShort_t base_sample; //UShort_t peak_sample; - std::vector wave_data; + std::vector wave_data; ClassDef(TANLEvent,0); }; diff --git a/include/TCagra.h b/include/TCagra.h index 118bcbae..3da64c22 100644 --- a/include/TCagra.h +++ b/include/TCagra.h @@ -9,6 +9,8 @@ #include "TVector3.h" +#include + class TCagra : public TDetector { public: diff --git a/include/TCagraHit.h b/include/TCagraHit.h index ccac293f..2dbb61cd 100644 --- a/include/TCagraHit.h +++ b/include/TCagraHit.h @@ -43,12 +43,20 @@ class TCagraHit : public TDetectorHit { const TVector3& particle_vec = TVector3(0,0,1), const TVector3& cagra_offset = TVector3(0,0,0)) const; - void SetDiscTime(const ULong_t t) { time = t; } - ULong_t GetDiscTime() { return time; } + void SetDiscTime(const Double_t t) { time = t; } + Double_t GetDiscTime() { return time; } + + std::vector* GetTrace(int segnum=0); + void SetTrace(std::vector& trace); + void DrawTrace(int segnum); + double GetTraceHeight() const; + double GetTraceHeightDoppler(double beta,const TVector3& vec = TVector3(0,0,1)) const; + Double_t GetTraceEnergy(const UShort_t& a,const UShort_t& b,const UShort_t& x,const UShort_t& y) const; private: + std::vector fTrace; std::vector fSegments; - ULong_t time; + Double_t time; ClassDef(TCagraHit,1); }; diff --git a/include/TCagraSegmentHit.h b/include/TCagraSegmentHit.h index cfd3ae7b..6de792c1 100644 --- a/include/TCagraSegmentHit.h +++ b/include/TCagraSegmentHit.h @@ -20,8 +20,12 @@ class TCagraSegmentHit : public TDetectorHit { int GetBoardID() const; int GetChannel() const; -private: + std::vector& GetTrace() { return fTrace; } + void SetTrace(std::vector& trace); + +private: + std::vector fTrace; ClassDef(TCagraSegmentHit,1); }; diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 8f6bc8cf..21636eb4 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -385,11 +385,11 @@ struct GEBArgonneLEDv18 { struct GEBArgonneCFDv18 { UShort_t cfd_low_prev; UShort_t flags; - Short_t cfd_sample0; // signed + UShort_t cfd_sample0; // signed UShort_t cfd_mid_prev; // bits 16:29 UInt_t sampled_baseline; - Short_t cfd_sample2; - Short_t cfd_sample1; + UShort_t cfd_sample2; + UShort_t cfd_sample1; UInt_t postrise_sum_low_prerise_sum; UShort_t timestamp_peak_low; UShort_t postrise_sum_high; @@ -401,6 +401,7 @@ struct GEBArgonneCFDv18 { UShort_t prerise_begin_sample; UShort_t base_sample; UShort_t peak_sample; + Double_t GetCFD() const; Short_t GetCFD0() const; Short_t GetCFD1() const; Short_t GetCFD2() const; @@ -429,6 +430,8 @@ struct GEBArgonneCFDv18 { UShort_t PileUpFlag() const; }__attribute__((__packed__)); +static Short_t GetSigned14BitFromUShort(UShort_t ushort); + friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv11& data); static void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index 91f934a1..c37a4353 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -7,7 +7,7 @@ ClassImp(TANLEvent) //bool TANLEvent::fExtractWaves = true; -TANLEvent::TANLEvent(TSmartBuffer& buf) { +TANLEvent::TANLEvent(TSmartBuffer& buf) : d_cfd(0.) { bool read_waveform = TGRUTOptions::Get()->ExtractWaves(); if (read_waveform) { @@ -89,7 +89,9 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { // Swap big endian for little endian TRawEvent::SwapArgonneCFDv18(*data); // Extract data from payload - //discriminator = data->GetCFD0(); // this should be a function to interpolate the zero crossing + d_cfd = data->GetCFD(); // TODO: use a fit + // std::cout << cfd << std::endl; + // std::cin.get(); disc_prev = data->GetPrevCFD(header); flags = data->flags; prerise_energy = data->GetPreRiseE(); @@ -102,13 +104,15 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) { size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); // labr 1.52us // // trace analysis here - // for (auto i=0u; i& raw_data){ if(segnum==0){ hit->SetAddress(address); hit->SetTimestamp(event.GetTimestamp()); - hit->SetDiscTime(anl.GetDiscriminator()); + hit->SetDiscTime(anl.GetCFD()); hit->SetCharge(anl.GetEnergy()); + hit->SetTrace(anl.GetTrace()); } else { TCagraSegmentHit& seg = hit->MakeSegmentByAddress(address); seg.SetCharge(anl.GetEnergy()); seg.SetTimestamp(event.GetTimestamp()); + //seg.SetDiscTime(anl.GetCFD()); + seg.SetTrace(anl.GetTrace()); } } diff --git a/libraries/TDetSystems/TArgonne/TCagraHit.cxx b/libraries/TDetSystems/TArgonne/TCagraHit.cxx index 75403ceb..5842a9ab 100644 --- a/libraries/TDetSystems/TArgonne/TCagraHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCagraHit.cxx @@ -28,6 +28,7 @@ void TCagraHit::Print(Option_t *opt) const { } void TCagraHit::Clear(Option_t *opt) { TDetectorHit::Clear(opt); + fTrace.clear(); } bool TCagraHit::HasCore() const { return fCharge != -1; @@ -139,3 +140,88 @@ Int_t TCagraHit::Charge() const { return fCharge; } } + +void TCagraHit::DrawTrace(int segnum) { + std::vector* trace = GetTrace(segnum); + if(!trace){ + std::cout << "No segment trace found for segment " << segnum << std::endl; + return; + } + + TH1I hist("hist", "", trace->size(), 0, 10*trace->size()); + hist.SetStats(false); + + if(segnum==0){ + hist.SetTitle(Form("CAGRA Detector %d at %ld ns", GetDetnum(), Timestamp())); + hist.GetXaxis()->SetTitle("Time (ns)"); + hist.GetYaxis()->SetTitle("ADC units"); + } + + for(size_t i=0; isize(); i++) { + hist.SetBinContent(i+1,(*trace)[i]); + } + hist.DrawCopy(); +} + +void TCagraHit::SetTrace(std::vector& trace) { + fTrace.clear(); + fTrace.swap(trace); +} + +std::vector* TCagraHit::GetTrace(int segnum) { + if(segnum == 0){ + return &fTrace; + } + for(auto& seg : fSegments) { + if(seg.GetSegnum() == segnum) { + return &seg.GetTrace(); + } + } + return NULL; +} + +double TCagraHit::GetTraceHeight() const { + if(fTrace.size() < 20){ + return std::sqrt(-1); + } + + double low = 0; + double high = 0; + for(unsigned int i=0; i<10; i++){ + low += fTrace[i]; + high += fTrace[fTrace.size()-i-1]; + } + + return (high-low)/10; +} + +double TCagraHit::GetTraceHeightDoppler(double beta,const TVector3& vec) const { + if(GetNumSegments()<1) { + return std::sqrt(-1); + } + + double gamma = 1/(sqrt(1-pow(beta,2))); + TVector3 pos = GetPosition(); + double cos_angle = TMath::Cos(pos.Angle(vec)); + double dc_en = GetTraceHeight()*gamma *(1 - beta*cos_angle); + return dc_en; +} + +Double_t TCagraHit::GetTraceEnergy(const UShort_t& a,const UShort_t& b,const UShort_t& x,const UShort_t& y) const { + if (!fTrace.size()) { return 0; } + + if (fTrace.size() < y) { + static int nprint = 0; + if (nprint < 10) { + std::cout << "Warning: Trace length less than requested sampling window: " << fTrace.size() <& trace) { + fTrace.clear(); + fTrace.swap(trace); } void TCagraSegmentHit::Print(Option_t *opt) const { diff --git a/libraries/TRawFormat/TMultiRawFile.cxx b/libraries/TRawFormat/TMultiRawFile.cxx index e52eff24..5cfa81cd 100644 --- a/libraries/TRawFormat/TMultiRawFile.cxx +++ b/libraries/TRawFormat/TMultiRawFile.cxx @@ -71,7 +71,7 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){ int bytes_read = next.file->Read(next.next_event); if(bytes_read > 0){ fFileEvents.insert(next); - } // else if (!TGRUTOptions::Get()->ExitAfterSorting()) { + } else if (!TGRUTOptions::Get()->ExitAfterSorting()) { // // // if in online mode and the current source is at its end, delete it // // std::cout << next.file->Status() << std::endl; // // TRawEventFileSource* filein = dynamic_cast(next.file); @@ -85,7 +85,8 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){ // // } else { // otherwise it is a stalled source and we should wait until data is available for coincidence building // // stalled_source = next.file; // // } - // } + stalled_source = next.file; + } else { // otherwise delete the source from the file list std::cout << "######################################\n"; std::cout << std::endl << "Deleting source: " << next.file->SourceDescription() << std::endl; diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index 63ae08a3..7d6eae23 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -189,10 +189,28 @@ ULong_t TRawEvent::GEBArgonneCFDv18::GetPrevCFD(const GEBArgonneHead* header) c return 0xffffffffffffffff; } } +#define STR(x) #x << ": " << x +Double_t TRawEvent::GEBArgonneCFDv18::GetCFD() const { + // std::cout << STR(CFDValidFlag()) << std::endl; + // std::cout << STR(cfd_sample0) << std::endl; + // std::cout << STR(cfd_sample1) << std::endl; + // std::cout << STR(cfd_sample2) << std::endl; + // std::cout << STR(GetCFD0()) << std::endl; + // std::cout << STR(GetCFD1()) << std::endl; + // std::cout << STR(GetCFD2()) << std::endl; + // std::cout << std::endl; + // std::cin.get(); + return 0. - GetCFD2()*2./(GetCFD2()-GetCFD0()); +} +#undef STR + +Short_t TRawEvent::GetSigned14BitFromUShort(UShort_t ushort) { + return ((Short_t)((ushort & 0x3fff) << 2))/4; +} -Short_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return (cfd_sample0 & 0x3fff); } -Short_t TRawEvent::GEBArgonneCFDv18::GetCFD1() const { return (cfd_sample1 & 0x3fff); } -Short_t TRawEvent::GEBArgonneCFDv18::GetCFD2() const { return (cfd_sample2 & 0x3fff); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD0() const { return GetSigned14BitFromUShort(cfd_sample0); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD1() const { return GetSigned14BitFromUShort(cfd_sample1); } +Short_t TRawEvent::GEBArgonneCFDv18::GetCFD2() const { return GetSigned14BitFromUShort(cfd_sample2); } UInt_t TRawEvent::GEBArgonneCFDv18::GetBaseline() const { return ((sampled_baseline & 0x00FFFFFF) >> 0); } UInt_t TRawEvent::GEBArgonneCFDv18::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } From 9fd9726e994ebb0260d3f60b6b27a44966095f47 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 1 Jul 2016 19:04:33 +0900 Subject: [PATCH 23/28] Added cal files. PoleZero & Asymptotic baseline corrections are now working. Be sure to add at least a PZ correction to the calibration file for every channel. --- config/rcnp_constants.val | 3 + config/rcnp_peter.cal | 330 +++++++++++++++++++ include/TANLEvent.h | 16 +- include/TCagraHit.h | 8 +- include/TRawBanks.h | 3 +- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 1 + libraries/TDetSystems/TArgonne/TCagra.cxx | 2 + libraries/TDetSystems/TArgonne/TCagraHit.cxx | 7 +- libraries/TGRUTUtil/TChannel.cxx | 12 +- 9 files changed, 372 insertions(+), 10 deletions(-) create mode 100644 config/rcnp_constants.val create mode 100644 config/rcnp_peter.cal diff --git a/config/rcnp_constants.val b/config/rcnp_constants.val new file mode 100644 index 00000000..c403f10f --- /dev/null +++ b/config/rcnp_constants.val @@ -0,0 +1,3 @@ +ShapingTime { + Value: 350.0 +} \ No newline at end of file diff --git a/config/rcnp_peter.cal b/config/rcnp_peter.cal new file mode 100644 index 00000000..babd64c8 --- /dev/null +++ b/config/rcnp_peter.cal @@ -0,0 +1,330 @@ +// Other channels +EXT00AP00 { + Address: 0x01006500 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT01AP00 { + Address: 0x01006501 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT02AP00 { + Address: 0x01006502 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT03AP00 { + Address: 0x01006503 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT04AP00 { + Address: 0x01006504 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT05AP00 { + Address: 0x01006505 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT06AP00 { + Address: 0x01006506 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT07AP00 { + Address: 0x01006507 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT08AP00 { + Address: 0x01006508 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT09AP00 { + Address: 0x01006509 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT10AP00 { + Address: 0x01006600 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT11AP00 { + Address: 0x01006601 + EnergyCoeff: 0 1 + Pol o: 1 +} +EXT12AP00 { + Address: 0x01006602 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT13AP00 { + Address: 0x01006603 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT14AP00 { + Address: 0x01006604 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT15AP00 { + Address: 0x01006605 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT16AP00 { + Address: 0x01006606 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT17AP00 { + Address: 0x01006607 + EnergyCoeff: 0 1 + Pol o: 1 +} +EXT18AP00 { + Address: 0x01006608 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT19AP00 { + Address: 0x01006609 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT20AP00 { + Address: 0x01006700 + EnergyCoeff: -55.898 2.2208 + PoleZero: 0.920 +} +EXT21AP00 { + Address: 0x01006701 + EnergyCoeff: -53.9224 1.1362 + PoleZero: 0.920 +} +EXT22AP00 { + Address: 0x01006702 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT23AP00 { + Address: 0x01006703 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT24AP00 { + Address: 0x01006704 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT25AP00 { + Address: 0x01006705 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT26AP00 { + Address: 0x01006706 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT27AP00 { + Address: 0x01006707 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT28AP00 { + Address: 0x01006708 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT29AP00 { + Address: 0x01006709 + EnergyCoeff: 0 1 + Pol o: 1 +} +EXT30AP00 { + Address: 0x01006800 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT31AP00 { + Address: 0x01006801 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT32AP00 { + Address: 0x01006802 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT33AP00 { + Address: 0x01006803 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT34AP00 { + Address: 0x01006804 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT35AP00 { + Address: 0x01006805 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT36AP00 { + Address: 0x01006806 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT37AP00 { + Address: 0x01006807 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT38AP00 { + Address: 0x01006808 + EnergyCoeff: 0 1 + PoleZero: 1 +} +EXT39AP00 { + Address: 0x01006809 + EnergyCoeff: 0 1 + PoleZero: 1 +} + + +// // Central contacts + +// CLO01AP00 { +// Address: 0x01006500 +// EnergyCoeff: 0 1 +// } + +// CLO01BP00 { +// Address: 0x01006501 +// EnergyCoeff: 0 1 +// } + +// CLO01CP00 { +// Address: 0x01006502 +// EnergyCoeff: 0 1 +// } + +// CLO01DP00 { +// Address: 0x01006503 +// EnergyCoeff: 0 1 +// } + +// CLO01EP00 { +// Address: 0x01006504 +// EnergyCoeff: 0 1 +// } + +// // left +// CLO01AN01 { +// Address: 0x01006505 +// EnergyCoeff: 0 1 +// } + +// // center +// CLO01AN02 { +// Address: 0x01006506 +// EnergyCoeff: 0 1 +// } + +// //right +// CLO01AN03 { +// Address: 0x01006507 +// EnergyCoeff: 0 1 +// } + +// EXT11AP00 { +// Address: 0x01607200 +// EnergyCoeff: 0 1 +// } +// EXT02AP00 { +// Address: 0x01007201 +// EnergyCoeff: 0 1 +// } +// EXT03AP00 { +// Address: 0x01007202 +// EnergyCoeff: 0 1 +// } +// EXT04AP00 { +// Address: 0x01007203 +// EnergyCoeff: 0 1 +// } + +// EXT05AP00 { +// Address: 0x01007300 +// EnergyCoeff: 0 1 +// } +// EXT06AP00 { +// Address: 0x01007301 +// EnergyCoeff: 0 1 +// } +// EXT07AP00 { +// Address: 0x01007302 +// EnergyCoeff: 0 1 +// } +// EXT08AP00 { +// Address: 0x01007303 +// EnergyCoeff: 0 1 +// } +// EXT09AP00 { +// Address: 0x01007304 +// EnergyCoeff: 0 1 +// } + + + + +// // Segments + +// CLO01AN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01AN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01BN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01BN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01CN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01CN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01DN01 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } + +// CLO01DN02 { +// Address: 0x010071xx +// EnergyCoeff: 0 1 +// } diff --git a/include/TANLEvent.h b/include/TANLEvent.h index e92f2959..c152e8da 100644 --- a/include/TANLEvent.h +++ b/include/TANLEvent.h @@ -26,6 +26,8 @@ class TANLEvent : public TObject { UShort_t GetPostEnd() const { return postrise_end_sample; } UShort_t GetPreBegin() const { return prerise_begin_sample; } UShort_t GetPreEnd() const { return prerise_end_sample; } + UShort_t GetFlags() const { return flags; } + UShort_t GetBaseSample() const { return base_sample; } static Float_t& GetShapingTime() { if (std::isnan(shaping_time)) { shaping_time = GValue::Value("ShapingTime"); } return shaping_time; @@ -40,6 +42,18 @@ class TANLEvent : public TObject { UShort_t GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); } + static UShort_t WriteFlag(const UShort_t& flags) { return ((flags & 0x20)>>5); } + static UShort_t VetoFlag(const UShort_t& flags) { return ((flags & 0x40)>>6); } + static UShort_t TSMatchFlag(const UShort_t& flags) { return ((flags & 0x80)>>7); } + static UShort_t ExternalDiscFlag(const UShort_t& flags) { return ((flags & 0x100)>>8); } + static UShort_t PeakValidFlag(const UShort_t& flags) { return ((flags & 0x200)>>9); } + static UShort_t OffsetFlag(const UShort_t& flags) { return ((flags & 0x400)>>10); } + static UShort_t CFDValidFlag(const UShort_t& flags) { return ((flags & 0x800)>>11); } + static UShort_t SyncErrorFlag(const UShort_t& flags) { return ((flags & 0x1000)>>12); } + static UShort_t GeneralErrorFlag(const UShort_t& flags) { return ((flags & 0x2000)>>13); } + static UShort_t PileUpOnlyFlag(const UShort_t& flags) { return ((flags & 0x4000)>>14); } + static UShort_t PileUpFlag(const UShort_t& flags) { return ((flags & 0x8000)>>15); } + double GetEnergy() const { return ((GetPostE() - GetPreE())/GetShapingTime()); } Double_t GetCFD() const { return (Double_t)discriminator + d_cfd; } @@ -65,7 +79,7 @@ class TANLEvent : public TObject { UShort_t postrise_begin_sample; UShort_t prerise_end_sample; UShort_t prerise_begin_sample; - //UShort_t base_sample; + UShort_t base_sample; //UShort_t peak_sample; std::vector wave_data; diff --git a/include/TCagraHit.h b/include/TCagraHit.h index 8480a7a7..056a08a3 100644 --- a/include/TCagraHit.h +++ b/include/TCagraHit.h @@ -48,7 +48,10 @@ class TCagraHit : public TDetectorHit { Double_t GetCorrectedEnergy(Double_t asym_bl=0.); void SetPreRise(Double_t prerise) { prerise_energy = prerise; } void SetPostRise(Double_t postrise) { postrise_energy = postrise; } - + void SetFlags(UShort_t fl) { flags = fl; } + const UShort_t& GetFlags() const { return flags; } + void SetBaseSample(UShort_t base) { base_sample = base; } + const UShort_t& GetBaseSample() const { return base_sample; } std::vector* GetTrace(int segnum=0); void SetTrace(std::vector& trace); void DrawTrace(int segnum); @@ -61,10 +64,11 @@ class TCagraHit : public TDetectorHit { std::vector fTrace; std::vector fSegments; Double_t time; + UShort_t flags; Double_t prerise_energy; Double_t postrise_energy; + UShort_t base_sample; //Double_t fPZEnergy; - Double_t fCorEnergy; ClassDef(TCagraHit,1); }; diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 21636eb4..b83186e0 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -401,7 +401,7 @@ struct GEBArgonneCFDv18 { UShort_t prerise_begin_sample; UShort_t base_sample; UShort_t peak_sample; - Double_t GetCFD() const; + Double_t GetCFD() const; Short_t GetCFD0() const; Short_t GetCFD1() const; Short_t GetCFD2() const; @@ -428,6 +428,7 @@ struct GEBArgonneCFDv18 { UShort_t GeneralErrorFlag() const; UShort_t PileUpOnlyFlag() const; UShort_t PileUpFlag() const; + }__attribute__((__packed__)); static Short_t GetSigned14BitFromUShort(UShort_t ushort); diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx index e65bf7fb..9540f852 100644 --- a/libraries/TDetSystems/TArgonne/TANLEvent.cxx +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -101,6 +101,7 @@ TANLEvent::TANLEvent(TSmartBuffer& buf) : d_cfd(0.) { prerise_begin_sample = data->GetPreRiseSampleBegin(); postrise_end_sample = data->GetPostRiseSampleEnd(); prerise_end_sample = data->GetPreRiseSampleEnd(); + base_sample = data->GetBaseSample(); size_t wave_bytes = header->GetLength()*4 - sizeof(*header) - sizeof(*data); // labr 1.52us diff --git a/libraries/TDetSystems/TArgonne/TCagra.cxx b/libraries/TDetSystems/TArgonne/TCagra.cxx index 457ad4cd..f4f703c2 100644 --- a/libraries/TDetSystems/TArgonne/TCagra.cxx +++ b/libraries/TDetSystems/TArgonne/TCagra.cxx @@ -87,6 +87,7 @@ int TCagra::BuildHits(std::vector& raw_data){ hit->SetPreRise(anl.GetPreE()); hit->SetPostRise(anl.GetPostE()); hit->SetFlags(anl.GetFlags()); + hit->SetBaseSample(anl.GetBaseSample()); } else { TCagraSegmentHit& seg = hit->MakeSegmentByAddress(address); seg.SetCharge(anl.GetEnergy()); @@ -96,6 +97,7 @@ int TCagra::BuildHits(std::vector& raw_data){ //seg->SetPreRise(anl.GetPreE()); //seg->SetPostRise(anl.GetPostE()); //seg->SetFlags(anl.GetFlags()); + //seg->SetBaseSample(anl.GetBaseSample()); seg.SetTrace(anl.GetTrace()); } } diff --git a/libraries/TDetSystems/TArgonne/TCagraHit.cxx b/libraries/TDetSystems/TArgonne/TCagraHit.cxx index a610f5d1..81c3c687 100644 --- a/libraries/TDetSystems/TArgonne/TCagraHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCagraHit.cxx @@ -17,7 +17,6 @@ ClassImp(TCagraHit) TCagraHit::TCagraHit() : prerise_energy(0), postrise_energy(0) { - fCorEnergy = std::sqrt(-1); } TCagraHit::~TCagraHit() { @@ -144,16 +143,16 @@ Int_t TCagraHit::Charge() const { } Double_t TCagraHit::GetCorrectedEnergy(Double_t asym_bl) { - //if(!std::isnan(fCorEnergy)) {return fCorEnergy;} TChannel* chan = TChannel::GetChannel(fAddress); + Double_t Energy = 0; if(!chan){ std::cout << std::hex << "Channel 0x" << fAddress << " not defined in calibrations file, no corrections are applied." << std::endl; } else { auto pzE = chan->PoleZeroCorrection(prerise_energy,postrise_energy,TANLEvent::GetShapingTime()); pzE = chan->BaselineCorrection(pzE,asym_bl); - fCorEnergy = chan->CalEnergy(Charge(), fTimestamp); + Energy = chan->CalEnergy(pzE, fTimestamp); } - return fCorEnergy; + return Energy; } Double_t TCagraHit:: GetTraceBaseline() { std::vector* trace = GetTrace(); diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index 9c5753f3..c34e474f 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -338,7 +338,11 @@ void TChannel::SetPoleZeroCoeff(std::vector coeff, double timestamp) { double TChannel::PoleZeroCorrection(const double& prerise, const double& postrise, const double& shaping_time, double timestamp) const { auto pz = GetPoleZeroCoeff(timestamp); - return (pz.size()) ? (postrise-prerise*pz[0])/shaping_time : 0; + if (!pz.size()) { + std::cout <& TChannel::GetBaselineCoeff(double timestamp) const { @@ -378,7 +382,11 @@ double TChannel::BaselineCorrection(const double& charge, double asym_bl, double auto bl = GetBaselineCoeff(timestamp); asym_bl = (bl.size()) ? bl[0] : 0; } - return (pz.size()) ? charge - asym_bl*(1. - pz[0]) : charge - asym_bl; + if (!pz.size()) { + std::cout <& TChannel::GetTimeCoeff(double timestamp) const { From aa27e39ff72d071515bff12d50f2109bb8d227f8 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 11 Jul 2016 23:07:03 +0900 Subject: [PATCH 24/28] Changed MPIEventLoop submodule remote address to point to CAGRAGR organization --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index ed0450da..1d229c40 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = git@github.com:CAGRA-GrandRaiden/GRAnalyzer.git [submodule "MPIEventLoop"] path = MPIEventLoop - url = git@github.com:csullivan/MPIEventLoop.git + url = git@github.com:CAGRA-GrandRaiden/MPIEventLoop.git From 9a87ef23949741520888fe3c135dea7ab41c666f Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 11 Jul 2016 23:59:08 +0900 Subject: [PATCH 25/28] Added RCNP histos file --- histos/RCNPhistos.cxx | 318 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 histos/RCNPhistos.cxx diff --git a/histos/RCNPhistos.cxx b/histos/RCNPhistos.cxx new file mode 100644 index 00000000..8fe04aac --- /dev/null +++ b/histos/RCNPhistos.cxx @@ -0,0 +1,318 @@ + +#include "TRuntimeObjects.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "TCagra.h" +#include "TGrandRaiden.h" +#include "TANLEvent.h" + +#define BAD_NUM -441441 + +//#include "TChannel.h" +//#include "GValue.h" + +#define PRINT(x) std::cout << #x" = " << x << std::endl +#define STR(x) #x << " = " <<() x + +using namespace std; + + +string name; +stringstream stream; +ULong_t nevent = 0; + +// extern "C" is needed to prevent name mangling. +// The function signature must be exactly as shown here, +// or else bad things will happen. +extern "C" +void MakeHistograms(TRuntimeObjects& obj) { + + + + TCagra* cagra = obj.GetDetector(); + TGrandRaiden* gr = obj.GetDetector(); + + TList *list = &(obj.GetObjects()); + int numobj = list->GetSize(); + + if (cagra && gr) { + for (auto& hit : *gr) { + + auto& rcnp = hit.GR(); + auto grtime = hit.GetTimestamp(); + + // coincidence rate + static ULong_t first_timestamp = grtime; + if (first_timestamp) { + auto rate = (grtime-first_timestamp)/1e8; + //cout << grtime << " " << first_timestamp << endl; + obj.FillHistogram("CoinRate",1000,0,10000, rate); + } + + // coincidence time difference + for (auto& caghit : *cagra) { + + ULong_t cagratime = caghit.Timestamp(); + Double_t cagra_cfd = caghit.GetDiscTime(); + + ULong_t ts_diff = cagratime-grtime; + Double_t cfd_diff = cagra_cfd-(Double_t)grtime; + + obj.FillHistogram("CoinDiff",2000,-1000,1000,ts_diff); + stream.str(""); + stream << "CoinDiff_" << caghit.GetBoardID() << "_" < 238 && cagratime -grtime < 246) { + stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated"; + obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy()); + obj.FillHistogram("GATETEST_CoinDiff",2000,-1000,1000,ts_diff); + } + obj.FillHistogram("CoinDiff_CFD",2000,-1000,1000,cfd_diff); + stream.str(""); + stream << "CoinDiff_CFD_" << caghit.GetBoardID() << "_" < 238 && cagra_cfd -grtime < 246) { + stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated"; + obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy()); + obj.FillHistogram("GATETEST_CoinDiff_CFD",2000,-1000,1000,cfd_diff); + } + + + } + + + + } + + } + + + if (gr) { + + for (auto& hit : *gr) { + + auto& rcnp = hit.GR(); + auto adc = rcnp.GR_ADC(); + + + if (rcnp.GR_MYRIAD(0) != BAD_NUM) { + obj.FillHistogram("MyriadTimestamp",10000,1e9,5e12,hit.GetTimestamp()); + } + + static ULong_t prev_ts = 0; + if (prev_ts) { + obj.FillHistogram("GR_EventPeriod",5000,100,50000,hit.GetTimestamp()-prev_ts); + } + prev_ts = hit.GetTimestamp(); + + + if (rcnp.GR_ADC()) { + auto& adc = *rcnp.GR_ADC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_ADC" << i; + obj.FillHistogram(stream.str().c_str(), 1000,0,2000, adc[i]); + } + obj.FillHistogram("MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram("MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2()); + } + if (rcnp.GR_TDC()) { + auto& tdc = *rcnp.GR_TDC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_TDC" << i; + obj.FillHistogram(stream.str().c_str(), 1000,-40000,40000, tdc[i]); + } + obj.FillHistogram("MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1()); + obj.FillHistogram("MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2()); + } + if (rcnp.QTC_LEADING_TDC()) { + auto& qtc_leading = *rcnp.QTC_LEADING_TDC(); + auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH(); + auto x = rcnp.GR_X(0); + + for (int i=0; i< qtc_leading_chan.size(); i++) { + int channum = qtc_leading_chan[i]; + stream.str(""); stream << "LaBrLeading" << channum; + obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + // gate on gr_x + if (x < 100 && x > 0) { + stream.str(""); stream << "LaBrLead"<< channum << "_GateX"; + obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + } + + + + if (qtc_leading[i]>=-5100 && qtc_leading[i] <=-4400) { + + + obj.FillHistogram("RayID_LEGate",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR_X_LEGate",1200,-600,600, rcnp.GR_X(0)); + obj.FillHistogram("GR_Y_LEGate",200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR_Theta_LEGate",100,-1,1, rcnp.GR_TH(0)); // need to learn + obj.FillHistogram("GR_Phi_LEGate",100,-1,1, rcnp.GR_PH(0)); // from hist.def + obj.FillHistogram("X_TH_LEGate",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + } + + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth_LEGate" << channum; + obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); + + if (rcnp.GR_X(0) != BAD_NUM) { + obj.FillHistogram("X_LaBr_LEGate",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + } + } + + + } + + + } + } + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth" << channum; + obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); + + if (rcnp.GR_X(0) != BAD_NUM) { + obj.FillHistogram("X_LaBr",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + } + + } + obj.FillHistogram("RayID",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR_X",1200,-600,600, rcnp.GR_X(0)); + obj.FillHistogram("GR_Y",200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn + obj.FillHistogram("GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def + obj.FillHistogram("X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + } + auto rf = rcnp.GR_RF(0); + if (rf != BAD_NUM) { + obj.FillHistogram("GR_RF",1000,0,0,rf); + } + + //GR timestamps check - sometimes the myriad timestamp is missing... + //static int n_gr = 0; + auto time = rcnp.GR_MYRIAD(0); + if (time != BAD_NUM) { + obj.FillHistogram("GR_LiveTimestamps",10,0,11,7); + } else { + obj.FillHistogram("GR_LiveTimestamps",10,0,11,3); + } + + // obj.FillHistogram("GR_RF",1000,0,0,rf); + // auto first = TMath::Sqrt(adc[0]*adc[1]); + // auto second = TMath::Sqrt(adc[2]*adc[3]); + // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first); + // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second); + // } + } + } + + if(cagra) { + + static ULong_t ts_prev = 0; + + ULong_t current_time = cagra->Timestamp(); + if (ts_prev) { + auto diff = current_time - ts_prev; + if (diff < 0) { + obj.FillHistogram("TimeOrdering",10,0,11,3); + } else { + obj.FillHistogram("TimeOrdering",10,0,11,7); + } + } + ts_prev = current_time; + + + //cout << "Size: " << cagra->Size() << endl; + for (auto& hit : *cagra) { + + stream.str(""); + stream << "PostE_BoardID" << hit.GetBoardID() << "_Chan" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),10000,0,0,hit.Charge()); + obj.FillHistogram("DigitizerHits",12,97,109,hit.GetBoardID(),12,-1,11,hit.GetChannel()); + + stream.str(""); + stream << "Ge_" << hit.GetBoardID() << "Raw" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.Charge()); + stream.str(""); + stream << "Ge_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); + if (hit.GetBoardID() == 102) { + auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); + if (nevent % 10000 == 0) { cout << labr_E << endl; } + obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E); + } else { + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy()); + } + stream.str(""); + stream << "Ge_PZ_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); + //Double_t baseline = 180; + Double_t baseline = hit.GetBaseSample(); + //auto baseline = hit.GetTraceBaseline(); + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(0)); + stream.str(""); + stream << "Ge_PZ_AsymBL_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(baseline)); + + stream.str(""); + stream << "E_BL" << hit.GetBoardID() << "_" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),1000,0,10000,hit.GetEnergy(),1000,0,3000,baseline); + stream.str(""); + stream << "E_cor_BL" << hit.GetBoardID() << "_" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),1000,0,10000,hit.GetCorrectedEnergy(baseline),1000,0,3000,baseline); + + if (!TANLEvent::PileUpFlag(hit.GetFlags())) { + stream.str(""); + stream << "Ge_NoPileUp_" << hit.GetBoardID() << "Raw" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.Charge()); + stream.str(""); + stream << "Ge_NoPileUp_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); + if (hit.GetBoardID() == 102) { + auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); + if (nevent % 10000 == 0) { cout << labr_E << endl; } + obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E); + } else { + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy()); + } + } + else { + stream.str(""); + stream << "Ge_PileUp_" << hit.GetBoardID() << "Raw" << hit.GetChannel(); + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.Charge()); + stream.str(""); + stream << "Ge_PileUp_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); + if (hit.GetBoardID() == 102) { + auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); + if (nevent % 10000 == 0) { cout << labr_E << endl; } + obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E); + } else { + obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy()); + } + + + } + } + + } + + + if(numobj!=list->GetSize()) + list->Sort(); + + nevent++; +} From dadb0c956d5153f2b46f5922d47f9d7e00bf7ab5 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 11 Jul 2016 17:55:58 -0400 Subject: [PATCH 26/28] Added Getters for Pre/Post rise sum to TCagraHit, and added new histo loop CAGRA.cxx. When doing polezero analysis, one should look at PreRiseSum/M vs (Post - Pre)/M to determine the polezero correction. --- config/rcnp_peter.cal | 6 +- config/rcnpchannels.cal | 40 +++++ histos/CAGRA.cxx | 279 +++++++++++++++++++++++++++++++ histos/RCNPhistos.cxx | 6 +- include/TCagraHit.h | 2 + libraries/TGRUTUtil/TChannel.cxx | 1 + 6 files changed, 328 insertions(+), 6 deletions(-) create mode 100644 histos/CAGRA.cxx diff --git a/config/rcnp_peter.cal b/config/rcnp_peter.cal index babd64c8..85e7133d 100644 --- a/config/rcnp_peter.cal +++ b/config/rcnp_peter.cal @@ -87,7 +87,7 @@ EXT16AP00 { EXT17AP00 { Address: 0x01006607 EnergyCoeff: 0 1 - Pol o: 1 + PoleZero: 1 } EXT18AP00 { Address: 0x01006608 @@ -102,12 +102,12 @@ EXT19AP00 { EXT20AP00 { Address: 0x01006700 EnergyCoeff: -55.898 2.2208 - PoleZero: 0.920 + PoleZero: 0.911 } EXT21AP00 { Address: 0x01006701 EnergyCoeff: -53.9224 1.1362 - PoleZero: 0.920 + PoleZero: 0.911 } EXT22AP00 { Address: 0x01006702 diff --git a/config/rcnpchannels.cal b/config/rcnpchannels.cal index ea4a914f..f23ce0bf 100644 --- a/config/rcnpchannels.cal +++ b/config/rcnpchannels.cal @@ -3,162 +3,202 @@ EXT00AP00 { Address: 0x01006500 EnergyCoeff: 0 1 + PoleZero: 1 } EXT01AP00 { Address: 0x01006501 EnergyCoeff: 0 1 + PoleZero: 1 } EXT02AP00 { Address: 0x01006502 EnergyCoeff: 0 1 + PoleZero: 1 } EXT03AP00 { Address: 0x01006503 EnergyCoeff: 0 1 + PoleZero: 1 } EXT04AP00 { Address: 0x01006504 EnergyCoeff: 0 1 + PoleZero: 1 } EXT05AP00 { Address: 0x01006505 EnergyCoeff: 0 1 + PoleZero: 1 } EXT06AP00 { Address: 0x01006506 EnergyCoeff: 0 1 + PoleZero: 1 } EXT07AP00 { Address: 0x01006507 EnergyCoeff: 0 1 + PoleZero: 1 } EXT08AP00 { Address: 0x01006508 EnergyCoeff: 0 1 + PoleZero: 1 } EXT09AP00 { Address: 0x01006509 EnergyCoeff: 0 1 + PoleZero: 1 } EXT10AP00 { Address: 0x01006600 EnergyCoeff: 0 1 + PoleZero: 1 } EXT11AP00 { Address: 0x01006601 EnergyCoeff: 0 1 + PoleZero: 1 } EXT12AP00 { Address: 0x01006602 EnergyCoeff: 0 1 + PoleZero: 1 } EXT13AP00 { Address: 0x01006603 EnergyCoeff: 0 1 + PoleZero: 1 } EXT14AP00 { Address: 0x01006604 EnergyCoeff: 0 1 + PoleZero: 1 } EXT15AP00 { Address: 0x01006605 EnergyCoeff: 0 1 + PoleZero: 1 } EXT16AP00 { Address: 0x01006606 EnergyCoeff: 0 1 + PoleZero: 1 } EXT17AP00 { Address: 0x01006607 EnergyCoeff: 0 1 + PoleZero: 1 } EXT18AP00 { Address: 0x01006608 EnergyCoeff: 0 1 + PoleZero: 1 } EXT19AP00 { Address: 0x01006609 EnergyCoeff: 0 1 + PoleZero: 1 } EXT20AP00 { Address: 0x01006700 EnergyCoeff: -23.996 1.5685 + PoleZero: 0.89123 } EXT21AP00 { Address: 0x01006701 EnergyCoeff: -7.5781 1.5026 + PoleZero: 1 } EXT22AP00 { Address: 0x01006702 EnergyCoeff: -31.6613 1.5664 + PoleZero: 1 } EXT23AP00 { Address: 0x01006703 EnergyCoeff: 0 1 + PoleZero: 1 } EXT24AP00 { Address: 0x01006704 EnergyCoeff: 0 1 + PoleZero: 1 } EXT25AP00 { Address: 0x01006705 EnergyCoeff: 0 1 + PoleZero: 1 } EXT26AP00 { Address: 0x01006706 EnergyCoeff: 0 1 + PoleZero: 1 } EXT27AP00 { Address: 0x01006707 EnergyCoeff: 0 1 + PoleZero: 1 } EXT28AP00 { Address: 0x01006708 EnergyCoeff: 0 1 + PoleZero: 1 } EXT29AP00 { Address: 0x01006709 EnergyCoeff: 0 1 + PoleZero: 1 } EXT30AP00 { Address: 0x01006800 EnergyCoeff: -18.3471 0.8697 + PoleZero: 0.89123 } EXT31AP00 { Address: 0x01006801 EnergyCoeff: -7.7967 0.8227 + PoleZero: 1 } EXT32AP00 { Address: 0x01006802 EnergyCoeff: -23.9436 0.8553 + PoleZero: 1 } EXT33AP00 { Address: 0x01006803 EnergyCoeff: 0 1 + PoleZero: 1 } EXT34AP00 { Address: 0x01006804 EnergyCoeff: 0 1 + PoleZero: 1 } EXT35AP00 { Address: 0x01006805 EnergyCoeff: 0 1 + PoleZero: 1 } EXT36AP00 { Address: 0x01006806 EnergyCoeff: 0 1 + PoleZero: 1 } EXT37AP00 { Address: 0x01006807 EnergyCoeff: 0 1 + PoleZero: 1 } EXT38AP00 { Address: 0x01006808 EnergyCoeff: 0 1 + PoleZero: 1 } EXT39AP00 { Address: 0x01006809 EnergyCoeff: 0 1 + PoleZero: 1 } diff --git a/histos/CAGRA.cxx b/histos/CAGRA.cxx new file mode 100644 index 00000000..b0d6ae9d --- /dev/null +++ b/histos/CAGRA.cxx @@ -0,0 +1,279 @@ + +#include "TRuntimeObjects.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "TCagra.h" +#include "TGrandRaiden.h" +#include "TANLEvent.h" + +#define BAD_NUM -441441 + +//#include "TChannel.h" +//#include "GValue.h" + +#define PRINT(x) std::cout << #x" = " << x << std::endl +#define STR(x) #x << " = " <<() x + +using namespace std; + + +string name; +stringstream stream; +ULong_t nevent = 0; + +// extern "C" is needed to prevent name mangling. +// The function signature must be exactly as shown here, +// or else bad things will happen. +extern "C" +void MakeHistograms(TRuntimeObjects& obj) { + + + + TCagra* cagra = obj.GetDetector(); + TGrandRaiden* gr = obj.GetDetector(); + + TList *list = &(obj.GetObjects()); + int numobj = list->GetSize(); + + if (cagra && gr) { + for (auto& hit : *gr) { + + auto& rcnp = hit.GR(); + auto grtime = hit.GetTimestamp(); + + // coincidence rate + static ULong_t first_timestamp = grtime; + if (first_timestamp) { + auto rate = (grtime-first_timestamp)/1e8; + //cout << grtime << " " << first_timestamp << endl; + obj.FillHistogram("CoinRate",1000,0,10000, rate); + } + + // coincidence time difference + for (auto& caghit : *cagra) { + + ULong_t cagratime = caghit.Timestamp(); + Double_t cagra_cfd = caghit.GetDiscTime(); + + ULong_t ts_diff = cagratime-grtime; + Double_t cfd_diff = cagra_cfd-(Double_t)grtime; + + obj.FillHistogram("CoinDiff",2000,-1000,1000,ts_diff); + stream.str(""); + stream << "CoinDiff_" << caghit.GetBoardID() << "_" < 238 && cagratime -grtime < 246) { + stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated"; + obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy()); + obj.FillHistogram("GATETEST_CoinDiff",2000,-1000,1000,ts_diff); + } + obj.FillHistogram("CoinDiff_CFD",2000,-1000,1000,cfd_diff); + stream.str(""); + stream << "CoinDiff_CFD_" << caghit.GetBoardID() << "_" < 238 && cagra_cfd -grtime < 246) { + stream.str(""); stream << caghit.GetBoardID() << "Cal" << caghit.GetChannel() << "_CoinGated"; + obj.FillHistogram(stream.str().c_str(),10000,0,10000,caghit.GetEnergy()); + obj.FillHistogram("GATETEST_CoinDiff_CFD",2000,-1000,1000,cfd_diff); + } + + + } + + + + } + + } + + + if (gr) { + + for (auto& hit : *gr) { + + auto& rcnp = hit.GR(); + auto adc = rcnp.GR_ADC(); + + + if (rcnp.GR_MYRIAD(0) != BAD_NUM) { + obj.FillHistogram("MyriadTimestamp",10000,1e9,5e12,hit.GetTimestamp()); + } + + static ULong_t prev_ts = 0; + if (prev_ts) { + obj.FillHistogram("GR_EventPeriod",5000,100,50000,hit.GetTimestamp()-prev_ts); + } + prev_ts = hit.GetTimestamp(); + + + if (rcnp.GR_ADC()) { + auto& adc = *rcnp.GR_ADC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_ADC" << i; + obj.FillHistogram(stream.str().c_str(), 1000,0,2000, adc[i]); + } + obj.FillHistogram("MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram("MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2()); + } + if (rcnp.GR_TDC()) { + auto& tdc = *rcnp.GR_TDC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_TDC" << i; + obj.FillHistogram(stream.str().c_str(), 1000,-40000,40000, tdc[i]); + } + obj.FillHistogram("MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1()); + obj.FillHistogram("MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2()); + } + if (rcnp.QTC_LEADING_TDC()) { + auto& qtc_leading = *rcnp.QTC_LEADING_TDC(); + auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH(); + auto x = rcnp.GR_X(0); + + for (int i=0; i< qtc_leading_chan.size(); i++) { + int channum = qtc_leading_chan[i]; + stream.str(""); stream << "LaBrLeading" << channum; + obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + // gate on gr_x + if (x < 100 && x > 0) { + stream.str(""); stream << "LaBrLead"<< channum << "_GateX"; + obj.FillHistogram(stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + } + + + + if (qtc_leading[i]>=-5100 && qtc_leading[i] <=-4400) { + + + obj.FillHistogram("RayID_LEGate",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR_X_LEGate",1200,-600,600, rcnp.GR_X(0)); + obj.FillHistogram("GR_Y_LEGate",200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR_Theta_LEGate",100,-1,1, rcnp.GR_TH(0)); // need to learn + obj.FillHistogram("GR_Phi_LEGate",100,-1,1, rcnp.GR_PH(0)); // from hist.def + obj.FillHistogram("X_TH_LEGate",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + } + + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth_LEGate" << channum; + obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); + + if (rcnp.GR_X(0) != BAD_NUM) { + obj.FillHistogram("X_LaBr_LEGate",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + } + } + + + } + + + } + } + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth" << channum; + obj.FillHistogram(stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); + + if (rcnp.GR_X(0) != BAD_NUM) { + obj.FillHistogram("X_LaBr",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + } + + } + obj.FillHistogram("RayID",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR_X",1200,-600,600, rcnp.GR_X(0)); + obj.FillHistogram("GR_Y",200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn + obj.FillHistogram("GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def + obj.FillHistogram("X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + } + auto rf = rcnp.GR_RF(0); + if (rf != BAD_NUM) { + obj.FillHistogram("GR_RF",1000,0,0,rf); + } + + //GR timestamps check - sometimes the myriad timestamp is missing... + //static int n_gr = 0; + auto time = rcnp.GR_MYRIAD(0); + if (time != BAD_NUM) { + obj.FillHistogram("GR_LiveTimestamps",10,0,11,7); + } else { + obj.FillHistogram("GR_LiveTimestamps",10,0,11,3); + } + + // obj.FillHistogram("GR_RF",1000,0,0,rf); + // auto first = TMath::Sqrt(adc[0]*adc[1]); + // auto second = TMath::Sqrt(adc[2]*adc[3]); + // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first); + // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second); + // } + } + } + + if(cagra) { + + for (auto& hit : *cagra) { + + auto boardid = hit.GetBoardID(); + auto chan = hit.GetChannel(); + + stream.str(""); + stream << "Ge_" << boardid << "_" << chan; + obj.FillHistogram("Raw", stream.str().c_str(),10000,0,10000,hit.Charge()); + + stream.str(""); + stream << "Ge_" << boardid << "_" << chan; + if (boardid == 102) { + auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); + //if (nevent % 10000 == 0) { cout << labr_E << endl; } + obj.FillHistogram("Calibrated",stream.str().c_str(),10000,0,10000,labr_E); + } else { + obj.FillHistogram("Calibrated",stream.str().c_str(),10000,0,10000,hit.GetEnergy()); + } + + stream.str(""); + stream << "Ge_PZ_" << boardid << "_" << chan; + obj.FillHistogram("Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(0)); + stream.str(""); + stream << "Ge_PZ_AsymBL_" << boardid << "Cal" << chan; + obj.FillHistogram("Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample())); + + Double_t prerise_base = hit.GetPreRise()/TANLEvent::GetShapingTime(); + + stream.str(""); + stream << "E_BL" << boardid << "_" << chan; + obj.FillHistogram("Baseline", stream.str().c_str(),1000,0,10000,hit.Charge(),1000,0,3000,prerise_base); + + stream.str(""); + stream << "E_BL_scale" << boardid << "_" << chan; + obj.FillHistogram("Baseline", stream.str().c_str(),1000,0,10000,hit.Charge()-(1.0/-11.21)*prerise_base,1000,0,3000,prerise_base); + + stream.str(""); + stream << "E_cor_BL" << boardid << "_" << chan; + obj.FillHistogram("Baseline", stream.str().c_str(),1000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample()),1000,0,3000,prerise_base); + + + + } + + } + + + if(numobj!=list->GetSize()) + list->Sort(); + + nevent++; +} diff --git a/histos/RCNPhistos.cxx b/histos/RCNPhistos.cxx index 8fe04aac..f524b2e7 100644 --- a/histos/RCNPhistos.cxx +++ b/histos/RCNPhistos.cxx @@ -254,7 +254,7 @@ void MakeHistograms(TRuntimeObjects& obj) { stream << "Ge_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); if (hit.GetBoardID() == 102) { auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); - if (nevent % 10000 == 0) { cout << labr_E << endl; } + //if (nevent % 10000 == 0) { cout << labr_E << endl; } obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E); } else { obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy()); @@ -284,7 +284,7 @@ void MakeHistograms(TRuntimeObjects& obj) { stream << "Ge_NoPileUp_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); if (hit.GetBoardID() == 102) { auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); - if (nevent % 10000 == 0) { cout << labr_E << endl; } + //if (nevent % 10000 == 0) { cout << labr_E << endl; } obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E); } else { obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy()); @@ -298,7 +298,7 @@ void MakeHistograms(TRuntimeObjects& obj) { stream << "Ge_PileUp_" << hit.GetBoardID() << "Cal" << hit.GetChannel(); if (hit.GetBoardID() == 102) { auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); - if (nevent % 10000 == 0) { cout << labr_E << endl; } + //if (nevent % 10000 == 0) { cout << labr_E << endl; } obj.FillHistogram(stream.str().c_str(),10000,0,10000,labr_E); } else { obj.FillHistogram(stream.str().c_str(),10000,0,10000,hit.GetEnergy()); diff --git a/include/TCagraHit.h b/include/TCagraHit.h index 056a08a3..f952c102 100644 --- a/include/TCagraHit.h +++ b/include/TCagraHit.h @@ -48,6 +48,8 @@ class TCagraHit : public TDetectorHit { Double_t GetCorrectedEnergy(Double_t asym_bl=0.); void SetPreRise(Double_t prerise) { prerise_energy = prerise; } void SetPostRise(Double_t postrise) { postrise_energy = postrise; } + Double_t GetPreRise() { return prerise_energy; } + Double_t GetPostRise() { return postrise_energy; } void SetFlags(UShort_t fl) { flags = fl; } const UShort_t& GetFlags() const { return flags; } void SetBaseSample(UShort_t base) { base_sample = base; } diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index c34e474f..38354c42 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -7,6 +7,7 @@ #include #include #include +#include #include "TRandom.h" From 69ea6e6816be92f0e6d93c6851f91991c6e64dcb Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 13 Jul 2016 14:48:29 -0400 Subject: [PATCH 27/28] Fixed bug with the saving of TChannel calibration information into the rootfile. Added styling to mainwindow.py since it overwrites SetPadTickX/Y options applied in the logon file. Added functions in TGrandRaiden to make it easier to plot from within the interpreter. Added new analysis / histo file: RCNPAna.cxx. --- .grutrc | 7 +- histos/RCNPAna.cxx | 324 +++++++++++++++++++++++++++++++ include/TGrandRaiden.h | 5 + libraries/TGRUTUtil/TChannel.cxx | 26 +++ pygui/mainwindow.py | 4 +- 5 files changed, 360 insertions(+), 6 deletions(-) create mode 100644 histos/RCNPAna.cxx diff --git a/.grutrc b/.grutrc index 2d699de4..4bb9edae 100644 --- a/.grutrc +++ b/.grutrc @@ -2,14 +2,11 @@ Unix.*.Root.MacroPath: .:$(GRUTSYS)/util:$(ROOTSYS)/macros #Unix.*.Root.DynamicPath: .:~/rootlibs:$(ROOTSYS)/lib:$/home/tiguser/packages/SharcAnalysis #default MakeHistos library -#GRUT.HistLib: $(GRUTSYS)/libraries/libMakeHistos.so -GRUT.HistLib: $(GRUTSYS)/libraries/libFastScintHists.so -#GRUT.HistLib: $(GRUTSYS)/libraries/libPolarHists.so -#GRUT.HistLib: $(GRUTSYS)/libraries/libMakeSegaJanusHistos.so +GRUT.HistLib: $(GRUTSYS)/libraries/libRCNPsav.so GRUT.GuiSetup: $(GRUTSYS)/gui_params.hist #files to load at log in: -Rint.Logon: $(GRUTSYS)/.grut_logon +Rint.Logon: $(GRUTSYS)/logon.C Rint.History $(GRUTSYS)/.grut_history Rint.HistSize: 1000000 diff --git a/histos/RCNPAna.cxx b/histos/RCNPAna.cxx new file mode 100644 index 00000000..d01ad85c --- /dev/null +++ b/histos/RCNPAna.cxx @@ -0,0 +1,324 @@ + +#include "TRuntimeObjects.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "TCagra.h" +#include "TGrandRaiden.h" + +#define BAD_NUM -441441 + +#include "TANLEvent.h" +//#include "GValue.h" + +#define PRINT(x) std::cout << #x" = " << x << std::endl +#define STR(x) #x << " = " <<() x + +using namespace std; + + +string name; +stringstream stream; + + +// extern "C" is needed to prevent name mangling. +// The function signature must be exactly as shown here, +// or else bad things will happen. +extern "C" +void MakeHistograms(TRuntimeObjects& obj) { + + + + TCagra* cagra = obj.GetDetector(); + TGrandRaiden* gr = obj.GetDetector(); + + TList *list = &(obj.GetObjects()); + int numobj = list->GetSize(); + + if (cagra && gr) { + for (auto& hit : *gr) { + + auto& rcnp = hit.GR(); + auto grtime = hit.GetTimestamp(); + + auto x = rcnp.GR_X(0); + auto Ex = x*0.0109738+7.65621; + + // coincidence rate + static ULong_t first_timestamp = grtime; + if (first_timestamp) { + auto rate = (grtime-first_timestamp)/1e8; + //cout << grtime << " " << first_timestamp << endl; + obj.FillHistogram("COIN","Rate",3000,0,30000, rate); + } + + // coincidence time difference + for (auto& caghit : *cagra) { + + auto cagratime = caghit.Timestamp(); + auto tdiff = cagratime-grtime; + obj.FillHistogram("COIN","Diff",1000,-1000,1000,cagratime-grtime); + stream.str(""); + stream << "TimeDiff_" << caghit.GetBoardID() << "_" < 235) && (tdiff < 245) ){ + + stream.str(""); + stream << "Ge_"<< caghit.GetBoardID() << "_" << caghit.GetChannel(); + obj.FillHistogram("COIN_Raw",stream.str(),10000,0,10000,caghit.Charge()); + stream.str(""); + stream << "Ge_" << caghit.GetBoardID() << "_" << caghit.GetChannel(); + obj.FillHistogram("COIN_Calibrated",stream.str(),10000,0,10000,caghit.GetEnergy()); + + stream.str(""); + stream << "Ex_Ge_" << caghit.GetBoardID() << "_" << caghit.GetChannel(); + obj.FillHistogram("COIN_Calibrated",stream.str(),1000,0,20,Ex,2500,0,10,caghit.GetEnergy()*0.0010552+0.0636885); + + stream.str(""); + stream << "Ex_CAGRACorrected_" << caghit.GetBoardID() << "_" << caghit.GetChannel(); + obj.FillHistogram("COIN_Calibrated", stream.str().c_str(),1000,0,20,Ex,2500,0,10000,caghit.GetCorrectedEnergy(caghit.GetBaseSample())); + } + + } + + + } + + + // int totalhits = 0; + // for (auto& hit : *gr) { totalhits++; } + // for (int i=0; i < totalhits; i++) { + // obj.FillHistogram("nCoin",4,0,1,0); + // } + + // static int ncoin = 0; + // ncoin+=totalhits; + } + + + if (gr) { + + for (auto& hit : *gr) { + + auto& rcnp = hit.GR(); + auto adc = rcnp.GR_ADC(); + + + if (rcnp.GR_MYRIAD(0) != BAD_NUM) { + obj.FillHistogram("Timing","MyriadTimestamp",10000,1e9,5e12,hit.GetTimestamp()); + } + + static ULong_t prev_ts = 0; + if (prev_ts) { + obj.FillHistogram("Timing","GR_EventPeriod",5000,100,50000,hit.GetTimestamp()-prev_ts); + } + prev_ts = hit.GetTimestamp(); + + auto rf = rcnp.GR_RF(0); + if (rf != BAD_NUM) { + + obj.FillHistogram("GR","GR_RF",1000,0,0,rf); + } + + if (rcnp.GR_ADC()) { + auto& adc = *rcnp.GR_ADC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_ADC" << i; + obj.FillHistogram("GR",stream.str().c_str(), 1000,0,2000, adc[i]); + } + obj.FillHistogram("GR","MeanPlastE1", 2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram("GR","MeanPlastE2", 2000,0,2000, hit.GetMeanPlastE2()); + if (rf != BAD_NUM) { + obj.FillHistogram("GR","dE1_RF",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram("GR","dE2_RF",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE2()); + obj.FillHistogram("GR","dE2_dE1",2000,0,2000, hit.GetMeanPlastE2(),2000,0,2000, hit.GetMeanPlastE1()); + + } + } + if (rcnp.GR_TDC()) { + auto& tdc = *rcnp.GR_TDC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_TDC" << i; + obj.FillHistogram("GR",stream.str().c_str(), 1000,-40000,40000, tdc[i]); + } + obj.FillHistogram("GR","MeanPlastPos1", 1000, 0, 40000, hit.GetMeanPlastPos1()); + obj.FillHistogram("GR","MeanPlastPos2", 1000, 0, 40000, hit.GetMeanPlastPos2()); + } + if (rcnp.QTC_LEADING_TDC()) { + auto& qtc_leading = *rcnp.QTC_LEADING_TDC(); + auto& qtc_leading_chan = *rcnp.QTC_LEADING_CH(); + auto x = rcnp.GR_X(0); + auto Ex = x*0.0109738+7.65621; + double Egamma; + + for (int i=0; i< qtc_leading_chan.size(); i++) { + int channum = qtc_leading_chan[i]; + stream.str(""); stream << "LaBrLeading" << channum; + obj.FillHistogram("GR",stream.str().c_str(), 10000,-40000, 40000, qtc_leading[i]); + + /* cut on prompt timing peak */ + + if (qtc_leading[i]>=-5100 && qtc_leading[i] <=-4300) { + + obj.FillHistogram("GR_Prompt","RayID",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR_Prompt","GR_X",1200,-600,600, rcnp.GR_X(0)); + obj.FillHistogram("GR_Prompt","GR_Y",200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR_Prompt","GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn + obj.FillHistogram("GR_Prompt","GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def + obj.FillHistogram("GR_Prompt","X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + + obj.FillHistogram("GR_Prompt","GR_Theta_Phi",100,-1,1, rcnp.GR_TH(0),100,-1,1, rcnp.GR_PH(0)); // need to learn + obj.FillHistogram("GR_Prompt","GR_X_Y",1200,-600,600, rcnp.GR_X(0),200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR_Prompt","GR_X_cal",1000,0,20, Ex); + + } + + // this needs to be moved out of the loop over qtc_chan I think - Chris + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth_LEGate" << channum; + obj.FillHistogram("GR_Prompt",stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); + if (channum == 1) { + Egamma = labr_hit.width*0.00190458-1.27177; + obj.FillHistogram("GR_Prompt","X_LaBrWidth1",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + obj.FillHistogram("GR_Prompt","LaBr1_cal", 1000,0,20,Egamma); + if ((Ex > Egamma-0.150)&&(Ex < Egamma+0.150)) { + obj.FillHistogram("GR_Prompt","LaBr1_cal_GS", 1000,0,20,labr_hit.width*0.00181-1.0887); + } + obj.FillHistogram("GR_Prompt","x_LaBr1_cal",1200,-600,600,x,1000,0,20,Egamma); + obj.FillHistogram("GR_Prompt","Ex_LaBr1_cal",1000,-0,20,Ex,1000,0,20,Egamma); + obj.FillHistogram("GR_Prompt","Ex",1000,-0,20,Ex); + obj.FillHistogram("GR_Prompt","LaBr1_cal_rf", 1000,0,20,Egamma,1000,-5500,4000,qtc_leading[i]-rf); + + } + + if (channum == 3) { + Egamma = labr_hit.width*0.00168037-0.931571; + obj.FillHistogram("GR_Prompt","LaBr2_cal", 1000,0,20,Egamma); + obj.FillHistogram("GR_Prompt","X_LaBrWidth2",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + obj.FillHistogram("GR_Prompt","Ex_LaBr2_cal",1000,-0,20,Ex,1000,0,20,Egamma); + obj.FillHistogram("GR_Prompt","LaBr2_cal_rf", 1000,0,20,Egamma,1000,-5500,4000,qtc_leading[i]-rf); + if ((Ex > Egamma-0.150)&&(Ex < Egamma+0.150)) { + obj.FillHistogram("GR_Prompt","LaBr2_cal_GS", 1000,0,20,labr_hit.width*0.00181-1.0887); + } + } + + if (rcnp.GR_TH(0)<0.04){ + obj.FillHistogram("GR_Prompt","Gamma_cal_cutTheta", 1000,0,20,Egamma); + if ((Ex > Egamma-0.150)&&(Ex < Egamma+0.150)) { + obj.FillHistogram("GR_Prompt","Gamma_cal_cutTheta_GS", 1000,0,20,labr_hit.width*0.00181-1.0887); + } + //if (Ex > 9. && Ex < 10.) { + //obj.FillHistogram("Gamma_cal_Ex_9650", 1000,0,10,labr_hit.width*0.00181-1.0887); + //} + // obj.FillHistogram("x_Egamma_prompt",1200,-600,600,x,1000,0,20,Egamma); + // obj.FillHistogram("Ex_Egamma_prompt",1000,-0,20,Ex,1000,0,20,Egamma); + obj.FillHistogram("GR_Prompt","Ex_TH_cutTheta",1000,0,20,Ex,1000,-1,1,rcnp.GR_TH(0)); + } + + } + } + + } + } + + for (auto const& labr_hit : hit.GetLaBr()) { + int channum = labr_hit.channel; + stream.str(""); stream << "LaBrWidth" << channum; + obj.FillHistogram("GR",stream.str().c_str(), 10000, -5000, 15000, labr_hit.width); + stream.str(""); stream << "LaBrWidth_cal" << channum; + obj.FillHistogram("GR",stream.str().c_str(), 1000,0,20,labr_hit.width*0.00181-1.0887); + + if (rcnp.GR_X(0) != BAD_NUM) { + obj.FillHistogram("GR","X_LaBr",1200,-600,600,rcnp.GR_X(0),10000,-5000,15000,labr_hit.width); + if (channum == 1){ + obj.FillHistogram("GR","X_LaBr_cal",1000,-0,20,rcnp.GR_X(0)*0.0109+7.6324,1000,0,20,labr_hit.width*0.00181-1.0887); + } + } + + } + obj.FillHistogram("GR","RayID",64,-16,48, rcnp.GR_RAYID(0)); + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + obj.FillHistogram("GR","GR_X",1200,-600,600, rcnp.GR_X(0)); + obj.FillHistogram("GR","GR_X_cal",1000,0,20, rcnp.GR_X(0)*0.0109+7.6324); + obj.FillHistogram("GR","GR_Y",200,-100,100, rcnp.GR_Y(0)); + obj.FillHistogram("GR","GR_Theta",100,-1,1, rcnp.GR_TH(0)); // need to learn + obj.FillHistogram("GR","GR_Phi",100,-1,1, rcnp.GR_PH(0)); // from hist.def + obj.FillHistogram("GR","X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + } + + // obj.FillHistogram("GR_RF",1000,0,0,rf); + // auto first = TMath::Sqrt(adc[0]*adc[1]); + // auto second = TMath::Sqrt(adc[2]*adc[3]); + // obj.FillHistogram("pid_1",500,0,0,rf,500,0,0,first); + // obj.FillHistogram("pid_2",500,0,0,rf,500,0,0,second); + // } + } + } + + if(cagra) { + + for (auto& hit : *cagra) { + + auto boardid = hit.GetBoardID(); + auto chan = hit.GetChannel(); + + stream.str(""); + stream << "Ge_" << boardid << "_" << chan; + obj.FillHistogram("CAGRA_Raw", stream.str().c_str(),10000,0,10000,hit.Charge()); + + stream.str(""); + stream << "Ge_" << boardid << "_" << chan; + if (boardid == 102) { + auto labr_E = hit.GetTraceEnergy(0,57,60,60+57); + //if (nevent % 10000 == 0) { cout << labr_E << endl; } + obj.FillHistogram("CAGRA_Calibrated",stream.str().c_str(),10000,0,10000,labr_E); + } else { + obj.FillHistogram("CAGRA_Calibrated",stream.str().c_str(),10000,0,10000,hit.GetEnergy()); + } + + stream.str(""); + stream << "Ge_PZ_" << boardid << "_" << chan; + obj.FillHistogram("CAGRA_Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(0)); + stream.str(""); + stream << "Ge_PZ_AsymBL_" << boardid << "Cal" << chan; + obj.FillHistogram("CAGRA_Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample())); + + Double_t prerise_base = hit.GetPreRise()/TANLEvent::GetShapingTime(); + + stream.str(""); + stream << "E_BL" << boardid << "_" << chan; + obj.FillHistogram("CAGRA_Baseline", stream.str().c_str(),1000,0,10000,hit.Charge(),1000,0,3000,prerise_base); + + stream.str(""); + stream << "E_BL_scale" << boardid << "_" << chan; + obj.FillHistogram("CAGRA_Baseline", stream.str().c_str(),1000,0,10000,hit.Charge()-(1.0/-11.21)*prerise_base,1000,0,3000,prerise_base); + + stream.str(""); + stream << "E_cor_BL" << boardid << "_" << chan; + obj.FillHistogram("CAGRA_Baseline", stream.str().c_str(),1000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample()),1000,0,3000,prerise_base); + + + + } + + } + + + + if(numobj!=list->GetSize()) + list->Sort(); + + +} diff --git a/include/TGrandRaiden.h b/include/TGrandRaiden.h index a45cc379..107966f9 100644 --- a/include/TGrandRaiden.h +++ b/include/TGrandRaiden.h @@ -28,6 +28,11 @@ class TGrandRaiden : public TDetector { std::vector::iterator begin() { return GRHits.begin(); } std::vector::iterator end() { return GRHits.end(); } + + + bool CheckHit(UInt_t i) { return (i < GRHits.size()) ? true : false; } + RCNPEvent* GetGRHit(UInt_t i) { return GRHits.at(i).GR(); } + private: virtual int BuildHits(std::vector& raw_data); diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index 38354c42..2e99a06c 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -68,6 +68,32 @@ std::ostream& operator<<(std::ostream& out, const TChannel& chan) { out << "\n"; } + // Print out each PoleZero correction coeff + for(auto& start_coeff : chan.polezero_corrections) { + out << " PoleZero"; + if(start_coeff.start_time != -DBL_MAX) { + out << "[" << start_coeff.start_time << "]"; + } + out << ":"; + for(double coef : start_coeff.coefficients) { + out << "\t" << coef; + } + out << "\n"; + } + + // Print out each Baseline correction coeff + for(auto& start_coeff : chan.baseline_corrections) { + out << " Baseline"; + if(start_coeff.start_time != -DBL_MAX) { + out << "[" << start_coeff.start_time << "]"; + } + out << ":"; + for(double coef : start_coeff.coefficients) { + out << "\t" << coef; + } + out << "\n"; + } + // Print out each time coefficient for(auto& start_coeff : chan.time_coeff) { out << " TimeCoeff"; diff --git a/pygui/mainwindow.py b/pygui/mainwindow.py index 6efb705c..f6774586 100755 --- a/pygui/mainwindow.py +++ b/pygui/mainwindow.py @@ -101,7 +101,7 @@ def _load_icons(self): def _load_default_style(self): style = ROOT.TStyle("GRUTStyle","") - style.SetOptStat(1001111) + #style.SetOptStat(1001111) style.SetPalette(1) style.SetTitleColor(ROOT.kBlue) style.SetStatTextColor(ROOT.kBlue) @@ -110,6 +110,8 @@ def _load_default_style(self): style.SetOptFit(1111) style.SetPadBorderSize(1) style.SetPadBorderMode(1) + style.SetPadTickX(1); # + style.SetPadTickY(1); # ROOT.gROOT.SetStyle("GRUTStyle") ROOT.gROOT.ForceStyle() From c982e40e134f2d7ecff565cfb991a7f470f0200a Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 13 Jul 2016 14:56:04 -0400 Subject: [PATCH 28/28] Error fix in last commit. --- include/TGrandRaiden.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/TGrandRaiden.h b/include/TGrandRaiden.h index 107966f9..a1f74432 100644 --- a/include/TGrandRaiden.h +++ b/include/TGrandRaiden.h @@ -31,7 +31,7 @@ class TGrandRaiden : public TDetector { bool CheckHit(UInt_t i) { return (i < GRHits.size()) ? true : false; } - RCNPEvent* GetGRHit(UInt_t i) { return GRHits.at(i).GR(); } + RCNPEvent& GetGRHit(UInt_t i) { return GRHits.at(i).GR(); } private: virtual int BuildHits(std::vector& raw_data);