From e2f0efaa87b270ee311aa0188d2d3752f62dd209 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 26 Feb 2016 13:37:14 -0500 Subject: [PATCH 01/94] Adding new TDetector system for parsing mode 3 data from the LBL digitizers with the Argonne National Lab firmware. This will allow us to instrument DGS and CAGRA data in GRUTinizer. --- include/TArgonne.h | 41 ++++++ include/TArgonneHit.h | 71 +++++++++ include/TRawBanks.h | 29 ++++ libraries/TDetSystems/TArgonne/LinkDef.h | 14 ++ libraries/TDetSystems/TArgonne/TArgonne.cxx | 47 ++++++ .../TDetSystems/TArgonne/TArgonneHit.cxx | 135 ++++++++++++++++++ 6 files changed, 337 insertions(+) create mode 100644 include/TArgonne.h create mode 100644 include/TArgonneHit.h create mode 100644 libraries/TDetSystems/TArgonne/LinkDef.h create mode 100644 libraries/TDetSystems/TArgonne/TArgonne.cxx create mode 100644 libraries/TDetSystems/TArgonne/TArgonneHit.cxx diff --git a/include/TArgonne.h b/include/TArgonne.h new file mode 100644 index 00000000..5baee79a --- /dev/null +++ b/include/TArgonne.h @@ -0,0 +1,41 @@ +#ifndef TARGONNE_H +#define TARGONNE_H + +#include +#include + +#include + +#include "TDetector.h" +#include "TArgonneHit.h" + +class TArgonne : public TDetector { + +public: + TArgonne(); + ~TArgonne(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + virtual void InsertHit(const TDetectorHit& hit); + virtual TDetectorHit& GetHit(int i) { return anl_hits.at(i); } + + const TArgonneHit& GetArgonneHit(int i) { return anl_hits.at(i); } + void PrintHit(int i){ anl_hits.at(i).Print(); } + +private: + virtual int BuildHits(); + + //TClonesArray* anl_hits;//("TArgonneHit"); + std::vector anl_hits; + + ClassDef(TArgonne,3); +}; + + + + + +#endif diff --git a/include/TArgonneHit.h b/include/TArgonneHit.h new file mode 100644 index 00000000..3c56c603 --- /dev/null +++ b/include/TArgonneHit.h @@ -0,0 +1,71 @@ +#ifndef TARGONNE3HIT_H +#define TARGONNE3HIT_H + +#include "TDetector.h" +#include "TDetectorHit.h" +//#include "TGretinaHit.h" + +#define MAXTRACE 1024 + +class TArgonneHit : public TDetectorHit { + public: + TArgonneHit(); + ~TArgonneHit(); + + virtual void Copy(TObject& obj) const; + //virtual void Compare(TObject &obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + virtual void ClearWave(Option_t *opt = ""); + + //virtual void InsertHit(const TDetectorHit& hit) { return; } + //virtual TDetectorHit& GetHit(const int &i=0) { return hit; } + //virtual int Size() { return 1; } + double AverageWave(int samples=-1); + + void BuildFrom(TSmartBuffer buf); + + Int_t GetChannel() const { return (board_id & 0x000f); } + Int_t GetVME() const { return (board_id & 0x0030)>>4; } + Int_t GetCrystal() const { return (board_id & 0x00c0)>>6; } + Int_t GetHole() const { return (board_id & 0x1f00)>>8; } + Int_t GetSegmentId() const { return GetVME()*10 + GetChannel(); } + Int_t GetCrystalId() const { return GetHole()*4 + GetCrystal(); } + Int_t GetWaveSize() const { return wavesize; } + Short_t* GetWave() const { return wave; } + + Long_t GetLed() const { return led; } + Long_t GetCfd() const { return cfd; } + + + static void SetExtractWaves(bool flag=true) { fExtractWaves = flag; } + static bool ExtractWaves() { return fExtractWaves; } + + virtual Int_t Charge() const { return charge; } + //Int_t Address() { return hit.Address(); } + + private: + //virtual int BuildHits(); + + static bool fExtractWaves; //! + //mutable bool fOwnWave; //! + + //TDetectorHit hit; + + Int_t board_id; + Int_t charge; + Int_t wavesize; // In 16-bit elements + Long_t led; + Long_t cfd; + Short_t wavebuffer[MAXTRACE]; //! + Short_t *wave; //[wavesize] + + + ClassDef(TArgonneHit,2); +}; + + + + + +#endif diff --git a/include/TRawBanks.h b/include/TRawBanks.h index fa780ad7..5244540c 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -275,6 +275,35 @@ struct GEBMode3Data { friend std::ostream& operator<<(std::ostream& os, const GEBMode3Data &data); static void SwapMode3Data(GEBMode3Data &data); +struct GEBArgonneLEDHead { + UShort_t a2; + UShort_t a1; + UShort_t lengthGA; + UShort_t board_id; +}__attribute__((__packed__)); + +//friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDHead &head); +//static void SwapArgonneLEDHead(GEBArgonneLEDHead &head); + +struct GEBArgonneLEDData { + UShort_t led_middle; + UShort_t led_low; + UShort_t energy_low; + UShort_t led_high; + UShort_t cfd_low; + UShort_t energy_high; + UShort_t cfd_high; + UShort_t cfd_middle; + UShort_t cfd_pt1_high; + UShort_t cfd_pt1_low; + UShort_t cfd_pt2_high; + UShort_t cfd_pt2_low; +}__attribute__((__packed__)); + +//friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDData &data); +//static void SwapArgonneLEDData(GEBArgonneLEDData &data); + + struct GEBS800Header { Int_t total_size; UShort_t total_size2; diff --git a/libraries/TDetSystems/TArgonne/LinkDef.h b/libraries/TDetSystems/TArgonne/LinkDef.h new file mode 100644 index 00000000..59685e55 --- /dev/null +++ b/libraries/TDetSystems/TArgonne/LinkDef.h @@ -0,0 +1,14 @@ +// TArgonne.h TArgonneHit.h + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclasses; + +#pragma link C++ class TArgonneHit+; +#pragma link C++ class std::vector+; +#pragma link C++ class TArgonne+; + +#endif diff --git a/libraries/TDetSystems/TArgonne/TArgonne.cxx b/libraries/TDetSystems/TArgonne/TArgonne.cxx new file mode 100644 index 00000000..f5597524 --- /dev/null +++ b/libraries/TDetSystems/TArgonne/TArgonne.cxx @@ -0,0 +1,47 @@ +#include "TArgonne.h" + +#include "TGEBEvent.h" + +TArgonne::TArgonne(){ + //anl_hits = new TClonesArray("TArgonneHit"); + Clear(); +} + +TArgonne::~TArgonne() { + //delete anl_hits; +} + +void TArgonne::Copy(TObject& obj) const { + TDetector::Copy(obj); + + TArgonne& detector = (TArgonne&)obj; + detector.anl_hits = anl_hits; + //anl_hits->Copy(*detector.anl_hits); + detector.raw_data.clear(); +} + +void TArgonne::InsertHit(const TDetectorHit& hit){ + //TArgonneHit* new_hit = (TArgonneHit*)anl_hits->ConstructedAt(Size()); + //hit.Copy(*new_hit); + anl_hits.emplace_back((TArgonneHit&)hit); + fSize++; +} + +int TArgonne::BuildHits(){ + for(auto& event : raw_data){ + SetTimestamp(event.GetTimestamp()); + TArgonneHit hit; + hit.BuildFrom(event.GetPayloadBuffer()); + hit.SetTimestamp(event.GetTimestamp()); + InsertHit(hit); + } + return Size(); +} + +void TArgonne::Print(Option_t *opt) const { } + +void TArgonne::Clear(Option_t *opt) { + //TDetector::Clear(opt); + anl_hits.clear(); //->Clear(opt);//("TArgonneHit"); + raw_data.clear(); +} diff --git a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx new file mode 100644 index 00000000..2e24436e --- /dev/null +++ b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx @@ -0,0 +1,135 @@ +#include "TArgonneHit.h" + +#include "TGEBEvent.h" +#include "TGRUTOptions.h" + +ClassImp(TArgonneHit) + +bool TArgonneHit::fExtractWaves = true; + +TArgonneHit::TArgonneHit(){ + //fOwnWave = false; + wave = NULL; + wavesize = 0; + for(int i=0;iExtractWaves(); + + auto header = (TRawEvent::GEBMode3Head*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBMode3Head)); + + board_id = header->board_id; + + auto data = (TRawEvent::GEBMode3Data*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBMode3Data)); + + led = data->GetLed(); + charge = data->GetEnergy(*header); + SetCharge(data->GetEnergy(*header)); + + SetAddress((2<<24) + + (GetCrystalId()<<16) ); + cfd = data->GetCfd(); + + size_t wave_bytes = header->GetLength()*4 - sizeof(*header) + 4 - sizeof(*data); + if(read_waveform & (wavesize0) { + //fOwnWave = true; + //mode3.wave = new Short_t[wavesize]; + memcpy(mode3.wavebuffer,wavebuffer,wavesize*(sizeof(Short_t))); + mode3.wave = &(mode3.wavebuffer[0]); + } else { + mode3.wave=0; + } + //mode3.raw_data.clear(); +} + + +void TArgonneHit::Print(Option_t *opt) const { } + +void TArgonneHit::Clear(Option_t *opt) { + TDetectorHit::Clear(opt); + board_id = -1; + charge = -1; + led = -1; + cfd = -1; + //if(fOwnWave && wave) { + // delete wave; + //} + ClearWave(); + //raw_data.clear(); +} + +void TArgonneHit::ClearWave(Option_t *opt) { + for(int i=0;iMAXTRACE) + break; + //std::cout << "Clear wave " << i << std::endl; + wavebuffer[i] = 0; + } + wave = NULL; + wavesize = 0; +} + +double TArgonneHit::AverageWave(int samples) { + //printf("wavesize = %i\n",wavesize); + if(wavesize<1) + return 0.0; + if(samples<0 || samples >wavesize) + samples = wavesize; + double avg = 0.0; + for(int i=0;i Date: Wed, 2 Mar 2016 15:44:42 -0500 Subject: [PATCH 02/94] Built out TArgonne(Hit) classes. The raw event parser should now handle the Argonne National Lab data with firmware v1.1 and of the LED type. Support for other formats and versions will come later. Added ANL as a detector system, and am now ready to adjust GRUTinizer unpacking logic to handle events from raw data files. --- include/TArgonne.h | 2 +- include/TArgonneHit.h | 68 +++---- include/TGRUTTypes.h | 6 +- include/TRawBanks.h | 78 ++++--- .../TDetSystems/TArgonne/TArgonneHit.cxx | 190 +++++++++--------- libraries/TRawFormat/LinkDef.h | 2 +- libraries/TRawFormat/TRawBanks.cxx | 94 ++++++++- 7 files changed, 284 insertions(+), 156 deletions(-) diff --git a/include/TArgonne.h b/include/TArgonne.h index 5baee79a..343795e3 100644 --- a/include/TArgonne.h +++ b/include/TArgonne.h @@ -31,7 +31,7 @@ class TArgonne : public TDetector { //TClonesArray* anl_hits;//("TArgonneHit"); std::vector anl_hits; - ClassDef(TArgonne,3); + ClassDef(TArgonne,1); }; diff --git a/include/TArgonneHit.h b/include/TArgonneHit.h index 3c56c603..cb2e0c50 100644 --- a/include/TArgonneHit.h +++ b/include/TArgonneHit.h @@ -1,9 +1,10 @@ -#ifndef TARGONNE3HIT_H -#define TARGONNE3HIT_H +#ifndef TARGONNEHIT_H +#define TARGONNEHIT_H #include "TDetector.h" #include "TDetectorHit.h" -//#include "TGretinaHit.h" + + #define MAXTRACE 1024 @@ -16,12 +17,6 @@ class TArgonneHit : public TDetectorHit { //virtual void Compare(TObject &obj) const; virtual void Print(Option_t *opt = "") const; virtual void Clear(Option_t *opt = ""); - virtual void ClearWave(Option_t *opt = ""); - - //virtual void InsertHit(const TDetectorHit& hit) { return; } - //virtual TDetectorHit& GetHit(const int &i=0) { return hit; } - //virtual int Size() { return 1; } - double AverageWave(int samples=-1); void BuildFrom(TSmartBuffer buf); @@ -31,41 +26,46 @@ class TArgonneHit : public TDetectorHit { Int_t GetHole() const { return (board_id & 0x1f00)>>8; } Int_t GetSegmentId() const { return GetVME()*10 + GetChannel(); } Int_t GetCrystalId() const { return GetHole()*4 + GetCrystal(); } - Int_t GetWaveSize() const { return wavesize; } - Short_t* GetWave() const { return wave; } Long_t GetLed() const { return led; } Long_t GetCfd() const { return cfd; } - static void SetExtractWaves(bool flag=true) { fExtractWaves = flag; } - static bool ExtractWaves() { return fExtractWaves; } - virtual Int_t Charge() const { return charge; } - //Int_t Address() { return hit.Address(); } private: - //virtual int BuildHits(); - - static bool fExtractWaves; //! - //mutable bool fOwnWave; //! - - //TDetectorHit hit; - Int_t board_id; - Int_t charge; - Int_t wavesize; // In 16-bit elements - Long_t led; - Long_t cfd; - Short_t wavebuffer[MAXTRACE]; //! - Short_t *wave; //[wavesize] - - - ClassDef(TArgonneHit,2); + UShort_t global_addr; + UShort_t board_id; + UShort_t channel; + ULong_t led; + ULong_t cfd; + + + ULong_t led_prev; + // store flags as one uint + UInt_t flags; + //UShort_t external_disc; + //UShort_t peak_valid; + //UShort_t offset; + //UShort_t sync_error; + //UShort_t general_error; + //UShort_t pile_up_only; + //UShort_t pile_up; + + //UInt_t sampled_baseline; + UInt_t prerise_energy; + UInt_t postrise_energy; + //ULong_t peak_timestamp; + 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; + + ClassDef(TArgonneHit,1); }; - - - #endif diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index 43341d9d..517b8ca2 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -16,14 +16,12 @@ enum kDetectorSystems { BANK29 = 8, GRETINA_SIM= 11, S800_SIM = 9, - SEGA = 64, JANUS = 65, FASTSCINT =4, - CAESAR = 80, - - PHOSWALL = 17 + PHOSWALL = 17, + ANL = 14 }; extern std::map detector_system_map; diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 5244540c..31aec10f 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -235,6 +235,7 @@ typedef struct { // Decomposed GRETINA Data friend std::ostream& operator<<(std::ostream& os, const GEBBankType1 &bank); static UShort_t SwapShort(UShort_t datum); +static UInt_t SwapInt(UInt_t datum); struct GEBMode3Head { UShort_t a2; @@ -275,34 +276,65 @@ struct GEBMode3Data { friend std::ostream& operator<<(std::ostream& os, const GEBMode3Data &data); static void SwapMode3Data(GEBMode3Data &data); -struct GEBArgonneLEDHead { - UShort_t a2; - UShort_t a1; - UShort_t lengthGA; - UShort_t board_id; -}__attribute__((__packed__)); +enum ArgonneType { LEDv10, LEDv11, CFDv11 }; -//friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDHead &head); -//static void SwapArgonneLEDHead(GEBArgonneLEDHead &head); - -struct GEBArgonneLEDData { - UShort_t led_middle; - UShort_t led_low; - UShort_t energy_low; +struct GEBArgonneHead { + UShort_t GA_packetlength; + UShort_t ud_channel; + UInt_t led_low; + UShort_t hdrlength_evttype_hdrtype; UShort_t led_high; - UShort_t cfd_low; - UShort_t energy_high; - UShort_t cfd_high; - UShort_t cfd_middle; - UShort_t cfd_pt1_high; - UShort_t cfd_pt1_low; - UShort_t cfd_pt2_high; - UShort_t cfd_pt2_low; + UShort_t GetGA() const; + UShort_t GetLength() const; + UShort_t GetBoardID() const; + UShort_t GetChannel() const; + UInt_t GetHeaderType() const; + UShort_t GetEventType() const; + UShort_t GetHeaderLength() const; + ULong_t GetLED() const; }__attribute__((__packed__)); -//friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDData &data); -//static void SwapArgonneLEDData(GEBArgonneLEDData &data); +friend std::ostream& operator<<(std::ostream& os, const GEBArgonneHead &header); +void SwapArgonneHead(TRawEvent::GEBArgonneHead& header); + +struct GEBArgonneLEDv11 { + 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; + UInt_t timestamp_peak_high; + 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 GetPreviousLED() const; + UInt_t GetBaseline() const; + UInt_t GetPreRiseE() const; + UInt_t GetPostRiseE() const; + ULong_t GetPeakTimestamp() 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 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); +void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); struct GEBS800Header { Int_t total_size; diff --git a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx index 2e24436e..48492dd2 100644 --- a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx +++ b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx @@ -5,13 +5,13 @@ ClassImp(TArgonneHit) -bool TArgonneHit::fExtractWaves = true; +//bool TArgonneHit::fExtractWaves = true; TArgonneHit::TArgonneHit(){ //fOwnWave = false; - wave = NULL; - wavesize = 0; - for(int i=0;iExtractWaves(); + if (read_waveform) { + throw std::invalid_argument( + "void TArgonneHit::BuildFrom(TSmartBuffer buf) :: Waveforms not supported in GEBArgonne data."); + } - auto header = (TRawEvent::GEBMode3Head*)buf.GetData(); - buf.Advance(sizeof(TRawEvent::GEBMode3Head)); - - board_id = header->board_id; - - auto data = (TRawEvent::GEBMode3Data*)buf.GetData(); - buf.Advance(sizeof(TRawEvent::GEBMode3Data)); - - led = data->GetLed(); - charge = data->GetEnergy(*header); - SetCharge(data->GetEnergy(*header)); - - SetAddress((2<<24) + - (GetCrystalId()<<16) ); - cfd = data->GetCfd(); - - size_t wave_bytes = header->GetLength()*4 - sizeof(*header) + 4 - sizeof(*data); - if(read_waveform & (wavesizeGetGA(); + board_id = header->GetBoardID(); + led = header->GetLED(); + cfd = 0; + + // Extract payload data. Two versions LED and CFD, with small changes for different FW versions + switch( static_cast(header->GetHeaderType()) ) { + case TRawEvent::ArgonneType::LEDv10: { + throw std::invalid_argument( + "void TArgonneHit::BuildFrom(TSmartBuffer buf) :: ArgonneType::LEDv10 is not implemented."); + break; + } + case TRawEvent::ArgonneType::LEDv11: { + auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); + 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; } - buf.Advance(wave_bytes); + case TRawEvent::ArgonneType::CFDv11: { + throw std::invalid_argument( + "void TArgonneHit::BuildFrom(TSmartBuffer buf) :: ArgonneType::CFDv11 is not implemented."); + break; + } + } + } @@ -71,25 +82,25 @@ void TArgonneHit::BuildFrom(TSmartBuffer buf){ void TArgonneHit::Copy(TObject& obj) const { TDetectorHit::Copy(obj); - TArgonneHit& mode3 = (TArgonneHit&)obj; - - - mode3.board_id = board_id; - //mode3.energy = energy; - mode3.charge = charge; - mode3.wavesize = wavesize; - mode3.led = led; - mode3.cfd = cfd; - //if(mode3.wave) { delete wave; } - if(ExtractWaves() && wavesize>0) { - //fOwnWave = true; - //mode3.wave = new Short_t[wavesize]; - memcpy(mode3.wavebuffer,wavebuffer,wavesize*(sizeof(Short_t))); - mode3.wave = &(mode3.wavebuffer[0]); - } else { - mode3.wave=0; - } - //mode3.raw_data.clear(); + // TArgonneHit& mode3 = (TArgonneHit&)obj; + + + // mode3.board_id = board_id; + + // mode3.charge = charge; + // mode3.wavesize = wavesize; + // mode3.led = led; + // mode3.cfd = cfd; + + // if(ExtractWaves() && wavesize>0) { + + + // memcpy(mode3.wavebuffer,wavebuffer,wavesize*(sizeof(Short_t))); + // mode3.wave = &(mode3.wavebuffer[0]); + // } else { + // mode3.wave=0; + // } + } @@ -97,39 +108,38 @@ void TArgonneHit::Print(Option_t *opt) const { } void TArgonneHit::Clear(Option_t *opt) { TDetectorHit::Clear(opt); - board_id = -1; - charge = -1; - led = -1; - cfd = -1; - //if(fOwnWave && wave) { - // delete wave; - //} - ClearWave(); - //raw_data.clear(); -} - -void TArgonneHit::ClearWave(Option_t *opt) { - for(int i=0;iMAXTRACE) - break; - //std::cout << "Clear wave " << i << std::endl; - wavebuffer[i] = 0; - } - wave = NULL; - wavesize = 0; -} - -double TArgonneHit::AverageWave(int samples) { - //printf("wavesize = %i\n",wavesize); - if(wavesize<1) - return 0.0; - if(samples<0 || samples >wavesize) - samples = wavesize; - double avg = 0.0; - for(int i=0;iMAXTRACE) +// break; +// //std::cout << "Clear wave " << i << std::endl; +// wavebuffer[i] = 0; +// } +// wave = NULL; +// wavesize = 0; +// } + +// double TArgonneHit::AverageWave(int samples) { +// //printf("wavesize = %i\n",wavesize); +// if(wavesize<1) +// return 0.0; +// if(samples<0 || samples >wavesize) +// samples = wavesize; +// double avg = 0.0; +// for(int i=0;i>8); + UShort_t temp = 0; + temp = (datum&0x00ff); + return (temp<<8) + (datum>>8); +} +UInt_t TRawEvent::SwapInt(UInt_t datum) { + UInt_t t1 = 0, t2 = 0, t3 = 0; + t1 = (datum&0x000000ff); + t2 = (datum&0x0000ff00); + t3 = (datum&0x00ff0000); + return (t1<<24) + (t2<<8) + (t3>>8) + (datum>>24); } void TRawEvent::SwapMode3Head(TRawEvent::GEBMode3Head &head) { @@ -120,6 +127,87 @@ std::ostream& operator<<(std ::ostream& os, const TRawEvent::GEBMode3Data &data) return os; } +UShort_t TRawEvent::GEBArgonneHead::GetGA() const { return ((GA_packetlength & 0xf800) >> 11); } +UShort_t TRawEvent::GEBArgonneHead::GetLength() const { return (GA_packetlength & 0x7ff); } +UShort_t TRawEvent::GEBArgonneHead::GetBoardID() const { return ((ud_channel & 0xfff0) >> 4); } +UShort_t TRawEvent::GEBArgonneHead::GetChannel() const { return (ud_channel & 0xf); } +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::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); } +UInt_t TRawEvent::GEBArgonneLEDv11::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } +UInt_t TRawEvent::GEBArgonneLEDv11::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24); } +ULong_t TRawEvent::GEBArgonneLEDv11::GetPeakTimestamp() const { return ((ULong_t)timestamp_peak_low) + (((ULong_t)timestamp_peak_high)<<16); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPostRiseSampleBegin() const { return (postrise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPostRiseSampleEnd() const { return (postrise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPreRiseSampleBegin() const { return (prerise_begin_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPreRiseSampleEnd() const { return (prerise_end_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetBaseSample() const { return (base_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::GetPeakSample() const { return (peak_sample & 0x3fff); } +UShort_t TRawEvent::GEBArgonneLEDv11::ExternalDiscFlag() const { return ((flags & 0x100)>>8); } +UShort_t TRawEvent::GEBArgonneLEDv11::PeakValidFlag() const { return ((flags & 0x200)>>9); } +UShort_t TRawEvent::GEBArgonneLEDv11::OffsetFlag() const { return ((flags & 0x400)>>10); } +UShort_t TRawEvent::GEBArgonneLEDv11::SyncErrorFlag() const { return ((flags & 0x1000)>>12); } +UShort_t TRawEvent::GEBArgonneLEDv11::GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } +UShort_t TRawEvent::GEBArgonneLEDv11::PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } +UShort_t TRawEvent::GEBArgonneLEDv11::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.hdrlength_evttype_hdrtype = SwapShort(header.hdrlength_evttype_hdrtype); + header.led_high = SwapShort(header.led_high); +} +void TRawEvent::SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& 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.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.hdrlength_evttype_hdrtype) << "\n" + << STR(header.led_high) << std::endl; +} +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; +} +#undef STR + std::ostream& operator<<(std::ostream& os,const TRawEvent::GEBS800Header &head) { return os << "-- S800 Header \"packet\" -- \n" << "\t S800 timestamp: " << head.S800_timestamp << "\n" From 2f6346d2d9c01f058fdab142fdf34cc7525e2ced Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 2 Mar 2016 21:48:31 -0500 Subject: [PATCH 03/94] Added ANL kFileType and kDetectorSystem and added TArgonne/ANL to the TUnpackingLoop, and TUnpackedEvent case-switch statements to build TArgonne event parer into GRUTinizer. I have also added a check for the raw ANL event file extension gtd* to TGRUTOptions. Finally, I added endian swaps into the BuildHits. Ready for testing. --- include/TArgonne.h | 1 - include/TGRUTTypes.h | 1 + libraries/TDetSystems/TArgonne/TArgonne.cxx | 9 ++------- libraries/TDetSystems/TArgonne/TArgonneHit.cxx | 6 ++++++ libraries/TDetSystems/TDetector/TDetectorEnv.cxx | 1 + libraries/TGRUTint/TGRUTOptions.cxx | 3 +++ libraries/TLoops/TUnpackedEvent.cxx | 6 +++++- libraries/TLoops/TUnpackingLoop.cxx | 12 ++++++++---- libraries/TRawFormat/TRawEvent.cxx | 7 ++++++- 9 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/TArgonne.h b/include/TArgonne.h index 343795e3..41fcf9a7 100644 --- a/include/TArgonne.h +++ b/include/TArgonne.h @@ -28,7 +28,6 @@ class TArgonne : public TDetector { private: virtual int BuildHits(); - //TClonesArray* anl_hits;//("TArgonneHit"); std::vector anl_hits; ClassDef(TArgonne,1); diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index 517b8ca2..4f16d28e 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -31,6 +31,7 @@ enum kFileType { NSCL_EVT = 1, GRETINA_MODE2 = 2, GRETINA_MODE3 = 3, + ANL = 4, ROOT_DATA = 256, ROOT_MACRO = 257, CALIBRATED = 512, diff --git a/libraries/TDetSystems/TArgonne/TArgonne.cxx b/libraries/TDetSystems/TArgonne/TArgonne.cxx index f5597524..4694bf04 100644 --- a/libraries/TDetSystems/TArgonne/TArgonne.cxx +++ b/libraries/TDetSystems/TArgonne/TArgonne.cxx @@ -3,12 +3,11 @@ #include "TGEBEvent.h" TArgonne::TArgonne(){ - //anl_hits = new TClonesArray("TArgonneHit"); Clear(); } TArgonne::~TArgonne() { - //delete anl_hits; + } void TArgonne::Copy(TObject& obj) const { @@ -16,13 +15,10 @@ void TArgonne::Copy(TObject& obj) const { TArgonne& detector = (TArgonne&)obj; detector.anl_hits = anl_hits; - //anl_hits->Copy(*detector.anl_hits); detector.raw_data.clear(); } void TArgonne::InsertHit(const TDetectorHit& hit){ - //TArgonneHit* new_hit = (TArgonneHit*)anl_hits->ConstructedAt(Size()); - //hit.Copy(*new_hit); anl_hits.emplace_back((TArgonneHit&)hit); fSize++; } @@ -41,7 +37,6 @@ int TArgonne::BuildHits(){ void TArgonne::Print(Option_t *opt) const { } void TArgonne::Clear(Option_t *opt) { - //TDetector::Clear(opt); - anl_hits.clear(); //->Clear(opt);//("TArgonneHit"); + anl_hits.clear(); raw_data.clear(); } diff --git a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx index 48492dd2..1edb9253 100644 --- a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx +++ b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx @@ -36,6 +36,9 @@ void TArgonneHit::BuildFrom(TSmartBuffer buf){ // Extract header data. Header format should stay constant pending FW updates auto header = (TRawEvent::GEBArgonneHead*)buf.GetData(); buf.Advance(sizeof(TRawEvent::GEBArgonneHead)); + // Swap big endian for little endian + SwapArgonneHead(*header); + // Extract header data global_addr = header->GetGA(); board_id = header->GetBoardID(); led = header->GetLED(); @@ -51,6 +54,9 @@ void TArgonneHit::BuildFrom(TSmartBuffer buf){ case TRawEvent::ArgonneType::LEDv11: { auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); + // Swap big endian for little endian + SwapArgonneLEDv11(*data); + // Extract data from payload led_prev = data->GetPreviousLED(); flags = data->flags; prerise_energy = data->GetPreRiseE(); diff --git a/libraries/TDetSystems/TDetector/TDetectorEnv.cxx b/libraries/TDetSystems/TDetector/TDetectorEnv.cxx index a3eb7a77..5b288fba 100644 --- a/libraries/TDetSystems/TDetector/TDetectorEnv.cxx +++ b/libraries/TDetSystems/TDetector/TDetectorEnv.cxx @@ -156,6 +156,7 @@ kDetectorSystems TDetectorEnv::DetermineSystem(TRawEvent& event) const { } break; + case ANL: case GRETINA_MODE2: case GRETINA_MODE3: { diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index f36fb8fd..870d139d 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -227,6 +227,8 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ return kFileType::GVALUE; } else if (ext == "win"){ return kFileType::PRESETWINDOW; + } else if (ext.find("gtd")!=std::string::npos) { + return kFileType::ANL; } else { return kFileType::UNKNOWN_FILETYPE; } @@ -235,6 +237,7 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ bool TGRUTOptions::FileAutoDetect(const std::string& filename) { switch(DetermineFileType(filename)){ case kFileType::NSCL_EVT: + case kFileType::ANL: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: input_raw_files.push_back(filename); diff --git a/libraries/TLoops/TUnpackedEvent.cxx b/libraries/TLoops/TUnpackedEvent.cxx index 5ede0a05..e3f6f914 100644 --- a/libraries/TLoops/TUnpackedEvent.cxx +++ b/libraries/TLoops/TUnpackedEvent.cxx @@ -34,7 +34,7 @@ void TUnpackedEvent::AddRawData(const TRawEvent& event, kDetectorSystems detecto case kDetectorSystems::GRETINA: GetDetector(true)->AddRawData(event); break; - + case kDetectorSystems::GRETINA_SIM: GetDetector(true)->AddRawData(event); break; @@ -79,6 +79,10 @@ void TUnpackedEvent::AddRawData(const TRawEvent& event, kDetectorSystems detecto GetDetector(true)->AddRawData(event); break; + case kDetectorSystems::ANL: + GetDetector(true)->AddRawData(event); + break; + default: break; } diff --git a/libraries/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index 2b72d988..c8d6838d 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -58,11 +58,12 @@ bool TUnpackingLoop::Iteration(){ TNSCLEvent nscl_event(raw_event); HandleNSCLData(nscl_event); } - break; + break; - case kFileType::GRETINA_MODE2: - case kFileType::GRETINA_MODE3: - { + case kFileType::ANL: + case kFileType::GRETINA_MODE2: + case kFileType::GRETINA_MODE3: + { TGEBEvent geb_event(raw_event); HandleGEBData(geb_event); } @@ -190,6 +191,9 @@ void TUnpackingLoop::HandleGEBData(TGEBEvent& event){ //event.Print("all"); //exit(1); break; + case 14: + fOutputEvent->AddRawData(event, kDetectorSystems::ANL); + break; case 17: //PWall Mode2 equivlant. fOutputEvent->AddRawData(event, kDetectorSystems::PHOSWALL); break; diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index 7b7a1bb3..ba75ff17 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -65,7 +65,8 @@ Int_t TRawEvent::GetEventType() const { switch(fFileType){ case NSCL_EVT: return ((EVTHeader*)(&fEventHeader))->type(); - + + case ANL: case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->type(); @@ -82,6 +83,7 @@ Int_t TRawEvent::GetBodySize() const { case NSCL_EVT: return ((EVTHeader*)(&fEventHeader))->size() - sizeof(RawHeader); //Size in nscldaq is inclusive + case ANL: case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->size() + sizeof(Long_t); //Size in gretinadaq is exclusive, plus timestamp @@ -110,6 +112,7 @@ Long_t TRawEvent::GetTimestamp() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetTimestamp(); + case ANL: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetTimestamp(); @@ -134,6 +137,7 @@ const char* TRawEvent::GetPayload() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetPayload(); + case ANL: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetPayload(); @@ -158,6 +162,7 @@ TSmartBuffer TRawEvent::GetPayloadBuffer() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetPayloadBuffer(); + case ANL: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetPayloadBuffer(); From f93cbc58b26a045715bba5253c75746a62f643ea Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 2 Mar 2016 22:02:10 -0500 Subject: [PATCH 04/94] (incremental) kFileType::ANL -> kFileType::ANL_RAW --- include/TGRUTTypes.h | 2 +- include/TRawBanks.h | 4 ++-- libraries/TDetSystems/TArgonne/TArgonneHit.cxx | 4 ++-- libraries/TDetSystems/TDetector/TDetectorEnv.cxx | 2 +- libraries/TGRUTint/TGRUTOptions.cxx | 4 ++-- libraries/TLoops/TUnpackedEvent.cxx | 1 + libraries/TLoops/TUnpackingLoop.cxx | 2 +- libraries/TRawFormat/TRawEvent.cxx | 10 +++++----- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index 4f16d28e..b725e74c 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -31,7 +31,7 @@ enum kFileType { NSCL_EVT = 1, GRETINA_MODE2 = 2, GRETINA_MODE3 = 3, - ANL = 4, + ANL_RAW = 4, ROOT_DATA = 256, ROOT_MACRO = 257, CALIBRATED = 512, diff --git a/include/TRawBanks.h b/include/TRawBanks.h index 31aec10f..6f120a37 100644 --- a/include/TRawBanks.h +++ b/include/TRawBanks.h @@ -295,7 +295,7 @@ struct GEBArgonneHead { }__attribute__((__packed__)); friend std::ostream& operator<<(std::ostream& os, const GEBArgonneHead &header); -void SwapArgonneHead(TRawEvent::GEBArgonneHead& header); +static void SwapArgonneHead(TRawEvent::GEBArgonneHead& header); struct GEBArgonneLEDv11 { UShort_t led_low_prev; @@ -334,7 +334,7 @@ struct GEBArgonneLEDv11 { }__attribute__((__packed__)); friend std::ostream& operator<<(std::ostream& os, const GEBArgonneLEDv11& data); -void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); +static void SwapArgonneLEDv11(TRawEvent::GEBArgonneLEDv11& data); struct GEBS800Header { Int_t total_size; diff --git a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx index 1edb9253..c803bf63 100644 --- a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx +++ b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx @@ -37,7 +37,7 @@ void TArgonneHit::BuildFrom(TSmartBuffer buf){ auto header = (TRawEvent::GEBArgonneHead*)buf.GetData(); buf.Advance(sizeof(TRawEvent::GEBArgonneHead)); // Swap big endian for little endian - SwapArgonneHead(*header); + TRawEvent::SwapArgonneHead(*header); // Extract header data global_addr = header->GetGA(); board_id = header->GetBoardID(); @@ -55,7 +55,7 @@ void TArgonneHit::BuildFrom(TSmartBuffer buf){ auto data = (TRawEvent::GEBArgonneLEDv11*)buf.GetData(); buf.Advance(sizeof(TRawEvent::GEBArgonneLEDv11)); // Swap big endian for little endian - SwapArgonneLEDv11(*data); + TRawEvent::SwapArgonneLEDv11(*data); // Extract data from payload led_prev = data->GetPreviousLED(); flags = data->flags; diff --git a/libraries/TDetSystems/TDetector/TDetectorEnv.cxx b/libraries/TDetSystems/TDetector/TDetectorEnv.cxx index 5b288fba..18c7709a 100644 --- a/libraries/TDetSystems/TDetector/TDetectorEnv.cxx +++ b/libraries/TDetSystems/TDetector/TDetectorEnv.cxx @@ -156,7 +156,7 @@ kDetectorSystems TDetectorEnv::DetermineSystem(TRawEvent& event) const { } break; - case ANL: + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: { diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index 870d139d..7a6a7ac4 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -228,7 +228,7 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ } else if (ext == "win"){ return kFileType::PRESETWINDOW; } else if (ext.find("gtd")!=std::string::npos) { - return kFileType::ANL; + return kFileType::ANL_RAW; } else { return kFileType::UNKNOWN_FILETYPE; } @@ -237,7 +237,7 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ bool TGRUTOptions::FileAutoDetect(const std::string& filename) { switch(DetermineFileType(filename)){ case kFileType::NSCL_EVT: - case kFileType::ANL: + case kFileType::ANL_RAW: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: input_raw_files.push_back(filename); diff --git a/libraries/TLoops/TUnpackedEvent.cxx b/libraries/TLoops/TUnpackedEvent.cxx index e3f6f914..33033f89 100644 --- a/libraries/TLoops/TUnpackedEvent.cxx +++ b/libraries/TLoops/TUnpackedEvent.cxx @@ -14,6 +14,7 @@ #include "TS800Scaler.h" #include "TSega.h" #include "TFastScint.h" +#include "TArgonne.h" TUnpackedEvent::TUnpackedEvent() { } diff --git a/libraries/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index c8d6838d..803f780f 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -60,7 +60,7 @@ bool TUnpackingLoop::Iteration(){ } break; - case kFileType::ANL: + case kFileType::ANL_RAW: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: { diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index ba75ff17..8a644aaf 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -66,7 +66,7 @@ Int_t TRawEvent::GetEventType() const { case NSCL_EVT: return ((EVTHeader*)(&fEventHeader))->type(); - case ANL: + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->type(); @@ -83,7 +83,7 @@ Int_t TRawEvent::GetBodySize() const { case NSCL_EVT: return ((EVTHeader*)(&fEventHeader))->size() - sizeof(RawHeader); //Size in nscldaq is inclusive - case ANL: + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((GEBHeader*)(&fEventHeader))->size() + sizeof(Long_t); //Size in gretinadaq is exclusive, plus timestamp @@ -112,7 +112,7 @@ Long_t TRawEvent::GetTimestamp() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetTimestamp(); - case ANL: + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetTimestamp(); @@ -137,7 +137,7 @@ const char* TRawEvent::GetPayload() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetPayload(); - case ANL: + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetPayload(); @@ -162,7 +162,7 @@ TSmartBuffer TRawEvent::GetPayloadBuffer() const { case NSCL_EVT: return ((TNSCLEvent*)this)->GetPayloadBuffer(); - case ANL: + case ANL_RAW: case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetPayloadBuffer(); From e064d000c1197295c4d8935216cdaa391d807e48 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 2 Mar 2016 22:53:45 -0500 Subject: [PATCH 05/94] (incremental) fixed enum miss match in TRawEventSource. --- libraries/TRawFormat/TRawEventSource.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index 76b6bc50..290e7271 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -131,6 +131,7 @@ std::string TRawEventByteSource::Status() const { int TRawEventByteSource::GetEvent(TRawEvent& rawevent) { switch(fFileType) { case kFileType::NSCL_EVT: + case kFileType::ANL_RAW: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: break; From 96ff7ee03c1215c8cecf266b4ecd812718d4b3bf Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 2 Mar 2016 23:47:43 -0500 Subject: [PATCH 06/94] ANL event building is now fully functional. Added MakeANLhistos.cxx for analysis. chicka, chi-kaaah! --- histos/MakeANLHistos.cxx | 52 ++++++++++++++++++++++++++++++ include/TArgonneHit.h | 10 ++---- libraries/TRawFormat/TRawBanks.cxx | 2 +- 3 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 histos/MakeANLHistos.cxx diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx new file mode 100644 index 00000000..cdaeef2a --- /dev/null +++ b/histos/MakeANLHistos.cxx @@ -0,0 +1,52 @@ + +#include "TRuntimeObjects.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "TArgonne.h" + +//#include "TChannel.h" +//#include "GValue.h" + +#define PRINT(x) std::cout << #x"=" << x << std::endl +#define STR(x) #x << " = " << x + +// 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) { + TArgonne *cagra = obj.GetDetector(); + + TList *list = &(obj.GetObjects()); + int numobj = list->GetSize(); + + if(!cagra) + return; + + + for(int y=0;ySize();y++) { + TArgonneHit hit = cagra->GetArgonneHit(y); + //histname = "Energy"; + //obj.FillHistogram(histname,,0,100,hit.GetCrystalId()); + std::cout << STR(hit.GetLed()) << std::endl; + std::cout << STR(hit.GetPostE()) << std::endl; + std::cout << STR(hit.GetPreE()) << std::endl; + std::cout << STR((hit.GetPostE() - hit.GetPreE())/350.0) << std::endl; + std::cin.get(); + } + + + + if(numobj!=list->GetSize()) + list->Sort(); + +} diff --git a/include/TArgonneHit.h b/include/TArgonneHit.h index cb2e0c50..3cdbbb47 100644 --- a/include/TArgonneHit.h +++ b/include/TArgonneHit.h @@ -20,16 +20,12 @@ class TArgonneHit : public TDetectorHit { void BuildFrom(TSmartBuffer buf); - Int_t GetChannel() const { return (board_id & 0x000f); } - Int_t GetVME() const { return (board_id & 0x0030)>>4; } - Int_t GetCrystal() const { return (board_id & 0x00c0)>>6; } - Int_t GetHole() const { return (board_id & 0x1f00)>>8; } - Int_t GetSegmentId() const { return GetVME()*10 + GetChannel(); } - Int_t GetCrystalId() const { return GetHole()*4 + GetCrystal(); } Long_t GetLed() const { return led; } Long_t GetCfd() const { return cfd; } - + Int_t GetPreE() const { return prerise_energy; } + Int_t GetPostE() const { return postrise_energy; } + //Float_t GetEnergy() const { return ((Int_t)postrise_energy - (Int_t)prerise_energy)/350.0; } diff --git a/libraries/TRawFormat/TRawBanks.cxx b/libraries/TRawFormat/TRawBanks.cxx index 12d6e9b4..6ed1eaac 100644 --- a/libraries/TRawFormat/TRawBanks.cxx +++ b/libraries/TRawFormat/TRawBanks.cxx @@ -139,7 +139,7 @@ ULong_t TRawEvent::GEBArgonneHead::GetLED() const { return (((ULong_t)led_high) 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); } UInt_t TRawEvent::GEBArgonneLEDv11::GetPreRiseE() const { return (postrise_sum_low_prerise_sum & 0xffffff); } -UInt_t TRawEvent::GEBArgonneLEDv11::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24); } +UInt_t TRawEvent::GEBArgonneLEDv11::GetPostRiseE() const { return ((postrise_sum_low_prerise_sum & 0xff000000)>>24) + (((UInt_t)postrise_sum_high) << 8); } ULong_t TRawEvent::GEBArgonneLEDv11::GetPeakTimestamp() const { return ((ULong_t)timestamp_peak_low) + (((ULong_t)timestamp_peak_high)<<16); } UShort_t TRawEvent::GEBArgonneLEDv11::GetPostRiseSampleBegin() const { return (postrise_begin_sample & 0x3fff); } UShort_t TRawEvent::GEBArgonneLEDv11::GetPostRiseSampleEnd() const { return (postrise_end_sample & 0x3fff); } From 4ae71f946fd5836a6fcf4888bcbade18952d9ce7 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 3 Mar 2016 15:44:01 -0500 Subject: [PATCH 07/94] (incremental) Set more members in TArgonneHit. --- histos/MakeANLHistos.cxx | 33 ++++++++++------ include/TArgonneHit.h | 39 ++++++++++--------- .../TDetSystems/TArgonne/TArgonneHit.cxx | 1 + 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index cdaeef2a..8d188ba4 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -2,8 +2,10 @@ #include "TRuntimeObjects.h" #include -#include -#include +#include +#include +#include +#include #include #include @@ -16,9 +18,14 @@ //#include "TChannel.h" //#include "GValue.h" -#define PRINT(x) std::cout << #x"=" << x << std::endl +#define PRINT(x) std::cout << #x" = " << x << std::endl #define STR(x) #x << " = " << x +using namespace std; + + +string name; + // extern "C" is needed to prevent name mangling. // The function signature must be exactly as shown here, // or else bad things will happen. @@ -32,16 +39,20 @@ void MakeHistograms(TRuntimeObjects& obj) { if(!cagra) return; - for(int y=0;ySize();y++) { TArgonneHit hit = cagra->GetArgonneHit(y); - //histname = "Energy"; - //obj.FillHistogram(histname,,0,100,hit.GetCrystalId()); - std::cout << STR(hit.GetLed()) << std::endl; - std::cout << STR(hit.GetPostE()) << std::endl; - std::cout << STR(hit.GetPreE()) << std::endl; - std::cout << STR((hit.GetPostE() - hit.GetPreE())/350.0) << std::endl; - std::cin.get(); + //stringstream stream; stream.str(""); + //stream << "Energy"; + name = "Energy"; + obj.FillHistogram(name,10000,0,20000,((hit.GetPostE() - hit.GetPreE())/350.0)); + // 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)); + } diff --git a/include/TArgonneHit.h b/include/TArgonneHit.h index 3cdbbb47..a0d4591a 100644 --- a/include/TArgonneHit.h +++ b/include/TArgonneHit.h @@ -4,10 +4,6 @@ #include "TDetector.h" #include "TDetectorHit.h" - - -#define MAXTRACE 1024 - class TArgonneHit : public TDetectorHit { public: TArgonneHit(); @@ -18,15 +14,29 @@ class TArgonneHit : public TDetectorHit { virtual void Print(Option_t *opt = "") const; virtual void Clear(Option_t *opt = ""); - void BuildFrom(TSmartBuffer buf); + void BuildFrom(TSmartBuffer buf); - Long_t GetLed() const { return led; } - Long_t GetCfd() const { return cfd; } + Long_t GetLED() const { return led; } + Long_t GetCFD() const { return cfd; } Int_t GetPreE() const { return prerise_energy; } - Int_t GetPostE() const { return postrise_energy; } - //Float_t GetEnergy() const { return ((Int_t)postrise_energy - (Int_t)prerise_energy)/350.0; } - + 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; } + UShort_t GetPostBegin() const { return postrise_begin_sample; } + UShort_t GetPostEnd() const { return postrise_end_sample; } + UShort_t GetPreBegin() const { return prerise_begin_sample; } + UShort_t GetPreEnd() const { return prerise_end_sample; } + + // Parse flags + UShort_t ExternalDiscFlag() const { return ((flags & 0x100)>>8); } + UShort_t PeakValidFlag() const { return ((flags & 0x200)>>9); } + UShort_t OffsetFlag() const { return ((flags & 0x400)>>10); } + UShort_t SyncErrorFlag() const { return ((flags & 0x1000)>>12); } + UShort_t GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } + UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } + UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); } private: @@ -39,16 +49,7 @@ class TArgonneHit : public TDetectorHit { ULong_t led_prev; - // store flags as one uint UInt_t flags; - //UShort_t external_disc; - //UShort_t peak_valid; - //UShort_t offset; - //UShort_t sync_error; - //UShort_t general_error; - //UShort_t pile_up_only; - //UShort_t pile_up; - //UInt_t sampled_baseline; UInt_t prerise_energy; UInt_t postrise_energy; diff --git a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx index c803bf63..6e3e3864 100644 --- a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx +++ b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx @@ -41,6 +41,7 @@ void TArgonneHit::BuildFrom(TSmartBuffer buf){ // Extract header data global_addr = header->GetGA(); board_id = header->GetBoardID(); + channel = header->GetChannel(); led = header->GetLED(); cfd = 0; From 73420ccd00e7d7dbf7b3fff48e821d4a7c9ed1ac Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 3 Mar 2016 23:22:11 -0500 Subject: [PATCH 08/94] (incremental) added clover histograms --- histos/MakeANLHistos.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 8d188ba4..91e59868 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -25,6 +25,7 @@ using namespace std; string name; +stringstream stream; // extern "C" is needed to prevent name mangling. // The function signature must be exactly as shown here, @@ -41,10 +42,18 @@ void MakeHistograms(TRuntimeObjects& obj) { for(int y=0;ySize();y++) { TArgonneHit hit = cagra->GetArgonneHit(y); - //stringstream stream; stream.str(""); - //stream << "Energy"; - name = "Energy"; - obj.FillHistogram(name,10000,0,20000,((hit.GetPostE() - hit.GetPreE())/350.0)); + + + 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()); From 17e0c14e814c429d84de8583173a8ad6c2b5bbc0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 10 May 2016 12:53:24 -0400 Subject: [PATCH 09/94] Added RCNP Tree source class, needs implementation --- include/TRCNPTreeSource.h | 58 ++++++++++++++++++++++++ libraries/TRawFormat/TRCNPTreeSource.cxx | 38 ++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 include/TRCNPTreeSource.h create mode 100644 libraries/TRawFormat/TRCNPTreeSource.cxx diff --git a/include/TRCNPTreeSource.h b/include/TRCNPTreeSource.h new file mode 100644 index 00000000..16a3c1e7 --- /dev/null +++ b/include/TRCNPTreeSource.h @@ -0,0 +1,58 @@ +#ifndef _TRCNPTREESOURCE_H_ +#define _TRCNPTREESOURCE_H_ + +#include +#ifndef __CINT__ +# include +#endif + +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +#include "TChain.h" +#include "TTree.h" +#include "rootalyze.h" + +class TRCNPTreeSource : public TRawEventSource { +public: + TRCNPTreeSource(const char* filename); + ~TRCNPTreeSource(); + + + void Add (const char* filename) { + fChain.Add(filename); + } + + bool IsValid() const { return fIsValid; } + + virtual void Reset(); + + virtual std::string SourceDescription() const; // required + virtual std::string Status() const; // required + virtual int GetLastErrno() const; + virtual std::string GetLastError() const; + +private: + TRCNPTreeSource(const TRCNPTreeSource& other) { } + TRCNPTreeSource& operator=(const TRCNPTreeSource& other) { return *this; } + + //std::vector fFileList; // This list does not get modified frequently + TChain fChain; + std::set fFileEvents; // This list is modified frequently + +#ifndef __CINT__ + mutable std::mutex fFileListMutex; +#endif + + + virtual int GetEvent(TRawEvent& outevent); // required + bool fIsValid; + + + ClassDef(TRCNPTreeSource, 0); +}; + + + + +#endif diff --git a/libraries/TRawFormat/TRCNPTreeSource.cxx b/libraries/TRawFormat/TRCNPTreeSource.cxx new file mode 100644 index 00000000..ab94adce --- /dev/null +++ b/libraries/TRawFormat/TRCNPTreeSource.cxx @@ -0,0 +1,38 @@ +#include "TRCNPTreeSource.h" + +#include +#include + +#include "Globals.h" + +TRCNPTreeSource::TRCNPTreeSource(const char* filename) + : fIsFirstStatus(true), fIsValid(true) { fChain.Add(filename); } + +TRCNPTreeSource::~TRCNPTreeSource(){ + // for(auto& val : fFileEvents){ + // delete val.file; + // } +} + +int TRCNPTreeSource::GetEvent(TRawEvent& outevent){ + +} + +void TRCNPTreeSource::Reset() { + +} + +std::string TRCNPTreeSource::SourceDescription() const{ + return "TRCNPTreeSource::SourceDescription needs definition"; +} + +std::string TRCNPTreeSource::Status() const{ + return "TRCNPTreeSource::Status needs definition"; +} + +int TRCNPTreeSource::GetLastErrno() const{ + return 0; +} +std::string TRCNPTreeSource::GetLastError() const{ + return ""; +} From e0fb1c1b7b13c3ea29aa32bf813246f7c5db32b6 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 12 May 2016 00:57:24 -0400 Subject: [PATCH 10/94] Added templated TTreeSource class for reading preprocessed events from a ROOT TTree --- include/TGRUTTypes.h | 1 + include/TRCNPTreeSource.h | 58 ---------------- include/TTreeSource.h | 88 ++++++++++++++++++++++++ libraries/TGRUTint/TGRUTint.cxx | 4 ++ libraries/TRawFormat/LinkDef.h | 4 +- libraries/TRawFormat/TRCNPTreeSource.cxx | 38 ---------- 6 files changed, 96 insertions(+), 97 deletions(-) delete mode 100644 include/TRCNPTreeSource.h create mode 100644 include/TTreeSource.h delete mode 100644 libraries/TRawFormat/TRCNPTreeSource.cxx diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index cea0b385..f1c98a40 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -34,6 +34,7 @@ enum kFileType { ANL_RAW = 4, ROOT_DATA = 256, ROOT_MACRO = 257, + ROOT_TTREE = 258, CALIBRATED = 512, GVALUE = 513, PRESETWINDOW = 514, diff --git a/include/TRCNPTreeSource.h b/include/TRCNPTreeSource.h deleted file mode 100644 index 16a3c1e7..00000000 --- a/include/TRCNPTreeSource.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _TRCNPTREESOURCE_H_ -#define _TRCNPTREESOURCE_H_ - -#include -#ifndef __CINT__ -# include -#endif - -#include "TObject.h" -#include "TRawEvent.h" -#include "TRawSource.h" -#include "TChain.h" -#include "TTree.h" -#include "rootalyze.h" - -class TRCNPTreeSource : public TRawEventSource { -public: - TRCNPTreeSource(const char* filename); - ~TRCNPTreeSource(); - - - void Add (const char* filename) { - fChain.Add(filename); - } - - bool IsValid() const { return fIsValid; } - - virtual void Reset(); - - virtual std::string SourceDescription() const; // required - virtual std::string Status() const; // required - virtual int GetLastErrno() const; - virtual std::string GetLastError() const; - -private: - TRCNPTreeSource(const TRCNPTreeSource& other) { } - TRCNPTreeSource& operator=(const TRCNPTreeSource& other) { return *this; } - - //std::vector fFileList; // This list does not get modified frequently - TChain fChain; - std::set fFileEvents; // This list is modified frequently - -#ifndef __CINT__ - mutable std::mutex fFileListMutex; -#endif - - - virtual int GetEvent(TRawEvent& outevent); // required - bool fIsValid; - - - ClassDef(TRCNPTreeSource, 0); -}; - - - - -#endif diff --git a/include/TTreeSource.h b/include/TTreeSource.h new file mode 100644 index 00000000..872c9e44 --- /dev/null +++ b/include/TTreeSource.h @@ -0,0 +1,88 @@ +#ifndef _TTREESOURCE_H_ +#define _TTREESOURCE_H_ + +#ifndef __CINT__ +# include +#endif + +#include + +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +#include "TChain.h" +#include "TTree.h" + +templateClassImp(TTreeSource) + +template +class TTreeSource : public TRawEventSource { +public: + TTreeSource() {;} + + TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) + : TTreeSource({filename},treename,eventclassname,file_type) { ; } + + template + TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) + : TTreeSource({filename},treename,eventclassname,file_type,std::forward(args)...) { ; } + + template + TTreeSource(const std::vector& filenames, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) + : fChain(treename), fCurrentEntry(0) { + + assert(file_type == kFileType::ROOT_TTREE); + fFileType = file_type; + + + for (auto fn : filenames) { + fChain.Add(fn); + } + fFileSize = fChain.GetEntries()*sizeof(T); + + if (sizeof...(Args) > 0) { + fEvent = new T(std::forward(args)...); + } else { + fEvent = new T(); + } + fChain.SetBranchAddress(eventclassname, &fEvent); + } + + ~TTreeSource() {;} + + virtual std::string Status() const {return std::string("");} + virtual std::string SourceDescription() const {return std::string("");} + + + kFileType GetFileType() const { return fFileType; } + long GetFileSize() const { return fFileSize; } + + virtual void Reset() {;} + +protected: + void SetFileSize(long file_size) { fFileSize = file_size; } + +private: + virtual int GetEvent(TRawEvent& event) { + fEvent = new T(*fEvent); // copy construct a new object from the old + fChain.GetEntry(fCurrentEntry); // fill the new object with current event data + + // save the pointer of this object into the TRawEvents SmartBuffer + + fCurrentEntry++; + //fEvent = nullptr; + return sizeof(*fEvent); + } + + TChain fChain; + kFileType fFileType; + long fFileSize; + T* fEvent; + long fCurrentEntry; + + ClassDef(TTreeSource,0); +}; + + + +#endif diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx index 8f538399..60d8e907 100644 --- a/libraries/TGRUTint/TGRUTint.cxx +++ b/libraries/TGRUTint/TGRUTint.cxx @@ -47,6 +47,8 @@ #include "TInverseMap.h" +#include "TTreeSource.h" + //extern "C" G__value G__getitem(const char* item); //#include "FastAllocString.h" //char* G__valuemonitor(G__value buf, G__FastAllocString& temp); @@ -212,6 +214,8 @@ void TGRUTint::ApplyOptions() { } } + //TRCNPTreeSource tst; + //next most important thing, if given a raw file && NOT told to not sort! if((opt->InputRing().length() || opt->RawInputFiles().size()) && !missing_file && opt->SortRaw()) { diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index 57e6c2cc..18677d18 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 +// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TOrderedRawFile.h TSequentialRawFile.h TTreeSource.h #ifdef __CINT__ @@ -28,6 +28,8 @@ #pragma link C++ class TOrderedRawFile+; #pragma link C++ class TSequentialRawFile+; +#pragma link C++ class TTreeSource+; + #pragma link C++ enum TRawEvent::ArgonneType; #endif diff --git a/libraries/TRawFormat/TRCNPTreeSource.cxx b/libraries/TRawFormat/TRCNPTreeSource.cxx deleted file mode 100644 index ab94adce..00000000 --- a/libraries/TRawFormat/TRCNPTreeSource.cxx +++ /dev/null @@ -1,38 +0,0 @@ -#include "TRCNPTreeSource.h" - -#include -#include - -#include "Globals.h" - -TRCNPTreeSource::TRCNPTreeSource(const char* filename) - : fIsFirstStatus(true), fIsValid(true) { fChain.Add(filename); } - -TRCNPTreeSource::~TRCNPTreeSource(){ - // for(auto& val : fFileEvents){ - // delete val.file; - // } -} - -int TRCNPTreeSource::GetEvent(TRawEvent& outevent){ - -} - -void TRCNPTreeSource::Reset() { - -} - -std::string TRCNPTreeSource::SourceDescription() const{ - return "TRCNPTreeSource::SourceDescription needs definition"; -} - -std::string TRCNPTreeSource::Status() const{ - return "TRCNPTreeSource::Status needs definition"; -} - -int TRCNPTreeSource::GetLastErrno() const{ - return 0; -} -std::string TRCNPTreeSource::GetLastError() const{ - return ""; -} From db385f53c8d46ad6535a4ebf651c568980be373f Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 12 May 2016 14:19:02 -0400 Subject: [PATCH 11/94] Made default constructor of TTreeSource private --- include/TTreeSource.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 872c9e44..8637c32f 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -1,10 +1,6 @@ #ifndef _TTREESOURCE_H_ #define _TTREESOURCE_H_ -#ifndef __CINT__ -# include -#endif - #include #include "TObject.h" @@ -18,10 +14,9 @@ templateClassImp(TTreeSource) template class TTreeSource : public TRawEventSource { public: - TTreeSource() {;} - TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) - : TTreeSource({filename},treename,eventclassname,file_type) { ; } + /* TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) */ + /* : TTreeSource({filename},treename,eventclassname,file_type) { ; } */ template TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) @@ -63,6 +58,7 @@ class TTreeSource : public TRawEventSource { void SetFileSize(long file_size) { fFileSize = file_size; } private: + TTreeSource() {;} virtual int GetEvent(TRawEvent& event) { fEvent = new T(*fEvent); // copy construct a new object from the old fChain.GetEntry(fCurrentEntry); // fill the new object with current event data @@ -85,4 +81,13 @@ class TTreeSource : public TRawEventSource { +/* template TTreeSource make_ttree_source(const char* filename, const char* treename, Args&&... args) */ +/* { */ + +/* } */ +/* make_ttree_source("./rootfilename.root","treename","branchname"); */ +/* make_ttree_source("./rootfilename.root","treename","branch1name","branch2name"); */ +/* make_ttree_source("./rootfilename.root","treename","branch1name", ... ,"branch2name", ...); */ + + #endif From 32fb498494857c1c38475d9c409266907b558e1f Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 12 May 2016 15:47:10 -0400 Subject: [PATCH 12/94] Built out TTreeSource. Calling GetEvent effectively calls TTree::GetEntry, creating a NEW event in memory each time. A pointer to this location in memory is serialized into the TSmartBuffer of the TRawEvent, which is passed on. GetEntry fills fEvent which is the type over which TTreeSource is specialized. For now I added a prototype EventType class to demo it's usage and how to register it in the LinkDef. This will be deleted after testing with data has been done. --- include/TTreeSource.h | 23 ++++++++++++++++++++--- libraries/TRawFormat/LinkDef.h | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 8637c32f..5d10586e 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -60,10 +60,19 @@ class TTreeSource : public TRawEventSource { private: TTreeSource() {;} virtual int GetEvent(TRawEvent& event) { + event.SetFileType(fFileType); + fEvent = new T(*fEvent); // copy construct a new object from the old fChain.GetEntry(fCurrentEntry); // fill the new object with current event data - - // save the pointer of this object into the TRawEvents SmartBuffer + TSmartBuffer eventbuffer(reinterpret_cast(fEvent),sizeof(fEvent)); + // set the pointer address into the buffer + event.SetData(eventbuffer); + // set the timestamp of the ttree event + event.SetFragmentTimestamp(fEvent->GetTimestamp()); + // save only the pointer of this object into the TRawEvent SmartBuffer + //memcpy(event.GetBody(),&fEvent,sizeof(fEvent)); + //event.GetBody().SetBuffer(&fEvent,sizeof(fEvent)) + //eventbuffer.SetBuffer(); fCurrentEntry++; //fEvent = nullptr; @@ -79,7 +88,15 @@ class TTreeSource : public TRawEventSource { ClassDef(TTreeSource,0); }; - +/* Prototype example, to be removed */ +class EventType : public TObject { +public: + EventType(){;} + virtual ~EventType(){;} + long GetTimestamp() {return fTimestamp;} + long fTimestamp; + ClassDef(EventType,0); +}; /* template TTreeSource make_ttree_source(const char* filename, const char* treename, Args&&... args) */ /* { */ diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index 18677d18..355e6df2 100644 --- a/libraries/TRawFormat/LinkDef.h +++ b/libraries/TRawFormat/LinkDef.h @@ -28,7 +28,8 @@ #pragma link C++ class TOrderedRawFile+; #pragma link C++ class TSequentialRawFile+; -#pragma link C++ class TTreeSource+; +#pragma link C++ class EventType+; // to be removed +#pragma link C++ class TTreeSource+; #pragma link C++ enum TRawEvent::ArgonneType; From a1f3dc029cd231ab7ee514d7d3705081b102fea6 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 12 May 2016 18:44:27 -0400 Subject: [PATCH 13/94] Added ability for ROOT file to be a source via TTreeSource. Added functionality to TGRUTint::ApplyOptions and TRawEventSource::EventSource. Needs testing. --- include/TGRUTTypes.h | 1 - include/TTreeSource.h | 19 +++++++------ libraries/TGRUTint/TGRUTint.cxx | 36 +++++++++++++++++++----- libraries/TRawFormat/TRawEventSource.cxx | 4 +++ 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index f1c98a40..cea0b385 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -34,7 +34,6 @@ enum kFileType { ANL_RAW = 4, ROOT_DATA = 256, ROOT_MACRO = 257, - ROOT_TTREE = 258, CALIBRATED = 512, GVALUE = 513, PRESETWINDOW = 514, diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 5d10586e..d04c47ad 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -2,12 +2,12 @@ #define _TTREESOURCE_H_ #include +#include #include "TObject.h" #include "TRawEvent.h" #include "TRawSource.h" #include "TChain.h" -#include "TTree.h" templateClassImp(TTreeSource) @@ -26,7 +26,7 @@ class TTreeSource : public TRawEventSource { TTreeSource(const std::vector& filenames, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) : fChain(treename), fCurrentEntry(0) { - assert(file_type == kFileType::ROOT_TTREE); + assert(file_type == kFileType::ROOT_DATA); fFileType = file_type; @@ -62,17 +62,18 @@ class TTreeSource : public TRawEventSource { virtual int GetEvent(TRawEvent& event) { event.SetFileType(fFileType); - fEvent = new T(*fEvent); // copy construct a new object from the old - fChain.GetEntry(fCurrentEntry); // fill the new object with current event data - TSmartBuffer eventbuffer(reinterpret_cast(fEvent),sizeof(fEvent)); + // copy construct a new object from the old + fEvent = new T(*fEvent); + // fill the new object with current event data + fChain.GetEntry(fCurrentEntry); + // create a small memory buffer to hold the pointer to the current entry + char* ptrbytes = (char*)malloc(sizeof(fEvent)); + memcpy(ptrbytes, &fEvent, sizeof(fEvent)); + TSmartBuffer eventbuffer(ptrbytes,sizeof(fEvent)); // set the pointer address into the buffer event.SetData(eventbuffer); // set the timestamp of the ttree event event.SetFragmentTimestamp(fEvent->GetTimestamp()); - // save only the pointer of this object into the TRawEvent SmartBuffer - //memcpy(event.GetBody(),&fEvent,sizeof(fEvent)); - //event.GetBody().SetBuffer(&fEvent,sizeof(fEvent)) - //eventbuffer.SetBuffer(); fCurrentEntry++; //fEvent = nullptr; diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx index 60d8e907..7e895b0a 100644 --- a/libraries/TGRUTint/TGRUTint.cxx +++ b/libraries/TGRUTint/TGRUTint.cxx @@ -47,8 +47,6 @@ #include "TInverseMap.h" -#include "TTreeSource.h" - //extern "C" G__value G__getitem(const char* item); //#include "FastAllocString.h" //char* G__valuemonitor(G__value buf, G__FastAllocString& temp); @@ -226,27 +224,51 @@ void TGRUTint::ApplyOptions() { source = new TRawEventRingSource(opt->InputRing(), opt->DefaultFileType()); - } else if(opt->RawInputFiles().size() > 1 && opt->SortMultiple()){ + } else if(opt->SortMultiple() && ( + opt->RawInputFiles().size() > 1 || + opt->RootInputFiles().size() > 1 || + (opt->RawInputFiles().size() > 0 && opt->RootInputFiles().size() > 0)) + ){ // Open multiple files, read from all at the same time. TMultiRawFile* multi_source = new TMultiRawFile(); for(auto& filename : opt->RawInputFiles()){ multi_source->AddFile(new TRawFileIn(filename.c_str())); } + // using rootfiles as source for sorting + for(auto& filename : opt->RootInputFiles()){ + multi_source->AddFile(filename.c_str()); + } source = multi_source; - } else if(opt->RawInputFiles().size() > 1 && !opt->SortMultiple()){ + } else if(!opt->SortMultiple() && ( + opt->RawInputFiles().size() > 1 || + opt->RootInputFiles().size() > 1 || + (opt->RawInputFiles().size() > 0 && opt->RootInputFiles().size() > 0)) + ){ // Open multiple files, read from each one at a a time. TSequentialRawFile* seq_source = new TSequentialRawFile(); for(auto& filename : opt->RawInputFiles()){ seq_source->Add(new TRawFileIn(filename.c_str())); } + // using rootfiles as source for sorting + for(auto& filename : opt->RootInputFiles()){ + seq_source->Add(TRawEventSource::EventSource(filename.c_str())); + } source = seq_source; } else { // Open a single file. - std::string filename = opt->RawInputFiles().at(0); - if(file_exists(filename.c_str())){ - source = new TRawFileIn(filename.c_str()); + if (opt->RawInputFiles().size()) { + std::string filename = opt->RawInputFiles().at(0); + if(file_exists(filename.c_str())){ + source = new TRawFileIn(filename.c_str()); + } + } + else if (opt->RootInputFiles().size()) { + std::string filename = opt->RootInputFiles().at(0); + if(file_exists(filename.c_str())){ + source = TRawEventSource::EventSource(filename.c_str()); + } } } diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index 290e7271..bf63ad2b 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -1,5 +1,7 @@ #include "TRawSource.h" +#include "TTreeSource.h" + #include #include "TString.h" @@ -87,6 +89,8 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, source = new TRawEventBZipSource(filename, file_type); } else if (hasSuffix(filename,".gz")){ source = new TRawEventGZipSource(filename, file_type); + } else if (hasSuffix(filename,".root")){ + source = new TTreeSource(filename,"eventtree","event", file_type); // If it is an in-progress file, open it that way } else if (is_online) { source = new TRawEventOnlineFileSource(filename, file_type); From 739712c6866e475588693a7c891f89ef9780aba8 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 18 May 2016 22:06:20 -0400 Subject: [PATCH 14/94] Added necessary files for builiding TGrandRaiden data from a root file source. Additionally, updated makefile to link against the external libRCNPTREE.so --- include/TGRUTTypes.h | 3 +- include/TGrandRaiden.h | 40 +++++++++++++++ include/TGrandRaidenHit.h | 49 +++++++++++++++++++ libraries/TDetSystems/TGrandRaiden/LinkDef.h | 14 ++++++ .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 40 +++++++++++++++ .../TGrandRaiden/TGrandRaidenHit.cxx | 43 ++++++++++++++++ libraries/TLoops/TUnpackedEvent.cxx | 8 ++- libraries/TLoops/TUnpackingLoop.cxx | 15 +++--- makefile | 5 +- 9 files changed, 207 insertions(+), 10 deletions(-) create mode 100644 include/TGrandRaiden.h create mode 100644 include/TGrandRaidenHit.h create mode 100644 libraries/TDetSystems/TGrandRaiden/LinkDef.h create mode 100644 libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx create mode 100644 libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index cea0b385..9bbdd826 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -21,7 +21,8 @@ enum kDetectorSystems { FASTSCINT =4, CAESAR = 80, PHOSWALL = 17, - ANL = 14 + ANL = 14, + GRAND_RAIDEN = 50 }; extern std::map detector_system_map; diff --git a/include/TGrandRaiden.h b/include/TGrandRaiden.h new file mode 100644 index 00000000..be50677d --- /dev/null +++ b/include/TGrandRaiden.h @@ -0,0 +1,40 @@ +#ifndef TGRANDRAIDEN_H +#define TGRANDRAIDEN_H + +#include +#include + +#include + +#include "TDetector.h" +#include "TGrandRaidenHit.h" + +class TGrandRaiden : public TDetector { + +public: + TGrandRaiden(); + ~TGrandRaiden(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + virtual void InsertHit(const TDetectorHit& hit); + virtual TDetectorHit& GetHit(int i) { return GRHits.at(i); } + + const TGrandRaidenHit& GetGrandRaidenHit(int i) { return GRHits.at(i); } + void PrintHit(int i){ GRHits.at(i).Print(); } + +private: + virtual int BuildHits(std::vector& raw_data); + + std::vector GRHits; + + ClassDef(TGrandRaiden,1); +}; + + + + + +#endif diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h new file mode 100644 index 00000000..b832e3f2 --- /dev/null +++ b/include/TGrandRaidenHit.h @@ -0,0 +1,49 @@ +#ifndef TGRANDRAIDENHIT_H +#define TGRANDRAIDENHIT_H + +#include "TDetector.h" +#include "TDetectorHit.h" + +class TGrandRaidenHit : public TDetectorHit { + public: + TGrandRaidenHit(); + ~TGrandRaidenHit(); + + virtual void Copy(TObject& obj) const; + //virtual void Compare(TObject &obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + void BuildFrom(TSmartBuffer& buf); + + + // Long_t GetLED() const { return led; } + // Long_t GetCFD() const { return cfd; } + // 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; } + // UShort_t GetPostBegin() const { return postrise_begin_sample; } + // UShort_t GetPostEnd() const { return postrise_end_sample; } + // UShort_t GetPreBegin() const { return prerise_begin_sample; } + // UShort_t GetPreEnd() const { return prerise_end_sample; } + + // // Parse flags + // UShort_t ExternalDiscFlag() const { return ((flags & 0x100)>>8); } + // UShort_t PeakValidFlag() const { return ((flags & 0x200)>>9); } + // UShort_t OffsetFlag() const { return ((flags & 0x400)>>10); } + // UShort_t SyncErrorFlag() const { return ((flags & 0x1000)>>12); } + // UShort_t GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } + // UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } + // UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); } + + + private: + + + ClassDef(TGrandRaidenHit,1); +}; + + +#endif diff --git a/libraries/TDetSystems/TGrandRaiden/LinkDef.h b/libraries/TDetSystems/TGrandRaiden/LinkDef.h new file mode 100644 index 00000000..b404a2c8 --- /dev/null +++ b/libraries/TDetSystems/TGrandRaiden/LinkDef.h @@ -0,0 +1,14 @@ +// TGrandRaiden.h TGrandRaidenHit.h + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclasses; + +#pragma link C++ class TGrandRaidenHit+; +#pragma link C++ class std::vector+; +#pragma link C++ class TGrandRaiden+; + +#endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx new file mode 100644 index 00000000..87819af3 --- /dev/null +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -0,0 +1,40 @@ +#include "TGrandRaiden.h" +#include "TRawEvent.h" + +TGrandRaiden::TGrandRaiden(){ + Clear(); +} + +TGrandRaiden::~TGrandRaiden() { + +} + +void TGrandRaiden::Copy(TObject& obj) const { + TDetector::Copy(obj); + + TGrandRaiden& detector = (TGrandRaiden&)obj; + detector.GRHits = GRHits; +} + +void TGrandRaiden::InsertHit(const TDetectorHit& hit){ + GRHits.emplace_back((TGrandRaidenHit&)hit); + fSize++; +} + +int TGrandRaiden::BuildHits(std::vector& raw_data){ + for(auto& event : raw_data){ + SetTimestamp(event.GetTimestamp()); + TGrandRaidenHit hit; + auto buf = event.GetPayloadBuffer(); + hit.BuildFrom(buf); + hit.SetTimestamp(event.GetTimestamp()); + InsertHit(hit); + } + return Size(); +} + +void TGrandRaiden::Print(Option_t *opt) const { } + +void TGrandRaiden::Clear(Option_t *opt) { + GRHits.clear(); +} diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx new file mode 100644 index 00000000..8bc52e8d --- /dev/null +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -0,0 +1,43 @@ +#include "TGrandRaidenHit.h" + +#include "TGRUTOptions.h" + +ClassImp(TGrandRaidenHit) + +TGrandRaidenHit::TGrandRaidenHit(){ + +} + +TGrandRaidenHit::~TGrandRaidenHit() { + +} + + + + +void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ + Clear(); + + //auto header = (TRawEvent::GEBGrandRaidenHead*)buf.GetData(); + //buf.Advance(sizeof(TRawEvent::GEBGrandRaidenHead)); + +} + + + + + +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); +} + diff --git a/libraries/TLoops/TUnpackedEvent.cxx b/libraries/TLoops/TUnpackedEvent.cxx index 6667eb4d..2e31f5ee 100644 --- a/libraries/TLoops/TUnpackedEvent.cxx +++ b/libraries/TLoops/TUnpackedEvent.cxx @@ -15,6 +15,7 @@ #include "TSega.h" #include "TFastScint.h" #include "TArgonne.h" +#include "TGrandRaiden.h" TUnpackedEvent::TUnpackedEvent() { } @@ -33,7 +34,7 @@ void TUnpackedEvent::Build() { case kDetectorSystems::GRETINA: GetDetector(true)->Build(raw_data); break; - + case kDetectorSystems::GRETINA_SIM: GetDetector(true)->Build(raw_data); break; @@ -82,6 +83,11 @@ void TUnpackedEvent::Build() { GetDetector(true)->Build(raw_data); break; + case kDetectorSystems::GRAND_RAIDEN: + GetDetector(true)->Build(raw_data); + break; + + default: break; } diff --git a/libraries/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index 452f48da..c3dfeb34 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -61,15 +61,18 @@ bool TUnpackingLoop::Iteration(){ } break; - case kFileType::ANL_RAW: - case kFileType::GRETINA_MODE2: - case kFileType::GRETINA_MODE3: - { + case kFileType::ANL_RAW: + case kFileType::GRETINA_MODE2: + case kFileType::GRETINA_MODE3: + { TGEBEvent geb_event(raw_event); HandleGEBData(geb_event); } - break; - + break; + case kFileType::ROOT_DATA: + { + fOutputEvent->AddRawData(raw_event, kDetectorSystems::GRAND_RAIDEN); + } default: break; } diff --git a/makefile b/makefile index 895502f6..497b0043 100644 --- a/makefile +++ b/makefile @@ -6,10 +6,11 @@ PLATFORM:=$(PLATFORM) # EDIT THIS SECTION -INCLUDES = include +GRANALYZER = $(realpath ../GRAnalyzer/analyzer) +INCLUDES = include $(GRANALYZER)/include CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter LINKFLAGS_PREFIX = -LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 +LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPTREE SRC_SUFFIX = cxx # EVERYTHING PAST HERE SHOULD WORK AUTOMATICALLY From bb7975633e247b3dd7ce0f0576c81665e9b3a129 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 19 May 2016 08:29:27 -0400 Subject: [PATCH 15/94] Removed trailing whitespace --- include/TDetector.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/TDetector.h b/include/TDetector.h index 2a91d8be..47f9cdaf 100644 --- a/include/TDetector.h +++ b/include/TDetector.h @@ -36,12 +36,12 @@ class TDetector : public TNamed { void SetTimestamp(Long_t timestamp) { fTimestamp = timestamp; } enum EDetectorStatus { kUnbuilt = BIT(15) }; - + unsigned int RunStart() const { return fRunStart; } virtual void SetRunStart(unsigned int unix_time) { fRunStart = unix_time; } - - + + void AddRawData(TRawEvent *event) { fRawData.push_back(event); } int Build(); // build from transient data member. @@ -56,7 +56,7 @@ class TDetector : public TNamed { It is the number of seconds since January 1, 1970. If unavailable, will be 0. **/ - unsigned int fRunStart; + unsigned int fRunStart; private: From 6cfa774943dd3d019428cab4fb73d1ec119dd554 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 19 May 2016 15:24:55 -0400 Subject: [PATCH 16/94] Successfully linking against GRAnalyzer data structure RCNPEvent. Some issue exists in the root file not being picked up as a TTreeSource. --- include/TGrandRaidenHit.h | 1 + include/TTreeSource.h | 2 ++ .../TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx | 12 ++++++++---- libraries/TRawFormat/LinkDef.h | 3 +-- libraries/TRawFormat/TRawEventSource.cxx | 2 +- makefile | 7 ++++--- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index b832e3f2..dfe3cad8 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -16,6 +16,7 @@ class TGrandRaidenHit : public TDetectorHit { void BuildFrom(TSmartBuffer& buf); + Int_t test; // Long_t GetLED() const { return led; } // Long_t GetCFD() const { return cfd; } diff --git a/include/TTreeSource.h b/include/TTreeSource.h index d04c47ad..71c69905 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -9,6 +9,8 @@ #include "TRawSource.h" #include "TChain.h" +#include "rootalyze.h" + templateClassImp(TTreeSource) template diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 8bc52e8d..bad680d0 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -1,10 +1,11 @@ #include "TGrandRaidenHit.h" - #include "TGRUTOptions.h" +#include "rootalyze.h" +#include "TSmartBuffer.h" ClassImp(TGrandRaidenHit) -TGrandRaidenHit::TGrandRaidenHit(){ +TGrandRaidenHit::TGrandRaidenHit() : test(0) { } @@ -18,8 +19,11 @@ TGrandRaidenHit::~TGrandRaidenHit() { void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ Clear(); - //auto header = (TRawEvent::GEBGrandRaidenHead*)buf.GetData(); - //buf.Advance(sizeof(TRawEvent::GEBGrandRaidenHead)); + auto event = reinterpret_cast(buf.GetData()); + buf.Advance(sizeof(event)); + + cout << "TGrandRaidenHit::BuildFrom" << endl; + test = 1; } diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index 355e6df2..8119cbca 100644 --- a/libraries/TRawFormat/LinkDef.h +++ b/libraries/TRawFormat/LinkDef.h @@ -28,8 +28,7 @@ #pragma link C++ class TOrderedRawFile+; #pragma link C++ class TSequentialRawFile+; -#pragma link C++ class EventType+; // to be removed -#pragma link C++ class TTreeSource+; +#pragma link C++ class TTreeSource+; #pragma link C++ enum TRawEvent::ArgonneType; diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index bf63ad2b..88407708 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -90,7 +90,7 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, } else if (hasSuffix(filename,".gz")){ source = new TRawEventGZipSource(filename, file_type); } else if (hasSuffix(filename,".root")){ - source = new TTreeSource(filename,"eventtree","event", file_type); + source = new TTreeSource(filename,"rcnptree1","rcnpevent", file_type); // If it is an in-progress file, open it that way } else if (is_online) { source = new TRawEventOnlineFileSource(filename, file_type); diff --git a/makefile b/makefile index 497b0043..371a1ed3 100644 --- a/makefile +++ b/makefile @@ -6,11 +6,12 @@ PLATFORM:=$(PLATFORM) # EDIT THIS SECTION -GRANALYZER = $(realpath ../GRAnalyzer/analyzer) -INCLUDES = include $(GRANALYZER)/include +GRANAPATH = ../GRAnalyzer/analyzer +GRANALYZER = $(realpath $(GRANAPATH)) +INCLUDES = include $(GRANAPATH)/include CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter LINKFLAGS_PREFIX = -LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPTREE +LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent SRC_SUFFIX = cxx # EVERYTHING PAST HERE SHOULD WORK AUTOMATICALLY From 2f8c4d1c7a47a706a359ac2a8d19ffa1502ebfcb Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 20 May 2016 09:22:40 -0400 Subject: [PATCH 17/94] Added TTreeSource which now moves data through and into TGrandRaiden hits where unpacking can be done. Time to test event correlation between CAGRA and GR! --- include/TGRUTOptions.h | 2 + include/TGrandRaidenHit.h | 20 ++--- include/TTreeSource.h | 82 ++++++++++--------- .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 2 +- .../TGrandRaiden/TGrandRaidenHit.cxx | 14 +++- libraries/TGRUTint/TGRUTOptions.cxx | 7 ++ libraries/TGRUTint/TGRUTint.cxx | 17 ++-- libraries/TRawFormat/TRawEventSource.cxx | 2 +- 8 files changed, 81 insertions(+), 65 deletions(-) diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index cb47c578..4a3175b7 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; } + bool TreeSource() const { return fTreeSource; } bool IsOnline() const { return fIsOnline; } @@ -97,6 +98,7 @@ class TGRUTOptions : public TObject { bool fStartGui; bool fMakeHistos; bool fSortMultiple; + bool fTreeSource; bool fTimeSortInput; int fTimeSortDepth; diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index dfe3cad8..11758fe3 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -16,8 +16,8 @@ class TGrandRaidenHit : public TDetectorHit { void BuildFrom(TSmartBuffer& buf); - Int_t test; + Long_t test; // Long_t GetLED() const { return led; } // Long_t GetCFD() const { return cfd; } // Int_t GetPreE() const { return prerise_energy; } @@ -26,18 +26,12 @@ class TGrandRaidenHit : public TDetectorHit { // UShort_t GetChannel() const { return channel; } // Long_t GetPrevLED() const { return led_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; } - // UShort_t GetPreEnd() const { return prerise_end_sample; } - - // // Parse flags - // UShort_t ExternalDiscFlag() const { return ((flags & 0x100)>>8); } - // UShort_t PeakValidFlag() const { return ((flags & 0x200)>>9); } - // UShort_t OffsetFlag() const { return ((flags & 0x400)>>10); } - // UShort_t SyncErrorFlag() const { return ((flags & 0x1000)>>12); } - // UShort_t GeneralErrorFlag() const { return ((flags & 0x2000)>>13); } - // UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } - // UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); } + // UShort_t GetPostEnd() const { return postrise_end_sample; } + // UShort_t GetPreBegin() const { return prerise_begin_sample; } + // UShort_t GetPreEnd() const { return prerise_end_sample; } + + + private: diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 71c69905..c4d870c9 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -20,28 +20,47 @@ class TTreeSource : public TRawEventSource { /* TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) */ /* : TTreeSource({filename},treename,eventclassname,file_type) { ; } */ - template - TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) - : TTreeSource({filename},treename,eventclassname,file_type,std::forward(args)...) { ; } + // template + // TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) + // : TTreeSource({filename},treename,eventclassname,file_type,std::forward(args)...) { ; } - template - TTreeSource(const std::vector& filenames, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) + // template + // TTreeSource(const std::vector& filenames, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) + + // template + // TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) + // : fChain(treename), fCurrentEntry(0) { + + // assert(file_type == kFileType::ROOT_DATA); + + // fFileType = file_type; + + // fChain.Add(filename); + + // fFileSize = fChain.GetEntries()*sizeof(T); + + // if (sizeof...(Args) > 0) { + // fEvent = new T(std::forward(args)...); + // } else { + // fEvent = new T(); + // } + // fChain.SetBranchAddress(eventclassname, &fEvent); + // } + TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) : fChain(treename), fCurrentEntry(0) { assert(file_type == kFileType::ROOT_DATA); + fFileType = file_type; + fChain.Add(filename); + + fNumEvents = fChain.GetEntries(); - for (auto fn : filenames) { - fChain.Add(fn); - } - fFileSize = fChain.GetEntries()*sizeof(T); + fFileSize = fNumEvents*sizeof(T); + + fEvent = new T(); - if (sizeof...(Args) > 0) { - fEvent = new T(std::forward(args)...); - } else { - fEvent = new T(); - } fChain.SetBranchAddress(eventclassname, &fEvent); } @@ -64,26 +83,32 @@ class TTreeSource : public TRawEventSource { virtual int GetEvent(TRawEvent& event) { event.SetFileType(fFileType); + // if there are no more events, signal termination + if (fCurrentEntry == fNumEvents) { return -1; } // copy construct a new object from the old - fEvent = new T(*fEvent); + fEvent = new T(); // fill the new object with current event data fChain.GetEntry(fCurrentEntry); // create a small memory buffer to hold the pointer to the current entry - char* ptrbytes = (char*)malloc(sizeof(fEvent)); - memcpy(ptrbytes, &fEvent, sizeof(fEvent)); + char* ptrbytes = (char*)calloc(1,sizeof(fEvent)); + // copy the address stored in fEvent into the temporary buffer + memcpy(&ptrbytes, &fEvent, sizeof(fEvent)); + // prepare the events smart buffer payload TSmartBuffer eventbuffer(ptrbytes,sizeof(fEvent)); // set the pointer address into the buffer event.SetData(eventbuffer); // set the timestamp of the ttree event + fEvent->SetTimestamp(fNumEvents - fCurrentEntry); event.SetFragmentTimestamp(fEvent->GetTimestamp()); - + // increment the event count fCurrentEntry++; //fEvent = nullptr; - return sizeof(*fEvent); + return sizeof(fEvent); } TChain fChain; kFileType fFileType; + long fNumEvents; long fFileSize; T* fEvent; long fCurrentEntry; @@ -91,23 +116,4 @@ class TTreeSource : public TRawEventSource { ClassDef(TTreeSource,0); }; -/* Prototype example, to be removed */ -class EventType : public TObject { -public: - EventType(){;} - virtual ~EventType(){;} - long GetTimestamp() {return fTimestamp;} - long fTimestamp; - ClassDef(EventType,0); -}; - -/* template TTreeSource make_ttree_source(const char* filename, const char* treename, Args&&... args) */ -/* { */ - -/* } */ -/* make_ttree_source("./rootfilename.root","treename","branchname"); */ -/* make_ttree_source("./rootfilename.root","treename","branch1name","branch2name"); */ -/* make_ttree_source("./rootfilename.root","treename","branch1name", ... ,"branch2name", ...); */ - - #endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index 87819af3..9025c6fe 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -25,7 +25,7 @@ int TGrandRaiden::BuildHits(std::vector& raw_data){ for(auto& event : raw_data){ SetTimestamp(event.GetTimestamp()); TGrandRaidenHit hit; - auto buf = event.GetPayloadBuffer(); + auto buf = event.GetBuffer(); hit.BuildFrom(buf); hit.SetTimestamp(event.GetTimestamp()); InsertHit(hit); diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index bad680d0..844f5337 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -19,12 +19,18 @@ TGrandRaidenHit::~TGrandRaidenHit() { void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ Clear(); - auto event = reinterpret_cast(buf.GetData()); - buf.Advance(sizeof(event)); + //char* ptrbytes = (char*)calloc(1,sizeof(RCNPEvent*)); + //auto buffer = buf.GetData(); + //memcpy(&ptrbytes, &buffer, sizeof(RCNPEvent*)); + //TSmartBuffer temp(std::move(buf)); - cout << "TGrandRaidenHit::BuildFrom" << endl; - test = 1; + auto event = const_cast((const RCNPEvent*)buf.GetData()); + //std::cout << event->GR_ADC() << std::endl; + test = 1; + buf.Advance(sizeof(event)); + //buf.Clear(); + //if (event) delete event; } diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index 4f4cf757..76e017c2 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -87,6 +87,13 @@ void TGRUTOptions::Load(int argc, char** argv) { .description("Input file(s)"); parser.option("o output", &output_file) .description("Root output file"); + + + parser.option("T tree-source", &fTreeSource) + .description("Input TTree source.") + .default_value(false); + + parser.option("hist-output",&output_histogram_file) .description("Output file for histograms"); parser.option("r ring",&input_ring) diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx index 7e895b0a..26af2278 100644 --- a/libraries/TGRUTint/TGRUTint.cxx +++ b/libraries/TGRUTint/TGRUTint.cxx @@ -178,12 +178,13 @@ void TGRUTint::ApplyOptions() { TFile* tfile = OpenRootFile(filename); cuts_files.push_back(tfile); } - - for(auto filename : opt->RootInputFiles()) { - OpenRootFile(filename); - // this will populate gChain if able. - // TChannels from the root file will be loaded as file is opened. - // GValues from the root file will be loaded as file is opened. + if (!opt->TreeSource()) { + for(auto filename : opt->RootInputFiles()) { + OpenRootFile(filename); + // this will populate gChain if able. + // TChannels from the root file will be loaded as file is opened. + // GValues from the root file will be loaded as file is opened. + } } //if I am passed any calibrations, lets load those, this @@ -212,10 +213,10 @@ void TGRUTint::ApplyOptions() { } } - //TRCNPTreeSource tst; //next most important thing, if given a raw file && NOT told to not sort! - if((opt->InputRing().length() || opt->RawInputFiles().size()) + if((opt->InputRing().length() || opt->RawInputFiles().size() + || (opt->RootInputFiles().size() && opt->TreeSource())) && !missing_file && opt->SortRaw()) { TRawEventSource* source = NULL; diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index 88407708..fff8725a 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -90,7 +90,7 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, } else if (hasSuffix(filename,".gz")){ source = new TRawEventGZipSource(filename, file_type); } else if (hasSuffix(filename,".root")){ - source = new TTreeSource(filename,"rcnptree1","rcnpevent", file_type); + source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type); // If it is an in-progress file, open it that way } else if (is_online) { source = new TRawEventOnlineFileSource(filename, file_type); From 1fe33abade674de47bb1131120a72106ed811f11 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 23 May 2016 10:27:10 -0400 Subject: [PATCH 18/94] Added some members to TGrandRaidenHit to test the GR data stream --- histos/MakeANLHistos.cxx | 2 +- include/TGrandRaiden.h | 4 ---- include/TGrandRaidenHit.h | 19 ++++--------------- include/TTreeSource.h | 2 +- .../TGrandRaiden/TGrandRaidenHit.cxx | 17 ++++++++++++++--- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 91e59868..cd8a6a20 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -43,8 +43,8 @@ void MakeHistograms(TRuntimeObjects& obj) { for(int y=0;ySize();y++) { TArgonneHit hit = cagra->GetArgonneHit(y); - if(hit.GetBoardID() == 113) { + cout << hit.GetLED() << endl; stream.str(""); stream << "Crystal" << hit.GetChannel(); float Energy = ((hit.GetPostE() - hit.GetPreE())/350.0); diff --git a/include/TGrandRaiden.h b/include/TGrandRaiden.h index be50677d..bbb3012a 100644 --- a/include/TGrandRaiden.h +++ b/include/TGrandRaiden.h @@ -33,8 +33,4 @@ class TGrandRaiden : public TDetector { ClassDef(TGrandRaiden,1); }; - - - - #endif diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index 11758fe3..a0780f0c 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -17,24 +17,13 @@ class TGrandRaidenHit : public TDetectorHit { void BuildFrom(TSmartBuffer& buf); - Long_t test; - // Long_t GetLED() const { return led; } - // Long_t GetCFD() const { return cfd; } - // 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; } - // UShort_t GetPostBegin() const { return postrise_begin_sample; } - // UShort_t GetPostEnd() const { return postrise_end_sample; } - // UShort_t GetPreBegin() const { return prerise_begin_sample; } - // UShort_t GetPreEnd() const { return prerise_end_sample; } - - - + Double_t* GetADC() { return &ADC[0]; } + Double_t GetADC(const Int_t& i) const { return ADC[i]; } + //void SetADC(Int_t chan, const Double_t& val) { ADC[chan] = val; } private: + Double_t ADC[4]; ClassDef(TGrandRaidenHit,1); diff --git a/include/TTreeSource.h b/include/TTreeSource.h index c4d870c9..5dbdc747 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -112,7 +112,7 @@ class TTreeSource : public TRawEventSource { long fFileSize; T* fEvent; long fCurrentEntry; - + ClassDef(TTreeSource,0); }; diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 844f5337..c54cda69 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -5,8 +5,8 @@ ClassImp(TGrandRaidenHit) -TGrandRaidenHit::TGrandRaidenHit() : test(0) { - +TGrandRaidenHit::TGrandRaidenHit() { + memset(&ADC[0],0,sizeof(Double_t)); } TGrandRaidenHit::~TGrandRaidenHit() { @@ -19,15 +19,26 @@ TGrandRaidenHit::~TGrandRaidenHit() { void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ Clear(); + // method 1 //char* ptrbytes = (char*)calloc(1,sizeof(RCNPEvent*)); //auto buffer = buf.GetData(); //memcpy(&ptrbytes, &buffer, sizeof(RCNPEvent*)); + + // method 2 //TSmartBuffer temp(std::move(buf)); + // method 3 auto event = const_cast((const RCNPEvent*)buf.GetData()); + auto adc = event->GR_ADC(); + if (adc != nullptr) { + std::copy(adc->begin(),adc->end(),&ADC[0]); + } + + // for (int i=0; i<4; i++) { + // std::cout << ADC[i] << " "; + // } std::cout << std::endl; //std::cout << event->GR_ADC() << std::endl; - test = 1; buf.Advance(sizeof(event)); //buf.Clear(); //if (event) delete event; From 9839e1f5e1589c06b73b35083e1588616053c476 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 24 May 2016 14:05:59 -0400 Subject: [PATCH 19/94] Added fake timestamps to GR data to test event correlation. Bug fix in TRawEvent. --- histos/RCNPHistos.cxx | 87 +++++++++++++++++++ include/TGrandRaidenHit.h | 1 + include/TTreeSource.h | 35 +++++++- .../TGrandRaiden/TGrandRaidenHit.cxx | 1 + libraries/TRawFormat/TRawEvent.cxx | 1 + makefile | 2 +- 6 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 histos/RCNPHistos.cxx diff --git a/histos/RCNPHistos.cxx b/histos/RCNPHistos.cxx new file mode 100644 index 00000000..7394d8e1 --- /dev/null +++ b/histos/RCNPHistos.cxx @@ -0,0 +1,87 @@ + +#include "TRuntimeObjects.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "TArgonne.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++) { + TArgonneHit hit = cagra->GetArgonneHit(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/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index a0780f0c..45762fc4 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -20,6 +20,7 @@ class TGrandRaidenHit : public TDetectorHit { Double_t* GetADC() { return &ADC[0]; } Double_t GetADC(const Int_t& i) const { return ADC[i]; } //void SetADC(Int_t chan, const Double_t& val) { ADC[chan] = val; } + Long_t Timestamp; private: diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 5dbdc747..f0269fb4 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -1,8 +1,10 @@ #ifndef _TTREESOURCE_H_ #define _TTREESOURCE_H_ -#include +#include #include +#include +#include #include "TObject.h" #include "TRawEvent.h" @@ -62,6 +64,8 @@ class TTreeSource : public TRawEventSource { fEvent = new T(); fChain.SetBranchAddress(eventclassname, &fEvent); + + LoadFakeTimestamps(); } ~TTreeSource() {;} @@ -77,6 +81,24 @@ class TTreeSource : public TRawEventSource { protected: void SetFileSize(long file_size) { fFileSize = file_size; } + void LoadFakeTimestamps() { + + std::string line; std::stringstream stream; ULong_t ts; + ifstream file ("/projects/ceclub/sullivan/cagragr/GRUTinizer/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(); + } + } private: TTreeSource() {;} @@ -98,7 +120,13 @@ class TTreeSource : public TRawEventSource { // set the pointer address into the buffer event.SetData(eventbuffer); // set the timestamp of the ttree event - fEvent->SetTimestamp(fNumEvents - fCurrentEntry); + if (timestamps.size()==0) { + std::cout << "End of time stamps" << std::endl; + return -1; + } + fEvent->SetTimestamp(timestamps.front()+1); + timestamps.pop(); + event.SetFragmentTimestamp(fEvent->GetTimestamp()); // increment the event count fCurrentEntry++; @@ -112,7 +140,8 @@ class TTreeSource : public TRawEventSource { long fFileSize; T* fEvent; long fCurrentEntry; - + queue timestamps; + ClassDef(TTreeSource,0); }; diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index c54cda69..96cd4df7 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -33,6 +33,7 @@ void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ if (adc != nullptr) { std::copy(adc->begin(),adc->end(),&ADC[0]); } + Timestamp = event->GetTimestamp(); // for (int i=0; i<4; i++) { // std::cout << ADC[i] << " "; diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index 8a644aaf..fd455894 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -45,6 +45,7 @@ TRawEvent &TRawEvent::operator=(const TRawEvent &rhs) { fEventHeader = rhs.fEventHeader; fBody = rhs.fBody; fFileType = rhs.fFileType; + fTimestamp = rhs.fTimestamp; return *this; } diff --git a/makefile b/makefile index 371a1ed3..8095e509 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,7 @@ PLATFORM:=$(PLATFORM) # EDIT THIS SECTION GRANAPATH = ../GRAnalyzer/analyzer -GRANALYZER = $(realpath $(GRANAPATH)) +GRANALYZER = $(realpath $(GRANAPATH)/../lib) INCLUDES = include $(GRANAPATH)/include CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter LINKFLAGS_PREFIX = From f77a9106f1c5edd1c7e9faaa2e55d2f50c7c20e3 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 26 May 2016 12:47:49 -0400 Subject: [PATCH 20/94] Added histos for all CAGRA boards and channels --- histos/MakeANLHistos.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index cd8a6a20..2d6d0143 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -19,7 +19,7 @@ //#include "GValue.h" #define PRINT(x) std::cout << #x" = " << x << std::endl -#define STR(x) #x << " = " << x +#define STR(x) #x << " = " <<() x using namespace std; @@ -43,8 +43,20 @@ void MakeHistograms(TRuntimeObjects& obj) { for(int y=0;ySize();y++) { TArgonneHit hit = cagra->GetArgonneHit(y); + + +//cout << hit.GetBoardID() << " " << hit.GetChannel() << endl; + + stream.str(""); + stream << "PostE_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); + obj.FillHistogram(stream.str(),10000,0,0,hit.GetPostE()); + //stream.str(""); + //stream << "LED_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); + //obj.FillHistogram(stream.str(),10000,0,0,hit.GetLED()); + + if(hit.GetBoardID() == 113) { - cout << hit.GetLED() << endl; + //cout << hit.GetLED() << endl; stream.str(""); stream << "Crystal" << hit.GetChannel(); float Energy = ((hit.GetPostE() - hit.GetPreE())/350.0); @@ -53,7 +65,6 @@ void MakeHistograms(TRuntimeObjects& obj) { - // PRINT(hit.GetBoardID()); // if (hit.GetChannel() > 2) PRINT(hit.GetChannel()); // PRINT(hit.GetLED()); From 0f0359cf6c2759c91dca7679943d8eb8e5ec503a Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 27 May 2016 01:38:48 -0400 Subject: [PATCH 21/94] Completely restructured Argonne/CAGRA interface. Instead of having TArgonne and TArgonneHit, I refactored TArgonneHit into a TANLEvent type that is responsible for doing the unpacking, and then the other classes are solely responsible for building the unpacked event into calibrated events. TArgonne/TArgonneHits have been renamed to TCAGRA/TCAGRAHits. Left to do: Need figure out why Clover channel 0 is not appearing in histos. Need to test to see if the positions map is working right. Need to test if the calibrations file is working right. See if the segmentation is working or if the TCAGRASegmentHit class is overkill. Finally, need expand channel calibrations to include second order corrections such as asymptotic baseline and pole-zero corrections, for example. --- config/CAGRA_positions.txt | 80 ++++++++ histos/MakeANLHistos.cxx | 36 ++-- histos/RCNPHistos.cxx | 11 +- include/{TArgonneHit.h => TANLEvent.h} | 27 ++- include/TArgonne.h | 40 ---- include/TCAGRA.h | 48 +++++ include/TCAGRAHit.h | 54 ++++++ include/TCAGRASegmentHit.h | 27 +++ libraries/TDetSystems/TArgonne/LinkDef.h | 11 +- libraries/TDetSystems/TArgonne/TANLEvent.cxx | 77 ++++++++ libraries/TDetSystems/TArgonne/TArgonne.cxx | 40 ---- .../TDetSystems/TArgonne/TArgonneHit.cxx | 152 --------------- libraries/TDetSystems/TArgonne/TCAGRA.cxx | 176 ++++++++++++++++++ libraries/TDetSystems/TArgonne/TCAGRAHit.cxx | 121 ++++++++++++ .../TDetSystems/TArgonne/TCAGRASegmentHit.cxx | 60 ++++++ libraries/TLoops/TUnpackedEvent.cxx | 4 +- util/generate_positions_cagra.py | 97 ++++++++++ 17 files changed, 791 insertions(+), 270 deletions(-) create mode 100644 config/CAGRA_positions.txt rename include/{TArgonneHit.h => TANLEvent.h} (79%) delete mode 100644 include/TArgonne.h create mode 100644 include/TCAGRA.h create mode 100644 include/TCAGRAHit.h create mode 100644 include/TCAGRASegmentHit.h create mode 100644 libraries/TDetSystems/TArgonne/TANLEvent.cxx delete mode 100644 libraries/TDetSystems/TArgonne/TArgonne.cxx delete mode 100644 libraries/TDetSystems/TArgonne/TArgonneHit.cxx create mode 100644 libraries/TDetSystems/TArgonne/TCAGRA.cxx create mode 100644 libraries/TDetSystems/TArgonne/TCAGRAHit.cxx create mode 100644 libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx create mode 100644 util/generate_positions_cagra.py diff --git a/config/CAGRA_positions.txt b/config/CAGRA_positions.txt new file mode 100644 index 00000000..8599d2bf --- /dev/null +++ b/config/CAGRA_positions.txt @@ -0,0 +1,80 @@ +clover.01.1.vec: 6.158151878 9.311848122 14.092638149 +clover.01.2.vec: 8.388151878 11.541848122 10.938941905 +clover.01.3.vec: 9.311848122 6.158151878 14.092638149 +clover.01.4.vec: 11.541848122 8.388151878 10.938941905 + +clover.02.1.vec: -9.311848122 6.158151878 14.092638149 +clover.02.2.vec: -11.541848122 8.388151878 10.938941905 +clover.02.3.vec: -6.158151878 9.311848122 14.092638149 +clover.02.4.vec: -8.388151878 11.541848122 10.938941905 + +clover.03.1.vec: -6.158151878 -9.311848122 14.092638149 +clover.03.2.vec: -8.388151878 -11.541848122 10.938941905 +clover.03.3.vec: -9.311848122 -6.158151878 14.092638149 +clover.03.4.vec: -11.541848122 -8.388151878 10.938941905 + +clover.04.1.vec: 9.311848122 -6.158151878 14.092638149 +clover.04.2.vec: 11.541848122 -8.388151878 10.938941905 +clover.04.3.vec: 6.158151878 -9.311848122 14.092638149 +clover.04.4.vec: 8.388151878 -11.541848122 10.938941905 + +clover.05.1.vec: 17.7 2.23 2.23 +clover.05.2.vec: 17.7 2.23 -2.23 +clover.05.3.vec: 17.7 -2.23 2.23 +clover.05.4.vec: 17.7 -2.23 -2.23 + +clover.06.1.vec: 10.938941905 14.092638149 2.23 +clover.06.2.vec: 10.938941905 14.092638149 -2.23 +clover.06.3.vec: 14.092638149 10.938941905 2.23 +clover.06.4.vec: 14.092638149 10.938941905 -2.23 + +clover.07.1.vec: -2.23 17.7 2.23 +clover.07.2.vec: -2.23 17.7 -2.23 +clover.07.3.vec: 2.23 17.7 2.23 +clover.07.4.vec: 2.23 17.7 -2.23 + +clover.08.1.vec: -14.092638149 10.938941905 2.23 +clover.08.2.vec: -14.092638149 10.938941905 -2.23 +clover.08.3.vec: -10.938941905 14.092638149 2.23 +clover.08.4.vec: -10.938941905 14.092638149 -2.23 + +clover.09.1.vec: -17.7 -2.23 2.23 +clover.09.2.vec: -17.7 -2.23 -2.23 +clover.09.3.vec: -17.7 2.23 2.23 +clover.09.4.vec: -17.7 2.23 -2.23 + +clover.10.1.vec: -10.938941905 -14.092638149 2.23 +clover.10.2.vec: -10.938941905 -14.092638149 -2.23 +clover.10.3.vec: -14.092638149 -10.938941905 2.23 +clover.10.4.vec: -14.092638149 -10.938941905 -2.23 + +clover.11.1.vec: 2.23 -17.7 2.23 +clover.11.2.vec: 2.23 -17.7 -2.23 +clover.11.3.vec: -2.23 -17.7 2.23 +clover.11.4.vec: -2.23 -17.7 -2.23 + +clover.12.1.vec: 14.092638149 -10.938941905 2.23 +clover.12.2.vec: 14.092638149 -10.938941905 -2.23 +clover.12.3.vec: 10.938941905 -14.092638149 2.23 +clover.12.4.vec: 10.938941905 -14.092638149 -2.23 + +clover.13.1.vec: 8.388151878 11.541848122 -10.938941905 +clover.13.2.vec: 6.158151878 9.311848122 -14.092638149 +clover.13.3.vec: 11.541848122 8.388151878 -10.938941905 +clover.13.4.vec: 9.311848122 6.158151878 -14.092638149 + +clover.14.1.vec: -11.541848122 8.388151878 -10.938941905 +clover.14.2.vec: -9.311848122 6.158151878 -14.092638149 +clover.14.3.vec: -8.388151878 11.541848122 -10.938941905 +clover.14.4.vec: -6.158151878 9.311848122 -14.092638149 + +clover.15.1.vec: -8.388151878 -11.541848122 -10.938941905 +clover.15.2.vec: -6.158151878 -9.311848122 -14.092638149 +clover.15.3.vec: -11.541848122 -8.388151878 -10.938941905 +clover.15.4.vec: -9.311848122 -6.158151878 -14.092638149 + +clover.16.1.vec: 11.541848122 -8.388151878 -10.938941905 +clover.16.2.vec: 9.311848122 -6.158151878 -14.092638149 +clover.16.3.vec: 8.388151878 -11.541848122 -10.938941905 +clover.16.4.vec: 6.158151878 -9.311848122 -14.092638149 + diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 2d6d0143..cc2728f0 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -13,7 +13,7 @@ #include #include -#include "TArgonne.h" +#include "TCAGRA.h" //#include "TChannel.h" //#include "GValue.h" @@ -32,7 +32,7 @@ stringstream stream; // or else bad things will happen. extern "C" void MakeHistograms(TRuntimeObjects& obj) { - TArgonne *cagra = obj.GetDetector(); + TCAGRA *cagra = obj.GetDetector(); TList *list = &(obj.GetObjects()); int numobj = list->GetSize(); @@ -40,27 +40,36 @@ void MakeHistograms(TRuntimeObjects& obj) { if(!cagra) return; + for(int y=0;ySize();y++) { - TArgonneHit hit = cagra->GetArgonneHit(y); + TCAGRAHit hit = cagra->GetCAGRAHit(y); + -//cout << hit.GetBoardID() << " " << hit.GetChannel() << endl; + //stream.str(""); + //stream << "PostE_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); + //obj.FillHistogram(stream.str(),10000,0,0,hit.GetPostE()); - stream.str(""); - stream << "PostE_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); - obj.FillHistogram(stream.str(),10000,0,0,hit.GetPostE()); //stream.str(""); //stream << "LED_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); //obj.FillHistogram(stream.str(),10000,0,0,hit.GetLED()); - if(hit.GetBoardID() == 113) { - //cout << hit.GetLED() << endl; - stream.str(""); - stream << "Crystal" << hit.GetChannel(); - float Energy = ((hit.GetPostE() - hit.GetPreE())/350.0); - obj.FillHistogram(stream.str(),10000,0,20000,Energy); + // if(hit.GetBoardID() == 113) { + // //cout << hit.GetLED() << endl; + // stream.str(""); + // stream << "Crystal" << hit.GetChannel(); + // float Energy = ((hit.GetPostE() - hit.GetPreE())/350.0); + // obj.FillHistogram(stream.str(),10000,0,20000,Energy); + // } + + for (auto& hit : *cagra) { + if (hit.GetBoardID() == 0x71) { + stream.str(""); + stream << "Crystal" << hit.GetChannel(); + obj.FillHistogram(stream.str(),10000,0,20000,hit.Charge()); + } } @@ -77,6 +86,7 @@ void MakeHistograms(TRuntimeObjects& obj) { + if(numobj!=list->GetSize()) list->Sort(); diff --git a/histos/RCNPHistos.cxx b/histos/RCNPHistos.cxx index 7394d8e1..61a997b5 100644 --- a/histos/RCNPHistos.cxx +++ b/histos/RCNPHistos.cxx @@ -13,7 +13,7 @@ #include #include -#include "TArgonne.h" +#include "TCAGRA.h" #include "TGrandRaiden.h" //#include "TChannel.h" @@ -33,7 +33,7 @@ stringstream stream; // or else bad things will happen. extern "C" void MakeHistograms(TRuntimeObjects& obj) { - auto cagra = obj.GetDetector(); + auto cagra = obj.GetDetector(); auto gr = obj.GetDetector(); TList *list = &(obj.GetObjects()); @@ -55,8 +55,10 @@ void MakeHistograms(TRuntimeObjects& obj) { if(!cagra || !gr) { return; } //cout << "Coincidence!!!" << endl; + + /* for(int y=0;ySize();y++) { - TArgonneHit hit = cagra->GetArgonneHit(y); + TCAGRAHit hit = cagra->GetCAGRAHit(y); if(hit.GetBoardID() == 113) { @@ -78,8 +80,7 @@ void MakeHistograms(TRuntimeObjects& obj) { //std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } - - + */ if(numobj!=list->GetSize()) list->Sort(); diff --git a/include/TArgonneHit.h b/include/TANLEvent.h similarity index 79% rename from include/TArgonneHit.h rename to include/TANLEvent.h index 124010ec..43fabdb0 100644 --- a/include/TArgonneHit.h +++ b/include/TANLEvent.h @@ -1,20 +1,16 @@ -#ifndef TARGONNEHIT_H -#define TARGONNEHIT_H +#ifndef TANLEVENT_H +#define TANLEVENT_H -#include "TDetector.h" -#include "TDetectorHit.h" +#include "TObject.h" + +#include "TSmartBuffer.h" -class TArgonneHit : public TDetectorHit { - public: - TArgonneHit(); - ~TArgonneHit(); - virtual void Copy(TObject& obj) const; - //virtual void Compare(TObject &obj) const; - virtual void Print(Option_t *opt = "") const; - virtual void Clear(Option_t *opt = ""); +class TANLEvent : public TObject { + public: + TANLEvent(TSmartBuffer& buf); + ~TANLEvent(); - void BuildFrom(TSmartBuffer& buf); Long_t GetLED() const { return led; } @@ -38,6 +34,9 @@ class TArgonneHit : public TDetectorHit { UShort_t PileUpOnlyFlag() const { return ((flags & 0x4000)>>14); } UShort_t PileUpFlag() const { return ((flags & 0x8000)>>15); } + // TODO: add to input calibrations file for second order corrections + // e.g. pole zero etc. + double GetEnergy() const { return ((GetPostE() - GetPreE())/350.0); } private: @@ -61,7 +60,7 @@ class TArgonneHit : public TDetectorHit { //UShort_t base_sample; //UShort_t peak_sample; - ClassDef(TArgonneHit,1); + ClassDef(TANLEvent,0); }; diff --git a/include/TArgonne.h b/include/TArgonne.h deleted file mode 100644 index f0f0058b..00000000 --- a/include/TArgonne.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef TARGONNE_H -#define TARGONNE_H - -#include -#include - -#include - -#include "TDetector.h" -#include "TArgonneHit.h" - -class TArgonne : public TDetector { - -public: - TArgonne(); - ~TArgonne(); - - virtual void Copy(TObject& obj) const; - virtual void Print(Option_t *opt = "") const; - virtual void Clear(Option_t *opt = ""); - - virtual void InsertHit(const TDetectorHit& hit); - virtual TDetectorHit& GetHit(int i) { return anl_hits.at(i); } - - const TArgonneHit& GetArgonneHit(int i) { return anl_hits.at(i); } - void PrintHit(int i){ anl_hits.at(i).Print(); } - -private: - virtual int BuildHits(std::vector& raw_data); - - std::vector anl_hits; - - ClassDef(TArgonne,1); -}; - - - - - -#endif diff --git a/include/TCAGRA.h b/include/TCAGRA.h new file mode 100644 index 00000000..4476f4a5 --- /dev/null +++ b/include/TCAGRA.h @@ -0,0 +1,48 @@ +#ifndef TCAGRA_H +#define TCAGRA_H + +#include +#include + +#include "TDetector.h" +#include "TCAGRAHit.h" + +#include "TVector3.h" + +class TCAGRA : public TDetector { + +public: + TCAGRA(); + ~TCAGRA(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + + virtual void InsertHit(const TDetectorHit& hit); + virtual TDetectorHit& GetHit(int i) { return cagra_hits.at(i); } + + const TCAGRAHit& GetCAGRAHit(int i) { return cagra_hits.at(i); } + void PrintHit(int i){ cagra_hits.at(i).Print(); } + + static TVector3 GetSegmentPosition(int detnum, int segnum); + // Allows for looping over all hits with for(auto& hit : cagra) { } + std::vector::iterator begin() { return cagra_hits.begin(); } + std::vector::iterator end() { return cagra_hits.end(); } + + +private: + virtual int BuildHits(std::vector& raw_data); + static void LoadDetectorPositions(); + + std::vector cagra_hits; + static std::map detector_positions; + + ClassDef(TCAGRA,1); +}; + + + + + +#endif diff --git a/include/TCAGRAHit.h b/include/TCAGRAHit.h new file mode 100644 index 00000000..ce0ae685 --- /dev/null +++ b/include/TCAGRAHit.h @@ -0,0 +1,54 @@ +#ifndef TCAGRAHIT_H +#define TCAGRAHIT_H + +#include "TDetectorHit.h" +#include "TCAGRASegmentHit.h" + +class TCAGRAHit : public TDetectorHit { + public: + TCAGRAHit(); + ~TCAGRAHit(); + + virtual void Copy(TObject& obj) const; + virtual void Print(Option_t *opt = "") const; + virtual void Clear(Option_t *opt = ""); + //virtual void Draw(Option_t* opt = ""); + + virtual Int_t Charge() const; + + int GetDetnum() const; + int GetMainSegnum() const; + + bool HasCore() const; + + unsigned int GetNumSegments() const { return fSegments.size(); } + TCAGRASegmentHit& GetSegment(int i) { return fSegments.at(i); } + unsigned long GetSegmentTimestamp() { + if(fSegments.size()){ + return fSegments[0].Timestamp(); + } else { + return -1; + } + } + + TCAGRASegmentHit& MakeSegmentByAddress(unsigned int address); + + int GetBoardID() const; + int GetChannel() const; + + TVector3 GetPosition(bool apply_array_offset = false) const; + + double GetDoppler(double beta, + const TVector3& particle_vec = TVector3(0,0,1), + const TVector3& cagra_offset = TVector3(0,0,0)) const; + + + private: + std::vector fSegments; + + + ClassDef(TCAGRAHit,1); +}; + + +#endif diff --git a/include/TCAGRASegmentHit.h b/include/TCAGRASegmentHit.h new file mode 100644 index 00000000..183c541e --- /dev/null +++ b/include/TCAGRASegmentHit.h @@ -0,0 +1,27 @@ +#ifndef _TCAGRASEGMENTHIT_H_ +#define _TCAGRASEGMENTHIT_H_ + +#include "TDetectorHit.h" + +class TCAGRASegmentHit : public TDetectorHit { +public: + TCAGRASegmentHit() { } + + virtual void Copy(TObject&) const; + virtual void Clear(Option_t *opt = ""); + virtual void Print(Option_t *opt = "") const; + + virtual Int_t Charge() const; + + int GetDetnum() const; + int GetSegnum() const; + + int GetBoardID() const; + int GetChannel() const; + +private: + + ClassDef(TCAGRASegmentHit,1); +}; + +#endif /* _TCAGRASEGMENTHIT_H_ */ diff --git a/libraries/TDetSystems/TArgonne/LinkDef.h b/libraries/TDetSystems/TArgonne/LinkDef.h index 59685e55..62a9095c 100644 --- a/libraries/TDetSystems/TArgonne/LinkDef.h +++ b/libraries/TDetSystems/TArgonne/LinkDef.h @@ -1,4 +1,4 @@ -// TArgonne.h TArgonneHit.h +// TCAGRA.h TCAGRAHit.h TCAGRASegmentHit.h TANLEvent.h #ifdef __CINT__ @@ -7,8 +7,11 @@ #pragma link off all functions; #pragma link C++ nestedclasses; -#pragma link C++ class TArgonneHit+; -#pragma link C++ class std::vector+; -#pragma link C++ class TArgonne+; +#pragma link C++ class TANLEvent+; +#pragma link C++ class TCAGRAHit+; +#pragma link C++ class TCAGRASegmentHit+; +#pragma link C++ class std::vector+; +#pragma link C++ class std::vector+; +#pragma link C++ class TCAGRA+; #endif diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TArgonne/TANLEvent.cxx new file mode 100644 index 00000000..2f6b2747 --- /dev/null +++ b/libraries/TDetSystems/TArgonne/TANLEvent.cxx @@ -0,0 +1,77 @@ +#include "TANLEvent.h" + +#include "TGEBEvent.h" +#include "TGRUTOptions.h" + +ClassImp(TANLEvent) + +//bool TANLEvent::fExtractWaves = true; + +TANLEvent::TANLEvent(TSmartBuffer& buf) { + + bool read_waveform = TGRUTOptions::Get()->ExtractWaves(); + if (read_waveform) { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer& buf) :: Waveforms not supported in GEBArgonne data."); + } + + // Extract header data. Header format should stay constant pending FW updates + auto header = (TRawEvent::GEBArgonneHead*)buf.GetData(); + buf.Advance(sizeof(TRawEvent::GEBArgonneHead)); + // Swap big endian for little endian + TRawEvent::SwapArgonneHead(*header); + // Extract header data + global_addr = header->GetGA(); + board_id = header->GetBoardID(); + channel = header->GetChannel(); + led = header->GetLED(); + cfd = 0; + + // Extract payload data. Two versions LED and CFD, with small changes for different FW versions + switch( static_cast(header->GetHeaderType()) ) { + case TRawEvent::ArgonneType::LEDv10: { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer& buf) :: ArgonneType::LEDv10 is not implemented."); + break; + } + case TRawEvent::ArgonneType::LEDv11: { + 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::CFDv11: { + throw std::invalid_argument( + "void TANLEvent::BuildFrom(TSmartBuffer buf) :: ArgonneType::CFDv11 is not implemented."); + break; + } + } + +} + + + +TANLEvent::~TANLEvent() { + //if(fOwnWave && wave) { + // wave = 0; + // delete wave; + //} +} + + + diff --git a/libraries/TDetSystems/TArgonne/TArgonne.cxx b/libraries/TDetSystems/TArgonne/TArgonne.cxx deleted file mode 100644 index 5f83071e..00000000 --- a/libraries/TDetSystems/TArgonne/TArgonne.cxx +++ /dev/null @@ -1,40 +0,0 @@ -#include "TArgonne.h" -#include "TGEBEvent.h" - -TArgonne::TArgonne(){ - Clear(); -} - -TArgonne::~TArgonne() { - -} - -void TArgonne::Copy(TObject& obj) const { - TDetector::Copy(obj); - - TArgonne& detector = (TArgonne&)obj; - detector.anl_hits = anl_hits; -} - -void TArgonne::InsertHit(const TDetectorHit& hit){ - anl_hits.emplace_back((TArgonneHit&)hit); - fSize++; -} - -int TArgonne::BuildHits(std::vector& raw_data){ - for(auto& event : raw_data){ - SetTimestamp(event.GetTimestamp()); - TArgonneHit hit; - auto buf = event.GetPayloadBuffer(); - hit.BuildFrom(buf); - hit.SetTimestamp(event.GetTimestamp()); - InsertHit(hit); - } - return Size(); -} - -void TArgonne::Print(Option_t *opt) const { } - -void TArgonne::Clear(Option_t *opt) { - anl_hits.clear(); -} diff --git a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx b/libraries/TDetSystems/TArgonne/TArgonneHit.cxx deleted file mode 100644 index 446df75d..00000000 --- a/libraries/TDetSystems/TArgonne/TArgonneHit.cxx +++ /dev/null @@ -1,152 +0,0 @@ -#include "TArgonneHit.h" - -#include "TGEBEvent.h" -#include "TGRUTOptions.h" - -ClassImp(TArgonneHit) - -//bool TArgonneHit::fExtractWaves = true; - -TArgonneHit::TArgonneHit(){ - //fOwnWave = false; - //wave = NULL; - //wavesize = 0; - //for(int i=0;iExtractWaves(); - if (read_waveform) { - throw std::invalid_argument( - "void TArgonneHit::BuildFrom(TSmartBuffer& buf) :: Waveforms not supported in GEBArgonne data."); - } - - // Extract header data. Header format should stay constant pending FW updates - auto header = (TRawEvent::GEBArgonneHead*)buf.GetData(); - buf.Advance(sizeof(TRawEvent::GEBArgonneHead)); - // Swap big endian for little endian - TRawEvent::SwapArgonneHead(*header); - // Extract header data - global_addr = header->GetGA(); - board_id = header->GetBoardID(); - channel = header->GetChannel(); - led = header->GetLED(); - cfd = 0; - - // Extract payload data. Two versions LED and CFD, with small changes for different FW versions - switch( static_cast(header->GetHeaderType()) ) { - case TRawEvent::ArgonneType::LEDv10: { - throw std::invalid_argument( - "void TArgonneHit::BuildFrom(TSmartBuffer& buf) :: ArgonneType::LEDv10 is not implemented."); - break; - } - case TRawEvent::ArgonneType::LEDv11: { - 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::CFDv11: { - throw std::invalid_argument( - "void TArgonneHit::BuildFrom(TSmartBuffer buf) :: ArgonneType::CFDv11 is not implemented."); - break; - } - } - -} - - - - - -void TArgonneHit::Copy(TObject& obj) const { - TDetectorHit::Copy(obj); - - // TArgonneHit& mode3 = (TArgonneHit&)obj; - - - // mode3.board_id = board_id; - - // mode3.charge = charge; - // mode3.wavesize = wavesize; - // mode3.led = led; - // mode3.cfd = cfd; - - // if(ExtractWaves() && wavesize>0) { - - - // memcpy(mode3.wavebuffer,wavebuffer,wavesize*(sizeof(Short_t))); - // mode3.wave = &(mode3.wavebuffer[0]); - // } else { - // mode3.wave=0; - // } - -} - - -void TArgonneHit::Print(Option_t *opt) const { } - -void TArgonneHit::Clear(Option_t *opt) { - TDetectorHit::Clear(opt); - // board_id = -1; - // charge = -1; - // led = -1; - // cfd = -1; - // //if(fOwnWave && wave) { - // // delete wave; - // //} - // ClearWave(); - // //raw_data.clear(); -} - -// void TArgonneHit::ClearWave(Option_t *opt) { -// for(int i=0;iMAXTRACE) -// break; -// //std::cout << "Clear wave " << i << std::endl; -// wavebuffer[i] = 0; -// } -// wave = NULL; -// wavesize = 0; -// } - -// double TArgonneHit::AverageWave(int samples) { -// //printf("wavesize = %i\n",wavesize); -// if(wavesize<1) -// return 0.0; -// if(samples<0 || samples >wavesize) -// samples = wavesize; -// double avg = 0.0; -// for(int i=0;i +#include + +#include "TANLEvent.h" +#include "TChannel.h" + +#include "TGEBEvent.h" + + +std::map TCAGRA::detector_positions; + + +TCAGRA::TCAGRA(){ + Clear(); +} + +TCAGRA::~TCAGRA() { + +} + +void TCAGRA::Copy(TObject& obj) const { + TDetector::Copy(obj); + + TCAGRA& detector = (TCAGRA&)obj; + detector.cagra_hits = cagra_hits; +} + +void TCAGRA::InsertHit(const TDetectorHit& hit){ + cagra_hits.emplace_back((TCAGRAHit&)hit); + fSize++; +} + +int TCAGRA::BuildHits(std::vector& raw_data){ + for (auto& event : raw_data) { + SetTimestamp(event.GetTimestamp()); + + auto buf = event.GetPayloadBuffer(); + TANLEvent anl(buf); + + unsigned int address = ( (1<<24) + + (anl.GetBoardID() << 8) + + anl.GetChannel() ); + + TChannel* chan = TChannel::GetChannel(address); + + static int lines_displayed = 0; + if(!chan){ + if(lines_displayed < 10) { + std::cout << "Unknown (board id, channel): (" + << anl.GetBoardID() << ", " << anl.GetChannel() + << ")" << std::endl; + } else if(lines_displayed==1000){ + std::cout << "I'm going to stop telling you that the channel was unknown," + << " you should probably stop the program." << std::endl; + } + lines_displayed++; + + continue; + } + + int detnum = chan->GetArrayPosition(); // crystal number + int segnum = chan->GetSegment(); // segment number + + // Get a hit, make it if it does not exist + TCAGRAHit* hit = NULL; + for(auto& ihit : cagra_hits){ + if(ihit.GetDetnum() == detnum){ + hit = &ihit; + break; + } + } + if(hit == NULL){ + cagra_hits.emplace_back(); + hit = &cagra_hits.back(); + fSize++; + } + + if(segnum==0){ + hit->SetAddress(address); + hit->SetTimestamp(anl.GetLED()); + hit->SetCharge(anl.GetEnergy()); + } else { + TCAGRASegmentHit& seg = hit->MakeSegmentByAddress(address); + seg.SetCharge(anl.GetEnergy()); + seg.SetTimestamp(anl.GetLED()); + } + } + + + + //TCAGRAHit hit; + //hit.BuildFrom(buf); + //hit.SetTimestamp(event.GetTimestamp()); + //InsertHit(hit); + return Size(); +} +TVector3 TCAGRA::GetSegmentPosition(int detnum, int segnum) { + if(detnum < 1 || detnum > 16 || + segnum < 1 || segnum > 32){ + return TVector3(std::sqrt(-1),std::sqrt(-1),std::sqrt(-1)); + } + LoadDetectorPositions(); + + int index = detnum*100+segnum; + if (detector_positions.count(index)>0) { + return detector_positions.at(index); + } else { + return TVector3(0.,0.,0.); + } + + // double segment_height = 1.0; + // double perp_distance = 1.5; + + // // Middle of the segment + // double segment_phi = 3.1415926535/4.0; + // double segment_z = segment_height/2.0; + + // double crystal_phi = segment_phi + (segnum-2)*3.1415926/2.0; + // double crystal_z = segment_z + ((segnum-1)/4)*segment_height; + + // TVector3 crystal_pos(1,0,0); + // crystal_pos.SetZ(crystal_z); + // crystal_pos.SetPhi(crystal_phi); + // crystal_pos.SetPerp(perp_distance); + + // TVector3 global_pos = CrystalToGlobal(detnum, crystal_pos); + + + // return global_pos; +} + +void TCAGRA::LoadDetectorPositions() { + static bool loaded = false; + if(loaded){ + return; + } + loaded = true; + + //std::string filename = std::string(getenv("GRUTSYS")) + "/../config/SeGA_rotations.txt"; + std::string filename = std::string(getenv("GRUTSYS")) + "/config/CAGRA_positions.txt"; + + //Read the locations from file. + std::ifstream infile(filename); + + if(!infile){ + std::cout << "CAGRA positions file \"" << filename << "\"" + << " does not exist, skipping" << std::endl; + return; + } + + std::string line; + while (std::getline(infile,line)) { + //Parse the line + int nclover, ncrystal; + double x,y,z; + int extracted = sscanf(line.c_str(),"clover.%02d.%01d.vec: %lf %lf %lf", + &nclover,&ncrystal,&x,&y,&z); + if (extracted!=5) { + continue; + } + + int index = nclover*100 + ncrystal; + + //Pack into the vector of transformations. + TVector3 vec = TVector3(x,y,z); + detector_positions[index] = vec; + } +} + +void TCAGRA::Print(Option_t *opt) const { } + +void TCAGRA::Clear(Option_t *opt) { + cagra_hits.clear(); +} diff --git a/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx b/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx new file mode 100644 index 00000000..979e1ef8 --- /dev/null +++ b/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx @@ -0,0 +1,121 @@ +#include "TCAGRAHit.h" + +#include "TCAGRA.h" + +#include +#include + +#include "TString.h" + +#include "GCanvas.h" +#include "GValue.h" + +#include "TGRUTOptions.h" + +ClassImp(TCAGRAHit) + +TCAGRAHit::TCAGRAHit(){ + +} + +TCAGRAHit::~TCAGRAHit() { + +} +void TCAGRAHit::Copy(TObject& obj) const { + TDetectorHit::Copy(obj); +} +void TCAGRAHit::Print(Option_t *opt) const { +} +void TCAGRAHit::Clear(Option_t *opt) { + TDetectorHit::Clear(opt); +} +bool TCAGRAHit::HasCore() const { + return fCharge != -1; +} + +int TCAGRAHit::GetDetnum() const { + TChannel* chan = TChannel::GetChannel(fAddress); + int output = -1; + if(chan && fAddress!=-1){ + output = chan->GetArrayPosition(); + } else if(fSegments.size()) { + output = fSegments[0].GetDetnum(); + } else { + // std::cout << "Unknown address: " << std::hex << fAddress << std::dec + // << std::endl; + output = -1; + } + + if(output == -1 && chan){ + // std::cout << "Chan with det=-1: " << chan->GetName() << std::endl; + // std::cout << "address: " << fAddress << std::endl; + } + + return output; +} +// int TCAGRAHit::GetCrate() const { +// return (fAddress&0x00ff0000)>>16; +// } + +int TCAGRAHit::GetBoardID() const { + return (fAddress&0x0000ff00)>>8; +} + +int TCAGRAHit::GetChannel() const { + return (fAddress&0x000000ff)>>0; +} + +TCAGRASegmentHit& TCAGRAHit::MakeSegmentByAddress(unsigned int address){ + // for(auto& segment : fSegments){ + // if(segment.Address() == address){ + // return segment; + // } + // } + + fSegments.emplace_back(); + TCAGRASegmentHit& output = fSegments.back(); + output.SetAddress(address); + return output; +} + +int TCAGRAHit::GetMainSegnum() const { + int output = 0; + double max_energy = -9e99; + for(auto& segment : fSegments){ + if(segment.GetEnergy() > max_energy){ + output = segment.GetSegnum(); + max_energy = segment.GetEnergy(); + } + } + return output; +} + +TVector3 TCAGRAHit::GetPosition(bool apply_array_offset) const { + TVector3 array_pos = TCAGRA::GetSegmentPosition(GetDetnum(), GetMainSegnum()); + if(apply_array_offset){ + array_pos += TVector3(GValue::Value("Cagra_X_offset"), + GValue::Value("Cagra_Y_offset"), + GValue::Value("Cagra_Z_offset")); + } + return array_pos; +} + +double TCAGRAHit::GetDoppler(double beta,const TVector3& particle_vec, const TVector3& offset) const { + if(GetNumSegments()<1) { + return std::sqrt(-1); + } + + double gamma = 1/(sqrt(1-pow(beta,2))); + TVector3 pos = GetPosition() + offset; + double cos_angle = TMath::Cos(pos.Angle(particle_vec)); + double dc_en = GetEnergy()*gamma *(1 - beta*cos_angle); + return dc_en; +} + +Int_t TCAGRAHit::Charge() const { + if(fCharge > 30000) { + return fCharge - 32768; + } else { + return fCharge; + } +} diff --git a/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx b/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx new file mode 100644 index 00000000..be852cad --- /dev/null +++ b/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx @@ -0,0 +1,60 @@ +#include "TCAGRASegmentHit.h" + +#include +#include + +void TCAGRASegmentHit::Copy(TObject& obj) const{ + TDetectorHit::Copy(obj); + + TCAGRASegmentHit& cagra = (TCAGRASegmentHit&)obj; +} + +void TCAGRASegmentHit::Clear(Option_t *opt) { + TDetectorHit::Clear(opt); +} + +void TCAGRASegmentHit::Print(Option_t *opt) const { + std::cout << "TCAGRASegmentHit:\n" + << "\tCharge: " << Charge() << "\n" + << std::flush; +} + +int TCAGRASegmentHit::GetDetnum() const { + TChannel* chan = TChannel::GetChannel(fAddress); + if(chan){ + return chan->GetArrayPosition(); + } else { + std::cout << "Unknown address: " << std::hex << fAddress << std::dec + << std::endl; + return -1; + } +} + +int TCAGRASegmentHit::GetSegnum() const { + TChannel* chan = TChannel::GetChannel(fAddress); + if(chan){ + return chan->GetSegment(); + } else { + return -1; + } +} + +// int TCAGRASegmentHit::GetCrate() const { +// return (fAddress&0x00ff0000)>>16; +// } + +int TCAGRASegmentHit::GetBoardID() const { + return (fAddress&0x0000ff00)>>8; +} + +int TCAGRASegmentHit::GetChannel() const { + return (fAddress&0x000000ff)>>0; +} + +Int_t TCAGRASegmentHit::Charge() const { + if(fCharge > 30000) { + return fCharge - 32768; + } else { + return fCharge; + } +} diff --git a/libraries/TLoops/TUnpackedEvent.cxx b/libraries/TLoops/TUnpackedEvent.cxx index 2e31f5ee..3b653cb8 100644 --- a/libraries/TLoops/TUnpackedEvent.cxx +++ b/libraries/TLoops/TUnpackedEvent.cxx @@ -14,7 +14,7 @@ #include "TS800Scaler.h" #include "TSega.h" #include "TFastScint.h" -#include "TArgonne.h" +#include "TCAGRA.h" #include "TGrandRaiden.h" TUnpackedEvent::TUnpackedEvent() { } @@ -80,7 +80,7 @@ void TUnpackedEvent::Build() { break; case kDetectorSystems::ANL: - GetDetector(true)->Build(raw_data); + GetDetector(true)->Build(raw_data); break; case kDetectorSystems::GRAND_RAIDEN: diff --git a/util/generate_positions_cagra.py b/util/generate_positions_cagra.py new file mode 100644 index 00000000..e62dc4c1 --- /dev/null +++ b/util/generate_positions_cagra.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python + +import numpy as np +from ROOT import TVector3 +from ROOT import TRotation + +class CloverType: + Yale, Tohoku, IMP = range(3) + +class clover(object): + def __init__(self,r,theta,phi,clovertype=CloverType.Yale): + self.xdispl = 0 + self.ydispl = 0 + self.placement = TVector3(1.,1.,1.) + self.placement.SetMag(r) + self.placement.SetTheta(theta*np.pi/180) + self.placement.SetPhi(phi*np.pi/180) + self.type = clovertype + + if clovertype == CloverType.Yale: + self.xdispl = self.ydispl = 2.23 + if clovertype == CloverType.Tohoku: + self.xdispl = self.ydispl = 2.23 + if clovertype == CloverType.IMP: + self.xdispl = self.ydispl = 2.23 + + def print_clover_placement(self,idxclover): + print("clover.{0:02d}.vec: ".format(idxclover) + str(np.around(self.placement.X(),10)) + " " + str(np.around(self.placement.Y(),10)) + " " + str(np.around(self.placement.Z(),10))) + def print_clover_placement_sph(self,idxclover): + print("clover.{0:02d}.vec_sph: ".format(idxclover) + str(np.around(self.placement.Mag(),10)) + " " + str(np.around(self.placement.Theta()*180/np.pi,10)) + " " + str(np.around(self.placement.Phi()*180/np.pi,10))) + def print_crystal_placement(self,idxclover): + for k,(xsign,ysign) in enumerate([(-1,+1),(+1,+1),(-1,-1),(+1,-1)]): + theta_rotation = TRotation() + phi_rotation = TRotation() + theta_rotation.RotateY(self.placement.Theta()) + phi_rotation.RotateZ(self.placement.Phi()) + crystal_offset = TVector3(xsign*self.xdispl,ysign*self.ydispl,0) + crystal_offset = phi_rotation*theta_rotation*crystal_offset + crystal = TVector3(self.placement.X()+crystal_offset.X(),self.placement.Y()+crystal_offset.Y(),self.placement.Z()+crystal_offset.Z()) + print("clover.{0:02d}.{1}.vec: ".format(idxclover,k+1) + str(np.around(crystal.X(),10)) + " " + str(np.around(crystal.Y(),10)) + " " + str(np.around(crystal.Z(),10))) + print("") + + def print_crystal_placement_sph(self,idxclover): + for k,(xsign,ysign) in enumerate([(-1,+1),(+1,+1),(-1,-1),(+1,-1)]): + theta_rotation = TRotation() + phi_rotation = TRotation() + theta_rotation.RotateY(self.placement.Theta()) + phi_rotation.RotateZ(self.placement.Phi()) + crystal_offset = TVector3(xsign*self.xdispl,ysign*self.ydispl,0) + crystal_offset = phi_rotation*theta_rotation*crystal_offset + crystal = TVector3(self.placement.X()+crystal_offset.X(),self.placement.Y()+crystal_offset.Y(),self.placement.Z()+crystal_offset.Z()) + print("clover.{0:02d}.{1}.vec_sph: ".format(idxclover,k+1) + str(np.around(crystal.Mag(),10)) + " " + str(np.around(crystal.Theta()*180/np.pi,10)) + " " + str(np.around(crystal.Phi()*180/np.pi,10))) + print("") + + + def set_placement(self, _placement): + self.placement = _placement + +if __name__=='__main__': + + # 45 degree detectors (Tohoku) + for i in range(0,4): + r = 17.70 + theta = 45.0 + phi = 45+90.0*i + if phi > 180: + phi -= 360 + placed = clover(r,theta,phi,CloverType.Yale) + #placed.print_clover_placement_sph(i+1) + #placed.print_clover_placement(i+1) + placed.print_crystal_placement(i+1) + #placed.print_crystal_placement_sph(i+1) + + + # 90 degree detectors (yale) + for i in range(0,8): + r = 17.70 + theta = 90.0 + phi = 45*i + placed = clover(r,theta,phi,CloverType.Yale) + #placed.print_clover_placement_sph(i+4+1) + #placed.print_clover_placement(i+4+1) + placed.print_crystal_placement(i+4+1) + #placed.print_crystal_placement_sph(i+4+1) + + # 135 degree detectors (Tohoku) + for i in range(0,4): + r = 17.70 + theta = 135.0 + phi = 45+90.0*i + if phi > 180: + phi -= 360 + placed = clover(r,theta,phi,CloverType.Yale) + #placed.print_clover_placement_sph(i+12+1) + #placed.print_clover_placement(i+12+1) + placed.print_crystal_placement(i+12+1) + #placed.print_crystal_placement_sph(i+12+1) From 316f812ccd974418e58a72ec4f1533024313b59c Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 27 May 2016 16:28:01 -0400 Subject: [PATCH 22/94] Updated channel map file to include crystals _and_ segments. The positions now seem to be working. Each clover detector gets a number from 01 - 16, and each clover has A,B,C,D leaf crystals. Each crystal can have segments or not. The naming scheme works as follows: CLO01AP00 this indicates the system is CLO short for Clover. The next number 01 indicates this is clover 01. A indicates the crystal number (should be the crystal leaf at smaller theta). P indicates that the signal is positive and 00 means that this is the 0th segment (ie the central contact). Some detectors will have multiple segments in which case this last number will be 01 or 02. The address is currently made from the BoardID and Channel number. So Board 113 (0x71) and channel 01 would be address 0x01007101. The first 01 is just for historical reasons, and indicates the subsystem number. --- config/CAGRA_positions.txt | 286 +++++++++++++----- histos/MakeANLHistos.cxx | 10 +- include/TCAGRA.h | 2 +- include/TCAGRAHit.h | 3 +- include/TCAGRASegmentHit.h | 1 + libraries/TDetSystems/TArgonne/TCAGRA.cxx | 27 +- libraries/TDetSystems/TArgonne/TCAGRAHit.cxx | 22 +- .../TDetSystems/TArgonne/TCAGRASegmentHit.cxx | 10 + util/generate_positions_cagra.py | 116 +++++-- 9 files changed, 353 insertions(+), 124 deletions(-) diff --git a/config/CAGRA_positions.txt b/config/CAGRA_positions.txt index 8599d2bf..f504e1f8 100644 --- a/config/CAGRA_positions.txt +++ b/config/CAGRA_positions.txt @@ -1,80 +1,208 @@ -clover.01.1.vec: 6.158151878 9.311848122 14.092638149 -clover.01.2.vec: 8.388151878 11.541848122 10.938941905 -clover.01.3.vec: 9.311848122 6.158151878 14.092638149 -clover.01.4.vec: 11.541848122 8.388151878 10.938941905 - -clover.02.1.vec: -9.311848122 6.158151878 14.092638149 -clover.02.2.vec: -11.541848122 8.388151878 10.938941905 -clover.02.3.vec: -6.158151878 9.311848122 14.092638149 -clover.02.4.vec: -8.388151878 11.541848122 10.938941905 - -clover.03.1.vec: -6.158151878 -9.311848122 14.092638149 -clover.03.2.vec: -8.388151878 -11.541848122 10.938941905 -clover.03.3.vec: -9.311848122 -6.158151878 14.092638149 -clover.03.4.vec: -11.541848122 -8.388151878 10.938941905 - -clover.04.1.vec: 9.311848122 -6.158151878 14.092638149 -clover.04.2.vec: 11.541848122 -8.388151878 10.938941905 -clover.04.3.vec: 6.158151878 -9.311848122 14.092638149 -clover.04.4.vec: 8.388151878 -11.541848122 10.938941905 - -clover.05.1.vec: 17.7 2.23 2.23 -clover.05.2.vec: 17.7 2.23 -2.23 -clover.05.3.vec: 17.7 -2.23 2.23 -clover.05.4.vec: 17.7 -2.23 -2.23 - -clover.06.1.vec: 10.938941905 14.092638149 2.23 -clover.06.2.vec: 10.938941905 14.092638149 -2.23 -clover.06.3.vec: 14.092638149 10.938941905 2.23 -clover.06.4.vec: 14.092638149 10.938941905 -2.23 - -clover.07.1.vec: -2.23 17.7 2.23 -clover.07.2.vec: -2.23 17.7 -2.23 -clover.07.3.vec: 2.23 17.7 2.23 -clover.07.4.vec: 2.23 17.7 -2.23 - -clover.08.1.vec: -14.092638149 10.938941905 2.23 -clover.08.2.vec: -14.092638149 10.938941905 -2.23 -clover.08.3.vec: -10.938941905 14.092638149 2.23 -clover.08.4.vec: -10.938941905 14.092638149 -2.23 - -clover.09.1.vec: -17.7 -2.23 2.23 -clover.09.2.vec: -17.7 -2.23 -2.23 -clover.09.3.vec: -17.7 2.23 2.23 -clover.09.4.vec: -17.7 2.23 -2.23 - -clover.10.1.vec: -10.938941905 -14.092638149 2.23 -clover.10.2.vec: -10.938941905 -14.092638149 -2.23 -clover.10.3.vec: -14.092638149 -10.938941905 2.23 -clover.10.4.vec: -14.092638149 -10.938941905 -2.23 - -clover.11.1.vec: 2.23 -17.7 2.23 -clover.11.2.vec: 2.23 -17.7 -2.23 -clover.11.3.vec: -2.23 -17.7 2.23 -clover.11.4.vec: -2.23 -17.7 -2.23 - -clover.12.1.vec: 14.092638149 -10.938941905 2.23 -clover.12.2.vec: 14.092638149 -10.938941905 -2.23 -clover.12.3.vec: 10.938941905 -14.092638149 2.23 -clover.12.4.vec: 10.938941905 -14.092638149 -2.23 - -clover.13.1.vec: 8.388151878 11.541848122 -10.938941905 -clover.13.2.vec: 6.158151878 9.311848122 -14.092638149 -clover.13.3.vec: 11.541848122 8.388151878 -10.938941905 -clover.13.4.vec: 9.311848122 6.158151878 -14.092638149 - -clover.14.1.vec: -11.541848122 8.388151878 -10.938941905 -clover.14.2.vec: -9.311848122 6.158151878 -14.092638149 -clover.14.3.vec: -8.388151878 11.541848122 -10.938941905 -clover.14.4.vec: -6.158151878 9.311848122 -14.092638149 - -clover.15.1.vec: -8.388151878 -11.541848122 -10.938941905 -clover.15.2.vec: -6.158151878 -9.311848122 -14.092638149 -clover.15.3.vec: -11.541848122 -8.388151878 -10.938941905 -clover.15.4.vec: -9.311848122 -6.158151878 -14.092638149 - -clover.16.1.vec: 11.541848122 -8.388151878 -10.938941905 -clover.16.2.vec: 9.311848122 -6.158151878 -14.092638149 -clover.16.3.vec: 8.388151878 -11.541848122 -10.938941905 -clover.16.4.vec: 6.158151878 -9.311848122 -14.092638149 +clover.01.A.0.vec: 6.408151878 9.561848122 14.4461915396 +clover.01.A.1.vec: 5.877635401 9.0313316451 15.1964551364 +clover.01.A.2.vec: 6.9386683549 10.092364599 13.6959279428 +clover.01.B.0.vec: 8.638151878 11.791848122 11.2924952955 +clover.01.B.1.vec: 8.107635401 11.2613316451 12.0427588923 +clover.01.B.2.vec: 9.1686683549 12.322364599 10.5422316988 +clover.01.C.0.vec: 9.561848122 6.408151878 14.4461915396 +clover.01.C.1.vec: 9.0313316451 5.877635401 15.1964551364 +clover.01.C.2.vec: 10.092364599 6.9386683549 13.6959279428 +clover.01.D.0.vec: 11.791848122 8.638151878 11.2924952955 +clover.01.D.1.vec: 11.2613316451 8.107635401 12.0427588923 +clover.01.D.2.vec: 12.322364599 9.1686683549 10.5422316988 + +clover.02.A.0.vec: -9.561848122 6.408151878 14.4461915396 +clover.02.A.1.vec: -9.0313316451 5.877635401 15.1964551364 +clover.02.A.2.vec: -10.092364599 6.9386683549 13.6959279428 +clover.02.B.0.vec: -11.791848122 8.638151878 11.2924952955 +clover.02.B.1.vec: -11.2613316451 8.107635401 12.0427588923 +clover.02.B.2.vec: -12.322364599 9.1686683549 10.5422316988 +clover.02.C.0.vec: -6.408151878 9.561848122 14.4461915396 +clover.02.C.1.vec: -5.877635401 9.0313316451 15.1964551364 +clover.02.C.2.vec: -6.9386683549 10.092364599 13.6959279428 +clover.02.D.0.vec: -8.638151878 11.791848122 11.2924952955 +clover.02.D.1.vec: -8.107635401 11.2613316451 12.0427588923 +clover.02.D.2.vec: -9.1686683549 12.322364599 10.5422316988 + +clover.03.A.0.vec: -6.408151878 -9.561848122 14.4461915396 +clover.03.A.1.vec: -5.877635401 -9.0313316451 15.1964551364 +clover.03.A.2.vec: -6.9386683549 -10.092364599 13.6959279428 +clover.03.B.0.vec: -8.638151878 -11.791848122 11.2924952955 +clover.03.B.1.vec: -8.107635401 -11.2613316451 12.0427588923 +clover.03.B.2.vec: -9.1686683549 -12.322364599 10.5422316988 +clover.03.C.0.vec: -9.561848122 -6.408151878 14.4461915396 +clover.03.C.1.vec: -9.0313316451 -5.877635401 15.1964551364 +clover.03.C.2.vec: -10.092364599 -6.9386683549 13.6959279428 +clover.03.D.0.vec: -11.791848122 -8.638151878 11.2924952955 +clover.03.D.1.vec: -11.2613316451 -8.107635401 12.0427588923 +clover.03.D.2.vec: -12.322364599 -9.1686683549 10.5422316988 + +clover.04.A.0.vec: 9.561848122 -6.408151878 14.4461915396 +clover.04.A.1.vec: 9.0313316451 -5.877635401 15.1964551364 +clover.04.A.2.vec: 10.092364599 -6.9386683549 13.6959279428 +clover.04.B.0.vec: 11.791848122 -8.638151878 11.2924952955 +clover.04.B.1.vec: 11.2613316451 -8.107635401 12.0427588923 +clover.04.B.2.vec: 12.322364599 -9.1686683549 10.5422316988 +clover.04.C.0.vec: 6.408151878 -9.561848122 14.4461915396 +clover.04.C.1.vec: 5.877635401 -9.0313316451 15.1964551364 +clover.04.C.2.vec: 6.9386683549 -10.092364599 13.6959279428 +clover.04.D.0.vec: 8.638151878 -11.791848122 11.2924952955 +clover.04.D.1.vec: 8.107635401 -11.2613316451 12.0427588923 +clover.04.D.2.vec: 9.1686683549 -12.322364599 10.5422316988 + +clover.05.A.0.vec: 18.2 2.23 2.23 +clover.05.A.1.vec: 18.2 2.23 3.2910329539 +clover.05.A.2.vec: 18.2 2.23 1.1689670461 +clover.05.B.0.vec: 18.2 2.23 -2.23 +clover.05.B.1.vec: 18.2 2.23 -1.1689670461 +clover.05.B.2.vec: 18.2 2.23 -3.2910329539 +clover.05.C.0.vec: 18.2 -2.23 2.23 +clover.05.C.1.vec: 18.2 -2.23 3.2910329539 +clover.05.C.2.vec: 18.2 -2.23 1.1689670461 +clover.05.D.0.vec: 18.2 -2.23 -2.23 +clover.05.D.1.vec: 18.2 -2.23 -1.1689670461 +clover.05.D.2.vec: 18.2 -2.23 -3.2910329539 + +clover.06.A.0.vec: 11.2924952955 14.4461915396 2.23 +clover.06.A.1.vec: 11.2924952955 14.4461915396 3.2910329539 +clover.06.A.2.vec: 11.2924952955 14.4461915396 1.1689670461 +clover.06.B.0.vec: 11.2924952955 14.4461915396 -2.23 +clover.06.B.1.vec: 11.2924952955 14.4461915396 -1.1689670461 +clover.06.B.2.vec: 11.2924952955 14.4461915396 -3.2910329539 +clover.06.C.0.vec: 14.4461915396 11.2924952955 2.23 +clover.06.C.1.vec: 14.4461915396 11.2924952955 3.2910329539 +clover.06.C.2.vec: 14.4461915396 11.2924952955 1.1689670461 +clover.06.D.0.vec: 14.4461915396 11.2924952955 -2.23 +clover.06.D.1.vec: 14.4461915396 11.2924952955 -1.1689670461 +clover.06.D.2.vec: 14.4461915396 11.2924952955 -3.2910329539 + +clover.07.A.0.vec: -2.23 18.2 2.23 +clover.07.A.1.vec: -2.23 18.2 3.2910329539 +clover.07.A.2.vec: -2.23 18.2 1.1689670461 +clover.07.B.0.vec: -2.23 18.2 -2.23 +clover.07.B.1.vec: -2.23 18.2 -1.1689670461 +clover.07.B.2.vec: -2.23 18.2 -3.2910329539 +clover.07.C.0.vec: 2.23 18.2 2.23 +clover.07.C.1.vec: 2.23 18.2 3.2910329539 +clover.07.C.2.vec: 2.23 18.2 1.1689670461 +clover.07.D.0.vec: 2.23 18.2 -2.23 +clover.07.D.1.vec: 2.23 18.2 -1.1689670461 +clover.07.D.2.vec: 2.23 18.2 -3.2910329539 + +clover.08.A.0.vec: -14.4461915396 11.2924952955 2.23 +clover.08.A.1.vec: -14.4461915396 11.2924952955 3.2910329539 +clover.08.A.2.vec: -14.4461915396 11.2924952955 1.1689670461 +clover.08.B.0.vec: -14.4461915396 11.2924952955 -2.23 +clover.08.B.1.vec: -14.4461915396 11.2924952955 -1.1689670461 +clover.08.B.2.vec: -14.4461915396 11.2924952955 -3.2910329539 +clover.08.C.0.vec: -11.2924952955 14.4461915396 2.23 +clover.08.C.1.vec: -11.2924952955 14.4461915396 3.2910329539 +clover.08.C.2.vec: -11.2924952955 14.4461915396 1.1689670461 +clover.08.D.0.vec: -11.2924952955 14.4461915396 -2.23 +clover.08.D.1.vec: -11.2924952955 14.4461915396 -1.1689670461 +clover.08.D.2.vec: -11.2924952955 14.4461915396 -3.2910329539 + +clover.09.A.0.vec: -18.2 -2.23 2.23 +clover.09.A.1.vec: -18.2 -2.23 3.2910329539 +clover.09.A.2.vec: -18.2 -2.23 1.1689670461 +clover.09.B.0.vec: -18.2 -2.23 -2.23 +clover.09.B.1.vec: -18.2 -2.23 -1.1689670461 +clover.09.B.2.vec: -18.2 -2.23 -3.2910329539 +clover.09.C.0.vec: -18.2 2.23 2.23 +clover.09.C.1.vec: -18.2 2.23 3.2910329539 +clover.09.C.2.vec: -18.2 2.23 1.1689670461 +clover.09.D.0.vec: -18.2 2.23 -2.23 +clover.09.D.1.vec: -18.2 2.23 -1.1689670461 +clover.09.D.2.vec: -18.2 2.23 -3.2910329539 + +clover.10.A.0.vec: -11.2924952955 -14.4461915396 2.23 +clover.10.A.1.vec: -11.2924952955 -14.4461915396 3.2910329539 +clover.10.A.2.vec: -11.2924952955 -14.4461915396 1.1689670461 +clover.10.B.0.vec: -11.2924952955 -14.4461915396 -2.23 +clover.10.B.1.vec: -11.2924952955 -14.4461915396 -1.1689670461 +clover.10.B.2.vec: -11.2924952955 -14.4461915396 -3.2910329539 +clover.10.C.0.vec: -14.4461915396 -11.2924952955 2.23 +clover.10.C.1.vec: -14.4461915396 -11.2924952955 3.2910329539 +clover.10.C.2.vec: -14.4461915396 -11.2924952955 1.1689670461 +clover.10.D.0.vec: -14.4461915396 -11.2924952955 -2.23 +clover.10.D.1.vec: -14.4461915396 -11.2924952955 -1.1689670461 +clover.10.D.2.vec: -14.4461915396 -11.2924952955 -3.2910329539 + +clover.11.A.0.vec: 2.23 -18.2 2.23 +clover.11.A.1.vec: 2.23 -18.2 3.2910329539 +clover.11.A.2.vec: 2.23 -18.2 1.1689670461 +clover.11.B.0.vec: 2.23 -18.2 -2.23 +clover.11.B.1.vec: 2.23 -18.2 -1.1689670461 +clover.11.B.2.vec: 2.23 -18.2 -3.2910329539 +clover.11.C.0.vec: -2.23 -18.2 2.23 +clover.11.C.1.vec: -2.23 -18.2 3.2910329539 +clover.11.C.2.vec: -2.23 -18.2 1.1689670461 +clover.11.D.0.vec: -2.23 -18.2 -2.23 +clover.11.D.1.vec: -2.23 -18.2 -1.1689670461 +clover.11.D.2.vec: -2.23 -18.2 -3.2910329539 + +clover.12.A.0.vec: 14.4461915396 -11.2924952955 2.23 +clover.12.A.1.vec: 14.4461915396 -11.2924952955 3.2910329539 +clover.12.A.2.vec: 14.4461915396 -11.2924952955 1.1689670461 +clover.12.B.0.vec: 14.4461915396 -11.2924952955 -2.23 +clover.12.B.1.vec: 14.4461915396 -11.2924952955 -1.1689670461 +clover.12.B.2.vec: 14.4461915396 -11.2924952955 -3.2910329539 +clover.12.C.0.vec: 11.2924952955 -14.4461915396 2.23 +clover.12.C.1.vec: 11.2924952955 -14.4461915396 3.2910329539 +clover.12.C.2.vec: 11.2924952955 -14.4461915396 1.1689670461 +clover.12.D.0.vec: 11.2924952955 -14.4461915396 -2.23 +clover.12.D.1.vec: 11.2924952955 -14.4461915396 -1.1689670461 +clover.12.D.2.vec: 11.2924952955 -14.4461915396 -3.2910329539 + +clover.13.A.0.vec: 8.638151878 11.791848122 -11.2924952955 +clover.13.A.1.vec: 9.1686683549 12.322364599 -10.5422316988 +clover.13.A.2.vec: 8.107635401 11.2613316451 -12.0427588923 +clover.13.B.0.vec: 6.408151878 9.561848122 -14.4461915396 +clover.13.B.1.vec: 6.9386683549 10.092364599 -13.6959279428 +clover.13.B.2.vec: 5.877635401 9.0313316451 -15.1964551364 +clover.13.C.0.vec: 11.791848122 8.638151878 -11.2924952955 +clover.13.C.1.vec: 12.322364599 9.1686683549 -10.5422316988 +clover.13.C.2.vec: 11.2613316451 8.107635401 -12.0427588923 +clover.13.D.0.vec: 9.561848122 6.408151878 -14.4461915396 +clover.13.D.1.vec: 10.092364599 6.9386683549 -13.6959279428 +clover.13.D.2.vec: 9.0313316451 5.877635401 -15.1964551364 + +clover.14.A.0.vec: -11.791848122 8.638151878 -11.2924952955 +clover.14.A.1.vec: -12.322364599 9.1686683549 -10.5422316988 +clover.14.A.2.vec: -11.2613316451 8.107635401 -12.0427588923 +clover.14.B.0.vec: -9.561848122 6.408151878 -14.4461915396 +clover.14.B.1.vec: -10.092364599 6.9386683549 -13.6959279428 +clover.14.B.2.vec: -9.0313316451 5.877635401 -15.1964551364 +clover.14.C.0.vec: -8.638151878 11.791848122 -11.2924952955 +clover.14.C.1.vec: -9.1686683549 12.322364599 -10.5422316988 +clover.14.C.2.vec: -8.107635401 11.2613316451 -12.0427588923 +clover.14.D.0.vec: -6.408151878 9.561848122 -14.4461915396 +clover.14.D.1.vec: -6.9386683549 10.092364599 -13.6959279428 +clover.14.D.2.vec: -5.877635401 9.0313316451 -15.1964551364 + +clover.15.A.0.vec: -8.638151878 -11.791848122 -11.2924952955 +clover.15.A.1.vec: -9.1686683549 -12.322364599 -10.5422316988 +clover.15.A.2.vec: -8.107635401 -11.2613316451 -12.0427588923 +clover.15.B.0.vec: -6.408151878 -9.561848122 -14.4461915396 +clover.15.B.1.vec: -6.9386683549 -10.092364599 -13.6959279428 +clover.15.B.2.vec: -5.877635401 -9.0313316451 -15.1964551364 +clover.15.C.0.vec: -11.791848122 -8.638151878 -11.2924952955 +clover.15.C.1.vec: -12.322364599 -9.1686683549 -10.5422316988 +clover.15.C.2.vec: -11.2613316451 -8.107635401 -12.0427588923 +clover.15.D.0.vec: -9.561848122 -6.408151878 -14.4461915396 +clover.15.D.1.vec: -10.092364599 -6.9386683549 -13.6959279428 +clover.15.D.2.vec: -9.0313316451 -5.877635401 -15.1964551364 + +clover.16.A.0.vec: 11.791848122 -8.638151878 -11.2924952955 +clover.16.A.1.vec: 12.322364599 -9.1686683549 -10.5422316988 +clover.16.A.2.vec: 11.2613316451 -8.107635401 -12.0427588923 +clover.16.B.0.vec: 9.561848122 -6.408151878 -14.4461915396 +clover.16.B.1.vec: 10.092364599 -6.9386683549 -13.6959279428 +clover.16.B.2.vec: 9.0313316451 -5.877635401 -15.1964551364 +clover.16.C.0.vec: 8.638151878 -11.791848122 -11.2924952955 +clover.16.C.1.vec: 9.1686683549 -12.322364599 -10.5422316988 +clover.16.C.2.vec: 8.107635401 -11.2613316451 -12.0427588923 +clover.16.D.0.vec: 6.408151878 -9.561848122 -14.4461915396 +clover.16.D.1.vec: 6.9386683549 -10.092364599 -13.6959279428 +clover.16.D.2.vec: 5.877635401 -9.0313316451 -15.1964551364 diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index cc2728f0..3c737a5f 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -42,7 +42,7 @@ void MakeHistograms(TRuntimeObjects& obj) { for(int y=0;ySize();y++) { - TCAGRAHit hit = cagra->GetCAGRAHit(y); + //auto hit = cagra->GetCAGRAHit(y); @@ -66,6 +66,14 @@ void MakeHistograms(TRuntimeObjects& obj) { for (auto& hit : *cagra) { if (hit.GetBoardID() == 0x71) { + /* + cout << "Clover: " << hit.GetDetnum() + << " Leaf: " << hit.GetLeaf() + << " Segment: " << hit.GetMainSegnum() + << " Theta: "<< hit.GetPosition().Theta()*180/TMath::Pi() + << endl; + */ + //hit.GetPosition().Print(); stream.str(""); stream << "Crystal" << hit.GetChannel(); obj.FillHistogram(stream.str(),10000,0,20000,hit.Charge()); diff --git a/include/TCAGRA.h b/include/TCAGRA.h index 4476f4a5..0b2ed344 100644 --- a/include/TCAGRA.h +++ b/include/TCAGRA.h @@ -25,7 +25,7 @@ class TCAGRA : public TDetector { const TCAGRAHit& GetCAGRAHit(int i) { return cagra_hits.at(i); } void PrintHit(int i){ cagra_hits.at(i).Print(); } - static TVector3 GetSegmentPosition(int detnum, int segnum); + static TVector3 GetSegmentPosition(int detnum, char subpos, int segnum); // Allows for looping over all hits with for(auto& hit : cagra) { } std::vector::iterator begin() { return cagra_hits.begin(); } std::vector::iterator end() { return cagra_hits.end(); } diff --git a/include/TCAGRAHit.h b/include/TCAGRAHit.h index ce0ae685..a6c0e4df 100644 --- a/include/TCAGRAHit.h +++ b/include/TCAGRAHit.h @@ -17,6 +17,7 @@ class TCAGRAHit : public TDetectorHit { virtual Int_t Charge() const; int GetDetnum() const; + char GetLeaf() const; int GetMainSegnum() const; bool HasCore() const; @@ -36,7 +37,7 @@ class TCAGRAHit : public TDetectorHit { int GetBoardID() const; int GetChannel() const; - TVector3 GetPosition(bool apply_array_offset = false) const; + TVector3 GetPosition(bool apply_array_offset = false) const; // modified from true double GetDoppler(double beta, const TVector3& particle_vec = TVector3(0,0,1), diff --git a/include/TCAGRASegmentHit.h b/include/TCAGRASegmentHit.h index 183c541e..f1a17154 100644 --- a/include/TCAGRASegmentHit.h +++ b/include/TCAGRASegmentHit.h @@ -14,6 +14,7 @@ class TCAGRASegmentHit : public TDetectorHit { virtual Int_t Charge() const; int GetDetnum() const; + char GetLeaf() const; int GetSegnum() const; int GetBoardID() const; diff --git a/libraries/TDetSystems/TArgonne/TCAGRA.cxx b/libraries/TDetSystems/TArgonne/TCAGRA.cxx index 13a4fb4c..78778958 100644 --- a/libraries/TDetSystems/TArgonne/TCAGRA.cxx +++ b/libraries/TDetSystems/TArgonne/TCAGRA.cxx @@ -60,7 +60,7 @@ int TCAGRA::BuildHits(std::vector& raw_data){ continue; } - int detnum = chan->GetArrayPosition(); // crystal number + int detnum = chan->GetArrayPosition(); // clover number int segnum = chan->GetSegment(); // segment number // Get a hit, make it if it does not exist @@ -79,12 +79,12 @@ int TCAGRA::BuildHits(std::vector& raw_data){ if(segnum==0){ hit->SetAddress(address); - hit->SetTimestamp(anl.GetLED()); + hit->SetTimestamp(event.GetTimestamp()); hit->SetCharge(anl.GetEnergy()); } else { TCAGRASegmentHit& seg = hit->MakeSegmentByAddress(address); seg.SetCharge(anl.GetEnergy()); - seg.SetTimestamp(anl.GetLED()); + seg.SetTimestamp(event.GetTimestamp()); } } @@ -96,14 +96,15 @@ int TCAGRA::BuildHits(std::vector& raw_data){ //InsertHit(hit); return Size(); } -TVector3 TCAGRA::GetSegmentPosition(int detnum, int segnum) { - if(detnum < 1 || detnum > 16 || - segnum < 1 || segnum > 32){ +TVector3 TCAGRA::GetSegmentPosition(int detnum, char subpos, int segnum) { + if(detnum < 1 || detnum > 16 || segnum < 0 || segnum > 2 || + subpos < 0x41 || subpos > 0x44){ return TVector3(std::sqrt(-1),std::sqrt(-1),std::sqrt(-1)); } LoadDetectorPositions(); - int index = detnum*100+segnum; + int index = (detnum << 16) + (((int)subpos) << 8) + segnum; + if (detector_positions.count(index)>0) { return detector_positions.at(index); } else { @@ -153,15 +154,17 @@ void TCAGRA::LoadDetectorPositions() { std::string line; while (std::getline(infile,line)) { //Parse the line - int nclover, ncrystal; + int nclover, nsegment; + char ncrystal; double x,y,z; - int extracted = sscanf(line.c_str(),"clover.%02d.%01d.vec: %lf %lf %lf", - &nclover,&ncrystal,&x,&y,&z); - if (extracted!=5) { + int extracted = sscanf(line.c_str(),"clover.%02d.%c.%01d.vec: %lf %lf %lf", + &nclover,&ncrystal,&nsegment,&x,&y,&z); + if (extracted!=6) { continue; } - int index = nclover*100 + ncrystal; + int index = (nclover << 16) + (((int)ncrystal) << 8) + nsegment; + //Pack into the vector of transformations. TVector3 vec = TVector3(x,y,z); diff --git a/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx b/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx index 979e1ef8..65667e58 100644 --- a/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx @@ -53,6 +53,26 @@ int TCAGRAHit::GetDetnum() const { return output; } +char TCAGRAHit::GetLeaf() const { + TChannel* chan = TChannel::GetChannel(fAddress); + char output = (char)-1; + if(chan && fAddress!=-1){ + output = *chan->GetArraySubposition(); + } else if(fSegments.size()) { + output = fSegments[0].GetLeaf(); + } else { + // std::cout << "Unknown address: " << std::hex << fAddress << std::dec + // << std::endl; + output = (char)-1; + } + + if(output == -1 && chan){ + // std::cout << "Chan with det=-1: " << chan->GetName() << std::endl; + // std::cout << "address: " << fAddress << std::endl; + } + + return output; +} // int TCAGRAHit::GetCrate() const { // return (fAddress&0x00ff0000)>>16; // } @@ -91,7 +111,7 @@ int TCAGRAHit::GetMainSegnum() const { } TVector3 TCAGRAHit::GetPosition(bool apply_array_offset) const { - TVector3 array_pos = TCAGRA::GetSegmentPosition(GetDetnum(), GetMainSegnum()); + TVector3 array_pos = TCAGRA::GetSegmentPosition(GetDetnum(), GetLeaf(), GetMainSegnum()); if(apply_array_offset){ array_pos += TVector3(GValue::Value("Cagra_X_offset"), GValue::Value("Cagra_Y_offset"), diff --git a/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx b/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx index be852cad..8ab3ea0e 100644 --- a/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx @@ -29,6 +29,16 @@ int TCAGRASegmentHit::GetDetnum() const { return -1; } } +char TCAGRASegmentHit::GetLeaf() const { + TChannel* chan = TChannel::GetChannel(fAddress); + if(chan){ + return *chan->GetArraySubposition(); + } else { + std::cout << "Unknown address: " << std::hex << fAddress << std::dec + << std::endl; + return (char)-1; + } +} int TCAGRASegmentHit::GetSegnum() const { TChannel* chan = TChannel::GetChannel(fAddress); diff --git a/util/generate_positions_cagra.py b/util/generate_positions_cagra.py index e62dc4c1..326dcb0c 100644 --- a/util/generate_positions_cagra.py +++ b/util/generate_positions_cagra.py @@ -19,37 +19,92 @@ def __init__(self,r,theta,phi,clovertype=CloverType.Yale): if clovertype == CloverType.Yale: self.xdispl = self.ydispl = 2.23 + self.covergap = 0.5 #cm + rcrystal = 2.5 #cm + self.segdispl = 4*rcrystal/(3*np.pi) if clovertype == CloverType.Tohoku: self.xdispl = self.ydispl = 2.23 + self.covergap = 0.5 #cm + rcrystal = 2.5 #cm + self.segdispl = 4*rcrystal/(3*np.pi) if clovertype == CloverType.IMP: self.xdispl = self.ydispl = 2.23 + self.covergap = 0.5 #cm + rcrystal = 2.5 #cm + self.segdispl = 4*rcrystal/(3*np.pi) - def print_clover_placement(self,idxclover): - print("clover.{0:02d}.vec: ".format(idxclover) + str(np.around(self.placement.X(),10)) + " " + str(np.around(self.placement.Y(),10)) + " " + str(np.around(self.placement.Z(),10))) - def print_clover_placement_sph(self,idxclover): - print("clover.{0:02d}.vec_sph: ".format(idxclover) + str(np.around(self.placement.Mag(),10)) + " " + str(np.around(self.placement.Theta()*180/np.pi,10)) + " " + str(np.around(self.placement.Phi()*180/np.pi,10))) - def print_crystal_placement(self,idxclover): + def print_clover_placement(self,idxclover,coord=None): + if coord == "Spherical": + print("clover.{0:02d}.vec_sph: ".format(idxclover) + + str(np.around(self.placement.Mag(),10)) + " " + + str(np.around(self.placement.Theta()*180/np.pi,10)) + " " + + str(np.around(self.placement.Phi()*180/np.pi,10))) + else: + print("clover.{0:02d}.vec: ".format(idxclover) + + str(np.around(self.placement.X(),10)) + " " + + str(np.around(self.placement.Y(),10)) + " " + + str(np.around(self.placement.Z(),10))) + + def print_crystal_placement(self,idxclover,coord=None): + theta_rotation = TRotation() + phi_rotation = TRotation() + theta_rotation.RotateY(self.placement.Theta()) + phi_rotation.RotateZ(self.placement.Phi()) for k,(xsign,ysign) in enumerate([(-1,+1),(+1,+1),(-1,-1),(+1,-1)]): - theta_rotation = TRotation() - phi_rotation = TRotation() - theta_rotation.RotateY(self.placement.Theta()) - phi_rotation.RotateZ(self.placement.Phi()) - crystal_offset = TVector3(xsign*self.xdispl,ysign*self.ydispl,0) + crystal_offset = TVector3(xsign*self.xdispl,ysign*self.ydispl,self.covergap) crystal_offset = phi_rotation*theta_rotation*crystal_offset - crystal = TVector3(self.placement.X()+crystal_offset.X(),self.placement.Y()+crystal_offset.Y(),self.placement.Z()+crystal_offset.Z()) - print("clover.{0:02d}.{1}.vec: ".format(idxclover,k+1) + str(np.around(crystal.X(),10)) + " " + str(np.around(crystal.Y(),10)) + " " + str(np.around(crystal.Z(),10))) + crystal = TVector3(self.placement.X()+crystal_offset.X(), + self.placement.Y()+crystal_offset.Y(), + self.placement.Z()+crystal_offset.Z()) + if coord == "Spherical": + print("clover.{0:02d}.{1}.{2}.vec_sph: ".format(idxclover,chr(0x40+k+1),0) + + str(np.around(crystal.Mag(),10)) + " " + + str(np.around(crystal.Theta()*180/np.pi,10)) + " " + + str(np.around(crystal.Phi()*180/np.pi,10))) + else: + print("clover.{0:02d}.{1}.{2}.vec: ".format(idxclover,chr(0x40+k+1),0) + + str(np.around(crystal.X(),10)) + " " + + str(np.around(crystal.Y(),10)) + " " + + str(np.around(crystal.Z(),10))) print("") - def print_crystal_placement_sph(self,idxclover): + def print_segment_placement(self,idxclover,coord=None): + theta_rotation = TRotation() + phi_rotation = TRotation() + theta_rotation.RotateY(self.placement.Theta()) + phi_rotation.RotateZ(self.placement.Phi()) for k,(xsign,ysign) in enumerate([(-1,+1),(+1,+1),(-1,-1),(+1,-1)]): - theta_rotation = TRotation() - phi_rotation = TRotation() - theta_rotation.RotateY(self.placement.Theta()) - phi_rotation.RotateZ(self.placement.Phi()) - crystal_offset = TVector3(xsign*self.xdispl,ysign*self.ydispl,0) + crystal_offset = TVector3(xsign*self.xdispl,ysign*self.ydispl,self.covergap) crystal_offset = phi_rotation*theta_rotation*crystal_offset - crystal = TVector3(self.placement.X()+crystal_offset.X(),self.placement.Y()+crystal_offset.Y(),self.placement.Z()+crystal_offset.Z()) - print("clover.{0:02d}.{1}.vec_sph: ".format(idxclover,k+1) + str(np.around(crystal.Mag(),10)) + " " + str(np.around(crystal.Theta()*180/np.pi,10)) + " " + str(np.around(crystal.Phi()*180/np.pi,10))) + crystal = TVector3(self.placement.X()+crystal_offset.X(), + self.placement.Y()+crystal_offset.Y(), + self.placement.Z()+crystal_offset.Z()) + if coord == "Spherical": + print("clover.{0:02d}.{1}.{2}.vec_sph: ".format(idxclover,chr(0x40+k+1),0) + + str(np.around(crystal.Mag(),10)) + " " + + str(np.around(crystal.Theta()*180/np.pi,10)) + " " + + str(np.around(crystal.Phi()*180/np.pi,10))) + else: + print("clover.{0:02d}.{1}.{2}.vec: ".format(idxclover,chr(0x40+k+1),0) + + str(np.around(crystal.X(),10)) + " " + + str(np.around(crystal.Y(),10)) + " " + + str(np.around(crystal.Z(),10))) + for s,segsign in enumerate([-1, +1]): + segment_offset = TVector3(xsign*self.xdispl+segsign*self.segdispl,ysign*self.ydispl,self.covergap) + segment_offset = phi_rotation*theta_rotation*segment_offset + segment = TVector3(self.placement.X()+segment_offset.X(), + self.placement.Y()+segment_offset.Y(), + self.placement.Z()+segment_offset.Z()) + if coord == "Spherical": + print("clover.{0:02d}.{1}.{2}.vec_sph: ".format(idxclover,chr(0x40+k+1),s+1) + + str(np.around(segment.Mag(),10)) + " " + + str(np.around(segment.Theta()*180/np.pi,10)) + " " + + str(np.around(segment.Phi()*180/np.pi,10))) + else: + print("clover.{0:02d}.{1}.{2}.vec: ".format(idxclover,chr(0x40+k+1),s+1) + + str(np.around(segment.X(),10)) + " " + + str(np.around(segment.Y(),10)) + " " + + str(np.around(segment.Z(),10))) print("") @@ -66,10 +121,11 @@ def set_placement(self, _placement): if phi > 180: phi -= 360 placed = clover(r,theta,phi,CloverType.Yale) - #placed.print_clover_placement_sph(i+1) + #placed.print_clover_placement(i+1,coord="Spherical") #placed.print_clover_placement(i+1) - placed.print_crystal_placement(i+1) - #placed.print_crystal_placement_sph(i+1) + #placed.print_crystal_placement(i+1) + placed.print_segment_placement(i+1) + #placed.print_crystal_placement(i+1,coord="Spherical") # 90 degree detectors (yale) @@ -78,10 +134,11 @@ def set_placement(self, _placement): theta = 90.0 phi = 45*i placed = clover(r,theta,phi,CloverType.Yale) - #placed.print_clover_placement_sph(i+4+1) + #placed.print_clover_placement(i+4+1,coord="Spherical") #placed.print_clover_placement(i+4+1) - placed.print_crystal_placement(i+4+1) - #placed.print_crystal_placement_sph(i+4+1) + #placed.print_crystal_placement(i+4+1) + placed.print_segment_placement(i+4+1) + #placed.print_crystal_placement(i+4+1,coord="Spherical") # 135 degree detectors (Tohoku) for i in range(0,4): @@ -91,7 +148,8 @@ def set_placement(self, _placement): if phi > 180: phi -= 360 placed = clover(r,theta,phi,CloverType.Yale) - #placed.print_clover_placement_sph(i+12+1) + #placed.print_clover_placement(i+12+1,coord="Spherical") #placed.print_clover_placement(i+12+1) - placed.print_crystal_placement(i+12+1) - #placed.print_crystal_placement_sph(i+12+1) + #placed.print_crystal_placement(i+12+1) + placed.print_segment_placement(i+12+1) + #placed.print_crystal_placement(i+12+1,coord="Spherical") From 3906befad34be6e30889e2fe87bba1e406805729 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 27 May 2016 17:29:05 -0400 Subject: [PATCH 23/94] Added calibrated energy spectra. The calibrations work! --- histos/MakeANLHistos.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 3c737a5f..81374b36 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -75,8 +75,12 @@ void MakeHistograms(TRuntimeObjects& obj) { */ //hit.GetPosition().Print(); stream.str(""); - stream << "Crystal" << hit.GetChannel(); + stream << "Leaf" << hit.GetChannel(); obj.FillHistogram(stream.str(),10000,0,20000,hit.Charge()); + stream.str(""); + stream << "CalLeaf" << hit.GetChannel(); + obj.FillHistogram(stream.str(),10000,0,20000,hit.GetEnergy()); + } } From 0ddad10c120e723d45be6d6eb5eb1dbe5961dc97 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 27 May 2016 17:36:05 -0400 Subject: [PATCH 24/94] TCAGRA has been replaced by TCagra due to loss in pinky strength --- histos/MakeANLHistos.cxx | 6 +-- histos/RCNPHistos.cxx | 6 +-- include/{TCAGRA.h => TCagra.h} | 22 +++++----- include/{TCAGRAHit.h => TCagraHit.h} | 20 ++++----- ...{TCAGRASegmentHit.h => TCagraSegmentHit.h} | 12 +++--- libraries/TDetSystems/TArgonne/LinkDef.h | 12 +++--- .../TArgonne/{TCAGRA.cxx => TCagra.cxx} | 36 ++++++++-------- .../TArgonne/{TCAGRAHit.cxx => TCagraHit.cxx} | 42 +++++++++---------- ...GRASegmentHit.cxx => TCagraSegmentHit.cxx} | 26 ++++++------ libraries/TLoops/TUnpackedEvent.cxx | 4 +- 10 files changed, 93 insertions(+), 93 deletions(-) rename include/{TCAGRA.h => TCagra.h} (67%) rename include/{TCAGRAHit.h => TCagraHit.h} (73%) rename include/{TCAGRASegmentHit.h => TCagraSegmentHit.h} (63%) rename libraries/TDetSystems/TArgonne/{TCAGRA.cxx => TCagra.cxx} (83%) rename libraries/TDetSystems/TArgonne/{TCAGRAHit.cxx => TCagraHit.cxx} (75%) rename libraries/TDetSystems/TArgonne/{TCAGRASegmentHit.cxx => TCagraSegmentHit.cxx} (63%) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 81374b36..82d71a41 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -13,7 +13,7 @@ #include #include -#include "TCAGRA.h" +#include "TCagra.h" //#include "TChannel.h" //#include "GValue.h" @@ -32,7 +32,7 @@ stringstream stream; // or else bad things will happen. extern "C" void MakeHistograms(TRuntimeObjects& obj) { - TCAGRA *cagra = obj.GetDetector(); + TCagra *cagra = obj.GetDetector(); TList *list = &(obj.GetObjects()); int numobj = list->GetSize(); @@ -42,7 +42,7 @@ void MakeHistograms(TRuntimeObjects& obj) { for(int y=0;ySize();y++) { - //auto hit = cagra->GetCAGRAHit(y); + //auto hit = cagra->GetCagraHit(y); diff --git a/histos/RCNPHistos.cxx b/histos/RCNPHistos.cxx index 61a997b5..b9b14ed3 100644 --- a/histos/RCNPHistos.cxx +++ b/histos/RCNPHistos.cxx @@ -13,7 +13,7 @@ #include #include -#include "TCAGRA.h" +#include "TCagra.h" #include "TGrandRaiden.h" //#include "TChannel.h" @@ -33,7 +33,7 @@ stringstream stream; // or else bad things will happen. extern "C" void MakeHistograms(TRuntimeObjects& obj) { - auto cagra = obj.GetDetector(); + auto cagra = obj.GetDetector(); auto gr = obj.GetDetector(); TList *list = &(obj.GetObjects()); @@ -58,7 +58,7 @@ void MakeHistograms(TRuntimeObjects& obj) { /* for(int y=0;ySize();y++) { - TCAGRAHit hit = cagra->GetCAGRAHit(y); + TCagraHit hit = cagra->GetCagraHit(y); if(hit.GetBoardID() == 113) { diff --git a/include/TCAGRA.h b/include/TCagra.h similarity index 67% rename from include/TCAGRA.h rename to include/TCagra.h index 0b2ed344..118bcbae 100644 --- a/include/TCAGRA.h +++ b/include/TCagra.h @@ -1,19 +1,19 @@ -#ifndef TCAGRA_H -#define TCAGRA_H +#ifndef TCagra_H +#define TCagra_H #include #include #include "TDetector.h" -#include "TCAGRAHit.h" +#include "TCagraHit.h" #include "TVector3.h" -class TCAGRA : public TDetector { +class TCagra : public TDetector { public: - TCAGRA(); - ~TCAGRA(); + TCagra(); + ~TCagra(); virtual void Copy(TObject& obj) const; virtual void Print(Option_t *opt = "") const; @@ -22,23 +22,23 @@ class TCAGRA : public TDetector { virtual void InsertHit(const TDetectorHit& hit); virtual TDetectorHit& GetHit(int i) { return cagra_hits.at(i); } - const TCAGRAHit& GetCAGRAHit(int i) { return cagra_hits.at(i); } + const TCagraHit& GetCagraHit(int i) { return cagra_hits.at(i); } void PrintHit(int i){ cagra_hits.at(i).Print(); } static TVector3 GetSegmentPosition(int detnum, char subpos, int segnum); // Allows for looping over all hits with for(auto& hit : cagra) { } - std::vector::iterator begin() { return cagra_hits.begin(); } - std::vector::iterator end() { return cagra_hits.end(); } + std::vector::iterator begin() { return cagra_hits.begin(); } + std::vector::iterator end() { return cagra_hits.end(); } private: virtual int BuildHits(std::vector& raw_data); static void LoadDetectorPositions(); - std::vector cagra_hits; + std::vector cagra_hits; static std::map detector_positions; - ClassDef(TCAGRA,1); + ClassDef(TCagra,1); }; diff --git a/include/TCAGRAHit.h b/include/TCagraHit.h similarity index 73% rename from include/TCAGRAHit.h rename to include/TCagraHit.h index a6c0e4df..3333173b 100644 --- a/include/TCAGRAHit.h +++ b/include/TCagraHit.h @@ -1,13 +1,13 @@ -#ifndef TCAGRAHIT_H -#define TCAGRAHIT_H +#ifndef TCagraHIT_H +#define TCagraHIT_H #include "TDetectorHit.h" -#include "TCAGRASegmentHit.h" +#include "TCagraSegmentHit.h" -class TCAGRAHit : public TDetectorHit { +class TCagraHit : public TDetectorHit { public: - TCAGRAHit(); - ~TCAGRAHit(); + TCagraHit(); + ~TCagraHit(); virtual void Copy(TObject& obj) const; virtual void Print(Option_t *opt = "") const; @@ -23,7 +23,7 @@ class TCAGRAHit : public TDetectorHit { bool HasCore() const; unsigned int GetNumSegments() const { return fSegments.size(); } - TCAGRASegmentHit& GetSegment(int i) { return fSegments.at(i); } + TCagraSegmentHit& GetSegment(int i) { return fSegments.at(i); } unsigned long GetSegmentTimestamp() { if(fSegments.size()){ return fSegments[0].Timestamp(); @@ -32,7 +32,7 @@ class TCAGRAHit : public TDetectorHit { } } - TCAGRASegmentHit& MakeSegmentByAddress(unsigned int address); + TCagraSegmentHit& MakeSegmentByAddress(unsigned int address); int GetBoardID() const; int GetChannel() const; @@ -45,10 +45,10 @@ class TCAGRAHit : public TDetectorHit { private: - std::vector fSegments; + std::vector fSegments; - ClassDef(TCAGRAHit,1); + ClassDef(TCagraHit,1); }; diff --git a/include/TCAGRASegmentHit.h b/include/TCagraSegmentHit.h similarity index 63% rename from include/TCAGRASegmentHit.h rename to include/TCagraSegmentHit.h index f1a17154..cfd3ae7b 100644 --- a/include/TCAGRASegmentHit.h +++ b/include/TCagraSegmentHit.h @@ -1,11 +1,11 @@ -#ifndef _TCAGRASEGMENTHIT_H_ -#define _TCAGRASEGMENTHIT_H_ +#ifndef _TCagraSEGMENTHIT_H_ +#define _TCagraSEGMENTHIT_H_ #include "TDetectorHit.h" -class TCAGRASegmentHit : public TDetectorHit { +class TCagraSegmentHit : public TDetectorHit { public: - TCAGRASegmentHit() { } + TCagraSegmentHit() { } virtual void Copy(TObject&) const; virtual void Clear(Option_t *opt = ""); @@ -22,7 +22,7 @@ class TCAGRASegmentHit : public TDetectorHit { private: - ClassDef(TCAGRASegmentHit,1); + ClassDef(TCagraSegmentHit,1); }; -#endif /* _TCAGRASEGMENTHIT_H_ */ +#endif /* _TCagraSEGMENTHIT_H_ */ diff --git a/libraries/TDetSystems/TArgonne/LinkDef.h b/libraries/TDetSystems/TArgonne/LinkDef.h index 62a9095c..21054148 100644 --- a/libraries/TDetSystems/TArgonne/LinkDef.h +++ b/libraries/TDetSystems/TArgonne/LinkDef.h @@ -1,4 +1,4 @@ -// TCAGRA.h TCAGRAHit.h TCAGRASegmentHit.h TANLEvent.h +// TCagra.h TCagraHit.h TCagraSegmentHit.h TANLEvent.h #ifdef __CINT__ @@ -8,10 +8,10 @@ #pragma link C++ nestedclasses; #pragma link C++ class TANLEvent+; -#pragma link C++ class TCAGRAHit+; -#pragma link C++ class TCAGRASegmentHit+; -#pragma link C++ class std::vector+; -#pragma link C++ class std::vector+; -#pragma link C++ class TCAGRA+; +#pragma link C++ class TCagraHit+; +#pragma link C++ class TCagraSegmentHit+; +#pragma link C++ class std::vector+; +#pragma link C++ class std::vector+; +#pragma link C++ class TCagra+; #endif diff --git a/libraries/TDetSystems/TArgonne/TCAGRA.cxx b/libraries/TDetSystems/TArgonne/TCagra.cxx similarity index 83% rename from libraries/TDetSystems/TArgonne/TCAGRA.cxx rename to libraries/TDetSystems/TArgonne/TCagra.cxx index 78778958..eca41594 100644 --- a/libraries/TDetSystems/TArgonne/TCAGRA.cxx +++ b/libraries/TDetSystems/TArgonne/TCagra.cxx @@ -1,4 +1,4 @@ -#include "TCAGRA.h" +#include "TCagra.h" #include #include @@ -9,30 +9,30 @@ #include "TGEBEvent.h" -std::map TCAGRA::detector_positions; +std::map TCagra::detector_positions; -TCAGRA::TCAGRA(){ +TCagra::TCagra(){ Clear(); } -TCAGRA::~TCAGRA() { +TCagra::~TCagra() { } -void TCAGRA::Copy(TObject& obj) const { +void TCagra::Copy(TObject& obj) const { TDetector::Copy(obj); - TCAGRA& detector = (TCAGRA&)obj; + TCagra& detector = (TCagra&)obj; detector.cagra_hits = cagra_hits; } -void TCAGRA::InsertHit(const TDetectorHit& hit){ - cagra_hits.emplace_back((TCAGRAHit&)hit); +void TCagra::InsertHit(const TDetectorHit& hit){ + cagra_hits.emplace_back((TCagraHit&)hit); fSize++; } -int TCAGRA::BuildHits(std::vector& raw_data){ +int TCagra::BuildHits(std::vector& raw_data){ for (auto& event : raw_data) { SetTimestamp(event.GetTimestamp()); @@ -64,7 +64,7 @@ int TCAGRA::BuildHits(std::vector& raw_data){ int segnum = chan->GetSegment(); // segment number // Get a hit, make it if it does not exist - TCAGRAHit* hit = NULL; + TCagraHit* hit = NULL; for(auto& ihit : cagra_hits){ if(ihit.GetDetnum() == detnum){ hit = &ihit; @@ -82,7 +82,7 @@ int TCAGRA::BuildHits(std::vector& raw_data){ hit->SetTimestamp(event.GetTimestamp()); hit->SetCharge(anl.GetEnergy()); } else { - TCAGRASegmentHit& seg = hit->MakeSegmentByAddress(address); + TCagraSegmentHit& seg = hit->MakeSegmentByAddress(address); seg.SetCharge(anl.GetEnergy()); seg.SetTimestamp(event.GetTimestamp()); } @@ -90,13 +90,13 @@ int TCAGRA::BuildHits(std::vector& raw_data){ - //TCAGRAHit hit; + //TCagraHit hit; //hit.BuildFrom(buf); //hit.SetTimestamp(event.GetTimestamp()); //InsertHit(hit); return Size(); } -TVector3 TCAGRA::GetSegmentPosition(int detnum, char subpos, int segnum) { +TVector3 TCagra::GetSegmentPosition(int detnum, char subpos, int segnum) { if(detnum < 1 || detnum > 16 || segnum < 0 || segnum > 2 || subpos < 0x41 || subpos > 0x44){ return TVector3(std::sqrt(-1),std::sqrt(-1),std::sqrt(-1)); @@ -132,7 +132,7 @@ TVector3 TCAGRA::GetSegmentPosition(int detnum, char subpos, int segnum) { // return global_pos; } -void TCAGRA::LoadDetectorPositions() { +void TCagra::LoadDetectorPositions() { static bool loaded = false; if(loaded){ return; @@ -140,13 +140,13 @@ void TCAGRA::LoadDetectorPositions() { loaded = true; //std::string filename = std::string(getenv("GRUTSYS")) + "/../config/SeGA_rotations.txt"; - std::string filename = std::string(getenv("GRUTSYS")) + "/config/CAGRA_positions.txt"; + std::string filename = std::string(getenv("GRUTSYS")) + "/config/Cagra_positions.txt"; //Read the locations from file. std::ifstream infile(filename); if(!infile){ - std::cout << "CAGRA positions file \"" << filename << "\"" + std::cout << "Cagra positions file \"" << filename << "\"" << " does not exist, skipping" << std::endl; return; } @@ -172,8 +172,8 @@ void TCAGRA::LoadDetectorPositions() { } } -void TCAGRA::Print(Option_t *opt) const { } +void TCagra::Print(Option_t *opt) const { } -void TCAGRA::Clear(Option_t *opt) { +void TCagra::Clear(Option_t *opt) { cagra_hits.clear(); } diff --git a/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx b/libraries/TDetSystems/TArgonne/TCagraHit.cxx similarity index 75% rename from libraries/TDetSystems/TArgonne/TCAGRAHit.cxx rename to libraries/TDetSystems/TArgonne/TCagraHit.cxx index 65667e58..75403ceb 100644 --- a/libraries/TDetSystems/TArgonne/TCAGRAHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCagraHit.cxx @@ -1,6 +1,6 @@ -#include "TCAGRAHit.h" +#include "TCagraHit.h" -#include "TCAGRA.h" +#include "TCagra.h" #include #include @@ -12,28 +12,28 @@ #include "TGRUTOptions.h" -ClassImp(TCAGRAHit) +ClassImp(TCagraHit) -TCAGRAHit::TCAGRAHit(){ +TCagraHit::TCagraHit(){ } -TCAGRAHit::~TCAGRAHit() { +TCagraHit::~TCagraHit() { } -void TCAGRAHit::Copy(TObject& obj) const { +void TCagraHit::Copy(TObject& obj) const { TDetectorHit::Copy(obj); } -void TCAGRAHit::Print(Option_t *opt) const { +void TCagraHit::Print(Option_t *opt) const { } -void TCAGRAHit::Clear(Option_t *opt) { +void TCagraHit::Clear(Option_t *opt) { TDetectorHit::Clear(opt); } -bool TCAGRAHit::HasCore() const { +bool TCagraHit::HasCore() const { return fCharge != -1; } -int TCAGRAHit::GetDetnum() const { +int TCagraHit::GetDetnum() const { TChannel* chan = TChannel::GetChannel(fAddress); int output = -1; if(chan && fAddress!=-1){ @@ -53,7 +53,7 @@ int TCAGRAHit::GetDetnum() const { return output; } -char TCAGRAHit::GetLeaf() const { +char TCagraHit::GetLeaf() const { TChannel* chan = TChannel::GetChannel(fAddress); char output = (char)-1; if(chan && fAddress!=-1){ @@ -73,19 +73,19 @@ char TCAGRAHit::GetLeaf() const { return output; } -// int TCAGRAHit::GetCrate() const { +// int TCagraHit::GetCrate() const { // return (fAddress&0x00ff0000)>>16; // } -int TCAGRAHit::GetBoardID() const { +int TCagraHit::GetBoardID() const { return (fAddress&0x0000ff00)>>8; } -int TCAGRAHit::GetChannel() const { +int TCagraHit::GetChannel() const { return (fAddress&0x000000ff)>>0; } -TCAGRASegmentHit& TCAGRAHit::MakeSegmentByAddress(unsigned int address){ +TCagraSegmentHit& TCagraHit::MakeSegmentByAddress(unsigned int address){ // for(auto& segment : fSegments){ // if(segment.Address() == address){ // return segment; @@ -93,12 +93,12 @@ TCAGRASegmentHit& TCAGRAHit::MakeSegmentByAddress(unsigned int address){ // } fSegments.emplace_back(); - TCAGRASegmentHit& output = fSegments.back(); + TCagraSegmentHit& output = fSegments.back(); output.SetAddress(address); return output; } -int TCAGRAHit::GetMainSegnum() const { +int TCagraHit::GetMainSegnum() const { int output = 0; double max_energy = -9e99; for(auto& segment : fSegments){ @@ -110,8 +110,8 @@ int TCAGRAHit::GetMainSegnum() const { return output; } -TVector3 TCAGRAHit::GetPosition(bool apply_array_offset) const { - TVector3 array_pos = TCAGRA::GetSegmentPosition(GetDetnum(), GetLeaf(), GetMainSegnum()); +TVector3 TCagraHit::GetPosition(bool apply_array_offset) const { + TVector3 array_pos = TCagra::GetSegmentPosition(GetDetnum(), GetLeaf(), GetMainSegnum()); if(apply_array_offset){ array_pos += TVector3(GValue::Value("Cagra_X_offset"), GValue::Value("Cagra_Y_offset"), @@ -120,7 +120,7 @@ TVector3 TCAGRAHit::GetPosition(bool apply_array_offset) const { return array_pos; } -double TCAGRAHit::GetDoppler(double beta,const TVector3& particle_vec, const TVector3& offset) const { +double TCagraHit::GetDoppler(double beta,const TVector3& particle_vec, const TVector3& offset) const { if(GetNumSegments()<1) { return std::sqrt(-1); } @@ -132,7 +132,7 @@ double TCAGRAHit::GetDoppler(double beta,const TVector3& particle_vec, const TVe return dc_en; } -Int_t TCAGRAHit::Charge() const { +Int_t TCagraHit::Charge() const { if(fCharge > 30000) { return fCharge - 32768; } else { diff --git a/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx b/libraries/TDetSystems/TArgonne/TCagraSegmentHit.cxx similarity index 63% rename from libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx rename to libraries/TDetSystems/TArgonne/TCagraSegmentHit.cxx index 8ab3ea0e..9963405a 100644 --- a/libraries/TDetSystems/TArgonne/TCAGRASegmentHit.cxx +++ b/libraries/TDetSystems/TArgonne/TCagraSegmentHit.cxx @@ -1,25 +1,25 @@ -#include "TCAGRASegmentHit.h" +#include "TCagraSegmentHit.h" #include #include -void TCAGRASegmentHit::Copy(TObject& obj) const{ +void TCagraSegmentHit::Copy(TObject& obj) const{ TDetectorHit::Copy(obj); - TCAGRASegmentHit& cagra = (TCAGRASegmentHit&)obj; + TCagraSegmentHit& cagra = (TCagraSegmentHit&)obj; } -void TCAGRASegmentHit::Clear(Option_t *opt) { +void TCagraSegmentHit::Clear(Option_t *opt) { TDetectorHit::Clear(opt); } -void TCAGRASegmentHit::Print(Option_t *opt) const { - std::cout << "TCAGRASegmentHit:\n" +void TCagraSegmentHit::Print(Option_t *opt) const { + std::cout << "TCagraSegmentHit:\n" << "\tCharge: " << Charge() << "\n" << std::flush; } -int TCAGRASegmentHit::GetDetnum() const { +int TCagraSegmentHit::GetDetnum() const { TChannel* chan = TChannel::GetChannel(fAddress); if(chan){ return chan->GetArrayPosition(); @@ -29,7 +29,7 @@ int TCAGRASegmentHit::GetDetnum() const { return -1; } } -char TCAGRASegmentHit::GetLeaf() const { +char TCagraSegmentHit::GetLeaf() const { TChannel* chan = TChannel::GetChannel(fAddress); if(chan){ return *chan->GetArraySubposition(); @@ -40,7 +40,7 @@ char TCAGRASegmentHit::GetLeaf() const { } } -int TCAGRASegmentHit::GetSegnum() const { +int TCagraSegmentHit::GetSegnum() const { TChannel* chan = TChannel::GetChannel(fAddress); if(chan){ return chan->GetSegment(); @@ -49,19 +49,19 @@ int TCAGRASegmentHit::GetSegnum() const { } } -// int TCAGRASegmentHit::GetCrate() const { +// int TCagraSegmentHit::GetCrate() const { // return (fAddress&0x00ff0000)>>16; // } -int TCAGRASegmentHit::GetBoardID() const { +int TCagraSegmentHit::GetBoardID() const { return (fAddress&0x0000ff00)>>8; } -int TCAGRASegmentHit::GetChannel() const { +int TCagraSegmentHit::GetChannel() const { return (fAddress&0x000000ff)>>0; } -Int_t TCAGRASegmentHit::Charge() const { +Int_t TCagraSegmentHit::Charge() const { if(fCharge > 30000) { return fCharge - 32768; } else { diff --git a/libraries/TLoops/TUnpackedEvent.cxx b/libraries/TLoops/TUnpackedEvent.cxx index 3b653cb8..8f13e8c6 100644 --- a/libraries/TLoops/TUnpackedEvent.cxx +++ b/libraries/TLoops/TUnpackedEvent.cxx @@ -14,7 +14,7 @@ #include "TS800Scaler.h" #include "TSega.h" #include "TFastScint.h" -#include "TCAGRA.h" +#include "TCagra.h" #include "TGrandRaiden.h" TUnpackedEvent::TUnpackedEvent() { } @@ -80,7 +80,7 @@ void TUnpackedEvent::Build() { break; case kDetectorSystems::ANL: - GetDetector(true)->Build(raw_data); + GetDetector(true)->Build(raw_data); break; case kDetectorSystems::GRAND_RAIDEN: From 1ec2491a5e278890810b508c5cef2734697cbe76 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 1 Jun 2016 15:36:31 -0400 Subject: [PATCH 25/94] Bug introduced when refactoring into TANLEvent. Forgot to add check to TCagra::BuildHits to distinguish between ArraySubpositions (Leaves of a clover). Now fixed. --- histos/MakeANLHistos.cxx | 75 ++++++++--------------- libraries/TDetSystems/TArgonne/TCagra.cxx | 5 +- 2 files changed, 30 insertions(+), 50 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 82d71a41..e9bb7546 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -14,6 +14,7 @@ #include #include "TCagra.h" +#include "TGrandRaiden.h" //#include "TChannel.h" //#include "GValue.h" @@ -27,78 +28,56 @@ using namespace std; string name; stringstream stream; +int debugctr =0; +int totalctr=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(); + TCagra* cagra = obj.GetDetector(); + TGrandRaiden* gr = obj.GetDetector(); TList *list = &(obj.GetObjects()); int numobj = list->GetSize(); - if(!cagra) - return; - - - for(int y=0;ySize();y++) { - //auto hit = cagra->GetCagraHit(y); - - - - - //stream.str(""); - //stream << "PostE_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); - //obj.FillHistogram(stream.str(),10000,0,0,hit.GetPostE()); - - //stream.str(""); - //stream << "LED_BoardID" << hit.GetBoardID() << "Chan" << hit.GetChannel(); - //obj.FillHistogram(stream.str(),10000,0,0,hit.GetLED()); + // totalctr++; + // if (cagra && gr) { + // cout << "Coincidence" << endl; + // debugctr=0; + // } else { + // cout << "Single" << endl; + // debugctr+=1; + // } + // if (debugctr>1e3){ + // cout << totalctr << endl; + // exit(1); + // } + if(cagra) { + + //cout << "Size: " << cagra->Size() << endl; + for (auto& hit : *cagra) { + //cout << " "< 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/libraries/TDetSystems/TArgonne/TCagra.cxx b/libraries/TDetSystems/TArgonne/TCagra.cxx index eca41594..6beded5f 100644 --- a/libraries/TDetSystems/TArgonne/TCagra.cxx +++ b/libraries/TDetSystems/TArgonne/TCagra.cxx @@ -61,12 +61,13 @@ int TCagra::BuildHits(std::vector& raw_data){ } int detnum = chan->GetArrayPosition(); // clover number + char leaf = *chan->GetArraySubposition(); // clover number int segnum = chan->GetSegment(); // segment number // Get a hit, make it if it does not exist TCagraHit* hit = NULL; for(auto& ihit : cagra_hits){ - if(ihit.GetDetnum() == detnum){ + if(ihit.GetDetnum() == detnum && ihit.GetLeaf() == leaf){ hit = &ihit; break; } @@ -140,7 +141,7 @@ void TCagra::LoadDetectorPositions() { loaded = true; //std::string filename = std::string(getenv("GRUTSYS")) + "/../config/SeGA_rotations.txt"; - std::string filename = std::string(getenv("GRUTSYS")) + "/config/Cagra_positions.txt"; + std::string filename = std::string(getenv("GRUTSYS")) + "/config/CAGRA_positions.txt"; //Read the locations from file. std::ifstream infile(filename); From dea84958f8025ec61e76645b7bdd6ff86363c828 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 2 Jun 2016 16:31:33 -0400 Subject: [PATCH 26/94] List of changes: Major: Fixed bug in TTreeSource::GetEvent in which the stack address was being copied into the TSmartBuffer, not the value at the stack address. This was what was causing a double free to occur. TGrandRaidenHit::BuiltHits and TTreeSource were adjusted to be more symmetric also Major: TMultiRawFile changes are in progress. Adjusting so that it has slightly different functionality in online and offline modes. --- histos/MakeANLHistos.cxx | 34 +++++++++++++++---- include/TGrandRaiden.h | 3 ++ include/TTreeSource.h | 2 +- .../TGrandRaiden/TGrandRaidenHit.cxx | 18 ++-------- libraries/TRawFormat/TMultiRawFile.cxx | 10 +++++- 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index e9bb7546..db97973f 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -28,14 +28,15 @@ using namespace std; string name; stringstream stream; -int debugctr =0; -int totalctr=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(); @@ -43,11 +44,31 @@ void MakeHistograms(TRuntimeObjects& obj) { int numobj = list->GetSize(); // totalctr++; - // if (cagra && gr) { - // cout << "Coincidence" << endl; + if (cagra && gr) { + obj.FillHistogram("nCoin",10,-1,1,0); + } + + if (gr) { + for (auto& hit : *gr) { + auto adc = hit.GetADC(); + for (int i=0; i<4; i++) { + stream.str(""); stream << "GR_ADC" << i; + obj.FillHistogram(stream.str().c_str(), 1000,0,1000, adc[i]); + } + } + } + // cout << " GR TS: " << gr->Timestamp() << " " << gr->Size() << endl; + // cout << " CAGRA TS: " << cagra->Timestamp() << " " << cagra->Size() << endl; // debugctr=0; // } else { - // cout << "Single" << endl; + // cout << "Single "; + // if (cagra) { + // cout << "Cagra" << endl; + // cout << cagra->Timestamp() << endl; + // } else if (gr) { + // cout << "Grand Raiden" << endl; + // cout << gr->Timestamp() << endl; + // } // debugctr+=1; // } // if (debugctr>1e3){ @@ -59,12 +80,11 @@ void MakeHistograms(TRuntimeObjects& obj) { //cout << "Size: " << cagra->Size() << endl; for (auto& hit : *cagra) { - //cout << " "<::iterator begin() { return GRHits.begin(); } + std::vector::iterator end() { return GRHits.end(); } private: virtual int BuildHits(std::vector& raw_data); diff --git a/include/TTreeSource.h b/include/TTreeSource.h index f0269fb4..e517e800 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -114,7 +114,7 @@ class TTreeSource : public TRawEventSource { // create a small memory buffer to hold the pointer to the current entry char* ptrbytes = (char*)calloc(1,sizeof(fEvent)); // copy the address stored in fEvent into the temporary buffer - memcpy(&ptrbytes, &fEvent, sizeof(fEvent)); + *reinterpret_cast(ptrbytes) = fEvent; // prepare the events smart buffer payload TSmartBuffer eventbuffer(ptrbytes,sizeof(fEvent)); // set the pointer address into the buffer diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 96cd4df7..9a0b74a5 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -19,30 +19,16 @@ TGrandRaidenHit::~TGrandRaidenHit() { void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ Clear(); - // method 1 - //char* ptrbytes = (char*)calloc(1,sizeof(RCNPEvent*)); - //auto buffer = buf.GetData(); - //memcpy(&ptrbytes, &buffer, sizeof(RCNPEvent*)); - // method 2 - //TSmartBuffer temp(std::move(buf)); - - // method 3 - auto event = const_cast((const RCNPEvent*)buf.GetData()); + 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(); - // for (int i=0; i<4; i++) { - // std::cout << ADC[i] << " "; - // } std::cout << std::endl; - - //std::cout << event->GR_ADC() << std::endl; buf.Advance(sizeof(event)); - //buf.Clear(); - //if (event) delete event; + if (event) delete event; } diff --git a/libraries/TRawFormat/TMultiRawFile.cxx b/libraries/TRawFormat/TMultiRawFile.cxx index c742348b..5c30b083 100644 --- a/libraries/TRawFormat/TMultiRawFile.cxx +++ b/libraries/TRawFormat/TMultiRawFile.cxx @@ -2,6 +2,8 @@ #include #include +#include +#include #include "Globals.h" @@ -58,7 +60,13 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){ int bytes_read = next.file->Read(next.next_event); if(bytes_read > 0){ fFileEvents.insert(next); - } else { + } else if (!TGRUTOptions::Get()->ExitAfterSorting()) { + // if online (not exiting immediately) and no bytes were read from source + while (bytes_read <= 0) { // stall until source provides next event + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + bytes_read = next.file->Read(next.next_event); + } + } else { // otherwise delete the source from the file list std::lock_guard lock(fFileListMutex); delete output.file; fFileList.erase(output.file); From 5555dd6aeae9413a6a0febc1350e1fec03b86008 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 3 Jun 2016 11:21:34 -0400 Subject: [PATCH 27/94] Merging from TMultiRawFile_StalledSource branch. Added online functionality to TMultiRawFile. See commit log. --- libraries/TLoops/TDataLoop.cxx | 5 ----- libraries/TRawFormat/TMultiRawFile.cxx | 20 +++++++++++++------- libraries/TRawFormat/TRawEventSource.cxx | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/libraries/TLoops/TDataLoop.cxx b/libraries/TLoops/TDataLoop.cxx index 7b59a224..2ca214ed 100644 --- a/libraries/TLoops/TDataLoop.cxx +++ b/libraries/TLoops/TDataLoop.cxx @@ -62,11 +62,6 @@ bool TDataLoop::Iteration() { output_queue.Push(evt); return true; } else { - static TRawEventSource* source_ptr = NULL; - if(source_ptr != source){ - std::cout << "Finished reading source" << std::endl; - source_ptr = source; - } // Nothing returned this time, but I might get something next time. std::this_thread::sleep_for(std::chrono::milliseconds(1000)); return true; diff --git a/libraries/TRawFormat/TMultiRawFile.cxx b/libraries/TRawFormat/TMultiRawFile.cxx index 5c30b083..c19c7190 100644 --- a/libraries/TRawFormat/TMultiRawFile.cxx +++ b/libraries/TRawFormat/TMultiRawFile.cxx @@ -2,8 +2,6 @@ #include #include -#include -#include #include "Globals.h" @@ -49,6 +47,18 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){ return -1; } + static TRawEventSource* stalled_source = nullptr; + if (stalled_source) { + FileEvent next; + int bytes_read = stalled_source->Read(next.next_event); + if (bytes_read > 0) { + next.file = stalled_source; + fFileEvents.insert(next); + stalled_source = nullptr; + } + return -1; + } + // Pop the event, place in output FileEvent output = *fFileEvents.begin(); fFileEvents.erase(fFileEvents.begin()); @@ -61,11 +71,7 @@ int TMultiRawFile::GetEvent(TRawEvent& outevent){ if(bytes_read > 0){ fFileEvents.insert(next); } else if (!TGRUTOptions::Get()->ExitAfterSorting()) { - // if online (not exiting immediately) and no bytes were read from source - while (bytes_read <= 0) { // stall until source provides next event - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - bytes_read = next.file->Read(next.next_event); - } + stalled_source = next.file; } else { // otherwise delete the source from the file list std::lock_guard lock(fFileListMutex); delete output.file; diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index fff8725a..7aa4106f 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -17,7 +17,7 @@ int TRawEventSource::Read(TRawEvent& event){ int result = GetEvent(event); if(result > 0){ UpdateByteThroughput(event.GetTotalSize()); - } else if (result < 0) { + } else if (result < 0 && TGRUTOptions::Get()->ExitAfterSorting()) { fIsFinished = true; } return result; From dbf194ba51d7c40e2aa340c925fddb3589664b6f Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 3 Jun 2016 11:41:12 -0400 Subject: [PATCH 28/94] rootalyze.h -> RCNPEvent.h, also removed +1 to Timestamps, and I am now able to verify that all GR events are are in coincidence with cagra events, as expected with the fake timestamps --- histos/MakeANLHistos.cxx | 24 +++++++++++++++++-- include/TTreeSource.h | 5 ++-- .../TGrandRaiden/TGrandRaidenHit.cxx | 2 +- makefile | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index db97973f..5a844a17 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -43,9 +43,29 @@ void MakeHistograms(TRuntimeObjects& obj) { TList *list = &(obj.GetObjects()); int numobj = list->GetSize(); - // totalctr++; if (cagra && gr) { - obj.FillHistogram("nCoin",10,-1,1,0); + 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; + //cout << "Coin: " << ncoin << endl; + } else if (gr) { + for (auto& hit : *gr) { + cout <<"Single GR: " << hit.Timestamp << endl; + } + } + + + if (gr) { + int totalhits = 0; + for (auto& hit : *gr) { totalhits++; } + static int ncoin = 0; + ncoin+=totalhits; + //cout << "GR only: " << ncoin << endl; } if (gr) { diff --git a/include/TTreeSource.h b/include/TTreeSource.h index e517e800..4a4208a0 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -11,7 +11,7 @@ #include "TRawSource.h" #include "TChain.h" -#include "rootalyze.h" +#include "RCNPEvent.h" templateClassImp(TTreeSource) @@ -124,9 +124,8 @@ class TTreeSource : public TRawEventSource { std::cout << "End of time stamps" << std::endl; return -1; } - fEvent->SetTimestamp(timestamps.front()+1); + fEvent->SetTimestamp(timestamps.front()); timestamps.pop(); - event.SetFragmentTimestamp(fEvent->GetTimestamp()); // increment the event count fCurrentEntry++; diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 9a0b74a5..70baa135 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -1,6 +1,6 @@ #include "TGrandRaidenHit.h" #include "TGRUTOptions.h" -#include "rootalyze.h" +#include "RCNPEvent.h" #include "TSmartBuffer.h" ClassImp(TGrandRaidenHit) diff --git a/makefile b/makefile index 8095e509..319b8ed6 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ PLATFORM:=$(PLATFORM) GRANAPATH = ../GRAnalyzer/analyzer GRANALYZER = $(realpath $(GRANAPATH)/../lib) -INCLUDES = include $(GRANAPATH)/include +INCLUDES = include $(GRANAPATH)/include $(GRANAPATH)/libRCNPEvent/include CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter LINKFLAGS_PREFIX = LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent From b0e8ccea094b7e3e104ac436e40d092d688f3623 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 3 Jun 2016 18:29:15 -0400 Subject: [PATCH 29/94] Added RF to TGrandRaidenHit, also more histos. RCNPEvent->T in templated TTreeSource class. Added back print message in TDataLoop --- histos/MakeANLHistos.cxx | 40 +++++++++---------- include/TGrandRaidenHit.h | 3 +- include/TTreeSource.h | 5 ++- .../TGrandRaiden/TGrandRaidenHit.cxx | 1 + libraries/TLoops/TDataLoop.cxx | 5 +++ 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/histos/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx index 5a844a17..17fc34eb 100644 --- a/histos/MakeANLHistos.cxx +++ b/histos/MakeANLHistos.cxx @@ -16,6 +16,8 @@ #include "TCagra.h" #include "TGrandRaiden.h" +#define BAD_NUM -441441 + //#include "TChannel.h" //#include "GValue.h" @@ -55,7 +57,7 @@ void MakeHistograms(TRuntimeObjects& obj) { //cout << "Coin: " << ncoin << endl; } else if (gr) { for (auto& hit : *gr) { - cout <<"Single GR: " << hit.Timestamp << endl; + //cout <<"Single GR: " << hit.Timestamp << endl; } } @@ -71,30 +73,24 @@ void MakeHistograms(TRuntimeObjects& obj) { if (gr) { for (auto& hit : *gr) { auto adc = hit.GetADC(); - for (int i=0; i<4; i++) { - stream.str(""); stream << "GR_ADC" << i; - obj.FillHistogram(stream.str().c_str(), 1000,0,1000, adc[i]); + if (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); + } } } } - // cout << " GR TS: " << gr->Timestamp() << " " << gr->Size() << endl; - // cout << " CAGRA TS: " << cagra->Timestamp() << " " << cagra->Size() << endl; - // debugctr=0; - // } else { - // cout << "Single "; - // if (cagra) { - // cout << "Cagra" << endl; - // cout << cagra->Timestamp() << endl; - // } else if (gr) { - // cout << "Grand Raiden" << endl; - // cout << gr->Timestamp() << endl; - // } - // debugctr+=1; - // } - // if (debugctr>1e3){ - // cout << totalctr << endl; - // exit(1); - // } + if(cagra) { //cout << "Size: " << cagra->Size() << endl; diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index 45762fc4..6a8c6c04 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -19,13 +19,14 @@ class TGrandRaidenHit : public TDetectorHit { 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; ClassDef(TGrandRaidenHit,1); }; diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 4a4208a0..a01ab688 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -114,7 +114,7 @@ class TTreeSource : public TRawEventSource { // create a small memory buffer to hold the pointer to the current entry char* ptrbytes = (char*)calloc(1,sizeof(fEvent)); // copy the address stored in fEvent into the temporary buffer - *reinterpret_cast(ptrbytes) = fEvent; + *reinterpret_cast(ptrbytes) = fEvent; // prepare the events smart buffer payload TSmartBuffer eventbuffer(ptrbytes,sizeof(fEvent)); // set the pointer address into the buffer @@ -125,8 +125,9 @@ class TTreeSource : public TRawEventSource { return -1; } fEvent->SetTimestamp(timestamps.front()); + event.SetFragmentTimestamp(timestamps.front()); timestamps.pop(); - event.SetFragmentTimestamp(fEvent->GetTimestamp()); + // increment the event count fCurrentEntry++; //fEvent = nullptr; diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 70baa135..826490c7 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -26,6 +26,7 @@ void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ std::copy(adc->begin(),adc->end(),&ADC[0]); } Timestamp = event->GetTimestamp(); + RF = event->GR_RF(0); buf.Advance(sizeof(event)); if (event) delete event; diff --git a/libraries/TLoops/TDataLoop.cxx b/libraries/TLoops/TDataLoop.cxx index 2ca214ed..51ebda5e 100644 --- a/libraries/TLoops/TDataLoop.cxx +++ b/libraries/TLoops/TDataLoop.cxx @@ -62,6 +62,11 @@ bool TDataLoop::Iteration() { output_queue.Push(evt); return true; } else { + static TRawEventSource* source_ptr = NULL; + if (source_ptr != source) { + std::cout << "Finished reading source" << std::endl; + source_ptr = source; + } // Nothing returned this time, but I might get something next time. std::this_thread::sleep_for(std::chrono::milliseconds(1000)); return true; From 77547e2af8ffe75c6601fee17abc4a564af59d69 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 5 Jun 2016 21:05:00 -0400 Subject: [PATCH 30/94] Added source description and status to TTreeSource, data throughput is not a measure of totale filesize in this case, since the only value passed through is the ptr to the event created via the TChain::GetEntry call. --- include/TTreeSource.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/TTreeSource.h b/include/TTreeSource.h index a01ab688..f77aa46e 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -10,6 +10,7 @@ #include "TRawEvent.h" #include "TRawSource.h" #include "TChain.h" +#include "TFile.h" #include "RCNPEvent.h" @@ -59,7 +60,7 @@ class TTreeSource : public TRawEventSource { fNumEvents = fChain.GetEntries(); - fFileSize = fNumEvents*sizeof(T); + fFileSize = fNumEvents*sizeof(T*); fEvent = new T(); @@ -70,8 +71,14 @@ class TTreeSource : public TRawEventSource { ~TTreeSource() {;} - virtual std::string Status() const {return std::string("");} - virtual std::string SourceDescription() const {return std::string("");} + virtual std::string Status() const { + return Form("%s: %s %8.2f MB given %s / %s %8.2f MB total %s => %s %3.02f MB/s processed %s", + SourceDescription().c_str(), + DCYAN, GetBytesGiven()/1e6, RESET_COLOR, + BLUE, GetFileSize()/1e6, RESET_COLOR, + GREEN, GetAverageRate()/1e6, RESET_COLOR); + } + virtual std::string SourceDescription() const {return "File: "+std::string(fChain.GetCurrentFile()->GetName());} kFileType GetFileType() const { return fFileType; } From 1dbc95f77860268b6e400baffd8210838e5c56b9 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 5 Jun 2016 21:50:55 -0400 Subject: [PATCH 31/94] Changed initialization of fEvent in TTreeSource --- include/TTreeSource.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/TTreeSource.h b/include/TTreeSource.h index f77aa46e..aaf8f4e8 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -50,7 +50,7 @@ class TTreeSource : public TRawEventSource { // fChain.SetBranchAddress(eventclassname, &fEvent); // } TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) - : fChain(treename), fCurrentEntry(0) { + : fChain(treename), fEvent(0), fCurrentEntry(0) { assert(file_type == kFileType::ROOT_DATA); @@ -62,8 +62,6 @@ class TTreeSource : public TRawEventSource { fFileSize = fNumEvents*sizeof(T*); - fEvent = new T(); - fChain.SetBranchAddress(eventclassname, &fEvent); LoadFakeTimestamps(); From 72642c520c1aed35a43cc6c60a5faeefe4612e02 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 6 Jun 2016 09:20:31 -0400 Subject: [PATCH 32/94] Now link against new libGRAnalyzer.so for dynamic calling of GR event builder --- makefile | 6 +++--- util/granalyzer.cxx | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 util/granalyzer.cxx diff --git a/makefile b/makefile index 319b8ed6..493581cf 100644 --- a/makefile +++ b/makefile @@ -8,10 +8,10 @@ PLATFORM:=$(PLATFORM) GRANAPATH = ../GRAnalyzer/analyzer GRANALYZER = $(realpath $(GRANAPATH)/../lib) -INCLUDES = include $(GRANAPATH)/include $(GRANAPATH)/libRCNPEvent/include -CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter +INCLUDES = include $(GRANAPATH)/include $(GRANAPATH)/libRCNPEvent/include $(GRANAPATH)/libGRAnalyzer/include +CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter -D`uname -m` -D`uname -s` -DLinux86 -Df2cFortran -DUSE_PAW LINKFLAGS_PREFIX = -LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent +LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent -lGRAnalyzer -L$(realpath $(GRANAPATH)/lib) -lpacklib -lm -lgfortran -lnsl SRC_SUFFIX = cxx # EVERYTHING PAST HERE SHOULD WORK AUTOMATICALLY diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx new file mode 100644 index 00000000..cb1dc4fc --- /dev/null +++ b/util/granalyzer.cxx @@ -0,0 +1,9 @@ +#include "GRAnalyzer.h" + +/* main */ +int main() +{ + start_analyzer("./datatest/run6106.bld"); + return 0; +} + From 9df71baec211fc82f915533b97f488fbce119fbc Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 6 Jun 2016 13:37:44 -0400 Subject: [PATCH 33/94] Added Grand Raiden analyzer submodule for linking against RCNP routines --- .gitmodules | 3 +++ GRAnalyzer | 1 + makefile | 28 +++++++++++++++++++++------- 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 .gitmodules create mode 160000 GRAnalyzer diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..929fa390 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "GRAnalyzer"] + path = GRAnalyzer + url = https://github.com/CAGRA-GrandRaiden/GRAnalyzer diff --git a/GRAnalyzer b/GRAnalyzer new file mode 160000 index 00000000..ebf8f581 --- /dev/null +++ b/GRAnalyzer @@ -0,0 +1 @@ +Subproject commit ebf8f581f14a61f2f76840098785b6231932b7e3 diff --git a/makefile b/makefile index 493581cf..7c922afd 100644 --- a/makefile +++ b/makefile @@ -6,12 +6,22 @@ PLATFORM:=$(PLATFORM) # EDIT THIS SECTION -GRANAPATH = ../GRAnalyzer/analyzer +# MAKE_PID := $(shell echo $$PPID) +# MAKECMD := $(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)") +# JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(MAKECMD))) +# THREADS := $(subst -j,,$(JOB_FLAG)) +# ifeq ($(strip $(THREADS)),) +# THREADS := 1 +# endif + + +GRANAPATH = ./GRAnalyzer/analyzer GRANALYZER = $(realpath $(GRANAPATH)/../lib) +GRLINKFLAGS = -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent -lGRAnalyzer -L$(realpath $(GRANAPATH)/lib) -lpacklib -lm -lgfortran -lnsl INCLUDES = include $(GRANAPATH)/include $(GRANAPATH)/libRCNPEvent/include $(GRANAPATH)/libGRAnalyzer/include CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter -D`uname -m` -D`uname -s` -DLinux86 -Df2cFortran -DUSE_PAW LINKFLAGS_PREFIX = -LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent -lGRAnalyzer -L$(realpath $(GRANAPATH)/lib) -lpacklib -lm -lgfortran -lnsl +LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 SRC_SUFFIX = cxx # EVERYTHING PAST HERE SHOULD WORK AUTOMATICALLY @@ -84,7 +94,7 @@ run_and_test =@printf "%b%b%b" " $(3)$(4)$(5)" $(notdir $(2)) "$(NO_COLOR)\r"; rm -f $(2).log $(2).error endif -all: include/GVersion.h $(EXECUTABLES) $(LIBRARY_OUTPUT) bin/grutinizer-config bin/gadd_fast.py $(HISTOGRAM_SO) +all: include/GVersion.h libGRAnalyzer $(EXECUTABLES) $(LIBRARY_OUTPUT) bin/grutinizer-config bin/gadd_fast.py $(HISTOGRAM_SO) @printf "$(OK_COLOR)Compilation successful, $(WARN_COLOR)woohoo!$(NO_COLOR)\n" docs: @@ -93,11 +103,11 @@ docs: bin/%: util/% | bin @ln -sf ../$< $@ -bin/grutinizer: $(MAIN_O_FILES) | $(LIBRARY_OUTPUT) bin - $(call run_and_test,$(CPP) $^ -o $@ $(LINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) +bin/grutinizer: $(MAIN_O_FILES) | $(LIBRARY_OUTPUT) libGRAnalyzer bin + $(call run_and_test,$(CPP) $^ -o $@ $(LINKFLAGS) $(GRLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) -bin/%: .build/util/%.o | $(LIBRARY_OUTPUT) bin - $(call run_and_test,$(CPP) $< -o $@ $(LINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) +bin/%: .build/util/%.o | $(LIBRARY_OUTPUT) libGRAnalyzer bin + $(call run_and_test,$(CPP) $< -o $@ $(LINKFLAGS) $(GRLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) bin: @mkdir -p $@ @@ -108,6 +118,9 @@ include/GVersion.h: .git/HEAD .git/index libraries/lib%.so: .build/histos/%.o $(call run_and_test,$(CPP) -fPIC $^ $(SHAREDSWITCH)lib$*.so $(ROOT_LIBFLAGS) -o $@,$@,$(BLD_COLOR),$(BLD_STRING),$(OBJ_COLOR) ) +libGRAnalyzer: + $(MAKE) -C GRAnalyzer + # Functions for determining the files included in a library. # All src files in the library directory are included. # If a LinkDef.h file is present in the library directory, @@ -150,6 +163,7 @@ clean: @-$(RM) -rf bin @-$(RM) -f $(LIBRARY_OUTPUT) @-$(RM) -f libraries/*.so + @-$(MAKE) clean -C GRAnalyzer cleaner: clean @printf "\nEven more clean up\n\n" From f3ad8569bed6d692eada56ee06b5aa92d374a5f5 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 6 Jun 2016 13:39:11 -0400 Subject: [PATCH 34/94] Removed commented lines in makefile --- makefile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/makefile b/makefile index 7c922afd..67e16085 100644 --- a/makefile +++ b/makefile @@ -6,15 +6,6 @@ PLATFORM:=$(PLATFORM) # EDIT THIS SECTION -# MAKE_PID := $(shell echo $$PPID) -# MAKECMD := $(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)") -# JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(MAKECMD))) -# THREADS := $(subst -j,,$(JOB_FLAG)) -# ifeq ($(strip $(THREADS)),) -# THREADS := 1 -# endif - - GRANAPATH = ./GRAnalyzer/analyzer GRANALYZER = $(realpath $(GRANAPATH)/../lib) GRLINKFLAGS = -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent -lGRAnalyzer -L$(realpath $(GRANAPATH)/lib) -lpacklib -lm -lgfortran -lnsl From cdd053cc51fb1b24aa86f71d981e8bc1c5a71b13 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 6 Jun 2016 13:57:06 -0400 Subject: [PATCH 35/94] Added lines to clean rule in makefile --- GRAnalyzer | 2 +- makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index ebf8f581..279bbfd1 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit ebf8f581f14a61f2f76840098785b6231932b7e3 +Subproject commit 279bbfd10f098205a152c497252323abbef8c3fe diff --git a/makefile b/makefile index 67e16085..da0b7985 100644 --- a/makefile +++ b/makefile @@ -149,12 +149,12 @@ $(foreach lib,$(LIBRARY_DIRS),$(eval $(call library_template,$(lib)))) -include $(shell find .build -name '*.d' 2> /dev/null) clean: - @printf "\n$(WARN_COLOR)Cleaning up$(NO_COLOR)\n\n" + @printf "\n$(WARN_COLOR)Cleaning GRUTinizer$(NO_COLOR)\n\n" @-$(RM) -rf .build @-$(RM) -rf bin @-$(RM) -f $(LIBRARY_OUTPUT) @-$(RM) -f libraries/*.so - @-$(MAKE) clean -C GRAnalyzer + @-$(MAKE) clean -sC GRAnalyzer cleaner: clean @printf "\nEven more clean up\n\n" From b3594dccc8230cdc6eff806977b65a44297894ba Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 6 Jun 2016 17:38:10 -0400 Subject: [PATCH 36/94] Updated submodule and granalyzer.cxx example --- GRAnalyzer | 2 +- util/granalyzer.cxx | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index 279bbfd1..e78fee35 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 279bbfd10f098205a152c497252323abbef8c3fe +Subproject commit e78fee356b24d39d091936273a5ca326f3b8e347 diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index cb1dc4fc..847846fc 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -1,9 +1,31 @@ -#include "GRAnalyzer.h" +#include +#include +#include + +#include "GRUTinizerInterface.h" +#include "ThreadsafeQueue.h" +#include "RCNPEvent.h" /* main */ int main() { - start_analyzer("./datatest/run6106.bld"); - return 0; + ThreadsafeQueue gr_queue; + std::thread grloop(StartGRAnalyzer,"./datatest/run6106.bld",[&](RCNPEvent* event){ + gr_queue.Push(*event); + }); + grloop.join(); + + return 0; } +// std::promise flag; +// std::thread grloop([&](){ StartGRAnalyzer("./datatest/run6106.bld",[&](RCNPEvent* event){ +// gr_queue.Push(*event); +// }); flag.set_value(); }); +// std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + +// auto future = flag.get_future(); +// while(future.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready) { +// std::cout << gr_queue.Size() << std::endl; +// } +// grloop.join(); From 2bb151356cfc8ca1286d675b699e0dc91722c524 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 6 Jun 2016 23:33:12 -0400 Subject: [PATCH 37/94] Added support for RCNPEvent's in ThreadsafeQueue, and also adjusted the granalyzer example so that a pipe command is passed to start_analyzer which can be used to cat a file in, or to launch the online data stream. --- GRAnalyzer | 2 +- libraries/TLoops/ThreadsafeQueue.cxx | 6 ++++++ util/granalyzer.cxx | 11 +++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index e78fee35..adb10a27 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit e78fee356b24d39d091936273a5ca326f3b8e347 +Subproject commit adb10a278f5589f1676f5c2718d18a431673633a diff --git a/libraries/TLoops/ThreadsafeQueue.cxx b/libraries/TLoops/ThreadsafeQueue.cxx index aed974ee..df6dcc7a 100644 --- a/libraries/TLoops/ThreadsafeQueue.cxx +++ b/libraries/TLoops/ThreadsafeQueue.cxx @@ -4,6 +4,7 @@ #include "TUnpackedEvent.h" +#include "RCNPEvent.h" template<> int ThreadsafeQueue::ObjectSize(TRawEvent& event){ return event.GetTotalSize(); @@ -23,3 +24,8 @@ template<> int ThreadsafeQueue::ObjectSize(TUnpackedEvent*& event) { return event->Size(); } + +template<> +int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { + return event.data.size(); +} diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index 847846fc..3409fd2a 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -1,18 +1,25 @@ #include #include #include - +#include #include "GRUTinizerInterface.h" #include "ThreadsafeQueue.h" #include "RCNPEvent.h" +using namespace std; /* main */ int main() { + const char* filename = "./datatest/run1001.bld"; ThreadsafeQueue gr_queue; - std::thread grloop(StartGRAnalyzer,"./datatest/run6106.bld",[&](RCNPEvent* event){ + stringstream stream; stream.str(""); stream << "cat " << filename; + std::thread grloop(StartGRAnalyzer,stream.str().c_str(),[&](RCNPEvent* event){ gr_queue.Push(*event); }); + RCNPEvent data; + while (gr_queue.Pop(data,0)) { + + } grloop.join(); return 0; From f359708479aa0dac155d92eec24dc87e42b9c886 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 7 Jun 2016 01:51:20 -0400 Subject: [PATCH 38/94] Added new source for raw RCNP BLD files. GRUTinizer calls GRAnalyzer which prepares RCNPEvents that are pushed on to a threadsafe queue and accessed by TRCNPSource. Added a TRCNPEvent which adds an RCNPEvent ptr to a normal TRawEvent. Added needed logic for this new raw file type. Need to find a way to differential between file runs and online runs with router_save, and to properly form pipe command for each scenario. --- include/TGRUTTypes.h | 1 + include/TRCNPEvent.h | 28 ++++ include/TRCNPSource.h | 123 ++++++++++++++++++ .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 11 +- .../TGrandRaiden/TGrandRaidenHit.cxx | 20 +-- libraries/TGRUTint/TGRUTOptions.cxx | 3 + libraries/TLoops/TUnpackingLoop.cxx | 9 ++ libraries/TRCNPFormat/LinkDef.h | 12 ++ libraries/TRCNPFormat/TRCNPEvent.cxx | 35 +++++ libraries/TRawFormat/LinkDef.h | 3 +- libraries/TRawFormat/TRawEvent.cxx | 4 + libraries/TRawFormat/TRawEventSource.cxx | 4 + 12 files changed, 237 insertions(+), 16 deletions(-) create mode 100644 include/TRCNPEvent.h create mode 100644 include/TRCNPSource.h create mode 100644 libraries/TRCNPFormat/LinkDef.h create mode 100644 libraries/TRCNPFormat/TRCNPEvent.cxx diff --git a/include/TGRUTTypes.h b/include/TGRUTTypes.h index 13c4fcc2..058e8b90 100644 --- a/include/TGRUTTypes.h +++ b/include/TGRUTTypes.h @@ -38,6 +38,7 @@ enum kFileType { GRETINA_MODE2 = 2, GRETINA_MODE3 = 3, ANL_RAW = 4, + RCNP_BLD = 50, ROOT_DATA = 256, ROOT_MACRO = 257, CALIBRATED = 512, diff --git a/include/TRCNPEvent.h b/include/TRCNPEvent.h new file mode 100644 index 00000000..29755e66 --- /dev/null +++ b/include/TRCNPEvent.h @@ -0,0 +1,28 @@ +#ifndef _TRCNPEVENT_H_ +#define _TRCNPEVENT_H_ + +#include "TRawEvent.h" +//#include "RCNPEvent.h" + +class RCNPEvent; + +class TRCNPEvent : public TRawEvent { +public: + TRCNPEvent(); + TRCNPEvent(const TRawEvent&); + virtual ~TRCNPEvent(); + + long GetTimestamp() const; + + const char* GetPayload() const; + TSmartBuffer GetPayloadBuffer() const; + + virtual void Clear(Option_t *opt =""); + virtual void Print(Option_t *opt ="") const; + + RCNPEvent* event; + + ClassDef(TRCNPEvent, 0); +}; + +#endif /* _TRCNPEVENT_H_ */ diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h new file mode 100644 index 00000000..9446c7e2 --- /dev/null +++ b/include/TRCNPSource.h @@ -0,0 +1,123 @@ +#ifndef _TRCNPSOURCE_H_ +#define _TRCNPSOURCE_H_ + +#include +#include +#include +#include +#include + +#ifndef __CINT__ +#include +#include +#endif + +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +#include "TChain.h" +#include "TFile.h" + +#include "TRCNPEvent.h" +#include "RCNPEvent.h" +#include "ThreadsafeQueue.h" +#include "GRUTinizerInterface.h" + +class TRCNPSource : public TRawEventSource { +public: + + TRCNPSource(const char* Command, kFileType file_type) + : fCommand(Command), fFileType(file_type) { + + assert(file_type == kFileType::RCNP_BLD); + +#ifndef __CINT__ + std::thread grloop(StartGRAnalyzer,Command,[&](RCNPEvent* event){ + gr_queue.Push(*event); + }); +#endif + + LoadFakeTimestamps(); + } + TRCNPSource(TRCNPSource& source) { ; } + + ~TRCNPSource() {;} + + virtual std::string Status() const { + return Form("%s: %s %8.2f MB given %s / %s %8.2f MB total %s => %s %3.02f MB/s processed %s", + SourceDescription().c_str(), + DCYAN, GetBytesGiven()/1e6, RESET_COLOR, + BLUE, GetFileSize()/1e6, RESET_COLOR, + GREEN, GetAverageRate()/1e6, RESET_COLOR); + } + virtual std::string SourceDescription() const {return "File: "+std::string("RCNP_BLD: ")+std::string(fCommand);} + + + kFileType GetFileType() const { return fFileType; } + long GetFileSize() const { return fFileSize; } + + virtual void Reset() {;} + +protected: + void SetFileSize(long file_size) { fFileSize = file_size; } + void LoadFakeTimestamps() { + + std::string line; std::stringstream stream; ULong_t ts; + ifstream file ("/projects/ceclub/sullivan/cagragr/GRUTinizer/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(); + } + } + +private: + TRCNPSource() {;} + virtual int GetEvent(TRawEvent& event) { + TRCNPEvent rcnp_evt; + rcnp_evt.event = new RCNPEvent; + if (gr_queue.Pop(*rcnp_evt.event,0) == -1 ){ + return -1; + } + + event = rcnp_evt; + event.SetFileType(fFileType); + + // if there are no more events, signal termination + //if (fCurrentEntry == fNumEvents) { return -1; } + + + + // set the timestamp of the ttree event + if (timestamps.size()==0) { + std::cout << "End of time stamps" << std::endl; + return -1; + } + event.SetFragmentTimestamp(timestamps.front()); + timestamps.pop(); + + // increment the event count + //fCurrentEntry++; + //fEvent = nullptr; + return sizeof(*rcnp_evt.event); + } + + const char* fCommand; + kFileType fFileType; + long fFileSize; + ThreadsafeQueue gr_queue; + + std::queue timestamps; + + ClassDef(TRCNPSource,0); +}; + +#endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index 9025c6fe..cba8471c 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -1,5 +1,5 @@ #include "TGrandRaiden.h" -#include "TRawEvent.h" +#include "TRCNPEvent.h" TGrandRaiden::TGrandRaiden(){ Clear(); @@ -23,11 +23,12 @@ void TGrandRaiden::InsertHit(const TDetectorHit& hit){ int TGrandRaiden::BuildHits(std::vector& raw_data){ for(auto& event : raw_data){ - SetTimestamp(event.GetTimestamp()); + auto rcnp_evt = (TRCNPEvent&)event; + SetTimestamp(rcnp_evt.GetTimestamp()); TGrandRaidenHit hit; - auto buf = event.GetBuffer(); - hit.BuildFrom(buf); - hit.SetTimestamp(event.GetTimestamp()); + //auto buf = rcnp_evt.GetBuffer(); + //hit.BuildFrom(buf); + hit.SetTimestamp(rcnp_evt.GetTimestamp()); InsertHit(hit); } return Size(); diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 826490c7..dfc2a081 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -20,16 +20,16 @@ void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ Clear(); - 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); - - buf.Advance(sizeof(event)); - if (event) delete event; + // 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); + + // buf.Advance(sizeof(event)); + // if (event) delete event; } diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index 76e017c2..b2808938 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -237,6 +237,8 @@ kFileType TGRUTOptions::DetermineFileType(const std::string& filename) const{ return kFileType::PRESETWINDOW; } else if (ext == "cuts") { return kFileType::CUTS_FILE; + } else if (ext == "bld") { + return kFileType::RCNP_BLD; } else if (ext.find("gtd")!=std::string::npos) { return kFileType::ANL_RAW; } else { @@ -248,6 +250,7 @@ bool TGRUTOptions::FileAutoDetect(const std::string& filename) { switch(DetermineFileType(filename)){ case kFileType::NSCL_EVT: case kFileType::ANL_RAW: + case kFileType::RCNP_BLD: case kFileType::GRETINA_MODE2: case kFileType::GRETINA_MODE3: input_raw_files.push_back(filename); diff --git a/libraries/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index ba292c73..04f09df7 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -9,6 +9,7 @@ #include "TGEBEvent.h" #include "TGRUTOptions.h" #include "TNSCLEvent.h" +#include "TRCNPEvent.h" #include "TBuildingLoop.h" #include "TDetectorEnv.h" @@ -69,10 +70,18 @@ bool TUnpackingLoop::Iteration(){ HandleGEBData(geb_event); } break; + case kFileType::RCNP_BLD: + { + //TRCNPEvent& evt = (TRCNPEvent&)raw_event; + fOutputEvent->AddRawData(raw_event, kDetectorSystems::GRAND_RAIDEN); + //consider adding HandleRCNPData + } + break; case kFileType::ROOT_DATA: { fOutputEvent->AddRawData(raw_event, kDetectorSystems::GRAND_RAIDEN); } + break; default: break; } diff --git a/libraries/TRCNPFormat/LinkDef.h b/libraries/TRCNPFormat/LinkDef.h new file mode 100644 index 00000000..605e27a3 --- /dev/null +++ b/libraries/TRCNPFormat/LinkDef.h @@ -0,0 +1,12 @@ +// TRCNPEvent.h + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ nestedclasses; + +#pragma link C++ class TRCNPEvent+; + +#endif diff --git a/libraries/TRCNPFormat/TRCNPEvent.cxx b/libraries/TRCNPFormat/TRCNPEvent.cxx new file mode 100644 index 00000000..8c1fc56a --- /dev/null +++ b/libraries/TRCNPFormat/TRCNPEvent.cxx @@ -0,0 +1,35 @@ +#include "TRCNPEvent.h" +#include "RCNPEvent.h" + +#include "TString.h" + + +ClassImp(TRCNPEvent) + +TRCNPEvent::TRCNPEvent() { } + +TRCNPEvent::TRCNPEvent(const TRawEvent &raw) { + raw.Copy(*this); +} + +TRCNPEvent::~TRCNPEvent() { } + +Long_t TRCNPEvent::GetTimestamp() const { + return event->GetTimestamp(); +} + +const char* TRCNPEvent::GetPayload() const { + return fBody.GetData() + sizeof(Long_t); +} + +TSmartBuffer TRCNPEvent::GetPayloadBuffer() const { + return fBody; +} + +void TRCNPEvent::Clear(Option_t *opt) { + TRawEvent::Clear(opt); +} + +void TRCNPEvent::Print(Option_t *opt) const { + TRawEvent::Print(opt); +} diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index ae85534d..6ba2550b 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 +// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TOrderedRawFile.h TSequentialRawFile.h TTreeSource.h TRCNPSource.h #ifdef __CINT__ @@ -30,6 +30,7 @@ #pragma link C++ class TSequentialRawFile+; #pragma link C++ class TTreeSource+; +#pragma link C++ class TRCNPSource+; #pragma link C++ enum TRawEvent::ArgonneType; diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index fd455894..faaeec20 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -10,6 +10,8 @@ #include "TGEBEvent.h" #include "TNSCLEvent.h" +#include "TRCNPEvent.h" +#include "RCNPEvent.h" ClassImp(TRawEvent) @@ -117,6 +119,8 @@ Long_t TRawEvent::GetTimestamp() const { case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetTimestamp(); + case RCNP_BLD: + return ((TRCNPEvent*)this)->event->GetTimestamp(); default: ; diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index 7aa4106f..d930bf00 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -1,5 +1,7 @@ #include "TRawSource.h" +#include "TRCNPSource.h" + #include "TTreeSource.h" #include @@ -91,6 +93,8 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, source = new TRawEventGZipSource(filename, file_type); } else if (hasSuffix(filename,".root")){ source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type); + } else if (hasSuffix(filename,".bld")){ + source = new TRCNPSource(filename, file_type); // If it is an in-progress file, open it that way } else if (is_online) { source = new TRawEventOnlineFileSource(filename, file_type); From d57984ad59c4bf2a013617c2cfaaf1f0a57d8875 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 8 Jun 2016 11:11:01 -0400 Subject: [PATCH 39/94] Now spawn std::async thread which returns a future that can be used to test if the GRAnalyzer is done. Still need a way to stop the GR thread while in progress if an early termination is desired. Added logic to Pop events off the rcnp_queue in TRCNPSource. In offline mode the logic is set up to perform a second _saving throw_ pop if the first was unsuccessful. If the second is also unsuccessful and if the GR ana thread is not finished, it throws an exception. In online mode it will simply continue to ask for events and so this logic is not needed. But as mentioned above, we still need a flag to signal to the GR analyzer thread to terminate if we are closing up early (this is especially true for online analysis). Bug fix: There is an issue with the TSmartBuffer destructor that needs investigation. I am able to avoid a segfault by declaring the smartbuffer in TTreeSource and TRCNPSource on the heap, and letting it leak out of scope. Needs further investigation. --- GRAnalyzer | 2 +- include/TRCNPSource.h | 69 ++++++++++++++----- include/TTreeSource.h | 4 +- include/ThreadsafeQueue.h | 6 ++ .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 19 +++-- .../TGrandRaiden/TGrandRaidenHit.cxx | 13 ++++ libraries/TLoops/ThreadsafeQueue.cxx | 5 ++ libraries/TRCNPFormat/TRCNPEvent.cxx | 2 +- libraries/TRawFormat/TRawEventSource.cxx | 8 ++- util/granalyzer.cxx | 2 +- 10 files changed, 100 insertions(+), 30 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index adb10a27..697f35c6 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit adb10a278f5589f1676f5c2718d18a431673633a +Subproject commit 697f35c6d921b2f59d59e08a0b9a11d881509b1f diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h index 9446c7e2..c68b8516 100644 --- a/include/TRCNPSource.h +++ b/include/TRCNPSource.h @@ -6,9 +6,11 @@ #include #include #include +#include #ifndef __CINT__ #include +#include #include #endif @@ -32,8 +34,8 @@ class TRCNPSource : public TRawEventSource { assert(file_type == kFileType::RCNP_BLD); #ifndef __CINT__ - std::thread grloop(StartGRAnalyzer,Command,[&](RCNPEvent* event){ - gr_queue.Push(*event); + fFuture = std::async(std::launch::async,StartGRAnalyzer,Command,[&](RCNPEvent* event){ + rcnp_queue.Push(event); }); #endif @@ -44,13 +46,13 @@ class TRCNPSource : public TRawEventSource { ~TRCNPSource() {;} virtual std::string Status() const { - return Form("%s: %s %8.2f MB given %s / %s %8.2f MB total %s => %s %3.02f MB/s processed %s", + return Form("%s: %s %8.2f MB given %s / %s Unknown MB total %s => %s %3.02f MB/s processed %s", SourceDescription().c_str(), DCYAN, GetBytesGiven()/1e6, RESET_COLOR, - BLUE, GetFileSize()/1e6, RESET_COLOR, + BLUE, RESET_COLOR, GREEN, GetAverageRate()/1e6, RESET_COLOR); } - virtual std::string SourceDescription() const {return "File: "+std::string("RCNP_BLD: ")+std::string(fCommand);} + virtual std::string SourceDescription() const {return "File: "+std::string("RCNP_BLD: ")+fCommand;} kFileType GetFileType() const { return fFileType; } @@ -82,38 +84,67 @@ class TRCNPSource : public TRawEventSource { private: TRCNPSource() {;} virtual int GetEvent(TRawEvent& event) { - TRCNPEvent rcnp_evt; - rcnp_evt.event = new RCNPEvent; - if (gr_queue.Pop(*rcnp_evt.event,0) == -1 ){ + + // TRCNPEvent* rcnp_evt = new TRCNPEvent; + RCNPEvent* rcnp;// = new RCNPEvent; + + // Try to get event from RCNP event queue + if (rcnp_queue.Pop(rcnp,200) == -1 ){ +#ifndef __CINT__ + // if offline + if (TGRUTOptions::Get()->ExitAfterSorting()) { + auto status = fFuture.wait_for(std::chrono::milliseconds(0)); + // check if RCNP analyzer is done + if (status == std::future_status::ready) { + std::cout << "RCNP analyzer thread finished ##" << std::endl; + return -1; + } else { + std::cout << "RCNP analyzer still running, awaiting data.." << std::endl; + // try again to pop an event + if (rcnp_queue.Pop(rcnp,1000) == -1) { + // if it failed again check if the RCNP analyzer is done now + status = fFuture.wait_for(std::chrono::milliseconds(1000)); + if (status == std::future_status::ready) { + return -1; + } else { + throw std::runtime_error("TRCNPSource::GetEvent GRAnalyzer loop is hung."); + } + } + } + } else { return -1; + } +#endif } - event = rcnp_evt; - event.SetFileType(fFileType); - - // if there are no more events, signal termination - //if (fCurrentEntry == fNumEvents) { return -1; } + // 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); // 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(); - // increment the event count - //fCurrentEntry++; - //fEvent = nullptr; - return sizeof(*rcnp_evt.event); + return sizeof(rcnp); } - const char* fCommand; + const std::string fCommand; kFileType fFileType; long fFileSize; - ThreadsafeQueue gr_queue; + #ifndef __CINT__ + std::future fFuture; + #endif + ThreadsafeQueue rcnp_queue; std::queue timestamps; diff --git a/include/TTreeSource.h b/include/TTreeSource.h index aaf8f4e8..c90de6a9 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -121,9 +121,9 @@ class TTreeSource : public TRawEventSource { // copy the address stored in fEvent into the temporary buffer *reinterpret_cast(ptrbytes) = fEvent; // prepare the events smart buffer payload - TSmartBuffer eventbuffer(ptrbytes,sizeof(fEvent)); + auto eventbuffer = new TSmartBuffer(ptrbytes,sizeof(fEvent)); // set the pointer address into the buffer - event.SetData(eventbuffer); + event.SetData(*eventbuffer); // set the timestamp of the ttree event if (timestamps.size()==0) { std::cout << "End of time stamps" << std::endl; diff --git a/include/ThreadsafeQueue.h b/include/ThreadsafeQueue.h index 7c8e7cd3..db314dbb 100644 --- a/include/ThreadsafeQueue.h +++ b/include/ThreadsafeQueue.h @@ -20,6 +20,7 @@ template class ThreadsafeQueue { public: ThreadsafeQueue(); + ThreadsafeQueue(size_t maxsize); ~ThreadsafeQueue(); int Push(T obj); int Pop(T& output, int millisecond_wait = 1000); @@ -51,6 +52,11 @@ ThreadsafeQueue::ThreadsafeQueue() : max_queue_size(50000), items_in_queue(0), items_pushed(0), items_popped(0) { } +template +ThreadsafeQueue::ThreadsafeQueue(size_t maxsize) + : max_queue_size(maxsize), + items_in_queue(0), items_pushed(0), items_popped(0) { } + template ThreadsafeQueue::~ThreadsafeQueue() { } diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index cba8471c..fe341000 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -23,13 +23,22 @@ void TGrandRaiden::InsertHit(const TDetectorHit& hit){ int TGrandRaiden::BuildHits(std::vector& raw_data){ for(auto& event : raw_data){ - auto rcnp_evt = (TRCNPEvent&)event; - SetTimestamp(rcnp_evt.GetTimestamp()); + SetTimestamp(event.GetTimestamp()); TGrandRaidenHit hit; - //auto buf = rcnp_evt.GetBuffer(); - //hit.BuildFrom(buf); - hit.SetTimestamp(rcnp_evt.GetTimestamp()); + auto buf = event.GetBuffer(); + hit.BuildFrom(buf); + 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); } return Size(); } diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index dfc2a081..0635d316 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -30,6 +30,19 @@ void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ // buf.Advance(sizeof(event)); // if (event) delete event; + + + 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); + + buf.Advance(sizeof(event)); + if (event) delete event; + } diff --git a/libraries/TLoops/ThreadsafeQueue.cxx b/libraries/TLoops/ThreadsafeQueue.cxx index df6dcc7a..eb4cb194 100644 --- a/libraries/TLoops/ThreadsafeQueue.cxx +++ b/libraries/TLoops/ThreadsafeQueue.cxx @@ -29,3 +29,8 @@ template<> int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { return event.data.size(); } + +template<> +int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) { + return event->data.size(); +} diff --git a/libraries/TRCNPFormat/TRCNPEvent.cxx b/libraries/TRCNPFormat/TRCNPEvent.cxx index 8c1fc56a..8c4828a3 100644 --- a/libraries/TRCNPFormat/TRCNPEvent.cxx +++ b/libraries/TRCNPFormat/TRCNPEvent.cxx @@ -6,7 +6,7 @@ ClassImp(TRCNPEvent) -TRCNPEvent::TRCNPEvent() { } +TRCNPEvent::TRCNPEvent() : event(nullptr) { } TRCNPEvent::TRCNPEvent(const TRawEvent &raw) { raw.Copy(*this); diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index d930bf00..c7330de4 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -94,7 +94,13 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, } else if (hasSuffix(filename,".root")){ source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type); } else if (hasSuffix(filename,".bld")){ - source = new TRCNPSource(filename, file_type); + std::string command; + if (is_online) { + command = "router_save -s -b 1024 BLD"; + }else { + command = std::string("cat ") + std::string(filename); + } + source = new TRCNPSource(command.c_str(), file_type); // If it is an in-progress file, open it that way } else if (is_online) { source = new TRawEventOnlineFileSource(filename, file_type); diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index 3409fd2a..2643af56 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -11,7 +11,7 @@ using namespace std; int main() { const char* filename = "./datatest/run1001.bld"; - ThreadsafeQueue gr_queue; + ThreadsafeQueue gr_queue(500000); stringstream stream; stream.str(""); stream << "cat " << filename; std::thread grloop(StartGRAnalyzer,stream.str().c_str(),[&](RCNPEvent* event){ gr_queue.Push(*event); From ea757b6fce23d5e356117a46c762b4b0aec8c263 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 8 Jun 2016 15:17:54 -0400 Subject: [PATCH 40/94] Added global atomic_int that is set by StoppableThread StopAllClean function, which tells the RCNP analyzer loop to terminate so that all threads can cleanly exit. --- include/TRCNPSource.h | 6 +++++- libraries/TLoops/StoppableThread.cxx | 3 +++ util/granalyzer.cxx | 9 ++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h index c68b8516..69e83147 100644 --- a/include/TRCNPSource.h +++ b/include/TRCNPSource.h @@ -23,7 +23,11 @@ #include "TRCNPEvent.h" #include "RCNPEvent.h" #include "ThreadsafeQueue.h" + +#ifndef __CINT__ #include "GRUTinizerInterface.h" +extern atomic stop_rcnp_signal; +#endif class TRCNPSource : public TRawEventSource { public: @@ -34,7 +38,7 @@ class TRCNPSource : public TRawEventSource { assert(file_type == kFileType::RCNP_BLD); #ifndef __CINT__ - fFuture = std::async(std::launch::async,StartGRAnalyzer,Command,[&](RCNPEvent* event){ + fFuture = std::async(std::launch::async,StartGRAnalyzer,Command,&stop_rcnp_signal,[&](RCNPEvent* event){ rcnp_queue.Push(event); }); #endif diff --git a/libraries/TLoops/StoppableThread.cxx b/libraries/TLoops/StoppableThread.cxx index feefe17c..71769558 100644 --- a/libraries/TLoops/StoppableThread.cxx +++ b/libraries/TLoops/StoppableThread.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -13,6 +14,7 @@ std::map StoppableThread::fthreadmap; bool StoppableThread::status_thread_on = false; std::thread StoppableThread::status_thread; +std::atomic stop_rcnp_signal(0); int StoppableThread::GetNThreads() { return fthreadmap.size(); } @@ -94,6 +96,7 @@ std::string StoppableThread::Status() { void StoppableThread::StopAllClean() { std::cout << "Stopping each TDataLoop" << std::endl; + stop_rcnp_signal = 1; for(auto& elem : fthreadmap){ TDataLoop* data_loop = dynamic_cast(elem.second); TChainLoop* chain_loop = dynamic_cast(elem.second); diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index 2643af56..4c0a22c4 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -5,20 +5,23 @@ #include "GRUTinizerInterface.h" #include "ThreadsafeQueue.h" #include "RCNPEvent.h" - +#include using namespace std; /* main */ int main() { const char* filename = "./datatest/run1001.bld"; ThreadsafeQueue gr_queue(500000); + atomic sig(0); stringstream stream; stream.str(""); stream << "cat " << filename; - std::thread grloop(StartGRAnalyzer,stream.str().c_str(),[&](RCNPEvent* event){ + std::thread grloop(StartGRAnalyzer,stream.str().c_str(),&sig,[&](RCNPEvent* event){ gr_queue.Push(*event); }); RCNPEvent data; + static int count = 0; while (gr_queue.Pop(data,0)) { - + count++; + if (count > 1e5) { sig = 1; break; } } grloop.join(); From aca01bd81d764d639e6e96b5d31b181bc055b607 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 8 Jun 2016 15:22:28 -0400 Subject: [PATCH 41/94] Added global atomic_int that is set by StoppableThread StopAllClean function, which tells the RCNP analyzer loop to terminate so that all threads can cleanly exit. --- GRAnalyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GRAnalyzer b/GRAnalyzer index 697f35c6..38c1ea38 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 697f35c6d921b2f59d59e08a0b9a11d881509b1f +Subproject commit 38c1ea38ae68f6efabd03ea3638a12556e9c8d5a From 493223aabb03bcb64dbd846f78740816c7764785 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 8 Jun 2016 19:20:40 -0400 Subject: [PATCH 42/94] Added -R option to indicate if the raw RCNP root tree should be saved while analyzing RCNP data. --- GRAnalyzer | 2 +- include/TGRUTOptions.h | 7 ++++--- include/TRCNPSource.h | 2 +- libraries/TGRUTint/TGRUTOptions.cxx | 3 +++ util/granalyzer.cxx | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/GRAnalyzer b/GRAnalyzer index 38c1ea38..57a0a3a5 160000 --- a/GRAnalyzer +++ b/GRAnalyzer @@ -1 +1 @@ -Subproject commit 38c1ea38ae68f6efabd03ea3638a12556e9c8d5a +Subproject commit 57a0a3a5de3fc2c86a2b90f2364bf737c4dab2af diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index 4a3175b7..e53c845c 100644 --- a/include/TGRUTOptions.h +++ b/include/TGRUTOptions.h @@ -46,6 +46,7 @@ class TGRUTOptions : public TObject { bool MakeHistos() const { return fMakeHistos; } bool SortMultiple() const { return fSortMultiple; } bool TreeSource() const { return fTreeSource; } + bool SaveRCNPTree() const { return fSaveRCNPTree; } bool IsOnline() const { return fIsOnline; } @@ -99,14 +100,14 @@ class TGRUTOptions : public TObject { bool fMakeHistos; bool fSortMultiple; bool fTreeSource; - bool fTimeSortInput; int fTimeSortDepth; - int fBuildWindow; - bool fShouldExit; + + bool fSaveRCNPTree; + ClassDef(TGRUTOptions,0); }; diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h index 69e83147..fa29ac02 100644 --- a/include/TRCNPSource.h +++ b/include/TRCNPSource.h @@ -40,7 +40,7 @@ class TRCNPSource : public TRawEventSource { #ifndef __CINT__ fFuture = std::async(std::launch::async,StartGRAnalyzer,Command,&stop_rcnp_signal,[&](RCNPEvent* event){ rcnp_queue.Push(event); - }); + }, TGRUTOptions::Get()->SaveRCNPTree()); #endif LoadFakeTimestamps(); diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index b2808938..89dd3760 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -92,6 +92,9 @@ void TGRUTOptions::Load(int argc, char** argv) { parser.option("T tree-source", &fTreeSource) .description("Input TTree source.") .default_value(false); + parser.option("R save-rcnp-tree", &fSaveRCNPTree) + .description("Save ROOT tree from raw RCNP analyzer data.") + .default_value(false); parser.option("hist-output",&output_histogram_file) diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index 4c0a22c4..56e32dd5 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -10,13 +10,13 @@ using namespace std; /* main */ int main() { - const char* filename = "./datatest/run1001.bld"; + const char* filename = "./datatest/run6106.bld"; 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); - }); + },false); RCNPEvent data; static int count = 0; while (gr_queue.Pop(data,0)) { From 313a47c7976dc219f7952ee59f4928acfed37ca7 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 8 Jun 2016 22:26:27 -0400 Subject: [PATCH 43/94] Added setup script to create the necessary links to the GRAnalyzer git submodule --- setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 setup.sh diff --git a/setup.sh b/setup.sh new file mode 100755 index 00000000..b6574864 --- /dev/null +++ b/setup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +GRANAFILES=("sca" "hb" "def" "alias" "datatest" "gr_wtdc.hst" "las_wtdc.hst" "hist.def") +for linkey in "${GRANAFILES[@]}"; do + echo "ln -s GRAnalyzer/$linkey $linkey" + ln -s "GRAnalyzer/$linkey" "$linkey" +done From bfa36109396689bc8600a3303aec6805208c580b Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 10 Jun 2016 10:18:41 +0900 Subject: [PATCH 44/94] 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 2181cfa4182016460762c6c3fbbfc197905b06cc Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 10 Jun 2016 22:13:54 -0400 Subject: [PATCH 45/94] Added line to source thisgrut.sh --- setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.sh b/setup.sh index b6574864..035fc87b 100755 --- a/setup.sh +++ b/setup.sh @@ -5,3 +5,4 @@ for linkey in "${GRANAFILES[@]}"; do echo "ln -s GRAnalyzer/$linkey $linkey" ln -s "GRAnalyzer/$linkey" "$linkey" done +source thisgrut.sh From 409bf947512d111b542c5e3b13098296c4a2fb30 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 11 Jun 2016 21:11:33 -0400 Subject: [PATCH 46/94] Isolated RCNP code a bit so that if you have the correct submodule (GRAnalyzer), it can be enabled by setting RCNP=1 in the makefile, but otherwise, the dependandt classes (TTreeSource TRCNPSource RCNPEvent etc) are implemented as "husk" versions of themselves. All defguards are in RCNP classes and are not present in GRUTinizer for the sake of clean code. --- include/TRCNPEvent.h | 28 ---- include/TRCNPSource.h | 154 ++++++------------ include/TTreeSource.h | 86 ++++++---- .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 2 +- .../TGrandRaiden/TGrandRaidenHit.cxx | 46 +++++- libraries/TLoops/TUnpackingLoop.cxx | 1 - libraries/TLoops/ThreadsafeQueue.cxx | 11 -- libraries/TRCNPFormat/LinkDef.h | 12 -- libraries/TRCNPFormat/TRCNPEvent.cxx | 35 ---- libraries/TRawFormat/TRCNPSource.cxx | 116 +++++++++++++ libraries/TRawFormat/TRawEvent.cxx | 4 - makefile | 25 ++- util/granalyzer.cxx | 5 + 13 files changed, 290 insertions(+), 235 deletions(-) delete mode 100644 include/TRCNPEvent.h delete mode 100644 libraries/TRCNPFormat/LinkDef.h delete mode 100644 libraries/TRCNPFormat/TRCNPEvent.cxx create mode 100644 libraries/TRawFormat/TRCNPSource.cxx diff --git a/include/TRCNPEvent.h b/include/TRCNPEvent.h deleted file mode 100644 index 29755e66..00000000 --- a/include/TRCNPEvent.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _TRCNPEVENT_H_ -#define _TRCNPEVENT_H_ - -#include "TRawEvent.h" -//#include "RCNPEvent.h" - -class RCNPEvent; - -class TRCNPEvent : public TRawEvent { -public: - TRCNPEvent(); - TRCNPEvent(const TRawEvent&); - virtual ~TRCNPEvent(); - - long GetTimestamp() const; - - const char* GetPayload() const; - TSmartBuffer GetPayloadBuffer() const; - - virtual void Clear(Option_t *opt =""); - virtual void Print(Option_t *opt ="") const; - - RCNPEvent* event; - - ClassDef(TRCNPEvent, 0); -}; - -#endif /* _TRCNPEVENT_H_ */ diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h index fa29ac02..c39c3a83 100644 --- a/include/TRCNPSource.h +++ b/include/TRCNPSource.h @@ -1,3 +1,4 @@ +#ifdef RCNP #ifndef _TRCNPSOURCE_H_ #define _TRCNPSOURCE_H_ @@ -20,127 +21,29 @@ #include "TChain.h" #include "TFile.h" -#include "TRCNPEvent.h" #include "RCNPEvent.h" #include "ThreadsafeQueue.h" -#ifndef __CINT__ -#include "GRUTinizerInterface.h" -extern atomic stop_rcnp_signal; -#endif - class TRCNPSource : public TRawEventSource { public: - TRCNPSource(const char* Command, kFileType file_type) - : fCommand(Command), fFileType(file_type) { - - assert(file_type == kFileType::RCNP_BLD); - -#ifndef __CINT__ - fFuture = std::async(std::launch::async,StartGRAnalyzer,Command,&stop_rcnp_signal,[&](RCNPEvent* event){ - rcnp_queue.Push(event); - }, TGRUTOptions::Get()->SaveRCNPTree()); -#endif - - LoadFakeTimestamps(); - } - TRCNPSource(TRCNPSource& source) { ; } - + TRCNPSource(const char* Command, kFileType file_type); + TRCNPSource(const TRCNPSource& source) { } ~TRCNPSource() {;} - virtual std::string Status() const { - return Form("%s: %s %8.2f MB given %s / %s Unknown MB total %s => %s %3.02f MB/s processed %s", - SourceDescription().c_str(), - DCYAN, GetBytesGiven()/1e6, RESET_COLOR, - BLUE, RESET_COLOR, - GREEN, GetAverageRate()/1e6, RESET_COLOR); - } - virtual std::string SourceDescription() const {return "File: "+std::string("RCNP_BLD: ")+fCommand;} - - + virtual std::string Status() const; + virtual std::string SourceDescription() const; kFileType GetFileType() const { return fFileType; } long GetFileSize() const { return fFileSize; } - virtual void Reset() {;} protected: void SetFileSize(long file_size) { fFileSize = file_size; } - void LoadFakeTimestamps() { - - std::string line; std::stringstream stream; ULong_t ts; - ifstream file ("/projects/ceclub/sullivan/cagragr/GRUTinizer/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(); - } - } + void LoadFakeTimestamps(); private: TRCNPSource() {;} - virtual int GetEvent(TRawEvent& event) { - - // TRCNPEvent* rcnp_evt = new TRCNPEvent; - RCNPEvent* rcnp;// = new RCNPEvent; - - // Try to get event from RCNP event queue - if (rcnp_queue.Pop(rcnp,200) == -1 ){ -#ifndef __CINT__ - // if offline - if (TGRUTOptions::Get()->ExitAfterSorting()) { - auto status = fFuture.wait_for(std::chrono::milliseconds(0)); - // check if RCNP analyzer is done - if (status == std::future_status::ready) { - std::cout << "RCNP analyzer thread finished ##" << std::endl; - return -1; - } else { - std::cout << "RCNP analyzer still running, awaiting data.." << std::endl; - // try again to pop an event - if (rcnp_queue.Pop(rcnp,1000) == -1) { - // if it failed again check if the RCNP analyzer is done now - status = fFuture.wait_for(std::chrono::milliseconds(1000)); - if (status == std::future_status::ready) { - return -1; - } else { - throw std::runtime_error("TRCNPSource::GetEvent GRAnalyzer loop is hung."); - } - } - } - } else { - return -1; - } -#endif - } - - - // 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); - - // 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(); - - return sizeof(rcnp); - } + virtual int GetEvent(TRawEvent& event); const std::string fCommand; kFileType fFileType; @@ -155,4 +58,47 @@ class TRCNPSource : public TRawEventSource { ClassDef(TRCNPSource,0); }; + +#endif + + + + + + + + + + + + + +#else // if RCNP is not defined + + +#ifndef _TRCNPSOURCE_H_ +#define _TRCNPSOURCE_H_ +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +class TRCNPSource : public TRawEventSource { +public: + TRCNPSource(const char* Command, kFileType file_type) {} + TRCNPSource(const TRCNPSource& source) { } + ~TRCNPSource() {;} + virtual std::string Status() const { return ""; } + virtual std::string SourceDescription() const { return ""; } + kFileType GetFileType() const { return kFileType::UNKNOWN_FILETYPE; } + long GetFileSize() const { return 0; } + virtual void Reset() {;} +protected: + void SetFileSize(long file_size) { ; } +private: + TRCNPSource() {;} + virtual int GetEvent(TRawEvent& event) { event.SetFragmentTimestamp(0); return -1; } + ClassDef(TRCNPSource,0); +}; #endif + + +#endif // RCNP diff --git a/include/TTreeSource.h b/include/TTreeSource.h index c90de6a9..9fa0494c 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -1,3 +1,4 @@ +#ifdef RCNP #ifndef _TTREESOURCE_H_ #define _TTREESOURCE_H_ @@ -20,35 +21,6 @@ template class TTreeSource : public TRawEventSource { public: - /* TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) */ - /* : TTreeSource({filename},treename,eventclassname,file_type) { ; } */ - - // template - // TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) - // : TTreeSource({filename},treename,eventclassname,file_type,std::forward(args)...) { ; } - - // template - // TTreeSource(const std::vector& filenames, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) - - // template - // TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type, Args&&... args) - // : fChain(treename), fCurrentEntry(0) { - - // assert(file_type == kFileType::ROOT_DATA); - - // fFileType = file_type; - - // fChain.Add(filename); - - // fFileSize = fChain.GetEntries()*sizeof(T); - - // if (sizeof...(Args) > 0) { - // fEvent = new T(std::forward(args)...); - // } else { - // fEvent = new T(); - // } - // fChain.SetBranchAddress(eventclassname, &fEvent); - // } TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) : fChain(treename), fEvent(0), fCurrentEntry(0) { @@ -151,3 +123,59 @@ class TTreeSource : public TRawEventSource { }; #endif + + + + + + + + + + + + + +#else // if RCNP is not defined + + +#ifndef _TTREESOURCE_H_ +#define _TTREESOURCE_H_ +#include "TObject.h" +#include "TRawEvent.h" +#include "TRawSource.h" +templateClassImp(TTreeSource) +template +class TTreeSource : public TRawEventSource { +public: + TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) {;} + ~TTreeSource() {;} + virtual std::string Status() const { return ""; } + virtual std::string SourceDescription() const {return ""; } + kFileType GetFileType() const { return kFileType::UNKNOWN_FILETYPE; } + long GetFileSize() const { return 0; } + virtual void Reset() {;} +protected: + void SetFileSize(long file_size) { ; } +private: + TTreeSource() {;} + virtual int GetEvent(TRawEvent& event) { event.SetFragmentTimestamp(0); return -1; } + ClassDef(TTreeSource,0); +}; +// --------------------- +class RCNPEvent : public TObject { +public: + RCNPEvent() {;} + virtual ~RCNPEvent() {;} + void Clear() {;} + long GetTimestamp() { return 0; } + void SetTimestamp(const long& ts) { ; } +private: +public: + ClassDef(RCNPEvent,1); +}; +// --------------------- +#endif + + +#endif // RCNP diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index fe341000..e9b1ad1f 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -1,5 +1,5 @@ #include "TGrandRaiden.h" -#include "TRCNPEvent.h" +#include "TRawEvent.h" TGrandRaiden::TGrandRaiden(){ Clear(); diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 0635d316..9929bcea 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -1,3 +1,5 @@ +#ifdef RCNP + #include "TGrandRaidenHit.h" #include "TGRUTOptions.h" #include "RCNPEvent.h" @@ -14,8 +16,6 @@ TGrandRaidenHit::~TGrandRaidenHit() { } - - void TGrandRaidenHit::BuildFrom(TSmartBuffer& buf){ Clear(); @@ -63,3 +63,45 @@ void TGrandRaidenHit::Clear(Option_t *opt) { TDetectorHit::Clear(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/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index 04f09df7..20f90052 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -9,7 +9,6 @@ #include "TGEBEvent.h" #include "TGRUTOptions.h" #include "TNSCLEvent.h" -#include "TRCNPEvent.h" #include "TBuildingLoop.h" #include "TDetectorEnv.h" diff --git a/libraries/TLoops/ThreadsafeQueue.cxx b/libraries/TLoops/ThreadsafeQueue.cxx index eb4cb194..aed974ee 100644 --- a/libraries/TLoops/ThreadsafeQueue.cxx +++ b/libraries/TLoops/ThreadsafeQueue.cxx @@ -4,7 +4,6 @@ #include "TUnpackedEvent.h" -#include "RCNPEvent.h" template<> int ThreadsafeQueue::ObjectSize(TRawEvent& event){ return event.GetTotalSize(); @@ -24,13 +23,3 @@ template<> int ThreadsafeQueue::ObjectSize(TUnpackedEvent*& event) { return event->Size(); } - -template<> -int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { - return event.data.size(); -} - -template<> -int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) { - return event->data.size(); -} diff --git a/libraries/TRCNPFormat/LinkDef.h b/libraries/TRCNPFormat/LinkDef.h deleted file mode 100644 index 605e27a3..00000000 --- a/libraries/TRCNPFormat/LinkDef.h +++ /dev/null @@ -1,12 +0,0 @@ -// TRCNPEvent.h - -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; -#pragma link C++ nestedclasses; - -#pragma link C++ class TRCNPEvent+; - -#endif diff --git a/libraries/TRCNPFormat/TRCNPEvent.cxx b/libraries/TRCNPFormat/TRCNPEvent.cxx deleted file mode 100644 index 8c4828a3..00000000 --- a/libraries/TRCNPFormat/TRCNPEvent.cxx +++ /dev/null @@ -1,35 +0,0 @@ -#include "TRCNPEvent.h" -#include "RCNPEvent.h" - -#include "TString.h" - - -ClassImp(TRCNPEvent) - -TRCNPEvent::TRCNPEvent() : event(nullptr) { } - -TRCNPEvent::TRCNPEvent(const TRawEvent &raw) { - raw.Copy(*this); -} - -TRCNPEvent::~TRCNPEvent() { } - -Long_t TRCNPEvent::GetTimestamp() const { - return event->GetTimestamp(); -} - -const char* TRCNPEvent::GetPayload() const { - return fBody.GetData() + sizeof(Long_t); -} - -TSmartBuffer TRCNPEvent::GetPayloadBuffer() const { - return fBody; -} - -void TRCNPEvent::Clear(Option_t *opt) { - TRawEvent::Clear(opt); -} - -void TRCNPEvent::Print(Option_t *opt) const { - TRawEvent::Print(opt); -} diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx new file mode 100644 index 00000000..6d5da10f --- /dev/null +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -0,0 +1,116 @@ +#include "TRCNPSource.h" +#include "GRUTinizerInterface.h" + +extern atomic stop_rcnp_signal; + +TRCNPSource::TRCNPSource(const char* Command, kFileType file_type) + : fCommand(Command), fFileType(file_type) { + + assert(file_type == kFileType::RCNP_BLD); + + fFuture = std::async(std::launch::async, + StartGRAnalyzer, + Command, + &stop_rcnp_signal, + [&](RCNPEvent* event) { + rcnp_queue.Push(event); + }, + TGRUTOptions::Get()->SaveRCNPTree()); + + LoadFakeTimestamps(); +} + +int TRCNPSource::GetEvent(TRawEvent& event) { + + // TRCNPEvent* rcnp_evt = new TRCNPEvent; + RCNPEvent* rcnp;// = new RCNPEvent; + + // Try to get event from RCNP event queue + if (rcnp_queue.Pop(rcnp,200) == -1 ){ +#ifndef __CINT__ + // if offline + if (TGRUTOptions::Get()->ExitAfterSorting()) { + auto status = fFuture.wait_for(std::chrono::milliseconds(0)); + // check if RCNP analyzer is done + if (status == std::future_status::ready) { + std::cout << "RCNP analyzer thread finished ##" << std::endl; + return -1; + } else { + std::cout << "RCNP analyzer still running, awaiting data.." << std::endl; + // try again to pop an event + if (rcnp_queue.Pop(rcnp,1000) == -1) { + // if it failed again check if the RCNP analyzer is done now + status = fFuture.wait_for(std::chrono::milliseconds(1000)); + if (status == std::future_status::ready) { + return -1; + } else { + throw std::runtime_error("TRCNPSource::GetEvent GRAnalyzer loop is hung."); + } + } + } + } else { + return -1; + } +#endif + } + + + // 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); + + // 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(); + + return sizeof(rcnp); +} + +std::string TRCNPSource::Status() const { + return Form("%s: %s %8.2f MB given %s / %s Unknown MB total %s => %s %3.02f MB/s processed %s", + SourceDescription().c_str(), + DCYAN, GetBytesGiven()/1e6, RESET_COLOR, + BLUE, RESET_COLOR, + GREEN, GetAverageRate()/1e6, RESET_COLOR); +} +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 ("/projects/ceclub/sullivan/cagragr/GRUTinizer/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(); + } +} + + +template<> +int ThreadsafeQueue::ObjectSize(RCNPEvent& event) { + return event.data.size(); +} + +template<> +int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) { + return event->data.size(); +} diff --git a/libraries/TRawFormat/TRawEvent.cxx b/libraries/TRawFormat/TRawEvent.cxx index faaeec20..fd455894 100644 --- a/libraries/TRawFormat/TRawEvent.cxx +++ b/libraries/TRawFormat/TRawEvent.cxx @@ -10,8 +10,6 @@ #include "TGEBEvent.h" #include "TNSCLEvent.h" -#include "TRCNPEvent.h" -#include "RCNPEvent.h" ClassImp(TRawEvent) @@ -119,8 +117,6 @@ Long_t TRawEvent::GetTimestamp() const { case GRETINA_MODE2: case GRETINA_MODE3: return ((TGEBEvent*)this)->GetTimestamp(); - case RCNP_BLD: - return ((TRCNPEvent*)this)->event->GetTimestamp(); default: ; diff --git a/makefile b/makefile index da0b7985..e7b05956 100644 --- a/makefile +++ b/makefile @@ -2,14 +2,10 @@ .SECONDARY: .SECONDEXPANSION: - PLATFORM:=$(PLATFORM) # EDIT THIS SECTION -GRANAPATH = ./GRAnalyzer/analyzer -GRANALYZER = $(realpath $(GRANAPATH)/../lib) -GRLINKFLAGS = -L$(GRANALYZER) -Wl,-rpath,$(GRANALYZER) -lRCNPEvent -lGRAnalyzer -L$(realpath $(GRANAPATH)/lib) -lpacklib -lm -lgfortran -lnsl -INCLUDES = include $(GRANAPATH)/include $(GRANAPATH)/libRCNPEvent/include $(GRANAPATH)/libGRAnalyzer/include +INCLUDES = include CFLAGS = -g -std=c++11 -O3 -Wall -Wextra -pedantic -Wno-unused-parameter -D`uname -m` -D`uname -s` -DLinux86 -Df2cFortran -DUSE_PAW LINKFLAGS_PREFIX = LINKFLAGS_SUFFIX = -L/opt/X11/lib -lX11 -lXpm -std=c++11 @@ -30,6 +26,19 @@ CFLAGS += -Wl,--no-as-needed SHAREDSWITCH = -shared -Wl,-soname,# NO ENDING SPACE endif +# When compiling and linking against RCNP analyzer routines +ifeq ($(RCNP),) +RCNPANAPATH = ./GRAnalyzer/analyzer +RCNPANALYZER = $(realpath $(RCNPANAPATH)/../lib) +RCNPFLAGS = -DRCNP +RCNPLINKFLAGS = -L$(RCNPANALYZER) -Wl,-rpath,$(RCNPANALYZER) -lRCNPEvent -lGRAnalyzer -L$(realpath $(RCNPANAPATH)/lib) -lpacklib -lm -lgfortran -lnsl +RCNPINCLUDES = $(RCNPANAPATH)/include $(RCNPANAPATH)/libRCNPEvent/include $(RCNPANAPATH)/libGRAnalyzer/include +CINTFLAGS += $(RCNPFLAGS) +CFLAGS += $(RCNPFLAGS) +INCLUDES += $(RCNPINCLUDES) +endif + + COM_COLOR=\033[0;34m OBJ_COLOR=\033[0;36m BLD_COLOR=\033[3;34m @@ -95,10 +104,10 @@ bin/%: util/% | bin @ln -sf ../$< $@ bin/grutinizer: $(MAIN_O_FILES) | $(LIBRARY_OUTPUT) libGRAnalyzer bin - $(call run_and_test,$(CPP) $^ -o $@ $(LINKFLAGS) $(GRLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) + $(call run_and_test,$(CPP) $^ -o $@ $(LINKFLAGS) $(RCNPLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) bin/%: .build/util/%.o | $(LIBRARY_OUTPUT) libGRAnalyzer bin - $(call run_and_test,$(CPP) $< -o $@ $(LINKFLAGS) $(GRLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) + $(call run_and_test,$(CPP) $< -o $@ $(LINKFLAGS) $(RCNPLINKFLAGS),$@,$(COM_COLOR),$(COM_STRING),$(OBJ_COLOR) ) bin: @mkdir -p $@ @@ -138,7 +147,7 @@ find_linkdef = $(shell find $(1) -name "*LinkDef.h") define library_template .build/$(1)/$(notdir $(1))Dict.cxx: $$(call dict_header_files,$(1)/LinkDef.h) $(1)/LinkDef.h @mkdir -p $$(dir $$@) - $$(call run_and_test,rootcint -f $$@ -c $$(INCLUDES) -p $$^,$$@,$$(COM_COLOR),$$(BLD_STRING) ,$$(OBJ_COLOR)) + $$(call run_and_test,rootcint -f $$@ -c $$(INCLUDES) $$(CINTFLAGS) -p $$^,$$@,$$(COM_COLOR),$$(BLD_STRING) ,$$(OBJ_COLOR)) .build/$(1)/LibDictionary.o: .build/$(1)/$(notdir $(1))Dict.cxx $$(call run_and_test,$$(CPP) -fPIC -c $$< -o $$@ $$(CFLAGS),$$@,$$(COM_COLOR),$$(COM_STRING),$$(OBJ_COLOR) ) diff --git a/util/granalyzer.cxx b/util/granalyzer.cxx index 56e32dd5..0aa905b0 100644 --- a/util/granalyzer.cxx +++ b/util/granalyzer.cxx @@ -1,3 +1,4 @@ +#ifdef RCNP #include #include #include @@ -39,3 +40,7 @@ int main() // std::cout << gr_queue.Size() << std::endl; // } // grloop.join(); + +#else +int main() { return 0; } +#endif From 0bd721aa3a92d7bc3087a685af41d9f2f50ac752 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 11 Jun 2016 23:48:15 -0400 Subject: [PATCH 47/94] Removed unnecessary script --- setup.sh | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 setup.sh diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 035fc87b..00000000 --- a/setup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -GRANAFILES=("sca" "hb" "def" "alias" "datatest" "gr_wtdc.hst" "las_wtdc.hst" "hist.def") -for linkey in "${GRANAFILES[@]}"; do - echo "ln -s GRAnalyzer/$linkey $linkey" - ln -s "GRAnalyzer/$linkey" "$linkey" -done -source thisgrut.sh From 5a80211f79a213e337c5fc01e88f6c8892403bbe Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 14 Jun 2016 15:02:13 +0900 Subject: [PATCH 48/94] 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 a1b1e2be29b364fff8bdb00c9dcd34022f2387f8 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 14 Jun 2016 03:00:39 -0400 Subject: [PATCH 49/94] Added missing rcnpchannel calibration file to analyzer --- config/rcnpchannels.cal | 108 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 config/rcnpchannels.cal diff --git a/config/rcnpchannels.cal b/config/rcnpchannels.cal new file mode 100644 index 00000000..77103536 --- /dev/null +++ b/config/rcnpchannels.cal @@ -0,0 +1,108 @@ + +// 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 + +EXT01AP00 { + Address: 0x01007200 + 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 +// } From bd5882d8dd0e1d75c6b63fd8cf9d113f81fb202c Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 15 Jun 2016 11:20:48 +0900 Subject: [PATCH 50/94] 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 d2f6f10256a148c90e0112bdfe6c2ccd76cf30d2 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 16 Jun 2016 21:12:31 -0400 Subject: [PATCH 51/94] Adding simple program for reading ANL GEB data --- util/simpleread_anl.cxx | 240 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 util/simpleread_anl.cxx diff --git a/util/simpleread_anl.cxx b/util/simpleread_anl.cxx new file mode 100644 index 00000000..eb57d8c2 --- /dev/null +++ b/util/simpleread_anl.cxx @@ -0,0 +1,240 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#define PRINT(x) std::cout << #x"=" << x << std::endl +#define STR(x) #x << '=' << x + +#define GEB_HEADER_SIZE 16 + + + +using namespace std; + +// template +// void endswap(T *objp) +// { +// unsigned char *memp = reinterpret_cast(objp); +// reverse(memp, memp + sizeof(T)); +// } + +void endswap(uint16_t* datum) { + uint16_t temp = 0; + temp = (*datum&0x00ff); + *datum = (temp<<8) + ((*datum)>>8); +} +void endswap(uint32_t* datum) { + uint32_t t1 = 0, t2 = 0, t3 = 0; + t1 = ((*datum)&0x000000ff); + t2 = ((*datum)&0x0000ff00); + t3 = ((*datum)&0x00ff0000); + *datum = (t1<<24) + (t2<<8) + (t3>>8) + ((*datum)>>24); +} + + +struct GEB_HEADER { + uint32_t type; + uint32_t length; + uint64_t timestamp; +}__attribute__((__packed__)); + +struct ANL_LED_v11 { + 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; + uint32_t timestamp_peak_high; + uint16_t postrise_end_sample; + uint16_t postrise_begin_sample; + uint16_t prerise_end_sample; + uint16_t prerise_begin_sample; + uint16_t base_sample; + uint16_t peak_sample; +}__attribute__((__packed__)); + + + +int main (int argc, char **argv) { + int i; + bool debug = false; + + if (argc<2) { + printf("[PATH TO INPUTFILE LIST] [-v PRINT EVENT]\n"); + exit(-1); + } + if (argc>2){ // lazy + if (strcmp(argv[2],"-v")==0) { + debug = true; + } + } + + FILE *fd,*list; + char fileName[255]; + char DataName[255]; + + strcpy(fileName,argv[1]); + list=fopen(fileName,"r"); + + while(fscanf(list,"%s",DataName)!=EOF) { + printf("%s\n",DataName); + fd = fopen(DataName, "r"); + if (!fd) { + perror("Failed to open"); + exit(1); + } + + int nevents =0; + int datasize = 64 + GEB_HEADER_SIZE; + unsigned char* header = (unsigned char*)malloc(GEB_HEADER_SIZE); + unsigned char* payload = (unsigned char*)malloc(datasize*4); + + while (fread(header,GEB_HEADER_SIZE,1,fd) == 1) { + + //if (nevents>10) break; + + auto head = (GEB_HEADER*)header; + //cout << head->length << endl; + //cin.get(); + datasize = head->length; + + if (fread(payload,datasize,1,fd) == 1) { + + auto event = (ANL_LED_v11*)payload; + + endswap(&event->ga_packetlength); + uint16_t ga = ((event->ga_packetlength & 0xf800) >> 11); + uint16_t length = (event->ga_packetlength & 0x7ff); + endswap(&event->ud_channel); + uint16_t userdefined = ((event->ud_channel & 0xfff0) >> 4); + uint16_t channel = (event->ud_channel & 0xf); + + endswap(&event->led_low); + endswap(&event->led_high); + uint64_t ts = (((uint64_t)event->led_high) << 32) + ((uint64_t)event->led_low); + + endswap(&event->hdrlength_evttype_hdrtype); + uint16_t headertype = ((event->hdrlength_evttype_hdrtype & 0xf) >> 0); + uint16_t eventtype = ((event->hdrlength_evttype_hdrtype & 0x380) >> 7); + uint16_t headerlength = ((event->hdrlength_evttype_hdrtype & 0xfc00) >> 10); + + endswap(&event->led_low_prev); + endswap(&event->led_high_prev); + uint64_t ts_prev = (((uint64_t)event->led_high_prev) << 16) + ((uint64_t)event->led_low_prev); + + endswap(&event->flags); + uint16_t external_disc = ((event->flags & 0x100)>>8); + uint16_t peak_valid = ((event->flags & 0x200)>>9); + uint16_t offset = ((event->flags & 0x400)>>10); + uint16_t sync_error = ((event->flags & 0x1000)>>12); + uint16_t general_error = ((event->flags & 0x2000)>>13); + uint16_t pile_up_only = ((event->flags & 0x4000)>>14); + uint16_t pile_up = ((event->flags & 0x8000)>>15); + + endswap(&event->sampled_baseline); + uint32_t sampled_baseline = ((event->sampled_baseline & 0x00FFFFFF) >> 0); + + endswap(&event->postrise_sum_low_prerise_sum); + endswap(&event->postrise_sum_high); + uint32_t prerise_sum = (event->postrise_sum_low_prerise_sum & 0xffffff); + uint32_t postrise_sum = ((event->postrise_sum_low_prerise_sum & 0xff000000)>>24); + postrise_sum += (((uint32_t)event->postrise_sum_high) << 8); + + endswap(&event->timestamp_peak_low); + endswap(&event->timestamp_peak_high); + uint64_t peak_timestamp = ((uint64_t)event->timestamp_peak_low) + (((uint64_t)event->timestamp_peak_high)<<16); + + endswap(&event->postrise_end_sample); + uint16_t postrise_end_sample = (event->postrise_end_sample & 0x3fff); + + endswap(&event->postrise_begin_sample); + uint16_t postrise_begin_sample = (event->postrise_begin_sample & 0x3fff); + + endswap(&event->prerise_end_sample); + uint16_t prerise_end_sample = (event->prerise_end_sample & 0x3fff); + + endswap(&event->prerise_begin_sample); + uint16_t prerise_begin_sample = (event->prerise_begin_sample & 0x3fff); + + endswap(&event->base_sample); + uint16_t base_sample = (event->base_sample & 0x3fff); + + endswap(&event->peak_sample); + uint16_t peak_sample = (event->peak_sample & 0x3fff); + + //cout << head->timestamp << endl; + + if (debug) { + cout << "\n\n Event number: " << nevents+1 << endl; + for (i=0;itype) << endl; + cout << STR(head->length) << endl; + cout << STR(head->timestamp) << endl; + cout << STR(ga) << endl; + cout << STR(length) << endl; + cout << STR(channel) << endl; + cout << STR(userdefined) << endl; //boardid + cout << STR(ts) << endl; + cout << STR(headertype) << endl; + cout << STR(eventtype) << endl; + cout << STR(headerlength) << endl; + cout << STR(ts_prev) << endl; + cout << STR(external_disc) << endl; + cout << STR(peak_valid) << endl; + cout << STR(offset) << endl; + cout << STR(sync_error) << endl; + cout << STR(general_error) << endl; + cout << STR(pile_up_only) << endl; + cout << STR(pile_up) << endl; + cout << dec << STR(sampled_baseline) << endl; + cout << STR(prerise_sum) << endl; + cout << STR(postrise_sum) << endl; + cout << STR(peak_timestamp) << endl; + PRINT(postrise_end_sample); + PRINT(postrise_begin_sample); + PRINT(prerise_end_sample); + PRINT(prerise_begin_sample); + PRINT(base_sample); + PRINT(peak_sample); + } + + nevents++; + } + } + delete payload; + delete header; + fclose(fd); + cout << "Read " << nevents << " events.\n"; + } + fclose(list); + exit(0); +} From bac04e9a109dbd278eae56d74e4a446b0e84ebd2 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 17 Jun 2016 10:25:22 +0900 Subject: [PATCH 52/94] 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 654b3b537da7af3f830e9511a20e0fc8bae33e42 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 17 Jun 2016 12:35:59 +0900 Subject: [PATCH 53/94] 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 13b11d7773367a330c9f4db366bee8433eebd7ff Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 18 Jun 2016 10:01:04 +0900 Subject: [PATCH 54/94] 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 bcdc6fe0e4a160f2531f21b416d10e0936f1f346 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 19 Jun 2016 22:59:12 +0900 Subject: [PATCH 55/94] 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 12cc479e708f72dcf661f3b2a68ff3aec6f25f5a Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 21 Jun 2016 12:01:21 +0900 Subject: [PATCH 56/94] 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 f5afa5a90067da0c7aeb168082ce80145d17f9ad Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 00:55:11 +0900 Subject: [PATCH 57/94] 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 ad4bfaa5235f53235f50040b095118af44a6f7ff Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 15:17:09 +0900 Subject: [PATCH 58/94] 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 c5cb61f15724b27a8b0acb1ff7322686d639a6b0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 19:14:40 +0900 Subject: [PATCH 59/94] 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 00970ee28932ac6dd9980639749ead41e69b5762 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 19:27:26 +0900 Subject: [PATCH 60/94] 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 d1175e54dc9680b19fef35e3a79a442a484533ba Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 21:21:35 +0900 Subject: [PATCH 61/94] 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 12bbfca74e6cf841aff24432c816ca3e05a19db0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sat, 25 Jun 2016 23:01:51 +0900 Subject: [PATCH 62/94] 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 6ba2c6a684219cd4600c815bfebbf554141482b3 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 11:33:47 +0900 Subject: [PATCH 63/94] 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 193ecbb1e4a6a3465a07dd5920209e6f8e24c58b Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 13:20:15 +0900 Subject: [PATCH 64/94] 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 054731f831753da2b1dfad1b0ffc9f1a9d47ab25 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 14:38:29 +0900 Subject: [PATCH 65/94] 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 1942389ab5d762149877057cd82eaf85f32511c5 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Sun, 26 Jun 2016 19:31:51 +0900 Subject: [PATCH 66/94] 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 df11aef0b8f13a4017913fc717b23441892c9cab Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 27 Jun 2016 00:48:18 +0900 Subject: [PATCH 67/94] 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 8b16e12bcb5b2bd1f0b6dac016a1cbfdc99ed7fa Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 27 Jun 2016 01:25:32 +0900 Subject: [PATCH 68/94] 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 fab128ca22294c0ee80c9ab5e3914ea21142cc8a Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 29 Jun 2016 15:12:11 +0900 Subject: [PATCH 69/94] 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 29b2810184936f12d5f075c1eba9def4cb538b8e Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Thu, 30 Jun 2016 17:40:12 +0900 Subject: [PATCH 70/94] 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 686f4bd84271e76bfa544087b4629f7ceb23e133 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 1 Jul 2016 19:04:33 +0900 Subject: [PATCH 71/94] 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 37f0249859beb65faad90e8c86eef501f6c050d9 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 11 Jul 2016 23:07:03 +0900 Subject: [PATCH 72/94] 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 796007fc86e931911d292ae4f5f48ec605e10c69 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 11 Jul 2016 23:59:08 +0900 Subject: [PATCH 73/94] 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 4a65c1769508ec9c499b287bde43fd8c109254d0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 11 Jul 2016 17:55:58 -0400 Subject: [PATCH 74/94] 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 680a098afec6af4309632fff05b3dc0cfddc9f33 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 13 Jul 2016 14:48:29 -0400 Subject: [PATCH 75/94] 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 9cf2cdab985c9f30c5282d9ee8d884329d807a25 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 13 Jul 2016 14:56:04 -0400 Subject: [PATCH 76/94] 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); From 5d1e8346149de5b37a64c60e5531fd379a50b8df Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 15 Jul 2016 16:34:18 -0400 Subject: [PATCH 77/94] Added fix to tcut_tab.py so that Save Cut works when the det_type is not registered. Also added many focal plane corrections. --- histos/RCNPAna.cxx | 136 +++++++++++++++++++++++++++++++++++++++++---- pygui/tcut_tab.py | 2 +- 2 files changed, 127 insertions(+), 11 deletions(-) diff --git a/histos/RCNPAna.cxx b/histos/RCNPAna.cxx index d01ad85c..be848a75 100644 --- a/histos/RCNPAna.cxx +++ b/histos/RCNPAna.cxx @@ -12,6 +12,7 @@ #include #include #include +#include #include "TCagra.h" #include "TGrandRaiden.h" @@ -30,6 +31,12 @@ using namespace std; string name; stringstream stream; +static TFile fcuts("bg_cuts.root"); +static auto cut0 = dynamic_cast(fcuts.Get("_cut0")); +static auto cut1 = dynamic_cast(fcuts.Get("_cut1")); +static auto cut2 = dynamic_cast(fcuts.Get("_cut2")); +static auto cut3 = dynamic_cast(fcuts.Get("_cut3")); + // extern "C" is needed to prevent name mangling. // The function signature must be exactly as shown here, @@ -38,6 +45,17 @@ extern "C" void MakeHistograms(TRuntimeObjects& obj) { + /////////////////////////// + // staic initializations // + /////////////////////////// + + + //reinterpret_cast(fcuts->Get("_cut0"))->IsInside + + + /////////////////////////// + + TCagra* cagra = obj.GetDetector(); TGrandRaiden* gr = obj.GetDetector(); @@ -66,26 +84,33 @@ void MakeHistograms(TRuntimeObjects& obj) { for (auto& caghit : *cagra) { auto cagratime = caghit.Timestamp(); - auto tdiff = cagratime-grtime; + auto tdiff = cagratime-grtime; + auto boardid = caghit.GetBoardID(); + auto channel = caghit.GetChannel(); + 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(); + stream << "Ge_"<< boardid << "_" < fp_corrections; + for (auto& hit : *gr) { auto& rcnp = hit.GR(); @@ -139,9 +167,87 @@ void MakeHistograms(TRuntimeObjects& obj) { 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()); + 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","dE1[dE2]",2000,0,2000, hit.GetMeanPlastE2(),2000,0,2000, hit.GetMeanPlastE1()); + + fp_corrections = [&](string dir) { + obj.FillHistogram(dir.c_str(),"RF[X]",1200,-600,600, rcnp.GR_X(0),500,700,1200,rf); + obj.FillHistogram(dir.c_str(),"RF[TH]",1000,-1,1, rcnp.GR_TH(0),500,700,1200,rf); + obj.FillHistogram(dir.c_str(),"RF[TH]cor",1000,-1,1, rcnp.GR_TH(0),500,700,1200,rf-(-1870.45+355.461)*rcnp.GR_TH(0)); + auto rf_cor = rf - (-1870.45+355.461)*rcnp.GR_TH(0); + obj.FillHistogram(dir.c_str(),"RF[X]_THcor",1200,-600,600, rcnp.GR_X(0),500,700,1200,rf_cor); + obj.FillHistogram(dir.c_str(),"RF[X]_THcor_Xcor",1200,-600,600, rcnp.GR_X(0),500,700,1200,rf_cor-0.177134*rcnp.GR_X(0)); + rf_cor -= 0.177134*rcnp.GR_X(0); + obj.FillHistogram(dir.c_str(),"dE1[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram(dir.c_str(),"dE2[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE2()); + + + obj.FillHistogram(dir.c_str(),"dE1[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram(dir.c_str(),"dE1[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE1()); + auto dE1 = hit.GetMeanPlastE1() - (-368.343)*rcnp.GR_TH(0); + obj.FillHistogram(dir.c_str(),"dE1[TH]_cor",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, dE1); + obj.FillHistogram(dir.c_str(),"dE1_THcor[dE2]",2000,0,2000, hit.GetMeanPlastE2(),2000,0,2000, dE1); + obj.FillHistogram(dir.c_str(),"RF_cor[dE1_THcor]",1000,0,0,rf_cor,2000,0,2000, dE1); //BOOM! :0) + + + if (cut0->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) || + cut1->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) || + cut2->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) || + cut3->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) + ) { + obj.FillHistogram(dir+"_BG","X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); + obj.FillHistogram(dir+"_BG","dE1[RF]",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram(dir+"_BG","dE2[RF]",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE2()); + obj.FillHistogram(dir+"_BG","dE1[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram(dir+"_BG","dE2[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE2()); + obj.FillHistogram(dir+"_BG","dE1_THcor[RF_cor]",1000,0,0,rf_cor,2000,0,2000, dE1); + obj.FillHistogram(dir+"_BG","dE1[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram(dir+"_BG","dE1[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE1()); + obj.FillHistogram(dir+"_BG","dE2[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE2()); + obj.FillHistogram(dir+"_BG","dE2[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE2()); + + } else { + obj.FillHistogram(dir.c_str(),"RF_cor[dE1_THcor]_NOTbgcuts",1000,0,0,rf_cor,2000,0,2000, dE1); + } + + + + dE1 -= ( -0.0007363*rcnp.GR_X(0)+0.00014677*rcnp.GR_X(0)*rcnp.GR_X(0) ); + obj.FillHistogram(dir.c_str(),"dE1_THcor[X]_cor",1200,-600,600, rcnp.GR_X(0),2000,0,2000, dE1); + obj.FillHistogram(dir.c_str(),"RF_cor[dE1_THcor_Xcor]",1000,0,0,rf_cor,2000,0,2000, dE1); + + + obj.FillHistogram(dir.c_str(),"dE2[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE2()); + obj.FillHistogram(dir.c_str(),"dE2[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE2()); + auto dE2 = hit.GetMeanPlastE2() - (980.2*rcnp.GR_TH(0) - 10478.3*rcnp.GR_TH(0)*rcnp.GR_TH(0)); + obj.FillHistogram(dir.c_str(),"dE2[TH]_cor",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, dE2); + obj.FillHistogram(dir.c_str(),"dE2_THcor_dE1_THcor",2000,0,2000,dE2,2000,0,2000, dE1); + obj.FillHistogram(dir.c_str(),"RF_cor[dE2_THcor]",1000,0,0,rf_cor,2000,0,2000, dE2); + + + // dE2 -= (0.023313*rcnp.GR_X(0)+ + // -0.00099883*TMath::Power(rcnp.GR_X(0),2)+ + // -2.42237e-06*TMath::Power(rcnp.GR_X(0),3)+ + // 1.77828e-08*TMath::Power(rcnp.GR_X(0),4)+ + // 6.2841e-12*TMath::Power(rcnp.GR_X(0),5)+ + // -1.02436e-13*TMath::Power(rcnp.GR_X(0),6)+ + // 6.40518e-18*TMath::Power(rcnp.GR_X(0),7)+ + // 1.58232e-19*TMath::Power(rcnp.GR_X(0),8)+ + // -9.92371e-24*TMath::Power(rcnp.GR_X(0),9)); + // obj.FillHistogram(dir.c_str(),"dE2[X]_cor9",1200,-600,600, rcnp.GR_X(0),2000,0,2000, dE2); + + + + + + + }; + if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull + fp_corrections("GR"); + } + + } } @@ -170,6 +276,9 @@ void MakeHistograms(TRuntimeObjects& obj) { 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)); @@ -182,6 +291,13 @@ void MakeHistograms(TRuntimeObjects& obj) { 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); + + fp_corrections("GR_Prompt"); + + + + + } // this needs to be moved out of the loop over qtc_chan I think - Chris @@ -292,7 +408,7 @@ void MakeHistograms(TRuntimeObjects& obj) { 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; + stream << "Ge_PZ_AsymBL_" << boardid << "_" << chan; obj.FillHistogram("CAGRA_Corrected", stream.str().c_str(),10000,0,10000,hit.GetCorrectedEnergy(hit.GetBaseSample())); Double_t prerise_base = hit.GetPreRise()/TANLEvent::GetShapingTime(); diff --git a/pygui/tcut_tab.py b/pygui/tcut_tab.py index 54fa0aa5..1f48ff11 100755 --- a/pygui/tcut_tab.py +++ b/pygui/tcut_tab.py @@ -107,7 +107,7 @@ def AddCut(self, cut, det_type = None): cut.SetLineWidth(3) self.cuts[full_name] = cut - if det_type is None: + if det_type not in self.detector_classes: parent = '' else: parent = det_type From 53dd9cbaa487aecc54dacb7edcb99ac16d4e50f9 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 18 Jul 2016 10:17:22 -0400 Subject: [PATCH 78/94] Cleaned repository for merge with upstream. Minimial use of defguards in main code body. Instead, they are mostly found in source files pertaining to RCNP analysis routines which rely on externel git submodules. --- GRAnalyzer | 1 - MPIEventLoop | 1 - histos/CAGRA.cxx | 279 ----------- histos/MakeANLHistos.cxx | 175 ------- histos/RCNPAna.cxx | 440 ------------------ histos/RCNPhistos.cxx | 318 ------------- include/TGrandRaidenHit.h | 7 + include/TRCNPSource.h | 4 +- include/TTreeSource.h | 12 +- .../TDetSystems/TGrandRaiden/TGrandRaiden.cxx | 1 + .../TGrandRaiden/TGrandRaidenHit.cxx | 4 +- libraries/TRawFormat/TRCNPSource.cxx | 8 +- libraries/TRawFormat/TRawEventSource.cxx | 11 +- makefile | 10 +- util/granalyzer.cxx | 46 -- util/simpleread_anl.cxx | 274 ----------- 16 files changed, 31 insertions(+), 1560 deletions(-) delete mode 160000 GRAnalyzer delete mode 160000 MPIEventLoop delete mode 100644 histos/CAGRA.cxx delete mode 100644 histos/MakeANLHistos.cxx delete mode 100644 histos/RCNPAna.cxx delete mode 100644 histos/RCNPhistos.cxx delete mode 100644 util/granalyzer.cxx delete mode 100644 util/simpleread_anl.cxx diff --git a/GRAnalyzer b/GRAnalyzer deleted file mode 160000 index 54c6c041..00000000 --- a/GRAnalyzer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 54c6c0414dcdd93579c44a6ab5220b15b1e9bcad diff --git a/MPIEventLoop b/MPIEventLoop deleted file mode 160000 index 27f2e4c2..00000000 --- a/MPIEventLoop +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 27f2e4c266423c9143acef01643ee8dc27f0107c diff --git a/histos/CAGRA.cxx b/histos/CAGRA.cxx deleted file mode 100644 index b0d6ae9d..00000000 --- a/histos/CAGRA.cxx +++ /dev/null @@ -1,279 +0,0 @@ - -#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/MakeANLHistos.cxx b/histos/MakeANLHistos.cxx deleted file mode 100644 index 735183d2..00000000 --- a/histos/MakeANLHistos.cxx +++ /dev/null @@ -1,175 +0,0 @@ - -#include "TRuntimeObjects.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "TCagra.h" -#include "TGrandRaiden.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; - - -// 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) { - 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; - //cout << "Coin: " << ncoin << endl; - } else if (gr) { - //for (auto& hit : *gr) { - //cout <<"Single GR: " << hit.Timestamp << endl; - //} - } - - - if (gr) { - int totalhits = 0; - for (auto& hit : *gr) { totalhits++; } - static int ncoin = 0; - ncoin+=totalhits; - //cout << "GR only: " << ncoin << endl; - } - - if (gr) { - for (auto& hit : *gr) { - - 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]); - } - 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]); - } - } - } - 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); - // } - } - } - - if(cagra) { - - //cout << "Size: " << cagra->Size() << endl; - for (auto& hit : *cagra) { - - //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()); - - obj.FillHistogram("DigitizerHits",12,97,109,hit.GetBoardID(),12,-1,11,hit.GetChannel()); - //cout << hit.GetBoardID() << " " << hit.GetChannel() << endl; - - if (hit.GetBoardID() == 0x65) { - - stream.str(""); - stream << "Leaf" << hit.GetChannel(); - obj.FillHistogram(stream.str(),10000,0,20000,hit.Charge()); - stream.str(""); - stream << "CalLeaf" << hit.GetChannel(); - obj.FillHistogram(stream.str(),10000,0,20000,hit.GetEnergy()); - } - } - } - - - if(numobj!=list->GetSize()) - list->Sort(); - - -} diff --git a/histos/RCNPAna.cxx b/histos/RCNPAna.cxx deleted file mode 100644 index be848a75..00000000 --- a/histos/RCNPAna.cxx +++ /dev/null @@ -1,440 +0,0 @@ - -#include "TRuntimeObjects.h" - -#include -#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; - -static TFile fcuts("bg_cuts.root"); -static auto cut0 = dynamic_cast(fcuts.Get("_cut0")); -static auto cut1 = dynamic_cast(fcuts.Get("_cut1")); -static auto cut2 = dynamic_cast(fcuts.Get("_cut2")); -static auto cut3 = dynamic_cast(fcuts.Get("_cut3")); - - -// 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) { - - - /////////////////////////// - // staic initializations // - /////////////////////////// - - - //reinterpret_cast(fcuts->Get("_cut0"))->IsInside - - - /////////////////////////// - - - - 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; - auto boardid = caghit.GetBoardID(); - auto channel = caghit.GetChannel(); - - obj.FillHistogram("COIN","Diff",1000,-1000,1000,cagratime-grtime); - stream.str(""); - stream << "TimeDiff_" << boardid << "_" < 235) && (tdiff < 245) ){ - - stream.str(""); - stream << "Ge_"<< boardid << "_" < fp_corrections; - - 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","dE1[dE2]",2000,0,2000, hit.GetMeanPlastE2(),2000,0,2000, hit.GetMeanPlastE1()); - - fp_corrections = [&](string dir) { - obj.FillHistogram(dir.c_str(),"RF[X]",1200,-600,600, rcnp.GR_X(0),500,700,1200,rf); - obj.FillHistogram(dir.c_str(),"RF[TH]",1000,-1,1, rcnp.GR_TH(0),500,700,1200,rf); - obj.FillHistogram(dir.c_str(),"RF[TH]cor",1000,-1,1, rcnp.GR_TH(0),500,700,1200,rf-(-1870.45+355.461)*rcnp.GR_TH(0)); - auto rf_cor = rf - (-1870.45+355.461)*rcnp.GR_TH(0); - obj.FillHistogram(dir.c_str(),"RF[X]_THcor",1200,-600,600, rcnp.GR_X(0),500,700,1200,rf_cor); - obj.FillHistogram(dir.c_str(),"RF[X]_THcor_Xcor",1200,-600,600, rcnp.GR_X(0),500,700,1200,rf_cor-0.177134*rcnp.GR_X(0)); - rf_cor -= 0.177134*rcnp.GR_X(0); - obj.FillHistogram(dir.c_str(),"dE1[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE1()); - obj.FillHistogram(dir.c_str(),"dE2[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE2()); - - - obj.FillHistogram(dir.c_str(),"dE1[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE1()); - obj.FillHistogram(dir.c_str(),"dE1[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE1()); - auto dE1 = hit.GetMeanPlastE1() - (-368.343)*rcnp.GR_TH(0); - obj.FillHistogram(dir.c_str(),"dE1[TH]_cor",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, dE1); - obj.FillHistogram(dir.c_str(),"dE1_THcor[dE2]",2000,0,2000, hit.GetMeanPlastE2(),2000,0,2000, dE1); - obj.FillHistogram(dir.c_str(),"RF_cor[dE1_THcor]",1000,0,0,rf_cor,2000,0,2000, dE1); //BOOM! :0) - - - if (cut0->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) || - cut1->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) || - cut2->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) || - cut3->IsInside(rcnp.GR_X(0),rcnp.GR_TH(0)) - ) { - obj.FillHistogram(dir+"_BG","X_TH",1200,-600,600,rcnp.GR_X(0),1000,-1,1,rcnp.GR_TH(0)); - obj.FillHistogram(dir+"_BG","dE1[RF]",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE1()); - obj.FillHistogram(dir+"_BG","dE2[RF]",1000,0,0,rf,2000,0,2000, hit.GetMeanPlastE2()); - obj.FillHistogram(dir+"_BG","dE1[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE1()); - obj.FillHistogram(dir+"_BG","dE2[RF_cor]",1000,0,0,rf_cor,2000,0,2000, hit.GetMeanPlastE2()); - obj.FillHistogram(dir+"_BG","dE1_THcor[RF_cor]",1000,0,0,rf_cor,2000,0,2000, dE1); - obj.FillHistogram(dir+"_BG","dE1[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE1()); - obj.FillHistogram(dir+"_BG","dE1[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE1()); - obj.FillHistogram(dir+"_BG","dE2[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE2()); - obj.FillHistogram(dir+"_BG","dE2[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE2()); - - } else { - obj.FillHistogram(dir.c_str(),"RF_cor[dE1_THcor]_NOTbgcuts",1000,0,0,rf_cor,2000,0,2000, dE1); - } - - - - dE1 -= ( -0.0007363*rcnp.GR_X(0)+0.00014677*rcnp.GR_X(0)*rcnp.GR_X(0) ); - obj.FillHistogram(dir.c_str(),"dE1_THcor[X]_cor",1200,-600,600, rcnp.GR_X(0),2000,0,2000, dE1); - obj.FillHistogram(dir.c_str(),"RF_cor[dE1_THcor_Xcor]",1000,0,0,rf_cor,2000,0,2000, dE1); - - - obj.FillHistogram(dir.c_str(),"dE2[X]",1200,-600,600, rcnp.GR_X(0),2000,0,2000, hit.GetMeanPlastE2()); - obj.FillHistogram(dir.c_str(),"dE2[TH]",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, hit.GetMeanPlastE2()); - auto dE2 = hit.GetMeanPlastE2() - (980.2*rcnp.GR_TH(0) - 10478.3*rcnp.GR_TH(0)*rcnp.GR_TH(0)); - obj.FillHistogram(dir.c_str(),"dE2[TH]_cor",1000,-1,1, rcnp.GR_TH(0),2000,0,2000, dE2); - obj.FillHistogram(dir.c_str(),"dE2_THcor_dE1_THcor",2000,0,2000,dE2,2000,0,2000, dE1); - obj.FillHistogram(dir.c_str(),"RF_cor[dE2_THcor]",1000,0,0,rf_cor,2000,0,2000, dE2); - - - // dE2 -= (0.023313*rcnp.GR_X(0)+ - // -0.00099883*TMath::Power(rcnp.GR_X(0),2)+ - // -2.42237e-06*TMath::Power(rcnp.GR_X(0),3)+ - // 1.77828e-08*TMath::Power(rcnp.GR_X(0),4)+ - // 6.2841e-12*TMath::Power(rcnp.GR_X(0),5)+ - // -1.02436e-13*TMath::Power(rcnp.GR_X(0),6)+ - // 6.40518e-18*TMath::Power(rcnp.GR_X(0),7)+ - // 1.58232e-19*TMath::Power(rcnp.GR_X(0),8)+ - // -9.92371e-24*TMath::Power(rcnp.GR_X(0),9)); - // obj.FillHistogram(dir.c_str(),"dE2[X]_cor9",1200,-600,600, rcnp.GR_X(0),2000,0,2000, dE2); - - - - - - - }; - if (rcnp.GR_RAYID(0) == 0) { // if track reconstruction successfull - fp_corrections("GR"); - } - - - - } - } - 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); - - - fp_corrections("GR_Prompt"); - - - - - - } - - // 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 << "_" << 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/histos/RCNPhistos.cxx b/histos/RCNPhistos.cxx deleted file mode 100644 index f524b2e7..00000000 --- a/histos/RCNPhistos.cxx +++ /dev/null @@ -1,318 +0,0 @@ - -#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++; -} diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index ce7a6a37..e30c0aa9 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -3,7 +3,14 @@ #include "TDetector.h" #include "TDetectorHit.h" + +#ifdef RCNP #include "RCNPEvent.h" +#else +#include "TTreeSource.h" +#endif + + #include diff --git a/include/TRCNPSource.h b/include/TRCNPSource.h index 7668de44..26f270a3 100644 --- a/include/TRCNPSource.h +++ b/include/TRCNPSource.h @@ -83,7 +83,9 @@ class TRCNPSource : public TRawEventSource { #include "TRawSource.h" class TRCNPSource : public TRawEventSource { public: - TRCNPSource(const char* Command, kFileType file_type) {} + TRCNPSource(const char* Command, kFileType file_type) { + throw std::runtime_error("RCNP GRAnalyzer submodule is required when utilizing TRCNPSource."); + } TRCNPSource(const TRCNPSource& source) { } ~TRCNPSource() {;} virtual std::string Status() const { return ""; } diff --git a/include/TTreeSource.h b/include/TTreeSource.h index 9fa0494c..0afa8b5a 100644 --- a/include/TTreeSource.h +++ b/include/TTreeSource.h @@ -163,17 +163,7 @@ class TTreeSource : public TRawEventSource { ClassDef(TTreeSource,0); }; // --------------------- -class RCNPEvent : public TObject { -public: - RCNPEvent() {;} - virtual ~RCNPEvent() {;} - void Clear() {;} - long GetTimestamp() { return 0; } - void SetTimestamp(const long& ts) { ; } -private: -public: - ClassDef(RCNPEvent,1); -}; +class RCNPEvent : public TObject { }; // --------------------- #endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx index f4508739..102aaeec 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaiden.cxx @@ -22,6 +22,7 @@ void TGrandRaiden::InsertHit(const TDetectorHit& hit){ } int TGrandRaiden::BuildHits(std::vector& raw_data){ + for(auto& event : raw_data){ SetTimestamp(event.GetTimestamp()); auto rcnp = reinterpret_cast(event.GetDataPtr()); diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 67aebf27..9c5e674f 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -1,7 +1,6 @@ #include "TGrandRaidenHit.h" #include "TGRUTOptions.h" -#include "RCNPEvent.h" #include "TSmartBuffer.h" #include "TMath.h" @@ -27,6 +26,7 @@ TGrandRaidenHit::~TGrandRaidenHit() { } void TGrandRaidenHit::BuildFrom(){ +#ifdef RCNP static bool once = true; if (once) { RCNPEvent::HistDefCheckSum(); @@ -71,7 +71,7 @@ void TGrandRaidenHit::BuildFrom(){ tpos2 = TMath::Sqrt((*tdc)[2]*(*tdc)[3]); } - +#endif } diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index bc5b93e6..f5d55a28 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -1,7 +1,11 @@ #include "TRCNPSource.h" +#include + +extern std::atomic stop_rcnp_signal; + +#ifdef RCNP #include "GRUTinizerInterface.h" -extern atomic stop_rcnp_signal; TRCNPSource::TRCNPSource(const char* Command, kFileType file_type) : fCommand(Command), fFileType(file_type) { @@ -112,3 +116,5 @@ template<> int ThreadsafeQueue::ObjectSize(RCNPEvent*& event) { return event->data.size(); } + +#endif diff --git a/libraries/TRawFormat/TRawEventSource.cxx b/libraries/TRawFormat/TRawEventSource.cxx index 4c5c81d9..0396f0e6 100644 --- a/libraries/TRawFormat/TRawEventSource.cxx +++ b/libraries/TRawFormat/TRawEventSource.cxx @@ -1,14 +1,9 @@ #include "TRawSource.h" - -#include "TRCNPSource.h" - -#include "TTreeSource.h" - #include - #include "TString.h" - #include "TGRUTOptions.h" +#include "TRCNPSource.h" +#include "TTreeSource.h" ClassImp(TRawEventSource) @@ -95,7 +90,7 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type); } else if (hasSuffix(filename,".bld")){ std::string command; - if (string(filename) == "online.bld") { + if (std::string(filename) == "online.bld") { std::cout << "Going online with TRCNPSource..." < -#include -#include -#include -#include "GRUTinizerInterface.h" -#include "ThreadsafeQueue.h" -#include "RCNPEvent.h" -#include -using namespace std; -/* main */ -int main() -{ - const char* filename = "~/data/run1006.bld"; - 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); - },false); - RCNPEvent* data; - static int count = 0; - while (gr_queue.Pop(data,0)) { - count++; - if (count > 1e5) { sig = 1; break; } - } - grloop.join(); - - return 0; -} - -// std::promise flag; -// std::thread grloop([&](){ StartGRAnalyzer("./datatest/run6106.bld",[&](RCNPEvent* event){ -// gr_queue.Push(*event); -// }); flag.set_value(); }); -// std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - -// auto future = flag.get_future(); -// while(future.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready) { -// std::cout << gr_queue.Size() << std::endl; -// } -// grloop.join(); - -#else -int main() { return 0; } -#endif diff --git a/util/simpleread_anl.cxx b/util/simpleread_anl.cxx deleted file mode 100644 index 6aa7c2fb..00000000 --- a/util/simpleread_anl.cxx +++ /dev/null @@ -1,274 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#define PRINT(x) std::cout << #x"=" << x << std::endl -#define STR(x) #x << '=' << x - -#define GEB_HEADER_SIZE 16 - - - -using namespace std; - -// template -// void endswap(T *objp) -// { -// unsigned char *memp = reinterpret_cast(objp); -// reverse(memp, memp + sizeof(T)); -// } - -void endswap(uint16_t* datum) { - uint16_t temp = 0; - temp = (*datum&0x00ff); - *datum = (temp<<8) + ((*datum)>>8); -} -void endswap(uint32_t* datum) { - uint32_t t1 = 0, t2 = 0, t3 = 0; - t1 = ((*datum)&0x000000ff); - t2 = ((*datum)&0x0000ff00); - t3 = ((*datum)&0x00ff0000); - *datum = (t1<<24) + (t2<<8) + (t3>>8) + ((*datum)>>24); -} - - -struct GEB_HEADER { - uint32_t type; - uint32_t length; - uint64_t timestamp; -}__attribute__((__packed__)); - -struct ANL_LED_v11 { - 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; - uint32_t timestamp_peak_high; - uint16_t postrise_end_sample; - uint16_t postrise_begin_sample; - uint16_t prerise_end_sample; - uint16_t prerise_begin_sample; - uint16_t base_sample; - 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) { - int i; - bool debug = false; - - if (argc<2) { - printf("[PATH TO INPUTFILE LIST] [-v PRINT EVENT]\n"); - exit(-1); - } - if (argc>2){ // lazy - if (strcmp(argv[2],"-v")==0) { - debug = true; - } - } - - FILE *fd,*list; - char fileName[255]; - char DataName[255]; - - strcpy(fileName,argv[1]); - list=fopen(fileName,"r"); - - while(fscanf(list,"%s",DataName)!=EOF) { - printf("%s\n",DataName); - fd = fopen(DataName, "r"); - if (!fd) { - perror("Failed to open"); - exit(1); - } - - int nevents =0; - int datasize = 64 + GEB_HEADER_SIZE; - unsigned char* header = (unsigned char*)malloc(GEB_HEADER_SIZE); - unsigned char* payload = (unsigned char*)malloc(datasize*4); - - while (fread(header,GEB_HEADER_SIZE,1,fd) == 1) { - - //if (nevents>10) break; - - auto head = (GEB_HEADER*)header; - cout << head->length << endl; - cin.get(); - datasize = head->length; - - if (fread(payload,datasize,1,fd) == 1) { - - auto event = (ANL_LED_v11*)payload; - - endswap(&event->ga_packetlength); - uint16_t ga = ((event->ga_packetlength & 0xf800) >> 11); - uint16_t length = (event->ga_packetlength & 0x7ff); - endswap(&event->ud_channel); - uint16_t userdefined = ((event->ud_channel & 0xfff0) >> 4); - uint16_t channel = (event->ud_channel & 0xf); - - endswap(&event->led_low); - endswap(&event->led_high); - uint64_t ts = (((uint64_t)event->led_high) << 32) + ((uint64_t)event->led_low); - - endswap(&event->hdrlength_evttype_hdrtype); - uint16_t headertype = ((event->hdrlength_evttype_hdrtype & 0xf) >> 0); - uint16_t eventtype = ((event->hdrlength_evttype_hdrtype & 0x380) >> 7); - uint16_t headerlength = ((event->hdrlength_evttype_hdrtype & 0xfc00) >> 10); - - endswap(&event->led_low_prev); - endswap(&event->led_high_prev); - uint64_t ts_prev = (((uint64_t)event->led_high_prev) << 16) + ((uint64_t)event->led_low_prev); - - endswap(&event->flags); - uint16_t external_disc = ((event->flags & 0x100)>>8); - uint16_t peak_valid = ((event->flags & 0x200)>>9); - uint16_t offset = ((event->flags & 0x400)>>10); - uint16_t sync_error = ((event->flags & 0x1000)>>12); - uint16_t general_error = ((event->flags & 0x2000)>>13); - uint16_t pile_up_only = ((event->flags & 0x4000)>>14); - uint16_t pile_up = ((event->flags & 0x8000)>>15); - - endswap(&event->sampled_baseline); - uint32_t sampled_baseline = ((event->sampled_baseline & 0x00FFFFFF) >> 0); - - endswap(&event->postrise_sum_low_prerise_sum); - endswap(&event->postrise_sum_high); - uint32_t prerise_sum = (event->postrise_sum_low_prerise_sum & 0xffffff); - uint32_t postrise_sum = ((event->postrise_sum_low_prerise_sum & 0xff000000)>>24); - postrise_sum += (((uint32_t)event->postrise_sum_high) << 8); - - endswap(&event->timestamp_peak_low); - endswap(&event->timestamp_peak_high); - uint64_t peak_timestamp = ((uint64_t)event->timestamp_peak_low) + (((uint64_t)event->timestamp_peak_high)<<16); - - endswap(&event->postrise_end_sample); - uint16_t postrise_end_sample = (event->postrise_end_sample & 0x3fff); - - endswap(&event->postrise_begin_sample); - uint16_t postrise_begin_sample = (event->postrise_begin_sample & 0x3fff); - - endswap(&event->prerise_end_sample); - uint16_t prerise_end_sample = (event->prerise_end_sample & 0x3fff); - - endswap(&event->prerise_begin_sample); - uint16_t prerise_begin_sample = (event->prerise_begin_sample & 0x3fff); - - endswap(&event->base_sample); - uint16_t base_sample = (event->base_sample & 0x3fff); - - endswap(&event->peak_sample); - uint16_t peak_sample = (event->peak_sample & 0x3fff); - - //cout << head->timestamp << endl; - - if (debug) { - cout << "\n\n Event number: " << nevents+1 << endl; - for (i=0;itype) << endl; - cout << STR(head->length) << endl; - cout << STR(head->timestamp) << endl; - cout << STR(ga) << endl; - cout << STR(length) << endl; - cout << STR(channel) << endl; - cout << STR(userdefined) << endl; //boardid - cout << STR(ts) << endl; - cout << STR(headertype) << endl; - cout << STR(eventtype) << endl; - cout << STR(headerlength) << endl; - cout << STR(ts_prev) << endl; - cout << STR(external_disc) << endl; - cout << STR(peak_valid) << endl; - cout << STR(offset) << endl; - cout << STR(sync_error) << endl; - cout << STR(general_error) << endl; - cout << STR(pile_up_only) << endl; - cout << STR(pile_up) << endl; - cout << dec << STR(sampled_baseline) << endl; - cout << STR(prerise_sum) << endl; - cout << STR(postrise_sum) << endl; - cout << STR(peak_timestamp) << endl; - PRINT(postrise_end_sample); - PRINT(postrise_begin_sample); - PRINT(prerise_end_sample); - PRINT(prerise_begin_sample); - PRINT(base_sample); - PRINT(peak_sample); - } - - nevents++; - } - } - delete payload; - delete header; - fclose(fd); - cout << "Read " << nevents << " events.\n"; - } - fclose(list); - exit(0); -} From ed857fe668373b0fd542fe156a3dfb996560f7da Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 18 Jul 2016 18:45:53 -0400 Subject: [PATCH 79/94] StoppableThread was not fully merged from upstream. Fixing this resolved the race condition. --- include/StoppableThread.h | 1 - libraries/TLoops/StoppableThread.cxx | 33 +--------------------------- makefile | 1 - 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/include/StoppableThread.h b/include/StoppableThread.h index 69c9cb68..b327aedc 100644 --- a/include/StoppableThread.h +++ b/include/StoppableThread.h @@ -15,7 +15,6 @@ class StoppableThread { public: static void StopAll(); - static void StopAllClean(); static bool AnyThreadRunning(); static std::string AnyThreadStatus(); diff --git a/libraries/TLoops/StoppableThread.cxx b/libraries/TLoops/StoppableThread.cxx index 71769558..513ec202 100644 --- a/libraries/TLoops/StoppableThread.cxx +++ b/libraries/TLoops/StoppableThread.cxx @@ -29,34 +29,6 @@ StoppableThread::StoppableThread(std::string name) } -void StoppableThread::StopAll() { - std::cout << "Stopping status thread" << std::endl; - stop_status_thread(); - - std::cout << "Stopping each thread" << std::endl; - for(auto& elem : fthreadmap){ - std::cout << "Stopping thread " << elem.first << std::endl; - StoppableThread* thread = elem.second; - thread->Stop(); - } - - for(auto& elem : fthreadmap){ - std::cout << "Joining thread " << elem.first << std::endl; - StoppableThread* thread = elem.second; - thread->Join(); - } - - for(auto& elem : fthreadmap){ - std::cout << "Deleting thread " << elem.first << std::endl; - StoppableThread* thread = elem.second; - delete thread; - } - - std::cout << "Last status" << std::endl; - status_out(); - std::cout << "End of function" << std::endl; -} - bool StoppableThread::AnyThreadRunning() { for(auto& elem : fthreadmap){ if(elem.second->IsRunning()){ @@ -94,8 +66,7 @@ std::string StoppableThread::Status() { return ss.str(); } -void StoppableThread::StopAllClean() { - std::cout << "Stopping each TDataLoop" << std::endl; +void StoppableThread::StopAll() { stop_rcnp_signal = 1; for(auto& elem : fthreadmap){ TDataLoop* data_loop = dynamic_cast(elem.second); @@ -118,9 +89,7 @@ void StoppableThread::StopAllClean() { delete thread; } - std::cout << "Last status" << std::endl; status_out(); - std::cout << "End of function" << std::endl; } StoppableThread *StoppableThread::Get(std::string name) { diff --git a/makefile b/makefile index 9307c681..b7008a8f 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,6 @@ .SECONDARY: .SECONDEXPANSION: -RCNP=1 PLATFORM:=$(PLATFORM) # EDIT THIS SECTION From 21afb482a936c0488ebe5f28a9bf4d4c2a0938cd Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 19 Jul 2016 10:14:38 -0400 Subject: [PATCH 80/94] added logon script and changed rint logon script path in grutrc --- .grutrc | 4 ++-- logon.C | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 logon.C diff --git a/.grutrc b/.grutrc index 8b53eb6b..7755cf6d 100644 --- a/.grutrc +++ b/.grutrc @@ -27,8 +27,8 @@ GRUT.SnapshotDir: #files to load at log in: -Rint.Logon: $(GRUTSYS)/.grut_logon -#Rint.Logon: $(GRUTSYS)/logon.C +#Rint.Logon: $(GRUTSYS)/.grut_logon +Rint.Logon: $(GRUTSYS)/logon.C Rint.History $(GRUTSYS)/.grut_history Rint.HistSize: 1000000 diff --git a/logon.C b/logon.C new file mode 100644 index 00000000..6f24202d --- /dev/null +++ b/logon.C @@ -0,0 +1,7 @@ +void logon() { + // set tick settings + gStyle->SetTitleOffset(1.2,"x"); + gStyle->SetTitleOffset(1.2,"y"); + gStyle->SetTickLength(-0.0125, "xyz"); + gStyle->SetLabelOffset(0.015, "xyz"); +} From c99da787b6c6b4638016eb1d85605afbc7d6a42d Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 19 Jul 2016 12:10:33 -0400 Subject: [PATCH 81/94] Added delay to StoppableThread::StopAll after shutting down the RCNP thread, to avoid a deadlock owing to an incomplete push after the GRUTinizer threads have shutdown. Also changed the behavior of the RCNP stdout so that it only prints status to screen in offline mode (ie without gui). --- .grutrc | 4 ++-- libraries/TLoops/StoppableThread.cxx | 2 +- libraries/TRawFormat/TRCNPSource.cxx | 4 +++- logon.C | 7 ------- 4 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 logon.C diff --git a/.grutrc b/.grutrc index 7755cf6d..8b53eb6b 100644 --- a/.grutrc +++ b/.grutrc @@ -27,8 +27,8 @@ GRUT.SnapshotDir: #files to load at log in: -#Rint.Logon: $(GRUTSYS)/.grut_logon -Rint.Logon: $(GRUTSYS)/logon.C +Rint.Logon: $(GRUTSYS)/.grut_logon +#Rint.Logon: $(GRUTSYS)/logon.C Rint.History $(GRUTSYS)/.grut_history Rint.HistSize: 1000000 diff --git a/libraries/TLoops/StoppableThread.cxx b/libraries/TLoops/StoppableThread.cxx index 513ec202..98547ab4 100644 --- a/libraries/TLoops/StoppableThread.cxx +++ b/libraries/TLoops/StoppableThread.cxx @@ -67,7 +67,7 @@ std::string StoppableThread::Status() { } void StoppableThread::StopAll() { - stop_rcnp_signal = 1; + stop_rcnp_signal = 1; std::this_thread::sleep_for(std::chrono::milliseconds(500)); for(auto& elem : fthreadmap){ TDataLoop* data_loop = dynamic_cast(elem.second); TChainLoop* chain_loop = dynamic_cast(elem.second); diff --git a/libraries/TRawFormat/TRCNPSource.cxx b/libraries/TRawFormat/TRCNPSource.cxx index 389c0031..0f9ee4a8 100644 --- a/libraries/TRawFormat/TRCNPSource.cxx +++ b/libraries/TRawFormat/TRCNPSource.cxx @@ -19,7 +19,9 @@ TRCNPSource::TRCNPSource(const char* Command, kFileType file_type) [&](RCNPEvent* event) { rcnp_queue.Push(event); }, - TGRUTOptions::Get()->SaveRCNPTree()); + TGRUTOptions::Get()->SaveRCNPTree(), + !TGRUTOptions::Get()->StartGUI() + ); //LoadFakeTimestamps(); std::this_thread::sleep_for(std::chrono::seconds(4)); diff --git a/logon.C b/logon.C deleted file mode 100644 index 6f24202d..00000000 --- a/logon.C +++ /dev/null @@ -1,7 +0,0 @@ -void logon() { - // set tick settings - gStyle->SetTitleOffset(1.2,"x"); - gStyle->SetTitleOffset(1.2,"y"); - gStyle->SetTickLength(-0.0125, "xyz"); - gStyle->SetLabelOffset(0.015, "xyz"); -} From e1bb4df1b1689967db4491602431a9ad5cb16fce Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 19 Jul 2016 12:15:12 -0400 Subject: [PATCH 82/94] Removed RCNP online.bld file --- online.bld | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 online.bld diff --git a/online.bld b/online.bld deleted file mode 100644 index e69de29b..00000000 From bc9ce915e284d186c93159a14cf86c3b1af40cec Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 5 Aug 2016 16:36:13 -0400 Subject: [PATCH 83/94] Updated LaBr hits class in TGrandRaidenHits. --- include/TGrandRaidenHit.h | 3 +++ libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index e30c0aa9..005fee8c 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -59,7 +59,10 @@ class TGrandRaidenHit : public TDetectorHit { struct LaBrHit { Int_t channel; + Double_t qtc_le; + Double_t qtc_tr; Double_t width; + //Double_t width() { return qtc_tr - qtc_le; } }; #endif diff --git a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx index 9c5e674f..7ce4bf47 100644 --- a/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx +++ b/libraries/TDetSystems/TGrandRaiden/TGrandRaidenHit.cxx @@ -52,10 +52,12 @@ void TGrandRaidenHit::BuildFrom(){ LaBrHit temphit; temphit.channel = (*qtc_le_chan)[i]; - temphit.width = (*qtc_tr_tdc)[i] - (*qtc_le_tdc)[j]; + temphit.width = (*qtc_tr_tdc)[j] - (*qtc_le_tdc)[i]; + temphit.qtc_le =(*qtc_le_tdc)[i]; + temphit.qtc_tr = (*qtc_tr_tdc)[j]; + labr_hits.push_back(temphit); - //labr_hits.emplace_back({(*qtc_le_chan)[i],(*qtc_le_tdc)[i] - (*qtc_tr_tdc)[j]}); // =( } } } From 976a720cea4eb56e0fddf77d7f0aa40a98cd720d Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 5 Aug 2016 16:48:26 -0400 Subject: [PATCH 84/94] Added comment in makefile to indicate how to compile and link against RCNP libGRAnalyzer.so and associated TDetector systems. --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index ce5ec7a0..4ebc9b11 100644 --- a/makefile +++ b/makefile @@ -29,7 +29,7 @@ LINKFLAGS_PREFIX += -Wl,--no-as-needed SHAREDSWITCH = -shared -Wl,-soname,# NO ENDING SPACE endif -# When compiling and linking against RCNP analyzer routines +# When compiling and linking against RCNP analyzer routines one must set RCNP=1 ifeq ($(RCNP),1) RCNPANAPATH = ./GRAnalyzer/analyzer RCNPANALYZER = $(realpath $(RCNPANAPATH)/../lib) From f9dfe9d955322ecb4b743a3dbb9cc4041da68db0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 5 Aug 2016 16:50:26 -0400 Subject: [PATCH 85/94] Removed git submodules for merging with upstream. --- .gitmodules | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1d229c40..00000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "GRAnalyzer"] - path = GRAnalyzer - url = git@github.com:CAGRA-GrandRaiden/GRAnalyzer.git -[submodule "MPIEventLoop"] - path = MPIEventLoop - url = git@github.com:CAGRA-GrandRaiden/MPIEventLoop.git From 54450fca765f1418d8dab99453cd75d305ed434e Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Fri, 5 Aug 2016 16:53:34 -0400 Subject: [PATCH 86/94] Reverted README for merge with upstream. --- Readme.md | 144 +----------------------------------------------------- 1 file changed, 1 insertion(+), 143 deletions(-) diff --git a/Readme.md b/Readme.md index c6b2f225..c40c14aa 100644 --- a/Readme.md +++ b/Readme.md @@ -5,148 +5,6 @@ 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. -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. +generic comments. From e53b6ff50c63b1cf859e6e08e76134a1164a5db5 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 16 Aug 2016 09:43:24 -0400 Subject: [PATCH 87/94] [Pull request #110] > TCaesar.h was modified, adding the header. Is this change needed? Removed change to TCaeser.h that is no longer necessary due to the ifdef guard. --- include/TCaesar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/TCaesar.h b/include/TCaesar.h index 63352c9a..a832c04e 100644 --- a/include/TCaesar.h +++ b/include/TCaesar.h @@ -16,7 +16,6 @@ #include "TEnv.h" //For easy parsing of detector positions #include -#include #ifndef __CINT__ #include From 2fe79fdd15c04a4dd16fc8bd5460ab6ceef8400b Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 16 Aug 2016 09:51:24 -0400 Subject: [PATCH 88/94] [Pull request #110] > Name-wise, TArgonne is a bit unspecific. Currently, each folder in TDetector is named by the detector that it unpacks. Could it be renamed to the particular detector system being unpacked for consistency? I've changed it to TCagra. Note however that TANLEvent.cxx (which is generalized to different ANL detector systems) resides in the now renamed TCagra directory. --- libraries/TDetSystems/{TArgonne => TCagra}/LinkDef.h | 0 libraries/TDetSystems/{TArgonne => TCagra}/TANLEvent.cxx | 0 libraries/TDetSystems/{TArgonne => TCagra}/TCagra.cxx | 0 libraries/TDetSystems/{TArgonne => TCagra}/TCagraHit.cxx | 0 libraries/TDetSystems/{TArgonne => TCagra}/TCagraSegmentHit.cxx | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename libraries/TDetSystems/{TArgonne => TCagra}/LinkDef.h (100%) rename libraries/TDetSystems/{TArgonne => TCagra}/TANLEvent.cxx (100%) rename libraries/TDetSystems/{TArgonne => TCagra}/TCagra.cxx (100%) rename libraries/TDetSystems/{TArgonne => TCagra}/TCagraHit.cxx (100%) rename libraries/TDetSystems/{TArgonne => TCagra}/TCagraSegmentHit.cxx (100%) diff --git a/libraries/TDetSystems/TArgonne/LinkDef.h b/libraries/TDetSystems/TCagra/LinkDef.h similarity index 100% rename from libraries/TDetSystems/TArgonne/LinkDef.h rename to libraries/TDetSystems/TCagra/LinkDef.h diff --git a/libraries/TDetSystems/TArgonne/TANLEvent.cxx b/libraries/TDetSystems/TCagra/TANLEvent.cxx similarity index 100% rename from libraries/TDetSystems/TArgonne/TANLEvent.cxx rename to libraries/TDetSystems/TCagra/TANLEvent.cxx diff --git a/libraries/TDetSystems/TArgonne/TCagra.cxx b/libraries/TDetSystems/TCagra/TCagra.cxx similarity index 100% rename from libraries/TDetSystems/TArgonne/TCagra.cxx rename to libraries/TDetSystems/TCagra/TCagra.cxx diff --git a/libraries/TDetSystems/TArgonne/TCagraHit.cxx b/libraries/TDetSystems/TCagra/TCagraHit.cxx similarity index 100% rename from libraries/TDetSystems/TArgonne/TCagraHit.cxx rename to libraries/TDetSystems/TCagra/TCagraHit.cxx diff --git a/libraries/TDetSystems/TArgonne/TCagraSegmentHit.cxx b/libraries/TDetSystems/TCagra/TCagraSegmentHit.cxx similarity index 100% rename from libraries/TDetSystems/TArgonne/TCagraSegmentHit.cxx rename to libraries/TDetSystems/TCagra/TCagraSegmentHit.cxx From 96c9c80f04aebaedb3e7f7dd2504418c99a14ba0 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Tue, 16 Aug 2016 10:27:49 -0400 Subject: [PATCH 89/94] [Pull request #110] > The std::runtime_error being thrown by TChannel::PoleZeroCorrection. Currently, if a value is not present, we either return a default value or nan if there is no reasonable default value. I now return a default value with a warning that is supressed after 5 consecutive calls. --- libraries/TGRUTUtil/TChannel.cxx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index 468e08f4..b611ae13 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -372,8 +372,16 @@ 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); if (!pz.size()) { - std::cout < Date: Mon, 22 Aug 2016 15:15:24 -0400 Subject: [PATCH 90/94] [Pull request #110] > Is the -T option still necessary? I remember that at some point you were able to read grand raiden data from a raw binary file. Is this still the case? I have removed TTreeSource and the corresponding flag and front end logic within TGRUTInt. As a note it still had utility in that it could open intermediate trees, produced from the GRAnalyzer subsystem, as sources, but as this was not done generically --- include/TGRUTOptions.h | 2 - include/TGrandRaidenHit.h | 10 +- include/TTreeSource.h | 171 ---------------------------- libraries/TGRUTint/TGRUTOptions.cxx | 3 - libraries/TGRUTint/TGRUTint.cxx | 33 ++---- libraries/TLoops/TUnpackingLoop.cxx | 7 +- libraries/TRawFormat/LinkDef.h | 3 +- libraries/TRawFormat/TRawSource.cxx | 6 +- 8 files changed, 15 insertions(+), 220 deletions(-) delete mode 100644 include/TTreeSource.h diff --git a/include/TGRUTOptions.h b/include/TGRUTOptions.h index cc2230d3..3f5e6104 100644 --- a/include/TGRUTOptions.h +++ b/include/TGRUTOptions.h @@ -49,7 +49,6 @@ class TGRUTOptions : public TObject { 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; } bool GRSingles() const { return fGRSingles; } @@ -112,7 +111,6 @@ class TGRUTOptions : public TObject { bool fStartGui; bool fMakeHistos; bool fSortMultiple; - bool fTreeSource; bool fTimeSortInput; int fTimeSortDepth; int fBuildWindow; diff --git a/include/TGrandRaidenHit.h b/include/TGrandRaidenHit.h index 005fee8c..f03eb3c4 100644 --- a/include/TGrandRaidenHit.h +++ b/include/TGrandRaidenHit.h @@ -3,17 +3,16 @@ #include "TDetector.h" #include "TDetectorHit.h" +#include #ifdef RCNP #include "RCNPEvent.h" #else -#include "TTreeSource.h" +// --------------------- +class RCNPEvent : public TObject { }; +// --------------------- #endif - - -#include - struct LaBrHit; class TGrandRaidenHit : public TDetectorHit { @@ -65,4 +64,5 @@ struct LaBrHit { //Double_t width() { return qtc_tr - qtc_le; } }; + #endif diff --git a/include/TTreeSource.h b/include/TTreeSource.h deleted file mode 100644 index 81c309d1..00000000 --- a/include/TTreeSource.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifdef RCNP -#ifndef _TTREESOURCE_H_ -#define _TTREESOURCE_H_ - -#include -#include -#include -#include - -#include "TObject.h" -#include "TRawEvent.h" -#include "TRawSource.h" -#include "TChain.h" -#include "TFile.h" - -#include "RCNPEvent.h" - -templateClassImp(TTreeSource) - -template -class TTreeSource : public TRawEventSource { -public: - - TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) - : fChain(treename), fEvent(0), fCurrentEntry(0) { - - assert(file_type == kFileType::ROOT_DATA); - - fFileType = file_type; - - fChain.Add(filename); - - fNumEvents = fChain.GetEntries(); - - fFileSize = fNumEvents*sizeof(T*); - - fChain.SetBranchAddress(eventclassname, &fEvent); - - LoadFakeTimestamps(); - } - - ~TTreeSource() {;} - - virtual std::string Status(bool long_description) const { - return Form("%s: %s %8.2f MB given %s / %s %8.2f MB total %s => %s %3.02f MB/s processed %s", - SourceDescription(long_description).c_str(), - DCYAN, GetBytesGiven()/1e6, RESET_COLOR, - BLUE, GetFileSize()/1e6, RESET_COLOR, - GREEN, GetAverageRate()/1e6, RESET_COLOR); - } - virtual std::string SourceDescription(bool long_description) const {return "File: "+std::string(fChain.GetCurrentFile()->GetName());} - - - kFileType GetFileType() const { return fFileType; } - long GetFileSize() const { return fFileSize; } - - virtual void Reset() {;} - -protected: - void SetFileSize(long file_size) { fFileSize = file_size; } - void LoadFakeTimestamps() { - - std::string line; std::stringstream stream; ULong_t ts; - ifstream file ("/projects/ceclub/sullivan/cagragr/GRUTinizer/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(); - } - } - -private: - TTreeSource() {;} - virtual int GetEvent(TRawEvent& event) { - event.SetFileType(fFileType); - - // if there are no more events, signal termination - if (fCurrentEntry == fNumEvents) { return -1; } - // copy construct a new object from the old - fEvent = new T(); - // fill the new object with current event data - fChain.GetEntry(fCurrentEntry); - // create a small memory buffer to hold the pointer to the current entry - char* ptrbytes = (char*)calloc(1,sizeof(fEvent)); - // copy the address stored in fEvent into the temporary buffer - *reinterpret_cast(ptrbytes) = fEvent; - // prepare the events smart buffer payload - auto eventbuffer = new TSmartBuffer(ptrbytes,sizeof(fEvent)); - // set the pointer address into the buffer - event.SetData(*eventbuffer); - // set the timestamp of the ttree event - if (timestamps.size()==0) { - std::cout << "End of time stamps" << std::endl; - return -1; - } - fEvent->SetTimestamp(timestamps.front()); - event.SetFragmentTimestamp(timestamps.front()); - timestamps.pop(); - - // increment the event count - fCurrentEntry++; - //fEvent = nullptr; - return sizeof(fEvent); - } - - TChain fChain; - kFileType fFileType; - long fNumEvents; - long fFileSize; - T* fEvent; - long fCurrentEntry; - queue timestamps; - - ClassDef(TTreeSource,0); -}; - -#endif - - - - - - - - - - - - - -#else // if RCNP is not defined - - -#ifndef _TTREESOURCE_H_ -#define _TTREESOURCE_H_ -#include "TObject.h" -#include "TRawEvent.h" -#include "TRawSource.h" -templateClassImp(TTreeSource) -template -class TTreeSource : public TRawEventSource { -public: - TTreeSource(const char* filename, const char* treename, const char* eventclassname, kFileType file_type) {;} - ~TTreeSource() {;} - virtual std::string Status(bool long_description) const { return ""; } - virtual std::string SourceDescription(bool long_description) const {return ""; } - kFileType GetFileType() const { return kFileType::UNKNOWN_FILETYPE; } - long GetFileSize() const { return 0; } - virtual void Reset() {;} -protected: - void SetFileSize(long file_size) { ; } -private: - TTreeSource() {;} - virtual int GetEvent(TRawEvent& event) { event.SetFragmentTimestamp(0); return -1; } - ClassDef(TTreeSource,0); -}; -// --------------------- -class RCNPEvent : public TObject { }; -// --------------------- -#endif - - -#endif // RCNP diff --git a/libraries/TGRUTint/TGRUTOptions.cxx b/libraries/TGRUTint/TGRUTOptions.cxx index f98d1e3b..cfc9720d 100644 --- a/libraries/TGRUTint/TGRUTOptions.cxx +++ b/libraries/TGRUTint/TGRUTOptions.cxx @@ -92,9 +92,6 @@ void TGRUTOptions::Load(int argc, char** argv) { .description("Root output file"); parser.option("f filter-output",&output_filtered_file) .description("Output file for raw filtered data"); - parser.option("T tree-source", &fTreeSource) - .description("Input TTree source.") - .default_value(false); parser.option("R save-rcnp-tree", &fSaveRCNPTree) .description("Save ROOT tree from raw RCNP analyzer data.") .default_value(false); diff --git a/libraries/TGRUTint/TGRUTint.cxx b/libraries/TGRUTint/TGRUTint.cxx index ba5e878d..70987249 100644 --- a/libraries/TGRUTint/TGRUTint.cxx +++ b/libraries/TGRUTint/TGRUTint.cxx @@ -149,13 +149,11 @@ void TGRUTint::ApplyOptions() { if(opt->S800InverseMapFile().length()) { TInverseMap::Get(opt->S800InverseMapFile().c_str()); } - if (!opt->TreeSource()) { - for(auto filename : opt->RootInputFiles()) { - // this will populate gChain if able. - // TChannels from the root file will be loaded as file is opened. - // GValues from the root file will be loaded as file is opened. - OpenRootFile(filename); - } + for(auto filename : opt->RootInputFiles()) { + // this will populate gChain if able. + // TChannels from the root file will be loaded as file is opened. + // GValues from the root file will be loaded as file is opened. + OpenRootFile(filename); } //if I am passed any calibrations, lets load those, this @@ -491,7 +489,6 @@ TRawEventSource* TGRUTint::OpenRawSource() { bool has_input_ring = opt->InputRing().length(); bool has_raw_file = opt->RawInputFiles().size(); bool is_glob_source = opt->SortMultipleGlob().length(); - bool has_ttree_source = (opt->RootInputFiles().size() && opt->TreeSource()); bool is_multi_sort = opt->SortMultiple(); TRawEventSource* source = NULL; @@ -502,40 +499,24 @@ TRawEventSource* TGRUTint::OpenRawSource() { true, true, opt->DefaultFileType()); - } else if(is_multi_sort && (has_raw_file || has_ttree_source)){ + } else if(is_multi_sort && has_raw_file ){ // Open multiple files, read from all at the same time. TMultiRawFile* multi_source = new TMultiRawFile(); for(auto& filename : opt->RawInputFiles()){ multi_source->AddFile(new TRawFileIn(filename.c_str())); } - if (has_ttree_source) { - // using rootfiles as source for sorting - for(auto& filename : opt->RootInputFiles()){ - multi_source->AddFile(filename.c_str()); - } - } source = multi_source; } else if(is_glob_source) { // Open multiple files, read from all at the same time. TGlobRawFile* glob_multi_source = new TGlobRawFile(opt->SortMultipleGlob()); source = glob_multi_source; - } else if(!is_multi_sort && ( - opt->RawInputFiles().size() > 1 || - (opt->RootInputFiles().size() > 1 && has_ttree_source) || - (opt->RawInputFiles().size() && opt->RootInputFiles().size() && has_ttree_source) - )){ + } else if(!is_multi_sort && opt->RawInputFiles().size() > 1){ // Open multiple files, read from each one at a a time. TSequentialRawFile* seq_source = new TSequentialRawFile(); for(auto& filename : opt->RawInputFiles()){ seq_source->Add(new TRawFileIn(filename.c_str())); } - // using rootfiles as source for sorting - if (has_ttree_source) { - for(auto& filename : opt->RootInputFiles()){ - seq_source->Add(TRawEventSource::EventSource(filename.c_str())); - } - } source = seq_source; } else { diff --git a/libraries/TLoops/TUnpackingLoop.cxx b/libraries/TLoops/TUnpackingLoop.cxx index 11e1bd4e..0b5d297e 100644 --- a/libraries/TLoops/TUnpackingLoop.cxx +++ b/libraries/TLoops/TUnpackingLoop.cxx @@ -71,15 +71,10 @@ bool TUnpackingLoop::Iteration(){ break; case kFileType::RCNP_BLD: { - //TRCNPEvent& evt = (TRCNPEvent&)raw_event; + // Consider adding HandleRCNPData to check for LAS or GR detector systems fOutputEvent->AddRawData(raw_event, kDetectorSystems::GRAND_RAIDEN); - //consider adding HandleRCNPData } break; - case kFileType::ROOT_DATA: - { - fOutputEvent->AddRawData(raw_event, kDetectorSystems::GRAND_RAIDEN); - } break; default: break; diff --git a/libraries/TRawFormat/LinkDef.h b/libraries/TRawFormat/LinkDef.h index ea0c682a..3839d139 100644 --- a/libraries/TRawFormat/LinkDef.h +++ b/libraries/TRawFormat/LinkDef.h @@ -1,4 +1,4 @@ -// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TGlobRawFile.h TOrderedRawFile.h TSequentialRawFile.h TRawFileOut.h TTreeSource.h TRCNPSource.h +// TRawSource.h TRawEvent.h TSmartBuffer.h TMultiRawFile.h TGlobRawFile.h TOrderedRawFile.h TSequentialRawFile.h TRawFileOut.h TRCNPSource.h #ifdef __CINT__ @@ -32,7 +32,6 @@ #pragma link C++ class TSequentialRawFile+; #pragma link C++ class TRawFileOut+; -#pragma link C++ class TTreeSource+; #pragma link C++ class TRCNPSource+; #pragma link C++ enum TRawEvent::ArgonneType; diff --git a/libraries/TRawFormat/TRawSource.cxx b/libraries/TRawFormat/TRawSource.cxx index 3845e4f5..02831df9 100644 --- a/libraries/TRawFormat/TRawSource.cxx +++ b/libraries/TRawFormat/TRawSource.cxx @@ -3,7 +3,6 @@ #include "TString.h" #include "TGRUTOptions.h" #include "TRCNPSource.h" -#include "TTreeSource.h" ClassImp(TRawEventSource) @@ -80,10 +79,7 @@ TRawEventSource* TRawEventSource::EventSource(const char* filename, TRawEventSource* source; - if (hasSuffix(filename,".root")){ - source = new TTreeSource(filename,"rcnptree","rcnpevent", file_type); - return source; - } else if (hasSuffix(filename,".bld")){ + if (hasSuffix(filename,".bld")){ std::string command; if (std::string(filename) == "online.bld") { std::cout << "Going online with TRCNPSource..." < Date: Mon, 22 Aug 2016 16:37:37 -0400 Subject: [PATCH 91/94] [Pull request #110] > Since the target libGRAnalyzer does not produce a file named libGRAnalysis, it should be listed as a .PHONY target. Added as a .PHONY target. --- makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/makefile b/makefile index 4ebc9b11..1e397bc8 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,7 @@ -.PHONY: clean all extras +.PHONY: clean all extras libGRAnalyzer .SECONDARY: .SECONDEXPANSION: - PLATFORM:=$(PLATFORM) # EDIT THIS SECTION From 194178ea539b1035fd309761e65e25ecc56d1223 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 22 Aug 2016 16:39:23 -0400 Subject: [PATCH 92/94] [Pull request #110] > In the _load_default_style(), we would like style.SetOptStat() to remain uncommented. These are going to be moved to the .grutrc at some point anyways to be configurable. Similarly, we would like for the SetPadTick commands not to be present. These were not meant to make it in to the pull request and have been removed. --- pygui/mainwindow.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pygui/mainwindow.py b/pygui/mainwindow.py index 1e0f2ec1..73221af9 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,8 +110,6 @@ 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 a19ad010450a12db99f3c97a8239b54f14f983b6 Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Mon, 22 Aug 2016 17:10:33 -0400 Subject: [PATCH 93/94] [Pull request #110] > Since the target libGRAnalyzer does not produce a file named libGRAnalysis, it should be listed as a .PHONY target. In retrospect, libGRAnalyzer is a meta-rule that is marked as a dependency so that make will compile the libGRAnalyzer submodule. Listing it as a PHONY target thus causes make to recompile all of GRUTinizer each time. --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index a5a545f8..d3483bbb 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -.PHONY: clean all extras pcm_files libGRAnalyzer +.PHONY: clean all extras pcm_files .SECONDARY: .SECONDEXPANSION: From 5b321cfecd172b838a5a0b88c94467f6bdbf0f8c Mon Sep 17 00:00:00 2001 From: Chris Sullivan Date: Wed, 14 Sep 2016 16:00:34 -0400 Subject: [PATCH 94/94] Pole-zero and baseline vectors were missing from TChannel::Copy which resulted in those vectors not being copied in when loading from a rootfile. --- libraries/TGRUTUtil/TChannel.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/TGRUTUtil/TChannel.cxx b/libraries/TGRUTUtil/TChannel.cxx index 223aa001..65e05297 100644 --- a/libraries/TGRUTUtil/TChannel.cxx +++ b/libraries/TGRUTUtil/TChannel.cxx @@ -143,6 +143,8 @@ void TChannel::Copy(TObject &rhs) const { ((TChannel&)rhs).collected_charge = collected_charge; ((TChannel&)rhs).segment = segment; ((TChannel&)rhs).energy_coeff = energy_coeff; + ((TChannel&)rhs).polezero_corrections = polezero_corrections; + ((TChannel&)rhs).baseline_corrections = baseline_corrections; ((TChannel&)rhs).time_coeff = time_coeff; ((TChannel&)rhs).efficiency_coeff = efficiency_coeff; ((TChannel&)rhs).pedestal = pedestal;