diff --git a/CMakeLists.txt b/CMakeLists.txt index e80f37dee..003c6b21a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.11.0 FATAL_ERROR) # Set name of our project to "R3BROOT". Has to be done after check of cmake version -project(R3BROOT) +project(R3BROOT C CXX Fortran) if(NOT EXISTS "${PROJECT_SOURCE_DIR}/macros") message(FATAL_ERROR @@ -285,6 +285,7 @@ if(NOT MODULE) add_subdirectory(neuland) add_subdirectory(los) add_subdirectory(rolu) + add_subdirectory(sci2) add_subdirectory(sci8) add_subdirectory(mtof) add_subdirectory(dtof) @@ -305,6 +306,7 @@ if(NOT MODULE) add_subdirectory(compilehelper) add_subdirectory(tcal) add_subdirectory(tracking) + add_subdirectory(tracker_rene) if(GARFIELD_FOUND) add_subdirectory(actar) set(LD_LIBRARY_PATH ${GARFIELD_LIBRARY_DIR} ${LD_LIBRARY_PATH}) diff --git a/dtof/R3BdTofDigitizer.cxx b/dtof/R3BdTofDigitizer.cxx index b4a7e2168..d674664a4 100644 --- a/dtof/R3BdTofDigitizer.cxx +++ b/dtof/R3BdTofDigitizer.cxx @@ -92,15 +92,6 @@ void R3BdTofDigitizer::Exec(Option_t* opt) Reset(); - // detector parameter - Int_t number_layers = 2; - Int_t number_paddles = 10; // per layer - - Float_t detector_width = 13.500000; - Float_t detector_thickness = 0.500000; - Float_t paddle_width = 1.350000; - Float_t paddle_thickness = 0.250000; - // vector vPoints[1000]; Int_t n_entries = fdTofPoints->GetEntries(); @@ -121,7 +112,7 @@ void R3BdTofDigitizer::Exec(Option_t* opt) Double_t energy_loss = data_element->GetEnergyLoss(); // discard all hits with an energy loss < cut - if (energy_loss < 1.) + if (energy_loss < 0.01) continue; // add hits to vector @@ -146,38 +137,46 @@ void R3BdTofDigitizer::Exec(Option_t* opt) { // energy threshold - if (vPoints[channel].at(point)->GetEnergyLoss() < 1.) + if (vPoints[channel].at(point)->GetEnergyLoss() < 0.01) continue; fHist1->Fill(vPoints[channel].at(point)->GetEnergyLoss()); if (0 == point || (vPoints[channel].at(point)->GetTime() - MapOfHits[channel]->GetTime()) > 30) { // add new hits - int layer_label; int paddle_number; - if (channel < number_paddles) + if (channel < 200) { layer_label = 0; + // paddle_number = channel - 101; paddle_number = channel; } - else + else if (channel < 300) { layer_label = 1; - paddle_number = channel - number_paddles * layer_label; + // paddle_number = channel - 201; + paddle_number = channel - 100; } - X_Pos[channel] = - -detector_width + paddle_width * (1 + layer_label) + paddle_number * (paddle_width * 2 + 0.05); - Y_Pos[channel] = vPoints[channel].at(point)->GetYIn() - 0.523976; // get y-position //local + X_Pos[channel] = -detector_width / 2. + paddle_width / 2. * (1 + layer_label) + + paddle_number * paddle_width + paddle_number * air_gap_paddles; + // X_Pos[channel] = + // -detector_width + paddle_width * (1 + layer_label) + paddle_number * + // (paddle_width * 2 + 0.05); + Y_Pos[channel] = vPoints[channel].at(point)->GetYIn(); // get y-position //local Time[channel] = vPoints[channel].at(point)->GetTime(); Energy_Loss[channel] = vPoints[channel].at(point)->GetEnergyLoss(); // add to HitData and introduce smearing of y-position, time and energy loss + cout << "Hit Tofd: ch = " << channel << " paddle = " << paddle_number << " x = " << X_Pos[channel] + << " y = " << Y_Pos[channel] << " t = " << Time[channel] << " eloss = " << Energy_Loss[channel] + << endl; MapOfHits.insert(pair( channel, new R3BTofdHitData(0., - fRnd->Uniform((X_Pos[channel] - 1.35), (X_Pos[channel] + 1.35)), + // fRnd->Uniform((X_Pos[channel] - 1.35), (X_Pos[channel] + 1.35)), + X_Pos[channel], fRnd->Gaus(Y_Pos[channel], fsigma_y), 0., fRnd->Gaus(Time[channel], fsigma_t), diff --git a/dtof/R3BdTofDigitizer.h b/dtof/R3BdTofDigitizer.h index 97a3bf0ce..17234aed1 100644 --- a/dtof/R3BdTofDigitizer.h +++ b/dtof/R3BdTofDigitizer.h @@ -13,8 +13,8 @@ // dTofDigitzer 07 aug 2017 created by Alicia Wongel -#ifndef R3BDTOFDDIGITISER_H -#define R3BDTOFDDIGITISER_H 1 +#ifndef R3BDTOFDIGITIZER_H +#define R3BDTOFDIGITIZER_H 1 #include "FairTask.h" #include "R3BTofdHitData.h" @@ -63,6 +63,17 @@ class R3BdTofDigitizer : public FairTask Float_t fsigma_t; Float_t fsigma_ELoss; + // detector parameter + Int_t number_layers = 2; + Int_t number_paddles = 44; // per layer + Float_t paddle_width = 2.70000; + Float_t paddle_thickness = 0.50000; + Float_t air_gap_paddles = 0.04; + Float_t air_gap_layer = 5.; + + Float_t detector_width = number_paddles*paddle_width+(number_paddles-1)*air_gap_paddles+paddle_width; + Float_t detector_thickness = (number_layers-1)*air_gap_layer+number_layers*paddle_thickness; + ClassDef(R3BdTofDigitizer, 1); }; diff --git a/fi0/R3BFi0Cal2Hit.cxx b/fi0/R3BFi0Cal2Hit.cxx index d0ec850dc..201cc941b 100644 --- a/fi0/R3BFi0Cal2Hit.cxx +++ b/fi0/R3BFi0Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi0Cal2Hit.h" R3BFi0Cal2Hit::R3BFi0Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi0", a_verbose, VERTICAL, 1, 256, 0, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi0", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 1, 256, 0, a_is_calibrator) { } diff --git a/fi0/R3BFi0Mapped2Cal.cxx b/fi0/R3BFi0Mapped2Cal.cxx index b4c7fa5d7..5adf89d93 100644 --- a/fi0/R3BFi0Mapped2Cal.cxx +++ b/fi0/R3BFi0Mapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi0Mapped2Cal.h" -R3BFi0Mapped2Cal::R3BFi0Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi0", a_verbose) +R3BFi0Mapped2Cal::R3BFi0Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi0", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250) { } diff --git a/fi0/R3BFi0Mapped2Cal.h b/fi0/R3BFi0Mapped2Cal.h index faaec3245..f5c55ca0e 100644 --- a/fi0/R3BFi0Mapped2Cal.h +++ b/fi0/R3BFi0Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi0Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi0Mapped2Cal(Int_t = 1); + R3BFi0Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi0Mapped2Cal(); ClassDef(R3BFi0Mapped2Cal, 1) diff --git a/fi10/CMakeLists.txt b/fi10/CMakeLists.txt index 8472faae6..ec6d30c85 100644 --- a/fi10/CMakeLists.txt +++ b/fi10/CMakeLists.txt @@ -45,6 +45,7 @@ R3BFi10.cxx R3BFi10Cal2Hit.cxx R3BFi10Mapped2Cal.cxx R3BFi10ContFact.cxx +R3BFi10Digitizer.cxx ) CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") diff --git a/fi10/Fi10LinkDef.h b/fi10/Fi10LinkDef.h index 889a2a62a..e33ce5a7b 100644 --- a/fi10/Fi10LinkDef.h +++ b/fi10/Fi10LinkDef.h @@ -22,6 +22,7 @@ #pragma link C++ class R3BFi10+; #pragma link C++ class R3BFi10Cal2Hit+; #pragma link C++ class R3BFi10Mapped2Cal+; -#pragma link C++ class R3BFi10ContFact; +#pragma link C++ class R3BFi10ContFact+; +#pragma link C++ class R3BFi10Digitizer+; #endif diff --git a/fi10/R3BFi10.cxx b/fi10/R3BFi10.cxx index 92bf09b23..2eaa9fcf4 100644 --- a/fi10/R3BFi10.cxx +++ b/fi10/R3BFi10.cxx @@ -82,7 +82,7 @@ void R3BFi10::Initialize() FairDetector::Initialize(); LOG(INFO) << "R3BFi10: initialisation"; - LOG(DEBUG) << "R3BFi10: Vol. (McId) " << gMC->VolId("FI101Log"); + LOG(DEBUG) << "R3BFi10: Vol. (McId) " << gMC->VolId("FI10Log"); } void R3BFi10::SetSpecialPhysicsCuts() diff --git a/fi10/R3BFi10Cal2Hit.cxx b/fi10/R3BFi10Cal2Hit.cxx index 630351923..345f14e80 100644 --- a/fi10/R3BFi10Cal2Hit.cxx +++ b/fi10/R3BFi10Cal2Hit.cxx @@ -13,8 +13,8 @@ #include "R3BFi10Cal2Hit.h" -R3BFi10Cal2Hit::R3BFi10Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi10", a_verbose, VERTICAL, 2, 256, 2, a_is_calibrator) +R3BFi10Cal2Hit::R3BFi10Cal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, Bool_t a_is_calibrator, Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi10", a_verbose, a_variant, VERTICAL, 2, 256, 2, a_is_calibrator) { } diff --git a/fi10/R3BFi10Cal2Hit.h b/fi10/R3BFi10Cal2Hit.h index c2efb6643..5016f8105 100644 --- a/fi10/R3BFi10Cal2Hit.h +++ b/fi10/R3BFi10Cal2Hit.h @@ -19,7 +19,7 @@ class R3BFi10Cal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi10Cal2Hit(Bool_t, Int_t = 1); + R3BFi10Cal2Hit(enum R3BTCalEngine::CTDCVariant, Bool_t, Int_t = 1); virtual ~R3BFi10Cal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi10/R3BFi10Digitizer.cxx b/fi10/R3BFi10Digitizer.cxx new file mode 100644 index 000000000..de43a1f37 --- /dev/null +++ b/fi10/R3BFi10Digitizer.cxx @@ -0,0 +1,232 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BFi10Digitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" +#include +#include +#include +#include +#include + +#include "R3BFibPoint.h" +#include "R3BMCTrack.h" + +using std::cout; +using std::endl; + +R3BFi10Digitizer::R3BFi10Digitizer() + : FairTask("R3B Fi10 Digitization scheme ") + , fFi10Points(NULL) +{ + + esigma = 0.001; + tsigma = 0.01; + ysigma = 1; +} + +R3BFi10Digitizer::R3BFi10Digitizer(Double_t e, Double_t t, Double_t y) + : FairTask("R3B Fi10 Digitization scheme ") + , fFi10Points(NULL) +{ + + esigma = e; + tsigma = t; + ysigma = y; +} + +R3BFi10Digitizer::~R3BFi10Digitizer() {} + +void R3BFi10Digitizer::SetEnergyResolution(Double_t e) { esigma = e; } + +void R3BFi10Digitizer::SetTimeResolution(Double_t t) { tsigma = t; } + +void R3BFi10Digitizer::SetYPositionResolution(Double_t y) { ysigma = y; } + +InitStatus R3BFi10Digitizer::Init() +{ + + // Get input array + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) + LOG(fatal) << "Init:No FairRootManager"; + fFi10Points = (TClonesArray*)ioman->GetObject("Fi10Point"); + + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array DchDigi + fFi10Hits = new TClonesArray("R3BBunchedFiberHitData", 1000); + ioman->Register("Fi10Hit", "Digital response in Fi10", fFi10Hits, kTRUE); + + // for sigmas + prnd = new TRandom3(); + + return kSUCCESS; +} + +void R3BFi10Digitizer::Exec(Option_t* opt) +{ + Reset(); + + auto Digitize = [this](TClonesArray* Points, TClonesArray* Hits, Int_t NumOfFibers) { + Int_t entryNum = Points->GetEntries(); + + if (!entryNum) + return; + + // creating the storage for energy and time for each PMT + std::vector* energy = new std::vector[NumOfFibers]; + std::vector* time = new std::vector[NumOfFibers]; + std::vector* y = new std::vector[NumOfFibers]; + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + time[i].push_back(99999); + energy[i].push_back(0); + y[i].push_back(0); + } + + struct TempHit + { + Int_t fiberID; + Double_t Energy; + Double_t Time; + Double_t Y; + + TempHit(Int_t id, Double_t e, Double_t t, Double_t y) + : fiberID(id) + , Energy(e) + , Time(t) + , Y(y) + { + } + }; + + // ordering the hits in time + + std::vector TempHits; + + for (Int_t i = 0; i < entryNum; ++i) + { + R3BFibPoint* data_element = (R3BFibPoint*)Points->At(i); + + TempHits.push_back(TempHit(data_element->GetDetectorID(), + data_element->GetEnergyLoss(), + data_element->GetTime(), + data_element->GetYIn())); + } + + std::sort(TempHits.begin(), TempHits.end(), [](const TempHit& lhs, const TempHit& rhs) { + return lhs.Time < rhs.Time; + }); + + // registering the hits in the PMTs + + for (TempHit& Hit : TempHits) + { + if (Hit.Energy < 0.0001) + { + continue; + } + + Int_t fiberID = Hit.fiberID; + + if (Hit.Time - time[fiberID].back() < 30) + { + energy[fiberID].back() += Hit.Energy; + + y[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Y : y[fiberID].back(); + + time[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Time : time[fiberID].back(); + } + else + { + energy[fiberID].push_back(Hit.Energy); + time[fiberID].push_back(Hit.Time); + y[fiberID].push_back(Hit.Y); + } + } + + // creating the final hits + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + for (Double_t& energyl : energy[i]) + { + if (energyl > 0.0001) + { + + Float_t xpos = + -detector_width / 2. + fiber_thickness / 2. + (i + (i * air_layer)) * fiber_thickness; + cout << "Test: Det = 10" + << " x = " << xpos << " fiber = " << i << endl; + + new ((*Hits)[Hits->GetEntries()]) + R3BBunchedFiberHitData(10, + xpos, + prnd->Gaus((y[i].at(&energyl - energy[i].data())), ysigma), + prnd->Gaus(energyl, esigma), + prnd->Gaus(time[i].at(&energyl - energy[i].data()), tsigma), + i, + 0., + 0., + 0., + 0.); + } + } + } + + delete[] energy; + delete[] time; + delete[] y; + }; + + // running the digitizer for the Fi detectors + + if (fFi10Points) + { + Digitize(fFi10Points, fFi10Hits, fiber_nbr); + } +} +// ------------------------------------------------------------------------- + +void R3BFi10Digitizer::Reset() +{ + if (fFi10Hits) + fFi10Hits->Clear(); +} + +void R3BFi10Digitizer::Finish() {} + +ClassImp(R3BFi10Digitizer) diff --git a/fi10/R3BFi10Digitizer.h b/fi10/R3BFi10Digitizer.h new file mode 100644 index 000000000..2491740e9 --- /dev/null +++ b/fi10/R3BFi10Digitizer.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// R3BFi10Digitizer.h + +#ifndef R3BFi10DIGITIZER_H +#define R3BFi10DIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BBunchedFiberHitData.h" +#include +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; + +class R3BFi10Digitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BFi10Digitizer(); + + R3BFi10Digitizer(Double_t esigma, Double_t tsigma, Double_t ysigma); + + /** Destructor **/ + ~R3BFi10Digitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + void SetEnergyResolution(Double_t e); + void SetTimeResolution(Double_t t); + void SetYPositionResolution(Double_t y); + + protected: + TClonesArray* fFi10Points; + + TClonesArray* fMCTrack; + + TClonesArray* fFi10Hits; + + private: + TRandom3* prnd; + Double_t esigma; + Double_t tsigma; + Double_t ysigma; + + Float_t detector_height = 50.000000; + Float_t fiber_thickness = 0.050000; + Int_t fiber_nbr = 1024; + Float_t dead_layer = 0.9; + Float_t air_layer = 0.01; // relative to fiber_thickness + Float_t detector_width = fiber_nbr * fiber_thickness * (1 + air_layer); + + ClassDef(R3BFi10Digitizer, 1); +}; + +#endif diff --git a/fi10/R3BFi10Mapped2Cal.cxx b/fi10/R3BFi10Mapped2Cal.cxx index f46b56d2e..d4971aa71 100644 --- a/fi10/R3BFi10Mapped2Cal.cxx +++ b/fi10/R3BFi10Mapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi10Mapped2Cal.h" -R3BFi10Mapped2Cal::R3BFi10Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi10", a_verbose, false) +R3BFi10Mapped2Cal::R3BFi10Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi10", a_verbose, a_variant, false) { } diff --git a/fi10/R3BFi10Mapped2Cal.h b/fi10/R3BFi10Mapped2Cal.h index 7eeea9660..9fedd2c26 100644 --- a/fi10/R3BFi10Mapped2Cal.h +++ b/fi10/R3BFi10Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi10Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi10Mapped2Cal(Int_t = 1); + R3BFi10Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi10Mapped2Cal(); ClassDef(R3BFi10Mapped2Cal, 1) diff --git a/fi11/CMakeLists.txt b/fi11/CMakeLists.txt index 23d66218a..9323fc6e5 100644 --- a/fi11/CMakeLists.txt +++ b/fi11/CMakeLists.txt @@ -45,6 +45,7 @@ R3BFi11.cxx R3BFi11Cal2Hit.cxx R3BFi11Mapped2Cal.cxx R3BFi11ContFact.cxx +R3BFi11Digitizer.cxx ) CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") diff --git a/fi11/Fi11LinkDef.h b/fi11/Fi11LinkDef.h index 6b0b2733a..7fb1cf3a3 100644 --- a/fi11/Fi11LinkDef.h +++ b/fi11/Fi11LinkDef.h @@ -22,6 +22,7 @@ #pragma link C++ class R3BFi11+; #pragma link C++ class R3BFi11Cal2Hit+; #pragma link C++ class R3BFi11Mapped2Cal+; -#pragma link C++ class R3BFi11ContFact; +#pragma link C++ class R3BFi11ContFact+; +#pragma link C++ class R3BFi11Digitizer+; #endif diff --git a/fi11/R3BFi11.cxx b/fi11/R3BFi11.cxx index 45a21f7fb..ea22e558b 100644 --- a/fi11/R3BFi11.cxx +++ b/fi11/R3BFi11.cxx @@ -160,8 +160,8 @@ Bool_t R3BFi11::ProcessHits(FairVolume* vol) fVolumeID = vol->getMotherCopyNo(); gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); - if (fELoss == 0.) - return kFALSE; + // if (fELoss == 0.) + // return kFALSE; fTime_out = gMC->TrackTime() * 1.0e09; // also in case particle is stopped in detector, or decays... fLength_out = gMC->TrackLength(); diff --git a/fi11/R3BFi11Cal2Hit.cxx b/fi11/R3BFi11Cal2Hit.cxx index 4c26c232b..7d490a16a 100644 --- a/fi11/R3BFi11Cal2Hit.cxx +++ b/fi11/R3BFi11Cal2Hit.cxx @@ -13,8 +13,8 @@ #include "R3BFi11Cal2Hit.h" -R3BFi11Cal2Hit::R3BFi11Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi11", a_verbose, VERTICAL, 2, 256, 2, a_is_calibrator) +R3BFi11Cal2Hit::R3BFi11Cal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, Bool_t a_is_calibrator, Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi11", a_verbose, a_variant, VERTICAL, 2, 256, 2, a_is_calibrator) { } diff --git a/fi11/R3BFi11Cal2Hit.h b/fi11/R3BFi11Cal2Hit.h index 3de0f6625..143d5b1d6 100644 --- a/fi11/R3BFi11Cal2Hit.h +++ b/fi11/R3BFi11Cal2Hit.h @@ -19,7 +19,7 @@ class R3BFi11Cal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi11Cal2Hit(Bool_t, Int_t = 1); + R3BFi11Cal2Hit(enum R3BTCalEngine::CTDCVariant, Bool_t, Int_t = 1); virtual ~R3BFi11Cal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi11/R3BFi11Digitizer.cxx b/fi11/R3BFi11Digitizer.cxx new file mode 100644 index 000000000..013789c4d --- /dev/null +++ b/fi11/R3BFi11Digitizer.cxx @@ -0,0 +1,232 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BFi11Digitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" +#include +#include +#include +#include +#include + +#include "R3BFibPoint.h" +#include "R3BMCTrack.h" + +using std::cout; +using std::endl; + +R3BFi11Digitizer::R3BFi11Digitizer() + : FairTask("R3B Fi11 Digitization scheme ") + , fFi11Points(NULL) +{ + + esigma = 0.001; + tsigma = 0.01; + ysigma = 1; +} + +R3BFi11Digitizer::R3BFi11Digitizer(Double_t e, Double_t t, Double_t y) + : FairTask("R3B Fi11 Digitization scheme ") + , fFi11Points(NULL) +{ + + esigma = e; + tsigma = t; + ysigma = y; +} + +R3BFi11Digitizer::~R3BFi11Digitizer() {} + +void R3BFi11Digitizer::SetEnergyResolution(Double_t e) { esigma = e; } + +void R3BFi11Digitizer::SetTimeResolution(Double_t t) { tsigma = t; } + +void R3BFi11Digitizer::SetYPositionResolution(Double_t y) { ysigma = y; } + +InitStatus R3BFi11Digitizer::Init() +{ + + // Get input array + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) + LOG(fatal) << "Init:No FairRootManager"; + fFi11Points = (TClonesArray*)ioman->GetObject("Fi11Point"); + + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array DchDigi + fFi11Hits = new TClonesArray("R3BBunchedFiberHitData", 1000); + ioman->Register("Fi11Hit", "Digital response in Fi11", fFi11Hits, kTRUE); + + // for sigmas + prnd = new TRandom3(); + + return kSUCCESS; +} + +void R3BFi11Digitizer::Exec(Option_t* opt) +{ + Reset(); + + auto Digitize = [this](TClonesArray* Points, TClonesArray* Hits, Int_t NumOfFibers) { + Int_t entryNum = Points->GetEntries(); + + if (!entryNum) + return; + + // creating the storage for energy and time for each PMT + std::vector* energy = new std::vector[NumOfFibers]; + std::vector* time = new std::vector[NumOfFibers]; + std::vector* y = new std::vector[NumOfFibers]; + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + time[i].push_back(99999); + energy[i].push_back(0); + y[i].push_back(0); + } + + struct TempHit + { + Int_t fiberID; + Double_t Energy; + Double_t Time; + Double_t Y; + + TempHit(Int_t id, Double_t e, Double_t t, Double_t y) + : fiberID(id) + , Energy(e) + , Time(t) + , Y(y) + { + } + }; + + // ordering the hits in time + + std::vector TempHits; + + for (Int_t i = 0; i < entryNum; ++i) + { + R3BFibPoint* data_element = (R3BFibPoint*)Points->At(i); + + TempHits.push_back(TempHit(data_element->GetDetectorID(), + data_element->GetEnergyLoss(), + data_element->GetTime(), + data_element->GetYIn())); + } + + std::sort(TempHits.begin(), TempHits.end(), [](const TempHit& lhs, const TempHit& rhs) { + return lhs.Time < rhs.Time; + }); + + // registering the hits in the PMTs + + for (TempHit& Hit : TempHits) + { + if (Hit.Energy < 0.0001) + { + continue; + } + + Int_t fiberID = Hit.fiberID; + + if (Hit.Time - time[fiberID].back() < 30) + { + energy[fiberID].back() += Hit.Energy; + + y[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Y : y[fiberID].back(); + + time[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Time : time[fiberID].back(); + } + else + { + energy[fiberID].push_back(Hit.Energy); + time[fiberID].push_back(Hit.Time); + y[fiberID].push_back(Hit.Y); + } + } + + // creating the final hits + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + for (Double_t& energyl : energy[i]) + { + if (energyl > 0.0001) + { + + Float_t xpos = + -detector_width / 2. + fiber_thickness / 2. + (i + (i * air_layer)) * fiber_thickness; + cout << "Test: Det = 11" + << " x = " << xpos << " fiber = " << i << endl; + + new ((*Hits)[Hits->GetEntries()]) + R3BBunchedFiberHitData((UInt_t)11, + xpos, + prnd->Gaus((y[i].at(&energyl - energy[i].data())), ysigma), + prnd->Gaus(energyl, esigma), + prnd->Gaus(time[i].at(&energyl - energy[i].data()), tsigma), + i, + 0., + 0., + 0., + 0.); + } + } + } + + delete[] energy; + delete[] time; + delete[] y; + }; + + // running the digitizer for the Fi detectors + + if (fFi11Points) + { + Digitize(fFi11Points, fFi11Hits, fiber_nbr); + } +} +// ------------------------------------------------------------------------- + +void R3BFi11Digitizer::Reset() +{ + if (fFi11Hits) + fFi11Hits->Clear(); +} + +void R3BFi11Digitizer::Finish() {} + +ClassImp(R3BFi11Digitizer) diff --git a/fi11/R3BFi11Digitizer.h b/fi11/R3BFi11Digitizer.h new file mode 100644 index 000000000..53048b831 --- /dev/null +++ b/fi11/R3BFi11Digitizer.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// R3BFi11Digitizer.h + +#ifndef R3BFi11DIGITIZER_H +#define R3BFi11DIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BBunchedFiberHitData.h" +#include +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; + +class R3BFi11Digitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BFi11Digitizer(); + + R3BFi11Digitizer(Double_t esigma, Double_t tsigma, Double_t ysigma); + + /** Destructor **/ + ~R3BFi11Digitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + void SetEnergyResolution(Double_t e); + void SetTimeResolution(Double_t t); + void SetYPositionResolution(Double_t y); + + protected: + TClonesArray* fFi11Points; + + TClonesArray* fMCTrack; + + TClonesArray* fFi11Hits; + + private: + TRandom3* prnd; + Double_t esigma; + Double_t tsigma; + Double_t ysigma; + + Float_t detector_height = 50.000000; + Float_t fiber_thickness = 0.050000; + Int_t fiber_nbr = 1024; + Float_t dead_layer = 0.9; + Float_t air_layer = 0.01; // relative to fiber_thickness + Float_t detector_width = fiber_nbr * fiber_thickness * (1 + air_layer); + + ClassDef(R3BFi11Digitizer, 1); +}; + +#endif diff --git a/fi11/R3BFi11Mapped2Cal.cxx b/fi11/R3BFi11Mapped2Cal.cxx index 618c41152..c21f51ee5 100644 --- a/fi11/R3BFi11Mapped2Cal.cxx +++ b/fi11/R3BFi11Mapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi11Mapped2Cal.h" -R3BFi11Mapped2Cal::R3BFi11Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi11", a_verbose, false) +R3BFi11Mapped2Cal::R3BFi11Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi11", a_verbose, a_variant, false) { } diff --git a/fi11/R3BFi11Mapped2Cal.h b/fi11/R3BFi11Mapped2Cal.h index 7214aacf3..406797f6c 100644 --- a/fi11/R3BFi11Mapped2Cal.h +++ b/fi11/R3BFi11Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi11Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi11Mapped2Cal(Int_t = 1); + R3BFi11Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi11Mapped2Cal(); ClassDef(R3BFi11Mapped2Cal, 1) diff --git a/fi12/CMakeLists.txt b/fi12/CMakeLists.txt index 45205e124..9fc7beec4 100644 --- a/fi12/CMakeLists.txt +++ b/fi12/CMakeLists.txt @@ -45,6 +45,7 @@ R3BFi12.cxx R3BFi12Cal2Hit.cxx R3BFi12Mapped2Cal.cxx R3BFi12ContFact.cxx +R3BFi12Digitizer.cxx ) CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") diff --git a/fi12/Fi12LinkDef.h b/fi12/Fi12LinkDef.h index 1e60043d9..efebf762b 100644 --- a/fi12/Fi12LinkDef.h +++ b/fi12/Fi12LinkDef.h @@ -22,6 +22,7 @@ #pragma link C++ class R3BFi12+; #pragma link C++ class R3BFi12Cal2Hit+; #pragma link C++ class R3BFi12Mapped2Cal+; -#pragma link C++ class R3BFi12ContFact; +#pragma link C++ class R3BFi12ContFact+; +#pragma link C++ class R3BFi12Digitizer+; #endif diff --git a/fi12/R3BFi12.cxx b/fi12/R3BFi12.cxx index 461ac1df8..a9d338bdf 100644 --- a/fi12/R3BFi12.cxx +++ b/fi12/R3BFi12.cxx @@ -82,7 +82,7 @@ void R3BFi12::Initialize() FairDetector::Initialize(); LOG(INFO) << "R3BFi12: initialisation"; - LOG(DEBUG) << "R3BFi12: Vol. (McId) " << gMC->VolId("FI121Log"); + LOG(DEBUG) << "R3BFi12: Vol. (McId) " << gMC->VolId("FI12Log"); } void R3BFi12::SetSpecialPhysicsCuts() @@ -160,8 +160,8 @@ Bool_t R3BFi12::ProcessHits(FairVolume* vol) fVolumeID = vol->getMotherCopyNo(); gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); - if (fELoss == 0.) - return kFALSE; + // if (fELoss == 0.) + // return kFALSE; fTime_out = gMC->TrackTime() * 1.0e09; // also in case particle is stopped in detector, or decays... fLength_out = gMC->TrackLength(); diff --git a/fi12/R3BFi12Cal2Hit.cxx b/fi12/R3BFi12Cal2Hit.cxx index bd3266d1e..11ee88267 100644 --- a/fi12/R3BFi12Cal2Hit.cxx +++ b/fi12/R3BFi12Cal2Hit.cxx @@ -13,8 +13,8 @@ #include "R3BFi12Cal2Hit.h" -R3BFi12Cal2Hit::R3BFi12Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi12", a_verbose, VERTICAL, 2, 256, 2, a_is_calibrator) +R3BFi12Cal2Hit::R3BFi12Cal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, Bool_t a_is_calibrator, Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi12", a_verbose, a_variant, VERTICAL, 2, 256, 2, a_is_calibrator) { } diff --git a/fi12/R3BFi12Cal2Hit.h b/fi12/R3BFi12Cal2Hit.h index 458c1d72f..3127e1bb4 100644 --- a/fi12/R3BFi12Cal2Hit.h +++ b/fi12/R3BFi12Cal2Hit.h @@ -19,7 +19,7 @@ class R3BFi12Cal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi12Cal2Hit(Bool_t, Int_t = 1); + R3BFi12Cal2Hit(enum R3BTCalEngine::CTDCVariant, Bool_t, Int_t = 1); virtual ~R3BFi12Cal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi12/R3BFi12Digitizer.cxx b/fi12/R3BFi12Digitizer.cxx new file mode 100644 index 000000000..c93ad2248 --- /dev/null +++ b/fi12/R3BFi12Digitizer.cxx @@ -0,0 +1,232 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BFi12Digitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" +#include +#include +#include +#include +#include + +#include "R3BFibPoint.h" +#include "R3BMCTrack.h" + +using std::cout; +using std::endl; + +R3BFi12Digitizer::R3BFi12Digitizer() + : FairTask("R3B Fi12 Digitization scheme ") + , fFi12Points(NULL) +{ + + esigma = 0.001; + tsigma = 0.01; + ysigma = 1; +} + +R3BFi12Digitizer::R3BFi12Digitizer(Double_t e, Double_t t, Double_t y) + : FairTask("R3B Fi12 Digitization scheme ") + , fFi12Points(NULL) +{ + + esigma = e; + tsigma = t; + ysigma = y; +} + +R3BFi12Digitizer::~R3BFi12Digitizer() {} + +void R3BFi12Digitizer::SetEnergyResolution(Double_t e) { esigma = e; } + +void R3BFi12Digitizer::SetTimeResolution(Double_t t) { tsigma = t; } + +void R3BFi12Digitizer::SetYPositionResolution(Double_t y) { ysigma = y; } + +InitStatus R3BFi12Digitizer::Init() +{ + + // Get input array + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) + LOG(fatal) << "Init:No FairRootManager"; + fFi12Points = (TClonesArray*)ioman->GetObject("Fi12Point"); + + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array DchDigi + fFi12Hits = new TClonesArray("R3BBunchedFiberHitData", 1000); + ioman->Register("Fi12Hit", "Digital response in Fi12", fFi12Hits, kTRUE); + + // for sigmas + prnd = new TRandom3(); + + return kSUCCESS; +} + +void R3BFi12Digitizer::Exec(Option_t* opt) +{ + Reset(); + + auto Digitize = [this](TClonesArray* Points, TClonesArray* Hits, Int_t NumOfFibers) { + Int_t entryNum = Points->GetEntries(); + + if (!entryNum) + return; + + // creating the storage for energy and time for each PMT + std::vector* energy = new std::vector[NumOfFibers]; + std::vector* time = new std::vector[NumOfFibers]; + std::vector* y = new std::vector[NumOfFibers]; + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + time[i].push_back(99999); + energy[i].push_back(0); + y[i].push_back(0); + } + + struct TempHit + { + Int_t fiberID; + Double_t Energy; + Double_t Time; + Double_t Y; + + TempHit(Int_t id, Double_t e, Double_t t, Double_t y) + : fiberID(id) + , Energy(e) + , Time(t) + , Y(y) + { + } + }; + + // ordering the hits in time + + std::vector TempHits; + + for (Int_t i = 0; i < entryNum; ++i) + { + R3BFibPoint* data_element = (R3BFibPoint*)Points->At(i); + + TempHits.push_back(TempHit(data_element->GetDetectorID(), + data_element->GetEnergyLoss(), + data_element->GetTime(), + data_element->GetYIn())); + } + + std::sort(TempHits.begin(), TempHits.end(), [](const TempHit& lhs, const TempHit& rhs) { + return lhs.Time < rhs.Time; + }); + + // registering the hits in the PMTs + + for (TempHit& Hit : TempHits) + { + if (Hit.Energy < 0.0001) + { + continue; + } + + Int_t fiberID = Hit.fiberID; + + if (Hit.Time - time[fiberID].back() < 30) + { + energy[fiberID].back() += Hit.Energy; + + y[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Y : y[fiberID].back(); + + time[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Time : time[fiberID].back(); + } + else + { + energy[fiberID].push_back(Hit.Energy); + time[fiberID].push_back(Hit.Time); + y[fiberID].push_back(Hit.Y); + } + } + + // creating the final hits + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + for (Double_t& energyl : energy[i]) + { + if (energyl > 0.0001) + { + + Float_t xpos = + -detector_width / 2. + fiber_thickness / 2. + (i + (i * air_layer)) * fiber_thickness; + cout << "Test: Det = 12" + << " x = " << xpos << " fiber = " << i << endl; + + new ((*Hits)[Hits->GetEntries()]) + R3BBunchedFiberHitData(12, + xpos, + prnd->Gaus((y[i].at(&energyl - energy[i].data())), ysigma), + prnd->Gaus(energyl, esigma), + prnd->Gaus(time[i].at(&energyl - energy[i].data()), tsigma), + i, + 0., + 0., + 0., + 0.); + } + } + } + + delete[] energy; + delete[] time; + delete[] y; + }; + + // running the digitizer for the Fi detectors + + if (fFi12Points) + { + Digitize(fFi12Points, fFi12Hits, fiber_nbr); + } +} +// ------------------------------------------------------------------------- + +void R3BFi12Digitizer::Reset() +{ + if (fFi12Hits) + fFi12Hits->Clear(); +} + +void R3BFi12Digitizer::Finish() {} + +ClassImp(R3BFi12Digitizer) diff --git a/fi12/R3BFi12Digitizer.h b/fi12/R3BFi12Digitizer.h new file mode 100644 index 000000000..aa63d2fde --- /dev/null +++ b/fi12/R3BFi12Digitizer.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// R3BFi12Digitizer.h + +#ifndef R3BFi12DIGITIZER_H +#define R3BFi12DIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BBunchedFiberHitData.h" +#include +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; + +class R3BFi12Digitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BFi12Digitizer(); + + R3BFi12Digitizer(Double_t esigma, Double_t tsigma, Double_t ysigma); + + /** Destructor **/ + ~R3BFi12Digitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + void SetEnergyResolution(Double_t e); + void SetTimeResolution(Double_t t); + void SetYPositionResolution(Double_t y); + + protected: + TClonesArray* fFi12Points; + + TClonesArray* fMCTrack; + + TClonesArray* fFi12Hits; + + private: + TRandom3* prnd; + Double_t esigma; + Double_t tsigma; + Double_t ysigma; + + Float_t detector_height = 50.000000; + Float_t fiber_thickness = 0.050000; + Int_t fiber_nbr = 1024; + Float_t dead_layer = 0.9; + Float_t air_layer = 0.01; // relative to fiber_thickness + Float_t detector_width = fiber_nbr * fiber_thickness * (1 + air_layer); + + ClassDef(R3BFi12Digitizer, 1); +}; + +#endif diff --git a/fi12/R3BFi12Mapped2Cal.cxx b/fi12/R3BFi12Mapped2Cal.cxx index 9b8aaf0c1..5f5adbb96 100644 --- a/fi12/R3BFi12Mapped2Cal.cxx +++ b/fi12/R3BFi12Mapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi12Mapped2Cal.h" -R3BFi12Mapped2Cal::R3BFi12Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi12", a_verbose, false) +R3BFi12Mapped2Cal::R3BFi12Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi12", a_verbose, a_variant, false) { } diff --git a/fi12/R3BFi12Mapped2Cal.h b/fi12/R3BFi12Mapped2Cal.h index 8a924c67b..ab6486236 100644 --- a/fi12/R3BFi12Mapped2Cal.h +++ b/fi12/R3BFi12Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi12Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi12Mapped2Cal(Int_t = 1); + R3BFi12Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi12Mapped2Cal(); ClassDef(R3BFi12Mapped2Cal, 1) diff --git a/fi13/CMakeLists.txt b/fi13/CMakeLists.txt index 5f43a6c1f..a50c50f69 100644 --- a/fi13/CMakeLists.txt +++ b/fi13/CMakeLists.txt @@ -45,6 +45,7 @@ R3BFi13.cxx R3BFi13Cal2Hit.cxx R3BFi13Mapped2Cal.cxx R3BFi13ContFact.cxx +R3BFi13Digitizer.cxx ) CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") diff --git a/fi13/Fi13LinkDef.h b/fi13/Fi13LinkDef.h index d3f87086b..ed9f96458 100644 --- a/fi13/Fi13LinkDef.h +++ b/fi13/Fi13LinkDef.h @@ -22,6 +22,7 @@ #pragma link C++ class R3BFi13+; #pragma link C++ class R3BFi13Cal2Hit+; #pragma link C++ class R3BFi13Mapped2Cal+; -#pragma link C++ class R3BFi13ContFact; +#pragma link C++ class R3BFi13ContFact+; +#pragma link C++ class R3BFi13Digitizer+; #endif diff --git a/fi13/R3BFi13.cxx b/fi13/R3BFi13.cxx index 298a64bb9..0e193bdd0 100644 --- a/fi13/R3BFi13.cxx +++ b/fi13/R3BFi13.cxx @@ -82,7 +82,7 @@ void R3BFi13::Initialize() FairDetector::Initialize(); LOG(INFO) << "R3BFi13: initialisation"; - LOG(DEBUG) << "R3BFi13: Vol. (McId) " << gMC->VolId("FI131Log"); + LOG(DEBUG) << "R3BFi13: Vol. (McId) " << gMC->VolId("FI13Log"); } void R3BFi13::SetSpecialPhysicsCuts() @@ -160,8 +160,8 @@ Bool_t R3BFi13::ProcessHits(FairVolume* vol) fVolumeID = vol->getMotherCopyNo(); gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); - if (fELoss == 0.) - return kFALSE; + // if (fELoss == 0.) + // return kFALSE; fTime_out = gMC->TrackTime() * 1.0e09; // also in case particle is stopped in detector, or decays... fLength_out = gMC->TrackLength(); diff --git a/fi13/R3BFi13Cal2Hit.cxx b/fi13/R3BFi13Cal2Hit.cxx index 4642fbe55..ac18d4dcd 100644 --- a/fi13/R3BFi13Cal2Hit.cxx +++ b/fi13/R3BFi13Cal2Hit.cxx @@ -13,8 +13,8 @@ #include "R3BFi13Cal2Hit.h" -R3BFi13Cal2Hit::R3BFi13Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi13", a_verbose, VERTICAL, 2, 256, 2, a_is_calibrator) +R3BFi13Cal2Hit::R3BFi13Cal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, Bool_t a_is_calibrator, Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi13", a_verbose, a_variant, VERTICAL, 2, 256, 2, a_is_calibrator) { } diff --git a/fi13/R3BFi13Cal2Hit.h b/fi13/R3BFi13Cal2Hit.h index 90b93b2ba..a1fb9c441 100644 --- a/fi13/R3BFi13Cal2Hit.h +++ b/fi13/R3BFi13Cal2Hit.h @@ -19,7 +19,7 @@ class R3BFi13Cal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi13Cal2Hit(Bool_t, Int_t = 1); + R3BFi13Cal2Hit(enum R3BTCalEngine::CTDCVariant, Bool_t, Int_t = 1); virtual ~R3BFi13Cal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi13/R3BFi13Digitizer.cxx b/fi13/R3BFi13Digitizer.cxx new file mode 100644 index 000000000..f52ed677c --- /dev/null +++ b/fi13/R3BFi13Digitizer.cxx @@ -0,0 +1,233 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BFi13Digitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" +#include +#include +#include +#include +#include + +#include "R3BFibPoint.h" +#include "R3BMCTrack.h" + +using std::cout; +using std::endl; + +R3BFi13Digitizer::R3BFi13Digitizer() + : FairTask("R3B Fi13 Digitization scheme ") + , fFi13Points(NULL) +{ + + esigma = 0.001; + tsigma = 0.01; + ysigma = 1; +} + +R3BFi13Digitizer::R3BFi13Digitizer(Double_t e, Double_t t, Double_t y) + : FairTask("R3B Fi13 Digitization scheme ") + , fFi13Points(NULL) +{ + + esigma = e; + tsigma = t; + ysigma = y; +} + +R3BFi13Digitizer::~R3BFi13Digitizer() {} + +void R3BFi13Digitizer::SetEnergyResolution(Double_t e) { esigma = e; } + +void R3BFi13Digitizer::SetTimeResolution(Double_t t) { tsigma = t; } + +void R3BFi13Digitizer::SetYPositionResolution(Double_t y) { ysigma = y; } + +InitStatus R3BFi13Digitizer::Init() +{ + + // Get input array + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) + LOG(fatal) << "Init:No FairRootManager"; + fFi13Points = (TClonesArray*)ioman->GetObject("Fi13Point"); + + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array DchDigi + fFi13Hits = new TClonesArray("R3BBunchedFiberHitData", 1000); + ioman->Register("Fi13Hit", "Digital response in Fi13", fFi13Hits, kTRUE); + ioman->Register("MCTrack", "MCTRACK", fMCTrack, kTRUE); + + // for sigmas + prnd = new TRandom3(); + + return kSUCCESS; +} + +void R3BFi13Digitizer::Exec(Option_t* opt) +{ + Reset(); + + auto Digitize = [this](TClonesArray* Points, TClonesArray* Hits, Int_t NumOfFibers) { + Int_t entryNum = Points->GetEntries(); + + if (!entryNum) + return; + + // creating the storage for energy and time for each PMT + std::vector* energy = new std::vector[NumOfFibers]; + std::vector* time = new std::vector[NumOfFibers]; + std::vector* y = new std::vector[NumOfFibers]; + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + time[i].push_back(99999); + energy[i].push_back(0); + y[i].push_back(0); + } + + struct TempHit + { + Int_t fiberID; + Double_t Energy; + Double_t Time; + Double_t Y; + + TempHit(Int_t id, Double_t e, Double_t t, Double_t y) + : fiberID(id) + , Energy(e) + , Time(t) + , Y(y) + { + } + }; + + // ordering the hits in time + + std::vector TempHits; + + for (Int_t i = 0; i < entryNum; ++i) + { + R3BFibPoint* data_element = (R3BFibPoint*)Points->At(i); + + TempHits.push_back(TempHit(data_element->GetDetectorID(), + data_element->GetEnergyLoss(), + data_element->GetTime(), + data_element->GetYIn())); + } + + std::sort(TempHits.begin(), TempHits.end(), [](const TempHit& lhs, const TempHit& rhs) { + return lhs.Time < rhs.Time; + }); + + // registering the hits in the PMTs + + for (TempHit& Hit : TempHits) + { + if (Hit.Energy < 0.0001) + { + continue; + } + + Int_t fiberID = Hit.fiberID; + + if (Hit.Time - time[fiberID].back() < 30) + { + energy[fiberID].back() += Hit.Energy; + + y[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Y : y[fiberID].back(); + + time[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Time : time[fiberID].back(); + } + else + { + energy[fiberID].push_back(Hit.Energy); + time[fiberID].push_back(Hit.Time); + y[fiberID].push_back(Hit.Y); + } + } + + // creating the final hits + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + for (Double_t& energyl : energy[i]) + { + if (energyl > 0.0001) + { + + Float_t xpos = + -detector_width / 2. + fiber_thickness / 2. + (i + (i * air_layer)) * fiber_thickness; + cout << "Test: Det = 13" + << " x = " << xpos << " fiber = " << i << endl; + + new ((*Hits)[Hits->GetEntries()]) + R3BBunchedFiberHitData((UInt_t)13, + xpos, + prnd->Gaus((y[i].at(&energyl - energy[i].data())), ysigma), + prnd->Gaus(energyl, esigma), + prnd->Gaus(time[i].at(&energyl - energy[i].data()), tsigma), + i, + 0., + 0., + 0., + 0.); + } + } + } + + delete[] energy; + delete[] time; + delete[] y; + }; + + // running the digitizer for the Fi detectors + + if (fFi13Points) + { + Digitize(fFi13Points, fFi13Hits, fiber_nbr); + } +} +// ------------------------------------------------------------------------- + +void R3BFi13Digitizer::Reset() +{ + if (fFi13Hits) + fFi13Hits->Clear(); +} + +void R3BFi13Digitizer::Finish() {} + +ClassImp(R3BFi13Digitizer) diff --git a/fi13/R3BFi13Digitizer.h b/fi13/R3BFi13Digitizer.h new file mode 100644 index 000000000..d93defb43 --- /dev/null +++ b/fi13/R3BFi13Digitizer.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// R3BFi13Digitizer.h + +#ifndef R3BFi13DIGITIZER_H +#define R3BFi13DIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BBunchedFiberHitData.h" +#include +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; + +class R3BFi13Digitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BFi13Digitizer(); + + R3BFi13Digitizer(Double_t esigma, Double_t tsigma, Double_t ysigma); + + /** Destructor **/ + ~R3BFi13Digitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + void SetEnergyResolution(Double_t e); + void SetTimeResolution(Double_t t); + void SetYPositionResolution(Double_t y); + + protected: + TClonesArray* fFi13Points; + + TClonesArray* fMCTrack; + + TClonesArray* fFi13Hits; + + private: + TRandom3* prnd; + Double_t esigma; + Double_t tsigma; + Double_t ysigma; + + Float_t detector_height = 50.000000; + Float_t fiber_thickness = 0.050000; + Int_t fiber_nbr = 1024; + Float_t dead_layer = 0.9; + Float_t air_layer = 0.01; // relative to fiber_thickness + Float_t detector_width = fiber_nbr * fiber_thickness * (1 + air_layer); + + ClassDef(R3BFi13Digitizer, 1); +}; + +#endif diff --git a/fi13/R3BFi13Mapped2Cal.cxx b/fi13/R3BFi13Mapped2Cal.cxx index 8289f0a11..9eb90e78f 100644 --- a/fi13/R3BFi13Mapped2Cal.cxx +++ b/fi13/R3BFi13Mapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi13Mapped2Cal.h" -R3BFi13Mapped2Cal::R3BFi13Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi13", a_verbose, false) +R3BFi13Mapped2Cal::R3BFi13Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi13", a_verbose, a_variant, false) { } diff --git a/fi13/R3BFi13Mapped2Cal.h b/fi13/R3BFi13Mapped2Cal.h index 801326971..7acc9085c 100644 --- a/fi13/R3BFi13Mapped2Cal.h +++ b/fi13/R3BFi13Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi13Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi13Mapped2Cal(Int_t = 1); + R3BFi13Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi13Mapped2Cal(); ClassDef(R3BFi13Mapped2Cal, 1) diff --git a/fi1a/R3BFi1aCal2Hit.cxx b/fi1a/R3BFi1aCal2Hit.cxx index 9f891e197..081fa5d86 100644 --- a/fi1a/R3BFi1aCal2Hit.cxx +++ b/fi1a/R3BFi1aCal2Hit.cxx @@ -13,8 +13,11 @@ #include "R3BFi1aCal2Hit.h" -R3BFi1aCal2Hit::R3BFi1aCal2Hit(Direction a_direction, Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi1a", a_verbose, a_direction, 1, 256, 1, a_is_calibrator) +R3BFi1aCal2Hit::R3BFi1aCal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, + Direction a_direction, + Bool_t a_is_calibrator, + Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi1a", a_verbose, a_variant, a_direction, 1, 256, 1, a_is_calibrator) { } diff --git a/fi1a/R3BFi1aCal2Hit.h b/fi1a/R3BFi1aCal2Hit.h index a3183ace5..b5f30b0d3 100644 --- a/fi1a/R3BFi1aCal2Hit.h +++ b/fi1a/R3BFi1aCal2Hit.h @@ -19,7 +19,7 @@ class R3BFi1aCal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi1aCal2Hit(Direction, Bool_t, Int_t = 1); + R3BFi1aCal2Hit(enum R3BTCalEngine::CTDCVariant, Direction, Bool_t, Int_t = 1); virtual ~R3BFi1aCal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi1a/R3BFi1aMapped2Cal.cxx b/fi1a/R3BFi1aMapped2Cal.cxx index 80da6a071..049605c03 100644 --- a/fi1a/R3BFi1aMapped2Cal.cxx +++ b/fi1a/R3BFi1aMapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi1aMapped2Cal.h" -R3BFi1aMapped2Cal::R3BFi1aMapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi1a", a_verbose, false) +R3BFi1aMapped2Cal::R3BFi1aMapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi1a", a_verbose, a_variant, false) { } diff --git a/fi1a/R3BFi1aMapped2Cal.h b/fi1a/R3BFi1aMapped2Cal.h index 60a010c62..a5ce831e7 100644 --- a/fi1a/R3BFi1aMapped2Cal.h +++ b/fi1a/R3BFi1aMapped2Cal.h @@ -19,10 +19,10 @@ class R3BFi1aMapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi1aMapped2Cal(Int_t = 1); + R3BFi1aMapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi1aMapped2Cal(); - ClassDef(R3BFi1aMapped2Cal, 1) + ClassDef(R3BFi1aMapped2Cal, 2) }; #endif diff --git a/fi1b/R3BFi1bCal2Hit.cxx b/fi1b/R3BFi1bCal2Hit.cxx index 9cc26a595..d9c4747d7 100644 --- a/fi1b/R3BFi1bCal2Hit.cxx +++ b/fi1b/R3BFi1bCal2Hit.cxx @@ -13,8 +13,11 @@ #include "R3BFi1bCal2Hit.h" -R3BFi1bCal2Hit::R3BFi1bCal2Hit(Direction a_direction, Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi1b", a_verbose, a_direction, 1, 256, 1, a_is_calibrator) +R3BFi1bCal2Hit::R3BFi1bCal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, + Direction a_direction, + Bool_t a_is_calibrator, + Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi1b", a_verbose, a_variant, a_direction, 1, 256, 1, a_is_calibrator) { } diff --git a/fi1b/R3BFi1bCal2Hit.h b/fi1b/R3BFi1bCal2Hit.h index 95ccadd7b..6893afd10 100644 --- a/fi1b/R3BFi1bCal2Hit.h +++ b/fi1b/R3BFi1bCal2Hit.h @@ -19,7 +19,7 @@ class R3BFi1bCal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi1bCal2Hit(Direction, Bool_t, Int_t = 1); + R3BFi1bCal2Hit(enum R3BTCalEngine::CTDCVariant, Direction, Bool_t, Int_t = 1); virtual ~R3BFi1bCal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi1b/R3BFi1bMapped2Cal.cxx b/fi1b/R3BFi1bMapped2Cal.cxx index 65c85a36a..4004981e2 100644 --- a/fi1b/R3BFi1bMapped2Cal.cxx +++ b/fi1b/R3BFi1bMapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi1bMapped2Cal.h" -R3BFi1bMapped2Cal::R3BFi1bMapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi1b", a_verbose, false) +R3BFi1bMapped2Cal::R3BFi1bMapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi1b", a_verbose, a_variant, false) { } diff --git a/fi1b/R3BFi1bMapped2Cal.h b/fi1b/R3BFi1bMapped2Cal.h index 518640377..b58559a48 100644 --- a/fi1b/R3BFi1bMapped2Cal.h +++ b/fi1b/R3BFi1bMapped2Cal.h @@ -19,10 +19,10 @@ class R3BFi1bMapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi1bMapped2Cal(Int_t = 1); + R3BFi1bMapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi1bMapped2Cal(); - ClassDef(R3BFi1bMapped2Cal, 1) + ClassDef(R3BFi1bMapped2Cal, 2) }; #endif diff --git a/fi2a/R3BFi2aCal2Hit.cxx b/fi2a/R3BFi2aCal2Hit.cxx index 59885d178..6898bd323 100644 --- a/fi2a/R3BFi2aCal2Hit.cxx +++ b/fi2a/R3BFi2aCal2Hit.cxx @@ -13,8 +13,11 @@ #include "R3BFi2aCal2Hit.h" -R3BFi2aCal2Hit::R3BFi2aCal2Hit(Direction a_direction, Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi2a", a_verbose, a_direction, 1, 256, 1, a_is_calibrator) +R3BFi2aCal2Hit::R3BFi2aCal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, + Direction a_direction, + Bool_t a_is_calibrator, + Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi2a", a_verbose, a_variant, a_direction, 1, 256, 1, a_is_calibrator) { } diff --git a/fi2a/R3BFi2aCal2Hit.h b/fi2a/R3BFi2aCal2Hit.h index 7918020df..62a0f23dc 100644 --- a/fi2a/R3BFi2aCal2Hit.h +++ b/fi2a/R3BFi2aCal2Hit.h @@ -19,7 +19,7 @@ class R3BFi2aCal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi2aCal2Hit(Direction, Bool_t, Int_t = 1); + R3BFi2aCal2Hit(enum R3BTCalEngine::CTDCVariant, Direction, Bool_t, Int_t = 1); virtual ~R3BFi2aCal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi2a/R3BFi2aMapped2Cal.cxx b/fi2a/R3BFi2aMapped2Cal.cxx index 2d2549e53..d0231662a 100644 --- a/fi2a/R3BFi2aMapped2Cal.cxx +++ b/fi2a/R3BFi2aMapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi2aMapped2Cal.h" -R3BFi2aMapped2Cal::R3BFi2aMapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi2a", a_verbose, false) +R3BFi2aMapped2Cal::R3BFi2aMapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi2a", a_verbose, a_variant, false) { } diff --git a/fi2a/R3BFi2aMapped2Cal.h b/fi2a/R3BFi2aMapped2Cal.h index 70ce7e384..d92343dbd 100644 --- a/fi2a/R3BFi2aMapped2Cal.h +++ b/fi2a/R3BFi2aMapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi2aMapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi2aMapped2Cal(Int_t = 1); + R3BFi2aMapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi2aMapped2Cal(); ClassDef(R3BFi2aMapped2Cal, 1) diff --git a/fi2b/R3BFi2bCal2Hit.cxx b/fi2b/R3BFi2bCal2Hit.cxx index 014e1f439..08ed151ff 100644 --- a/fi2b/R3BFi2bCal2Hit.cxx +++ b/fi2b/R3BFi2bCal2Hit.cxx @@ -13,8 +13,11 @@ #include "R3BFi2bCal2Hit.h" -R3BFi2bCal2Hit::R3BFi2bCal2Hit(Direction a_direction, Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi2b", a_verbose, a_direction, 1, 256, 1, a_is_calibrator) +R3BFi2bCal2Hit::R3BFi2bCal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, + Direction a_direction, + Bool_t a_is_calibrator, + Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi2b", a_verbose, a_variant, a_direction, 1, 256, 1, a_is_calibrator) { } diff --git a/fi2b/R3BFi2bCal2Hit.h b/fi2b/R3BFi2bCal2Hit.h index 51d55631f..706a07c00 100644 --- a/fi2b/R3BFi2bCal2Hit.h +++ b/fi2b/R3BFi2bCal2Hit.h @@ -19,7 +19,7 @@ class R3BFi2bCal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi2bCal2Hit(Direction, Bool_t, Int_t = 1); + R3BFi2bCal2Hit(enum R3BTCalEngine::CTDCVariant, Direction, Bool_t, Int_t = 1); virtual ~R3BFi2bCal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi2b/R3BFi2bMapped2Cal.cxx b/fi2b/R3BFi2bMapped2Cal.cxx index 29a848e1f..bd78ea7a8 100644 --- a/fi2b/R3BFi2bMapped2Cal.cxx +++ b/fi2b/R3BFi2bMapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi2bMapped2Cal.h" -R3BFi2bMapped2Cal::R3BFi2bMapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi2b", a_verbose, false) +R3BFi2bMapped2Cal::R3BFi2bMapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi2b", a_verbose, a_variant, false) { } diff --git a/fi2b/R3BFi2bMapped2Cal.h b/fi2b/R3BFi2bMapped2Cal.h index 99125a850..42dd97553 100644 --- a/fi2b/R3BFi2bMapped2Cal.h +++ b/fi2b/R3BFi2bMapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi2bMapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi2bMapped2Cal(Int_t = 1); + R3BFi2bMapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi2bMapped2Cal(); ClassDef(R3BFi2bMapped2Cal, 1) diff --git a/fi3a/CMakeLists.txt b/fi3a/CMakeLists.txt index 05f94c353..5bad590f3 100644 --- a/fi3a/CMakeLists.txt +++ b/fi3a/CMakeLists.txt @@ -44,7 +44,9 @@ set(SRCS R3BFi3aCal2Hit.cxx R3BFi3aMapped2Cal.cxx R3BFi3a.cxx -R3BFi3aContFact.cxx) +R3BFi3aContFact.cxx +R3BFi3aDigitizer.cxx +) CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") diff --git a/fi3a/Fi3aLinkDef.h b/fi3a/Fi3aLinkDef.h index 3d334b0fa..78b17fdc8 100644 --- a/fi3a/Fi3aLinkDef.h +++ b/fi3a/Fi3aLinkDef.h @@ -24,5 +24,6 @@ #pragma link C++ class R3BFi3a+; #pragma link C++ class R3BFi3aContFact+; +#pragma link C++ class R3BFi3aDigitizer+; #endif diff --git a/fi3a/R3BFi3a.cxx b/fi3a/R3BFi3a.cxx index c1b2a8210..e80cd033c 100644 --- a/fi3a/R3BFi3a.cxx +++ b/fi3a/R3BFi3a.cxx @@ -82,7 +82,7 @@ void R3BFi3a::Initialize() FairDetector::Initialize(); LOG(INFO) << "R3BFi3a: initialisation"; - LOG(DEBUG) << "R3BFi3a: Vol. (McId) " << gMC->VolId("FI3a1Log"); + LOG(DEBUG) << "R3BFi3a: Vol. (McId) " << gMC->VolId("FI3aLog"); } void R3BFi3a::SetSpecialPhysicsCuts() @@ -160,8 +160,8 @@ Bool_t R3BFi3a::ProcessHits(FairVolume* vol) fVolumeID = vol->getMotherCopyNo(); gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); - if (fELoss == 0.) - return kFALSE; + // if (fELoss == 0.) + // return kFALSE; fTime_out = gMC->TrackTime() * 1.0e09; // also in case particle is stopped in detector, or decays... fLength_out = gMC->TrackLength(); @@ -308,7 +308,7 @@ R3BFibPoint* R3BFi3a::AddHit(Int_t trackID, Bool_t R3BFi3a::CheckIfSensitive(std::string name) { - if (TString(name).Contains("FI3A1Log")) + if (TString(name).Contains("FI3ALogActive")) { return kTRUE; } diff --git a/fi3a/R3BFi3aCal2Hit.cxx b/fi3a/R3BFi3aCal2Hit.cxx index ed040a73a..592dc5ffe 100644 --- a/fi3a/R3BFi3aCal2Hit.cxx +++ b/fi3a/R3BFi3aCal2Hit.cxx @@ -13,8 +13,11 @@ #include "R3BFi3aCal2Hit.h" -R3BFi3aCal2Hit::R3BFi3aCal2Hit(Direction a_direction, Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi3a", a_verbose, a_direction, 1, 256, 2, a_is_calibrator) +R3BFi3aCal2Hit::R3BFi3aCal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, + Direction a_direction, + Bool_t a_is_calibrator, + Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi3a", a_verbose, a_variant, a_direction, 1, 256, 2, a_is_calibrator) { } diff --git a/fi3a/R3BFi3aCal2Hit.h b/fi3a/R3BFi3aCal2Hit.h index 2d45140a3..bb8b7f009 100644 --- a/fi3a/R3BFi3aCal2Hit.h +++ b/fi3a/R3BFi3aCal2Hit.h @@ -19,7 +19,7 @@ class R3BFi3aCal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi3aCal2Hit(Direction, Bool_t, Int_t = 1); + R3BFi3aCal2Hit(enum R3BTCalEngine::CTDCVariant, Direction, Bool_t, Int_t = 1); virtual ~R3BFi3aCal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi3a/R3BFi3aDigitizer.cxx b/fi3a/R3BFi3aDigitizer.cxx new file mode 100644 index 000000000..920282ba9 --- /dev/null +++ b/fi3a/R3BFi3aDigitizer.cxx @@ -0,0 +1,232 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BFi3aDigitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" +#include +#include +#include +#include +#include + +#include "R3BFibPoint.h" +#include "R3BMCTrack.h" + +using std::cout; +using std::endl; + +R3BFi3aDigitizer::R3BFi3aDigitizer() + : FairTask("R3B Fi3a Digitization scheme ") + , fFi3aPoints(NULL) +{ + + esigma = 0.001; + tsigma = 0.01; + ysigma = 1; +} + +R3BFi3aDigitizer::R3BFi3aDigitizer(Double_t e, Double_t t, Double_t y) + : FairTask("R3B Fi3a Digitization scheme ") + , fFi3aPoints(NULL) +{ + + esigma = e; + tsigma = t; + ysigma = y; +} + +R3BFi3aDigitizer::~R3BFi3aDigitizer() {} + +void R3BFi3aDigitizer::SetEnergyResolution(Double_t e) { esigma = e; } + +void R3BFi3aDigitizer::SetTimeResolution(Double_t t) { tsigma = t; } + +void R3BFi3aDigitizer::SetYPositionResolution(Double_t y) { ysigma = y; } + +InitStatus R3BFi3aDigitizer::Init() +{ + + // Get input array + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) + LOG(fatal) << "Init:No FairRootManager"; + fFi3aPoints = (TClonesArray*)ioman->GetObject("Fi3aPoint"); + + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array DchDigi + fFi3aHits = new TClonesArray("R3BBunchedFiberHitData", 1000); + ioman->Register("Fi3aHit", "Digital response in Fi3a", fFi3aHits, kTRUE); + + // for sigmas + prnd = new TRandom3(); + + return kSUCCESS; +} + +void R3BFi3aDigitizer::Exec(Option_t* opt) +{ + Reset(); + + auto Digitize = [this](TClonesArray* Points, TClonesArray* Hits, Int_t NumOfFibers) { + Int_t entryNum = Points->GetEntries(); + + if (!entryNum) + return; + + // creating the storage for energy and time for each PMT + std::vector* energy = new std::vector[NumOfFibers]; + std::vector* time = new std::vector[NumOfFibers]; + std::vector* y = new std::vector[NumOfFibers]; + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + time[i].push_back(99999); + energy[i].push_back(0); + y[i].push_back(0); + } + + struct TempHit + { + Int_t fiberID; + Double_t Energy; + Double_t Time; + Double_t Y; + + TempHit(Int_t id, Double_t e, Double_t t, Double_t y) + : fiberID(id) + , Energy(e) + , Time(t) + , Y(y) + { + } + }; + + // ordering the hits in time + + std::vector TempHits; + + for (Int_t i = 0; i < entryNum; ++i) + { + R3BFibPoint* data_element = (R3BFibPoint*)Points->At(i); + + TempHits.push_back(TempHit(data_element->GetDetectorID(), + data_element->GetEnergyLoss(), + data_element->GetTime(), + data_element->GetYIn())); + } + + std::sort(TempHits.begin(), TempHits.end(), [](const TempHit& lhs, const TempHit& rhs) { + return lhs.Time < rhs.Time; + }); + + // registering the hits in the PMTs + + for (TempHit& Hit : TempHits) + { + if (Hit.Energy < 0.0001) + { + continue; + } + + Int_t fiberID = Hit.fiberID; + + if (Hit.Time - time[fiberID].back() < 30) + { + energy[fiberID].back() += Hit.Energy; + + y[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Y : y[fiberID].back(); + + time[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Time : time[fiberID].back(); + } + else + { + energy[fiberID].push_back(Hit.Energy); + time[fiberID].push_back(Hit.Time); + y[fiberID].push_back(Hit.Y); + } + } + + // creating the final hits + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + for (Double_t& energyl : energy[i]) + { + if (energyl > 0.0001) + { + + Float_t xpos = + -detector_width / 2. + fiber_thickness / 2. + (i + (i * air_layer)) * fiber_thickness; + cout << "Test: Det = 3a" + << " x = " << xpos << " fiber = " << i << endl; + + new ((*Hits)[Hits->GetEntries()]) + R3BBunchedFiberHitData(1, + xpos, + prnd->Gaus((y[i].at(&energyl - energy[i].data())), ysigma), + prnd->Gaus(energyl, esigma), + prnd->Gaus(time[i].at(&energyl - energy[i].data()), tsigma), + i, + 0., + 0., + 0., + 0.); + } + } + } + + delete[] energy; + delete[] time; + delete[] y; + }; + + // running the digitizer for the Fi detectors + + if (fFi3aPoints) + { + Digitize(fFi3aPoints, fFi3aHits, fiber_nbr); + } +} +// ------------------------------------------------------------------------- + +void R3BFi3aDigitizer::Reset() +{ + if (fFi3aHits) + fFi3aHits->Clear(); +} + +void R3BFi3aDigitizer::Finish() {} + +ClassImp(R3BFi3aDigitizer) diff --git a/fi3a/R3BFi3aDigitizer.h b/fi3a/R3BFi3aDigitizer.h new file mode 100644 index 000000000..fb774e374 --- /dev/null +++ b/fi3a/R3BFi3aDigitizer.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// R3BFi3aDigitizer.h + +#ifndef R3BFi3aDIGITIZER_H +#define R3BFi3aDIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BBunchedFiberHitData.h" +#include +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; + +class R3BFi3aDigitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BFi3aDigitizer(); + + R3BFi3aDigitizer(Double_t esigma, Double_t tsigma, Double_t ysigma); + + /** Destructor **/ + ~R3BFi3aDigitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + void SetEnergyResolution(Double_t e); + void SetTimeResolution(Double_t t); + void SetYPositionResolution(Double_t y); + + protected: + TClonesArray* fFi3aPoints; + + TClonesArray* fMCTrack; + + TClonesArray* fFi3aHits; + + private: + TRandom3* prnd; + Double_t esigma; + Double_t tsigma; + Double_t ysigma; + + Float_t detector_height = 10.000000; + Float_t fiber_thickness = 0.021000; + Int_t fiber_nbr = 512; + Float_t dead_layer = 0.9; + Float_t air_layer = 0.01; // relative to fiber_thickness + Float_t detector_width = fiber_nbr * fiber_thickness * (1 + air_layer); + + ClassDef(R3BFi3aDigitizer, 1); +}; + +#endif diff --git a/fi3a/R3BFi3aMapped2Cal.cxx b/fi3a/R3BFi3aMapped2Cal.cxx index d70db6575..ca2e404d1 100644 --- a/fi3a/R3BFi3aMapped2Cal.cxx +++ b/fi3a/R3BFi3aMapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi3aMapped2Cal.h" -R3BFi3aMapped2Cal::R3BFi3aMapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi3a", a_verbose, false) +R3BFi3aMapped2Cal::R3BFi3aMapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi3a", a_verbose, a_variant, false) { } diff --git a/fi3a/R3BFi3aMapped2Cal.h b/fi3a/R3BFi3aMapped2Cal.h index a10bbdbf0..263f8b855 100644 --- a/fi3a/R3BFi3aMapped2Cal.h +++ b/fi3a/R3BFi3aMapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi3aMapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi3aMapped2Cal(Int_t = 1); + R3BFi3aMapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi3aMapped2Cal(); ClassDef(R3BFi3aMapped2Cal, 1) diff --git a/fi3b/CMakeLists.txt b/fi3b/CMakeLists.txt index 564d17b89..9b67a7233 100644 --- a/fi3b/CMakeLists.txt +++ b/fi3b/CMakeLists.txt @@ -45,6 +45,7 @@ R3BFi3bCal2Hit.cxx R3BFi3bMapped2Cal.cxx R3BFi3b.cxx R3BFi3bContFact.cxx +R3BFi3bDigitizer.cxx ) CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") diff --git a/fi3b/Fi3bLinkDef.h b/fi3b/Fi3bLinkDef.h index 32eeda1de..0dfbc3e11 100644 --- a/fi3b/Fi3bLinkDef.h +++ b/fi3b/Fi3bLinkDef.h @@ -22,6 +22,7 @@ #pragma link C++ class R3BFi3bCal2Hit+; #pragma link C++ class R3BFi3bMapped2Cal+; #pragma link C++ class R3BFi3b+; -#pragma link C++ class R3BFi3bContFact; +#pragma link C++ class R3BFi3bContFact;+ +#pragma link C++ class R3BFi3bDigitizer+; #endif diff --git a/fi3b/R3BFi3b.cxx b/fi3b/R3BFi3b.cxx index f3fbefe38..eaf1f3b11 100644 --- a/fi3b/R3BFi3b.cxx +++ b/fi3b/R3BFi3b.cxx @@ -160,8 +160,8 @@ Bool_t R3BFi3b::ProcessHits(FairVolume* vol) fVolumeID = vol->getMotherCopyNo(); gMC->TrackPosition(fPosOut); gMC->TrackMomentum(fMomOut); - if (fELoss == 0.) - return kFALSE; + // if (fELoss == 0.) + // return kFALSE; fTime_out = gMC->TrackTime() * 1.0e09; // also in case particle is stopped in detector, or decays... fLength_out = gMC->TrackLength(); @@ -308,7 +308,7 @@ R3BFibPoint* R3BFi3b::AddHit(Int_t trackID, Bool_t R3BFi3b::CheckIfSensitive(std::string name) { - if (TString(name).Contains("FI3B1Log")) + if (TString(name).Contains("FI3BLogActive")) { return kTRUE; } diff --git a/fi3b/R3BFi3bCal2Hit.cxx b/fi3b/R3BFi3bCal2Hit.cxx index af8fb0ff2..08fadbb80 100644 --- a/fi3b/R3BFi3bCal2Hit.cxx +++ b/fi3b/R3BFi3bCal2Hit.cxx @@ -13,8 +13,11 @@ #include "R3BFi3bCal2Hit.h" -R3BFi3bCal2Hit::R3BFi3bCal2Hit(Direction a_direction, Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi3b", a_verbose, a_direction, 1, 256, 2, a_is_calibrator) +R3BFi3bCal2Hit::R3BFi3bCal2Hit(enum R3BTCalEngine::CTDCVariant a_variant, + Direction a_direction, + Bool_t a_is_calibrator, + Int_t a_verbose) + : R3BBunchedFiberCal2Hit("Fi3b", a_verbose, a_variant, a_direction, 1, 256, 2, a_is_calibrator) { } diff --git a/fi3b/R3BFi3bCal2Hit.h b/fi3b/R3BFi3bCal2Hit.h index 447e4595c..8d5afaaba 100644 --- a/fi3b/R3BFi3bCal2Hit.h +++ b/fi3b/R3BFi3bCal2Hit.h @@ -19,7 +19,7 @@ class R3BFi3bCal2Hit : public R3BBunchedFiberCal2Hit { public: - R3BFi3bCal2Hit(Direction, Bool_t, Int_t = 1); + R3BFi3bCal2Hit(enum R3BTCalEngine::CTDCVariant, Direction, Bool_t, Int_t = 1); virtual ~R3BFi3bCal2Hit(); UInt_t FixMistake(UInt_t); diff --git a/fi3b/R3BFi3bDigitizer.cxx b/fi3b/R3BFi3bDigitizer.cxx new file mode 100644 index 000000000..12f6a5524 --- /dev/null +++ b/fi3b/R3BFi3bDigitizer.cxx @@ -0,0 +1,232 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BFi3bDigitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" +#include +#include +#include +#include +#include + +#include "R3BFibPoint.h" +#include "R3BMCTrack.h" + +using std::cout; +using std::endl; + +R3BFi3bDigitizer::R3BFi3bDigitizer() + : FairTask("R3B Fi3b Digitization scheme ") + , fFi3bPoints(NULL) +{ + + esigma = 0.001; + tsigma = 0.01; + ysigma = 1; +} + +R3BFi3bDigitizer::R3BFi3bDigitizer(Double_t e, Double_t t, Double_t y) + : FairTask("R3B Fi3b Digitization scheme ") + , fFi3bPoints(NULL) +{ + + esigma = e; + tsigma = t; + ysigma = y; +} + +R3BFi3bDigitizer::~R3BFi3bDigitizer() {} + +void R3BFi3bDigitizer::SetEnergyResolution(Double_t e) { esigma = e; } + +void R3BFi3bDigitizer::SetTimeResolution(Double_t t) { tsigma = t; } + +void R3BFi3bDigitizer::SetYPositionResolution(Double_t y) { ysigma = y; } + +InitStatus R3BFi3bDigitizer::Init() +{ + + // Get input array + FairRootManager* ioman = FairRootManager::Instance(); + if (!ioman) + LOG(fatal) << "Init:No FairRootManager"; + fFi3bPoints = (TClonesArray*)ioman->GetObject("Fi3bPoint"); + + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array DchDigi + fFi3bHits = new TClonesArray("R3BBunchedFiberHitData", 1000); + ioman->Register("Fi3bHit", "Digital response in Fi3b", fFi3bHits, kTRUE); + + // for sigmas + prnd = new TRandom3(); + + return kSUCCESS; +} + +void R3BFi3bDigitizer::Exec(Option_t* opt) +{ + Reset(); + + auto Digitize = [this](TClonesArray* Points, TClonesArray* Hits, Int_t NumOfFibers) { + Int_t entryNum = Points->GetEntries(); + + if (!entryNum) + return; + + // creating the storage for energy and time for each PMT + std::vector* energy = new std::vector[NumOfFibers]; + std::vector* time = new std::vector[NumOfFibers]; + std::vector* y = new std::vector[NumOfFibers]; + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + time[i].push_back(99999); + energy[i].push_back(0); + y[i].push_back(0); + } + + struct TempHit + { + Int_t fiberID; + Double_t Energy; + Double_t Time; + Double_t Y; + + TempHit(Int_t id, Double_t e, Double_t t, Double_t y) + : fiberID(id) + , Energy(e) + , Time(t) + , Y(y) + { + } + }; + + // ordering the hits in time + + std::vector TempHits; + + for (Int_t i = 0; i < entryNum; ++i) + { + R3BFibPoint* data_element = (R3BFibPoint*)Points->At(i); + + TempHits.push_back(TempHit(data_element->GetDetectorID(), + data_element->GetEnergyLoss(), + data_element->GetTime(), + data_element->GetYIn())); + } + + std::sort(TempHits.begin(), TempHits.end(), [](const TempHit& lhs, const TempHit& rhs) { + return lhs.Time < rhs.Time; + }); + + // registering the hits in the PMTs + + for (TempHit& Hit : TempHits) + { + if (Hit.Energy < 0.0001) + { + continue; + } + + Int_t fiberID = Hit.fiberID; + + if (Hit.Time - time[fiberID].back() < 30) + { + energy[fiberID].back() += Hit.Energy; + + y[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Y : y[fiberID].back(); + + time[fiberID].back() = (time[fiberID].back() > Hit.Time) ? Hit.Time : time[fiberID].back(); + } + else + { + energy[fiberID].push_back(Hit.Energy); + time[fiberID].push_back(Hit.Time); + y[fiberID].push_back(Hit.Y); + } + } + + // creating the final hits + + for (Int_t i = 0; i < NumOfFibers; ++i) + { + for (Double_t& energyl : energy[i]) + { + if (energyl > 0.0001) + { + + Float_t xpos = + -detector_width / 2. + fiber_thickness / 2. + (i + (i * air_layer)) * fiber_thickness; + cout << "Test Det = 3b" + << " x = " << xpos << " fiber = " << i << endl; + + new ((*Hits)[Hits->GetEntries()]) + R3BBunchedFiberHitData(2, + xpos, + prnd->Gaus((y[i].at(&energyl - energy[i].data())), ysigma), + prnd->Gaus(energyl, esigma), + prnd->Gaus(time[i].at(&energyl - energy[i].data()), tsigma), + i, + 0., + 0., + 0., + 0.); + } + } + } + + delete[] energy; + delete[] time; + delete[] y; + }; + + // running the digitizer for the Fi detectors + + if (fFi3bPoints) + { + Digitize(fFi3bPoints, fFi3bHits, fiber_nbr); + } +} +// ------------------------------------------------------------------------- + +void R3BFi3bDigitizer::Reset() +{ + if (fFi3bHits) + fFi3bHits->Clear(); +} + +void R3BFi3bDigitizer::Finish() {} + +ClassImp(R3BFi3bDigitizer) diff --git a/fi3b/R3BFi3bDigitizer.h b/fi3b/R3BFi3bDigitizer.h new file mode 100644 index 000000000..fa8246582 --- /dev/null +++ b/fi3b/R3BFi3bDigitizer.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// R3BFi3bDigitizer.h + +#ifndef R3BFi3bDIGITIZER_H +#define R3BFi3bDIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BBunchedFiberHitData.h" +#include +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; + +class R3BFi3bDigitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BFi3bDigitizer(); + + R3BFi3bDigitizer(Double_t esigma, Double_t tsigma, Double_t ysigma); + + /** Destructor **/ + ~R3BFi3bDigitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + void SetEnergyResolution(Double_t e); + void SetTimeResolution(Double_t t); + void SetYPositionResolution(Double_t y); + + protected: + TClonesArray* fFi3bPoints; + + TClonesArray* fMCTrack; + + TClonesArray* fFi3bHits; + + private: + TRandom3* prnd; + Double_t esigma; + Double_t tsigma; + Double_t ysigma; + + Float_t detector_height = 10.000000; + Float_t fiber_thickness = 0.021000; + Int_t fiber_nbr = 512; + Float_t dead_layer = 0.9; + Float_t air_layer = 0.01; // relative to fiber_thickness + Float_t detector_width = fiber_nbr * fiber_thickness * (1 + air_layer); + + ClassDef(R3BFi3bDigitizer, 1); +}; + +#endif diff --git a/fi3b/R3BFi3bMapped2Cal.cxx b/fi3b/R3BFi3bMapped2Cal.cxx index ea94b4b73..7cfb83028 100644 --- a/fi3b/R3BFi3bMapped2Cal.cxx +++ b/fi3b/R3BFi3bMapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi3bMapped2Cal.h" -R3BFi3bMapped2Cal::R3BFi3bMapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi3b", a_verbose, false) +R3BFi3bMapped2Cal::R3BFi3bMapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi3b", a_verbose, a_variant, false) { } diff --git a/fi3b/R3BFi3bMapped2Cal.h b/fi3b/R3BFi3bMapped2Cal.h index 93ec081ed..e7d40598c 100644 --- a/fi3b/R3BFi3bMapped2Cal.h +++ b/fi3b/R3BFi3bMapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi3bMapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi3bMapped2Cal(Int_t = 1); + R3BFi3bMapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi3bMapped2Cal(); ClassDef(R3BFi3bMapped2Cal, 1) diff --git a/fi4/CMakeLists.txt b/fi4/CMakeLists.txt index fe21a0217..d40346ccf 100644 --- a/fi4/CMakeLists.txt +++ b/fi4/CMakeLists.txt @@ -35,6 +35,7 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/tofData ${R3BROOT_SOURCE_DIR}/r3bdata/landData ${R3BROOT_SOURCE_DIR}/r3bdata/trackerData ${R3BROOT_SOURCE_DIR}/tracking +${R3BROOT_SOURCE_DIR}/tcal ) include_directories( ${INCLUDE_DIRECTORIES}) diff --git a/fi4/R3BFi4Cal2Hit.cxx b/fi4/R3BFi4Cal2Hit.cxx index 4f60004d6..01aa47f2d 100644 --- a/fi4/R3BFi4Cal2Hit.cxx +++ b/fi4/R3BFi4Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi4Cal2Hit.h" R3BFi4Cal2Hit::R3BFi4Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi4", a_verbose, VERTICAL, 2, 256, 4, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi4", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 2, 256, 4, a_is_calibrator) { } diff --git a/fi4/R3BFi4Mapped2Cal.cxx b/fi4/R3BFi4Mapped2Cal.cxx index a56728a25..e116bcfe9 100644 --- a/fi4/R3BFi4Mapped2Cal.cxx +++ b/fi4/R3BFi4Mapped2Cal.cxx @@ -18,8 +18,8 @@ #include "R3BFi4Mapped2Cal.h" -R3BFi4Mapped2Cal::R3BFi4Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi4", a_verbose) +R3BFi4Mapped2Cal::R3BFi4Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi4", a_verbose, a_variant) { } diff --git a/fi4/R3BFi4Mapped2Cal.h b/fi4/R3BFi4Mapped2Cal.h index 602a3b798..96c6ff66b 100644 --- a/fi4/R3BFi4Mapped2Cal.h +++ b/fi4/R3BFi4Mapped2Cal.h @@ -25,7 +25,7 @@ class R3BFi4Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi4Mapped2Cal(Int_t = 1); + R3BFi4Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi4Mapped2Cal(); ClassDef(R3BFi4Mapped2Cal, 1) diff --git a/fi5/R3BFi5Cal2Hit.cxx b/fi5/R3BFi5Cal2Hit.cxx index 55531e649..a5752aba6 100644 --- a/fi5/R3BFi5Cal2Hit.cxx +++ b/fi5/R3BFi5Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi5Cal2Hit.h" R3BFi5Cal2Hit::R3BFi5Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi5", a_verbose, VERTICAL, 2, 256, 4, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi5", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 2, 256, 4, a_is_calibrator) { } diff --git a/fi5/R3BFi5Mapped2Cal.cxx b/fi5/R3BFi5Mapped2Cal.cxx index 60c70df9b..52d99b232 100644 --- a/fi5/R3BFi5Mapped2Cal.cxx +++ b/fi5/R3BFi5Mapped2Cal.cxx @@ -18,8 +18,8 @@ #include "R3BFi5Mapped2Cal.h" -R3BFi5Mapped2Cal::R3BFi5Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi5", a_verbose) +R3BFi5Mapped2Cal::R3BFi5Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi5", a_verbose, a_variant) { } diff --git a/fi5/R3BFi5Mapped2Cal.h b/fi5/R3BFi5Mapped2Cal.h index 18f3d099d..2592b67d6 100644 --- a/fi5/R3BFi5Mapped2Cal.h +++ b/fi5/R3BFi5Mapped2Cal.h @@ -25,7 +25,7 @@ class R3BFi5Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi5Mapped2Cal(Int_t = 1); + R3BFi5Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi5Mapped2Cal(); ClassDef(R3BFi5Mapped2Cal, 1) diff --git a/fi6/R3BFi6Cal2Hit.cxx b/fi6/R3BFi6Cal2Hit.cxx index 4de7070cd..c45671dac 100644 --- a/fi6/R3BFi6Cal2Hit.cxx +++ b/fi6/R3BFi6Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi6Cal2Hit.h" R3BFi6Cal2Hit::R3BFi6Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi6", a_verbose, VERTICAL, 2, 256, 2, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi6", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 2, 256, 2, a_is_calibrator) { } diff --git a/fi6/R3BFi6Mapped2Cal.cxx b/fi6/R3BFi6Mapped2Cal.cxx index 5003a4da0..e4fcbeaae 100644 --- a/fi6/R3BFi6Mapped2Cal.cxx +++ b/fi6/R3BFi6Mapped2Cal.cxx @@ -18,8 +18,8 @@ #include "R3BFi6Mapped2Cal.h" -R3BFi6Mapped2Cal::R3BFi6Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi6", a_verbose) +R3BFi6Mapped2Cal::R3BFi6Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi6", a_verbose, a_variant) { } diff --git a/fi6/R3BFi6Mapped2Cal.h b/fi6/R3BFi6Mapped2Cal.h index 70f5a913f..969be78d6 100644 --- a/fi6/R3BFi6Mapped2Cal.h +++ b/fi6/R3BFi6Mapped2Cal.h @@ -25,7 +25,7 @@ class R3BFi6Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi6Mapped2Cal(Int_t = 1); + R3BFi6Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi6Mapped2Cal(); ClassDef(R3BFi6Mapped2Cal, 1) diff --git a/fi7/R3BFi7Cal2Hit.cxx b/fi7/R3BFi7Cal2Hit.cxx index d82aba6e7..496deaf0f 100644 --- a/fi7/R3BFi7Cal2Hit.cxx +++ b/fi7/R3BFi7Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi7Cal2Hit.h" R3BFi7Cal2Hit::R3BFi7Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi7", a_verbose, VERTICAL, 2, 256, 1, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi7", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 2, 256, 1, a_is_calibrator) { } diff --git a/fi7/R3BFi7Mapped2Cal.cxx b/fi7/R3BFi7Mapped2Cal.cxx index db22b7040..3365f215e 100644 --- a/fi7/R3BFi7Mapped2Cal.cxx +++ b/fi7/R3BFi7Mapped2Cal.cxx @@ -14,7 +14,7 @@ #include "R3BFi7Mapped2Cal.h" R3BFi7Mapped2Cal::R3BFi7Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi7", a_verbose, false) + : R3BBunchedFiberMapped2Cal("Fi7", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, false) { } diff --git a/fi7/R3BFi7Mapped2Cal.h b/fi7/R3BFi7Mapped2Cal.h index 69ddbe02e..8eab8c058 100644 --- a/fi7/R3BFi7Mapped2Cal.h +++ b/fi7/R3BFi7Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi7Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi7Mapped2Cal(Int_t = 1); + R3BFi7Mapped2Cal(Int_t); virtual ~R3BFi7Mapped2Cal(); ClassDef(R3BFi7Mapped2Cal, 1) diff --git a/fi8/R3BFi8Cal2Hit.cxx b/fi8/R3BFi8Cal2Hit.cxx index da85eb3d1..45317f2e9 100644 --- a/fi8/R3BFi8Cal2Hit.cxx +++ b/fi8/R3BFi8Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi8Cal2Hit.h" R3BFi8Cal2Hit::R3BFi8Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi8", a_verbose, VERTICAL, 2, 256, 1, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi8", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 2, 256, 1, a_is_calibrator) { } diff --git a/fi8/R3BFi8Mapped2Cal.cxx b/fi8/R3BFi8Mapped2Cal.cxx index 939731db4..536a8d158 100644 --- a/fi8/R3BFi8Mapped2Cal.cxx +++ b/fi8/R3BFi8Mapped2Cal.cxx @@ -14,7 +14,7 @@ #include "R3BFi8Mapped2Cal.h" R3BFi8Mapped2Cal::R3BFi8Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi8", a_verbose, false) + : R3BBunchedFiberMapped2Cal("Fi8", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, false) { } diff --git a/fi8/R3BFi8Mapped2Cal.h b/fi8/R3BFi8Mapped2Cal.h index 6e5b3a3ad..d0d2d3767 100644 --- a/fi8/R3BFi8Mapped2Cal.h +++ b/fi8/R3BFi8Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi8Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi8Mapped2Cal(Int_t = 1); + R3BFi8Mapped2Cal(Int_t); virtual ~R3BFi8Mapped2Cal(); ClassDef(R3BFi8Mapped2Cal, 1) diff --git a/fi9/R3BFi9Cal2Hit.cxx b/fi9/R3BFi9Cal2Hit.cxx index bebf43987..9a2135c04 100644 --- a/fi9/R3BFi9Cal2Hit.cxx +++ b/fi9/R3BFi9Cal2Hit.cxx @@ -14,7 +14,7 @@ #include "R3BFi9Cal2Hit.h" R3BFi9Cal2Hit::R3BFi9Cal2Hit(Bool_t a_is_calibrator, Int_t a_verbose) - : R3BBunchedFiberCal2Hit("Fi9", a_verbose, VERTICAL, 2, 256, 1, a_is_calibrator) + : R3BBunchedFiberCal2Hit("Fi9", a_verbose, R3BTCalEngine::CTDC_8_12_FWD_250, VERTICAL, 2, 256, 1, a_is_calibrator) { } diff --git a/fi9/R3BFi9Mapped2Cal.cxx b/fi9/R3BFi9Mapped2Cal.cxx index b3b869473..3afb31ad4 100644 --- a/fi9/R3BFi9Mapped2Cal.cxx +++ b/fi9/R3BFi9Mapped2Cal.cxx @@ -13,8 +13,8 @@ #include "R3BFi9Mapped2Cal.h" -R3BFi9Mapped2Cal::R3BFi9Mapped2Cal(Int_t a_verbose) - : R3BBunchedFiberMapped2Cal("Fi9", a_verbose, false) +R3BFi9Mapped2Cal::R3BFi9Mapped2Cal(Int_t a_verbose, enum R3BTCalEngine::CTDCVariant a_variant) + : R3BBunchedFiberMapped2Cal("Fi9", a_verbose, a_variant, false) { } diff --git a/fi9/R3BFi9Mapped2Cal.h b/fi9/R3BFi9Mapped2Cal.h index fc5b9ceab..a5b895bbd 100644 --- a/fi9/R3BFi9Mapped2Cal.h +++ b/fi9/R3BFi9Mapped2Cal.h @@ -19,7 +19,7 @@ class R3BFi9Mapped2Cal : public R3BBunchedFiberMapped2Cal { public: - R3BFi9Mapped2Cal(Int_t = 1); + R3BFi9Mapped2Cal(Int_t, enum R3BTCalEngine::CTDCVariant); virtual ~R3BFi9Mapped2Cal(); ClassDef(R3BFi9Mapped2Cal, 1) diff --git a/fiber/CMakeLists.txt b/fiber/CMakeLists.txt index cbdf549bc..4ddb29301 100644 --- a/fiber/CMakeLists.txt +++ b/fiber/CMakeLists.txt @@ -24,6 +24,7 @@ set(INCLUDE_DIRECTORIES ${R3BROOT_SOURCE_DIR}/r3bdata/fibData ${R3BROOT_SOURCE_DIR}/fiber ${R3BROOT_SOURCE_DIR}/tcal +${R3BROOT_SOURCE_DIR}/r3bdata ) include_directories(${INCLUDE_DIRECTORIES}) diff --git a/fiber/R3BBunchedFiberCal2Hit.cxx b/fiber/R3BBunchedFiberCal2Hit.cxx index 0df3439b9..82202b03b 100644 --- a/fiber/R3BBunchedFiberCal2Hit.cxx +++ b/fiber/R3BBunchedFiberCal2Hit.cxx @@ -38,6 +38,7 @@ R3BBunchedFiberCal2Hit::ToT::ToT(R3BBunchedFiberCalData const* a_lead, R3BBunchedFiberCal2Hit::R3BBunchedFiberCal2Hit(const char* a_name, Int_t a_verbose, + enum R3BTCalEngine::CTDCVariant a_ctdc_variant, Direction a_direction, UInt_t a_sub_num, UInt_t a_mapmt_per_sub, @@ -45,6 +46,7 @@ R3BBunchedFiberCal2Hit::R3BBunchedFiberCal2Hit(const char* a_name, Bool_t a_is_calibrator) : FairTask(TString("R3B") + a_name + "Cal2Hit", a_verbose) , fName(a_name) + , fClockFreq(R3BTCalEngine::CTDC_16_BWD_150 == a_ctdc_variant ? 150 : 250) , fDirection(a_direction) , fSubNum(a_sub_num) , fIsCalibrator(a_is_calibrator) @@ -59,6 +61,9 @@ R3BBunchedFiberCal2Hit::R3BBunchedFiberCal2Hit(const char* a_name, , fh_ToT_Single_Fib() , fh_ToT_s_Fib() , fh_ToT_ToT() + , fh_dt_Fib() + , fnEvents(0) + { fChPerSub[0] = a_mapmt_per_sub; fChPerSub[1] = a_spmt_per_sub; @@ -85,6 +90,8 @@ InitStatus R3BBunchedFiberCal2Hit::Init() LOG(ERROR) << "Branch " << name << " not found."; return kERROR; } + maxevent = mgr->CheckMaxEventNo(); + mgr->Register(fName + "Hit", "Land", fHitItems, kTRUE); // Resize per-channel info arrays. for (auto side_i = 0; side_i < 2; ++side_i) @@ -119,14 +126,14 @@ InitStatus R3BBunchedFiberCal2Hit::Init() // ToT MAPMT: chistName = fName + "_ToT_MAPMT"; chistTitle = fName + " ToT of fibers"; - fh_ToT_MA_Fib = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 200, 0., 200.); + fh_ToT_MA_Fib = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 100, 0., 41.666667); fh_ToT_MA_Fib->GetXaxis()->SetTitle("Fiber number"); fh_ToT_MA_Fib->GetYaxis()->SetTitle("ToT / ns"); // ToT single PMT: chistName = fName + "_ToT_SAPMT"; chistTitle = fName + " ToT of fibers"; - fh_ToT_Single_Fib = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 200, 0., 200.); + fh_ToT_Single_Fib = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 100, 0., 100.); fh_ToT_Single_Fib->GetXaxis()->SetTitle("Fiber number"); fh_ToT_Single_Fib->GetYaxis()->SetTitle("ToT / ns"); @@ -137,7 +144,7 @@ InitStatus R3BBunchedFiberCal2Hit::Init() snprintf(number, sizeof(number), "%d", i); chistName = fName + "_ToT_SAPMT" + number; chistTitle = fName + " ToT of single PMTs " + number; - fh_ToT_s_Fib[i] = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 200, 0., 200.); + fh_ToT_s_Fib[i] = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 100, 0., 100.); fh_ToT_s_Fib[i]->GetXaxis()->SetTitle("Fiber number"); fh_ToT_s_Fib[i]->GetYaxis()->SetTitle("ToT / ns"); } @@ -148,6 +155,14 @@ InitStatus R3BBunchedFiberCal2Hit::Init() fh_ToT_ToT = new TH2F(chistName.Data(), chistTitle.Data(), 1000, 0., 100., 1000, 0., 100.); fh_ToT_ToT->GetXaxis()->SetTitle("SPMT 1"); fh_ToT_ToT->GetYaxis()->SetTitle("SPMT 2"); + + // time difference SPMT - MAPMT: + chistName = fName + "_dt"; + chistTitle = fName + " dt of fibers"; + fh_dt_Fib = new TH2F(chistName.Data(), chistTitle.Data(), 2100, 0., 2100., 1200, -600., 600.); + fh_dt_Fib->GetXaxis()->SetTitle("Fiber number"); + fh_dt_Fib->GetYaxis()->SetTitle("dt / ns"); + return kSUCCESS; } @@ -166,6 +181,11 @@ void R3BBunchedFiberCal2Hit::SetParContainers() void R3BBunchedFiberCal2Hit::Exec(Option_t* option) { + // cout<<"in exec"<GetEntriesFast(); // Find multi-hit ToT for every channel. @@ -227,18 +249,20 @@ void R3BBunchedFiberCal2Hit::Exec(Option_t* option) auto tot = fmod(cur_cal->GetTime_ns() - lead->GetTime_ns() + c_period, c_period); if (tot < 1000) { - if (side_i == 0) - tot -= 9.; + // if (side_i==0) tot -= 9.;//taken out for the moment MH + channel.tot_list.push_back(ToT(lead, cur_cal, tot)); channel.lead_list.pop_front(); } } } - double s1 = 99; - double s2 = 99; - double s3 = 99; - double s4 = 99; + // cout<<"finished list"<GetChannel(); /* - cout<<"MA Fiber ch: "<GetChannel()<<" Fiber: "<< fiber_id<<" ToT: "<< - mapmt_tot.tot<GetChannel()<<" ToT: "<GetChannel()<<" Fiber: "<< fiber_id<<" ToT: "<< + mapmt_tot.tot<GetChannel()<<" ToT: "<direction to find real life coordinates. @@ -302,10 +328,36 @@ void R3BBunchedFiberCal2Hit::Exec(Option_t* option) // Calibrate hit fiber. auto tot_mapmt = mapmt_tot.tot; auto tot_spmt = spmt_tot.tot; + Double_t t_mapmt = mapmt_tot.lead->GetTime_ns(); + Double_t t_spmt = spmt_tot.lead->GetTime_ns(); + + // "Push" two times in the same clock cycle: + // MAPMT coarse counter has 4096 channels with 1000/150=6.67 ns or 4 ns each + // SPMT coarse counter has 2048 channels with 5 ns each + Double_t dtime = t_spmt - t_mapmt; + while (dtime > 256. / 2. * 1000. / fClockFreq) + { + t_mapmt += 256. * 1000. / fClockFreq; + dtime = t_spmt - t_mapmt; + // cout<<"dtime1 "<Fill(fiber_id, t_spmt - t_mapmt); // Apply calibration. - Double_t gainMA = 100; - Double_t gainS = 100; + Double_t gainMA = 10.; + Double_t gainS = 10.; + Double_t offset1 = 0.; + Double_t offset2 = 0.; + if (!fIsCalibrator && fHitPar) { R3BBunchedFiberHitModulePar* par = fHitPar->GetModuleParAt(fiber_id); @@ -313,10 +365,22 @@ void R3BBunchedFiberCal2Hit::Exec(Option_t* option) { gainMA = par->GetGainMA(); gainS = par->GetGainS(); + offset1 = par->GetOffset1(); + offset2 = par->GetOffset2(); } } - tot_mapmt *= 100 / gainMA; - tot_spmt *= 100 / gainS; + // cout<<"offset "<Fill(fiber_id, t_spmt - t_mapmt); /* if (tot_mapmt > tot_mapmt_max) { @@ -342,40 +406,68 @@ void R3BBunchedFiberCal2Hit::Exec(Option_t* option) fh_ToT_Single_Fib->Fill(fiber_id, tot_spmt); fh_ToT_s_Fib[single - 1]->Fill(fiber_id, tot_spmt); } - /* - if(fiber_id==300){ - if (spmt_tot.lead->GetChannel() == 1 && s1 == 99) s1 = tot_spmt; - if (spmt_tot.lead->GetChannel() == 2 && s2 == 99) s2 = tot_spmt; - if (spmt_tot.lead->GetChannel() == 3 && s3 == 99) s3 = tot_spmt; - if (spmt_tot.lead->GetChannel() == 4 && s4 == 99) s4 = tot_spmt; - cout<<"s1234: "<GetTime_ns(), spmt_tot.lead->GetTime_ns(), tot_mapmt, tot_spmt); + if (fName == "Fi1a" || fName == "Fi1b" || fName == "Fi2a" || fName == "Fi2b" || fName == "Fi3a" || + fName == "Fi3b") + { + if (fDirection == VERTICAL) + { + x = ((double)fiber_id - (double)numFibs / 2) * 0.021; // in cm + y = (t_spmt - t_mapmt) * 3.; + } + else + { + x = (t_spmt - t_mapmt) * 3.; + y = ((double)fiber_id - (double)numFibs / 2) * 0.021; // in cm + } + } + Double_t eloss = sqrt(tot_mapmt * tot_spmt); + Double_t t = (t_mapmt + t_spmt) / 2.; + + // cout<<"FiberID: "<Fill(s1, s2); + fnEvents++; - // Fill histograms for gain match, and for debugging. - // if (-1 != tot_mapmt_max) fh_ToT_m_Fib->Fill(tot_mapmt_max_fiber_id, tot_mapmt_max); - // if (-1 != tot_spmt_max) fh_ToT_s_Fib->Fill(tot_spmt_max_fiber_id, tot_spmt_max); + // cout<<"end exec"<Clear(); fNofHitItems = 0; - // cout<<"next event"<Write(); fh_ToT_Single_Fib->Write(); + fh_dt_Fib->Write(); for (Int_t i = 0; i < 4; i++) { @@ -398,6 +490,17 @@ void R3BBunchedFiberCal2Hit::FinishTask() fCalPar->AddModulePar(mpar); } + // time offset + for (UInt_t i = 1; i <= max; i++) + { + TH1D* proj = fh_dt_Fib->ProjectionY("", i + 1, i + 1, 0); + R3BBunchedFiberHitModulePar* par = fCalPar->GetModuleParAt(i); + par->SetOffset1(0.5 * proj->GetBinCenter(proj->GetMaximumBin())); + par->SetOffset2(-0.5 * proj->GetBinCenter(proj->GetMaximumBin())); + + cout << "MA fiber: " << i << " offset: " << 0.5 * proj->GetBinCenter(proj->GetMaximumBin()) << endl; + } + for (UInt_t i = 1; i <= max; i++) { TH1D* proj = fh_ToT_MA_Fib->ProjectionY("", i + 1, i + 1, 0); @@ -407,11 +510,11 @@ void R3BBunchedFiberCal2Hit::FinishTask() { // could not find maximum } - if (proj->GetBinContent(j) > proj->GetMaximum() / 10.) + if (proj->GetBinContent(j) > proj->GetMaximum() / 100.) { R3BBunchedFiberHitModulePar* par = fCalPar->GetModuleParAt(i); par->SetGainMA(proj->GetBinCenter(j)); - // cout<<"MA fiber: "<< i<<" par: "<GetBinCenter(j)<GetBinCenter(j)<SetGainMA(j - 1); cout << "MA fiber: " << i << " par: " << proj->GetBinCenter(j) << endl; break; @@ -433,7 +536,7 @@ void R3BBunchedFiberCal2Hit::FinishTask() { R3BBunchedFiberHitModulePar* par = fCalPar->GetModuleParAt(i); par->SetGainS(proj->GetBinCenter(j)); - // cout<<"S fiber: "<< i<<" par: "<GetBinCenter(j)<GetBinCenter(j)<SetGainS(j - 1); cout << "S fiber: " << i << " par: " << proj->GetBinCenter(j) << endl; break; diff --git a/fiber/R3BBunchedFiberCal2Hit.h b/fiber/R3BBunchedFiberCal2Hit.h index e9b40e539..eea9e2704 100644 --- a/fiber/R3BBunchedFiberCal2Hit.h +++ b/fiber/R3BBunchedFiberCal2Hit.h @@ -15,6 +15,8 @@ #define R3BBUNCHEDFIBERCAL2HIT #include "FairTask.h" +#include + class TH1F; class TH2F; @@ -62,7 +64,14 @@ class R3BBunchedFiberCal2Hit : public FairTask * @param name a name of the task. * @param iVerbose a verbosity level. */ - R3BBunchedFiberCal2Hit(const char*, Int_t, Direction, UInt_t, UInt_t, UInt_t, Bool_t); + R3BBunchedFiberCal2Hit(const char*, + Int_t, + enum R3BTCalEngine::CTDCVariant, + Direction, + UInt_t, + UInt_t, + UInt_t, + Bool_t); /** * Destructor. @@ -116,6 +125,10 @@ class R3BBunchedFiberCal2Hit : public FairTask private: TString fName; + Int_t fnEvents; + Int_t maxevent; + + double fClockFreq; Direction fDirection; UInt_t fSubNum; UInt_t fChPerSub[2]; @@ -133,8 +146,8 @@ class R3BBunchedFiberCal2Hit : public FairTask TH2F* fh_ToT_MA_Fib; TH2F* fh_ToT_Single_Fib; TH2F* fh_ToT_s_Fib[4]; - TH2F* fh_ToT_ToT; + TH2F* fh_dt_Fib; public: ClassDef(R3BBunchedFiberCal2Hit, 3) diff --git a/fiber/R3BBunchedFiberMapped2Cal.cxx b/fiber/R3BBunchedFiberMapped2Cal.cxx index 2c68985e2..c33bf6cd4 100644 --- a/fiber/R3BBunchedFiberMapped2Cal.cxx +++ b/fiber/R3BBunchedFiberMapped2Cal.cxx @@ -25,7 +25,10 @@ #include "TClonesArray.h" #include -R3BBunchedFiberMapped2Cal::R3BBunchedFiberMapped2Cal(const char* a_name, Int_t a_verbose, Bool_t a_skip_spmt) +R3BBunchedFiberMapped2Cal::R3BBunchedFiberMapped2Cal(const char* a_name, + Int_t a_verbose, + enum R3BTCalEngine::CTDCVariant a_variant, + Bool_t a_skip_spmt) : FairTask(TString("R3B") + a_name + "Mapped2Cal", a_verbose) , fName(a_name) , fSkipSPMT(a_skip_spmt) @@ -34,7 +37,7 @@ R3BBunchedFiberMapped2Cal::R3BBunchedFiberMapped2Cal(const char* a_name, Int_t a , fMappedItems(nullptr) , fCalItems(new TClonesArray("R3BBunchedFiberCalData")) , fNofCalItems(0) - , fClockFreq(1000. / CLOCK_TDC_MHZ) + , fClockFreq(1000. / (R3BTCalEngine::CTDC_16_BWD_150 == a_variant ? 150 : 250)) , fTamexFreq(1000. / VFTX_CLOCK_MHZ) { } @@ -140,7 +143,11 @@ void R3BBunchedFiberMapped2Cal::Exec(Option_t* option) } // Calculate final time with clock cycles. - time_ns = mapped->GetCoarse() * fClockFreq + (mapped->IsLeading() ? -fine_ns : fine_ns); + // time_ns = mapped->GetCoarse() * fClockFreq + + // (mapped->IsLeading() ? -fine_ns : fine_ns); + // new clock TDC firmware need here a minus + time_ns = mapped->GetCoarse() * fClockFreq - fine_ns; + LOG(DEBUG) << " R3BBunchedFiberMapped2Cal::Exec (" << fName << "): Channel=" << channel << ": Time=" << time_ns << "ns."; } @@ -154,7 +161,11 @@ void R3BBunchedFiberMapped2Cal::Exec(Option_t* option) } // Calculate final time with clock cycles. - time_ns = mapped->GetCoarse() * fTamexFreq + (mapped->IsLeading() ? -fine_ns : fine_ns); + // time_ns = mapped->GetCoarse() * fTamexFreq + + // (mapped->IsLeading() ? -fine_ns : fine_ns); + // new clock TDC firmware need here a minus + time_ns = mapped->GetCoarse() * fTamexFreq - fine_ns; + LOG(DEBUG) << " R3BBunchedFiberMapped2Cal::Exec:Channel=" << channel << ": Time=" << time_ns << "ns."; } new ((*fCalItems)[fNofCalItems++]) diff --git a/fiber/R3BBunchedFiberMapped2Cal.h b/fiber/R3BBunchedFiberMapped2Cal.h index 26ba3663c..131c13cb6 100644 --- a/fiber/R3BBunchedFiberMapped2Cal.h +++ b/fiber/R3BBunchedFiberMapped2Cal.h @@ -21,6 +21,7 @@ #define R3BBUNCHEDFIBERMAPPED2CAL #include "FairTask.h" +#include class R3BTCalPar; @@ -39,8 +40,10 @@ class R3BBunchedFiberMapped2Cal : public FairTask * Creates an instance of the task. * @param name a name of the task. * @param iVerbose a verbosity level. + * @param a_variant CTDC firmware variant, see R3BTCalEngine. + * @param a_skip_spmt Don't process SPMT side for pure MAPMT tests. */ - R3BBunchedFiberMapped2Cal(const char*, Int_t, Bool_t = false); + R3BBunchedFiberMapped2Cal(const char*, Int_t, enum R3BTCalEngine::CTDCVariant, Bool_t = false); /** * Destructor. @@ -101,7 +104,7 @@ class R3BBunchedFiberMapped2Cal : public FairTask Double_t fTamexFreq; public: - ClassDef(R3BBunchedFiberMapped2Cal, 1) + ClassDef(R3BBunchedFiberMapped2Cal, 2) }; #endif diff --git a/fiber/R3BBunchedFiberMapped2CalPar.cxx b/fiber/R3BBunchedFiberMapped2CalPar.cxx index 4dfdfff9b..3a8a5a04e 100644 --- a/fiber/R3BBunchedFiberMapped2CalPar.cxx +++ b/fiber/R3BBunchedFiberMapped2CalPar.cxx @@ -23,11 +23,13 @@ R3BBunchedFiberMapped2CalPar::R3BBunchedFiberMapped2CalPar(const char* a_name, Int_t a_verbose, enum Electronics a_spmt_electronics, + enum R3BTCalEngine::CTDCVariant a_ctdc_variant, Int_t a_update_rate, Int_t a_min_stats) : FairTask(TString("R3B") + a_name + "Mapped2CalPar", a_verbose) , fName(a_name) , fSPMTElectronics(a_spmt_electronics) + , fCTDCVariant(a_ctdc_variant) , fUpdateRate(a_update_rate) , fMinStats(a_min_stats) { @@ -99,11 +101,11 @@ void R3BBunchedFiberMapped2CalPar::FinishEvent() {} void R3BBunchedFiberMapped2CalPar::FinishTask() { - fMAPMTEngine->CalculateParamClockTDC(); + fMAPMTEngine->CalculateParamClockTDC(fCTDCVariant); switch (fSPMTElectronics) { case CTDC: - fSPMTEngine->CalculateParamClockTDC(); + fSPMTEngine->CalculateParamClockTDC(fCTDCVariant); break; case TAMEX: fSPMTEngine->CalculateParamVFTX(); diff --git a/fiber/R3BBunchedFiberMapped2CalPar.h b/fiber/R3BBunchedFiberMapped2CalPar.h index 90f0230c8..f2d12ec4a 100644 --- a/fiber/R3BBunchedFiberMapped2CalPar.h +++ b/fiber/R3BBunchedFiberMapped2CalPar.h @@ -19,11 +19,11 @@ #define R3BBUNCHEDFIBERMAPPED2CALPAR_H #include "FairTask.h" +#include class TClonesArray; class R3BTCalPar; class R3BEventHeader; -class R3BTCalEngine; class R3BBunchedFiberMapped2CalPar : public FairTask { @@ -42,7 +42,12 @@ class R3BBunchedFiberMapped2CalPar : public FairTask * @param a_update_rate a update rate for online histograms. * @param a_min_stats a minimum statistics for calibration. */ - R3BBunchedFiberMapped2CalPar(const char*, Int_t, enum Electronics = TAMEX, Int_t = 1e6, Int_t = 1e5); + R3BBunchedFiberMapped2CalPar(const char*, + Int_t, + enum Electronics = TAMEX, + enum R3BTCalEngine::CTDCVariant = R3BTCalEngine::CTDC_16_BWD_150, + Int_t = 1e6, + Int_t = 1e5); /** * Destructor. @@ -96,6 +101,7 @@ class R3BBunchedFiberMapped2CalPar : public FairTask private: TString fName; enum Electronics fSPMTElectronics; + enum R3BTCalEngine::CTDCVariant fCTDCVariant; TClonesArray* fMapped; R3BTCalPar* fMAPMTTCalPar; R3BTCalEngine* fMAPMTEngine; @@ -105,7 +111,7 @@ class R3BBunchedFiberMapped2CalPar : public FairTask Int_t fMinStats; public: - ClassDef(R3BBunchedFiberMapped2CalPar, 1) + ClassDef(R3BBunchedFiberMapped2CalPar, 2) }; #endif diff --git a/fiber/R3BFiberContFact.cxx b/fiber/R3BFiberContFact.cxx index f2e4552fd..6166b4442 100644 --- a/fiber/R3BFiberContFact.cxx +++ b/fiber/R3BFiberContFact.cxx @@ -101,6 +101,14 @@ void R3BFiberContFact::setAllContainers() FairContainer* p8 = new FairContainer("Fi13HitPar", "Fi13 Hit Parameters", "TestDefaultContext"); p8->addContext("TestNonDefaultContext"); containers->Add(p8); + + FairContainer* p9 = new FairContainer("Fi1aHitPar", "Fi1a Hit Parameters", "TestDefaultContext"); + p9->addContext("TestNonDefaultContext"); + containers->Add(p9); + + FairContainer* p10 = new FairContainer("Fi1bHitPar", "Fi1b Hit Parameters", "TestDefaultContext"); + p10->addContext("TestNonDefaultContext"); + containers->Add(p10); } FairParSet* R3BFiberContFact::createContainer(FairContainer* c) diff --git a/los/R3BLosMapped2Cal.cxx b/los/R3BLosMapped2Cal.cxx index fff29f789..4071416fb 100644 --- a/los/R3BLosMapped2Cal.cxx +++ b/los/R3BLosMapped2Cal.cxx @@ -1,16 +1,3 @@ -/****************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2019 Members of R3B Collaboration * - * * - * This software is distributed under the terms of the * - * GNU General Public Licence (GPL) version 3, * - * copied verbatim in the file "LICENSE". * - * * - * In applying this license GSI does not waive the privileges and immunities * - * granted to it by virtue of its status as an Intergovernmental Organization * - * or submit itself to any jurisdiction. * - ******************************************************************************/ - // ------------------------------------------------------------ // ----- R3BLosMapped2Cal ----- // ----- Created Feb 4th 2016 by R.Plag ----- @@ -44,8 +31,10 @@ #include "TClonesArray.h" #include "TMath.h" -#define LOS_COINC_WINDOW_V_NS 200 -#define LOS_COINC_WINDOW_T_NS 190 // Same as VFTX, as leading and trailing times are separately treated +#define LOS_COINC_WINDOW_V_NS 200; +#define LOS_COINC_WINDOW_TL_NS 200; // leading +#define LOS_COINC_WINDOW_TT_NS 1000; // trailing, longer because of pileup +#define LOS_COINC_WINDOW_M_NS 400; // 200 // ??? #define IS_NAN(x) TMath::IsNaN(x) R3BLosMapped2Cal::R3BLosMapped2Cal() @@ -54,7 +43,6 @@ R3BLosMapped2Cal::R3BLosMapped2Cal() , fCalItems(new TClonesArray("R3BLosCalData")) , fNofCalItems(0) , fNofTcalPars(0) - , fNofModules(0) , fTcalPar(NULL) , fTrigger(-1) , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) @@ -68,7 +56,6 @@ R3BLosMapped2Cal::R3BLosMapped2Cal(const char* name, Int_t iVerbose) , fCalItems(new TClonesArray("R3BLosCalData")) , fNofCalItems(0) , fNofTcalPars(0) - , fNofModules(0) , fTcalPar(NULL) , fTrigger(1) // trigger 1 - onspill, 2 - offspill, -1 - all events , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) @@ -87,8 +74,6 @@ InitStatus R3BLosMapped2Cal::Init() return kFATAL; } - LOG(INFO) << "R3BLosMapped2Cal::Init : read " << fNofModules << " modules"; - // try to get a handle on the EventHeader. EventHeader may not be // present though and hence may be null. Take care when using. FairRootManager* mgr = FairRootManager::Instance(); @@ -146,6 +131,8 @@ void R3BLosMapped2Cal::Exec(Option_t* option) Int_t nHits = fMappedItems->GetEntriesFast(); + // if(nHits >0) cout<<"Mapped hits: "<GetDetector(); // 1.. UInt_t iCha = hit->GetChannel(); // 1.. - UInt_t iType = hit->GetType(); // 0,1,2 + UInt_t iType = hit->GetType(); // 0,1,2,3 + + // cout<<"Mapped info: "<GetTimeFine()< fNofDetectors)) { @@ -177,33 +166,41 @@ void R3BLosMapped2Cal::Exec(Option_t* option) // Fetch calib data for current channel // new: - R3BTCalModulePar* par = fTcalPar->GetModuleParAt(iDet, iCha, iType + 1); - - if (!par) + if (iType < 3) { - LOG(INFO) << "R3BLosMapped2Cal::Exec : Tcal par not found, Detector: " << iDet << ", Channel: " << iCha - << ", Type: " << iType; - continue; - } + R3BTCalModulePar* par = fTcalPar->GetModuleParAt(iDet, iCha, iType + 1); - // Convert TDC to [ns] ... + if (!par) + { + LOG(INFO) << "R3BLosMapped2Cal::Exec : Tcal par not found, Detector: " << iDet << ", Channel: " << iCha + << ", Type: " << iType; + continue; + } - times_raw_ns = par->GetTimeVFTX(hit->GetTimeFine()); + // Convert TDC to [ns] ... - if (times_raw_ns < 0. || times_raw_ns > fClockFreq || IS_NAN(times_raw_ns)) - { + times_raw_ns = par->GetTimeVFTX(hit->GetTimeFine()); - LOG(INFO) << "R3BLosMapped2Cal::Exec : Bad time in ns: det= " << iDet << ", ch= " << iCha - << ", type= " << iType << ", time in channels = " << hit->GetTimeFine() - << ", time in ns = " << times_raw_ns; - continue; - } + if (times_raw_ns < 0. || times_raw_ns > fClockFreq || IS_NAN(times_raw_ns)) + { - // ... and add clock time - times_ns = fClockFreq - times_raw_ns + hit->GetTimeCoarse() * fClockFreq; + LOG(INFO) << "R3BLosMapped2Cal::Exec : Bad time in ns: det= " << iDet << ", ch= " << iCha + << ", type= " << iType << ", time in channels = " << hit->GetTimeFine() + << ", time in ns = " << times_raw_ns; + continue; + } - // if(fNEvent == 2387) cout<<"Mapped2Cal bef "<GetTimeFine()<<", "<GetTimeCoarse()<GetTimeCoarse() * fClockFreq; + } + else + { + // MTDC32 time need only a factor + times_ns = hit->GetTimeFine() / 7.8 / 1000.; // range MTDC 3->7.8ps + } + + // cout<<"Mapped2Cal :"<GetTimeFine()<At(iCal); + // cout<<"aCalItem->GetDetector() "<GetDetector()<<"; "<GetDetector() != iDet) { // Do not consider an item for another detector. @@ -246,25 +245,35 @@ void R3BLosMapped2Cal::Exec(Option_t* option) Tdev = fabs(aCalItem->GetMeanTimeVFTX() - times_ns); if (Tdev < LOS_COINC_WINDOW_NS) LOS_COINC = true; + // if(nHits%48 != 0 ) cout<<"Tdev VFTX: "<GetMeanTimeVFTX()<GetMeanTimeTAMEXL() - times_ns); if (Tdev < LOS_COINC_WINDOW_NS && aCalItem->GetTAMEXLNcha() > 0) LOS_COINC = true; - if (IS_NAN(Tdev) && aCalItem->GetTAMEXLNcha() == 0) + if (IS_NAN(Tdev) && aCalItem->GetTAMEXLNcha() == 0 && aCalItem->GetVFTXNcha() == 8) LOS_COINC = true; // First Tamex leading time } if (iType == 2) { - LOS_COINC_WINDOW_NS = LOS_COINC_WINDOW_T_NS; + LOS_COINC_WINDOW_NS = LOS_COINC_WINDOW_TT_NS; Tdev = fabs(aCalItem->GetMeanTimeTAMEXT() - times_ns); if (Tdev < LOS_COINC_WINDOW_NS && aCalItem->GetTAMEXTNcha() > 0) LOS_COINC = true; - if (IS_NAN(Tdev) && aCalItem->GetTAMEXTNcha() == 0) + if (IS_NAN(Tdev) && aCalItem->GetTAMEXTNcha() == 0 && aCalItem->GetVFTXNcha() == 8) LOS_COINC = true; // First Tamex trailing time } + if (iType == 3) + { + LOS_COINC_WINDOW_NS = LOS_COINC_WINDOW_M_NS; + Tdev = fabs(aCalItem->GetMeanTimeMTDC32() - times_ns); + if (Tdev < LOS_COINC_WINDOW_NS && aCalItem->GetMTDC32Ncha() > 0) + LOS_COINC = true; + if (IS_NAN(Tdev) && aCalItem->GetMTDC32Ncha() == 0) + LOS_COINC = true; // First MTDC time + } if (LOS_COINC) { @@ -389,6 +398,14 @@ void R3BLosMapped2Cal::Exec(Option_t* option) << endl; } + if (iType == 3) + { + calItem->fTimeM_ns[iCha - 1] = times_ns; + if (calItem->fTimeM_ns[iCha - 1] < 0. || IS_NAN(calItem->fTimeM_ns[iCha - 1])) + LOG(INFO) << "Problem with fTimeM_ns: " << calItem->fTimeM_ns[iCha - 1] << " " << times_ns << " " + << endl; + } + // if(fNEvent == 25383 || fNEvent == 322367 || fNEvent == 399481) // if(fNEvent == 24733) cout<<"Mapped2Cal "<> fCalLookup; public: - ClassDef(R3BLosMapped2Cal, 1) + ClassDef(R3BLosMapped2Cal, 2) }; #endif diff --git a/r3bbase/CMakeLists.txt b/r3bbase/CMakeLists.txt index fd4fa16d0..65521c468 100644 --- a/r3bbase/CMakeLists.txt +++ b/r3bbase/CMakeLists.txt @@ -33,6 +33,8 @@ ${R3BROOT_SOURCE_DIR}/los ${R3BROOT_SOURCE_DIR}/r3bdata/losData ${R3BROOT_SOURCE_DIR}/rolu ${R3BROOT_SOURCE_DIR}/r3bdata/roluData +${R3BROOT_SOURCE_DIR}/sci2 +${R3BROOT_SOURCE_DIR}/r3bdata/sci2Data ${R3BROOT_SOURCE_DIR}/sci8 ${R3BROOT_SOURCE_DIR}/r3bdata/sci8Data ${R3BROOT_SOURCE_DIR}/r3bdata/tofData @@ -43,6 +45,8 @@ ${R3BROOT_SOURCE_DIR}/tcal ${R3BROOT_SOURCE_DIR}/r3bdata/ptofData ${R3BROOT_SOURCE_DIR}/fiber ${R3BROOT_SOURCE_DIR}/r3bdata +${R3BROOT_SOURCE_DIR}/r3bdata/sampData +${R3BROOT_SOURCE_DIR}/tracker_rene ) include_directories( ${INCLUDE_DIRECTORIES}) @@ -55,6 +59,7 @@ R3BModule.cxx R3BDetector.cxx R3BEventHeader.cxx R3BOnlineSpectra.cxx +R3BOnlineSpectraDec2019.cxx R3BGlobalAnalysis.cxx R3BGlobalAnalysisS454.cxx ) @@ -66,7 +71,7 @@ CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") Set(LINKDEF R3BLinkDef.h) Set(DEPENDENCIES - GeoBase ParBase MbsAPI Base FairTools R3BData Core Geom GenVector Physics Matrix MathCore) + GeoBase ParBase MbsAPI Base FairTools R3BData Core Geom GenVector Physics Matrix MathCore R3BTraRene) Set(LIBRARY_NAME R3Bbase) diff --git a/r3bbase/R3BGlobalAnalysisS454.cxx b/r3bbase/R3BGlobalAnalysisS454.cxx index 4464e237b..8b4c7012f 100644 --- a/r3bbase/R3BGlobalAnalysisS454.cxx +++ b/r3bbase/R3BGlobalAnalysisS454.cxx @@ -26,6 +26,8 @@ #include "R3BLosHitData.h" #include "R3BLosMappedData.h" +#include "R3BBeamMonitorMappedData.h" + #include "R3BGlobalAnalysisS454.h" #include "R3BSci8CalData.h" @@ -35,6 +37,9 @@ #include "R3BTofdHitData.h" #include "R3BTofdMappedData.h" +#include "R3BRoluCalData.h" +#include "R3BRoluMappedData.h" + #include "R3BPaddleCalData.h" #include "R3BPspxCalData.h" @@ -47,6 +52,8 @@ #include "R3BBunchedFiberHitData.h" #include "R3BBunchedFiberMappedData.h" +#include "R3BMCTrack.h" + #include "FairLogger.h" #include "FairRootManager.h" #include "FairRunAna.h" @@ -57,6 +64,8 @@ #include "TH1F.h" #include "TH2F.h" +#include "tracker_routines.h" + #include "TClonesArray.h" #include "TMath.h" #include @@ -79,11 +88,7 @@ R3BGlobalAnalysisS454::R3BGlobalAnalysisS454(const char* name, Int_t iVerbose) : FairTask(name, iVerbose) , fTrigger(-1) , fTpat(-1) - , fNofPlanes(N_PLANE_MAX_TOFD) - , fPaddlesPerPlane(N_PADDLE_MAX_TOFD) - , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) , fNEvents(0) - , fFibEvents(0) { } @@ -91,7 +96,7 @@ R3BGlobalAnalysisS454::~R3BGlobalAnalysisS454() { for (int i = 0; i < NOF_FIB_DET; i++) { - delete fh_channels_Fib[i]; + delete fh_xy_Fib[i]; delete fh_fibers_Fib[i]; delete fh_fiber_Fib[i]; delete fh_mult_Fib[i]; @@ -122,27 +127,35 @@ InitStatus R3BGlobalAnalysisS454::Init() header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); FairRunOnline* run = FairRunOnline::Instance(); - fhTpat = new TH1F("Tpat", "Tpat", 20, 0, 20); - fhTpat->GetXaxis()->SetTitle("Tpat value"); - // Get objects for detectors on all levels + fMCTrack = (TClonesArray*)mgr->GetObject("MCTrack"); + assert(DET_MAX + 1 == sizeof(fDetectorNames) / sizeof(fDetectorNames[0])); printf("Have %d fiber detectors.\n", NOF_FIB_DET); - for (int det = 0; det < DET_MAX; det++) + fMappedItems.push_back((TClonesArray*)mgr->GetObject(Form("%sMappedData", fDetectorNames[0]))); + if (NULL == fMappedItems.at(0)) + { + printf("Could not find mapped data for '%s'.\n", fDetectorNames[0]); + } + fCalItems.push_back((TClonesArray*)mgr->GetObject(Form("%sCrystalCalData", fDetectorNames[0]))); + if (NULL == fCalItems.at(0)) + { + printf("Could not find Cal data for '%s'.\n", fDetectorNames[0]); + } + fHitItems.push_back((TClonesArray*)mgr->GetObject(Form("%sHit", fDetectorNames[0]))); + if (NULL == fHitItems.at(0)) + { + printf("Could not find hit data for '%s'.\n", fDetectorNames[0]); + } + for (int det = 1; det < DET_MAX; det++) { - /* - fMappedItems.push_back((TClonesArray *)mgr->GetObject(Form("%sMapped", fDetectorNames[det]))); - if (NULL == fMappedItems.at(det)) { - printf("Could not find mapped data for '%s'.\n", fDetectorNames[det]); - } - fCalItems.push_back((TClonesArray *)mgr->GetObject(Form("%sCal", fDetectorNames[det]))); - fHitItems.push_back((TClonesArray *)mgr->GetObject(Form("%sHit", fDetectorNames[det]))); - */ fMappedItems.push_back((TClonesArray*)mgr->GetObject(Form("%sMapped", fDetectorNames[det]))); if (NULL == fMappedItems.at(det)) { printf("Could not find mapped data for '%s'.\n", fDetectorNames[det]); } + if (det == 9) + maxevent = mgr->CheckMaxEventNo(); fCalItems.push_back((TClonesArray*)mgr->GetObject(Form("%sCal", fDetectorNames[det]))); if (NULL == fCalItems.at(det)) { @@ -163,18 +176,103 @@ InitStatus R3BGlobalAnalysisS454::Init() sprintf(strNameC, "Cave_C_position"); fh_Cave_position = new TH2F(strNameC, "", 2100, -100., 2000., 1000, -500., 500.); - if (fHitItems.at(DET_LOS) || fCalItems.at(DET_LOS)) - { - char strName[255]; - sprintf(strName, "LOS_X_vs_Y_MCFD"); - // fh_los_pos = new TH2F(strName, "", 2000, -10., 10., 2000, -10., 10.); - fh_los_pos = new TH2F(strName, "", 2000, -10., 10., 2000, -10., 10.); - - sprintf(strName, "LosQ_vs_TofdQ"); - fhChargeLosTofD = new TH2F(strName, "", 1000, 0., 80., 1000, 0., 80.); - fhChargeLosTofD->GetYaxis()->SetTitle("Charge LOS"); - fhChargeLosTofD->GetXaxis()->SetTitle("Charge ToFD"); - } + //----------------------------------------------------------------------- + // BeamMonitor + + // get the theoretical calib factors for SEETRAM + Double_t fexp = float(fsens_SEE + 9); + Double_t fpow = float(pow(10., fexp)); + calib_SEE = 135641.7786 * fpow; + LOG(DEBUG) << fsens_SEE << ", " << fexp << ", " << fpow << ", " << calib_SEE << endl; + + fh_Tpat = new TH1F("Tpat", "Tpat", 20, 0, 20); + fh_Tpat->GetXaxis()->SetTitle("Tpat value"); + + fh_Trigger = new TH1F("Trigger", "Trigger all", 20, 0, 20); + fh_Trigger->GetXaxis()->SetTitle("Trigger value"); + + fh_IC = new TH1F("IC", "IC ", 1000, 0, 1000); + fh_IC->GetXaxis()->SetTitle("spill number"); + fh_IC->GetYaxis()->SetTitle("IC counts"); + + fh_SEE = new TH1F("SEETRAM", "SEETRAM ", 1000, 0, 1000); + fh_SEE->GetXaxis()->SetTitle("spill number"); + fh_SEE->GetYaxis()->SetTitle("SEETRAM counts"); + + fh_TOFDOR = new TH1F("TOFDOR", "TOFDOR ", 1000, 0, 1000); + fh_TOFDOR->GetXaxis()->SetTitle("spill number"); + fh_TOFDOR->GetYaxis()->SetTitle("TOFDOR counts"); + + //----------------------------------------------------------------------- + // compare against MC Simulations + + fh_target_px = new TH1F("target_px", "target px ", 2000, -500., 500); + fh_target_px->GetXaxis()->SetTitle("px / MeV/c"); + fh_target_px->GetYaxis()->SetTitle("counts"); + + fh_target_py = new TH1F("target_py", "target py ", 2000, -500., 500); + fh_target_py->GetXaxis()->SetTitle("py / MeV/c"); + fh_target_py->GetYaxis()->SetTitle("counts"); + + fh_target_pz = new TH1F("target_pz", "target pz ", 30000, 0., 30000.); + fh_target_pz->GetXaxis()->SetTitle("pz / MeV/c"); + fh_target_pz->GetYaxis()->SetTitle("counts"); + + fh_target_xy = new TH2F("target_xy", "target xy ", 1000, -5, 5, 1000, -5., 5.); + fh_target_xy->GetXaxis()->SetTitle("x / cm"); + fh_target_xy->GetYaxis()->SetTitle("y / cm"); + + fh_dx = new TH1F("tracker_dx", "tracker dx ", 2000, -5., 5); + fh_dx->GetXaxis()->SetTitle("dx / cm"); + fh_dx->GetYaxis()->SetTitle("counts"); + + fh_dy = new TH1F("tracker_dy", "tracker dy ", 2000, -5., 5.); + fh_dy->GetXaxis()->SetTitle("dy / cm"); + fh_dy->GetYaxis()->SetTitle("counts"); + + fh_dz = new TH1F("tracker_dz", "tracker dz ", 2000, -5., 5.); + fh_dz->GetXaxis()->SetTitle("dz / cm"); + fh_dz->GetYaxis()->SetTitle("counts"); + + fh_dpx = new TH1F("tracker_dpx", "tracker dpx ", 2000, -10, 10); + fh_dpx->GetXaxis()->SetTitle("dpx / percent"); + fh_dpx->GetYaxis()->SetTitle("counts"); + + fh_dpy = new TH1F("tracker_dpy", "tracker dpy ", 2000, -10, 10); + fh_dpy->GetXaxis()->SetTitle("dpy / percent"); + fh_dpy->GetYaxis()->SetTitle("counts"); + + fh_dpz = new TH1F("tracker_dpz", "tracker dpz ", 2000, -10, 10); + fh_dpz->GetXaxis()->SetTitle("dpz / percent"); + fh_dpz->GetYaxis()->SetTitle("counts"); + + fh_dp = new TH1F("tracker_dp", "tracker dp ", 2000, -10, 10); + fh_dp->GetXaxis()->SetTitle("dp / percent"); + fh_dp->GetYaxis()->SetTitle("counts"); + + fh_thetax_dpx = new TH2F("tracker_thethax_dpx", "tracker theta_x vs dpx ", 1000, -50, 50, 200, -100., 100.); + fh_thetax_dpx->GetXaxis()->SetTitle("dpx / percent"); + fh_thetax_dpx->GetYaxis()->SetTitle("theta_x / mrad"); + + fh_thetay_dpy = new TH2F("tracker_thethay_dpy", "tracker theta_y vs dpy ", 1000, -50, 50, 200, -100., 100.); + fh_thetay_dpy->GetXaxis()->SetTitle("dpy / percent"); + fh_thetay_dpy->GetYaxis()->SetTitle("theta_y / mrad"); + + fh_thetax_dpy = new TH2F("tracker_thethax_dpy", "tracker theta_x vs dpy ", 1000, -50, 50, 200, -100., 100.); + fh_thetax_dpy->GetXaxis()->SetTitle("dpy / percent"); + fh_thetax_dpy->GetYaxis()->SetTitle("theta_x / mrad"); + + fh_thetay_dpx = new TH2F("tracker_thethay_dpx", "tracker theta_y vs dpx ", 1000, -50, 50, 200, -100., 100.); + fh_thetay_dpx->GetXaxis()->SetTitle("dpx / percent"); + fh_thetay_dpx->GetYaxis()->SetTitle("theta_y / mrad"); + + fh_x_dpx = new TH2F("tracker_x_dpx", "tracker x vs dpx ", 1000, -50, 50, 200, -10., 10.); + fh_x_dpx->GetXaxis()->SetTitle("dpx / percent"); + fh_x_dpx->GetYaxis()->SetTitle("x / cm"); + + fh_y_dpy = new TH2F("tracker_y_dpy", "tracker y vs dpy ", 1000, -50, 50, 200, -10., 10.); + fh_y_dpy->GetXaxis()->SetTitle("dpy / percent"); + fh_y_dpy->GetYaxis()->SetTitle("y / cm"); //----------------------------------------------------------------------- // Fiber Detectors 1-NOF_FIB_DET @@ -184,40 +282,20 @@ InitStatus R3BGlobalAnalysisS454::Init() for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) { - std::stringstream fibhitobj; - std::stringstream fibmapobj; - std::string temp; - std::stringstream FileNameTemp; - - std::stringstream histName1, histName2, histName22, histName3, histName4, histName5, histName6, histName33, - histName7, histName8, histName9, histName10, histName11, histName12, histName13, histName14; - std::stringstream histTitle1, histTitle2, histTitle22, histTitle3, histTitle4, histTitle5, histTitle6, - histTitle33, histTitle7, histTitle8, histTitle9, histTitle10, histTitle11, histTitle12, histTitle13, - histTitle14; - if (fCalItems.at(DET_FI_FIRST + ifibcount) || fHitItems.at(DET_FI_FIRST + ifibcount)) { - const char* chistName; - const char* chistTitle; const char* detName; const char* detName2; - const char* FileName; - std::string tempTitle; - std::string tempName; - std::stringstream tempFibName; - std::string tempFibNames; - std::stringstream tempCanvName; - detName = fDetectorNames[DET_FI_FIRST + ifibcount]; - cout << "I am creating canvas " << detName << endl; + LOG(DEBUG) << "I am creating canvas " << detName << endl; - // Channels: - fh_channels_Fib[ifibcount] = - new TH1F(Form("%s_channels", detName), Form("%s channels", detName), 520, 0., 520.); - fh_channels_Fib[ifibcount]->GetXaxis()->SetTitle("Channel number"); - fh_channels_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + // xy: + fh_xy_Fib[ifibcount] = + new TH2F(Form("%s_xy", detName), Form("%s xy", detName), 1000, -50., 50., 1000, -50., 50.); + fh_xy_Fib[ifibcount]->GetXaxis()->SetTitle("x / cm "); + fh_xy_Fib[ifibcount]->GetYaxis()->SetTitle("y / cm"); // Fibers: fh_fibers_Fib[ifibcount] = @@ -232,7 +310,7 @@ InitStatus R3BGlobalAnalysisS454::Init() fh_fiber_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); // Multiplicity (number of hit fibers): - fh_mult_Fib[ifibcount] = new TH1F(Form("%s_mult", detName), Form("%s # of fibers", detName), 100, 0., 100.); + fh_mult_Fib[ifibcount] = new TH1F(Form("%s_mult", detName), Form("%s # of fibers", detName), 500, 0., 500.); fh_mult_Fib[ifibcount]->GetXaxis()->SetTitle("Multiplicity"); fh_mult_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); @@ -285,16 +363,10 @@ InitStatus R3BGlobalAnalysisS454::Init() fh_time_Fib[ifibcount]->GetYaxis()->SetTitle("tMAPMT-tSPMT"); // ToF Tofd -> Fiber: - fh_Fib_ToF[ifibcount] = new TH2F(Form("%s_tof", detName), - Form("%s ToF Tofd to Fiber", detName), - N_FIBER_PLOT, - 0., - N_FIBER_PLOT, - 10000, - -5000., - 5000.); + fh_Fib_ToF[ifibcount] = new TH2F( + Form("%s_tof", detName), Form("%s ToF Tofd to Fiber", detName), 600, -30., 30, 10000, -50000., 50000.); fh_Fib_ToF[ifibcount]->GetYaxis()->SetTitle("ToF / ns"); - fh_Fib_ToF[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_Fib_ToF[ifibcount]->GetXaxis()->SetTitle("x / cm"); // ToF Tofd -> Fiber vs. event number: fh_ToF_vs_events[ifibcount] = new TH2F(Form("%s_tof_vs_events", detName), @@ -308,10 +380,10 @@ InitStatus R3BGlobalAnalysisS454::Init() fh_ToF_vs_events[ifibcount]->GetYaxis()->SetTitle("ToF / ns"); fh_ToF_vs_events[ifibcount]->GetXaxis()->SetTitle("event number"); - // Not-calibrated position: + // x position: fh_xpos_Fib[ifibcount] = - new TH1F(Form("%s_pos", detName), Form("%s Not-calibrated position", detName), 6000, -1500., 1500.); - fh_xpos_Fib[ifibcount]->GetXaxis()->SetTitle("x-Position"); + new TH1F(Form("%s_xpos", detName), Form("%s x position", detName), 1000, -50., 50.); + fh_xpos_Fib[ifibcount]->GetXaxis()->SetTitle("x / cm"); fh_xpos_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); // hit fiber number vs. event number: @@ -384,18 +456,11 @@ InitStatus R3BGlobalAnalysisS454::Init() ; } - // Not-calibrated position: - histName14 << detName << "_ypos"; - tempName = histName14.str(); - chistName = tempName.c_str(); - histTitle14 << detName << " Not-calibrated y-position "; - tempTitle = histTitle14.str(); - chistTitle = tempTitle.c_str(); - fh_ypos_Fib[ifibcount] = new TH1F(chistName, chistTitle, 6000, -1500., 1500.); - fh_ypos_Fib[ifibcount]->GetXaxis()->SetTitle("y-Position"); + // y position: + fh_ypos_Fib[ifibcount] = + new TH1F(Form("%s_ypos", detName), Form("%s y position", detName), 1000, -50., 50.); + fh_ypos_Fib[ifibcount]->GetXaxis()->SetTitle("y / cm"); fh_ypos_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); - tempName.clear(); - tempTitle.clear(); } // end if(Mapped) @@ -407,15 +472,14 @@ InitStatus R3BGlobalAnalysisS454::Init() if (fHitItems.at(DET_TOFD) || fCalItems.at(DET_TOFD)) { - char strName1[255]; - char strName2[255]; - sprintf(strName1, "TofD_X_vs_Y"); - sprintf(strName2, "TofD X vs. Y"); - fh_tofd_pos = new TH2F(strName1, strName2, 20000, -100., 100., 20000, -100., 100.); + // xy: + fh_xy_tofd = new TH2F("tofd_xy", "tofd xy", 2000, -100., 100., 2000, -100., 100.); + fh_xy_tofd->GetXaxis()->SetTitle("x / cm "); + fh_xy_tofd->GetYaxis()->SetTitle("y / cm"); - sprintf(strName1, "TofD_Q"); - sprintf(strName2, "TofD Q"); - fh_tofd_charge = new TH1F(strName1, strName2, 200, 0., 20.); + fh_tofd_charge = new TH1F("tofd_Q", "Charge of Tofd", 200, 0., 20.); + fh_tofd_charge->GetXaxis()->SetTitle("x / cm "); + fh_tofd_charge->GetYaxis()->SetTitle("y / cm"); fh_TimePreviousEvent = new TH1F("TimePreviousEvent", "Time between 2 particles ", 300000, 0, 3000); fh_TimePreviousEvent->GetXaxis()->SetTitle("time / ns"); @@ -424,475 +488,626 @@ InitStatus R3BGlobalAnalysisS454::Init() fh_tofd_mult = new TH1F("tofd_mult", "ToFD multiplicits ", 100, 0, 100); fh_tofd_mult->GetXaxis()->SetTitle("multiplicity"); fh_tofd_mult->GetYaxis()->SetTitle("counts"); - - /* - for (Int_t j = 0; j < 4; j++) - { - char strName1[255]; - sprintf(strName1, "tofd_channels_plane_%d", j+1); - char strName2[255]; - sprintf(strName2, "Tofd channels plane %d", j+1); - fh_tofd_channels[j] = new TH1F(strName1, strName2, 90, -45., 45.); - fh_tofd_channels[j]->GetXaxis()->SetTitle("Channel"); - fh_tofd_channels[j]->GetYaxis()->SetTitle("Counts"); - - char strName3[255]; - sprintf(strName3, "tofd_ToT_plane_%d", j+1); - char strName4[255]; - sprintf(strName4, "Tofd ToT plane %d", j+1); - fh_tofd_TotPm[j] = new TH2F(strName3, strName4, 90,-45,45,3000,0.,300.); - fh_tofd_TotPm[j]->GetXaxis()->SetTitle("Bar number"); - fh_tofd_TotPm[j]->GetYaxis()->SetTitle("ToT / ns"); - - char strName7[255]; - sprintf(strName7, "tofd_ToF_plane_%d", j+1); - char strName8[255]; - sprintf(strName8, "TOFD-LOS ToF plane %d", j+1); - fh_tofd_ToF[j] = new TH2F(strName7, strName8, 45,0,45, 1e4, 0, 1e3); - fh_tofd_ToF[j]->GetXaxis()->SetTitle("Bar number"); - fh_tofd_ToF[j]->GetYaxis()->SetTitle("ToF / ns"); - - char strName9[255]; - sprintf(strName9, "tofd_multihit_plane_%d", j+1); - char strName10[255]; - sprintf(strName10, "Tofd multihit plane %d", j+1); - fh_tofd_multihit[j] = new TH2F(strName9, strName10, 45, 0., 45., 10, 0, 10); - fh_tofd_multihit[j]->GetXaxis()->SetTitle("Bar number"); - fh_tofd_multihit[j]->GetYaxis()->SetTitle("Multihit"); - - - - for(Int_t p = 0;pGetXaxis()->SetTitle("position"); - fh_tofd_TotvsPos[j][p]->GetYaxis()->SetTitle("ToT / ns"); - } - - - - if(j<3) - { - int jk = j + 1; - char strName5[255]; - sprintf(strName5, "tofd_ToF_plane_%d_%d", jk, jk+1); - char strName6[255]; - sprintf(strName6, "Tofd ToF plane %d and %d ", jk, jk+1); - fh_tofd_dt[j] = new TH2F(strName5, strName6, 50,0,50,8000, -40., 40); - fh_tofd_dt[j]->GetXaxis()->SetTitle("Bar number"); - fh_tofd_dt[j]->GetYaxis()->SetTitle("dt / ns"); - } - } - - - - char strName11[255]; - sprintf(strName11, "tofd_ToT_vs_pos_paddle_plane"); - char strName12[255]; - sprintf(strName12, "Tofd ToT vs. Pos bar plane"); - fh_tofd_TotvsPos = new TH2F(strName11, strName12, 1000, -50., 50., 3000, 0, 300); - fh_tofd_TotvsPos->GetXaxis()->SetTitle("position"); - fh_tofd_TotvsPos->GetYaxis()->SetTitle("ToT / ns"); - - */ } // ------------------------------------------------------------------------- + // Rene's tracker. + + init_from_cpp_(); return kSUCCESS; } void R3BGlobalAnalysisS454::Exec(Option_t* option) { - if (fNEvents / 1000000. == (int)fNEvents / 1000000) - cout << "Events: " << fNEvents << flush << '\r'; + if (fNEvents / 10000. == (int)fNEvents / 10000) + std::cout << "\rEvents: " << fNEvents << " / " << maxevent << " (" << (int)(fNEvents * 100. / maxevent) + << " %) " << std::flush; + + // cout << "New event" << endl; FairRootManager* mgr = FairRootManager::Instance(); if (NULL == mgr) LOG(fatal) << "FairRootManager not found"; - // check for requested trigger (Todo: should be done globablly / somewhere else) - if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) - return; - Int_t tpatbin; - for (int i = 0; i < 16; i++) + if (header) { - tpatbin = (header->GetTpat() & (1 << i)); - if (tpatbin != 0) - fhTpat->Fill(i + 1); - } + time = header->GetTimeStamp(); - // fTpat = 1-16; fTpat_bit = 0-15 - Int_t fTpat_bit = fTpat - 1; - Int_t itpat; - Int_t tpatvalue; - if (fTpat_bit >= 0) - { - itpat = header->GetTpat(); - tpatvalue = (itpat && (1 << fTpat_bit)) >> fTpat_bit; - if (tpatvalue == 0) + if (time_start == 0 && time > 0) + { + time_start = time; + fNEvents_start = fNEvents; + } + + if (header->GetTrigger() == 12) + { + // spill start in nsec + cout << "spill start" << endl; + num_spills++; + } + if (header->GetTrigger() == 13) + { + // spill end in nsec + cout << "spill stop" << endl; + } + + fh_Trigger->Fill(header->GetTrigger()); + // check for requested trigger (Todo: should be done globablly / somewhere else) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + + Int_t tpatbin; + for (int i = 0; i < 16; i++) + { + tpatbin = (header->GetTpat() & (1 << i)); + if (tpatbin != 0) + fh_Tpat->Fill(i + 1); + } + + // fTpat = 1-16; fTpat_bit = 0-15 + Int_t fTpat_bit = fTpat - 1; + Int_t itpat; + Int_t tpatvalue; + if (fTpat_bit >= 0) + { + itpat = header->GetTpat(); + tpatvalue = (itpat && (1 << fTpat_bit)) >> fTpat_bit; + if ((tpatvalue == 0)) + return; + } + + // check for requested trigger (Todo: should be done globablly / somewhere else) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) return; } - //---------------------------------------------------------------------- - // LOS detector - //---------------------------------------------------------------------- - Double_t timeLos[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. }; - Double_t LosQ = 0.; + // cout << "Spill: " << num_spills << endl; - if (fHitItems.at(DET_LOS)) + if (fMappedItems.at(DET_BMON)) { - auto det = fHitItems.at(DET_LOS); - Int_t nHits = det->GetEntriesFast(); + unsigned long IC; + unsigned long SEETRAM_raw; + Double_t SEETRAM; + unsigned long TOFDOR; + + auto detBmon = fMappedItems.at(DET_BMON); + Int_t nHitsbm = detBmon->GetEntriesFast(); + // cout<<"Bmon hits: "<At(ihit); - timeLos[ihit] = hitData->fTime_ns; + R3BBeamMonitorMappedData* hit = (R3BBeamMonitorMappedData*)detBmon->At(ihit); + if (!hit) + continue; + + IC = hit->GetIC(); // negative values if offset not high enough + counts_IC += (double)IC; + + SEETRAM_raw = hit->GetSEETRAM(); // raw counts + SEETRAM = (double)SEETRAM_raw * calib_SEE; // calibrated SEETRAM counts + counts_SEE += SEETRAM; + + TOFDOR = hit->GetTOFDOR(); // only positive values possible + counts_TofD += TOFDOR; + + if (fNEvents == fNEvents_start) + { + see_start = SEETRAM; + ic_start = IC; + tofdor_start = TOFDOR; + } + + /* + cout << "time " << time << endl; + cout << "IC " << IC << " " << counts_IC << " " << endl; + cout << "SEE " << SEETRAM_raw << " " << counts_SEE << " " << SEETRAM << endl; + cout << "TofD " << TOFDOR << " " << counts_TofD << " " << endl; + */ - fh_los_pos->Fill(hitData->fX_cm, hitData->fY_cm); + // IC: + Int_t yIC = IC - ic_start; + fh_IC->Fill(num_spills, yIC); - fh_Cave_position->Fill(0., hitData->fX_cm); + // SEETRAM: + Int_t ySEE = SEETRAM - see_start; + fh_SEE->Fill(num_spills, ySEE); + // Double_t ySEE_part = (SEETRAM-see_mem)*fNorm*1.e+3-see_offset*calib_SEE; - if (hitData->fZ > LosQ) - LosQ = hitData->fZ; + // TOFDOR: + Int_t yTOFDOR = TOFDOR - tofdor_start; + fh_TOFDOR->Fill(num_spills, yTOFDOR); } } - //---------------------------------------------------------------------- - // TOFD - //---------------------------------------------------------------------- - Double_t timeTofd[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. }; - Double_t xTofd[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. }; - Double_t yTofd[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. }; - Double_t qTofd[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. }; - Double_t TofdQ = 0.; - Double_t TofdX = 0.; - Double_t timeTofd0 = 0; + Bool_t RoluCut = false; + if (fMappedItems.at(DET_ROLU)) + { + // rolu + auto detRolu = fMappedItems.at(DET_ROLU); + Int_t nHitsRolu = detRolu->GetEntriesFast(); + // cout<<"ROLU hits: "<At(ihit); + if (!hitRolu) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iDet = hitRolu->GetDetector(); // 1.. + Int_t iCha = hitRolu->GetChannel(); // 1.. + RoluCut = true; + } + } + if (RoluCut) + { + cout << "ROLU cut applied !!!" << endl; + return; + } + + if (fMCTrack) { - auto det = fHitItems.at(DET_TOFD); - Int_t nHits = det->GetEntriesFast(); - // cout<<"ToFD hits: "<GetTimeStamp(); - double_t time1 = -1.; + // read in Monte Carlo Track parameter - if (nHits > 0) + Int_t nHitsMCTrack = fMCTrack->GetEntriesFast(); + cout << "MCTrack hits: " << nHitsMCTrack << endl; + + for (Int_t l = 0; l < nHitsMCTrack; l++) { - fh_tofd_mult->Fill(nHits); + R3BMCTrack* aTrack = (R3BMCTrack*)fMCTrack->At(l); + + Int_t PID = aTrack->GetPdgCode(); + Int_t mother = aTrack->GetMotherId(); + if (mother < 0) + { + Xf = aTrack->GetStartX(); + Yf = aTrack->GetStartY(); + Zf = aTrack->GetStartZ(); + Tf = aTrack->GetStartT(); + + Pxf = aTrack->GetPx() * 1000.; + Pyf = aTrack->GetPy() * 1000.; + Pzf = aTrack->GetPz() * 1000.; + Pf_tot = sqrt((Pxf * Pxf) + (Pyf * Pyf) + (Pzf * Pzf)); + + LOG(DEBUG) << "******************************************" << endl; + LOG(DEBUG) << "Track In " + << "x " << Xf << " y " << Yf << " z " << Zf << endl; + ; + LOG(DEBUG) << "Track In " + << "Pxf " << Pxf << " Pyf " << Pyf << " Pzf " << Pzf << " Pf_tot " << Pf_tot << endl; + ; + } + } + } - for (Int_t ihit = 0; ihit < nHits; ihit++) + Int_t n_det = 8; + Double_t x[n_det] = { 0. }; + Double_t y[n_det] = { 0. }; + Double_t z[n_det] = { 0. }; + Double_t q[n_det] = { 0. }; + Double_t t[n_det] = { 0. }; + Bool_t ptn[n_det] = { 0. }; + Int_t det; + + // is also number of ifibcount + Int_t fi3a = 0; + Int_t fi3b = 1; + Int_t fi10 = 2; + Int_t fi11 = 3; + Int_t fi12 = 4; + Int_t fi13 = 5; + Int_t tofdr = 6; + Int_t tofdl = 7; + + Double_t tof = 0.; + + auto detTofd = fHitItems.at(DET_TOFD); + Int_t nHits = detTofd->GetEntriesFast(); + LOG(DEBUG) << "ToFD hits: " << nHits << endl; + + if (nHits > 0) + fh_tofd_mult->Fill(nHits); + + // loop over ToFD + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BTofdHitData* hitTofd = (R3BTofdHitData*)detTofd->At(ihit); + if (!hitTofd) + continue; // should not happen + if (ihit > 15) + { + cout << "Error, more than 16 hits" << endl; + continue; + } + if (hitTofd->GetX() / 100. <= -0.007) + { + // tof rechts + det = tofdr; + ptn[tofdl] = false; + } + else + { + // tof links + det = tofdl; + ptn[tofdr] = false; + } + x[det] = hitTofd->GetX() / 100.; + y[det] = hitTofd->GetY() / 100.; + z[det] = 0.; + q[det] = hitTofd->GetEloss(); + t[det] = hitTofd->GetTime(); + + // Cuts on TofD + if (q[det] > 8.5) + continue; + if (q[det] < 7.5) + continue; + if (t[det] < 0. || t[det] > 8192. * 5.) + continue; + if (IS_NAN(t[det])) + continue; + + ptn[det] = true; + + LOG(DEBUG) << "ToFD: " << ihit << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] << " t: " << t[det] + << endl; + + // fill histograms for ToFD + fh_xy_tofd->Fill(x[det] * 100., y[det] * 100.); + fh_Cave_position->Fill(1000., x[det] * 100.); + fh_tofd_charge->Fill(q[det]); + + // differ between left and right half of ToFD + if (ptn[tofdr]) + { // right half in direction of beam + + // look for hits in Fi3a, Fi11 and Fi13 + // auto detMapped3a = fMappedItems.at(DET_FI3A); + auto detHit3a = fHitItems.at(DET_FI3A); + Int_t nHits3a = detHit3a->GetEntriesFast(); + LOG(DEBUG) << "Fi3a hits: " << nHits3a << endl; + fh_mult_Fib[fi3a]->Fill(nHits3a); + for (Int_t ihit3a = 0; ihit3a <= nHits3a; ihit3a++) { - R3BTofdHitData* hit = (R3BTofdHitData*)det->At(ihit); - if (!hit) - continue; // should not happen - if (ihit > 15) + if (nHits3a == 0) { - cout << "Error, more than 16 hits" << endl; - continue; + // no hit in 3a but can still be tracked + + det = fi3a; + x[det] = 0.; + y[det] = 0.; + z[det] = 0.; + q[det] = 0.; + t[det] = 0.; + ptn[det] = false; } - timeTofd[ihit] = hit->GetTime(); - xTofd[ihit] = hit->GetX(); - yTofd[ihit] = hit->GetY(); - qTofd[ihit] = hit->GetEloss(); - if (qTofd[ihit] > 1 && qTofd[ihit] < 4) + else { - TofdQ = 2.; - TofdX = xTofd[ihit]; - timeTofd0 = timeTofd[ihit]; - } + R3BBunchedFiberHitData* hit3a = (R3BBunchedFiberHitData*)detHit3a->At(ihit3a); + if (!hit3a) + continue; - // cout<<"ToFD: "<Fill(xTofd[ihit], yTofd[ihit]); - fh_Cave_position->Fill(1000., xTofd[ihit]); - fh_tofd_charge->Fill(qTofd[ihit]); + x[det] = hit3a->GetX() / 100.; + y[det] = hit3a->GetY() / 100.; + z[det] = 0.; + q[det] = hit3a->GetEloss(); + t[det] = hit3a->GetTime(); - double_t time2 = 0.; - if (time1 < 0 && qTofd[ihit] > 6.) - time1 = timeTofd[ihit]; - if (qTofd[ihit] > 6.) - time2 = timeTofd[ihit]; + // "Push" the Fib times in the same cycle with ToFD: + // ToFD coarse counter has 8192 channels with 5 ns each + // SPMT coarse counter has 2048 channels with 5 ns each - // cout << "Time0: "< 2048. * 5. / 2.) + { + t[det] += 2048. * 5.; + } - if (time2 > time1 && time1 > 0. && time2 > 0.) - { - // cout<<"Time Test "<Fill(time2 - time1); - time1 = time2; - // t0_prev=time0; - // time_previous_event=double(time0)+time2-time1; - - // cout << "Time0: "<Fill(x[det] * 100., tof); + fh_xy_Fib[det]->Fill(x[det] * 100., y[det] * 100.); + // Cuts on Fi3a - // fhChargeLosTofD->Fill(TofdQ,LosQ/2.); + ptn[det] = true; + LOG(DEBUG) << "Fi3a: " << ihit3a << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] + << " t: " << t[det] << endl; + } + // auto detMapped11 = fMappedItems.at(DET_FI11); + auto detHit11 = fHitItems.at(DET_FI11); + Int_t nHits11 = detHit11->GetEntriesFast(); + // cout<<"Fi11 hits: "<Fill(nHits11); + for (Int_t ihit11 = 0; ihit11 < nHits11; ihit11++) + { + R3BBunchedFiberHitData* hit11 = (R3BBunchedFiberHitData*)detHit11->At(ihit11); + if (!hit11) + continue; - //---------------------------------------------------------------------- - // Fiber detectors - //---------------------------------------------------------------------- - Double_t dtime = 0.0 / 0.0; - Int_t test = 0; - Int_t counter = 0; - for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) - { - Int_t iFib = 0; - FibMax[ifibcount] = 0; - auto detMapped = fMappedItems.at(DET_FI_FIRST + ifibcount); - auto detHit = fHitItems.at(DET_FI_FIRST + ifibcount); + det = fi11; - if (detMapped) - { - Int_t nHits = detMapped->GetEntriesFast(); - std::vector mapmt_num(512); - std::vector spmt_num(16); - for (Int_t ihit = 0; ihit < nHits; ihit++) - { - R3BBunchedFiberMappedData* hit = (R3BBunchedFiberMappedData*)detMapped->At(ihit); - if (!hit) - continue; + x[det] = hit11->GetX() / 100.; + y[det] = hit11->GetY() / 100.; + z[det] = 0.; + q[det] = hit11->GetEloss(); + t[det] = hit11->GetTime(); - // channel numbers are stored 1-based (1..n) - Int_t iCha = hit->GetChannel(); // 1.. + // "Push" two times in the same clock cycle: + while (t[tofdr] - t[det] < 2048. * 5. / 2.) + { + t[det] -= 2048. * 5.; + } + while (t[tofdr] - t[det] > 2048. * 5. / 2.) + { + t[det] += 2048. * 5.; + } - if (hit->IsMAPMT() && hit->IsLeading()) - { - fh_channels_Fib[ifibcount]->Fill(iCha); // Fill which clockTDC channel has events - ++mapmt_num.at(hit->GetChannel() - 1); // multihit of a given clockTDC channel - } + tof = t[tofdr] - t[det]; + fh_Fib_ToF[det]->Fill(x[det] * 100., tof); + fh_xy_Fib[det]->Fill(x[det] * 100., y[det] * 100); + // Cuts on Fi11 + + ptn[det] = true; + LOG(DEBUG) << "Fi11: " << ihit11 << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] + << " t: " << t[det] << endl; + + // auto detMapped13 = fMappedItems.at(DET_FI13); + auto detHit13 = fHitItems.at(DET_FI13); + Int_t nHits13 = detHit13->GetEntriesFast(); + // cout<<"Fi13 hits: "<Fill(nHits13); + for (Int_t ihit13 = 0; ihit13 < nHits13; ihit13++) + { + R3BBunchedFiberHitData* hit13 = (R3BBunchedFiberHitData*)detHit13->At(ihit13); + if (!hit13) + continue; - if (!hit->IsMAPMT() && hit->IsLeading()) - { - ++spmt_num.at(hit->GetChannel() - 1); // multihit of a given PADI channel - } - } + det = fi13; - for (int i = 0; i < 512; ++i) - { - auto m = mapmt_num.at(i); - if (m > 0) - fh_multihit_m_Fib[ifibcount]->Fill(i, m); // multihit of a given clockTDC channel - } + x[det] = hit13->GetX() / 100.; + y[det] = hit13->GetY() / 100.; + z[det] = 0.; + q[det] = hit13->GetEloss(); + t[det] = hit13->GetTime(); - for (int i = 0; i < 16; ++i) - { - auto s = spmt_num.at(i); + // "Push" two times in the same clock cycle: + while (t[tofdr] - t[det] < 2048. * 5. / 2.) + { + t[det] -= 2048. * 5.; + } + while (t[tofdr] - t[det] > 2048. * 5. / 2.) + { + t[det] += 2048. * 5.; + } - if (s > 0) - fh_multihit_s_Fib[ifibcount]->Fill(i, s); // multihit of a given PADI channel - } - } + tof = t[tofdr] - t[det]; + fh_Fib_ToF[det]->Fill(x[det] * 100., tof); + fh_xy_Fib[det]->Fill(x[det] * 100., y[det] * 100.); + // Cuts on Fi13 - if (detHit) - { + ptn[det] = true; - Int_t nHits = detHit->GetEntriesFast(); - // cout<<"Fiber Hits: "< fiber_num(2049); - - Double_t xposfib = 0. / 0.; - Double_t yposfib = 0. / 0.; - Double_t totMax = 0.; - Double_t tfib = 0. / 0., tof_fib_s = 0. / 0., tof_fib_m = 0. / 0.; - Double_t randx; - Int_t iFibMax = 0; - Double_t totMax_MA = 0.; - Int_t iFibMax_MA = 0; - - Double_t spmtMax; - Double_t mapmtMax; - Double_t tofMax; - Double_t y; - Double_t tof[16] = { 0., 0., 0., 0., -20., -20., 0., 0., 0., 0., 0., 0., 85., 60., 80., 65. }; - Double_t z[16] = { -51., -49., 0., 0., 45., 50., 0., 0., 0., 0., 0., 0., 700., 670., 630., 600. }; - Double_t x[16] = { 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., -200., -180., -150., -130. }; - - if (counter == 0 && nHits > 0) - { - fFibEvents++; - counter = 1; - } + LOG(DEBUG) << "Fi13: " << ihit13 << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] + << " t: " << t[det] << endl; - for (Int_t ihit = 0; ihit < nHits; ihit++) - { - Double_t tMAPMT = 0. / 0.; - Double_t tSPMT = 0. / 0.; + Bool_t det_coord = true; + Double_t track_parameter[6]; // x,y,z, px, py, pz + Double_t chi_single_parameter[2]; // chi2, chi2_red - R3BBunchedFiberHitData* hit = (R3BBunchedFiberHitData*)detHit->At(ihit); - if (!hit) - continue; + ptn[1] = false; + ptn[2] = false; + ptn[4] = false; - iFib = hit->GetFiberId(); // 1.. - ++fiber_num.at(iFib); // multihit of a given fiber - auto m_fib = fiber_num.at(iFib); + // here call tracker + single_track_from_cpp_(&n_det, &det_coord, x, y, z, ptn, track_parameter, chi_single_parameter); - // times - tMAPMT = hit->GetMAPMTTime_ns(); - tSPMT = hit->GetSPMTTime_ns(); + // make output + if (chi_single_parameter[1] < 10.) + Output(track_parameter, chi_single_parameter); - dtime = tMAPMT - tSPMT; + } // end of loop Fi13 - // "Push" two times in the same clock cycle: - while (dtime < -1024) + } // end of loop Fi11 + } // end of loop Fi3a + } + else + { // left half in direction of beam + + // look for hits in Fi3b, Fi12 and Fi10 + // auto detMapped3b = fMappedItems.at(DET_FI3B); + auto detHit3b = fHitItems.at(DET_FI3B); + Int_t nHits3b = detHit3b->GetEntriesFast(); + // cout<<"Fi3b hits: "<Fill(nHits3b); + for (Int_t ihit3b = 0; ihit3b <= nHits3b; ihit3b++) + { + if (nHits3b == 0) { - tSPMT = tSPMT - 2048.; - dtime = tMAPMT - tSPMT; + // no hit in 3b but can still be tracked + det = fi3b; + x[det] = 0.; + y[det] = 0.; + z[det] = 0.; + q[det] = 0.; + t[det] = 0.; + ptn[det] = false; } - while (dtime > 1024.) + else { - tSPMT = tSPMT + 2048.; - dtime = tMAPMT - tSPMT; - } + R3BBunchedFiberHitData* hit3b = (R3BBunchedFiberHitData*)detHit3b->At(ihit3b); + if (!hit3b) + continue; - // "Push" the Fib times in the same cycle with Tofd: - if (timeTofd0 > 0. && !(IS_NAN(timeTofd0))) - { - while (tSPMT - timeTofd0 < -1024.) + det = fi3b; + + x[det] = hit3b->GetX() / 100.; + y[det] = hit3b->GetY() / 100.; + z[det] = 0.; + q[det] = hit3b->GetEloss(); + t[det] = hit3b->GetTime(); + + // "Push" two times in the same clock cycle: + while (t[tofdl] - t[det] < 2048. * 5. / 2.) { - tMAPMT = tMAPMT + 2048.; - tSPMT = tSPMT + 2048.; + t[det] -= 2048. * 5.; } - while (tSPMT - timeTofd0 > 1024.) + while (t[tofdl] - t[det] > 2048. * 5. / 2.) { - tMAPMT = tMAPMT - 2048.; - tSPMT = tSPMT - 2048.; + t[det] += 2048. * 5.; } - } - // find fiber with most light - // Double_t ToT = sqrt(hit->GetSPMTToT_ns()*hit->GetMAPMTToT_ns()); - Double_t ToT = (3. * hit->GetMAPMTToT_ns() + hit->GetSPMTToT_ns()) / 4.; - Double_t ToT_MA = hit->GetMAPMTToT_ns(); - - // Not-calibrated ToF: - // tfib = (tMAPMT + tSPMT) / 2.; - tfib = tSPMT; - if (tfib > 0. && !(IS_NAN(tfib)) && timeTofd0 > 0. && !(IS_NAN(timeTofd0))) - tof_fib_s = tfib - timeTofd0; - if (tMAPMT > 0. && !(IS_NAN(tMAPMT)) && timeTofd0 > 0. && !(IS_NAN(timeTofd0))) - tof_fib_m = tMAPMT - timeTofd0; - - // if(fNEvents<10000 && ifibcount == 13){ - if (fNEvents < 10000 && iFib > 900 && iFib < 1020 && ifibcount == 13) - { - test = 0; - cout << "Det: " << ifibcount << " Fiber: " << iFib << " MAToT: " << hit->GetMAPMTToT_ns() - << " SToT: " << hit->GetSPMTToT_ns() << " sqrt: " << ToT << " tof: " << tof_fib_s - << " tM: " << tof_fib_m << endl; - } + tof = t[tofdl] - t[det]; + fh_Fib_ToF[det]->Fill(x[det] * 100., tof); + fh_xy_Fib[det]->Fill(x[det] * 100., y[det] * 100.); + // Cuts on Fi3b - if (abs(tof_fib_s - tof[ifibcount]) < 20. && ToT < 1000.) - { - // if(ToT>totMax && ToT<1000.) { - totMax = ToT; - iFibMax = iFib; - spmtMax = hit->GetSPMTToT_ns(); - mapmtMax = hit->GetMAPMTToT_ns(); - // tofMax=tof_fib_m; - tofMax = tof_fib_s; - // Not-calibrated position: - randx = (std::rand() / (float)RAND_MAX); - xposfib = (-n_fiber[ifibcount] / 2. + iFib + (0.5 - randx)); - yposfib = tMAPMT - tSPMT; + LOG(DEBUG) << "Fi3b: " << ihit3b << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] + << " t: " << t[det] << endl; + ptn[det] = true; } - // if(ToT_MA>totMax_MA && abs(tof_fib_s-tof[ifibcount])<20. && ToT_MA<1000.) { - if (ToT_MA > totMax_MA) + // auto detMapped12 = fMappedItems.at(DET_FI12); + auto detHit12 = fHitItems.at(DET_FI12); + Int_t nHits12 = detHit12->GetEntriesFast(); + // cout<<"Fi12 hits: "<Fill(nHits12); + for (Int_t ihit12 = 0; ihit12 < nHits12; ihit12++) { - totMax_MA = ToT_MA; - iFibMax_MA = iFib; - } + R3BBunchedFiberHitData* hit12 = (R3BBunchedFiberHitData*)detHit12->At(ihit12); + if (!hit12) + continue; - if (abs(tof_fib_s - tof[ifibcount]) < 20. && TofdQ > 0 && TofdQ < 200.01) - { - fh_Fibs_vs_Tofd[ifibcount]->Fill(TofdX, iFib); - // cout<<"test "<Fill(iFibMax); - fh_fiber_Fib[ifibcount]->Fill(iFibMax); - fh_ToT_s_Fib[ifibcount]->Fill(iFibMax, spmtMax); - fh_ToT_m_Fib[ifibcount]->Fill(iFibMax, mapmtMax); - fh_time_Fib[ifibcount]->Fill(iFibMax, yposfib); - fh_Fib_ToF[ifibcount]->Fill(iFibMax, tofMax); - fh_xpos_Fib[ifibcount]->Fill(xposfib); - fh_ypos_Fib[ifibcount]->Fill(yposfib); - fh_Fibs_vs_Events[ifibcount]->Fill(fFibEvents, iFibMax); - fh_Fib_vs_Events[ifibcount]->Fill(fFibEvents, iFibMax_MA); - fh_ToF_vs_events[ifibcount]->Fill(fFibEvents, tofMax); - FibMax[ifibcount] = iFibMax; - } + det = fi12; - } // end for(ihit) + x[det] = hit12->GetX() / 100.; + y[det] = hit12->GetY() / 100.; + z[det] = 0.; + q[det] = hit12->GetEloss(); + t[det] = hit12->GetTime(); - // if(abs(tof_fib_s-tof[ifibcount])<20.) - /* - if(totMax>0) + // "Push" two times in the same clock cycle: + while (t[tofdl] - t[det] < 2048. * 5. / 2.) + { + t[det] -= 2048. * 5.; + } + while (t[tofdl] - t[det] > 2048. * 5. / 2.) + { + t[det] += 2048. * 5.; + } + + tof = t[tofdl] - t[det]; + fh_Fib_ToF[det]->Fill(x[det] * 100., tof); + fh_xy_Fib[det]->Fill(x[det] * 100., y[det] * 100.); + // Cuts on Fi12 + + LOG(DEBUG) << "Fi12: " << ihit12 << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] + << " t: " << t[det] << endl; + ptn[det] = true; + + // auto detMapped10 = fMappedItems.at(DET_FI10); + auto detHit10 = fHitItems.at(DET_FI10); + Int_t nHits10 = detHit10->GetEntriesFast(); + // cout<<"Fi10 hits: "<Fill(nHits10); + for (Int_t ihit10 = 0; ihit10 < nHits10; ihit10++) + { + R3BBunchedFiberHitData* hit10 = (R3BBunchedFiberHitData*)detHit10->At(ihit10); + if (!hit10) + continue; + + det = fi10; + + x[det] = hit10->GetX() / 100.; + y[det] = hit10->GetY() / 100.; + z[det] = 0.; + q[det] = hit10->GetEloss(); + t[det] = hit10->GetTime(); + + // "Push" two times in the same clock cycle: + while (t[tofdl] - t[det] < 2048. * 5. / 2.) { - if(TofdQ>1. && TofdQ<4.) { - fh_fibers_Fib[ifibcount]->Fill(iFibMax); - fh_fiber_Fib[ifibcount]->Fill(iFibMax); - fh_ToT_s_Fib[ifibcount]->Fill(iFibMax,spmtMax); - fh_ToT_m_Fib[ifibcount]->Fill(iFibMax,mapmtMax); - fh_time_Fib[ifibcount]->Fill(iFibMax,yposfib); - fh_Fib_ToF[ifibcount]->Fill(iFibMax,tofMax); - fh_xpos_Fib[ifibcount]->Fill(xposfib); - fh_ypos_Fib[ifibcount]->Fill(yposfib); - fh_Fibs_vs_Events[ifibcount]->Fill(fFibEvents,iFibMax); - fh_Fib_vs_Events[ifibcount]->Fill(fFibEvents,iFibMax_MA); - fh_ToF_vs_events[ifibcount]->Fill(fFibEvents, tofMax); - FibMax[ifibcount]=iFibMax; - } + t[det] -= 2048. * 5.; + } + while (t[tofdl] - t[det] > 2048. * 5. / 2.) + { + t[det] += 2048. * 5.; } - */ - if (nHits > 0) - fh_mult_Fib[ifibcount]->Fill(nHits); - fh_Cave_position->Fill(z[ifibcount], x[ifibcount] + xposfib); + tof = t[tofdl] - t[det]; + fh_Fib_ToF[det]->Fill(x[det] * 100., tof); + fh_xy_Fib[det]->Fill(x[det] * 100., y[det] * 100.); + // Cuts on Fi10 - if (test) - cout << "fiber max: " << iFibMax << endl; + LOG(DEBUG) << "Fi10: " << ihit10 << " x: " << x[det] << " y: " << y[det] << " q: " << q[det] + << " t: " << t[det] << endl; + ptn[det] = true; - } // end if(aHit[ifibcount]) + // here call tracker + Bool_t det_coord = true; + Double_t track_parameter[6]; // x,y,z, px, py, pz + Double_t chi_single_parameter[2]; // chi2, chi2_red - if (ifibcount == 13 && test) - { - cout << " " << endl; - cout << "new event! ******************************************************" << endl; - } + ptn[0] = false; + ptn[3] = false; + ptn[5] = false; - } // end for(ifibcount) + // here call tracker + single_track_from_cpp_(&n_det, &det_coord, x, y, z, ptn, track_parameter, chi_single_parameter); + if (chi_single_parameter[1] < 10.) + Output(track_parameter, chi_single_parameter); - for (Int_t i = 0; i < NOF_FIB_DET; i++) - { - for (Int_t j = i + 1; j < NOF_FIB_DET; j++) - { - if (fHitItems.at(i + DET_FI_FIRST) && fHitItems.at(j + DET_FI_FIRST)) - { - if (TofdQ > 0. && TofdQ < 100.) - { - fh_Fib_vs_Fib[i][j]->Fill(FibMax[i], FibMax[j]); - if (FibMax[i] > 0 && FibMax[j] > 0) - fh_Fib_dx[i][j]->Fill(FibMax[i], FibMax[j] - FibMax[i]); - } - } - } - } + } // end of loop Fi13 + + } // end of loop Fi11 + } // end of loop Fi3a + + } // end if left half + + } // end loop over ToFD fNEvents += 1; } - +void R3BGlobalAnalysisS454::Output(Double_t track_parameter[6], Double_t chi_single_parameter[2]) +{ + Double_t q = 8.; + LOG(DEBUG) << "******************************************" << endl; + LOG(DEBUG) << "chi_single_parameter " << chi_single_parameter[0] << " " << chi_single_parameter[1] << endl; + LOG(DEBUG) << "xyz: " << track_parameter[0] * 100. << " " << track_parameter[1] * 100. << " " + << track_parameter[2] * 100. << endl; + LOG(DEBUG) << "p: " << track_parameter[3] * q << " " << track_parameter[4] * q << " " << track_parameter[5] * q + << endl; + Double_t p_tot = q * sqrt(track_parameter[3] * track_parameter[3] + track_parameter[4] * track_parameter[4] + + track_parameter[5] * track_parameter[5]); + Double_t thetax_simu = Pxf / Pzf * 1000.; + Double_t thetay_simu = Pyf / Pzf * 1000.; + + fh_target_xy->Fill(track_parameter[0] * 100., track_parameter[1] * 100.); + fh_target_px->Fill(track_parameter[3] * q); + fh_target_py->Fill(track_parameter[4] * q); + fh_target_pz->Fill(track_parameter[5] * q); + + fh_thetax_dpx->Fill((Pxf - track_parameter[3] * q) / Pxf * 100., thetax_simu); + fh_thetay_dpy->Fill((Pyf - track_parameter[4] * q) / Pyf * 100., thetay_simu); + + fh_thetax_dpy->Fill((Pyf - track_parameter[4] * q) / Pyf * 100., thetax_simu); + fh_thetay_dpx->Fill((Pxf - track_parameter[3] * q) / Pxf * 100., thetay_simu); + + fh_x_dpx->Fill((Pxf - track_parameter[3] * q) / Pxf * 100., Xf); + fh_y_dpy->Fill((Pyf - track_parameter[4] * q) / Pyf * 100., Yf); + fh_dx->Fill(Xf - track_parameter[0] * 100.); + fh_dy->Fill(Yf - track_parameter[1] * 100.); + fh_dz->Fill(Zf - track_parameter[2] * 100.); + fh_dpx->Fill((Pxf - track_parameter[3] * q) / Pxf * 100.); + fh_dpy->Fill((Pyf - track_parameter[4] * q) / Pyf * 100.); + fh_dpz->Fill((Pzf - track_parameter[5] * q) / Pzf * 100.); + fh_dp->Fill((Pf_tot - p_tot) / Pf_tot * 100.); +} void R3BGlobalAnalysisS454::FinishEvent() { @@ -915,16 +1130,35 @@ void R3BGlobalAnalysisS454::FinishEvent() void R3BGlobalAnalysisS454::FinishTask() { - fhTpat->Write(); + fh_Tpat->Write(); + fh_Trigger->Write(); fh_Cave_position->Write(); - if (fMappedItems.at(DET_LOS)) - { - fhChargeLosTofD->Write(); - fh_los_pos->Write(); - } + fh_TOFDOR->Write(); + fh_SEE->Write(); + fh_IC->Write(); + + fh_target_xy->Write(); + fh_target_px->Write(); + fh_target_py->Write(); + fh_target_pz->Write(); + + fh_dx->Write(); + fh_dy->Write(); + fh_dz->Write(); + fh_dpx->Write(); + fh_dpy->Write(); + fh_dpz->Write(); + fh_dp->Write(); + fh_thetax_dpx->Write(); + fh_thetay_dpy->Write(); + fh_thetax_dpy->Write(); + fh_thetay_dpx->Write(); + fh_x_dpx->Write(); + fh_y_dpy->Write(); + if (fHitItems.at(DET_TOFD)) { - // fh_tofd_pos->Write(); + fh_xy_tofd->Write(); fh_tofd_charge->Write(); fh_TimePreviousEvent->Write(); fh_tofd_mult->Write(); @@ -934,7 +1168,7 @@ void R3BGlobalAnalysisS454::FinishTask() { if (fMappedItems.at(ifibcount + DET_FI_FIRST)) { - fh_channels_Fib[ifibcount]->Write(); + fh_xy_Fib[ifibcount]->Write(); fh_fibers_Fib[ifibcount]->Write(); fh_fiber_Fib[ifibcount]->Write(); fh_mult_Fib[ifibcount]->Write(); diff --git a/r3bbase/R3BGlobalAnalysisS454.h b/r3bbase/R3BGlobalAnalysisS454.h index 0f152be9d..965df0e67 100644 --- a/r3bbase/R3BGlobalAnalysisS454.h +++ b/r3bbase/R3BGlobalAnalysisS454.h @@ -96,6 +96,8 @@ class R3BGlobalAnalysisS454 : public FairTask */ virtual void FinishTask(); + virtual void Output(Double_t tracker[6], Double_t chi2[2]); + /** * Method for setting the trigger value. * @param trigger 1 - onspill, 2 - offspill, -1 - all events. @@ -104,90 +106,83 @@ class R3BGlobalAnalysisS454 : public FairTask inline void SetTpat(Int_t tpat) { fTpat = tpat; } /** - * Methods for setting number of planes and paddles + * Methods for setting reset and readout times for Bmon */ - inline void SetNofModules(Int_t planes, Int_t ppp) + inline void SetBmon(Int_t sens_SEE, Int_t sens_IC) { - fNofPlanes = planes; - fPaddlesPerPlane = ppp; + fsens_SEE = sens_SEE; + fsens_IC = sens_IC; } - // virtual void SetParContainers(); - private: std::vector fMappedItems; std::vector fCalItems; std::vector fHitItems; + TClonesArray* fMCTrack; enum DetectorInstances { - DET_AMS, DET_CALIFA, + DET_BMON, + DET_ROLU, DET_FI_FIRST, - DET_FI1A = DET_FI_FIRST, - DET_FI1B, - DET_FI2A, - DET_FI2B, - DET_FI3A, + DET_FI3A = DET_FI_FIRST, DET_FI3B, - DET_FI4, - DET_FI5, - DET_FI6, - DET_FI7, - DET_FI8, - DET_FI9, DET_FI10, DET_FI11, DET_FI12, DET_FI13, DET_FI_LAST = DET_FI13, - DET_L3T, - DET_LOS, - DET_MUSIC, - DET_NEULAND, - DET_PSPX, - DET_PTOF, - DET_ROLU, - DET_SCI8, - DET_STRAW, DET_TOFD, DET_MAX }; #define NOF_FIB_DET (DET_FI_LAST - DET_FI_FIRST + 1) - const char* fDetectorNames[DET_MAX + 1] = { "Ams", "Califa", "Fi1a", "Fi1b", "Fi2a", "Fi2b", "Fi3a", "Fi3b", - "Fi4", "Fi5", "Fi6", "Fi7", "Fi8", "Fi9", "Fi10", "Fi11", - "Fi12", "Fi13", "L3t", "Los", "Music", "Neuland", "Pspx", "Ptof", - "Rolu", "Sci8", "Straw", "Tofd", NULL }; + const char* fDetectorNames[DET_MAX + 1] = { "Califa", "BeamMonitor", "Rolu", "Fi3a", "Fi3b", "Fi10", + "Fi11", "Fi12", "Fi13", "Tofd", NULL }; // If FiberI is present or not: Int_t ifibdet; // Number of fibers per detector - Double_t n_fiber[NOF_FIB_DET] = { 256., 256., 256., 256., 512., 512., 2048., - 2048., 1024., 512., 512., 512., 1024., 1024. }; + Double_t n_fiber[NOF_FIB_DET] = { 512., 512., 2048., 2048., 2048., 2048. }; // check for trigger should be done globablly (somewhere else) R3BEventHeader* header; /**< Event header. */ Int_t fTrigger; /**< Trigger value. */ Int_t fTpat; - Double_t fClockFreq; /**< Clock cycle in [ns]. */ - UInt_t fNofPlanes; - UInt_t fPaddlesPerPlane; /**< Number of paddles per plane. */ - unsigned long long t0_prev = 0; - Double_t time_previous_event = 0; - - TH1F* fhTpat; - - Int_t fNEvents = 0; /**< Event counter. */ - Int_t fFibEvents = 0; /**< Event counter. */ - Double_t max_values[NOF_FIB_DET][2048]; - Int_t FibMax[NOF_FIB_DET]; - TH2F* fhChargeLosTofD; - TH2F* fh_los_pos; - - TH1F* fh_channels_Fib[NOF_FIB_DET]; + unsigned long long time_start = 0, time = 0; + unsigned long ic_start = 0, see_start = 0, tofdor_start = 0; + unsigned long fNEvents = 0, fNEvents_start = 0; /**< Event counter. */ + + Int_t maxevent; + + Int_t fsens_SEE, fsens_IC; // SEETRAM and IC sensitivity, between -4 and -10 + Double_t calib_SEE = 1.; // SEETRAM calibration factor + Double_t see_offset = 7.1; // SEETRAM offset in kHz + Double_t counts_SEE = 0; + Double_t counts_IC = 0; + Double_t counts_TofD = 0; + + Double_t Pxf = 0.; + Double_t Pyf = 0.; + Double_t Pzf = 0.; + Double_t Xf = 0.; + Double_t Yf = 0.; + Double_t Zf = 0.; + Double_t Tf = 0.; + Double_t Pf_tot = 0.; + + UInt_t num_spills = 0; + + TH1F* fh_Tpat; + TH1F* fh_Trigger; + TH1F* fh_IC; + TH1F* fh_SEE; + TH1F* fh_TOFDOR; + + TH2F* fh_xy_Fib[NOF_FIB_DET]; TH1F* fh_fibers_Fib[NOF_FIB_DET]; TH1F* fh_fiber_Fib[NOF_FIB_DET]; TH1F* fh_mult_Fib[NOF_FIB_DET]; @@ -209,34 +204,32 @@ class R3BGlobalAnalysisS454 : public FairTask TH2F* fh_Cave_position; - TH2F* fh_tofd_pos; + TH2F* fh_xy_tofd; TH1F* fh_tofd_charge; TH1F* fh_TimePreviousEvent; TH1F* fh_tofd_mult; - TH1F* fh_ptof_channels; - TH1F* fh_ptof_channels_cut; - TH1F* fh_ptof_test1; - TH1F* fh_ptof_test2; - TH1F* fh_ptof_TotPm1[N_PADDLE_MAX_PTOF]; - TH1F* fh_ptof_TotPm2[N_PADDLE_MAX_PTOF]; - - TH1F* fh_pspx_strips_psp[N_PSPX_S454]; - TH1F* fh_pspx_energy_psp[N_PSPX_S454]; - TH1F* fh_pspx_multiplicity_psp[N_PSPX_S454]; - - TH2F* fh_pspx_pos1_strips; - TH2F* fh_pspx_pos2_strips; - TH2F* fh_pspx_pos1_energy; - TH2F* fh_pspx_pos2_energy; - - TH2F* fh_pspx_cor_x_strips; - TH2F* fh_pspx_cor_y_strips; - TH2F* fh_pspx_cor_x_energy; - TH2F* fh_pspx_cor_y_energy; - TH2F* fh_ToF_vs_events[NOF_FIB_DET]; + TH2F* fh_target_xy; + TH1F* fh_target_px; + TH1F* fh_target_py; + TH1F* fh_target_pz; + + TH1F* fh_dx; + TH1F* fh_dy; + TH1F* fh_dz; + TH1F* fh_dpx; + TH1F* fh_dpy; + TH1F* fh_dpz; + TH1F* fh_dp; + TH2F* fh_thetax_dpx; + TH2F* fh_thetay_dpy; + TH2F* fh_x_dpx; + TH2F* fh_y_dpy; + TH2F* fh_thetax_dpy; + TH2F* fh_thetay_dpx; + public: ClassDef(R3BGlobalAnalysisS454, 1) }; diff --git a/r3bbase/R3BLinkDef.h b/r3bbase/R3BLinkDef.h index 7c15b948f..2336090b0 100644 --- a/r3bbase/R3BLinkDef.h +++ b/r3bbase/R3BLinkDef.h @@ -23,6 +23,7 @@ #pragma link C++ class R3BDetector+; #pragma link C++ class R3BEventHeader+; #pragma link C++ class R3BOnlineSpectra+; +#pragma link C++ class R3BOnlineSpectraDec2019+; #pragma link C++ class R3BGlobalAnalysis+; #pragma link C++ class R3BGlobalAnalysisS454+; diff --git a/r3bbase/R3BOnlineSpectraDec2019.cxx b/r3bbase/R3BOnlineSpectraDec2019.cxx new file mode 100644 index 000000000..3de763372 --- /dev/null +++ b/r3bbase/R3BOnlineSpectraDec2019.cxx @@ -0,0 +1,3048 @@ +// ------------------------------------------------------------ +// ----- R3BOnlineSpectraDec2019 ----- +// ----- Created April 13th 2016 by M.Heil ----- +// ------------------------------------------------------------ + +/* + * This task should fill histograms with detector variables which allow + * to test the detectors online + * + */ + +#include "R3BOnlineSpectraDec2019.h" +#include "R3BLosCalData.h" +#include "R3BLosMappedData.h" + +#include "R3BRoluCalData.h" +#include "R3BRoluMappedData.h" + +#include "R3BSci8CalData.h" +#include "R3BSci8MappedData.h" + +#include "R3BBeamMonitorMappedData.h" + +#include "R3BTofdCalData.h" +#include "R3BTofdMappedData.h" + +#include "R3BPaddleCalData.h" +#include "R3BPaddleTamexMappedData.h" + +#include "R3BPspxCalData.h" +#include "R3BPspxHitData.h" +#include "R3BPspxMappedData.h" +#include "R3BPspxPrecalData.h" + +#include "R3BEventHeader.h" +#include "R3BTCalEngine.h" + +#include "R3BBunchedFiberCalData.h" +#include "R3BBunchedFiberHitData.h" +#include "R3BBunchedFiberMappedData.h" + +#include "R3BSamplerMappedData.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRunOnline.h" +#include "FairRuntimeDb.h" +#include "TCanvas.h" +#include "TGaxis.h" +#include "TH1F.h" +#include "TH2F.h" +#include "THttpServer.h" +#include "TLegend.h" + +#include "TClonesArray.h" +#include "TMath.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define IS_NAN(x) TMath::IsNaN(x) +using namespace std; + +R3BOnlineSpectraDec2019::R3BOnlineSpectraDec2019() + : R3BOnlineSpectraDec2019("OnlineSpectra", 1) +{ +} + +R3BOnlineSpectraDec2019::R3BOnlineSpectraDec2019(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fTrigger(-1) + , fTpat(-1) + , fSamp(-1) + , fNofPlanes(N_PLANE_MAX_TOFD) + , fPaddlesPerPlane(N_PADDLE_MAX_TOFD) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fNEvents(0) +{ +} + +R3BOnlineSpectraDec2019::~R3BOnlineSpectraDec2019() +{ + // delete fhTpat ; + // delete fhTrigger; + // delete fh_SEETRAM; + + for (int i = 0; i < NOF_FIB_DET; i++) + { + delete fh_channels_Fib[i]; + delete fh_fibers_Fib[i]; + delete fh_mult_Fib[i]; + delete fh_time_Fib[i]; + delete fh_multihit_m_Fib[i]; + delete fh_multihit_s_Fib[i]; + delete fh_ToT_m_Fib[i]; + delete fh_ToT_s_Fib[i]; + delete fh_ToT_single_Fib[i]; + delete fh_channels_single_Fib[i]; + } +} + +InitStatus R3BOnlineSpectraDec2019::Init() +{ + + // Initialize random number: + std::srand(std::time(0)); // use current time as seed for random generator + + LOG(INFO) << "R3BOnlineSpectraDec2019::Init "; + + // try to get a handle on the EventHeader. EventHeader may not be + // present though and hence may be null. Take care when using. + + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + LOG(fatal) << "FairRootManager not found"; + + header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); + FairRunOnline* run = FairRunOnline::Instance(); + + run->GetHttpServer()->Register("/Tasks", this); + + // Get objects for detectors on all levels + assert(DET_MAX + 1 == sizeof(fDetectorNames) / sizeof(fDetectorNames[0])); + printf("Have %d fiber detectors.\n", NOF_FIB_DET); + for (int det = 0; det < DET_MAX; det++) + { + fMappedItems.push_back((TClonesArray*)mgr->GetObject(Form("%sMapped", fDetectorNames[det]))); + if (NULL == fMappedItems.at(det)) + { + printf("Could not find mapped data for '%s'.\n", fDetectorNames[det]); + } + fCalItems.push_back((TClonesArray*)mgr->GetObject(Form("%sCal", fDetectorNames[det]))); + fHitItems.push_back((TClonesArray*)mgr->GetObject(Form("%sHit", fDetectorNames[det]))); + } + + //------------------------------------------------------------------------ + // create histograms of all detectors + //------------------------------------------------------------------------ + + // Trigger and Tpat + TCanvas* cTrigg = new TCanvas("Trigg", "Triggers", 10, 10, 650, 350); + fhTpat = new TH1F("Tpat", "Tpat", 20, 0, 20); + fhTpat->GetXaxis()->SetTitle("Tpat value"); + + fhTrigger = new TH1F("Trigger", "Trigger all", 20, 0, 20); + fhTrigger->GetXaxis()->SetTitle("Trigger value"); + + cTrigg->Divide(2, 1); + cTrigg->cd(1); + gPad->SetLogy(); + fhTrigger->Draw(); + cTrigg->cd(2); + gPad->SetLogy(); + fhTpat->Draw(); + cTrigg->cd(0); + + //------------------------------------------------------------------------ + // Rolu detector + + if (fMappedItems.at(DET_ROLU)) + { + TCanvas* cRolu = new TCanvas("Rolu", "Rolu", 10, 10, 800, 400); + + fh_rolu_tot = new TH2F("Rolu_tot", "ROLU ToT", 10, 0, 10, 3000, 0, 300); + fh_rolu_tot->GetXaxis()->SetTitle("Channel number"); + fh_rolu_tot->GetYaxis()->SetTitle("ToT / ns"); + + fh_rolu_channels = new TH1F("Rolu_channels", "ROLU channels", 10, 0, 10); + fh_rolu_channels->GetXaxis()->SetTitle("Channel number"); + fh_rolu_channels->GetYaxis()->SetTitle("Counts"); + + cRolu->Divide(2, 1); + cRolu->cd(1); + gPad->SetLogy(); + fh_rolu_channels->Draw(); + cRolu->cd(2); + gPad->SetLogz(); + fh_rolu_tot->Draw("colz"); + cRolu->cd(0); + run->AddObject(cRolu); + + run->GetHttpServer()->RegisterCommand("Reset_ROLU", Form("/Tasks/%s/->Reset_ROLU_Histo()", GetName())); + } + + //------------------------------------------------------------------------ + // Sci8 detector + + if (fMappedItems.at(DET_SCI8)) + { + TCanvas* cSci8 = new TCanvas("Sci8", "SCI8", 10, 10, 850, 850); + + fh_sci8_channels = new TH1F("sci8_channels", "SCI8 channels", 4, 0., 4.); + fh_sci8_channels->GetXaxis()->SetTitle("Channel number"); + fh_sci8_multihit = new TH1F("sci8_multihit", "SCI8 multihit", 20, 0., 20.); + fh_sci8_multihit->GetXaxis()->SetTitle("Multihit"); + fh_sci8_multihitVFTX = new TH2F("sci8_vftx_multihit", "SCI8 VFTX multihit", 4, 0., 4., 20, 0., 20.); + fh_sci8_multihitVFTX->GetYaxis()->SetTitle("Multihit "); + fh_sci8_multihitVFTX->GetXaxis()->SetTitle("Channel number"); + fh_sci8_multihitLEAD = new TH2F("sci8_lead_multihit", "SCI8 TAMEX Leading multihit", 4, 0., 4., 20, 0., 20.); + fh_sci8_multihitLEAD->GetYaxis()->SetTitle("Multihit "); + fh_sci8_multihitLEAD->GetXaxis()->SetTitle("Channel number"); + fh_sci8_multihitTRAI = new TH2F("sci8_trai_multihit", "SCI8 TAMEX Trailing multihit", 4, 0., 4., 20, 0., 20.); + fh_sci8_multihitTRAI->GetYaxis()->SetTitle("Multihit "); + fh_sci8_multihitTRAI->GetXaxis()->SetTitle("Channel number"); + fh_sci8_dt_hits = new TH1F("sci8_dt_hits", "SCI8 dt multihits", 4000, -2000, 2000); + fh_sci8_dt_hits->GetXaxis()->SetTitle("dt_VFTX between two hits / ns"); + fh_sci8_dt_hits_l = new TH1F("sci8_dt_hits_l", "SCI8 dt multihits leading", 4000, -2000, 2000); + fh_sci8_dt_hits_l->GetXaxis()->SetTitle("dt_LEAD between two hits / ns"); + fh_sci8_dt_hits_t = new TH1F("sci8_dt_hits_t", "SCI8 dt multihits trailing", 4000, -2000, 2000); + fh_sci8_dt_hits_t->GetXaxis()->SetTitle("dt_TRAIL between two hits / ns"); + fh_sci8_tres_MCFD = new TH1F("sci8_time_res_MCFD", "SCI8 MCFD Time resolution - raw", 2000, -10., 10.); + fh_sci8_tres_MCFD->GetXaxis()->SetTitle("Time MCFD / ns"); + fh_sci8_tres_TAMEX = new TH1F("sci8_time_res_TAMEX", "SCI8 TAMEX Time resolution -raw ", 8000, -4., 4.); + fh_sci8_tres_TAMEX->GetXaxis()->SetTitle("Time TAMEX / ns"); + fh_sci8_tot = new TH2F("sci8_tot", "SCI8 ToT vs PM", 4, 0, 4, 3000, 0., 300.); + fh_sci8_tot->GetXaxis()->SetTitle("PMT number"); + fh_sci8_tot->GetYaxis()->SetTitle("ToT / ns"); + fh_sci8_tot_mean = new TH1F("sci8_tot_mean", "SCI8 mean ToT", 3000, 0., 300.); + fh_sci8_tot_mean->GetYaxis()->SetTitle("Counts"); + fh_sci8_tot_mean->GetXaxis()->SetTitle("ToT / ns"); + fh_tof_sci8 = new TH1F("sci8_tof", "SCI8-LOS ToF", 20000, -5000, 15000); + fh_tof_sci8->GetXaxis()->SetTitle("ToF / ns"); + + cSci8->Divide(2, 2); + cSci8->cd(1); + fh_sci8_channels->Draw(); + cSci8->cd(2); + gPad->SetLogy(); + fh_sci8_multihit->Draw(); + // cSci8->cd(3);gPad->SetLogz(); + // fh_sci8_tot->Draw("colz"); + cSci8->cd(3); + fh_sci8_tres_MCFD->Draw(); + // cSci8->cd(5); + // fh_sci8_tres_TAMEX->Draw(); + cSci8->cd(4); + fh_tof_sci8->Draw(); + // cSci8->cd(7); + // fh_sci8_tot_mean->Draw(); + + cSci8->cd(0); + run->AddObject(cSci8); + + run->GetHttpServer()->RegisterCommand("Reset_SCI8", Form("/Tasks/%s/->Reset_SCI8_Histo()", GetName())); + } + + //------------------------------------------------------------------------ + // Los detector + TCanvas* cLos[fNofLosDetectors]; + + if (fMappedItems.at(DET_LOS)) + { + + if (fNofLosDetectors == 2) + { + fh_los_ToT_vs_ToT = new TH2F("los_tot_vs_tot", "LOS ToT vs ToT", 3000, 0., 300., 3000, 0., 300.); + fh_los_ToT_vs_ToT->GetXaxis()->SetTitle("ToT LOS1 / ns"); + fh_los_ToT_vs_ToT->GetYaxis()->SetTitle("ToT LOS2 / ns"); + } + + for (Int_t iloscount = 0; iloscount < fNofLosDetectors; iloscount++) + { + + char detName[255]; + sprintf(detName, "LOS%d", iloscount + 1); + + cLos[iloscount] = new TCanvas(detName, detName, 10, 10, 910, 810); + + fh_los_channels[iloscount] = + new TH1F(Form("%s_channels", detName), Form("%s channels", detName), 10, 0., 10.); + fh_los_channels[iloscount]->GetXaxis()->SetTitle("Channel number"); + + fh_los_multihit[iloscount] = + new TH1F(Form("%s_multihit", detName), Form("%s multihit && all 8 PMs", detName), 30, 0., 30.); + fh_los_multihit[iloscount]->GetXaxis()->SetTitle("Multihit"); + + fh_los_pos_MCFD[iloscount] = new TH2F( + Form("%s_pos_MCFD", detName), Form("%s MCFD Position ", detName), 1000, -5., 5., 1000, -5., 5.); + fh_los_pos_MCFD[iloscount]->GetXaxis()->SetTitle("X position / cm"); + fh_los_pos_MCFD[iloscount]->GetYaxis()->SetTitle("Y position / cm"); + + fh_los_pos_TAMEX[iloscount] = new TH2F( + Form("%s_pos_TAMEX", detName), Form("%s TAMEX Position ", detName), 1000, -5., 5., 1000, -5., 5.); + fh_los_pos_TAMEX[iloscount]->GetXaxis()->SetTitle("X position / cm"); + fh_los_pos_TAMEX[iloscount]->GetYaxis()->SetTitle("Y position / cm"); + + fh_los_pos_ToT[iloscount] = + new TH2F(Form("%s_pos_ToT", detName), Form("%s ToT Position ", detName), 1000, -5., 5., 1000, -5., 5.); + fh_los_pos_ToT[iloscount]->GetXaxis()->SetTitle("X position / cm"); + fh_los_pos_ToT[iloscount]->GetYaxis()->SetTitle("Y position / cm"); + + fh_los_dt_hits_ToT[iloscount] = + new TH2F(Form("%s_dt_ToT", detName), Form("%s ToT dt ", detName), 100000, 0, 500, 500, 0, 200.); + fh_los_dt_hits_ToT[iloscount]->GetXaxis()->SetTitle( + "dt between two hits / micros"); // dt between two hits / ns + fh_los_dt_hits_ToT[iloscount]->GetYaxis()->SetTitle("ToT / ns"); // ToT / ns + + fh_los_tres_MCFD[iloscount] = new TH1F( + Form("%s_time_res_MCFD", detName), Form("%s MCFD Time resolution - raw", detName), 4000, -4., 4.); + fh_los_tres_MCFD[iloscount]->GetXaxis()->SetTitle("Time MCFD / ns"); + + fh_los_tres_TAMEX[iloscount] = new TH1F( + Form("%s_time_res_TAMEX", detName), Form("%s TAMEX Time resolution -raw ", detName), 4000, -4., 4.); + fh_los_tres_TAMEX[iloscount]->GetXaxis()->SetTitle("Time TAMEX / ns"); + + fh_los_tres_MTDC = new TH1F("los_time_res_MTDC", "LOS MTDC Time resolution - raw", 4000, -4, 4); + fh_los_tres_MTDC->GetXaxis()->SetTitle("Time MTDC / ns"); + + fh_los_tot[iloscount] = + new TH2F(Form("%s_tot", detName), Form("%s ToT vs PMT", detName), 10, 0, 10, 3000, 0., 300.); + fh_los_tot[iloscount]->GetXaxis()->SetTitle("PMT number"); + fh_los_tot[iloscount]->GetYaxis()->SetTitle("ToT / ns"); + + fh_los_tot_mean[iloscount] = + new TH1F(Form("%s_tot_mean", detName), Form("%s mean ToT", detName), 1500, 0., 300.); + fh_los_tot_mean[iloscount]->GetYaxis()->SetTitle("Counts"); + fh_los_tot_mean[iloscount]->GetXaxis()->SetTitle("ToT / ns"); + + fh_los_ihit_ToT[iloscount] = + new TH2F(Form("%s_tot_ihit", detName), Form("%s ToT vs ihit", detName), 15, 0, 15, 9100, -10., 900.); + fh_los_ihit_ToT[iloscount]->GetXaxis()->SetTitle("iHit"); + fh_los_ihit_ToT[iloscount]->GetYaxis()->SetTitle("ToT / ns"); + + fh_los_dt_hits[iloscount] = + new TH1F(Form("%s_los_dt_hits", detName), Form("%s los dt hits", detName), 100000, 0, 500); + fh_los_dt_hits[iloscount]->GetXaxis()->SetTitle("dt between two hits / micros"); + fh_los_dt_hits[iloscount]->GetYaxis()->SetTitle("Counts"); + + fh_dt_hits[iloscount] = new TH1F(Form("%s_dt_hits", detName), Form("%s dt hits", detName), 2000, 0, 500); + fh_dt_hits[iloscount]->GetXaxis()->SetTitle("dt between two hits / micros"); + fh_dt_hits[iloscount]->GetYaxis()->SetTitle("Counts"); + + fh_los_dt_first_ToT[iloscount] = new TH2F( + Form("%s_dt_events_ToT", detName), Form("%s ToT vs deltat", detName), 5000, 0, 150000, 500, 0, 200.); + fh_los_dt_first_ToT[iloscount]->GetXaxis()->SetTitle("dt between two events / ns"); + fh_los_dt_first_ToT[iloscount]->GetYaxis()->SetTitle("ToT / ns"); + + cLos[iloscount]->Divide(4, 3); + cLos[iloscount]->cd(1); + fh_los_channels[iloscount]->Draw(); + cLos[iloscount]->cd(2); + gPad->SetLogy(); + fh_los_multihit[iloscount]->Draw(); + cLos[iloscount]->cd(3); + gPad->SetLogz(); + fh_los_tot[iloscount]->Draw("colz"); + cLos[iloscount]->cd(4); + gPad->SetLogy(); + fh_los_tot_mean[iloscount]->Draw(); + cLos[iloscount]->cd(5); + gPad->SetLogz(); + fh_los_ihit_ToT[iloscount]->Draw("colz"); + // cLos[iloscount]->cd(6);gPad->SetLogz(); + // fh_los_dt_first_ToT[iloscount]->Draw("colz"); + cLos[iloscount]->cd(6); + gPad->SetLogz(); + fh_los_dt_hits_ToT[iloscount]->Draw("colz"); + cLos[iloscount]->cd(7); + gPad->SetLogz(); + + cLos[iloscount]->cd(8); + gPad->SetLogy(); + fh_los_tres_MCFD[iloscount]->Draw(); + cLos[iloscount]->cd(9); + gPad->SetLogz(); + fh_los_ToT_vs_ToT->Draw("colz"); + cLos[iloscount]->cd(10); + gPad->SetLogz(); + fh_los_pos_ToT[iloscount]->Draw("colz"); + cLos[iloscount]->cd(11); + gPad->SetLogz(); + fh_los_pos_MCFD[iloscount]->Draw("colz"); + cLos[iloscount]->cd(12); + gPad->SetLogz(); + fh_los_pos_TAMEX[iloscount]->Draw("colz"); + cLos[iloscount]->cd(0); + run->AddObject(cLos[iloscount]); + } + + run->GetHttpServer()->RegisterCommand("Reset_LOS", Form("/Tasks/%s/->Reset_LOS_Histo()", GetName())); + } + + //----------------------------------------------------------------------- + + if (fMappedItems.at(DET_BMON)) + { + + fh_TimePreviousEvent = new TH1F("TimePreviousEvent", "Time between 2 particles ", 300000, -3000, 3000); + fh_TimePreviousEvent->GetXaxis()->SetTitle("time / µsec"); + fh_TimePreviousEvent->GetYaxis()->SetTitle("counts"); + + TCanvas* cbmon = new TCanvas("Beam_Monitor", "Beam Monitors", 820, 10, 900, 900); + Int_t Nbin_bmon = reset_time / read_time; + + fhTpat = new TH1F("Tpat", "Tpat", 20, 0, 20); + fhTpat->GetXaxis()->SetTitle("Tpat value"); + + fhTrigger = new TH1F("Trigger", "Trigger all", 20, 0, 20); + fhTrigger->GetXaxis()->SetTitle("Trigger value"); + + fh_spill_length = new TH1F("spill_length", "Spill ", Nbin_bmon, 0, reset_time); + fh_spill_length->GetXaxis()->SetTitle("time / sec"); + + fh_spill_times = new TH1F("CountsPerSpill", "counts per spill ", 120000, 0., 12.); + fh_spill_times->GetXaxis()->SetTitle("time / sec"); + fh_spill_times->GetYaxis()->SetTitle("counts"); + + fh_spill_times_zoom = new TH1F("CountsPerSpill_zoom", "counts per spill ", 50000, 0., 5.); + fh_spill_times_zoom->GetXaxis()->SetTitle("time / sec"); + fh_spill_times_zoom->GetYaxis()->SetTitle("counts"); + + fh_spill_times_pois = new TH1F("CountsPerSpill_pois", "counts per spill poisson", 50000, 0., 5.); + fh_spill_times_pois->GetXaxis()->SetTitle("time / sec"); + fh_spill_times_pois->GetYaxis()->SetTitle("counts"); + // fh_spill_times_pois->SetLineColor(kRed); + + fh_spill_times_daq = new TH1F("CountsPerSpill_daq", "counts per spill daq", 50000, 0., 5.); + fh_spill_times_daq->GetXaxis()->SetTitle("time / sec"); + fh_spill_times_daq->GetYaxis()->SetTitle("counts"); + // fh_spill_times_daq->SetLineColor(kRed); + + fh_spill_times_daq_first = + new TH1F("CountsPerSpill_daq_first", "counts per spill daq first hit only", 50000, 0., 5.); + fh_spill_times_daq_first->GetXaxis()->SetTitle("time / sec"); + fh_spill_times_daq_first->GetYaxis()->SetTitle("counts"); + // fh_spill_times_daq_first->SetLineColor(kRed); + + fh_frequencies = new TH1F("frequencies", "frequencies ", 10000., 0, 5000.); + fh_frequencies->GetXaxis()->SetTitle("frequency / kHz"); + fh_frequencies->GetYaxis()->SetTitle("counts"); + + fh_rate = new TH1F("rate", "accepted events relativ to poisson", 100, 0, 50); + fh_rate->GetXaxis()->SetTitle("spill number"); + fh_rate->GetYaxis()->SetTitle("Percent"); + + fh_TOFDOR = new TH1F("TOFDOR", "TOFDOR ", Nbin_bmon, 0, reset_time); + fh_TOFDOR->GetXaxis()->SetTitle("time / sec"); + fh_TOFDOR->GetYaxis()->SetTitle("TOFDOR counts"); + + fh_particle = new TH1F("particle_per_time", "Particle per time", 100, -50., 50.); + fh_particle->GetXaxis()->SetTitle("particle per time"); + fh_particle->GetYaxis()->SetTitle("counts"); + + fh_particle_pois = new TH1F("particle_per_time_pois", "Particle per time poisson", 100, -50., 50.); + fh_particle_pois->GetXaxis()->SetTitle("particle per time"); + fh_particle_pois->GetYaxis()->SetTitle("counts"); + fh_particle_pois->SetLineColor(kRed); + + fh_TOFDOR_spill = new TH1F("TOFDOR_spill", "TOFDOR rate in kHz ", Nbin_bmon, 0, reset_time); + fh_TOFDOR_spill->GetXaxis()->SetTitle("time / sec"); + fh_TOFDOR_spill->GetYaxis()->SetTitle("TOFDOR rate / kHz"); + + cbmon->Divide(3, 3); + // cbmon->cd(1);gPad->SetLogy(); + // fhTrigger->Draw(); + cbmon->cd(1); + fh_spill_length->Draw(); + + cbmon->cd(2); + gPad->SetLogy(); + fh_dt_hits[0]->Draw(); + + cbmon->cd(3); + gPad->SetLogy(); + fh_los_dt_hits[0]->Draw(); + + // cbmon->cd(4); + // fh_spill_times_daq_first->Draw("hist"); + + // cbmon->cd(5); + // fh_spill_times_daq->Draw("hist"); + + cbmon->cd(4); + fh_spill_times->Draw("hist"); + // fh_spill_times_pois->Draw("same"); + + cbmon->cd(5); + fh_frequencies->Draw("hist"); + gPad->SetLogy(); + + cbmon->cd(6); + gPad->SetLogy(); + fh_particle->Draw("hist"); + fh_particle_pois->Draw("same"); + TLegend* leg_particle = new TLegend(0.7, 0.8, 0.9, 0.9); + leg_particle->AddEntry(fh_particle, "Measured", "l"); + leg_particle->AddEntry(fh_particle_pois, "Poisson", "l"); + leg_particle->Draw("same"); + + cbmon->cd(9); + fh_rate->SetFillColor(3); + fh_rate->GetYaxis()->SetRange(0, 110); + fh_rate->Draw("B"); + + // cbmon->cd(9); + // fh_TOFDOR_spill->Draw("hist"); + + cbmon->cd(0); + + run->AddObject(cbmon); + + run->GetHttpServer()->RegisterCommand("Reset_BMON", Form("/Tasks/%s/->Reset_BMON_Histo()", GetName())); + } + + //----------------------------------------------------------------------- + // Fiber Detectors 1-NOF_FIB_DET + + char canvName[255]; + TCanvas* FibCanvas[NOF_FIB_DET]; + + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + + std::stringstream fibhitobj; + std::stringstream fibmapobj; + std::stringstream FiName; + std::string temp; + + if (fMappedItems.at(DET_FI_FIRST + ifibcount)) + { + + const char* chistName; + const char* chistTitle; + const char* detName; + std::string tempTitle; + std::string tempName; + std::stringstream tempFibName; + std::string tempFibNames; + std::stringstream tempCanvName; + + detName = fDetectorNames[DET_FI_FIRST + ifibcount]; + + cout << "I am creating canvas " << detName << endl; + + FibCanvas[ifibcount] = new TCanvas(detName, detName, 10, 10, 910, 910); + + // Channels: + fh_channels_Fib[ifibcount] = + new TH1F(Form("%s_channels", detName), Form("%s channels", detName), 520, 0., 520.); + fh_channels_Fib[ifibcount]->GetXaxis()->SetTitle("Channel number"); + fh_channels_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Channels: + fh_channels_single_Fib[ifibcount] = + new TH1F(Form("%s_channels_single", detName), Form("%s channels of single PMTs", detName), 10, 0., 10.); + fh_channels_single_Fib[ifibcount]->GetXaxis()->SetTitle("Channel number"); + fh_channels_single_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Fibers: + fh_fibers_Fib[ifibcount] = + new TH1F(Form("%s_fibers", detName), Form("%s fibers", detName), N_FIBER_PLOT, 0., N_FIBER_PLOT); + fh_fibers_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_fibers_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Multiplicity (number of hit fibers): + fh_mult_Fib[ifibcount] = new TH1F(Form("%s_mult", detName), Form("%s mult", detName), 100, 0., 100.); + fh_mult_Fib[ifibcount]->GetXaxis()->SetTitle("Multiplicity"); + fh_mult_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Multihit MAPMT: + fh_multihit_m_Fib[ifibcount] = new TH2F( + Form("%s_multihit_m", detName), Form("%s multihits MAPMT", detName), 520, 0., 520., 20, 0., 20.); + fh_multihit_m_Fib[ifibcount]->GetXaxis()->SetTitle("MAPMT channel"); + fh_multihit_m_Fib[ifibcount]->GetYaxis()->SetTitle("Multihit"); + + // Multihit SAPMT: + fh_multihit_s_Fib[ifibcount] = new TH2F( + Form("%s_multihit_s", detName), Form("%s multihits single PMT", detName), 16, 0., 16., 20, 0., 20.); + fh_multihit_s_Fib[ifibcount]->GetXaxis()->SetTitle("Single PMT channel"); + fh_multihit_s_Fib[ifibcount]->GetYaxis()->SetTitle("Multihit"); + + // ToT MAPMT: + fh_ToT_m_Fib[ifibcount] = new TH2F(Form("%s_tot_m", detName), + Form("%s ToT of MAPMT", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 100, + 0., + 41.666667); + fh_ToT_m_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_ToT_m_Fib[ifibcount]->GetYaxis()->SetTitle("ToT / ns"); + + // ToT SAPMT: + fh_ToT_s_Fib[ifibcount] = new TH2F(Form("%s_tot_s", detName), + Form("%s ToT of single PMT", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 2000, + 0., + 200.); + fh_ToT_s_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_ToT_s_Fib[ifibcount]->GetYaxis()->SetTitle("ToT / ns"); + + // Time of fiber: + fh_time_Fib[ifibcount] = new TH2F(Form("%s_TimevsFiber", detName), + Form("%s Time vs Fiber", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 2048, + -1024., + 1024.); + fh_time_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_time_Fib[ifibcount]->GetYaxis()->SetTitle("tMAPMT-tSPMT"); + + // ToF LOS -> Fiber: + fh_Fib_ToF[ifibcount] = new TH2F(Form("%s_tof", detName), + Form("%s ToF LOS to Fiber", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 1200, + -6000., + 6000.); + fh_Fib_ToF[ifibcount]->GetYaxis()->SetTitle("ToF / ns"); + fh_Fib_ToF[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + + // Not-calibrated position: + fh_Fib_pos_xy[ifibcount] = + new TH2F(Form("%s_pos", detName), Form("%s xy position", detName), 500, 0., 500, 1200, -600., 600.); + fh_Fib_pos_xy[ifibcount]->GetXaxis()->SetTitle("x position (fiber)"); + fh_Fib_pos_xy[ifibcount]->GetYaxis()->SetTitle("y position (dt)"); + + // hit fiber number vs. event number: + fh_Fib_vs_Events[ifibcount] = new TH2F(Form("%s_fib_vs_event", detName), + Form("%s Fiber # vs. Event #", detName), + 1000, + 0, + 5e6, + 1100, + 0., + 1100.); + fh_Fib_vs_Events[ifibcount]->GetYaxis()->SetTitle("Fiber number"); + fh_Fib_vs_Events[ifibcount]->GetXaxis()->SetTitle("Event number"); + + // ToT SAPMT: + fh_ToT_single_Fib[ifibcount] = new TH2F( + Form("%s_tot_single", detName), Form("%s ToT of single PMTs", detName), 10, 0., 10., 200, 0., 20.); + fh_ToT_single_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_ToT_single_Fib[ifibcount]->GetYaxis()->SetTitle("ToT / ns"); + + FibCanvas[ifibcount]->Divide(3, 4); + FibCanvas[ifibcount]->cd(1); + fh_channels_Fib[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(2); + gPad->SetLogz(); + fh_multihit_m_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(3); + gPad->SetLogz(); + fh_multihit_s_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(4); + fh_fibers_Fib[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(5); + fh_mult_Fib[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(6); + gPad->SetLogz(); + fh_ToT_m_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(7); + gPad->SetLogz(); + fh_ToT_s_Fib[ifibcount]->Draw("colz"); + // FibCanvas[ifibcount]->cd(8);gPad->SetLogz(); + // fh_time_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(8); + gPad->SetLogz(); + fh_Fib_ToF[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(9); + fh_Fib_pos_xy[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(10); + fh_Fib_vs_Events[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(11); + fh_ToT_single_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(12); + fh_channels_single_Fib[ifibcount]->Draw(); + + FibCanvas[ifibcount]->cd(0); + run->AddObject(FibCanvas[ifibcount]); + + } // end if(Mapped) + + } // end for(ifibcount) + if (NOF_FIB_DET > 0) + run->GetHttpServer()->RegisterCommand("Reset_Fibers", Form("/Tasks/%s/->Reset_FIBERS_Histo()", GetName())); + + //--------------------------------------------------------------------------------------- + // Ptof detector + + if (fCalItems.at(DET_PTOF)) + { + + TCanvas* cPtof_plane = new TCanvas("Ptof_plane", "Ptof plane", 10, 10, 510, 510); + cPtof_plane->Divide(1, 2); + + fh_ptof_channels = new TH1F("Ptof_channels", "Ptof channels", 65, 0., 65.); + cPtof_plane->cd(1); + fh_ptof_channels->Draw(); + + fh_ptof_channels_cut = new TH1F("Ptof_channels_cut", "Ptof channels with cut", 65, 0., 65.); + cPtof_plane->cd(2); + fh_ptof_channels_cut->Draw(); + run->AddObject(cPtof_plane); + + TCanvas* cPtof_test = new TCanvas("Ptof_test", "Ptof test", 10, 10, 510, 510); + cPtof_test->Divide(1, 1); + + fh_ptof_test1 = new TH1F("Ptof_test1", "Ptof test1", 1000, 0., 100.); + fh_ptof_test2 = new TH1F("Ptof_test2", "Ptof test2", 1000, 0., 100.); + cPtof_test->cd(1); + fh_ptof_test1->Draw(); + // cPtof_test->cd(2); + // fh_ptof_test2->Draw(); + + run->AddObject(cPtof_test); + + TCanvas* cPtof1; + cPtof1 = new TCanvas("Ptof1", "Ptof1", 10, 10, 500, 500); + cPtof1->Divide(3, 3); + for (Int_t j = 1; j < 10; j++) + { + char strName[255]; + sprintf(strName, "ToT_Bar_%d_PM_1", j); + fh_ptof_TotPm1[j] = new TH1F(strName, "", 1000, 0., 100.); + cPtof1->cd(j); + fh_ptof_TotPm1[j]->Draw(); + } + run->AddObject(cPtof1); + + TCanvas* cPtof2; + cPtof2 = new TCanvas("Ptof2", "Ptof2", 10, 10, 500, 500); + cPtof2->Divide(3, 3); + for (Int_t j = 1; j < 10; j++) + { + char strName[255]; + sprintf(strName, "ToT_Bar_%d_PM_2", j); + fh_ptof_TotPm2[j] = new TH1F(strName, "", 1000, 0., 100.); + cPtof2->cd(j); + fh_ptof_TotPm2[j]->Draw(); + } + run->AddObject(cPtof2); + } + + //--------------------------------------------------------------------------------------------------- + // TofD detector + + if (fMappedItems.at(DET_TOFD)) + { + TCanvas* cTofd_planes = new TCanvas("TOFD_planes", "TOFD planes", 10, 10, 1100, 1000); + cTofd_planes->Divide(5, 4); + + for (Int_t j = 0; j < 4; j++) + { + char strName1[255]; + sprintf(strName1, "tofd_channels_plane_%d", j + 1); + char strName2[255]; + sprintf(strName2, "Tofd channels plane %d", j + 1); + fh_tofd_channels[j] = new TH1F(strName1, strName2, 90, -45., 45.); + fh_tofd_channels[j]->GetXaxis()->SetTitle("Channel"); + fh_tofd_channels[j]->GetYaxis()->SetTitle("Counts"); + + char strName3[255]; + sprintf(strName3, "tofd_ToT_plane_%d", j + 1); + char strName4[255]; + sprintf(strName4, "Tofd ToT plane %d", j + 1); + fh_tofd_TotPm[j] = new TH2F(strName3, strName4, 90, -45, 45, 3000, 0., 300.); + fh_tofd_TotPm[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_TotPm[j]->GetYaxis()->SetTitle("ToT / ns"); + + char strName7[255]; + sprintf(strName7, "tofd_ToF_plane_%d", j + 1); + char strName8[255]; + sprintf(strName8, "TOFD-LOS ToF plane %d", j + 1); + fh_tofd_ToF[j] = new TH2F(strName7, strName8, 15, 0, 15, 1000, 0, 100); + fh_tofd_ToF[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_ToF[j]->GetYaxis()->SetTitle("ToF / ns"); + + char strName9[255]; + sprintf(strName9, "tofd_multihit_plane_%d", j + 1); + char strName10[255]; + sprintf(strName10, "Tofd multihit plane %d", j + 1); + fh_tofd_multihit[j] = new TH2F(strName9, strName10, 45, 0., 45., 10, 0, 10); + fh_tofd_multihit[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_multihit[j]->GetYaxis()->SetTitle("Multihit"); + + if (j < 3) + { + int jk = j + 1; + char strName5[255]; + sprintf(strName5, "tofd_ToF_plane_%d_%d", jk, jk + 1); + char strName6[255]; + sprintf(strName6, "Tofd ToF plane %d and %d ", jk, jk + 1); + fh_tofd_dt[j] = new TH2F(strName5, strName6, 50, 0, 50, 800, -40., 40); + fh_tofd_dt[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_dt[j]->GetYaxis()->SetTitle("dt / ns"); + } + } + + cTofd_planes->cd(1); + fh_tofd_channels[0]->Draw(); + cTofd_planes->cd(2); + gPad->SetLogz(); + fh_tofd_TotPm[0]->Draw("colz"); + cTofd_planes->cd(3); + gPad->SetLogz(); + fh_tofd_ToF[0]->Draw("colz"); + cTofd_planes->cd(4); + gPad->SetLogz(); + fh_tofd_multihit[0]->Draw("colz"); + + cTofd_planes->cd(6); + fh_tofd_channels[1]->Draw(); + cTofd_planes->cd(7); + gPad->SetLogz(); + fh_tofd_TotPm[1]->Draw("colz"); + cTofd_planes->cd(8); + gPad->SetLogz(); + fh_tofd_ToF[1]->Draw("colz"); + cTofd_planes->cd(9); + gPad->SetLogz(); + fh_tofd_multihit[1]->Draw("colz"); + cTofd_planes->cd(10); + gPad->SetLogz(); + fh_tofd_dt[0]->Draw("colz"); + + cTofd_planes->cd(11); + fh_tofd_channels[2]->Draw(); + cTofd_planes->cd(12); + gPad->SetLogz(); + fh_tofd_TotPm[2]->Draw("colz"); + cTofd_planes->cd(13); + gPad->SetLogz(); + fh_tofd_ToF[2]->Draw("colz"); + cTofd_planes->cd(14); + gPad->SetLogz(); + fh_tofd_multihit[2]->Draw("colz"); + cTofd_planes->cd(15); + gPad->SetLogz(); + fh_tofd_dt[1]->Draw("colz"); + + cTofd_planes->cd(16); + fh_tofd_channels[3]->Draw(); + cTofd_planes->cd(17); + gPad->SetLogz(); + fh_tofd_TotPm[3]->Draw("colz"); + cTofd_planes->cd(18); + gPad->SetLogz(); + fh_tofd_ToF[3]->Draw("colz"); + cTofd_planes->cd(19); + gPad->SetLogz(); + fh_tofd_multihit[3]->Draw("colz"); + cTofd_planes->cd(20); + gPad->SetLogz(); + fh_tofd_dt[2]->Draw("colz"); + + cTofd_planes->cd(0); + run->AddObject(cTofd_planes); + + run->GetHttpServer()->RegisterCommand("Reset_TOFD", Form("/Tasks/%s/->Reset_TOFD_Histo()", GetName())); + } + + // ------------------------------------------------------------------------- + + //------------------------------------------------------------------------ + // PSPX detector + // get access to data + if (fMappedItems.at(DET_PSPX) || fCalItems.at(DET_PSPX) || fHitItems.at(DET_PSPX)) + { + TCanvas* cPspx_comp = new TCanvas("Pspx_comp", "Pspx Comparison", 10, 10, 1100, 1000); + cPspx_comp->Divide(N_PSPX, 3); + + Int_t Emax = 1000000; + + if (fMappedItems.at(DET_PSPX)) + { + // LOG(INFO) << "Init MappedPspx"; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + if (i % 2 == 0) + { // even numbers = read out with energy filter + fh_pspx_channel_x[i] = + new TH1F(Form("pspx_%d_energyreadout_channel_x", i / 2), + Form("Pspx %d Energy Readout: x Channel;x Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 1, + 2 * N_STRIPS_PSPX + 1); + fh_pspx_channel_y[i] = + new TH1F(Form("pspx_%d_energyreadout_channel_y", i / 2), + Form("Pspx %d Energy Readout: y Channel;y Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 2 * N_STRIPS_PSPX + 1, + 4 * N_STRIPS_PSPX + 1); + + fh_pspx_multiplicity_x[i] = + new TH1F(Form("pspx_%d_energyreadout_multiplicity_x", i / 2), + Form("Pspx %d Energy Readout: x Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_multiplicity_y[i] = + new TH1F(Form("pspx_%d_energyreadout_multiplicity_y", i / 2), + Form("Pspx %d Energy Readout: y Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_strips_position[i] = new TH2F( + Form("pspx_%d_energyreadout_strips", i), + Form("Pspx %d Energy Readout Position;x Position / Strips; y Position / Strips", i / 2 + 1), + N_STRIPS_PSPX, + 1, + N_STRIPS_PSPX + 1, + N_STRIPS_PSPX, + N_STRIPS_PSPX + 1, + 2 * N_STRIPS_PSPX + 1); + } + else + { // odd numbers = read out with position filter + fh_pspx_channel_x[i] = + new TH1F(Form("pspx_%d_positionreadout_channel_x", i / 2), + Form("Pspx %d Position Readout: x Channel;x Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 1, + 2 * N_STRIPS_PSPX + 1); + fh_pspx_channel_y[i] = + new TH1F(Form("pspx_%d_positionreadout_channel_y", i / 2), + Form("Pspx %d Position Readout: y Channel;y Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 2 * N_STRIPS_PSPX + 1, + 4 * N_STRIPS_PSPX + 1); + + fh_pspx_multiplicity_x[i] = + new TH1F(Form("pspx_%d_positionreadout_multiplicity_x", i / 2), + Form("Pspx %d Position Readout: x Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_multiplicity_y[i] = + new TH1F(Form("pspx_%d_positionreadout_multiplicity_y", i / 2), + Form("Pspx %d Position Readout: y Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_strips_position[i] = new TH2F( + Form("pspx_%d_positionreadout_strips", i), + Form("Pspx %d Position Readout Position;x Position / Strips; y Position / Strips", i / 2 + 1), + N_STRIPS_PSPX, + 1, + N_STRIPS_PSPX + 1, + N_STRIPS_PSPX, + N_STRIPS_PSPX + 1, + 2 * N_STRIPS_PSPX + 1); + } + } + + TCanvas* cPspx_strips = new TCanvas("Pspx_strips", "Pspx Strips", 10, 10, 1100, 1000); + cPspx_strips->Divide(N_PSPX, 2); + + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_strips->cd(i + 1); + fh_pspx_channel_x[i]->Draw(); + + cPspx_strips->cd(i + 1 + N_PSPX); + fh_pspx_channel_y[i]->Draw(); + } + + run->AddObject(cPspx_strips); + + TCanvas* cPspx_multiplicity = new TCanvas("Pspx_multiplicity", "Pspx Multiplicity", 10, 10, 1100, 1000); + cPspx_multiplicity->Divide(N_PSPX, 2); + + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_multiplicity->cd(i + 1); + fh_pspx_multiplicity_x[i]->Draw(); + + cPspx_multiplicity->cd(i + 1 + N_PSPX); + fh_pspx_multiplicity_y[i]->Draw(); + } + + run->AddObject(cPspx_multiplicity); + + // Fill cPspx_comp with Mapped level data + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_comp->cd(i + 1); + fh_pspx_strips_position[i]->Draw("colz"); + + // Remove the current axis + fh_pspx_strips_position[i]->GetYaxis()->SetLabelOffset(999); + fh_pspx_strips_position[i]->GetYaxis()->SetTickLength(0); + + // Redraw the new inverted axis + gPad->Update(); + TGaxis* newaxis = new TGaxis(gPad->GetUxmin(), + gPad->GetUymax(), + gPad->GetUxmin() - 0.001, + gPad->GetUymin(), + fh_pspx_strips_position[i]->GetYaxis()->GetXmin(), + fh_pspx_strips_position[i]->GetYaxis()->GetXmax(), + 510, + "+"); + newaxis->SetLabelOffset(0.003); + newaxis->SetLabelSize(0.03); + newaxis->SetTickLength(0.025); + newaxis->Draw(); + } + } + + if (fCalItems.at(DET_PSPX)) + { + UInt_t nbins = 200; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + if (i % 2 == 0) + { + fh_pspx_cal_energy_frontback[i] = new TH2F( + Form("pspx_%d_energy_frontback", i / 2), + Form("Pspx %d Energy Back vs Front;Front Energy / arb.u.;Back Energy / arb.u.", i / 2 + 1), + nbins, + 0, + Emax, + nbins, + -Emax, + 0); + } + else + { + fh_pspx_cal_energy_frontback[i] = new TH2F( + Form("pspx_%d_position_frontback", i / 2), + Form("Pspx %d Energy Back vs Front;Front Energy / arb.u.;Back Energy / arb.u.", i / 2 + 1), + nbins, + 0, + Emax / 4, + nbins, + -Emax / 4, + 0); + } + } + + /*fh_pspx_cal_energy_corr[i] = + new TH2F("pspx_%d_energy_corr", + "Pspx %d Energy PSP2 vs. PSP3;PSP2 Energy / arb.u.;PSP3 Energy / arb.u.", + nbins, + 0, + Emax, + nbins, + 0, + Emax); + */ + + // Fill cPspx_comp with Cal level data + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_comp->cd(i + 1 + N_PSPX); // i*2 + fh_pspx_cal_energy_frontback[i]->Draw("colz"); + } + } + + if (fHitItems.at(DET_PSPX)) + { + UInt_t nbins = 100; + Double_t length = 10; // detector length, range of histogram + + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + fh_pspx_hit_position[i] = new TH2F(Form("pspx_%d_position_cm", i), + Form("Pspx %d Position;x Position / cm; y Position / cm", i + 1), + nbins, + -length / 4., + length / 4., + nbins, + -length / 4., + length / 4.); + + fh_pspx_hit_energy[i] = new TH1F(Form("pspx_%d_energy", i), + Form("Pspx %d Energy;Energy / arb.u.; Counts", i + 1), + nbins, + -Emax, + Emax); + } + + TCanvas* cPspx_hit = new TCanvas("Pspx_hit", "Pspx Hit", 10, 10, 1100, 1000); + cPspx_hit->Divide((N_PSPX + 1) / 2, 2); + + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + cPspx_hit->cd(i + 1); + fh_pspx_hit_position[i]->Draw("colz"); + + cPspx_hit->cd(i + 1 + (N_PSPX + 1) / 2); + fh_pspx_hit_energy[i]->Draw(); + } + + run->AddObject(cPspx_hit); + + // Fill cPspx_comp with Hit level data-((channel_y[i][0] + 1) / 2) + 3 * N_STRIPS_PSPX + 1) + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + cPspx_comp->cd(i * 2 + 2 * N_PSPX + 1); // supposed to be +2 if + // energy and position + // readout is used + fh_pspx_hit_position[i]->Draw("colz"); + } + } + + run->AddObject(cPspx_comp); + + run->GetHttpServer()->RegisterCommand("Reset_PSPX", Form("/Tasks/%s/->Reset_PSPX_Histo()", GetName())); + } + // ------------------------------------------------------------------------- + + return kSUCCESS; +} + +void R3BOnlineSpectraDec2019::Reset_LOS_Histo() +{ + if (fMappedItems.at(DET_LOS)) + { + for (Int_t iloscount = 0; iloscount < fNofLosDetectors; iloscount++) + { + fh_los_channels[iloscount]->Reset(); + fh_los_tres_MCFD[iloscount]->Reset(); + fh_los_tres_TAMEX[iloscount]->Reset(); + fh_los_pos_ToT[iloscount]->Reset(); + fh_los_tot[iloscount]->Reset(); + fh_los_tot_mean[iloscount]->Reset(); + fh_los_pos_MCFD[iloscount]->Reset(); + fh_los_pos_TAMEX[iloscount]->Reset(); + fh_los_multihit[iloscount]->Reset(); + fh_los_ihit_ToT[iloscount]->Reset(); + } + if (fNofLosDetectors == 2) + fh_los_ToT_vs_ToT->Reset(); + } +} + +void R3BOnlineSpectraDec2019::Reset_ROLU_Histo() +{ + fh_rolu_channels->Reset(); + fh_rolu_tot->Reset(); +} + +void R3BOnlineSpectraDec2019::Reset_BMON_Histo() +{ + fhTrigger->Reset(); + fhTpat->Reset(); + fh_spill_length->Reset(); + fh_spill_times->Reset(); + fh_spill_times_pois->Reset(); + fh_spill_times_daq->Reset(); + fh_spill_times_daq_first->Reset(); + fh_rate->Reset(); + fh_particle->Reset(); + fh_particle_pois->Reset(); + fh_frequencies->Reset(); + fh_TOFDOR->Reset(); + fh_TOFDOR_spill->Reset(); + for (Int_t iloscount = 0; iloscount < fNofLosDetectors; iloscount++) + { + fh_los_dt_hits[iloscount]->Reset(); + fh_dt_hits[iloscount]->Reset(); + } +} + +void R3BOnlineSpectraDec2019::Reset_SCI8_Histo() +{ + fh_sci8_channels->Reset(); + fh_sci8_tres_MCFD->Reset(); + fh_sci8_tres_TAMEX->Reset(); + fh_sci8_tot->Reset(); + fh_sci8_tot_mean->Reset(); + fh_sci8_dt_hits->Reset(); + fh_sci8_dt_hits_l->Reset(); + fh_sci8_dt_hits_t->Reset(); + fh_sci8_multihit->Reset(); + fh_sci8_multihitVFTX->Reset(); + fh_sci8_multihitLEAD->Reset(); + fh_sci8_multihitTRAI->Reset(); + fh_tof_sci8->Reset(); +} +void R3BOnlineSpectraDec2019::Reset_TOFD_Histo() +{ + for (int i = 0; i < N_PLANE_MAX_TOFD; i++) + { + fh_tofd_channels[i]->Reset(); + fh_tofd_multihit[i]->Reset(); + fh_tofd_ToF[i]->Reset(); + fh_tofd_TotPm[i]->Reset(); + } + fh_tofd_dt[0]->Reset(); + fh_tofd_dt[1]->Reset(); + fh_tofd_dt[2]->Reset(); +} +void R3BOnlineSpectraDec2019::Reset_FIBERS_Histo() +{ + if (fMappedItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_channel_x[i]->Reset(); + fh_pspx_channel_y[i]->Reset(); + fh_pspx_multiplicity_x[i]->Reset(); + fh_pspx_multiplicity_y[i]->Reset(); + fh_pspx_strips_position[i]->Reset(); + } + } + if (fCalItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_cal_energy_frontback[i]->Reset(); + } + } + if (fHitItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX / 2; i++) + { + fh_pspx_hit_position[i]->Reset(); + fh_pspx_hit_energy[i]->Reset(); + } + } + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + if (fMappedItems.at(DET_FI_FIRST + ifibcount)) + { + fh_channels_Fib[ifibcount]->Reset(); + fh_multihit_m_Fib[ifibcount]->Reset(); + fh_multihit_s_Fib[ifibcount]->Reset(); + fh_fibers_Fib[ifibcount]->Reset(); + fh_mult_Fib[ifibcount]->Reset(); + fh_ToT_m_Fib[ifibcount]->Reset(); + fh_ToT_s_Fib[ifibcount]->Reset(); + fh_ToT_single_Fib[ifibcount]->Reset(); + fh_Fib_ToF[ifibcount]->Reset(); + fh_Fib_pos_xy[ifibcount]->Reset(); + fh_Fib_vs_Events[ifibcount]->Reset(); + fh_channels_single_Fib[ifibcount]->Reset(); + } + } +} + +void R3BOnlineSpectraDec2019::Exec(Option_t* option) +{ + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + { + // FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, "FairRootManager not found"); + LOG(ERROR) << "FairRootManager not found"; + return; + } + // cout<<"next event"<GetTimeStamp(); // /1.6; // divided by 1.6 for stand alone daq with Vulom generating time stamps + if (time_begin == 0) + time_begin = time; + time -= time_begin; + + if (time_start == 0 && time > 0) + { + time_start = time; + fNEvents_start = fNEvents; + } + + if (header->GetTrigger() == 12) + { + spill_on = true; + spill_on_sampler = true; + } + + if (fMappedItems.at(DET_SAMPLER)) + { + // cout << "Samples:\n"; + auto det = fMappedItems.at(DET_SAMPLER); + Int_t nHitsSamp = det->GetEntriesFast(); + for (Int_t ihit = 0; ihit < nHitsSamp; ihit++) + { + auto hit = (R3BSamplerMappedData*)det->At(ihit); + // time is in steps of 10 ns + // is is a 34 bit number, so max 1073741823 + samplerCurr = hit->GetTime(); + if (samplerBegin == 0) + samplerBegin = samplerCurr; + samplerCurr -= samplerBegin; + + // cout<<"Time - Sampler: "< fSpillLength && spillCounter > 0) + { + cout << "Missed spill end!" << endl; + cout << samplerCurr << " " << samplerPrev << " " << samplerSpill << " " << (double)samp / 1e8 + << '\n'; + } + + fh_spill_times->Fill((double)samp / 1.e8); + + Double_t dt = ((double)(samplerCurr - samplerPrev)) / 100.; + + // cout << "sampler times: " << samplerCurr << " " << samplerPrev << " " << dt << endl; + + fh_dt_hits[0]->Fill(dt); + fh_frequencies->Fill(1. / dt * 1.E3); + // cout <<"freq " << 1./dt*1.E3 << endl; + samplerPrev = samplerCurr; + } + } + + if (spill_on && time > 0) + { + time_spill_start = time; // spill start in nsec + cout << "Spill start: " << time_spill_start << " " << endl; + spill_on = false; + spillCounter++; + } + + if (header->GetTrigger() == 13) + spill_off = true; + + if (spill_off) + { + time_spill_end = time; // spill end in nsec + cout << "Spill stop: " << time_spill_end << " " << endl; + spill_off = false; + + Int_t pps = fh_spill_times->Integral(1, fh_spill_times->GetSize() - 2); + Int_t pps_daq = fh_spill_times_daq->Integral(1, fh_spill_times_daq->GetSize() - 2); + Int_t pps_daq_first = fh_spill_times_daq_first->Integral(1, fh_spill_times_daq_first->GetSize() - 2); + if (time_spill_start > 0 && pps > 0 && spillCounter > 0) + { + + cout << "pps: " << pps << " " << pps_daq << " " << pps_daq_first << endl; + + Double_t norm = (double)pps * 100.E-6 / fSpillLength; // expected particle per channel + + // calculate the accepted trigger + Double_t a = pps * fDAQ_dead_time / (fSpillLength * 1e6); + Double_t R_Poisson = (1 - exp(-a)) / a; // ratio of accepted trigger relativ to incoming particle + + Double_t accepted = + ((double)pps / fSpillLength) / (1 + ((double)pps / fSpillLength) * fDAQ_dead_time * 1.e-6); + + cout << "Ratio pois: " << R_Poisson << " " << accepted / (double)pps * fSpillLength << " " + << (double)pps_daq_first / (double)pps << " " << (double)pps_daq / (double)pps << endl; + + cout << "value " << (double)pps_daq_first / accepted / fSpillLength * 100. << endl; + fh_rate->Fill(spillCounter, (double)pps_daq_first / accepted / fSpillLength * 100.); + + // now make histogram for random distribution + for (Int_t i = 1; i < pps; i++) + { + Double_t num = (std::rand() / (float)RAND_MAX * fSpillLength); + fh_spill_times_pois->Fill(num); + } + + for (Int_t i = 1; i < fh_spill_times->GetSize() - 2; i++) + { + Int_t counts = fh_spill_times->GetBinContent(i); + Int_t counts_pois = fh_spill_times_pois->GetBinContent(i); + + if (fh_spill_times->GetBinCenter(i) < fSpillLength && counts > 0) + fh_particle->Fill((double)counts - norm); + if (fh_spill_times->GetBinCenter(i) < fSpillLength && counts_pois > 0) + fh_particle_pois->Fill((double)counts_pois - norm); + + // cout<<"Exp : " << i << " counts " << counts << " norm " << norm << " value " << (double)counts - norm + // <Reset(); + fh_spill_times_pois->Reset(); + fh_spill_times_daq->Reset(); + fh_spill_times_daq_first->Reset(); + } + + Bool_t spectra_clear = false; + Double_t xtime = double(time - time_start) / 1.e9; + // for reseting spectra + Int_t icount = iclear_count * reset_time; // reset after reset_time (sec) + if (time_clear < 0. && int(xtime) % icount == 0 && xtime > 1.) + { + time_clear = xtime; + spectra_clear = true; + } + + // cout<<"Trigger: "<GetTrigger()<Fill(header->GetTrigger()); + } + + // check for requested trigger (Todo: should be done globablly / somewhere else) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + + if (fMappedItems.at(DET_BMON)) + { + Int_t tpatbin; + for (int i = 0; i < 16; i++) + { + tpatbin = (header->GetTpat() & (1 << i)); + if (tpatbin != 0) + fhTpat->Fill(i + 1); + } + } + + // fTpat = 1-16; fTpat_bit = 0-15 + Int_t fTpat_bit = fTpat - 1; + Int_t itpat; + Int_t tpatvalue; + if (fTpat_bit >= 0) + { + itpat = header->GetTpat(); + tpatvalue = (itpat && (1 << fTpat_bit)) >> fTpat_bit; + if ((tpatvalue == 0)) + return; + } + + if (fMappedItems.at(DET_BMON)) + { + unsigned long IC; + unsigned long SEETRAM, SEETRAM_raw; + unsigned long TOFDOR; + + Bool_t bmon_read = false; + + auto det = fMappedItems.at(DET_BMON); + Int_t nHitsbm = det->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHitsbm; ihit++) + { + R3BBeamMonitorMappedData* hit = (R3BBeamMonitorMappedData*)det->At(ihit); + if (!hit) + continue; + + IC = hit->GetIC(); // negative values if offset not high enough + SEETRAM_raw = hit->GetSEETRAM(); // raw counts + TOFDOR = hit->GetTOFDOR(); // only positive values possible + SEETRAM = SEETRAM_raw * calib_SEE; // calibrated SEETRAM counts + + if (fNEvents == fNEvents_start) + { + see_mem = SEETRAM; + ic_mem = IC; + tofdor_mem = TOFDOR; + time_mem = time_start; + see_start = SEETRAM; + ic_start = IC; + tofdor_start = TOFDOR; + time_prev_read = time_start; + } + + if (time > 0) + { + + // cout<Fill((time - time_mem) / 1e9); + + // Spectra below are filled every read_time (secs) + if (time_to_read == 0 && (time - time_prev_read) >= read_time * 1000000000) + { + time_to_read = time; + bmon_read = true; + } + + if (bmon_read) + { + + tdiff = double(time - time_mem) / 1.e9; + fNorm = 1.e-3 / (double(time - time_prev_read) / 1.e9); // kHz + + // TOFDOR: + Int_t yTOFDOR = TOFDOR - tofdor_start; + fh_TOFDOR->Fill(tdiff, yTOFDOR); + fh_TOFDOR_spill->Fill(tdiff, (TOFDOR - tofdor_mem) * fNorm); + tofdor_mem = TOFDOR; + + time_to_read = 0; + time_prev_read = time; + bmon_read = false; + } + + if (spectra_clear) + { + fh_spill_length->Reset(); + fh_TOFDOR_spill->Reset("ICESM"); + fh_frequencies->Reset("ICESM"); + fh_TOFDOR->Reset("ICESM"); + time_mem = time; + time_clear = -1.; + iclear_count = iclear_count + 1; + spectra_clear = false; + see_start = SEETRAM; + ic_start = IC; + tofdor_start = TOFDOR; + } + } + } + } + + // ************** ROLU ************************************* + + if (fMappedItems.at(DET_ROLU)) + { + auto det = fMappedItems.at(DET_ROLU); + Int_t nHits = det->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BRoluMappedData* hit = (R3BRoluMappedData*)det->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iDet = hit->GetDetector(); // 1.. + Int_t iCha = hit->GetChannel(); // 1.. + + if (iDet < 2) + fh_rolu_channels->Fill(iCha); // ROLU 1 + if (iDet > 1) + fh_rolu_channels->Fill(iCha + 4); // ROLU 2 + } + } + + Int_t nParts; + if (fCalItems.at(DET_ROLU)) + { + + auto det = fCalItems.at(DET_ROLU); + nParts = det->GetEntriesFast(); + + if (nParts < 1) + return; + + Int_t iDet = 0; + Double_t timeRolu_L[nParts][2][4] = { 0.0 / 0.0 }; + Double_t timeRolu_T[nParts][2][4] = { 0.0 / 0.0 }; + Double_t totRolu[nParts][2][4] = { 0.0 / 0.0 }; + + for (Int_t iPart = 0; iPart < nParts; iPart++) + { + /* + * nParts is the number of particle passing through detector in one event + */ + R3BRoluCalData* calData = (R3BRoluCalData*)det->At(iPart); + iDet = calData->GetDetector(); + + for (Int_t iCha = 0; iCha < 4; iCha++) + { + + if (!(IS_NAN(calData->GetTimeL_ns(iCha)))) + { // TAMEX leading + timeRolu_L[iPart][iDet - 1][iCha] = calData->GetTimeL_ns(iCha); + } + if (!(IS_NAN(calData->GetTimeT_ns(iCha)))) + { // TAMEX trailing + timeRolu_T[iPart][iDet - 1][iCha] = calData->GetTimeT_ns(iCha); + } + + // cout<<"ROLU: "< 0. && timeRolu_L[iPart][iDet - 1][iCha] > 0. && + !(IS_NAN(timeRolu_T[iPart][iDet - 1][iCha])) && !(IS_NAN(timeRolu_L[iPart][iDet - 1][iCha]))) + { + while (timeRolu_T[iPart][iDet - 1][iCha] - timeRolu_L[iPart][iDet - 1][iCha] <= 0.) + { + timeRolu_T[iPart][iDet - 1][iCha] = timeRolu_T[iPart][iDet - 1][iCha] + 2048. * fClockFreq; + } + + totRolu[iPart][iDet - 1][iCha] = + timeRolu_T[iPart][iDet - 1][iCha] - timeRolu_L[iPart][iDet - 1][iCha]; + } + + if (iDet < 2) + fh_rolu_tot->Fill(iCha + 1, totRolu[iPart][iDet - 1][iCha]); + if (iDet > 1) + fh_rolu_tot->Fill(iCha + 5, totRolu[iPart][iDet - 1][iCha]); + } + + if (!calData) + { + cout << "Rolu !calData" << endl; + continue; // can this happen? + } + } + } + + //---------------------------------------------------------------------- + // LOS detector + //---------------------------------------------------------------------- + // Time nomenclature for LOS: + // lt=0, l=1,lb=2,b=3,rb=4,r=5,rt=6,t=7 + // t / \lt + // rt| |l + // r | |lb + // rb\ /b + + Double_t timeTofd = 0; + Double_t time_V[fNofLosDetectors][32][8] = { 0.0 / 0.0 }; // [det][multihit][pm] + Double_t time_L[fNofLosDetectors][32][8] = { 0.0 / 0.0 }; + Double_t time_T[fNofLosDetectors][32][8] = { 0.0 / 0.0 }; + + Double_t time_MTDC[32][8] = { 0.0 / 0.0 }; + Double_t LosTresMTDC[32] = { 0.0 / 0.0 }; + + Double_t timeLosV[fNofLosDetectors][32] = { 0.0 }; + Double_t LosTresV[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t timeLosT[fNofLosDetectors][32] = { 0.0 }; + Double_t LosTresT[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t timeLos[fNofLosDetectors][32] = { 0.0 }; + Double_t totsum[fNofLosDetectors][32] = { 0.0 }; + Double_t tot[fNofLosDetectors][32][8] = { 0.0 / 0.0 }; + Double_t xT_cm[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t yT_cm[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t xToT_cm[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t yToT_cm[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t xV_cm[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t yV_cm[fNofLosDetectors][32] = { 0.0 / 0.0 }; + Double_t time_V_temp[32][8] = { 0.0 / 0.0 }; + + Int_t Multip; + + if (fMappedItems.at(DET_LOS)) + { + auto det = fMappedItems.at(DET_LOS); + Int_t nHits = det->GetEntriesFast(); + + Multip = nHits; + // cout<<"LOS: nHits"<At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iDet = hit->GetDetector(); // 1.. + Int_t iCha = hit->GetChannel(); // 1.. + Int_t iTyp = hit->GetType(); // 0,1,2,3 + + // cout<<"LOS mapped: "<Fill(iCha); // exclude MTDC data + } + } + + Int_t nPart; + Int_t nPartLos[fNofLosDetectors] = { 0 }; + + if (fCalItems.at(DET_LOS)) + { + Bool_t LOSID = false; + + auto det = fCalItems.at(DET_LOS); + nPart = det->GetEntriesFast(); + + Int_t iDet = 0; + Double_t time_V_LOS1[32][8] = { 0. }; + Double_t time_V_LOS2[32][8] = { 0. }; + + for (Int_t iPart = 0; iPart < nPart; iPart++) + { + /* + * nPart is the number of particle passing through LOS detector in one event + */ + R3BLosCalData* calData = (R3BLosCalData*)det->At(iPart); + iDet = calData->GetDetector(); + Int_t nVftx = 0; + Int_t nTamexL = 0; + Int_t nTamexT = 0; + + for (Int_t iCha = 0; iCha < 8; iCha++) + { + if (iDet == 1) + { + time_V_LOS1[nPartLos[iDet - 1]][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeV_ns(iCha)))) + { // VFTX + time_V_LOS1[nPartLos[iDet - 1]][iCha] = calData->GetTimeV_ns(iCha); + nVftx++; + } + // cout<<"time_V_LOS1: "<GetTimeV_ns(iCha)<GetTimeL_ns(iCha)))) + { // TAMEX leading + time_L[iDet - 1][nPartLos[iDet - 1]][iCha] = calData->GetTimeL_ns(iCha); + nTamexL++; + } + + time_T[iDet - 1][nPartLos[iDet - 1]][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeT_ns(iCha)))) + { // TAMEX trailing + time_T[iDet - 1][nPartLos[iDet - 1]][iCha] = calData->GetTimeT_ns(iCha); + nTamexT++; + } + // cout<<"time Tamex trailing LOS1: "<GetTimeT_ns(iCha)<GetTimeM_ns(iCha)))) + { // MTDC + time_MTDC[nPartLos[iDet - 1]][iCha] = calData->GetTimeM_ns(iCha); + } + } + if (iDet == 2) + { + time_V_LOS2[nPartLos[iDet - 1]][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeV_ns(iCha)))) + { // VFTX + time_V_LOS2[nPartLos[iDet - 1]][iCha] = calData->GetTimeV_ns(iCha); + nVftx++; + } + // cout<<"time_V_LOS2: "<GetTimeV_ns(iCha)<GetTimeL_ns(iCha)))) + { // TAMEX leading + time_L[iDet - 1][nPartLos[iDet - 1]][iCha] = calData->GetTimeL_ns(iCha); + nTamexL++; + } + + time_T[iDet - 1][nPartLos[iDet - 1]][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeT_ns(iCha)))) + { // TAMEX trailing + time_T[iDet - 1][nPartLos[iDet - 1]][iCha] = calData->GetTimeT_ns(iCha); + nTamexT++; + } + + time_MTDC[nPartLos[iDet - 1]][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeM_ns(iCha)))) + { // MTDC + time_MTDC[nPartLos[iDet - 1]][iCha] = calData->GetTimeM_ns(iCha); + } + } + } + // cout<<"n: "< 0) + { + std::qsort(time_V_LOS1, nPartLos[0], sizeof(*time_V_LOS1), [](const void* arg1, const void* arg2) -> int { + double const* lhs = static_cast(arg1); + double const* rhs = static_cast(arg2); + + return (lhs[0] < rhs[0]) ? -1 : ((rhs[0] < lhs[0]) ? 1 : 0); + }); + for (Int_t iPart = 0; iPart < nPartLos[0]; iPart++) + { + for (int ipm = 0; ipm < 8; ipm++) + { + time_V[0][iPart][ipm] = time_V_LOS1[iPart][ipm]; + // cout<<"Test "< 0) + { + std::qsort(time_V_LOS2, nPartLos[1], sizeof(*time_V_LOS2), [](const void* arg1, const void* arg2) -> int { + double const* lhs = static_cast(arg1); + double const* rhs = static_cast(arg2); + + return (lhs[0] < rhs[0]) ? -1 : ((rhs[0] < lhs[0]) ? 1 : 0); + }); + for (Int_t iPart = 0; iPart < nPartLos[1]; iPart++) + { + for (int ipm = 0; ipm < 8; ipm++) + { + time_V[1][iPart][ipm] = time_V_LOS2[iPart][ipm]; + // cout<<"Test "< time_first(fNofLosDetectors, -1.); + std::vector time0(fNofLosDetectors, -1.); + std::vector time1(fNofLosDetectors, -1.); + std::vector time_abs(fNofLosDetectors, -1.); + + for (iDet = 1; iDet <= fNofLosDetectors; iDet++) + { + for (Int_t iPart = 0; iPart < nPartLos[iDet - 1]; iPart++) + { + Bool_t iLOSTypeMCFD = false; + Bool_t iLOSTypeTAMEX = false; + Bool_t iLOSType = false; + + if (time_V[iDet - 1][iPart][0] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][0])) && + time_V[iDet - 1][iPart][1] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][1])) && + time_V[iDet - 1][iPart][2] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][2])) && + time_V[iDet - 1][iPart][3] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][3])) && + time_V[iDet - 1][iPart][4] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][4])) && + time_V[iDet - 1][iPart][5] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][5])) && + time_V[iDet - 1][iPart][6] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][6])) && + time_V[iDet - 1][iPart][7] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][7]))) + { + iLOSTypeMCFD = true; // all 8 MCFD times + } + + if (time_L[iDet - 1][iPart][0] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][0])) && + time_L[iDet - 1][iPart][1] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][1])) && + time_L[iDet - 1][iPart][2] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][2])) && + time_L[iDet - 1][iPart][3] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][3])) && + time_L[iDet - 1][iPart][4] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][4])) && + time_L[iDet - 1][iPart][5] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][5])) && + time_L[iDet - 1][iPart][6] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][6])) && + time_L[iDet - 1][iPart][7] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][7])) && + + time_T[iDet - 1][iPart][0] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][0])) && + time_T[iDet - 1][iPart][1] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][1])) && + time_T[iDet - 1][iPart][2] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][2])) && + time_T[iDet - 1][iPart][3] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][3])) && + time_T[iDet - 1][iPart][4] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][4])) && + time_T[iDet - 1][iPart][5] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][5])) && + time_T[iDet - 1][iPart][6] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][6])) && + time_T[iDet - 1][iPart][7] > 0. && !(IS_NAN(time_T[iDet - 1][iPart][7]))) + { + iLOSTypeTAMEX = true; // all 8 leading and trailing times + } + + // We will consider only events in which booth MCFD and TAMEX see same number of channels: + if (iLOSTypeTAMEX && iLOSTypeMCFD) + iLOSType = true; + + if (1 == 1) + { + + if (1 == 1) //(iLOSType) + { + int nPMT = 0; + int nPMV = 0; + + for (int ipm = 0; ipm < 8; ipm++) + { + + tot[iDet - 1][iPart][ipm] = 0. / 0.; + + if (time_T[iDet - 1][iPart][ipm] > 0. && time_L[iDet - 1][iPart][ipm] > 0. && + !(IS_NAN(time_T[iDet - 1][iPart][ipm])) && !(IS_NAN(time_L[iDet - 1][iPart][ipm]))) + { + while (time_T[iDet - 1][iPart][ipm] - time_L[iDet - 1][iPart][ipm] <= 0.) + { + time_T[iDet - 1][iPart][ipm] = time_T[iDet - 1][iPart][ipm] + 2048. * fClockFreq; + } + + nPMT = nPMT + 1; + tot[iDet - 1][iPart][ipm] = time_T[iDet - 1][iPart][ipm] - time_L[iDet - 1][iPart][ipm]; + } + + if (tot[iDet - 1][iPart][ipm] != 0. && !(IS_NAN(tot[iDet - 1][iPart][ipm]))) + totsum[iDet - 1][iPart] += tot[iDet - 1][iPart][ipm]; + + if (time_L[iDet - 1][iPart][ipm] > 0. && !(IS_NAN(time_L[iDet - 1][iPart][ipm]))) + timeLosT[iDet - 1][iPart] += time_L[iDet - 1][iPart][ipm]; + + /* + if(iDet == 2){ + // Push VFTX times of LOS2 + if( timeLos[iDet-2][iPart] > 0. && + !(IS_NAN(timeLos[iDet-2][iPart])) > 0. && time_V[iDet-1][iPart][ipm] > 0. && + !(IS_NAN(time_V[iDet-1][iPart][ipm]))){ + + while(time_V[iDet-1][iPart][ipm]-timeLos[iDet-2][iPart] < + 8192.*5.){ time_V[iDet-1][iPart][ipm] = time_V[iDet-1][iPart][ipm] + 8192.*5.; + } + } + } + */ + + // Calculate detector time + if (time_V[iDet - 1][iPart][ipm] > 0. && !(IS_NAN(time_V[iDet - 1][iPart][ipm]))) + { + timeLosV[iDet - 1][iPart] += time_V[iDet - 1][iPart][ipm]; + nPMV = nPMV + 1; + } + } + + totsum[iDet - 1][iPart] = totsum[iDet - 1][iPart] / nPMT; + + timeLosV[iDet - 1][iPart] = timeLosV[iDet - 1][iPart] / nPMV; + + timeLosT[iDet - 1][iPart] = timeLosT[iDet - 1][iPart] / nPMT; + + timeLos[iDet - 1][iPart] = timeLosV[iDet - 1][iPart]; + + // cout<<"LOS: "<Fill(tt); + } + time1[iDet - 1] = timeLosV[iDet - 1][iPart]; + time_abs[iDet - 1] = + time1[iDet - 1] - time0[iDet - 1] + (double)(time - time_prev[iDet - 1]); + // cout<<"idet: "< 0 && time_abs[iDet - 1] < 5.E8) + { + fh_los_dt_hits_ToT[iDet - 1]->Fill(time_abs[iDet - 1] / 1000., totsum[iDet - 1][iPart]); + // cout<<"draw "<Fill(time_abs[iDet - 1] / 1000.); + } + time_prev[iDet - 1] = time; + time0[iDet - 1] = time1[iDet - 1]; + + // Plot Events over one spill + Double_t tt = + (time1[iDet - 1] - time0[iDet - 1] + (double)(time - time_spill_start)) / 1.e9; + fh_spill_times_daq->Fill(tt); + + // MH + /* + // time difference between two events in one read-out window + time2[iDet-1]=0.; + if (time0[iDet-1] < 0 ) { + time0[iDet-1] = timeLosV[iDet-1][iPart]; + Double_t tt = (time0[iDet-1] + time - time_spill_start)/1.e9; + fh_spill_times_daq_first->Fill(tt); + } + if (time1[iDet-1] < 0 ) time1[iDet-1] = timeLosV[iDet-1][iPart]; + + time2[iDet-1] = timeLosV[iDet-1][iPart] ; + + + double_t time_abs[iDet-1] = time2[iDet-1] - time1[iDet-1] + + (double)(time-time_prev); if(time_abs[iDet-1] > 0 && time_abs[iDet-1] < 5.E8) { + fh_los_dt_hits->Fill(time_abs[iDet-1] / 1000.); + // fh_frequencies->Fill(1./time_abs*1.E6); + //if(1./time_abs*1.E6<30.) + //cout << "Time Test " << time1 << " " << time2 << " " << time2 - time1 << + " " << time << " " << time_prev << " " << time_abs<<" "<<1./time_abs*1.E6<Fill(tt); + */ + // end MH + + if (foptcond == 0) + { + fh_los_tot_mean[iDet - 1]->Fill(totsum[iDet - 1][iPart]); + for (int ipm = 0; ipm < 8; ipm++) + { + fh_los_tot[iDet - 1]->Fill(ipm + 1, tot[iDet - 1][iPart][ipm]); + } + + fh_los_tres_MCFD[iDet - 1]->Fill(LosTresV[iDet - 1][iPart]); + fh_los_tres_TAMEX[iDet - 1]->Fill(LosTresT[iDet - 1][iPart]); + if (iDet == 1) + fh_los_tres_MTDC->Fill(LosTresMTDC[iPart]); + + fh_los_pos_MCFD[iDet - 1]->Fill(xV_cm[iDet - 1][iPart], yV_cm[iDet - 1][iPart]); + fh_los_pos_TAMEX[iDet - 1]->Fill(xT_cm[iDet - 1][iPart], yT_cm[iDet - 1][iPart]); + fh_los_pos_ToT[iDet - 1]->Fill(xToT_cm[iDet - 1][iPart], yToT_cm[iDet - 1][iPart]); + } + + fh_los_ihit_ToT[iDet - 1]->Fill(iPart + 1, totsum[iDet - 1][iPart]); + fh_los_multihit[iDet - 1]->Fill(iPart + 1); + } + } + } + else + { + cout << "Wrong detector ID for LOS!" << endl; + } + } + } + } + + if (fCalItems.at(DET_LOS) && fNofLosDetectors == 2) + { + for (Int_t iPart = 0; iPart < nPart; iPart++) + { + // fh_los_ToT_vs_ToT->Fill(totsum[0][iPart],totsum[1][iPart]); + } + } + + //---------------------------------------------------------------------- + // SCI8 detector + //---------------------------------------------------------------------- + + Double_t timeS8_V[10][2] = { 0.0 / 0.0 }; // [multihit][pm] + Double_t timeS8_L[10][2] = { 0.0 / 0.0 }; + Double_t timeS8_T[10][2] = { 0.0 / 0.0 }; + Double_t timeSci8M[10] = { 0.0 }; + Double_t Sci8TresM[10] = { 0.0 / 0.0 }; + Double_t timeSci8T[10] = { 0.0 }; + Double_t Sci8TresT[10] = { 0.0 / 0.0 }; + Double_t timeSci8[10] = { 0.0 }; + Double_t totsumS8[10] = { 0.0 }; + Double_t totS8[10][8] = { 0.0 / 0.0 }; + + Int_t MultipS8; + + if (fMappedItems.at(DET_SCI8)) + { + auto det = fMappedItems.at(DET_SCI8); + Int_t nHits = det->GetEntriesFast(); + + MultipS8 = nHits; + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BSci8MappedData* hit = (R3BSci8MappedData*)det->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iDet = hit->GetDetector(); // 1.. + Int_t iCha = hit->GetChannel(); // 1.. + + fh_sci8_channels->Fill(iCha); + } + } + + Int_t nPartS8; + + if (fCalItems.at(DET_SCI8)) + { + auto det = fCalItems.at(DET_SCI8); + nPartS8 = det->GetEntriesFast(); + + fh_sci8_multihit->Fill(nPartS8); + + Int_t iDet = 0; + Int_t nPartS8_VFTX[2] = { 0 }; + Int_t nPartS8_LEAD[2] = { 0 }; + Int_t nPartS8_TRAI[2] = { 0 }; + + for (Int_t iPart = 0; iPart < nPartS8; iPart++) + { + + /* + * nPart is the number of particle passing through Sci8 detector in one event + */ + + R3BSci8CalData* calDataS8 = (R3BSci8CalData*)det->At(iPart); + iDet = calDataS8->GetDetector(); + + // VFTX Channels 1-2: + if (!(IS_NAN(calDataS8->fTimeV_r_ns))) + { + timeS8_V[iPart][0] = calDataS8->fTimeV_r_ns; + nPartS8_VFTX[0] += 1; + } + if (!(IS_NAN(calDataS8->fTimeV_l_ns))) + { + timeS8_V[iPart][1] = calDataS8->fTimeV_l_ns; + nPartS8_VFTX[1] += 1; + } + + // TAMEX Channels 1-2: + if (!(IS_NAN(calDataS8->fTimeL_r_ns))) + { + timeS8_L[iPart][0] = calDataS8->fTimeL_r_ns; + nPartS8_LEAD[0] += 1; + } + if (!(IS_NAN(calDataS8->fTimeT_r_ns))) + { + timeS8_T[iPart][0] = calDataS8->fTimeT_r_ns; + nPartS8_TRAI[0] += 1; + } + if (!(IS_NAN(calDataS8->fTimeL_l_ns))) + { + timeS8_L[iPart][1] = calDataS8->fTimeL_l_ns; + nPartS8_LEAD[1] += 1; + } + if (!(IS_NAN(calDataS8->fTimeT_l_ns))) + { + timeS8_T[iPart][1] = calDataS8->fTimeT_l_ns; + nPartS8_TRAI[1] += 1; + } + + if (iPart > 0 && MultipS8 % 2 == 0) + { + for (int k = 0; k < 2; k++) + { + if (timeS8_V[iPart][k] > 0. && timeS8_V[iPart - 1][k] > 0. && !(IS_NAN(timeS8_V[iPart][k])) && + !(IS_NAN(timeS8_V[iPart - 1][k]))) + { + fh_sci8_dt_hits->Fill(timeS8_V[iPart][k] - timeS8_V[iPart - 1][k]); + } + if (timeS8_L[iPart][k] > 0. && timeS8_L[iPart - 1][k] > 0. && !(IS_NAN(timeS8_L[iPart][k])) && + !(IS_NAN(timeS8_L[iPart - 1][k]))) + { + fh_sci8_dt_hits_l->Fill(timeS8_L[iPart][k] - timeS8_L[iPart - 1][k]); + } + if (timeS8_T[iPart][k] > 0. && timeS8_T[iPart - 1][k] > 0. && !(IS_NAN(timeS8_T[iPart][k])) && + !(IS_NAN(timeS8_T[iPart - 1][k]))) + { + fh_sci8_dt_hits_t->Fill(timeS8_T[iPart][k] - timeS8_T[iPart - 1][k]); + } + } + } + + if (iDet == 1) + { + + // if(iPart >= 0) + if (1 == 1) + { + int nPMT = 0; + int nPMV = 0; + int ilc = iPart; + + for (int ipm = 0; ipm < 2; ipm++) + { + + if (timeS8_T[iPart][ipm] > 0. && timeS8_L[iPart][ipm] > 0. && !(IS_NAN(timeS8_T[iPart][ipm])) && + !(IS_NAN(timeS8_L[iPart][ipm]))) + { + while (timeS8_T[iPart][ipm] - timeS8_L[iPart][ipm] < 0.) + { + timeS8_T[iPart][ipm] = timeS8_T[iPart][ipm] + 2048. * fClockFreq; + } + + nPMT = nPMT + 1; + totS8[iPart][ipm] = timeS8_T[iPart][ipm] - timeS8_L[iPart][ipm]; + } + + totsumS8[iPart] += totS8[iPart][ipm]; + + if (totS8[iPart][ipm] != 0. && !(IS_NAN(totS8[iPart][ipm]))) + fh_sci8_tot->Fill(ipm + 1, totS8[iPart][ipm]); + + if (timeS8_L[iPart][ipm] > 0. && !(IS_NAN(timeS8_L[iPart][ipm]))) + timeSci8T[iPart] += timeS8_L[iPart][ipm]; + + if (timeS8_V[iPart][ipm] > 0. && !(IS_NAN(timeS8_V[iPart][ipm]))) + { + timeSci8M[iPart] += timeS8_V[iPart][ipm]; + nPMV = nPMV + 1; + } + } + + totsumS8[iPart] = totsumS8[iPart] / nPMT; + /* + if(totsum[iPart] < 88.) cout< 0.) + { + if (timeSci8[iPart] - timeLos[1][0] < 8192. * 5. / 2.) + timeSci8[iPart] += 8192. * 5.; + if (timeSci8[iPart] - timeLos[1][0] > 8192. * 5. / 2.) + timeSci8[iPart] -= 8192. * 5.; + tof = timeSci8[iPart] - timeLos[1][0]; + } + + // cout<<"tof "< 8192. * 5. / 2.) + timeSci8[iPart] -= 8192. * 5.; + Double_t tofi = timeSci8[iPart] - timeLos[1][lhit]; + // if hit is closer to expected value then take it + if (abs(tofi - 7852.) < abs(tof - 7852.)) + tof = tofi; + // cout<<"tofi "<Fill(tof); + + if (nPMV == 2) + Sci8TresM[iPart] = (timeS8_V[iPart][1] - timeS8_V[iPart][0]); + if (nPMT == 2) + Sci8TresT[iPart] = (timeS8_L[iPart][1] - timeS8_L[iPart][0]); + + if (nPMV == 2) + fh_sci8_tres_MCFD->Fill(Sci8TresM[iPart]); + if (nPMT == 2) + fh_sci8_tres_TAMEX->Fill(Sci8TresT[iPart]); + if (nPMT == 2) + fh_sci8_tot_mean->Fill(totsumS8[iPart]); + } + } + else + { + cout << "Wrong detector ID for Sci8!" << endl; + } + } + + for (int ik = 0; ik < 2; ik++) + { + fh_sci8_multihitVFTX->Fill(ik + 1, nPartS8_VFTX[ik]); + fh_sci8_multihitLEAD->Fill(ik + 1, nPartS8_LEAD[ik]); + fh_sci8_multihitTRAI->Fill(ik + 1, nPartS8_TRAI[ik]); + } + } + + //---------------------------------------------------------------------- + // Fiber detectors + //---------------------------------------------------------------------- + Double_t dtime = 0.0 / 0.0; + Bool_t fib1a_cut = false; + Bool_t fib1b_cut = false; + Int_t iLosHit = 0; + + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + + Int_t iFib = 0; + + auto detMapped = fMappedItems.at(DET_FI_FIRST + ifibcount); + auto detHit = fHitItems.at(DET_FI_FIRST + ifibcount); + + if (detMapped) + { + Int_t nHits = detMapped->GetEntriesFast(); + std::vector mapmt_num(512); + std::vector spmt_num(16); + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BBunchedFiberMappedData* hit = (R3BBunchedFiberMappedData*)detMapped->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iCha = hit->GetChannel(); // 1.. + + if (hit->IsMAPMT() && hit->IsLeading()) + { + fh_channels_Fib[ifibcount]->Fill(iCha); // Fill which clockTDC channel has events + ++mapmt_num.at(hit->GetChannel() - 1); // multihit of a given clockTDC channel + } + + if (!hit->IsMAPMT() && hit->IsLeading()) + { + fh_channels_single_Fib[ifibcount]->Fill(iCha); // Fill which single PMT channel has events + ++spmt_num.at(hit->GetChannel() - 1); // multihit of a given PADI channel + } + } + + for (int i = 0; i < 512; ++i) + { + auto m = mapmt_num.at(i); + if (m > 0) + fh_multihit_m_Fib[ifibcount]->Fill(i + 1, m); // multihit of a given clockTDC channel + } + + for (int i = 0; i < 16; ++i) + { + auto s = spmt_num.at(i); + if (s > 0) + fh_multihit_s_Fib[ifibcount]->Fill(i + 1, s); // multihit of a given PADI channel + } + } + + if (detHit) + { + Int_t nHits = detHit->GetEntriesFast(); + + Double_t xpos = 0. / 0.; + Double_t ypos = 0. / 0.; + Double_t totMax = 0.; + Double_t totMax_MA = 0.; + Double_t tfib = 0. / 0., tof_fib = 0. / 0.; + Double_t randx; + Int_t iFibmax = -100; + Int_t iFibMax_MA = -100; + Double_t totMax_S = 0.; + Double_t yposMax = -10000; + Double_t tof_fibMax = -10000; + // cout<<"new event: "<< nHits<<" "<At(ihit); + if (!hit) + continue; + + iFib = hit->GetFiberId(); // 1.. + + // times + tMAPMT = hit->GetMAPMTTime_ns(); + tSPMT = hit->GetSPMTTime_ns(); + + // if not both times present, go to next + if (!(tMAPMT > 0.) || !(tSPMT > 0.)) + continue; + + // loop over all hits of LOS1: + for (Int_t lhit = 0; lhit < nPartLos[1]; lhit++) + { + if (IS_NAN(timeLos[1][lhit])) + continue; + + // if not multiplicity 8 or pile-up, go to next event + Bool_t pileup = false; + Int_t nPMT = 0; + for (int ipm = 0; ipm < 8; ipm++) + { + if (tot[1][iLosHit][ipm] > 0. && !(IS_NAN(tot[1][iLosHit][ipm]))) + nPMT++; + if (tot[1][iLosHit][ipm] > 100.) + pileup = true; + } + if (pileup || nPMT != 8) + continue; + + // "Push" the Fib times in the same cycle with LOS: + // Los coarse counter has 8192 channels with 5 ns each + // SPMT coarse counter has 2048 channels with 5 ns each + if (timeLos[1][lhit] > 0. && timeLos[1][lhit] < 8192. * 5. && !(IS_NAN(timeLos[1][lhit]))) + { + while (tSPMT - timeLos[1][lhit] < 2048. * 5. / 2.) + { + tSPMT = tSPMT + 2048. * 5.; + } + while (tSPMT - timeLos[1][lhit] > 2048. * 5. / 2.) + { + tSPMT = tSPMT - 2048. * 5.; + } + } + + // "Push" two times in the same clock cycle: + // MAPMT coarse counter has 4096 channels with 1000/150=6.67 ns each + // SPMT coarse counter has 2048 channels with 5 ns each + dtime = tMAPMT - tSPMT; + while (dtime > 1024. / 2. * 1000. / 150.) + { + tMAPMT = tMAPMT - 1024. * 1000. / 150.; + dtime = tMAPMT - tSPMT; + } + while (dtime < -1024. / 2. * 1000. / 150.) + { + tMAPMT = tMAPMT + 1024. * 1000. / 150.; + dtime = tMAPMT - tSPMT; + } + + // Not-calibrated ToF: + tfib = (tMAPMT + tSPMT) / 2.; + // tfib = tSPMT; + // tfib = tMAPMT; + if (tfib > 0. && !(IS_NAN(tfib)) && timeLos[1][lhit] > 0. && !(IS_NAN(timeLos[1][lhit]))) + tof_fib = tfib - timeLos[1][lhit]; + + // cout<<"Test "<GetMAPMTToT_ns()<<" + //"<GetSPMTToT_ns()<< " "< tof_fiber[ifibcount] + 10.) + continue; + + // Not-calibrated position: + randx = (std::rand() / (float)RAND_MAX); + // if(iFib > 0) xpos = ((-n_fiber[ifibcount]/2.+iFib+(0.5-randx)))*0.21; + xpos = iFib; + ypos = dtime; + + // if not resonable y-position, go to next + if (ypos < 70. || ypos > 100.) + continue; + + // find fiber with most light which has resonable ToF and y-position + Double_t ToT_MA = hit->GetMAPMTToT_ns(); + if (ToT_MA > totMax_MA) + { + totMax_MA = ToT_MA; + iFibMax_MA = iFib; + totMax_S = hit->GetSPMTToT_ns(); + yposMax = ypos; + tof_fibMax = tof_fib; + iLosHit = lhit; + // cout<<"new imax "<Fill(iFib); + fh_ToT_s_Fib[ifibcount]->Fill(iFib,hit->GetSPMTToT_ns()); + fh_ToT_m_Fib[ifibcount]->Fill(iFib,hit->GetMAPMTToT_ns()); + fh_time_Fib[ifibcount]->Fill(iFib,tMAPMT-tSPMT); + fh_Fib_ToF[ifibcount]->Fill(iFib,tof_fib); + fh_Fib_pos_xy[ifibcount]->Fill(xpos,ypos); + fh_Fib_vs_Events[ifibcount]->Fill(fNEvents,iFib); + fh_ToT_single_Fib[ifibcount]->Fill(1,hit->GetSPMTToT_ns()); + */ + } // end for (lhit) + } // end for(ihit) + + fh_fibers_Fib[ifibcount]->Fill(iFibMax_MA); + fh_ToT_s_Fib[ifibcount]->Fill(iFibMax_MA, totMax_S); + fh_ToT_m_Fib[ifibcount]->Fill(iFibMax_MA, totMax_MA); + fh_time_Fib[ifibcount]->Fill(iFibMax_MA, yposMax); + fh_Fib_ToF[ifibcount]->Fill(iFibMax_MA, tof_fibMax); + fh_Fib_pos_xy[ifibcount]->Fill(xpos, ypos); + fh_Fib_vs_Events[ifibcount]->Fill(fNEvents, iFibMax_MA); + fh_ToT_single_Fib[ifibcount]->Fill(1, totMax_S); + + if (ifibcount == 0 && iFibMax_MA > 120 && iFibMax_MA < 136) + { + fib1a_cut = true; + } + if (ifibcount == 1 && iFibMax_MA > 120 && iFibMax_MA < 136) + { + fib1b_cut = true; + // cout<<"Cut true "<< iFibMax_MA << endl; + } + if (nHits > 0) + fh_mult_Fib[ifibcount]->Fill(nHits); + // cout<<"Hits "<Fill(xV_cm[ilos][iLosHit], yV_cm[ilos][iLosHit]); + fh_los_pos_TAMEX[ilos]->Fill(xT_cm[ilos][iLosHit], yT_cm[ilos][iLosHit]); + fh_los_pos_ToT[ilos]->Fill(xToT_cm[ilos][iLosHit], yToT_cm[ilos][iLosHit]); + fh_los_tres_MCFD[ilos]->Fill(LosTresV[ilos][iLosHit]); + fh_los_tres_TAMEX[ilos]->Fill(LosTresT[ilos][iLosHit]); + // fh_los_tres_MTDC->Fill(LosTresMTDC[iLosHit]); + fh_los_tot_mean[ilos]->Fill(totsum[ilos][iLosHit]); + for (int ipm = 0; ipm < 8; ipm++) + { + fh_los_tot[ilos]->Fill(ipm + 1, tot[ilos][iLosHit][ipm]); + } + fh_los_ToT_vs_ToT->Fill(totsum[0][iLosHit], totsum[1][iLosHit]); + } + } + } + + //---------------------------------------------------------------------- + // TOFD + //---------------------------------------------------------------------- + + Int_t NumPaddles[4] = { 0 }; + if (fMappedItems.at(DET_TOFD)) + { + auto det = fMappedItems.at(DET_TOFD); + Int_t nMapped = det->GetEntriesFast(); + Int_t iPlaneMem = 1, iBarMem = 0; + for (Int_t imapped = 0; imapped < nMapped; imapped++) + { + auto mapped = (R3BTofdMappedData const*)det->At(imapped); + if (!mapped) + continue; // should not happen + + Int_t const iPlane = mapped->GetDetectorId(); // 1..n + Int_t const iBar = mapped->GetBarId(); // 1..n + Int_t const iSide = mapped->GetSideId(); // 1..n + Int_t const iEdge = mapped->GetEdgeId(); + + if (iPlaneMem != iPlane) + iBarMem = 0; + if (iPlane == 1 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[0] += 1; + if (iPlane == 2 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[1] += 1; + if (iPlane == 3 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[2] += 1; + if (iPlane == 3 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[3] += 1; + + // cout<Fill(-iBar - 1); + if (iSide == 2) + fh_tofd_channels[iPlane - 1]->Fill(iBar); + } + } + } + + if (fCalItems.at(DET_TOFD)) + { + auto det = fCalItems.at(DET_TOFD); + Int_t nCals = det->GetEntriesFast(); + + Double_t tot1[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t tot2[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t_paddle[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t1l[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t2l[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t1t[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t2t[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t ToF[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + + Bool_t Bar_present[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { false }; + + Int_t iBarMem = 0; + Int_t jmult[N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0 }; + + unsigned long long time0 = header->GetTimeStamp(); + double_t time1 = -1.; + + for (Int_t ical = 0; ical < nCals; ical++) + { + auto cal = (R3BTofdCalData const*)det->At(ical); + if (!cal) + continue; // should not happen + + Int_t const iPlane = cal->GetDetectorId(); // 1..n + Int_t const iBar = cal->GetBarId(); // 1..n + + // std::cout << iPlane << ' ' << iBar << + // ',' << cal->GetTimeBL_ns() << + // ' ' << cal->GetTimeBT_ns() << + // ' ' << cal->GetTimeTL_ns() << + // ' ' << cal->GetTimeTT_ns() << std::endl; + + // get all times of one bar + /* + cout<<"TOFD Online: "<fTime1L_ns<<", "<fTime1T_ns<<", "<< cal->fTime2L_ns<<", + "<fTime2T_ns<GetTimeBL_ns())) t1l[0][iPlane-1][iBar-1] = cal->GetTimeBL_ns(); + if (!IS_NAN(cal->GetTimeBT_ns())) t1t[0][iPlane-1][iBar-1] = cal->GetTimeBT_ns(); + if (!IS_NAN(cal->GetTimeTL_ns())) t2l[0][iPlane-1][iBar-1] = cal->GetTimeTL_ns(); + if (!IS_NAN(cal->GetTimeTT_ns())) t2t[0][iPlane-1][iBar-1] = cal->GetTimeTT_ns(); + Bar_present[0][iPlane-1][iBar-1] = true; + } + else + { + jmult[iPlane-1][iBar-1] = jmult[iPlane-1][iBar-1] + 1; + Int_t jm = jmult[iPlane-1][iBar-1]; + if (!IS_NAN(cal->GetTimeBL_ns())) t1l[jm][iPlane-1][iBar-1] = cal->GetTimeBL_ns(); + if (!IS_NAN(cal->GetTimeBT_ns())) t1t[jm][iPlane-1][iBar-1] = cal->GetTimeBT_ns(); + if (!IS_NAN(cal->GetTimeTL_ns())) t2l[jm][iPlane-1][iBar-1] = cal->GetTimeTL_ns(); + if (!IS_NAN(cal->GetTimeTT_ns())) t2t[jm][iPlane-1][iBar-1] = cal->GetTimeTT_ns(); + Bar_present[jm][iPlane-1][iBar-1] = true; + } + iBarMem = iBar; + */ + + Int_t jm = jmult[iPlane - 1][iBar - 1]; + /* if (!IS_NAN(cal->GetTimeBL_ns())) t1l[jm][iPlane-1][iBar-1] = cal->GetTimeBL_ns(); + if (!IS_NAN(cal->GetTimeBT_ns())) t1t[jm][iPlane-1][iBar-1] = cal->GetTimeBT_ns(); + if (!IS_NAN(cal->GetTimeTL_ns())) t2l[jm][iPlane-1][iBar-1] = cal->GetTimeTL_ns(); + if (!IS_NAN(cal->GetTimeTT_ns())) t2t[jm][iPlane-1][iBar-1] = cal->GetTimeTT_ns();*/ + Bar_present[jm][iPlane - 1][iBar - 1] = true; + jmult[iPlane - 1][iBar - 1] = jmult[iPlane - 1][iBar - 1] + 1; + + double_t time2 = 0.; + if (time1 < 0 && iPlane == 2) + time1 = (t1l[jm][iPlane - 1][iBar - 1] + t2l[jm][iPlane - 1][iBar - 1]) / 2.; + if (iPlane == 2) + time2 = (t1l[jm][iPlane - 1][iBar - 1] + t2l[jm][iPlane - 1][iBar - 1]) / 2.; + if (time1 > 0. && time2 > 0. && time2 > time1) + { + // cout<<"Time Test "<Fill(time2 - time1); + time2 = time1; + } + } + + /* + for (Int_t ipl = 0; ipl < N_PLANE_MAX_TOFD; ipl++) + for(Int_t ibr = 0; ibr < N_PADDLE_MAX_TOFD; ibr++) + { + fh_tofd_multihit[ipl]->Fill(ibr+1,jmult[ipl][ibr]+1); + } + */ + for (Int_t ipl = 0; ipl < N_PLANE_MAX_TOFD; ipl++) + for (Int_t ibr = 0; ibr < N_PADDLE_MAX_TOFD; ibr++) + for (Int_t jm = 0; jm < jmult[ipl][ibr]; jm++) + { + + if (Bar_present[jm][ipl][ibr]) + { + Int_t iPlane = ipl + 1; // 1..n + Int_t iBar = ibr + 1; // 1..n + + fh_tofd_multihit[ipl]->Fill(ibr + 1, jmult[ipl][ibr]); + + // calculate time over threshold and check if clock counter went out of range + + while (t1t[jm][iPlane - 1][iBar - 1] < t1l[jm][iPlane - 1][iBar - 1]) + { + t1t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + + while (t2t[jm][iPlane - 1][iBar - 1] < t2l[jm][iPlane - 1][iBar - 1]) + { + t2t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + + int ilc = jm; + + if (!(IS_NAN(timeLos[0][ilc])) && timeLos[0][ilc] > 0.) + { + + while (t1l[jm][iPlane - 1][iBar - 1] < timeLos[0][ilc]) + { + t1t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + t1l[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + while (t2l[jm][iPlane - 1][iBar - 1] < timeLos[0][ilc]) + { + t2t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + t2l[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + } + + // ToF + t_paddle[jm][iPlane - 1][iBar - 1] = + (t1l[jm][iPlane - 1][iBar - 1] + t2l[jm][iPlane - 1][iBar - 1]) / 2.; + + // between 2 bars in 2 planes + if (ipl > 0) + { + fh_tofd_dt[ipl - 1]->Fill(iBar, + t_paddle[jm][ipl][iBar - 1] - t_paddle[jm][ipl - 1][iBar - 1]); + } + + if (!(IS_NAN(timeLos[0][ilc])) && timeLos[0][ilc] > 0.) + { + // between LOS and paddle + ToF[jm][iPlane - 1][iBar - 1] = + fmod(t_paddle[jm][iPlane - 1][iBar - 1] - timeLos[0][ilc] + 5 * 8192, 5 * 2048); + fh_tofd_ToF[iPlane - 1]->Fill(iBar, ToF[jm][iPlane - 1][iBar - 1]); + } + // ToT + tot1[jm][iPlane - 1][iBar - 1] = t1t[jm][iPlane - 1][iBar - 1] - t1l[jm][iPlane - 1][iBar - 1]; + if (tot1[jm][iPlane - 1][iBar - 1] < 0) + { + cout << "Negative ToT " << tot1[jm][iPlane - 1] << ", for hit= " << jm << endl; + cout << "Times1: " << t1t[jm][iPlane - 1][iBar - 1] << " " << t1l[jm][iPlane - 1][iBar - 1] + << endl; + } + + tot2[jm][iPlane - 1][iBar - 1] = t2t[jm][iPlane - 1][iBar - 1] - t2l[jm][iPlane - 1][iBar - 1]; + if (tot2[jm][iPlane - 1][iBar - 1] < 0) + { + cout << "Negative ToT " << tot2[jm][iPlane - 1][iBar - 1] << ", for hit= " << jm << endl; + cout << "Times2: " << t2t[jm][iPlane - 1][iBar - 1] << " " << t2l[jm][iPlane - 1][iBar - 1] + << endl; + } + + fh_tofd_TotPm[iPlane - 1]->Fill(iBar, tot2[jm][iPlane - 1][iBar - 1]); + fh_tofd_TotPm[iPlane - 1]->Fill(-iBar - 1, tot1[jm][iPlane - 1][iBar - 1]); + } + } + } + + //---------------------------------------------------------------------- + // PTOF + //---------------------------------------------------------------------- + + if (fCalItems.at(DET_PTOF)) + { + auto det = fCalItems.at(DET_PTOF); + + Double_t tot1 = 0.; + Double_t tot2 = 0.; + Double_t t1l = 0.; + Double_t t2l = 0.; + Double_t t1t = 0.; + Double_t t2t = 0.; + Bool_t bar_quer1 = false; + Bool_t bar_quer2 = false; + + Int_t nHits = det->GetEntriesFast(); + LOG(DEBUG) << "nHits: " << nHits; + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BPaddleCalData* hit = (R3BPaddleCalData*)det->At(ihit); + + if (!hit) + continue; // should not happen + + Int_t iBar = hit->GetBar(); // 1..n + // get all times of one bar + t1l = hit->fTime1L_ns; + t2l = hit->fTime2L_ns; + t1t = hit->fTime1T_ns; + t2t = hit->fTime2T_ns; + + if (!(t1l > 0 && t2l > 0 && t1t > 0 && t2t > 0)) + continue; + + fh_ptof_channels->Fill(iBar); + LOG(DEBUG) << "Bar: " << iBar; + LOG(DEBUG) << "times PM1: " << t1l << " " << t1t << " " << t1t - t1l; + LOG(DEBUG) << "times PM2: " << t2l << " " << t2t << " " << t2t - t2l; + if (iBar == 7) + bar_quer1 = true; + if (iBar == 8) + bar_quer2 = true; + + // calculate time over threshold and check if clock counter went out of range + while (t1t - t1l < 0.) + { + t1t = t1t + 2048. * fClockFreq; + } + + while (t2t - t2l < 0.) + { + t2t = t2t + 2048. * fClockFreq; + } + while (t1l - timeLos[0][0] < 0.) + { + t1t = t1t + 2048. * fClockFreq; + t1l = t1l + 2048. * fClockFreq; + t2t = t2t + 2048. * fClockFreq; + t2l = t2l + 2048. * fClockFreq; + } + + tot1 = t1t - t1l; + if (tot1 < 0) + { + LOG(WARNING) << "Negative ToT " << tot1; + LOG(WARNING) << "times1: " << t1t << " " << t1l; + } + + tot2 = t2t - t2l; + if (tot2 < 0) + { + LOG(WARNING) << "Negative ToT " << tot2; + LOG(WARNING) << "times2: " << t2t << " " << t2l; + } + + fh_ptof_TotPm1[iBar]->Fill(tot1); + fh_ptof_TotPm2[iBar]->Fill(tot2); + if (iBar == 2) + fh_ptof_test1->Fill(sqrt(tot1 * tot1)); + } + + // once again + + nHits = det->GetEntriesFast(); + // LOG(DEBUG) << "nHits: " << nHits; + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BPaddleCalData* hit = (R3BPaddleCalData*)det->At(ihit); + + if (!hit) + continue; // should not happen + + Int_t iBar = hit->GetBar(); // 1..n + // get all times of one bar + t1l = hit->fTime1L_ns; + t2l = hit->fTime2L_ns; + t1t = hit->fTime1T_ns; + t2t = hit->fTime2T_ns; + + if (!(t1l > 0 && t2l > 0 && t1t > 0 && t2t > 0)) + continue; + + // calculate time over threshold and check if clock counter went out of range + while (t1t - t1l < 0.) + { + t1t = t1t + 2048. * fClockFreq; + } + + while (t2t - t2l < 0.) + { + t2t = t2t + 2048. * fClockFreq; + } + while (t1l - timeLos[0][0] < 0.) + { + t1t = t1t + 2048. * fClockFreq; + t1l = t1l + 2048. * fClockFreq; + t2t = t2t + 2048. * fClockFreq; + t2l = t2l + 2048. * fClockFreq; + } + + tot1 = t1t - t1l; + if (tot1 < 0) + { + LOG(WARNING) << "Negative ToT " << tot1; + LOG(WARNING) << "times1: " << t1t << " " << t1l; + } + + tot2 = t2t - t2l; + if (tot2 < 0) + { + LOG(WARNING) << "Negative ToT " << tot2; + LOG(WARNING) << "times2: " << t2t << " " << t2l; + } + + if (bar_quer1 && bar_quer2) + { + // fh_ptof_TotPm1[iBar]->Fill(tot1); + // fh_ptof_TotPm2[iBar]->Fill(tot2); + // if(iBar==2) fh_ptof_test2->Fill(sqrt(tot1*tot2)); + fh_ptof_channels_cut->Fill(iBar); + } + } + } + + fNEvents += 1; +} + +void R3BOnlineSpectraDec2019::FinishEvent() +{ + + for (Int_t det = 0; det < DET_MAX; det++) + { + if (fMappedItems.at(det)) + { + fMappedItems.at(det)->Clear(); + } + if (fCalItems.at(det)) + { + fCalItems.at(det)->Clear(); + } + if (fHitItems.at(det)) + { + fHitItems.at(det)->Clear(); + } + } +} + +void R3BOnlineSpectraDec2019::FinishTask() +{ + + if (fMappedItems.at(DET_LOS)) + { + for (Int_t iloscount = 0; iloscount < fNofLosDetectors; iloscount++) + { + fh_los_channels[iloscount]->Write(); + fh_los_tot[iloscount]->Write(); + fh_los_dt_hits_ToT[iloscount]->Write(); + fh_los_ihit_ToT[iloscount]->Write(); + fh_los_dt_hits[iloscount]->Write(); + fh_dt_hits[iloscount]->Write(); + fh_los_pos_MCFD[iloscount]->Write(); + fh_los_pos_TAMEX[iloscount]->Write(); + fh_los_pos_ToT[iloscount]->Write(); + } + } + + if (fMappedItems.at(DET_BMON)) + { + fhTpat->Write(); + fh_spill_length->Write(); + fhTrigger->Write(); + fh_spill_times->Write(); + fh_spill_times_pois->Write(); + fh_spill_times_daq->Write(); + fh_spill_times_daq_first->Write(); + fh_rate->Write(); + fh_frequencies->Write(); + fh_TOFDOR->Write(); + fh_particle->Write(); + fh_particle_pois->Write(); + fh_TOFDOR_spill->Write(); + } + + if (fCalItems.at(DET_TOFD)) + { + fh_TimePreviousEvent->Write(); + + for (Int_t i; i < 4; i++) + { + fh_tofd_TotPm[i]->Write(); + } + } + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + if (fMappedItems.at(ifibcount + DET_FI_FIRST)) + { + fh_channels_Fib[ifibcount]->Write(); + fh_fibers_Fib[ifibcount]->Write(); + fh_mult_Fib[ifibcount]->Write(); + fh_time_Fib[ifibcount]->Write(); + fh_multihit_m_Fib[ifibcount]->Write(); + fh_multihit_s_Fib[ifibcount]->Write(); + fh_ToT_m_Fib[ifibcount]->Write(); + fh_Fib_pos_xy[ifibcount]->Write(); + fh_ToT_s_Fib[ifibcount]->Write(); + fh_ToT_single_Fib[ifibcount]->Write(); + fh_Fib_vs_Events[ifibcount]->Write(); + fh_Fib_ToF[ifibcount]->Write(); + fh_channels_single_Fib[ifibcount]->Write(); + } + } + + if (fMappedItems.at(DET_PSPX)) + { + // LOG(INFO) << "Finish MappedPspx"; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_channel_x[i]->Write(); + fh_pspx_channel_y[i]->Write(); + fh_pspx_multiplicity_x[i]->Write(); + fh_pspx_multiplicity_y[i]->Write(); + fh_pspx_strips_position[i]->Write(); + } + } + if (fCalItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_cal_energy_frontback[i]->Write(); + } + } + if (fHitItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + fh_pspx_hit_energy[i]->Write(); + fh_pspx_hit_position[i]->Write(); + } + } +} + +ClassImp(R3BOnlineSpectraDec2019) diff --git a/r3bbase/R3BOnlineSpectraDec2019.h b/r3bbase/R3BOnlineSpectraDec2019.h new file mode 100644 index 000000000..ea57307c8 --- /dev/null +++ b/r3bbase/R3BOnlineSpectraDec2019.h @@ -0,0 +1,398 @@ +// ------------------------------------------------------------ +// ----- R3BOnlineSpectraDec2019 ----- +// ----- Created 13-04-2016 by M.Heil ----- +// ----- Fill online histograms ----- +// ------------------------------------------------------------ + +#ifndef R3BONLINESPECTRADEC2019 +#define R3BONLINESPECTRADEC2019 +#define N_PLANE_MAX_TOFD 4 +#define N_PADDLE_MAX_TOFD 50 +#define N_PADDLE_MAX_PTOF 100 +#define N_PSPX 6 +#define N_STRIPS_PSPX 32 +#define N_FIBER_PLOT 520 // range to plot + +#include "FairTask.h" +#include +#include +#include +#include +#include + +#include "TClonesArray.h" +#include "TMath.h" +#include + +class TClonesArray; +class TH1F; +class TH2F; +class R3BEventHeader; + +/** + * This taks reads all detector data items and plots histograms + * for online checks. + */ +class R3BOnlineSpectraDec2019 : public FairTask +{ + + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BOnlineSpectraDec2019(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BOnlineSpectraDec2019(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BOnlineSpectraDec2019(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Methods for setting position offset and effective velocity of light + */ + inline void SetLosXYMCFD(Double_t offsetX1, + Double_t offsetY1, + Double_t veffX1, + Double_t veffY1, + Double_t offsetX2, + Double_t offsetY2, + Double_t veffX2, + Double_t veffY2) + { + flosOffsetXV[0] = offsetX1; + flosOffsetYV[0] = offsetY1; + flosVeffXV[0] = veffX1; + flosVeffYV[0] = veffY1; + flosOffsetXV[1] = offsetX2; + flosOffsetYV[1] = offsetY2; + flosVeffXV[1] = veffX2; + flosVeffYV[1] = veffY2; + } + + inline void SetLosXYTAMEX(Double_t offsetXT1, + Double_t offsetYT1, + Double_t veffXT1, + Double_t veffYT1, + Double_t offsetXT2, + Double_t offsetYT2, + Double_t veffXT2, + Double_t veffYT2) + { + flosOffsetXT[0] = offsetXT1; + flosOffsetYT[0] = offsetYT1; + flosVeffXT[0] = veffXT1; + flosVeffYT[0] = veffYT1; + flosOffsetXT[1] = offsetXT2; + flosOffsetYT[1] = offsetYT2; + flosVeffXT[1] = veffXT2; + flosVeffYT[1] = veffYT2; + } + + inline void SetLosXYToT(Double_t offsetXQ1, + Double_t offsetYQ1, + Double_t veffXQ1, + Double_t veffYQ1, + Double_t offsetXQ2, + Double_t offsetYQ2, + Double_t veffXQ2, + Double_t veffYQ2) + { + flosOffsetXQ[0] = offsetXQ1; + flosOffsetYQ[0] = offsetYQ1; + flosVeffXQ[0] = veffXQ1; + flosVeffYQ[0] = veffYQ1; + flosOffsetXQ[1] = offsetXQ2; + flosOffsetYQ[1] = offsetYQ2; + flosVeffXQ[1] = veffXQ2; + flosVeffYQ[1] = veffYQ2; + } + /* Method for setting number of LOS detectors */ + inline void SetNofLosModules(Int_t nDets) { fNofLosDetectors = nDets; } + /** + * Methods for setting condition on filling xs from LOS + * 0 = no condition, 1 = condition from fiber + */ + inline void SetLosPosition(Int_t optcond) { foptcond = optcond; } + /** + * Method for setting the trigger value. + * @param trigger 1 - physics, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) { fTrigger = trigger; } + inline void SetTpat(Int_t tpat) { fTpat = tpat; } + + /** + * Methods for setting reset and readout times for Bmon + */ + inline void SetBmon(Int_t time_range, Double_t time_step, Double_t SpillLength, Double_t DAQ_dead_time) + { + reset_time = time_range; + read_time = time_step; + fDAQ_dead_time = DAQ_dead_time; // dead time in micro seconds + fSpillLength = SpillLength; + } + /** + * Methods for setting number of planes and paddles + */ + inline void SetNofModules(Int_t planes, Int_t ppp) + { + fNofPlanes = planes; + fPaddlesPerPlane = ppp; + } + + void Reset_ROLU_Histo(); + void Reset_LOS_Histo(); + void Reset_SCI8_Histo(); + void Reset_BMON_Histo(); + void Reset_TOFD_Histo(); + void Reset_FIBERS_Histo(); + + private: + std::vector fMappedItems; + std::vector fCalItems; + std::vector fHitItems; + + enum DetectorInstances + { + DET_AMS, + DET_CALIFA, + DET_BMON, + DET_FI_FIRST, + DET_FI1A = DET_FI_FIRST, + DET_FI1B, + DET_FI2A, + DET_FI2B, + DET_FI3A, + DET_FI3B, + DET_FI4, + DET_FI5, + DET_FI6, + DET_FI7, + DET_FI8, + DET_FI9, + DET_FI10, + DET_FI11, + DET_FI12, + DET_FI13, + DET_FI_LAST = DET_FI13, + DET_L3T, + DET_LOS, + DET_MUSIC, + DET_NEULAND, + DET_PSPX, + DET_PTOF, + DET_ROLU, + DET_SCI8, + DET_STRAW, + DET_TOFD, + DET_SAMPLER, + DET_MAX + }; + +#define NOF_FIB_DET (DET_FI_LAST - DET_FI_FIRST + 1) + + const char* fDetectorNames[DET_MAX + 1] = { "Ams", "Califa", "BeamMonitor", "Fi1a", "Fi1b", "Fi2a", "Fi2b", + "Fi3a", "Fi3b", "Fi4", "Fi5", "Fi6", "Fi7", "Fi8", + "Fi9", "Fi10", "Fi11", "Fi12", "Fi13", "L3t", "Los", + "Music", "Neuland", "Pspx", "Ptof", "Rolu", "Sci8", "Straw", + "Tofd", "Sampler", NULL }; + + // If FiberI is present or not: + Int_t ifibdet; + // Number of fibers per detector + Double_t n_fiber[NOF_FIB_DET] = { 256., 256., 256., 256, 512., 512., 2048., + 2048., 1024., 512., 512., 512., 1024., 1024. }; + Double_t tof_fiber[NOF_FIB_DET] = { 2580., 2580., 256., 256, 512., 512., 2048., + 2048., 1024., 512., 512., 512., 1024., 1024. }; + + // check for trigger should be done globablly (somewhere else) + R3BEventHeader* header; /**< Event header. */ + Int_t fTrigger; /**< Trigger value. */ + Int_t fTpat; + Int_t fSamp; + Double_t fClockFreq; /**< Clock cycle in [ns]. */ + UInt_t fNofPlanes; + UInt_t fPaddlesPerPlane; /**< Number of paddles per plane. */ + + // TClonesArray *fbmonMappedItems; + + Int_t fNofLosDetectors; /**< Number of LOS detectors. */ + +#define NOF_LOS_DET 2 + + Double_t flosVeffXV[2]; + Double_t flosVeffYV[2]; + Double_t flosOffsetXV[2]; + Double_t flosOffsetYV[2]; + Double_t flosVeffXT[2]; + Double_t flosVeffYT[2]; + Double_t flosOffsetXT[2]; + Double_t flosOffsetYT[2]; + Double_t flosVeffXQ[2]; + Double_t flosVeffYQ[2]; + Double_t flosOffsetXQ[2]; + Double_t flosOffsetYQ[2]; + Int_t foptcond; + + unsigned long long time_V_mem = 0, time_start = 0, time_mem = 0, time = 0, time_begin = 0; + unsigned long long time_prev[NOF_LOS_DET] = { 0 }; + + unsigned long long time_prev_read = 0, time_to_read = 0; + unsigned long ic_mem = 0, see_mem = 0, tofdor_mem = 0; + unsigned long ic_start = 0, see_start = 0, tofdor_start = 0; + unsigned long long time_spill_start = 0, time_spill_end = 0; + unsigned long long time_previous_event = 0; + long samplerPrev = 0, samplerCurr = 0, samplerSpill = 0, samplerBegin = 0; + UInt_t spillCounter = 0; + + Bool_t spill_on = false; + Bool_t spill_off = false; + Bool_t spill_on_sampler = false; + Double_t time_clear = -1.; + Double_t tdiff = 0.; + Double_t fNorm = 1.; + Int_t iclear_count = 1; + UInt_t reset_time; // time after which bmon spectra are reseted + Double_t read_time; // step in which scalers are read, in sec + Double_t calib_SEE = 1.; // SEETRAM calibration factor + Double_t see_offset = 7.1; // SEETRAM offset in kHz + Double_t fSpillLength; + Double_t fDAQ_dead_time; + unsigned long fNEvents = 0, fNEvents_start = 0; /**< Event counter. */ + + TH1F* fhTpat; + TH1F* fh_spill_length; + TH1F* fhTrigger; + TH1F* fh_particle; + TH1F* fh_particle_pois; + TH1F* fh_TOFDOR_spill; + TH1F* fh_spill_times; + TH1F* fh_spill_times_zoom; + TH1F* fh_spill_times_pois; + TH1F* fh_spill_times_daq; + TH1F* fh_spill_times_daq_first; + TH1F* fh_frequencies; + TH1F* fh_TOFDOR; + TH1F* fh_rate; + // TH1F *h3; + TH1F* fh_TimePreviousEvent; + + TH1F* fh_sci8_channels; + TH1F* fh_sci8_tres_MCFD; + TH1F* fh_sci8_tres_TAMEX; + TH1F* fh_sci8_tot_mean; + TH1F* fh_tof_sci8; + TH2F* fh_sci8_tot; + TH1F* fh_sci8_dt_hits; + TH1F* fh_sci8_dt_hits_l; + TH1F* fh_sci8_dt_hits_t; + TH1F* fh_sci8_multihit; + TH2F* fh_sci8_multihitVFTX; + TH2F* fh_sci8_multihitLEAD; + TH2F* fh_sci8_multihitTRAI; + + TH2F* fh_rolu_tot; + TH1F* fh_rolu_channels; + + TH1F* fh_los_channels[NOF_LOS_DET]; + TH1F* fh_los_tres_MCFD[NOF_LOS_DET]; + TH1F* fh_los_tres_TAMEX[NOF_LOS_DET]; + TH1F* fh_los_tres_MTDC; + TH1F* fh_los_tot_mean[NOF_LOS_DET]; + TH2F* fh_los_tot[NOF_LOS_DET]; + TH1F* fh_los_multihit[NOF_LOS_DET]; + TH2F* fh_los_multihitVFTX[NOF_LOS_DET]; + TH2F* fh_los_multihitLEAD[NOF_LOS_DET]; + TH2F* fh_los_multihitTRAI[NOF_LOS_DET]; + TH2F* fh_los_pos_MCFD[NOF_LOS_DET]; + TH2F* fh_los_pos_TAMEX[NOF_LOS_DET]; + TH2F* fh_los_pos_ToT[NOF_LOS_DET]; + TH2F* fh_los_ihit_ToT[NOF_LOS_DET]; + TH2F* fh_los_dt_hits_ToT[NOF_LOS_DET]; + TH2F* fh_los_ToT_vs_ToT; + + TH1F* fh_los_TOF[NOF_LOS_DET]; + TH1F* fh_los_dt_hits[NOF_LOS_DET]; + TH2F* fh_los_dt_first_ToT[NOF_LOS_DET]; + TH1F* fh_dt_hits[NOF_LOS_DET]; + + TH1F* fh_channels_Fib[NOF_FIB_DET]; + TH1F* fh_channels_single_Fib[NOF_FIB_DET]; + TH1F* fh_fibers_Fib[NOF_FIB_DET]; + TH1F* fh_mult_Fib[NOF_FIB_DET]; + TH2F* fh_Fib_ToF[NOF_FIB_DET]; + TH2F* fh_Fib_pos_xy[NOF_FIB_DET]; + TH2F* fh_time_Fib[NOF_FIB_DET]; + TH2F* fh_multihit_m_Fib[NOF_FIB_DET]; + TH2F* fh_multihit_s_Fib[NOF_FIB_DET]; + TH2F* fh_ToT_m_Fib[NOF_FIB_DET]; + TH2F* fh_ToT_s_Fib[NOF_FIB_DET]; + TH2F* fh_Fib_vs_Events[NOF_FIB_DET]; + TH2F* fh_ToT_single_Fib[NOF_FIB_DET]; + + TH1F* fh_tofd_channels[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_multihit[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_ToF[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_TotPm[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_dt[3]; + + TH1F* fh_ptof_channels; + TH1F* fh_ptof_channels_cut; + TH1F* fh_ptof_test1; + TH1F* fh_ptof_test2; + TH1F* fh_ptof_TotPm1[N_PADDLE_MAX_PTOF]; + TH1F* fh_ptof_TotPm2[N_PADDLE_MAX_PTOF]; + + TH1F* fh_pspx_channel_x[N_PSPX]; /**< PSPX x channel profile on mapped level */ + TH1F* fh_pspx_channel_y[N_PSPX]; /**< PSPX y channel profile on mapped level */ + TH1F* fh_pspx_multiplicity_x[N_PSPX]; /**< PSPX x multiplicity on mapped level */ + TH1F* fh_pspx_multiplicity_y[N_PSPX]; /**< PSPX y multiplicity on mapped level */ + + TH2F* fh_pspx_strips_position[N_PSPX]; /**< PSPX 2D position on mapped level */ + TH2F* fh_pspx_hit_position[(N_PSPX + 1) / 2]; /**< PSPX 2D position on hit level */ + + TH1F* fh_pspx_hit_energy[(N_PSPX + 1) / 2]; /**< PSPX energy on hit level */ + TH2F* fh_pspx_cal_energy_frontback[N_PSPX]; /**< PSPX energy front vs back on cal level */ + + public: + ClassDef(R3BOnlineSpectraDec2019, 2) +}; + +#endif diff --git a/r3bbase/R3BOnlineSpectraS454.cxx b/r3bbase/R3BOnlineSpectraS454.cxx new file mode 100644 index 000000000..79b75938c --- /dev/null +++ b/r3bbase/R3BOnlineSpectraS454.cxx @@ -0,0 +1,2534 @@ +// ------------------------------------------------------------ +// ----- R3BOnlineSpectra ----- +// ----- Created April 13th 2016 by M.Heil ----- +// ------------------------------------------------------------ + +/* + * This task should fill histograms with detector variables which allow + * to test the detectors online + * + */ + +#include "R3BLosCalData.h" +#include "R3BLosMappedData.h" +#include "R3BOnlineSpectra.h" + +#include "R3BSci8CalData.h" +#include "R3BSci8MappedData.h" + +#include "R3BBeamMonitorMappedData.h" + +#include "R3BTofdCalData.h" +#include "R3BTofdMappedData.h" + +#include "R3BPaddleCalData.h" +#include "R3BPaddleTamexMappedData.h" + +#include "R3BPspxCalData.h" +#include "R3BPspxHitData.h" +#include "R3BPspxMappedData.h" +#include "R3BPspxPrecalData.h" + +#include "R3BEventHeader.h" +#include "R3BTCalEngine.h" + +#include "R3BBunchedFiberCalData.h" +#include "R3BBunchedFiberHitData.h" +#include "R3BBunchedFiberMappedData.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRunOnline.h" +#include "FairRuntimeDb.h" +#include "TCanvas.h" +#include "TGaxis.h" +#include "TH1F.h" +#include "TH2F.h" +#include "THttpServer.h" + +#include "TClonesArray.h" +#include "TMath.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define IS_NAN(x) TMath::IsNaN(x) +using namespace std; + +R3BOnlineSpectra::R3BOnlineSpectra() + : R3BOnlineSpectra("OnlineSpectra", 1) +{ +} + +R3BOnlineSpectra::R3BOnlineSpectra(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fTrigger(-1) + , fTpat(-1) + , fNofPlanes(N_PLANE_MAX_TOFD) + , fPaddlesPerPlane(N_PADDLE_MAX_TOFD) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fNEvents(0) +{ +} + +R3BOnlineSpectra::~R3BOnlineSpectra() +{ + // delete fhTpat ; + // delete fhTrigger; + // delete fh_SEETRAM; + + for (int i = 0; i < NOF_FIB_DET; i++) + { + delete fh_channels_Fib[i]; + delete fh_fibers_Fib[i]; + delete fh_mult_Fib[i]; + delete fh_time_Fib[i]; + delete fh_multihit_m_Fib[i]; + delete fh_multihit_s_Fib[i]; + delete fh_ToT_m_Fib[i]; + delete fh_ToT_s_Fib[i]; + delete fh_ToT_single_Fib[i]; + delete fh_channels_single_Fib[i]; + } +} + +InitStatus R3BOnlineSpectra::Init() +{ + + // Initialize random number: + std::srand(std::time(0)); // use current time as seed for random generator + + LOG(INFO) << "R3BOnlineSpectra::Init "; + + // try to get a handle on the EventHeader. EventHeader may not be + // present though and hence may be null. Take care when using. + + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + LOG(fatal) << "FairRootManager not found"; + + header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); + FairRunOnline* run = FairRunOnline::Instance(); + + run->GetHttpServer()->Register("/Tasks", this); + + // Get objects for detectors on all levels + assert(DET_MAX + 1 == sizeof(fDetectorNames) / sizeof(fDetectorNames[0])); + printf("Have %d fiber detectors.\n", NOF_FIB_DET); + for (int det = 0; det < DET_MAX; det++) + { + fMappedItems.push_back((TClonesArray*)mgr->GetObject(Form("%sMapped", fDetectorNames[det]))); + if (NULL == fMappedItems.at(det)) + { + printf("Could not find mapped data for '%s'.\n", fDetectorNames[det]); + } + fCalItems.push_back((TClonesArray*)mgr->GetObject(Form("%sCal", fDetectorNames[det]))); + fHitItems.push_back((TClonesArray*)mgr->GetObject(Form("%sHit", fDetectorNames[det]))); + } + + //------------------------------------------------------------------------ + // create histograms of all detectors + //------------------------------------------------------------------------ + + //------------------------------------------------------------------------ + // Sci8 detector + + if (fMappedItems.at(DET_SCI8)) + { + TCanvas* cSci8 = new TCanvas("Sci8", "SCI8", 10, 10, 850, 850); + + fh_sci8_channels = new TH1F("sci8_channels", "SCI8 channels", 4, 0., 4.); + fh_sci8_channels->GetXaxis()->SetTitle("Channel number"); + fh_sci8_multihit = new TH1F("sci8_multihit", "SCI8 multihit", 20, 0., 20.); + fh_sci8_multihit->GetXaxis()->SetTitle("Multihit"); + fh_sci8_multihitVFTX = new TH2F("sci8_vftx_multihit", "SCI8 VFTX multihit", 4, 0., 4., 20, 0., 20.); + fh_sci8_multihitVFTX->GetYaxis()->SetTitle("Multihit "); + fh_sci8_multihitVFTX->GetXaxis()->SetTitle("Channel number"); + fh_sci8_multihitLEAD = new TH2F("sci8_lead_multihit", "SCI8 TAMEX Leading multihit", 4, 0., 4., 20, 0., 20.); + fh_sci8_multihitLEAD->GetYaxis()->SetTitle("Multihit "); + fh_sci8_multihitLEAD->GetXaxis()->SetTitle("Channel number"); + fh_sci8_multihitTRAI = new TH2F("sci8_trai_multihit", "SCI8 TAMEX Trailing multihit", 4, 0., 4., 20, 0., 20.); + fh_sci8_multihitTRAI->GetYaxis()->SetTitle("Multihit "); + fh_sci8_multihitTRAI->GetXaxis()->SetTitle("Channel number"); + fh_sci8_dt_hits = new TH1F("sci8_dt_hits", "SCI8 dt multihits", 40000, -2000, 2000); + fh_sci8_dt_hits->GetXaxis()->SetTitle("dt_VFTX between two hits / ns"); + fh_sci8_dt_hits_l = new TH1F("sci8_dt_hits_l", "SCI8 dt multihits leading", 40000, -2000, 2000); + fh_sci8_dt_hits_l->GetXaxis()->SetTitle("dt_LEAD between two hits / ns"); + fh_sci8_dt_hits_t = new TH1F("sci8_dt_hits_t", "SCI8 dt multihits trailing", 40000, -2000, 2000); + fh_sci8_dt_hits_t->GetXaxis()->SetTitle("dt_TRAIL between two hits / ns"); + fh_sci8_tres_MCFD = new TH1F("sci8_time_res_MCFD", "SCI8 MCFD Time resolution - raw", 30000, 0., 300.); + fh_sci8_tres_MCFD->GetXaxis()->SetTitle("Time MCFD / ns"); + fh_sci8_tres_TAMEX = new TH1F("sci8_time_res_TAMEX", "SCI8 TAMEX Time resolution -raw ", 8000, -4., 4.); + fh_sci8_tres_TAMEX->GetXaxis()->SetTitle("Time TAMEX / ns"); + fh_sci8_tot = new TH2F("sci8_tot", "SCI8 ToT vs PM", 4, 0, 4, 3000, 0., 300.); + fh_sci8_tot->GetXaxis()->SetTitle("PMT number"); + fh_sci8_tot->GetYaxis()->SetTitle("ToT / ns"); + fh_sci8_tot_mean = new TH1F("sci8_tot_mean", "SCI8 mean ToT", 30000, 0., 300.); + fh_sci8_tot_mean->GetYaxis()->SetTitle("Counts"); + fh_sci8_tot_mean->GetXaxis()->SetTitle("ToT / ns"); + fh_tof_sci8 = new TH1F("sci8_tof", "SCI8-LOS ToF", 40000, -20, 20); + fh_tof_sci8->GetXaxis()->SetTitle("ToF / ns"); + + cSci8->Divide(3, 3); + cSci8->cd(1); + fh_sci8_channels->Draw(); + cSci8->cd(2); + gPad->SetLogy(); + fh_sci8_multihit->Draw(); + cSci8->cd(3); + gPad->SetLogz(); + fh_sci8_tot->Draw("colz"); + cSci8->cd(4); + fh_sci8_tres_MCFD->Draw(); + cSci8->cd(5); + fh_sci8_tres_TAMEX->Draw(); + cSci8->cd(6); + fh_tof_sci8->Draw(); + cSci8->cd(7); + fh_sci8_tot_mean->Draw(); + + cSci8->cd(0); + run->AddObject(cSci8); + + run->GetHttpServer()->RegisterCommand("Reset_SCI8", Form("/Tasks/%s/->Reset_SCI8_Histo()", GetName())); + } + + if (fMappedItems.at(DET_BMON)) + { + + fh_TimePreviousEvent = new TH1F("TimePreviousEvent", "Time between 2 particles ", 300000, -3000, 3000); + fh_TimePreviousEvent->GetXaxis()->SetTitle("time / µsec"); + fh_TimePreviousEvent->GetYaxis()->SetTitle("counts"); + + // get the theoretical calib factors for SEETRAM + Double_t fexp = float(fsens_SEE + 9); + Double_t fpow = float(pow(10., fexp)); + calib_SEE = 135641.7786 * fpow; + cout << fsens_SEE << ", " << fexp << ", " << fpow << ", " << calib_SEE << endl; + + TCanvas* cbmon = new TCanvas("Beam_Monitor", "Beam Monitors", 820, 10, 900, 900); + Int_t Nbin_bmon = reset_time / read_time; + + fhTpat = new TH1F("Tpat", "Tpat", 20, 0, 20); + fhTpat->GetXaxis()->SetTitle("Tpat value"); + + fhTrigger = new TH1F("Trigger", "Trigger all", 20, 0, 20); + fhTrigger->GetXaxis()->SetTitle("Trigger value"); + + fh_spill_length = new TH1F("spill_length", "Spill ", Nbin_bmon, 0, reset_time); + fh_spill_length->GetXaxis()->SetTitle("time / sec"); + + fh_IC = new TH1F("IC", "IC ", Nbin_bmon, 0, reset_time); + fh_IC->GetXaxis()->SetTitle("time / sec"); + fh_IC->GetYaxis()->SetTitle("IC counts"); + + fh_SEE = new TH1F("SEETRAM", "SEETRAM ", Nbin_bmon, 0, reset_time); + fh_SEE->GetXaxis()->SetTitle("time / sec"); + fh_SEE->GetYaxis()->SetTitle("SEETRAM counts"); + + fh_TOFDOR = new TH1F("TOFDOR", "TOFDOR ", Nbin_bmon, 0, reset_time); + fh_TOFDOR->GetXaxis()->SetTitle("time / sec"); + fh_TOFDOR->GetYaxis()->SetTitle("TOFDOR counts"); + + fh_IC_spill = new TH1F("IC_spill", "IC rate in kHz ", Nbin_bmon, 0, reset_time); + fh_IC_spill->GetXaxis()->SetTitle("time / sec"); + fh_IC_spill->GetYaxis()->SetTitle("IC rate / kHz"); + + fh_SEE_spill = new TH1F("SEE_spill", "SEE particle rate ", Nbin_bmon, 0, reset_time); + fh_SEE_spill->GetXaxis()->SetTitle("time / sec"); + fh_SEE_spill->GetYaxis()->SetTitle("Particles / sec"); + + fh_TOFDOR_spill = new TH1F("TOFDOR_spill", "TOFDOR rate in kHz ", Nbin_bmon, 0, reset_time); + fh_TOFDOR_spill->GetXaxis()->SetTitle("time / sec"); + fh_TOFDOR_spill->GetYaxis()->SetTitle("TOFDOR rate / kHz"); + + cbmon->Divide(3, 3); + cbmon->cd(1); + gPad->SetLogy(); + fhTrigger->Draw(); + cbmon->cd(2); + gPad->SetLogy(); + fhTpat->Draw(); + cbmon->cd(3); + fh_spill_length->Draw(); + cbmon->cd(4); + fh_IC->Draw("hist"); + // fh_TimePreviousEvent->Draw("hist"); + cbmon->cd(5); + fh_SEE->Draw("hist"); + cbmon->cd(6); + fh_TOFDOR->Draw("hist"); + cbmon->cd(7); + fh_IC_spill->Draw("hist"); + cbmon->cd(8); + fh_SEE_spill->Draw("hist"); + cbmon->cd(9); + fh_TOFDOR_spill->Draw("hist"); + cbmon->cd(0); + + run->AddObject(cbmon); + + run->GetHttpServer()->RegisterCommand("Reset_BMON", Form("/Tasks/%s/->Reset_BMON_Histo()", GetName())); + } + + //------------------------------------------------------------------------ + // Los detector + + if (fMappedItems.at(DET_LOS)) + { + TCanvas* cLos = new TCanvas("Los", "LOS", 10, 10, 910, 810); + + fh_los_channels = new TH1F("los_channels", "LOS channels", 10, 0., 10.); + fh_los_channels->GetXaxis()->SetTitle("Channel number"); + fh_los_multihit = new TH1F("los_multihit", "LOS multihit && all 8 PMs", 10, 0., 10.); + fh_los_multihit->GetXaxis()->SetTitle("Multihit"); + + fh_los_pos_MCFD = new TH2F("los_pos_MCFD", "LOS MCFD Position ", 1000, -5., 5., 1000, -5., 5.); + fh_los_pos_MCFD->GetXaxis()->SetTitle("X position / cm"); + fh_los_pos_MCFD->GetYaxis()->SetTitle("Y position / cm"); + fh_los_pos_TAMEX = new TH2F("los_pos_TAMEX", "LOS TAMEX Position ", 1000, -5., 5., 1000, -5., 5.); + fh_los_pos_TAMEX->GetXaxis()->SetTitle("X position / cm"); + fh_los_pos_TAMEX->GetYaxis()->SetTitle("Y position / cm"); + fh_los_pos_ToT = new TH2F("los_pos_ToT", "LOS ToT Position ", 1000, -5., 5., 1000, -5., 5.); + fh_los_pos_ToT->GetXaxis()->SetTitle("X position / cm"); + fh_los_pos_ToT->GetYaxis()->SetTitle("Y position / cm"); + fh_los_dt_hits_ToT = new TH2F("los_dt_ToT", "LOS ToT dt ", 5000, 0, 3000, 500, 0, 200.); + fh_los_dt_hits_ToT->GetXaxis()->SetTitle("dt between two hits / ns"); + fh_los_dt_hits_ToT->GetYaxis()->SetTitle("ToT / ns"); + fh_los_dt_first_ToT = new TH2F("los_dt_events_ToT", "LOS ToT dtevents ", 5000, 0, 150000, 500, 0, 200.); + fh_los_dt_first_ToT->GetXaxis()->SetTitle("dt between two events / ns"); + fh_los_dt_first_ToT->GetYaxis()->SetTitle("ToT / ns"); + + fh_los_dt_hits = new TH1F("los_dt_hits", "LOS dt hits", 100000, 0, 10000); + fh_los_dt_hits->GetXaxis()->SetTitle("dt between two hits / micros"); + fh_los_dt_hits->GetYaxis()->SetTitle("Counts"); + + fh_los_tres_MCFD = new TH1F("los_time_res_MCFD", "LOS MCFD Time resolution - raw", 4000, -4., 4.); + fh_los_tres_MCFD->GetXaxis()->SetTitle("Time MCFD / ns"); + fh_los_tres_TAMEX = new TH1F("los_time_res_TAMEX", "LOS TAMEX Time resolution -raw ", 4000, -4., 4.); + fh_los_tres_TAMEX->GetXaxis()->SetTitle("Time TAMEX / ns"); + fh_los_tot = new TH2F("los_tot", "LOS ToT vs PMT", 10, 0, 10, 3000, 0., 300.); + fh_los_tot->GetXaxis()->SetTitle("PMT number"); + fh_los_tot->GetYaxis()->SetTitle("ToT / ns"); + fh_los_tot_mean = new TH1F("los_tot_mean", "LOS mean ToT", 1500, 0., 300.); + fh_los_tot_mean->GetYaxis()->SetTitle("Counts"); + fh_los_tot_mean->GetXaxis()->SetTitle("ToT / ns"); + fh_los_ihit_ToT = new TH2F("los_tot_ihit", "LOS ToT vs ihit", 10, 0, 10, 3100, -10., 300.); + fh_los_ihit_ToT->GetXaxis()->SetTitle("iHit"); + fh_los_ihit_ToT->GetYaxis()->SetTitle("ToT / ns"); + + cLos->Divide(4, 3); + cLos->cd(1); + fh_los_channels->Draw(); + cLos->cd(2); + gPad->SetLogy(); + fh_los_multihit->Draw(); + cLos->cd(3); + gPad->SetLogz(); + fh_los_tot->Draw("colz"); + cLos->cd(4); + gPad->SetLogy(); + fh_los_tot_mean->Draw(); + cLos->cd(5); + gPad->SetLogz(); + fh_los_ihit_ToT->Draw("colz"); + cLos->cd(6); + gPad->SetLogz(); + fh_los_dt_first_ToT->Draw("colz"); + cLos->cd(7); + gPad->SetLogz(); + fh_los_dt_hits_ToT->Draw("colz"); + cLos->cd(8); + gPad->SetLogy(); + fh_los_tres_MCFD->Draw(); + cLos->cd(9); + gPad->SetLogy(); + fh_los_tres_TAMEX->Draw(); + cLos->cd(10); + gPad->SetLogz(); + fh_los_pos_ToT->Draw("colz"); + cLos->cd(11); + gPad->SetLogz(); + fh_los_pos_MCFD->Draw("colz"); + cLos->cd(12); + gPad->SetLogz(); + fh_los_pos_TAMEX->Draw("colz"); + cLos->cd(0); + run->AddObject(cLos); + + run->GetHttpServer()->RegisterCommand("Reset_LOS", Form("/Tasks/%s/->Reset_LOS_Histo()", GetName())); + } + + //----------------------------------------------------------------------- + // Fiber Detectors 1-NOF_FIB_DET + + char canvName[255]; + TCanvas* FibCanvas[NOF_FIB_DET]; + + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + + std::stringstream fibhitobj; + std::stringstream fibmapobj; + std::stringstream FiName; + std::string temp; + + if (fMappedItems.at(DET_FI_FIRST + ifibcount)) + { + + const char* chistName; + const char* chistTitle; + const char* detName; + std::string tempTitle; + std::string tempName; + std::stringstream tempFibName; + std::string tempFibNames; + std::stringstream tempCanvName; + + detName = fDetectorNames[DET_FI_FIRST + ifibcount]; + + cout << "I am creating canvas " << detName << endl; + + FibCanvas[ifibcount] = new TCanvas(detName, detName, 10, 10, 910, 910); + + // Channels: + fh_channels_Fib[ifibcount] = + new TH1F(Form("%s_channels", detName), Form("%s channels", detName), 520, 0., 520.); + fh_channels_Fib[ifibcount]->GetXaxis()->SetTitle("Channel number"); + fh_channels_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Channels: + fh_channels_single_Fib[ifibcount] = + new TH1F(Form("%s_channels_single", detName), Form("%s channels of single PMTs", detName), 10, 0., 10.); + fh_channels_single_Fib[ifibcount]->GetXaxis()->SetTitle("Channel number"); + fh_channels_single_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Fibers: + fh_fibers_Fib[ifibcount] = + new TH1F(Form("%s_fibers", detName), Form("%s fibers", detName), N_FIBER_PLOT, 0., N_FIBER_PLOT); + fh_fibers_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_fibers_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Multiplicity (number of hit fibers): + fh_mult_Fib[ifibcount] = new TH1F(Form("%s_mult", detName), Form("%s mult", detName), 100, 0., 100.); + fh_mult_Fib[ifibcount]->GetXaxis()->SetTitle("Multiplicity"); + fh_mult_Fib[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // Multihit MAPMT: + fh_multihit_m_Fib[ifibcount] = new TH2F( + Form("%s_multihit_m", detName), Form("%s multihits MAPMT", detName), 520, 0., 520., 20, 0., 20.); + fh_multihit_m_Fib[ifibcount]->GetXaxis()->SetTitle("MAPMT channel"); + fh_multihit_m_Fib[ifibcount]->GetYaxis()->SetTitle("Multihit"); + + // Multihit SAPMT: + fh_multihit_s_Fib[ifibcount] = new TH2F( + Form("%s_multihit_s", detName), Form("%s multihits single PMT", detName), 16, 0., 16., 20, 0., 20.); + fh_multihit_s_Fib[ifibcount]->GetXaxis()->SetTitle("Single PMT channel"); + fh_multihit_s_Fib[ifibcount]->GetYaxis()->SetTitle("Multihit"); + + // ToT MAPMT: + fh_ToT_m_Fib[ifibcount] = new TH2F(Form("%s_tot_m", detName), + Form("%s ToT of MAPMT", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 200, + 0., + 20.); + fh_ToT_m_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_ToT_m_Fib[ifibcount]->GetYaxis()->SetTitle("ToT / ns"); + + // ToT SAPMT: + fh_ToT_s_Fib[ifibcount] = new TH2F(Form("%s_tot_s", detName), + Form("%s ToT of single PMT", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 400, + 0., + 40.); + fh_ToT_s_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_ToT_s_Fib[ifibcount]->GetYaxis()->SetTitle("ToT / ns"); + + // Time of fiber: + fh_time_Fib[ifibcount] = new TH2F(Form("%s_TimevsFiber", detName), + Form("%s Time vs Fiber", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 2048, + -1024., + 1024.); + fh_time_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_time_Fib[ifibcount]->GetYaxis()->SetTitle("tMAPMT-tSPMT"); + + // ToF LOS -> Fiber: + fh_Fib_ToF[ifibcount] = new TH2F(Form("%s_tof", detName), + Form("%s ToF LOS to Fiber", detName), + N_FIBER_PLOT, + 0., + N_FIBER_PLOT, + 10000, + -5000., + 5000.); + fh_Fib_ToF[ifibcount]->GetYaxis()->SetTitle("ToF / ns"); + fh_Fib_ToF[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + + // Not-calibrated position: + fh_Fib_pos[ifibcount] = + new TH1F(Form("%s_pos", detName), Form("%s Not-calibrated position", detName), 2100, -1050., 1050.); + fh_Fib_pos[ifibcount]->GetXaxis()->SetTitle("Position"); + fh_Fib_pos[ifibcount]->GetYaxis()->SetTitle("Counts"); + + // hit fiber number vs. event number: + fh_Fib_vs_Events[ifibcount] = new TH2F(Form("%s_fib_vs_event", detName), + Form("%s Fiber # vs. Event #", detName), + 10000, + 0, + 5e6, + 1100, + 0., + 1100.); + fh_Fib_vs_Events[ifibcount]->GetYaxis()->SetTitle("Fiber number"); + fh_Fib_vs_Events[ifibcount]->GetXaxis()->SetTitle("Event number"); + + // ToT SAPMT: + fh_ToT_single_Fib[ifibcount] = new TH2F( + Form("%s_tot_single", detName), Form("%s ToT of single PMTs", detName), 10, 0., 10., 400, 0., 40.); + fh_ToT_single_Fib[ifibcount]->GetXaxis()->SetTitle("Fiber number"); + fh_ToT_single_Fib[ifibcount]->GetYaxis()->SetTitle("ToT / ns"); + + FibCanvas[ifibcount]->Divide(3, 4); + FibCanvas[ifibcount]->cd(1); + fh_channels_Fib[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(2); + gPad->SetLogz(); + fh_multihit_m_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(3); + gPad->SetLogz(); + fh_multihit_s_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(4); + fh_fibers_Fib[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(5); + fh_mult_Fib[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(6); + gPad->SetLogz(); + fh_ToT_m_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(7); + gPad->SetLogz(); + fh_ToT_s_Fib[ifibcount]->Draw("colz"); + // FibCanvas[ifibcount]->cd(8);gPad->SetLogz(); + // fh_time_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(8); + gPad->SetLogz(); + fh_Fib_ToF[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(9); + fh_Fib_pos[ifibcount]->Draw(); + FibCanvas[ifibcount]->cd(10); + fh_Fib_vs_Events[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(11); + fh_ToT_single_Fib[ifibcount]->Draw("colz"); + FibCanvas[ifibcount]->cd(12); + fh_channels_single_Fib[ifibcount]->Draw(); + + FibCanvas[ifibcount]->cd(0); + run->AddObject(FibCanvas[ifibcount]); + + } // end if(Mapped) + + } // end for(ifibcount) + if (NOF_FIB_DET > 0) + run->GetHttpServer()->RegisterCommand("Reset_Fibers", Form("/Tasks/%s/->Reset_FIBERS_Histo()", GetName())); + + //--------------------------------------------------------------------------------------- + // Ptof detector + + if (fCalItems.at(DET_PTOF)) + { + + TCanvas* cPtof_plane = new TCanvas("Ptof_plane", "Ptof plane", 10, 10, 510, 510); + cPtof_plane->Divide(1, 2); + + fh_ptof_channels = new TH1F("Ptof_channels", "Ptof channels", 65, 0., 65.); + cPtof_plane->cd(1); + fh_ptof_channels->Draw(); + + fh_ptof_channels_cut = new TH1F("Ptof_channels_cut", "Ptof channels with cut", 65, 0., 65.); + cPtof_plane->cd(2); + fh_ptof_channels_cut->Draw(); + run->AddObject(cPtof_plane); + + TCanvas* cPtof_test = new TCanvas("Ptof_test", "Ptof test", 10, 10, 510, 510); + cPtof_test->Divide(1, 1); + + fh_ptof_test1 = new TH1F("Ptof_test1", "Ptof test1", 1000, 0., 100.); + fh_ptof_test2 = new TH1F("Ptof_test2", "Ptof test2", 1000, 0., 100.); + cPtof_test->cd(1); + fh_ptof_test1->Draw(); + // cPtof_test->cd(2); + // fh_ptof_test2->Draw(); + + run->AddObject(cPtof_test); + + TCanvas* cPtof1; + cPtof1 = new TCanvas("Ptof1", "Ptof1", 10, 10, 500, 500); + cPtof1->Divide(3, 3); + for (Int_t j = 1; j < 10; j++) + { + char strName[255]; + sprintf(strName, "ToT_Bar_%d_PM_1", j); + fh_ptof_TotPm1[j] = new TH1F(strName, "", 1000, 0., 100.); + cPtof1->cd(j); + fh_ptof_TotPm1[j]->Draw(); + } + run->AddObject(cPtof1); + + TCanvas* cPtof2; + cPtof2 = new TCanvas("Ptof2", "Ptof2", 10, 10, 500, 500); + cPtof2->Divide(3, 3); + for (Int_t j = 1; j < 10; j++) + { + char strName[255]; + sprintf(strName, "ToT_Bar_%d_PM_2", j); + fh_ptof_TotPm2[j] = new TH1F(strName, "", 1000, 0., 100.); + cPtof2->cd(j); + fh_ptof_TotPm2[j]->Draw(); + } + run->AddObject(cPtof2); + } + + //--------------------------------------------------------------------------------------------------- + // TofD detector + + if (fMappedItems.at(DET_TOFD)) + { + TCanvas* cTofd_planes = new TCanvas("TOFD_planes", "TOFD planes", 10, 10, 1100, 1000); + cTofd_planes->Divide(5, 4); + + for (Int_t j = 0; j < 4; j++) + { + char strName1[255]; + sprintf(strName1, "tofd_channels_plane_%d", j + 1); + char strName2[255]; + sprintf(strName2, "Tofd channels plane %d", j + 1); + fh_tofd_channels[j] = new TH1F(strName1, strName2, 90, -45., 45.); + fh_tofd_channels[j]->GetXaxis()->SetTitle("Channel"); + fh_tofd_channels[j]->GetYaxis()->SetTitle("Counts"); + + char strName3[255]; + sprintf(strName3, "tofd_ToT_plane_%d", j + 1); + char strName4[255]; + sprintf(strName4, "Tofd ToT plane %d", j + 1); + fh_tofd_TotPm[j] = new TH2F(strName3, strName4, 90, -45, 45, 3000, 0., 300.); + fh_tofd_TotPm[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_TotPm[j]->GetYaxis()->SetTitle("ToT / ns"); + + char strName7[255]; + sprintf(strName7, "tofd_ToF_plane_%d", j + 1); + char strName8[255]; + sprintf(strName8, "TOFD-LOS ToF plane %d", j + 1); + fh_tofd_ToF[j] = new TH2F(strName7, strName8, 15, 0, 15, 1000, 0, 100); + fh_tofd_ToF[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_ToF[j]->GetYaxis()->SetTitle("ToF / ns"); + + char strName9[255]; + sprintf(strName9, "tofd_multihit_plane_%d", j + 1); + char strName10[255]; + sprintf(strName10, "Tofd multihit plane %d", j + 1); + fh_tofd_multihit[j] = new TH2F(strName9, strName10, 45, 0., 45., 10, 0, 10); + fh_tofd_multihit[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_multihit[j]->GetYaxis()->SetTitle("Multihit"); + + if (j < 3) + { + int jk = j + 1; + char strName5[255]; + sprintf(strName5, "tofd_ToF_plane_%d_%d", jk, jk + 1); + char strName6[255]; + sprintf(strName6, "Tofd ToF plane %d and %d ", jk, jk + 1); + fh_tofd_dt[j] = new TH2F(strName5, strName6, 50, 0, 50, 800, -40., 40); + fh_tofd_dt[j]->GetXaxis()->SetTitle("Bar number"); + fh_tofd_dt[j]->GetYaxis()->SetTitle("dt / ns"); + } + } + + cTofd_planes->cd(1); + fh_tofd_channels[0]->Draw(); + cTofd_planes->cd(2); + gPad->SetLogz(); + fh_tofd_TotPm[0]->Draw("colz"); + cTofd_planes->cd(3); + gPad->SetLogz(); + fh_tofd_ToF[0]->Draw("colz"); + cTofd_planes->cd(4); + gPad->SetLogz(); + fh_tofd_multihit[0]->Draw("colz"); + + cTofd_planes->cd(6); + fh_tofd_channels[1]->Draw(); + cTofd_planes->cd(7); + gPad->SetLogz(); + fh_tofd_TotPm[1]->Draw("colz"); + cTofd_planes->cd(8); + gPad->SetLogz(); + fh_tofd_ToF[1]->Draw("colz"); + cTofd_planes->cd(9); + gPad->SetLogz(); + fh_tofd_multihit[1]->Draw("colz"); + cTofd_planes->cd(10); + gPad->SetLogz(); + fh_tofd_dt[0]->Draw("colz"); + + cTofd_planes->cd(11); + fh_tofd_channels[2]->Draw(); + cTofd_planes->cd(12); + gPad->SetLogz(); + fh_tofd_TotPm[2]->Draw("colz"); + cTofd_planes->cd(13); + gPad->SetLogz(); + fh_tofd_ToF[2]->Draw("colz"); + cTofd_planes->cd(14); + gPad->SetLogz(); + fh_tofd_multihit[2]->Draw("colz"); + cTofd_planes->cd(15); + gPad->SetLogz(); + fh_tofd_dt[1]->Draw("colz"); + + cTofd_planes->cd(16); + fh_tofd_channels[3]->Draw(); + cTofd_planes->cd(17); + gPad->SetLogz(); + fh_tofd_TotPm[3]->Draw("colz"); + cTofd_planes->cd(18); + gPad->SetLogz(); + fh_tofd_ToF[3]->Draw("colz"); + cTofd_planes->cd(19); + gPad->SetLogz(); + fh_tofd_multihit[3]->Draw("colz"); + cTofd_planes->cd(20); + gPad->SetLogz(); + fh_tofd_dt[2]->Draw("colz"); + + cTofd_planes->cd(0); + run->AddObject(cTofd_planes); + + run->GetHttpServer()->RegisterCommand("Reset_TOFD", Form("/Tasks/%s/->Reset_TOFD_Histo()", GetName())); + } + + // ------------------------------------------------------------------------- + + //------------------------------------------------------------------------ + // PSPX detector + // get access to data + TCanvas* cPspx_comp = new TCanvas("Pspx_comp", "Pspx Comparison", 10, 10, 1100, 1000); + cPspx_comp->Divide(N_PSPX, 3); + + Int_t Emax = 1000000; + + if (fMappedItems.at(DET_PSPX)) + { + // LOG(INFO) << "Init MappedPspx"; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + if (i % 2 == 0) + { // even numbers = read out with energy filter + fh_pspx_channel_x[i] = + new TH1F(Form("pspx_%d_energyreadout_channel_x", i / 2), + Form("Pspx %d Energy Readout: x Channel;x Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 1, + 2 * N_STRIPS_PSPX + 1); + fh_pspx_channel_y[i] = + new TH1F(Form("pspx_%d_energyreadout_channel_y", i / 2), + Form("Pspx %d Energy Readout: y Channel;y Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 2 * N_STRIPS_PSPX + 1, + 4 * N_STRIPS_PSPX + 1); + + fh_pspx_multiplicity_x[i] = + new TH1F(Form("pspx_%d_energyreadout_multiplicity_x", i / 2), + Form("Pspx %d Energy Readout: x Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_multiplicity_y[i] = + new TH1F(Form("pspx_%d_energyreadout_multiplicity_y", i / 2), + Form("Pspx %d Energy Readout: y Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_strips_position[i] = new TH2F( + Form("pspx_%d_energyreadout_strips", i), + Form("Pspx %d Energy Readout Position;x Position / Strips; y Position / Strips", i / 2 + 1), + N_STRIPS_PSPX, + 1, + N_STRIPS_PSPX + 1, + N_STRIPS_PSPX, + N_STRIPS_PSPX + 1, + 2 * N_STRIPS_PSPX + 1); + } + else + { // odd numbers = read out with position filter + fh_pspx_channel_x[i] = + new TH1F(Form("pspx_%d_positionreadout_channel_x", i / 2), + Form("Pspx %d Position Readout: x Channel;x Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 1, + 2 * N_STRIPS_PSPX + 1); + fh_pspx_channel_y[i] = + new TH1F(Form("pspx_%d_positionreadout_channel_y", i / 2), + Form("Pspx %d Position Readout: y Channel;y Position / Channel;Counts", i / 2 + 1), + 2 * N_STRIPS_PSPX, + 2 * N_STRIPS_PSPX + 1, + 4 * N_STRIPS_PSPX + 1); + + fh_pspx_multiplicity_x[i] = + new TH1F(Form("pspx_%d_positionreadout_multiplicity_x", i / 2), + Form("Pspx %d Position Readout: x Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_multiplicity_y[i] = + new TH1F(Form("pspx_%d_positionreadout_multiplicity_y", i / 2), + Form("Pspx %d Position Readout: y Multiplicity;Multiplicity;Counts", i / 2 + 1), + 10, + 0, + 10); + fh_pspx_strips_position[i] = new TH2F( + Form("pspx_%d_positionreadout_strips", i), + Form("Pspx %d Position Readout Position;x Position / Strips; y Position / Strips", i / 2 + 1), + N_STRIPS_PSPX, + 1, + N_STRIPS_PSPX + 1, + N_STRIPS_PSPX, + N_STRIPS_PSPX + 1, + 2 * N_STRIPS_PSPX + 1); + } + } + + TCanvas* cPspx_strips = new TCanvas("Pspx_strips", "Pspx Strips", 10, 10, 1100, 1000); + cPspx_strips->Divide(N_PSPX, 2); + + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_strips->cd(i + 1); + fh_pspx_channel_x[i]->Draw(); + + cPspx_strips->cd(i + 1 + N_PSPX); + fh_pspx_channel_y[i]->Draw(); + } + + run->AddObject(cPspx_strips); + + TCanvas* cPspx_multiplicity = new TCanvas("Pspx_multiplicity", "Pspx Multiplicity", 10, 10, 1100, 1000); + cPspx_multiplicity->Divide(N_PSPX, 2); + + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_multiplicity->cd(i + 1); + fh_pspx_multiplicity_x[i]->Draw(); + + cPspx_multiplicity->cd(i + 1 + N_PSPX); + fh_pspx_multiplicity_y[i]->Draw(); + } + + run->AddObject(cPspx_multiplicity); + + // Fill cPspx_comp with Mapped level data + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_comp->cd(i + 1); + fh_pspx_strips_position[i]->Draw("colz"); + + // Remove the current axis + fh_pspx_strips_position[i]->GetYaxis()->SetLabelOffset(999); + fh_pspx_strips_position[i]->GetYaxis()->SetTickLength(0); + + // Redraw the new inverted axis + gPad->Update(); + TGaxis* newaxis = new TGaxis(gPad->GetUxmin(), + gPad->GetUymax(), + gPad->GetUxmin() - 0.001, + gPad->GetUymin(), + fh_pspx_strips_position[i]->GetYaxis()->GetXmin(), + fh_pspx_strips_position[i]->GetYaxis()->GetXmax(), + 510, + "+"); + newaxis->SetLabelOffset(0.003); + newaxis->SetLabelSize(0.03); + newaxis->SetTickLength(0.025); + newaxis->Draw(); + } + } + + if (fCalItems.at(DET_PSPX)) + { + UInt_t nbins = 200; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + if (i % 2 == 0) + { + fh_pspx_cal_energy_frontback[i] = + new TH2F(Form("pspx_%d_energy_frontback", i / 2), + Form("Pspx %d Energy Back vs Front;Front Energy / arb.u.;Back Energy / arb.u.", i / 2 + 1), + nbins, + 0, + Emax, + nbins, + -Emax, + 0); + } + else + { + fh_pspx_cal_energy_frontback[i] = + new TH2F(Form("pspx_%d_position_frontback", i / 2), + Form("Pspx %d Energy Back vs Front;Front Energy / arb.u.;Back Energy / arb.u.", i / 2 + 1), + nbins, + 0, + Emax / 4, + nbins, + -Emax / 4, + 0); + } + } + + /*fh_pspx_cal_energy_corr[i] = + new TH2F("pspx_%d_energy_corr", + "Pspx %d Energy PSP2 vs. PSP3;PSP2 Energy / arb.u.;PSP3 Energy / arb.u.", + nbins, + 0, + Emax, + nbins, + 0, + Emax); + */ + + // Fill cPspx_comp with Cal level data + for (UInt_t i = 0; i < N_PSPX; i++) + { + cPspx_comp->cd(i + 1 + N_PSPX); // i*2 + fh_pspx_cal_energy_frontback[i]->Draw("colz"); + } + } + + if (fHitItems.at(DET_PSPX)) + { + UInt_t nbins = 100; + Double_t length = 10; // detector length, range of histogram + + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + fh_pspx_hit_position[i] = new TH2F(Form("pspx_%d_position_cm", i), + Form("Pspx %d Position;x Position / cm; y Position / cm", i + 1), + nbins, + -length / 4., + length / 4., + nbins, + -length / 4., + length / 4.); + + fh_pspx_hit_energy[i] = new TH1F( + Form("pspx_%d_energy", i), Form("Pspx %d Energy;Energy / arb.u.; Counts", i + 1), nbins, -Emax, Emax); + } + + TCanvas* cPspx_hit = new TCanvas("Pspx_hit", "Pspx Hit", 10, 10, 1100, 1000); + cPspx_hit->Divide((N_PSPX + 1) / 2, 2); + + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + cPspx_hit->cd(i + 1); + fh_pspx_hit_position[i]->Draw("colz"); + + cPspx_hit->cd(i + 1 + (N_PSPX + 1) / 2); + fh_pspx_hit_energy[i]->Draw(); + } + + run->AddObject(cPspx_hit); + + // Fill cPspx_comp with Hit level data-((channel_y[i][0] + 1) / 2) + 3 * N_STRIPS_PSPX + 1) + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + cPspx_comp->cd(i * 2 + 2 * N_PSPX + 1); // supposed to be +2 if + // energy and position + // readout is used + fh_pspx_hit_position[i]->Draw("colz"); + } + } + + run->AddObject(cPspx_comp); + + run->GetHttpServer()->RegisterCommand("Reset_PSPX", Form("/Tasks/%s/->Reset_PSPX_Histo()", GetName())); + + // ------------------------------------------------------------------------- + + return kSUCCESS; +} + +void R3BOnlineSpectra::Reset_LOS_Histo() +{ + fh_los_channels->Reset(); + fh_los_tres_MCFD->Reset(); + fh_los_tres_TAMEX->Reset(); + fh_los_pos_ToT->Reset(); + fh_los_tot->Reset(); + fh_los_tot_mean->Reset(); + fh_los_pos_MCFD->Reset(); + fh_los_pos_TAMEX->Reset(); + fh_los_dt_hits->Reset(); + fh_los_multihit->Reset(); + fh_los_ihit_ToT->Reset(); +} + +void R3BOnlineSpectra::Reset_BMON_Histo() +{ + fhTrigger->Reset(); + fhTpat->Reset(); + fh_spill_length->Reset(); + fh_IC->Reset(); + fh_IC_spill->Reset(); + fh_SEE->Reset(); + fh_SEE_spill->Reset(); + fh_TOFDOR->Reset(); + fh_TOFDOR_spill->Reset(); +} + +void R3BOnlineSpectra::Reset_SCI8_Histo() +{ + fh_sci8_channels->Reset(); + fh_sci8_tres_MCFD->Reset(); + fh_sci8_tres_TAMEX->Reset(); + fh_sci8_tot->Reset(); + fh_sci8_tot_mean->Reset(); + fh_sci8_dt_hits->Reset(); + fh_sci8_dt_hits_l->Reset(); + fh_sci8_dt_hits_t->Reset(); + fh_sci8_multihit->Reset(); + fh_sci8_multihitVFTX->Reset(); + fh_sci8_multihitLEAD->Reset(); + fh_sci8_multihitTRAI->Reset(); + fh_tof_sci8->Reset(); +} +void R3BOnlineSpectra::Reset_TOFD_Histo() +{ + for (int i = 0; i < N_PLANE_MAX_TOFD; i++) + { + fh_tofd_channels[i]->Reset(); + fh_tofd_multihit[i]->Reset(); + fh_tofd_ToF[i]->Reset(); + fh_tofd_TotPm[i]->Reset(); + } + fh_tofd_dt[0]->Reset(); + fh_tofd_dt[1]->Reset(); + fh_tofd_dt[2]->Reset(); +} +void R3BOnlineSpectra::Reset_FIBERS_Histo() +{ + if (fMappedItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_channel_x[i]->Reset(); + fh_pspx_channel_y[i]->Reset(); + fh_pspx_multiplicity_x[i]->Reset(); + fh_pspx_multiplicity_y[i]->Reset(); + fh_pspx_strips_position[i]->Reset(); + } + } + if (fCalItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_cal_energy_frontback[i]->Reset(); + } + } + if (fHitItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX / 2; i++) + { + fh_pspx_hit_position[i]->Reset(); + fh_pspx_hit_energy[i]->Reset(); + } + } + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + if (fMappedItems.at(DET_FI_FIRST + ifibcount)) + { + fh_channels_Fib[ifibcount]->Reset(); + fh_multihit_m_Fib[ifibcount]->Reset(); + fh_multihit_s_Fib[ifibcount]->Reset(); + fh_fibers_Fib[ifibcount]->Reset(); + fh_mult_Fib[ifibcount]->Reset(); + fh_ToT_m_Fib[ifibcount]->Reset(); + fh_ToT_s_Fib[ifibcount]->Reset(); + fh_ToT_single_Fib[ifibcount]->Reset(); + fh_Fib_ToF[ifibcount]->Reset(); + fh_Fib_pos[ifibcount]->Reset(); + fh_Fib_vs_Events[ifibcount]->Reset(); + fh_channels_single_Fib[ifibcount]->Reset(); + } + } +} + +void R3BOnlineSpectra::Exec(Option_t* option) +{ + // cout << "fNEvents " << fNEvents << endl; + + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + { + // FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, "FairRootManager not found"); + LOG(ERROR) << "FairRootManager not found"; + return; + } + + time = header->GetTimeStamp(); + + if (time_start == 0 && time > 0) + { + time_start = time; + fNEvents_start = fNEvents; + } + Bool_t spectra_clear = false; + Double_t xtime = double(time - time_start) / 1.e9; + // for reseting spectra + Int_t icount = iclear_count * reset_time; // reset after reset_time (sec) + if (time_clear < 0. && int(xtime) % icount == 0 && xtime > 1.) + { + time_clear = xtime; + spectra_clear = true; + } + + if (header->GetTrigger() == 12) + time_spill_start = header->GetTimeStamp(); // spill start in nsec + if (header->GetTrigger() == 13) + time_spill_end = header->GetTimeStamp(); // spill end in nsec + + if (header->GetTrigger() == 12) + cout << "Spill start: " << double(time_spill_start - time_start) / 1.e9 << " sec" << endl; + if (header->GetTrigger() == 13) + cout << "Spill stop: " << double(time_spill_end - time_start) / 1.e9 << " sec" << endl; + + if (fMappedItems.at(DET_BMON)) + { + fhTrigger->Fill(header->GetTrigger()); + } + + // check for requested trigger (Todo: should be done globablly / somewhere else) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + + if (fMappedItems.at(DET_BMON)) + { + Int_t tpatbin; + for (int i = 0; i < 16; i++) + { + tpatbin = (header->GetTpat() & (1 << i)); + if (tpatbin != 0) + fhTpat->Fill(i + 1); + } + } + + // fTpat = 1-16; fTpat_bit = 0-15 + Int_t fTpat_bit = fTpat - 1; + Int_t itpat; + Int_t tpatvalue; + if (fTpat_bit >= 0) + { + itpat = header->GetTpat(); + tpatvalue = (itpat && (1 << fTpat_bit)) >> fTpat_bit; + if ((tpatvalue == 0)) + return; + } + + if (fMappedItems.at(DET_BMON)) + { + unsigned long IC; + unsigned long SEETRAM, SEETRAM_raw; + unsigned long TOFDOR; + + Bool_t bmon_read = false; + + auto det = fMappedItems.at(DET_BMON); + Int_t nHitsbm = det->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHitsbm; ihit++) + { + R3BBeamMonitorMappedData* hit = (R3BBeamMonitorMappedData*)det->At(ihit); + if (!hit) + continue; + + IC = hit->GetIC(); // negative values if offset not high enough + SEETRAM_raw = hit->GetSEETRAM(); // raw counts + TOFDOR = hit->GetTOFDOR(); // only positive values possible + SEETRAM = SEETRAM_raw * calib_SEE; // calibrated SEETRAM counts + + if (fNEvents == fNEvents_start) + { + see_mem = SEETRAM; + ic_mem = IC; + tofdor_mem = TOFDOR; + time_mem = time_start; + see_start = SEETRAM; + ic_start = IC; + tofdor_start = TOFDOR; + time_prev_read = time_start; + } + + if (time > 0) + { + + // cout<Fill((time - time_mem) / 1e9); + + // Spectra below are filled every read_time (secs) + if (time_to_read == 0 && (time - time_prev_read) >= read_time * 1000000000) + { + time_to_read = time; + bmon_read = true; + } + + if (bmon_read) + { + + tdiff = double(time - time_mem) / 1.e9; + fNorm = 1.e-3 / (double(time - time_prev_read) / 1.e9); // kHz + + // IC: + Int_t yIC = IC - ic_start; + fh_IC->Fill(tdiff, yIC); + fh_IC_spill->Fill(tdiff, (IC - ic_mem) * fNorm); + ic_mem = IC; + + // SEETRAM: + Int_t ySEE = SEETRAM - see_start; + fh_SEE->Fill(tdiff, ySEE); + Double_t ySEE_part = (SEETRAM - see_mem) * fNorm * 1.e+3 - see_offset * calib_SEE; + fh_SEE_spill->Fill(tdiff, ySEE_part); + see_mem = SEETRAM; + + // TOFDOR: + Int_t yTOFDOR = TOFDOR - tofdor_start; + fh_TOFDOR->Fill(tdiff, yTOFDOR); + fh_TOFDOR_spill->Fill(tdiff, (TOFDOR - tofdor_mem) * fNorm); + tofdor_mem = TOFDOR; + + time_to_read = 0; + time_prev_read = time; + bmon_read = false; + } + + if (spectra_clear) + { + fh_spill_length->Reset(); + fh_IC_spill->Reset("ICESM"); + fh_SEE_spill->Reset("ICESM"); + fh_TOFDOR_spill->Reset("ICESM"); + fh_IC->Reset("ICESM"); + fh_SEE->Reset("ICESM"); + fh_TOFDOR->Reset("ICESM"); + time_mem = time; + time_clear = -1.; + iclear_count = iclear_count + 1; + spectra_clear = false; + see_start = SEETRAM; + ic_start = IC; + tofdor_start = TOFDOR; + } + } + } + } + + //---------------------------------------------------------------------- + // LOS detector + //---------------------------------------------------------------------- + // Time nomenclature for LOS: + // lt=0, l=1,lb=2,b=3,rb=4,r=5,rt=6,t=7 + // t / \lt + // rt| |l + // r | |lb + // rb\ /b + + Double_t timeTofd = 0; + Double_t time_V[10][8] = { 0.0 / 0.0 }; // [multihit][pm] + Double_t time_L[10][8] = { 0.0 / 0.0 }; + Double_t time_T[10][8] = { 0.0 / 0.0 }; + Double_t timeLosM[10] = { 0.0 }; + Double_t LosTresM[10] = { 0.0 / 0.0 }; + Double_t timeLosT[10] = { 0.0 }; + Double_t LosTresT[10] = { 0.0 / 0.0 }; + Double_t timeLos[10] = { 0.0 }; + Double_t totsum[10] = { 0.0 }; + Double_t tot[10][8] = { 0.0 / 0.0 }; + Double_t xT_cm[10] = { 0.0 / 0.0 }; + Double_t yT_cm[10] = { 0.0 / 0.0 }; + Double_t xToT_cm[10] = { 0.0 / 0.0 }; + Double_t yToT_cm[10] = { 0.0 / 0.0 }; + Double_t xV_cm[10] = { 0.0 / 0.0 }; + Double_t yV_cm[10] = { 0.0 / 0.0 }; + Double_t time_V_temp[10][8] = { 0.0 / 0.0 }; + + Int_t Multip; + + if (fMappedItems.at(DET_LOS)) + { + auto det = fMappedItems.at(DET_LOS); + Int_t nHits = det->GetEntriesFast(); + + Multip = nHits; + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BLosMappedData* hit = (R3BLosMappedData*)det->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iDet = hit->GetDetector(); // 1.. + Int_t iCha = hit->GetChannel(); // 1.. + + fh_los_channels->Fill(iCha); + } + } + + Int_t nPart; + if (fCalItems.at(DET_LOS)) + { + Bool_t LOSID = false; + + auto det = fCalItems.at(DET_LOS); + nPart = det->GetEntriesFast(); + + Int_t iDet = 0; + + for (Int_t iPart = 0; iPart < nPart; iPart++) + { + /* + * nPart is the number of particle passing through LOS detector in one event + */ + R3BLosCalData* calData = (R3BLosCalData*)det->At(iPart); + iDet = calData->GetDetector(); + + for (Int_t iCha = 0; iCha < 8; iCha++) + { + + time_V[iPart][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeV_ns(iCha)))) + { // VFTX + time_V[iPart][iCha] = calData->GetTimeV_ns(iCha); + } + + time_L[iPart][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeL_ns(iCha)))) + { // TAMEX leading + time_L[iPart][iCha] = calData->GetTimeL_ns(iCha); + } + time_T[iPart][iCha] = 0. / 0.; + if (!(IS_NAN(calData->GetTimeT_ns(iCha)))) + { // TAMEX trailing + time_T[iPart][iCha] = calData->GetTimeT_ns(iCha); + } + } + + if (!calData) + { + cout << "LOS !calData" << endl; + continue; // can this happen? + } + } + + // Sorting VFTX data: + + std::qsort(time_V, nPart, sizeof(*time_V), [](const void* arg1, const void* arg2) -> int { + double const* lhs = static_cast(arg1); + double const* rhs = static_cast(arg2); + + return (lhs[0] < rhs[0]) ? -1 : ((rhs[0] < lhs[0]) ? 1 : 0); + }); + // End sorting + double_t time_first = -1.; + double_t time1 = -1.; + + for (Int_t iPart = 0; iPart < nPart; iPart++) + { + + Bool_t iLOSTypeMCFD = false; + Bool_t iLOSTypeTAMEX = false; + Bool_t iLOSType = false; + + if (time_V[iPart][0] > 0. && !(IS_NAN(time_V[iPart][0])) && time_V[iPart][1] > 0. && + !(IS_NAN(time_V[iPart][1])) && time_V[iPart][2] > 0. && !(IS_NAN(time_V[iPart][2])) && + time_V[iPart][3] > 0. && !(IS_NAN(time_V[iPart][3])) && time_V[iPart][4] > 0. && + !(IS_NAN(time_V[iPart][4])) && time_V[iPart][5] > 0. && !(IS_NAN(time_V[iPart][5])) && + time_V[iPart][6] > 0. && !(IS_NAN(time_V[iPart][6])) && time_V[iPart][7] > 0. && + !(IS_NAN(time_V[iPart][7]))) + { + iLOSTypeMCFD = true; // all 8 MCFD times + } + + if (time_L[iPart][0] > 0. && !(IS_NAN(time_L[iPart][0])) && time_L[iPart][1] > 0. && + !(IS_NAN(time_L[iPart][1])) && time_L[iPart][2] > 0. && !(IS_NAN(time_L[iPart][2])) && + time_L[iPart][3] > 0. && !(IS_NAN(time_L[iPart][3])) && time_L[iPart][4] > 0. && + !(IS_NAN(time_L[iPart][4])) && time_L[iPart][5] > 0. && !(IS_NAN(time_L[iPart][5])) && + time_L[iPart][6] > 0. && !(IS_NAN(time_L[iPart][6])) && time_L[iPart][7] > 0. && + !(IS_NAN(time_L[iPart][7])) && + + time_T[iPart][0] > 0. && !(IS_NAN(time_T[iPart][0])) && time_T[iPart][1] > 0. && + !(IS_NAN(time_T[iPart][1])) && time_T[iPart][2] > 0. && !(IS_NAN(time_T[iPart][2])) && + time_T[iPart][3] > 0. && !(IS_NAN(time_T[iPart][3])) && time_T[iPart][4] > 0. && + !(IS_NAN(time_T[iPart][4])) && time_T[iPart][5] > 0. && !(IS_NAN(time_T[iPart][5])) && + time_T[iPart][6] > 0. && !(IS_NAN(time_T[iPart][6])) && time_T[iPart][7] > 0. && + !(IS_NAN(time_T[iPart][7]))) + { + iLOSTypeTAMEX = true; // all 8 leading and trailing times + } + + // We will consider only events in which booth MCFD and TAMEX see same number of channels: + if (iLOSTypeTAMEX && iLOSTypeMCFD) + iLOSType = true; + + if (iDet == 1) + { + + if (1 == 1) //(iLOSType) + { + + int nPMT = 0; + int nPMV = 0; + + for (int ipm = 0; ipm < 8; ipm++) + { + + tot[iPart][ipm] = 0. / 0.; + if (time_T[iPart][ipm] > 0. && time_L[iPart][ipm] > 0. && !(IS_NAN(time_T[iPart][ipm])) && + !(IS_NAN(time_L[iPart][ipm]))) + { + while (time_T[iPart][ipm] - time_L[iPart][ipm] <= 0.) + { + time_T[iPart][ipm] = time_T[iPart][ipm] + 2048. * fClockFreq; + } + + nPMT = nPMT + 1; + tot[iPart][ipm] = time_T[iPart][ipm] - time_L[iPart][ipm]; + } + + if (tot[iPart][ipm] != 0. && !(IS_NAN(tot[iPart][ipm]))) + totsum[iPart] += tot[iPart][ipm]; + + if (time_L[iPart][ipm] > 0. && !(IS_NAN(time_L[iPart][ipm]))) + timeLosT[iPart] += time_L[iPart][ipm]; + + if (time_V[iPart][ipm] > 0. && !(IS_NAN(time_V[iPart][ipm]))) + { + timeLosM[iPart] += time_V[iPart][ipm]; + nPMV = nPMV + 1; + } + } + + totsum[iPart] = totsum[iPart] / nPMT; + + timeLosM[iPart] = timeLosM[iPart] / nPMV; + + timeLosT[iPart] = timeLosT[iPart] / nPMT; + + timeLos[iPart] = timeLosM[iPart]; + + LosTresM[iPart] = ((time_V[iPart][0] + time_V[iPart][2] + time_V[iPart][4] + time_V[iPart][6]) - + (time_V[iPart][1] + time_V[iPart][3] + time_V[iPart][5] + time_V[iPart][7])) / + 4.; + + LosTresT[iPart] = ((time_L[iPart][0] + time_L[iPart][2] + time_L[iPart][4] + time_L[iPart][6]) - + (time_L[iPart][1] + time_L[iPart][3] + time_L[iPart][5] + time_L[iPart][7])) / + 4.; + + // Position from tamex: + xT_cm[iPart] = + ((time_L[iPart][5] + time_L[iPart][6]) / 2. - (time_L[iPart][1] + time_L[iPart][2]) / 2.) * + (-1.); + yT_cm[iPart] = + ((time_L[iPart][7] + time_L[iPart][0]) / 2. - (time_L[iPart][3] + time_L[iPart][4]) / 2.) * + (-1.); + xT_cm[iPart] = (xT_cm[iPart] - flosOffsetXT) * flosVeffXT; + yT_cm[iPart] = (yT_cm[iPart] - flosOffsetYT) * flosVeffYT; + + // Position from VFTX: + xV_cm[iPart] = + ((time_V[iPart][5] + time_V[iPart][6]) / 2. - (time_V[iPart][1] + time_V[iPart][2]) / 2.) * + (-1.); + yV_cm[iPart] = + ((time_V[iPart][7] + time_V[iPart][0]) / 2. - (time_V[iPart][3] + time_V[iPart][4]) / 2.) * + (-1.); + xV_cm[iPart] = (xV_cm[iPart] - flosOffsetXV) * flosVeffXV; + yV_cm[iPart] = (yV_cm[iPart] - flosOffsetYV) * flosVeffYV; + + // Position from ToT: + xToT_cm[iPart] = (((tot[iPart][5] + tot[iPart][6]) / 2. - (tot[iPart][1] + tot[iPart][2]) / 2.) / + ((tot[iPart][1] + tot[iPart][2] + tot[iPart][5] + tot[iPart][6]) / 4.)); + + yToT_cm[iPart] = (((tot[iPart][0] + tot[iPart][7]) / 2. - (tot[iPart][3] + tot[iPart][4]) / 2.) / + ((tot[iPart][7] + tot[iPart][0] + tot[iPart][3] + tot[iPart][4]) / 4.)); + + xToT_cm[iPart] = (xToT_cm[iPart] - flosOffsetXQ) * flosVeffXQ; + yToT_cm[iPart] = (yToT_cm[iPart] - flosOffsetYQ) * flosVeffYQ; + + if (nPMV == 8 && nPMT == 8) + { + + fh_los_tot_mean->Fill(totsum[iPart]); + + if (time_first < 0) + time_first = timeLosM[iPart]; + if (iPart < 1) + { + Double_t timediff = float(header->GetTimeStamp() - time_V_mem); + fh_los_dt_first_ToT->Fill(timediff / 1.e3, totsum[iPart]); + } + + double_t time2 = 0.; + if (time1 < 0) + time1 = timeLosM[iPart]; + time2 = timeLosM[iPart]; + if (time1 > 0. && time2 > 0. && time2 > time1) + { + // cout<<"Time Test "<Fill(time2 - time1); + time1 = time2; + } + + fh_los_dt_hits_ToT->Fill( + (header->GetTimeStamp() - time_V_mem + timeLosM[iPart] - time_first) / 1000., + totsum[iPart]); + time_V_mem = header->GetTimeStamp() + timeLosM[iPart] - time_first; + + for (int ipm = 0; ipm < 8; ipm++) + { + fh_los_tot->Fill(ipm + 1, tot[iPart][ipm]); + } + + fh_los_tres_MCFD->Fill(LosTresM[iPart]); + fh_los_tres_TAMEX->Fill(LosTresT[iPart]); + fh_los_pos_MCFD->Fill(xV_cm[iPart], yV_cm[iPart]); + fh_los_pos_TAMEX->Fill(xT_cm[iPart], yT_cm[iPart]); + fh_los_pos_ToT->Fill(xToT_cm[iPart], yToT_cm[iPart]); + fh_los_ihit_ToT->Fill(iPart, totsum[iPart]); + fh_los_multihit->Fill(iPart + 1); + } + } + + // if(iPart == nPart-1) time_V_mem = header->GetTimeStamp(); // memorize time of the last hit + } + else + { + cout << "Wrong detector ID for LOS!" << endl; + } + } + } + + //---------------------------------------------------------------------- + // SCI8 detector + //---------------------------------------------------------------------- + + Double_t timeS8_V[10][2] = { 0.0 / 0.0 }; // [multihit][pm] + Double_t timeS8_L[10][2] = { 0.0 / 0.0 }; + Double_t timeS8_T[10][2] = { 0.0 / 0.0 }; + Double_t timeSci8M[10] = { 0.0 }; + Double_t Sci8TresM[10] = { 0.0 / 0.0 }; + Double_t timeSci8T[10] = { 0.0 }; + Double_t Sci8TresT[10] = { 0.0 / 0.0 }; + Double_t timeSci8[10] = { 0.0 }; + Double_t totsumS8[10] = { 0.0 }; + Double_t totS8[10][8] = { 0.0 / 0.0 }; + + Int_t MultipS8; + + if (fMappedItems.at(DET_SCI8)) + { + auto det = fMappedItems.at(DET_SCI8); + Int_t nHits = det->GetEntriesFast(); + + MultipS8 = nHits; + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BSci8MappedData* hit = (R3BSci8MappedData*)det->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iDet = hit->GetDetector(); // 1.. + Int_t iCha = hit->GetChannel(); // 1.. + + fh_sci8_channels->Fill(iCha); + } + } + + Int_t nPartS8; + + if (fCalItems.at(DET_SCI8)) + { + auto det = fCalItems.at(DET_SCI8); + nPartS8 = det->GetEntriesFast(); + + fh_sci8_multihit->Fill(nPartS8); + + Int_t iDet = 0; + Int_t nPartS8_VFTX[2] = { 0 }; + Int_t nPartS8_LEAD[2] = { 0 }; + Int_t nPartS8_TRAI[2] = { 0 }; + + for (Int_t iPart = 0; iPart < nPartS8; iPart++) + { + + /* + * nPart is the number of particle passing through Sci8 detector in one event + */ + + R3BSci8CalData* calDataS8 = (R3BSci8CalData*)det->At(iPart); + iDet = calDataS8->GetDetector(); + + // VFTX Channels 1-2: + if (!(IS_NAN(calDataS8->fTimeV_r_ns))) + { + timeS8_V[iPart][0] = calDataS8->fTimeV_r_ns; + nPartS8_VFTX[0] += 1; + } + if (!(IS_NAN(calDataS8->fTimeV_l_ns))) + { + timeS8_V[iPart][1] = calDataS8->fTimeV_l_ns; + nPartS8_VFTX[1] += 1; + } + + // TAMEX Channels 1-2: + if (!(IS_NAN(calDataS8->fTimeL_r_ns))) + { + timeS8_L[iPart][0] = calDataS8->fTimeL_r_ns; + nPartS8_LEAD[0] += 1; + } + if (!(IS_NAN(calDataS8->fTimeT_r_ns))) + { + timeS8_T[iPart][0] = calDataS8->fTimeT_r_ns; + nPartS8_TRAI[0] += 1; + } + if (!(IS_NAN(calDataS8->fTimeL_l_ns))) + { + timeS8_L[iPart][1] = calDataS8->fTimeL_l_ns; + nPartS8_LEAD[1] += 1; + } + if (!(IS_NAN(calDataS8->fTimeT_l_ns))) + { + timeS8_T[iPart][1] = calDataS8->fTimeT_l_ns; + nPartS8_TRAI[1] += 1; + } + + if (iPart > 0 && MultipS8 % 2 == 0) + { + for (int k = 0; k < 2; k++) + { + if (timeS8_V[iPart][k] > 0. && timeS8_V[iPart - 1][k] > 0. && !(IS_NAN(timeS8_V[iPart][k])) && + !(IS_NAN(timeS8_V[iPart - 1][k]))) + { + fh_sci8_dt_hits->Fill(timeS8_V[iPart][k] - timeS8_V[iPart - 1][k]); + } + if (timeS8_L[iPart][k] > 0. && timeS8_L[iPart - 1][k] > 0. && !(IS_NAN(timeS8_L[iPart][k])) && + !(IS_NAN(timeS8_L[iPart - 1][k]))) + { + fh_sci8_dt_hits_l->Fill(timeS8_L[iPart][k] - timeS8_L[iPart - 1][k]); + } + if (timeS8_T[iPart][k] > 0. && timeS8_T[iPart - 1][k] > 0. && !(IS_NAN(timeS8_T[iPart][k])) && + !(IS_NAN(timeS8_T[iPart - 1][k]))) + { + fh_sci8_dt_hits_t->Fill(timeS8_T[iPart][k] - timeS8_T[iPart - 1][k]); + } + } + } + + if (iDet == 1) + { + + // if(iPart >= 0) + if (1 == 1) + { + int nPMT = 0; + int nPMV = 0; + int ilc = iPart; + + for (int ipm = 0; ipm < 2; ipm++) + { + + if (timeS8_T[iPart][ipm] > 0. && timeS8_L[iPart][ipm] > 0. && !(IS_NAN(timeS8_T[iPart][ipm])) && + !(IS_NAN(timeS8_L[iPart][ipm]))) + { + while (timeS8_T[iPart][ipm] - timeS8_L[iPart][ipm] < 0.) + { + timeS8_T[iPart][ipm] = timeS8_T[iPart][ipm] + 2048. * fClockFreq; + } + + nPMT = nPMT + 1; + totS8[iPart][ipm] = timeS8_T[iPart][ipm] - timeS8_L[iPart][ipm]; + } + + totsumS8[iPart] += totS8[iPart][ipm]; + + if (totS8[iPart][ipm] != 0. && !(IS_NAN(totS8[iPart][ipm]))) + fh_sci8_tot->Fill(ipm + 1, totS8[iPart][ipm]); + + if (timeS8_L[iPart][ipm] > 0. && !(IS_NAN(timeS8_L[iPart][ipm]))) + timeSci8T[iPart] += timeS8_L[iPart][ipm]; + + if (timeS8_V[iPart][ipm] > 0. && !(IS_NAN(timeS8_V[iPart][ipm]))) + { + timeSci8M[iPart] += timeS8_V[iPart][ipm]; + nPMV = nPMV + 1; + } + } + + totsumS8[iPart] = totsumS8[iPart] / nPMT; + /* + if(totsum[iPart] < 88.) cout<Fill(timeSci8[iPart] - timeLos[ilc]); + + // cout<<"TOF "<Fill(Sci8TresM[iPart]); + if (nPMT == 2) + fh_sci8_tres_TAMEX->Fill(Sci8TresT[iPart]); + if (nPMT == 2) + fh_sci8_tot_mean->Fill(totsumS8[iPart]); + } + } + else + { + cout << "Wrong detector ID for Sci8!" << endl; + } + } + + for (int ik = 0; ik < 2; ik++) + { + fh_sci8_multihitVFTX->Fill(ik + 1, nPartS8_VFTX[ik]); + fh_sci8_multihitLEAD->Fill(ik + 1, nPartS8_LEAD[ik]); + fh_sci8_multihitTRAI->Fill(ik + 1, nPartS8_TRAI[ik]); + } + } + + //---------------------------------------------------------------------- + // Fiber detectors + //---------------------------------------------------------------------- + Double_t dtime = 0.0 / 0.0; + + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + + Int_t iFib = 0; + + auto detMapped = fMappedItems.at(DET_FI_FIRST + ifibcount); + auto detHit = fHitItems.at(DET_FI_FIRST + ifibcount); + + if (detMapped) + { + Int_t nHits = detMapped->GetEntriesFast(); + std::vector mapmt_num(512); + std::vector spmt_num(16); + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BBunchedFiberMappedData* hit = (R3BBunchedFiberMappedData*)detMapped->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + Int_t iCha = hit->GetChannel(); // 1.. + + if (hit->IsMAPMT() && hit->IsLeading()) + { + fh_channels_Fib[ifibcount]->Fill(iCha); // Fill which clockTDC channel has events + ++mapmt_num.at(hit->GetChannel() - 1); // multihit of a given clockTDC channel + } + + if (!hit->IsMAPMT() && hit->IsLeading()) + { + fh_channels_single_Fib[ifibcount]->Fill(iCha); // Fill which single PMT channel has events + ++spmt_num.at(hit->GetChannel() - 1); // multihit of a given PADI channel + } + } + + for (int i = 0; i < 512; ++i) + { + auto m = mapmt_num.at(i); + if (m > 0) + fh_multihit_m_Fib[ifibcount]->Fill(i + 1, m); // multihit of a given clockTDC channel + } + + for (int i = 0; i < 16; ++i) + { + auto s = spmt_num.at(i); + if (s > 0) + fh_multihit_s_Fib[ifibcount]->Fill(i + 1, s); // multihit of a given PADI channel + } + } + + if (detHit) + { + Int_t nHits = detHit->GetEntriesFast(); + + Double_t posfib = 0. / 0.; + Double_t totMax = 0.; + Double_t tfib = 0. / 0., tof_fib = 0. / 0.; + Double_t randx; + Int_t iFibmax = 0; + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + Double_t tMAPMT = 0. / 0.; + Double_t tSPMT = 0. / 0.; + + R3BBunchedFiberHitData* hit = (R3BBunchedFiberHitData*)detHit->At(ihit); + if (!hit) + continue; + + iFib = hit->GetFiberId(); // 1.. + + // times + tMAPMT = hit->GetMAPMTTime_ns(); + tSPMT = hit->GetSPMTTime_ns(); + + dtime = tMAPMT - tSPMT; + + // "Push" two times in the same clock cycle: + while (dtime < -1024) + { + tSPMT = tSPMT - 2048.; + dtime = tMAPMT - tSPMT; + } + while (dtime > 1024.) + { + tSPMT = tSPMT + 2048.; + dtime = tMAPMT - tSPMT; + } + + // "Push" the Fib times in the same cycle with LOS: + if (timeLos[0] > 0. && !(IS_NAN(timeLos[0]))) + { + while (tMAPMT - timeLos[0] < 4096.) + { + tMAPMT = tMAPMT + 2048. * 4.; + tSPMT = tSPMT + 2048. * 4.; + } + while (tMAPMT - timeLos[0] > 4096.) + { + tMAPMT = tMAPMT - 2048. * 4.; + tSPMT = tSPMT - 2048. * 4.; + } + } + + // Not-calibrated ToF: + // tfib = (tMAPMT + tSPMT) / 2.; + tfib = tSPMT; + if (tfib > 0. && !(IS_NAN(tfib)) && timeLos[0] > 0. && !(IS_NAN(timeLos[0]))) + tof_fib = tfib - timeLos[0]; + + // Not-calibrated position: + randx = (std::rand() / (float)RAND_MAX); + if (iFib > 0) + posfib = (-n_fiber[ifibcount] / 2. + iFib + (0.5 - randx)); + + if (hit->GetSPMTToT_ns() > 0) + { + fh_fibers_Fib[ifibcount]->Fill(iFib); + fh_ToT_s_Fib[ifibcount]->Fill(iFib, hit->GetSPMTToT_ns()); + fh_ToT_m_Fib[ifibcount]->Fill(iFib, hit->GetMAPMTToT_ns()); + fh_time_Fib[ifibcount]->Fill(iFib, tMAPMT - tSPMT); + fh_Fib_ToF[ifibcount]->Fill(iFib, tof_fib); + fh_Fib_pos[ifibcount]->Fill(posfib); + fh_Fib_vs_Events[ifibcount]->Fill(fNEvents, iFib); + if (ifibcount == 12 || ifibcount == 13) + { + fh_ToT_single_Fib[ifibcount]->Fill((iFib - 1) % 2 + 1 + 2 * ((iFib - 1) / 512), + hit->GetSPMTToT_ns()); + // cout<<"Test: "<Fill((iFib - 1) % 2 + 1 + 2 * ((iFib - 1) / 512), + hit->GetSPMTToT_ns()); + // cout<<"Test: "<Fill((iFib - 1) / 256 + 1, hit->GetSPMTToT_ns()); + } + + if (ifibcount == 4 || ifibcount == 5) + { + fh_ToT_single_Fib[ifibcount]->Fill((iFib - 1) % 2 + 1, hit->GetSPMTToT_ns()); + } + } + } // end for(ihit) + + if (nHits > 0) + fh_mult_Fib[ifibcount]->Fill(nHits); + + } // end if(aHit[ifibcount]) + } // end for(ifibcount) + + //---------------------------------------------------------------------- + // TOFD + //---------------------------------------------------------------------- + + Int_t NumPaddles[4] = { 0 }; + if (fMappedItems.at(DET_TOFD)) + { + auto det = fMappedItems.at(DET_TOFD); + Int_t nMapped = det->GetEntriesFast(); + Int_t iPlaneMem = 1, iBarMem = 0; + for (Int_t imapped = 0; imapped < nMapped; imapped++) + { + auto mapped = (R3BTofdMappedData const*)det->At(imapped); + if (!mapped) + continue; // should not happen + + Int_t const iPlane = mapped->GetDetectorId(); // 1..n + Int_t const iBar = mapped->GetBarId(); // 1..n + Int_t const iSide = mapped->GetSideId(); // 1..n + Int_t const iEdge = mapped->GetEdgeId(); + + if (iPlaneMem != iPlane) + iBarMem = 0; + if (iPlane == 1 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[0] += 1; + if (iPlane == 2 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[1] += 1; + if (iPlane == 3 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[2] += 1; + if (iPlane == 3 && iBarMem != iBar && iSide == 1 && iEdge == 1) + NumPaddles[3] += 1; + + // cout<Fill(-iBar - 1); + if (iSide == 2) + fh_tofd_channels[iPlane - 1]->Fill(iBar); + } + } + } + + if (fCalItems.at(DET_TOFD)) + { + auto det = fCalItems.at(DET_TOFD); + Int_t nCals = det->GetEntriesFast(); + + Double_t tot1[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t tot2[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t_paddle[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t1l[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t2l[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t1t[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t t2t[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + Double_t ToF[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0. / 0. }; + + Bool_t Bar_present[10][N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { false }; + + Int_t iBarMem = 0; + Int_t jmult[N_PLANE_MAX_TOFD][N_PADDLE_MAX_TOFD] = { 0 }; + + unsigned long long time0 = header->GetTimeStamp(); + double_t time1 = -1.; + + for (Int_t ical = 0; ical < nCals; ical++) + { + auto cal = (R3BTofdCalData const*)det->At(ical); + if (!cal) + continue; // should not happen + + Int_t const iPlane = cal->GetDetectorId(); // 1..n + Int_t const iBar = cal->GetBarId(); // 1..n + + // std::cout << iPlane << ' ' << iBar << + // ',' << cal->GetTimeBL_ns() << + // ' ' << cal->GetTimeBT_ns() << + // ' ' << cal->GetTimeTL_ns() << + // ' ' << cal->GetTimeTT_ns() << std::endl; + + // get all times of one bar + /* + cout<<"TOFD Online: "<fTime1L_ns<<", "<fTime1T_ns<<", "<< cal->fTime2L_ns<<", + "<fTime2T_ns<GetTimeBL_ns())) t1l[0][iPlane-1][iBar-1] = cal->GetTimeBL_ns(); + if (!IS_NAN(cal->GetTimeBT_ns())) t1t[0][iPlane-1][iBar-1] = cal->GetTimeBT_ns(); + if (!IS_NAN(cal->GetTimeTL_ns())) t2l[0][iPlane-1][iBar-1] = cal->GetTimeTL_ns(); + if (!IS_NAN(cal->GetTimeTT_ns())) t2t[0][iPlane-1][iBar-1] = cal->GetTimeTT_ns(); + Bar_present[0][iPlane-1][iBar-1] = true; + } + else + { + jmult[iPlane-1][iBar-1] = jmult[iPlane-1][iBar-1] + 1; + Int_t jm = jmult[iPlane-1][iBar-1]; + if (!IS_NAN(cal->GetTimeBL_ns())) t1l[jm][iPlane-1][iBar-1] = cal->GetTimeBL_ns(); + if (!IS_NAN(cal->GetTimeBT_ns())) t1t[jm][iPlane-1][iBar-1] = cal->GetTimeBT_ns(); + if (!IS_NAN(cal->GetTimeTL_ns())) t2l[jm][iPlane-1][iBar-1] = cal->GetTimeTL_ns(); + if (!IS_NAN(cal->GetTimeTT_ns())) t2t[jm][iPlane-1][iBar-1] = cal->GetTimeTT_ns(); + Bar_present[jm][iPlane-1][iBar-1] = true; + } + iBarMem = iBar; + */ + + Int_t jm = jmult[iPlane - 1][iBar - 1]; + /* if (!IS_NAN(cal->GetTimeBL_ns())) t1l[jm][iPlane-1][iBar-1] = cal->GetTimeBL_ns(); + if (!IS_NAN(cal->GetTimeBT_ns())) t1t[jm][iPlane-1][iBar-1] = cal->GetTimeBT_ns(); + if (!IS_NAN(cal->GetTimeTL_ns())) t2l[jm][iPlane-1][iBar-1] = cal->GetTimeTL_ns(); + if (!IS_NAN(cal->GetTimeTT_ns())) t2t[jm][iPlane-1][iBar-1] = cal->GetTimeTT_ns();*/ + Bar_present[jm][iPlane - 1][iBar - 1] = true; + jmult[iPlane - 1][iBar - 1] = jmult[iPlane - 1][iBar - 1] + 1; + + double_t time2 = 0.; + if (time1 < 0 && iPlane == 2) + time1 = (t1l[jm][iPlane - 1][iBar - 1] + t2l[jm][iPlane - 1][iBar - 1]) / 2.; + if (iPlane == 2) + time2 = (t1l[jm][iPlane - 1][iBar - 1] + t2l[jm][iPlane - 1][iBar - 1]) / 2.; + if (time1 > 0. && time2 > 0. && time2 > time1) + { + // cout<<"Time Test "<Fill(time2 - time1); + time2 = time1; + } + } + + /* + for (Int_t ipl = 0; ipl < N_PLANE_MAX_TOFD; ipl++) + for(Int_t ibr = 0; ibr < N_PADDLE_MAX_TOFD; ibr++) + { + fh_tofd_multihit[ipl]->Fill(ibr+1,jmult[ipl][ibr]+1); + } + */ + for (Int_t ipl = 0; ipl < N_PLANE_MAX_TOFD; ipl++) + for (Int_t ibr = 0; ibr < N_PADDLE_MAX_TOFD; ibr++) + for (Int_t jm = 0; jm < jmult[ipl][ibr]; jm++) + { + + if (Bar_present[jm][ipl][ibr]) + { + Int_t iPlane = ipl + 1; // 1..n + Int_t iBar = ibr + 1; // 1..n + + fh_tofd_multihit[ipl]->Fill(ibr + 1, jmult[ipl][ibr]); + + // calculate time over threshold and check if clock counter went out of range + + while (t1t[jm][iPlane - 1][iBar - 1] < t1l[jm][iPlane - 1][iBar - 1]) + { + t1t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + + while (t2t[jm][iPlane - 1][iBar - 1] < t2l[jm][iPlane - 1][iBar - 1]) + { + t2t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + + int ilc = jm; + + if (!(IS_NAN(timeLos[ilc])) && timeLos[ilc] > 0.) + { + + while (t1l[jm][iPlane - 1][iBar - 1] < timeLos[ilc]) + { + t1t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + t1l[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + while (t2l[jm][iPlane - 1][iBar - 1] < timeLos[ilc]) + { + t2t[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + t2l[jm][iPlane - 1][iBar - 1] += 2048. * fClockFreq; + } + } + + // ToF + t_paddle[jm][iPlane - 1][iBar - 1] = + (t1l[jm][iPlane - 1][iBar - 1] + t2l[jm][iPlane - 1][iBar - 1]) / 2.; + + // between 2 bars in 2 planes + if (ipl > 0) + { + fh_tofd_dt[ipl - 1]->Fill(iBar, + t_paddle[jm][ipl][iBar - 1] - t_paddle[jm][ipl - 1][iBar - 1]); + } + + if (!(IS_NAN(timeLos[ilc])) && timeLos[ilc] > 0.) + { + // between LOS and paddle + ToF[jm][iPlane - 1][iBar - 1] = + fmod(t_paddle[jm][iPlane - 1][iBar - 1] - timeLos[ilc] + 5 * 8192, 5 * 2048); + fh_tofd_ToF[iPlane - 1]->Fill(iBar, ToF[jm][iPlane - 1][iBar - 1]); + } + // ToT + tot1[jm][iPlane - 1][iBar - 1] = t1t[jm][iPlane - 1][iBar - 1] - t1l[jm][iPlane - 1][iBar - 1]; + if (tot1[jm][iPlane - 1][iBar - 1] < 0) + { + cout << "Negative ToT " << tot1[jm][iPlane - 1] << ", for hit= " << jm << endl; + cout << "Times1: " << t1t[jm][iPlane - 1][iBar - 1] << " " << t1l[jm][iPlane - 1][iBar - 1] + << endl; + } + + tot2[jm][iPlane - 1][iBar - 1] = t2t[jm][iPlane - 1][iBar - 1] - t2l[jm][iPlane - 1][iBar - 1]; + if (tot2[jm][iPlane - 1][iBar - 1] < 0) + { + cout << "Negative ToT " << tot2[jm][iPlane - 1][iBar - 1] << ", for hit= " << jm << endl; + cout << "Times2: " << t2t[jm][iPlane - 1][iBar - 1] << " " << t2l[jm][iPlane - 1][iBar - 1] + << endl; + } + + fh_tofd_TotPm[iPlane - 1]->Fill(iBar, tot2[jm][iPlane - 1][iBar - 1]); + fh_tofd_TotPm[iPlane - 1]->Fill(-iBar - 1, tot1[jm][iPlane - 1][iBar - 1]); + } + } + } + + //---------------------------------------------------------------------- + // PTOF + //---------------------------------------------------------------------- + + if (fCalItems.at(DET_PTOF)) + { + auto det = fCalItems.at(DET_PTOF); + + Double_t tot1 = 0.; + Double_t tot2 = 0.; + Double_t t1l = 0.; + Double_t t2l = 0.; + Double_t t1t = 0.; + Double_t t2t = 0.; + Bool_t bar_quer1 = false; + Bool_t bar_quer2 = false; + + Int_t nHits = det->GetEntriesFast(); + LOG(DEBUG) << "nHits: " << nHits; + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BPaddleCalData* hit = (R3BPaddleCalData*)det->At(ihit); + + if (!hit) + continue; // should not happen + + Int_t iBar = hit->GetBar(); // 1..n + // get all times of one bar + t1l = hit->fTime1L_ns; + t2l = hit->fTime2L_ns; + t1t = hit->fTime1T_ns; + t2t = hit->fTime2T_ns; + + if (!(t1l > 0 && t2l > 0 && t1t > 0 && t2t > 0)) + continue; + + fh_ptof_channels->Fill(iBar); + LOG(DEBUG) << "Bar: " << iBar; + LOG(DEBUG) << "times PM1: " << t1l << " " << t1t << " " << t1t - t1l; + LOG(DEBUG) << "times PM2: " << t2l << " " << t2t << " " << t2t - t2l; + if (iBar == 7) + bar_quer1 = true; + if (iBar == 8) + bar_quer2 = true; + + // calculate time over threshold and check if clock counter went out of range + while (t1t - t1l < 0.) + { + t1t = t1t + 2048. * fClockFreq; + } + + while (t2t - t2l < 0.) + { + t2t = t2t + 2048. * fClockFreq; + } + while (t1l - timeLos[0] < 0.) + { + t1t = t1t + 2048. * fClockFreq; + t1l = t1l + 2048. * fClockFreq; + t2t = t2t + 2048. * fClockFreq; + t2l = t2l + 2048. * fClockFreq; + } + + tot1 = t1t - t1l; + if (tot1 < 0) + { + LOG(WARNING) << "Negative ToT " << tot1; + LOG(WARNING) << "times1: " << t1t << " " << t1l; + } + + tot2 = t2t - t2l; + if (tot2 < 0) + { + LOG(WARNING) << "Negative ToT " << tot2; + LOG(WARNING) << "times2: " << t2t << " " << t2l; + } + + fh_ptof_TotPm1[iBar]->Fill(tot1); + fh_ptof_TotPm2[iBar]->Fill(tot2); + if (iBar == 2) + fh_ptof_test1->Fill(sqrt(tot1 * tot1)); + } + + // once again + + nHits = det->GetEntriesFast(); + // LOG(DEBUG) << "nHits: " << nHits; + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BPaddleCalData* hit = (R3BPaddleCalData*)det->At(ihit); + + if (!hit) + continue; // should not happen + + Int_t iBar = hit->GetBar(); // 1..n + // get all times of one bar + t1l = hit->fTime1L_ns; + t2l = hit->fTime2L_ns; + t1t = hit->fTime1T_ns; + t2t = hit->fTime2T_ns; + + if (!(t1l > 0 && t2l > 0 && t1t > 0 && t2t > 0)) + continue; + + // calculate time over threshold and check if clock counter went out of range + while (t1t - t1l < 0.) + { + t1t = t1t + 2048. * fClockFreq; + } + + while (t2t - t2l < 0.) + { + t2t = t2t + 2048. * fClockFreq; + } + while (t1l - timeLos[0] < 0.) + { + t1t = t1t + 2048. * fClockFreq; + t1l = t1l + 2048. * fClockFreq; + t2t = t2t + 2048. * fClockFreq; + t2l = t2l + 2048. * fClockFreq; + } + + tot1 = t1t - t1l; + if (tot1 < 0) + { + LOG(WARNING) << "Negative ToT " << tot1; + LOG(WARNING) << "times1: " << t1t << " " << t1l; + } + + tot2 = t2t - t2l; + if (tot2 < 0) + { + LOG(WARNING) << "Negative ToT " << tot2; + LOG(WARNING) << "times2: " << t2t << " " << t2l; + } + + if (bar_quer1 && bar_quer2) + { + // fh_ptof_TotPm1[iBar]->Fill(tot1); + // fh_ptof_TotPm2[iBar]->Fill(tot2); + // if(iBar==2) fh_ptof_test2->Fill(sqrt(tot1*tot2)); + fh_ptof_channels_cut->Fill(iBar); + } + } + } + + //---------------------------------------------------------------------- + // PSPX + //---------------------------------------------------------------------- + if (fMappedItems.at(DET_PSPX)) + { + UInt_t mult_x[N_PSPX]; + UInt_t mult_y[N_PSPX]; + + UInt_t channel_x[N_PSPX][N_STRIPS_PSPX * 2]; + UInt_t channel_y[N_PSPX][N_STRIPS_PSPX * 2]; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + mult_x[i] = 0; + mult_y[i] = 0; + + for (UInt_t j = 0; j < N_STRIPS_PSPX * 2; j++) + { + channel_x[i][j] = 0; + channel_y[i][j] = 0; + } + } + + Int_t nHits = fMappedItems.at(DET_PSPX)->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BPspxMappedData* mappedData = (R3BPspxMappedData*)fMappedItems.at(DET_PSPX)->At(ihit); + UInt_t i = mappedData->GetDetector() - 1; + if (mappedData->GetChannel() > N_STRIPS_PSPX * 2 && mappedData->GetChannel() < N_STRIPS_PSPX * 4 + 1) + { + // LOG(INFO) << "Test1 " << i << " " << mappedData->GetDetector() << " " << + // mappedData->GetChannel(); + channel_y[i][mult_y[i]] = mappedData->GetChannel(); + mult_y[i]++; + } + else if (mappedData->GetChannel() > 0 && mappedData->GetChannel() < N_STRIPS_PSPX * 2 + 1) + { + // LOG(INFO) << "Test2 " << i << " " << mappedData->GetDetector() << " " << + // mappedData->GetChannel(); + channel_x[i][mult_x[i]] = mappedData->GetChannel(); + mult_x[i]++; + } + } + + for (UInt_t i = 0; i < N_PSPX; i++) + { + // LOG(INFO) << "Test3 " << i << " " << mult_x[i] << " " << mult_y[i]; + fh_pspx_multiplicity_x[i]->Fill(mult_x[i]); + fh_pspx_multiplicity_y[i]->Fill(mult_y[i]); + // LOG(INFO) << "Test4 " << fh_pspx_multiplicity_x[i]->GetBinContent(1); + + std::vector v_ch_x, v_ch_y; + for (Int_t j = 0; j < mult_x[i]; j++) + { + if ((channel_x[i][j] + 1) / 2 == (channel_x[i][j + 1] + 1) / 2) + { + v_ch_x.push_back((channel_x[i][j] + 1) / 2); + } + } + for (Int_t j = 0; j < mult_y[i]; j++) + { + if ((channel_y[i][j] + 1) / 2 == (channel_y[i][j + 1] + 1) / 2) + { + v_ch_y.push_back((channel_y[i][j] + 1) / 2); + } + } + for (auto it_x = v_ch_x.begin(); v_ch_x.end() != it_x; ++it_x) + { + for (auto it_y = v_ch_y.begin(); v_ch_y.end() != it_y; ++it_y) + { + fh_pspx_strips_position[i]->Fill( + *it_x, + -*it_y + 3 * N_STRIPS_PSPX + 1); // with inverted axis to account for orientation + // fh_pspx_strips_position[i]->Fill((channel_x[i][0] + 1) / 2, ((channel_y[i][0] + 1) / 2)); + // //without inverted axis => wrong orientation y axis + } + } + + // std::cout << "x: " << mult_x[i] << ", " << (channel_x[i][0]+1)/2 << endl; + // std::cout << "y: " << mult_y[i] << ", " << -((int)channel_y[i][0]+1)/2 + 3 * N_STRIPS_PSPX + 1<< endl; + + for (Int_t j = 0; j < mult_x[i]; j++) + { + fh_pspx_channel_x[i]->Fill(channel_x[i][j]); + } + + for (Int_t j = 0; j < mult_y[i]; j++) + { + fh_pspx_channel_y[i]->Fill(channel_y[i][j]); + } + } + } + + if (fCalItems.at(DET_PSPX)) + { + Int_t energy_front[N_PSPX]; + Int_t energy_back[N_PSPX]; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + energy_front[i] = 0; + energy_back[i] = 0; + } + + Int_t nHits = fCalItems.at(DET_PSPX)->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + R3BPspxCalData* calData = (R3BPspxCalData*)fCalItems.at(DET_PSPX)->At(ihit); + if (calData->GetDetector() == i + 1 && calData->GetStrip() > N_STRIPS_PSPX && + calData->GetStrip() < N_STRIPS_PSPX * 2 + 1) + { + energy_back[i] += (calData->GetEnergy1() + calData->GetEnergy2()); + } + else if (calData->GetDetector() == i + 1 && calData->GetStrip() > 0 && + calData->GetStrip() < N_STRIPS_PSPX + 1) + { + energy_front[i] += (calData->GetEnergy1() + calData->GetEnergy2()); + } + } + } + + for (UInt_t i = 0; i < N_PSPX; i++) + { + // LOG(INFO) << "Test " << i << " " << energy_front[i] << " " << energy_back[i]; + if (i != 2 && i != 3) + { + fh_pspx_cal_energy_frontback[i]->Fill(energy_front[i], energy_back[i]); + } + else + { + fh_pspx_cal_energy_frontback[i]->Fill( + -energy_front[i], -energy_back[i]); // s444: psp 2 is read out with Munich cards, inverts polarity + } + } + } + + if (fHitItems.at(DET_PSPX)) + { + Int_t nHits = fHitItems.at(DET_PSPX)->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + R3BPspxHitData* hitData = (R3BPspxHitData*)fHitItems.at(DET_PSPX)->At(ihit); + + if (hitData->GetDetector() == i * 2 + 1) + { + fh_pspx_hit_energy[i]->Fill(hitData->GetEnergy()); + fh_pspx_hit_position[i]->Fill(hitData->GetX(), hitData->GetY()); + } + } + } + } + + fNEvents += 1; +} + +void R3BOnlineSpectra::FinishEvent() +{ + + for (Int_t det = 0; det < DET_MAX; det++) + { + if (fMappedItems.at(det)) + { + fMappedItems.at(det)->Clear(); + } + if (fCalItems.at(det)) + { + fCalItems.at(det)->Clear(); + } + if (fHitItems.at(det)) + { + fHitItems.at(det)->Clear(); + } + } +} + +void R3BOnlineSpectra::FinishTask() +{ + + if (fMappedItems.at(DET_LOS)) + { + fh_los_channels->Write(); + fh_los_tot->Write(); + fh_los_dt_hits_ToT->Write(); + fh_los_ihit_ToT->Write(); + fh_los_dt_hits->Write(); + } + + if (fMappedItems.at(DET_BMON)) + { + fhTpat->Write(); + fh_spill_length->Write(); + fhTrigger->Write(); + fh_IC->Write(); + fh_SEE->Write(); + fh_TOFDOR->Write(); + fh_IC_spill->Write(); + fh_SEE_spill->Write(); + fh_TOFDOR_spill->Write(); + } + + if (fCalItems.at(DET_TOFD)) + { + fh_TimePreviousEvent->Write(); + + for (Int_t i; i < 4; i++) + { + fh_tofd_TotPm[i]->Write(); + } + } + for (Int_t ifibcount = 0; ifibcount < NOF_FIB_DET; ifibcount++) + { + if (fMappedItems.at(ifibcount + DET_FI_FIRST)) + { + fh_channels_Fib[ifibcount]->Write(); + fh_fibers_Fib[ifibcount]->Write(); + fh_mult_Fib[ifibcount]->Write(); + fh_time_Fib[ifibcount]->Write(); + fh_multihit_m_Fib[ifibcount]->Write(); + fh_multihit_s_Fib[ifibcount]->Write(); + fh_ToT_m_Fib[ifibcount]->Write(); + fh_ToT_s_Fib[ifibcount]->Write(); + fh_ToT_single_Fib[ifibcount]->Write(); + fh_Fib_vs_Events[ifibcount]->Write(); + fh_Fib_ToF[ifibcount]->Write(); + fh_channels_single_Fib[ifibcount]->Write(); + } + } + + if (fMappedItems.at(DET_PSPX)) + { + // LOG(INFO) << "Finish MappedPspx"; + + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_channel_x[i]->Write(); + fh_pspx_channel_y[i]->Write(); + fh_pspx_multiplicity_x[i]->Write(); + fh_pspx_multiplicity_y[i]->Write(); + fh_pspx_strips_position[i]->Write(); + } + } + if (fCalItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < N_PSPX; i++) + { + fh_pspx_cal_energy_frontback[i]->Write(); + } + } + if (fHitItems.at(DET_PSPX)) + { + for (UInt_t i = 0; i < (N_PSPX + 1) / 2; i++) + { + fh_pspx_hit_energy[i]->Write(); + fh_pspx_hit_position[i]->Write(); + } + } +} + +ClassImp(R3BOnlineSpectra) diff --git a/r3bbase/R3BOnlineSpectraS454.h b/r3bbase/R3BOnlineSpectraS454.h new file mode 100644 index 000000000..d3765f137 --- /dev/null +++ b/r3bbase/R3BOnlineSpectraS454.h @@ -0,0 +1,328 @@ +// ------------------------------------------------------------ +// ----- R3BOnlineSpectra ----- +// ----- Created 13-04-2016 by M.Heil ----- +// ----- Fill online histograms ----- +// ------------------------------------------------------------ + +#ifndef R3BONLINESPECTRA +#define R3BONLINESPECTRA +#define N_PLANE_MAX_TOFD 4 +#define N_PADDLE_MAX_TOFD 50 +#define N_PADDLE_MAX_PTOF 100 +#define N_PSPX 6 +#define N_STRIPS_PSPX 32 +#define N_FIBER_PLOT 1050 // range to plot + +#include "FairTask.h" +#include +#include +#include +#include +#include + +#include "TClonesArray.h" +#include "TMath.h" +#include + +class TClonesArray; +class TH1F; +class TH2F; +class R3BEventHeader; + +/** + * This taks reads all detector data items and plots histograms + * for online checks. + */ +class R3BOnlineSpectra : public FairTask +{ + + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BOnlineSpectra(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BOnlineSpectra(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BOnlineSpectra(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Methods for setting position offset and effective velocity of light + */ + inline void SetLosXYMCFD(Double_t offsetX, Double_t offsetY, Double_t veffX, Double_t veffY) + { + flosOffsetXV = offsetX; + flosOffsetYV = offsetY; + flosVeffXV = veffX; + flosVeffYV = veffY; + } + + inline void SetLosXYTAMEX(Double_t offsetXT, Double_t offsetYT, Double_t veffXT, Double_t veffYT) + { + flosOffsetXT = offsetXT; + flosOffsetYT = offsetYT; + flosVeffXT = veffXT; + flosVeffYT = veffYT; + } + + inline void SetLosXYToT(Double_t offsetXQ, Double_t offsetYQ, Double_t veffXQ, Double_t veffYQ) + { + flosOffsetXQ = offsetXQ; + flosOffsetYQ = offsetYQ; + flosVeffXQ = veffXQ; + flosVeffYQ = veffYQ; + } + /** + * Method for setting the trigger value. + * @param trigger 1 - physics, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) { fTrigger = trigger; } + inline void SetTpat(Int_t tpat) { fTpat = tpat; } + + /** + * Methods for setting reset and readout times for Bmon + */ + inline void SetBmon(Int_t time_range, Double_t time_step, Int_t sens_SEE, Int_t sens_IC) + { + reset_time = time_range; + read_time = time_step; + fsens_SEE = sens_SEE; + fsens_IC = sens_IC; + } + /** + * Methods for setting number of planes and paddles + */ + inline void SetNofModules(Int_t planes, Int_t ppp) + { + fNofPlanes = planes; + fPaddlesPerPlane = ppp; + } + + void Reset_LOS_Histo(); + void Reset_SCI8_Histo(); + void Reset_BMON_Histo(); + void Reset_TOFD_Histo(); + void Reset_FIBERS_Histo(); + + private: + std::vector fMappedItems; + std::vector fCalItems; + std::vector fHitItems; + + enum DetectorInstances + { + DET_AMS, + DET_CALIFA, + DET_BMON, + DET_FI_FIRST, + DET_FI1A = DET_FI_FIRST, + DET_FI1B, + DET_FI2A, + DET_FI2B, + DET_FI3A, + DET_FI3B, + DET_FI4, + DET_FI5, + DET_FI6, + DET_FI7, + DET_FI8, + DET_FI9, + DET_FI10, + DET_FI11, + DET_FI12, + DET_FI13, + DET_FI_LAST = DET_FI13, + DET_L3T, + DET_LOS, + DET_MUSIC, + DET_NEULAND, + DET_PSPX, + DET_PTOF, + DET_ROLU, + DET_SCI8, + DET_STRAW, + DET_TOFD, + DET_MAX + }; + +#define NOF_FIB_DET (DET_FI_LAST - DET_FI_FIRST + 1) + + const char* fDetectorNames[DET_MAX + 1] = { "Ams", "Califa", "BeamMonitor", "Fi1a", "Fi1b", "Fi2a", + "Fi2b", "Fi3a", "Fi3b", "Fi4", "Fi5", "Fi6", + "Fi7", "Fi8", "Fi9", "Fi10", "Fi11", "Fi12", + "Fi13", "L3t", "Los", "Music", "Neuland", "Pspx", + "Ptof", "Rolu", "Sci8", "Straw", "Tofd", NULL }; + + // If FiberI is present or not: + Int_t ifibdet; + // Number of fibers per detector + Double_t n_fiber[NOF_FIB_DET] = { 256., 256., 256., 256, 512., 512., 2048., + 2048., 1024., 512., 512., 512., 1024., 1024. }; + + // check for trigger should be done globablly (somewhere else) + R3BEventHeader* header; /**< Event header. */ + Int_t fTrigger; /**< Trigger value. */ + Int_t fTpat; + Double_t fClockFreq; /**< Clock cycle in [ns]. */ + UInt_t fNofPlanes; + UInt_t fPaddlesPerPlane; /**< Number of paddles per plane. */ + + // TClonesArray *fbmonMappedItems; + + Double_t flosVeffXV; + Double_t flosVeffYV; + Double_t flosOffsetXV; + Double_t flosOffsetYV; + Double_t flosVeffXT; + Double_t flosVeffYT; + Double_t flosOffsetXT; + Double_t flosOffsetYT; + Double_t flosVeffXQ; + Double_t flosVeffYQ; + Double_t flosOffsetXQ; + Double_t flosOffsetYQ; + + unsigned long long time_V_mem = 0, time_start = 0, time = 0, time_mem = 0; + unsigned long long time_prev_read = 0, time_to_read = 0; + unsigned long ic_mem = 0, see_mem = 0, tofdor_mem = 0; + unsigned long ic_start = 0, see_start = 0, tofdor_start = 0; + unsigned long long time_spill_start = 0, time_spill_end = 0; + unsigned long long time_previous_event = 0; + Double_t time_clear = -1.; + Double_t tdiff = 0.; + Double_t fNorm = 1.; + Int_t iclear_count = 1; + UInt_t reset_time; // time after which bmon spectra are reseted + Double_t read_time; // step in which scalers are read, in sec + Int_t fsens_SEE, fsens_IC; // SEETRAM and IC sensitivity, between -4 and -10 + Double_t calib_SEE = 1.; // SEETRAM calibration factor + Double_t see_offset = 7.1; // SEETRAM offset in kHz + + unsigned long fNEvents = 0, fNEvents_start = 0; /**< Event counter. */ + + TH1F* fhTpat; + TH1F* fh_spill_length; + TH1F* fhTrigger; + TH1F* fh_IC_spill; + TH1F* fh_SEE_spill; + TH1F* fh_TOFDOR_spill; + TH1F* fh_IC; + TH1F* fh_SEE; + TH1F* fh_TOFDOR; + // TH1F *h3; + TH1F* fh_TimePreviousEvent; + + TH1F* fh_sci8_channels; + TH1F* fh_sci8_tres_MCFD; + TH1F* fh_sci8_tres_TAMEX; + TH1F* fh_sci8_tot_mean; + TH1F* fh_tof_sci8; + TH2F* fh_sci8_tot; + TH1F* fh_sci8_dt_hits; + TH1F* fh_sci8_dt_hits_l; + TH1F* fh_sci8_dt_hits_t; + TH1F* fh_sci8_multihit; + TH2F* fh_sci8_multihitVFTX; + TH2F* fh_sci8_multihitLEAD; + TH2F* fh_sci8_multihitTRAI; + + TH1F* fh_los_channels; + TH1F* fh_los_tres_MCFD; + TH1F* fh_los_tres_TAMEX; + TH1F* fh_los_tot_mean; + TH2F* fh_los_tot; + TH1F* fh_los_dt_hits; + TH1F* fh_los_multihit; + TH2F* fh_los_multihitVFTX; + TH2F* fh_los_multihitLEAD; + TH2F* fh_los_multihitTRAI; + TH2F* fh_los_pos_MCFD; + TH2F* fh_los_pos_TAMEX; + TH2F* fh_los_pos_ToT; + TH2F* fh_los_ihit_ToT; + TH2F* fh_los_dt_hits_ToT; + TH2F* fh_los_dt_first_ToT; + TH2F* fh_los_dt_hits_VT; + + TH1F* fh_channels_Fib[NOF_FIB_DET]; + TH1F* fh_channels_single_Fib[NOF_FIB_DET]; + TH1F* fh_fibers_Fib[NOF_FIB_DET]; + TH1F* fh_mult_Fib[NOF_FIB_DET]; + TH2F* fh_Fib_ToF[NOF_FIB_DET]; + TH1F* fh_Fib_pos[NOF_FIB_DET]; + TH2F* fh_time_Fib[NOF_FIB_DET]; + TH2F* fh_multihit_m_Fib[NOF_FIB_DET]; + TH2F* fh_multihit_s_Fib[NOF_FIB_DET]; + TH2F* fh_ToT_m_Fib[NOF_FIB_DET]; + TH2F* fh_ToT_s_Fib[NOF_FIB_DET]; + TH2F* fh_Fib_vs_Events[NOF_FIB_DET]; + TH2F* fh_ToT_single_Fib[NOF_FIB_DET]; + + TH1F* fh_tofd_channels[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_multihit[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_ToF[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_TotPm[N_PLANE_MAX_TOFD]; + TH2F* fh_tofd_dt[3]; + + TH1F* fh_ptof_channels; + TH1F* fh_ptof_channels_cut; + TH1F* fh_ptof_test1; + TH1F* fh_ptof_test2; + TH1F* fh_ptof_TotPm1[N_PADDLE_MAX_PTOF]; + TH1F* fh_ptof_TotPm2[N_PADDLE_MAX_PTOF]; + + TH1F* fh_pspx_channel_x[N_PSPX]; /**< PSPX x channel profile on mapped level */ + TH1F* fh_pspx_channel_y[N_PSPX]; /**< PSPX y channel profile on mapped level */ + TH1F* fh_pspx_multiplicity_x[N_PSPX]; /**< PSPX x multiplicity on mapped level */ + TH1F* fh_pspx_multiplicity_y[N_PSPX]; /**< PSPX y multiplicity on mapped level */ + + TH2F* fh_pspx_strips_position[N_PSPX]; /**< PSPX 2D position on mapped level */ + TH2F* fh_pspx_hit_position[(N_PSPX + 1) / 2]; /**< PSPX 2D position on hit level */ + + TH1F* fh_pspx_hit_energy[(N_PSPX + 1) / 2]; /**< PSPX energy on hit level */ + TH2F* fh_pspx_cal_energy_frontback[N_PSPX]; /**< PSPX energy front vs back on cal level */ + + public: + ClassDef(R3BOnlineSpectra, 2) +}; + +#endif diff --git a/r3bdata/CMakeLists.txt b/r3bdata/CMakeLists.txt index 4dc582737..9fef2a9ec 100755 --- a/r3bdata/CMakeLists.txt +++ b/r3bdata/CMakeLists.txt @@ -37,6 +37,7 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/startrackData ${R3BROOT_SOURCE_DIR}/r3bdata/landData ${R3BROOT_SOURCE_DIR}/r3bdata/roluData ${R3BROOT_SOURCE_DIR}/r3bdata/losData +${R3BROOT_SOURCE_DIR}/r3bdata/sci2Data ${R3BROOT_SOURCE_DIR}/r3bdata/sci8Data ${R3BROOT_SOURCE_DIR}/r3bdata/mfiData ${R3BROOT_SOURCE_DIR}/r3bdata/fibData @@ -46,8 +47,10 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/actarData ${R3BROOT_SOURCE_DIR}/r3bdata/strawtubesData ${R3BROOT_SOURCE_DIR}/r3bdata/amsData ${R3BROOT_SOURCE_DIR}/r3bdata/ptofData +${R3BROOT_SOURCE_DIR}/r3bdata/sci2Data ${R3BROOT_SOURCE_DIR}/r3bdata/sci8Data ${R3BROOT_SOURCE_DIR}/r3bdata/musicData +${R3BROOT_SOURCE_DIR}/r3bdata/sampData ) include_directories(${INCLUDE_DIRECTORIES}) @@ -127,6 +130,9 @@ losData/R3BLosHitData.cxx roluData/R3BRoluMappedData.cxx roluData/R3BRoluCalData.cxx roluData/R3BRoluHitData.cxx +sci2Data/R3BSci2MappedData.cxx +sci2Data/R3BSci2CalData.cxx +sci2Data/R3BSci2HitData.cxx sci8Data/R3BSci8MappedData.cxx sci8Data/R3BSci8CalData.cxx sci8Data/R3BSci8HitData.cxx @@ -157,6 +163,7 @@ musicData/R3BMusicPoint.cxx musicData/R3BMusicMappedData.cxx musicData/R3BMusicCalData.cxx musicData/R3BMusicHitData.cxx +sampData/R3BSamplerMappedData.cxx ) # fill list of header files from list of source files by exchanging the file extension diff --git a/r3bdata/R3BDataLinkDef.h b/r3bdata/R3BDataLinkDef.h index e1afa296e..daedce2c4 100755 --- a/r3bdata/R3BDataLinkDef.h +++ b/r3bdata/R3BDataLinkDef.h @@ -99,6 +99,9 @@ #pragma link C++ class R3BRoluMappedData+; #pragma link C++ class R3BRoluCalData+; #pragma link C++ class R3BRoluHitData+; +#pragma link C++ class R3BSci2MappedData+; +#pragma link C++ class R3BSci2CalData+; +#pragma link C++ class R3BSci2HitData+; #pragma link C++ class R3BSci8MappedData+; #pragma link C++ class R3BSci8CalData+; #pragma link C++ class R3BSci8HitData+; @@ -122,9 +125,13 @@ #pragma link C++ class R3BFibMappedData+; #pragma link C++ class R3BFibCalData+; #pragma link C++ class R3BFibPoint+; +#pragma link C++ class R3BSci2MappedData+; +#pragma link C++ class R3BSci2CalData+; +#pragma link C++ class R3BSci2HitData+; #pragma link C++ class R3BSci8MappedData+; #pragma link C++ class R3BSci8CalData+; #pragma link C++ class R3BSci8HitData+; #pragma link C++ class R3BBeamMonitorMappedData+; +#pragma link C++ class R3BSamplerMappedData+; #endif diff --git a/r3bdata/fibData/R3BBunchedFiberHitData.cxx b/r3bdata/fibData/R3BBunchedFiberHitData.cxx index 80c0a1fdb..532692013 100644 --- a/r3bdata/fibData/R3BBunchedFiberHitData.cxx +++ b/r3bdata/fibData/R3BBunchedFiberHitData.cxx @@ -23,12 +23,18 @@ R3BBunchedFiberHitData::R3BBunchedFiberHitData() { } -R3BBunchedFiberHitData::R3BBunchedFiberHitData(Int_t a_fiber_id, +R3BBunchedFiberHitData::R3BBunchedFiberHitData(Int_t ID, + Double_t x, + Double_t y, + Double_t eloss, + Double_t time, + Int_t a_fiber_id, Double_t a_mapmt_time_ns, Double_t a_spmt_time_ns, Double_t a_mapmt_tot_ns, Double_t a_spmt_tot_ns) - : fFiberId(a_fiber_id) + : R3BHit(ID, x, y, eloss, time) + , fFiberId(a_fiber_id) , fMAPMTTime_ns(a_mapmt_time_ns) , fSPMTTime_ns(a_spmt_time_ns) , fTime_ns((a_mapmt_time_ns + a_spmt_time_ns) / 2) diff --git a/r3bdata/fibData/R3BBunchedFiberHitData.h b/r3bdata/fibData/R3BBunchedFiberHitData.h index 45eb6ebd8..b00f76a62 100644 --- a/r3bdata/fibData/R3BBunchedFiberHitData.h +++ b/r3bdata/fibData/R3BBunchedFiberHitData.h @@ -18,13 +18,15 @@ #ifndef R3BBUNCHEDFIBERHITDATA_H #define R3BBUNCHEDFIBERHITDATA_H -#include "TObject.h" +#include "R3BHit.h" -class R3BBunchedFiberHitData : public TObject +class R3BBunchedFiberHitData: public R3BHit { public: R3BBunchedFiberHitData(); - R3BBunchedFiberHitData(Int_t, Double_t, Double_t, Double_t, Double_t); + R3BBunchedFiberHitData(Int_t detId, Double_t x, Double_t y, Double_t eloss, Double_t time, Int_t a_fiber_id, Double_t + a_mapmt_time_ns, Double_t a_spmt_time_ns, Double_t a_mapmt_tot_ns, Double_t a_spmt_tot_ns); + virtual ~R3BBunchedFiberHitData(); Int_t GetFiberId() const; @@ -42,7 +44,11 @@ class R3BBunchedFiberHitData : public TObject Double_t fMAPMTToT_ns; Double_t fSPMTToT_ns; - ClassDef(R3BBunchedFiberHitData, 1) + ClassDef(R3BBunchedFiberHitData, 2) }; #endif + + + + diff --git a/r3bdata/losData/R3BLosCalData.cxx b/r3bdata/losData/R3BLosCalData.cxx index 3a22fd9b1..26bd43c4e 100644 --- a/r3bdata/losData/R3BLosCalData.cxx +++ b/r3bdata/losData/R3BLosCalData.cxx @@ -78,6 +78,7 @@ void R3BLosCalData::Reset() fTimeV_ns[j] = 0.0 / 0.0; fTimeL_ns[j] = 0.0 / 0.0; fTimeT_ns[j] = 0.0 / 0.0; + fTimeM_ns[j] = 0.0 / 0.0; } } @@ -97,7 +98,12 @@ Double_t R3BLosCalData::GetTimeT_ns(UInt_t chann) const { ASSERT(chann, <, LENGTH(fTimeT_ns)); return fTimeT_ns[chann]; - ; +} + +Double_t R3BLosCalData::GetTimeM_ns(UInt_t chann) const +{ + ASSERT(chann, <, LENGTH(fTimeM_ns)); + return fTimeM_ns[chann]; } /* @@ -295,6 +301,22 @@ Double_t R3BLosCalData::GetMeanTimeVFTX() return num_times ? mean / num_times : NAN; } + +Double_t R3BLosCalData::GetMeanTimeMTDC32() +{ + Double_t mean = 0; + Int_t num_times = 0; + for (Int_t i = 0; i < 8; i++) + { + if (!std::isnan(fTimeM_ns[i])) + { + mean += fTimeM_ns[i]; + num_times++; + } + } + return num_times ? mean / num_times : NAN; +} + UInt_t R3BLosCalData::GetVFTXNcha() { Int_t num_times = 0; @@ -308,5 +330,17 @@ UInt_t R3BLosCalData::GetVFTXNcha() return num_times; } +UInt_t R3BLosCalData::GetMTDC32Ncha() +{ + Int_t num_times = 0; + for (Int_t i = 0; i < 8; i++) + { + if (!std::isnan(fTimeM_ns[i])) + { + num_times++; + } + } + return num_times; +} ClassImp(R3BLosCalData) diff --git a/r3bdata/losData/R3BLosCalData.h b/r3bdata/losData/R3BLosCalData.h index c13b6ea14..507f06125 100644 --- a/r3bdata/losData/R3BLosCalData.h +++ b/r3bdata/losData/R3BLosCalData.h @@ -35,26 +35,30 @@ class R3BLosCalData : public TObject UInt_t GetVFTXNcha(); UInt_t GetTAMEXLNcha(); UInt_t GetTAMEXTNcha(); - - Double_t GetTimeV_ns(UInt_t) const; - Double_t GetTimeL_ns(UInt_t) const; - Double_t GetTimeT_ns(UInt_t) const; + UInt_t GetMTDC32Ncha(); + + Double_t GetTimeV_ns(UInt_t) const; + Double_t GetTimeL_ns(UInt_t) const; + Double_t GetTimeT_ns(UInt_t) const; + Double_t GetTimeM_ns(UInt_t) const; Double_t GetMeanTime(); Double_t GetMeanTimeTAMEXL(); Double_t GetMeanTimeTAMEXT(); Double_t GetMeanTimeVFTX(); - + Double_t GetMeanTimeMTDC32(); + private: UInt_t fDetector; void Reset(); public: - Double_t fTimeV_ns[8]; // VFTX - Double_t fTimeL_ns[8]; // TAMEX leading - Double_t fTimeT_ns[8]; // TAMEX trailing + Double_t fTimeV_ns[8]; // VFTX + Double_t fTimeL_ns[8]; // TAMEX leading + Double_t fTimeT_ns[8]; // TAMEX trailing + Double_t fTimeM_ns[8]; // MTDC32 - ClassDef(R3BLosCalData, 1) + ClassDef(R3BLosCalData, 2) }; #endif diff --git a/r3bdata/sampData/R3BSamplerMappedData.cxx b/r3bdata/sampData/R3BSamplerMappedData.cxx new file mode 100644 index 000000000..a327b608e --- /dev/null +++ b/r3bdata/sampData/R3BSamplerMappedData.cxx @@ -0,0 +1,19 @@ +#include "R3BSamplerMappedData.h" +#include "FairLogger.h" +#include + +using namespace std; + +R3BSamplerMappedData::R3BSamplerMappedData() + : fTime(-1) // VULOM timestamp. +{ +} + +R3BSamplerMappedData::R3BSamplerMappedData(UInt_t time) + : fTime(time) +{ +} + +UInt_t R3BSamplerMappedData::GetTime() const { return fTime; } + +ClassImp(R3BSamplerMappedData) diff --git a/r3bdata/sampData/R3BSamplerMappedData.h b/r3bdata/sampData/R3BSamplerMappedData.h new file mode 100644 index 000000000..542568776 --- /dev/null +++ b/r3bdata/sampData/R3BSamplerMappedData.h @@ -0,0 +1,26 @@ +#ifndef R3BSAMPLERMAPPEDITEM_H +#define R3BSAMPLERMAPPEDITEM_H + +#include "TObject.h" + +// For the data analysis of the SAMPLER. + +class R3BSamplerMappedData : public TObject +{ + public: + // Default Constructor + R3BSamplerMappedData(); + + // Standard Constructor + R3BSamplerMappedData(UInt_t); + + UInt_t GetTime() const; + + public: + UInt_t fTime; + + public: + ClassDef(R3BSamplerMappedData, 1) +}; + +#endif diff --git a/r3bdata/sci2Data/R3BSci2CalData.cxx b/r3bdata/sci2Data/R3BSci2CalData.cxx new file mode 100644 index 000000000..ff64c99f7 --- /dev/null +++ b/r3bdata/sci2Data/R3BSci2CalData.cxx @@ -0,0 +1,172 @@ +#include "R3BSci2CalData.h" +#include "FairLogger.h" +#include +#include + +/* Re isnan: + * std::isnan is defined as an overloaded function in cmath + * the macro isnan is defined in math.h + * if you include math.h and do using namespace std;, my + * compiler will complain about ambiguous definition of isnan + * because cmath seems to get pulled in as a dependency. + * + * Solution: we explicitly include cmath and do not commit + * what has been described as the + * "environmental crime of namespace pollution", + * in case anyone includes math.h for some reason. + */ + +/* for the data analysis of Sci2 detector. + */ + +R3BSci2CalData::R3BSci2CalData() + : fDetector(0) +{ +} + +R3BSci2CalData::R3BSci2CalData(UInt_t detector) + : fDetector(detector) + , fTimeV_r_ns(0.0 / 0.0) // 0/0 produces a NAN. Macro NAN not available?? + , fTimeV_l_ns(0.0 / 0.0) + , fTimeL_r_ns(0.0 / 0.0) + , fTimeL_l_ns(0.0 / 0.0) + , fTimeT_r_ns(0.0 / 0.0) + , fTimeT_l_ns(0.0 / 0.0) +{ +} + +Double_t R3BSci2CalData::GetMeanTime() +{ + Double_t mean = 0; + Int_t num_times = 0; + if (!std::isnan(fTimeV_r_ns)) + { + mean += fTimeV_r_ns; + num_times++; + } + if (!std::isnan(fTimeV_l_ns)) + { + mean += fTimeV_l_ns; + num_times++; + } + if (!std::isnan(fTimeL_r_ns)) + { + mean += fTimeL_r_ns; + num_times++; + } + if (!std::isnan(fTimeL_l_ns)) + { + mean += fTimeL_l_ns; + num_times++; + } + if (!std::isnan(fTimeT_r_ns)) + { + mean += fTimeT_r_ns; + num_times++; + } + if (!std::isnan(fTimeT_l_ns)) + { + mean += fTimeT_l_ns; + num_times++; + } + + return num_times ? mean / num_times : NAN; +} +Double_t R3BSci2CalData::GetMeanTimeTAMEXL() +{ + Double_t mean = 0; + Int_t num_times = 0; + if (!std::isnan(fTimeL_r_ns)) + { + mean += fTimeL_r_ns; + num_times++; + } + if (!std::isnan(fTimeL_l_ns)) + { + mean += fTimeL_l_ns; + num_times++; + } + + return num_times ? mean / num_times : NAN; +} + +Double_t R3BSci2CalData::GetMeanTimeTAMEXT() +{ + Double_t mean = 0; + Int_t num_times = 0; + if (!std::isnan(fTimeT_r_ns)) + { + mean += fTimeT_r_ns; + num_times++; + } + if (!std::isnan(fTimeT_l_ns)) + { + mean += fTimeT_l_ns; + num_times++; + } + + return num_times ? mean / num_times : NAN; +} + +UInt_t R3BSci2CalData::GetTAMEXLNcha() +{ + Int_t num_times = 0; + if (!std::isnan(fTimeL_r_ns)) + { + num_times++; + } + if (!std::isnan(fTimeL_l_ns)) + { + num_times++; + } + + return num_times; +} + +UInt_t R3BSci2CalData::GetTAMEXTNcha() +{ + Int_t num_times = 0; + if (!std::isnan(fTimeT_r_ns)) + { + num_times++; + } + if (!std::isnan(fTimeT_l_ns)) + { + num_times++; + } + + return num_times; +} + +Double_t R3BSci2CalData::GetMeanTimeVFTX() +{ + Double_t mean = 0; + Int_t num_times = 0; + if (!std::isnan(fTimeV_r_ns)) + { + mean += fTimeV_r_ns; + num_times++; + } + if (!std::isnan(fTimeV_l_ns)) + { + mean += fTimeV_l_ns; + num_times++; + } + + return num_times ? mean / num_times : NAN; +} +UInt_t R3BSci2CalData::GetVFTXNcha() +{ + Int_t num_times = 0; + if (!std::isnan(fTimeV_r_ns)) + { + num_times++; + } + if (!std::isnan(fTimeV_l_ns)) + { + num_times++; + } + + return num_times; +} +ClassImp(R3BSci2CalData) diff --git a/r3bdata/sci2Data/R3BSci2CalData.h b/r3bdata/sci2Data/R3BSci2CalData.h new file mode 100644 index 000000000..42ee77e2e --- /dev/null +++ b/r3bdata/sci2Data/R3BSci2CalData.h @@ -0,0 +1,47 @@ +#ifndef R3BSCI2CALITEM_H +#define R3BSCI2CALITEM_H + +#include "TObject.h" + +// for the data analysis of the Sci2 detectors. + +class R3BSci2CalData : public TObject +{ + public: + // Default Constructor + R3BSci2CalData(); + + // Standard Constructor + R3BSci2CalData(UInt_t detector); + + // Destructor + virtual ~R3BSci2CalData() { } + + // Getters + inline const UInt_t& GetDetector() const { return fDetector; } + + Double_t GetMeanTime(); + Double_t GetMeanTimeTAMEXL(); + Double_t GetMeanTimeTAMEXT(); + Double_t GetMeanTimeVFTX(); + UInt_t GetVFTXNcha(); + UInt_t GetTAMEXLNcha(); + UInt_t GetTAMEXTNcha(); + + private: + UInt_t fDetector; + + public: + Double_t fTimeV_r_ns; // right VFTX + Double_t fTimeV_l_ns; // left VFTX + Double_t fTimeL_r_ns; // right TAMEX leading + Double_t fTimeL_l_ns; // left TAMEX leading + Double_t fTimeT_r_ns; // right TAMEX trailing + Double_t fTimeT_l_ns; // left TAMEX trailing + + ClassDef(R3BSci2CalData, 1) +}; + +#endif + + diff --git a/r3bdata/sci2Data/R3BSci2HitData.cxx b/r3bdata/sci2Data/R3BSci2HitData.cxx new file mode 100644 index 000000000..c6eee9346 --- /dev/null +++ b/r3bdata/sci2Data/R3BSci2HitData.cxx @@ -0,0 +1,21 @@ + +#include "R3BSci2HitData.h" + +// for the data analysis of the Sci2 detector. + +R3BSci2HitData::R3BSci2HitData() + : fDetector(0) +{ +} + +R3BSci2HitData::R3BSci2HitData(UChar_t detector, Double_t t, Double_t x, Double_t Z) + + : fDetector(detector) + , fTime_ns(t) + , fX_cm(x) + , fZ(Z) + +{ +} + +ClassImp(R3BSci2HitData) diff --git a/r3bdata/sci2Data/R3BSci2HitData.h b/r3bdata/sci2Data/R3BSci2HitData.h new file mode 100644 index 000000000..13d151311 --- /dev/null +++ b/r3bdata/sci2Data/R3BSci2HitData.h @@ -0,0 +1,37 @@ +#ifndef R3BSCI2HITITEM_H +#define R3BSCI2HITITEM_H + +#include "TObject.h" + +// for the data analysis of the SCI2 detectors. + + +class R3BSci2HitData : public TObject +{ + public: + // Default Constructor + R3BSci2HitData(); + + // Standard Constructor + R3BSci2HitData(UChar_t detector,Double_t t,Double_t x, Double_t Z); + + // Destructor + virtual ~R3BSci2HitData() { } + + // Getters + inline const UChar_t& GetDetector() const { return fDetector; } + + private: + UChar_t fDetector; // 1..n + Double_t fTime_ns; // average time of the scintillators + Double_t fX_cm; // position in cm + Double_t fZ; // Charge + + public: + + ClassDef(R3BSci2HitData, 1) +}; + +#endif + + diff --git a/r3bdata/sci2Data/R3BSci2MappedData.cxx b/r3bdata/sci2Data/R3BSci2MappedData.cxx new file mode 100644 index 000000000..47e3d140a --- /dev/null +++ b/r3bdata/sci2Data/R3BSci2MappedData.cxx @@ -0,0 +1,32 @@ + +#include "R3BSci2MappedData.h" +#include "FairLogger.h" +#include "TMath.h" +#define IS_NAN(x) TMath::IsNaN(x) +#include + +using namespace std; + +// for the data analysis of the Sci2 detector. + +R3BSci2MappedData::R3BSci2MappedData() + : fDetector(0) // Detector number: 1...n + , fChannel(0) // Channel number: 1,2 + , fType(0) // Type: 0 = VFTX time, 1 = TAMEX leading edge, 2 = TAMEX trailing edge + , fTimeFine(-1) // Fine time + , fTimeCoarse(-1) // Coarse time +{ +} + +R3BSci2MappedData::R3BSci2MappedData(UInt_t detector, UInt_t channel, UInt_t type, UInt_t timeFine, UInt_t timeCoarse) + : fDetector(detector) + , fChannel(channel) + , fType(type) + , fTimeFine(timeFine) + , fTimeCoarse(timeCoarse) +{ + // cout<<"R3BSci2MappedData: chann. "<< channel <<", type "<Uniform(-fx,fx); - fVy = fOffset + SpotR * sin(Phi); // gRandom->Uniform(-fy,fy); + fVx = fOffset + SpotR * cos(Phi); // gRandom->Uniform(-fx,fx); + fVy = SpotR * sin(Phi); // gRandom->Uniform(-fy,fy); + // fVy = 0.; fVz = fz; } else @@ -226,15 +235,39 @@ Bool_t R3BIonGenerator::ReadEvent(FairPrimaryGenerator* primGen) fVz = 0.0; } - cout << "-I- FairIonGenerator: Generating " << fMult << " ions of type " << fIon->GetName() << " (PDG code " - << pdgType << ")" << endl; - cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") Gev from vertex (" << fVx << ", " << fVy << ", " - << fVz << ") cm" << endl; + if (fSigmaP > 0.) + { + Double_t p0 = gRandom->Uniform(fPz - fSigmaP, fPz + fSigmaP); + fPz = p0; + } + + if (fAngle > 0.) + { + Double_t p = sqrt(fPx * fPx + fPy * fPy + fPz * fPz); + Double_t thetaX = gRandom->Uniform(-fAngle, fAngle); // max angle in mrad + fPx = tan(thetaX) * fPz; + + Double_t thetaY = gRandom->Uniform(-fAngle, fAngle); // max angle in mrad + fPy = tan(thetaY) * fPz; + fPz = sqrt(p * p - fPx * fPx - fPy * fPy); + + // cout<< " theta "<< thetaX << " " << thetaY << " "<GetName() << " (PDG code " << pdgType << ")" << endl; + cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz + << ") Gev from vertex (" << fVx << ", " << fVy + << ", " << fVz << ") cm" << endl; + */ for (Int_t i = 0; i < fMult; i++) primGen->AddTrack(pdgType, fPx, fPy, fPz, fVx, fVy, fVz); return kTRUE; + + return kTRUE; } //_____________________________________________________________________________ diff --git a/r3bgen/R3BIonGenerator.h b/r3bgen/R3BIonGenerator.h index 0fdb1c4db..9a7951c8e 100644 --- a/r3bgen/R3BIonGenerator.h +++ b/r3bgen/R3BIonGenerator.h @@ -81,6 +81,12 @@ class R3BIonGenerator : public FairGenerator fBeamSpotIsSet = kTRUE; } + void SetBeamParameter(Double32_t sigmaP = 0, Double32_t angle = 0) + { + fSigmaP = sigmaP; + fAngle = angle; + } + /** Method ReadEvent ** Generates of the specified ions and hands hem to the ** FairPrimaryGenerator. @@ -95,6 +101,7 @@ class R3BIonGenerator : public FairGenerator Double_t fVx, fVy, fVz; // Vertex coordinates [cm] FairIon* fIon; // Pointer to the FairIon to be generated Int_t fQ; // Electric charge [e] + Double32_t fSigmaP, fAngle; // beam variation in momentum, angle of emittance Bool_t fBeamSpotIsSet; // True if point beamspot is set diff --git a/r3bsource/CMakeLists.txt b/r3bsource/CMakeLists.txt index 88222f3c4..5c19a9c46 100644 --- a/r3bsource/CMakeLists.txt +++ b/r3bsource/CMakeLists.txt @@ -32,6 +32,7 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/pspData ${R3BROOT_SOURCE_DIR}/r3bdata/fibData ${R3BROOT_SOURCE_DIR}/r3bdata/losData ${R3BROOT_SOURCE_DIR}/r3bdata/roluData +${R3BROOT_SOURCE_DIR}/r3bdata/sci2Data ${R3BROOT_SOURCE_DIR}/r3bdata/sci8Data ${R3BROOT_SOURCE_DIR}/r3bdata/tofData ${R3BROOT_SOURCE_DIR}/r3bdata/strawtubesData @@ -40,6 +41,7 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/startrackData ${R3BROOT_SOURCE_DIR}/r3bdata/amsData ${R3BROOT_SOURCE_DIR}/r3bdata/wrData ${R3BROOT_SOURCE_DIR}/r3bdata/musicData +${R3BROOT_SOURCE_DIR}/r3bdata/sampData ) set(LINK_DIRECTORIES @@ -61,6 +63,7 @@ R3BWhiterabbitMasterReader.cxx R3BWhiterabbitCalifaReader.cxx R3BWhiterabbitAmsReader.cxx R3BTrloiiTpatReader.cxx +R3BTrloiiSampReader.cxx R3BTimestampMasterReader.cxx R3BPspxReader.cxx R3BBunchedFiberReader.cxx @@ -84,6 +87,7 @@ R3BFi12Reader.cxx R3BFi13Reader.cxx R3BLosReader.cxx R3BRoluReader.cxx +R3BSci2Reader.cxx R3BSci8Reader.cxx R3BTofdReader.cxx R3BCalifaFebexReader.cxx @@ -123,8 +127,10 @@ ext_h101_fibten.h ext_h101_fibeleven.h ext_h101_fibtwelve.h ext_h101_fibthirteen.h -ext_h101_los_tamex.h +#ext_h101_los_tamex.h +ext_h101_los_dez19.h ext_h101_rolu.h +ext_h101_sci2.h ext_h101_sci8.h ext_h101_tofd.h ext_h101_ptof.h @@ -137,6 +143,7 @@ ext_h101_star.h ext_h101_fibfour.h ext_h101_ams.h ext_h101_music.h +ext_h101_samp.h ) # fill list of header files from list of source files diff --git a/r3bsource/R3BLinkDef.h b/r3bsource/R3BLinkDef.h index 99127772e..fc0671669 100644 --- a/r3bsource/R3BLinkDef.h +++ b/r3bsource/R3BLinkDef.h @@ -23,39 +23,41 @@ #pragma link C++ class R3BReader + ; #pragma link C++ class R3BUnpackReader + ; //#pragma link C++ class R3BWhiterabbitReader+; -#pragma link C++ class R3BWhiterabbitMasterReader + ; -#pragma link C++ class R3BWhiterabbitCalifaReader + ; -#pragma link C++ class R3BWhiterabbitAmsReader + ; -#pragma link C++ class R3BTrloiiTpatReader + ; -#pragma link C++ class R3BTimestampMasterReader + ; -#pragma link C++ class R3BBeamMonitorReader + ; -#pragma link C++ class R3BPspxReader + ; -#pragma link C++ class R3BBunchedFiberReader + ; -#pragma link C++ class R3BFi0Reader + ; -#pragma link C++ class R3BFi1aReader + ; -#pragma link C++ class R3BFi1bReader + ; -#pragma link C++ class R3BFi3aReader + ; -#pragma link C++ class R3BFi3bReader + ; -#pragma link C++ class R3BFi4Reader + ; -#pragma link C++ class R3BFi5Reader + ; -#pragma link C++ class R3BFi6Reader + ; -#pragma link C++ class R3BFi7Reader + ; -#pragma link C++ class R3BFi8Reader + ; -#pragma link C++ class R3BFi10Reader + ; -#pragma link C++ class R3BFi11Reader + ; -#pragma link C++ class R3BFi12Reader + ; -#pragma link C++ class R3BFi13Reader + ; -#pragma link C++ class R3BLosReader + ; -#pragma link C++ class R3BRoluReader + ; -#pragma link C++ class R3BSci8Reader + ; -#pragma link C++ class R3BTofdReader + ; -#pragma link C++ class R3BCalifaFebexReader + ; -#pragma link C++ class R3BPtofReader + ; -#pragma link C++ class R3BNeulandTamexReader + ; -#pragma link C++ class R3BNeulandTacquilaReader + ; -#pragma link C++ class R3BStrawtubesReader + ; -#pragma link C++ class R3BStartrackReader + ; -#pragma link C++ class R3BAmsReader + ; +#pragma link C++ class R3BWhiterabbitMasterReader+; +#pragma link C++ class R3BWhiterabbitCalifaReader+; +#pragma link C++ class R3BWhiterabbitAmsReader+; +#pragma link C++ class R3BTrloiiTpatReader+; +#pragma link C++ class R3BTrloiiSampReader+; +#pragma link C++ class R3BTimestampMasterReader+; +#pragma link C++ class R3BBeamMonitorReader+; +#pragma link C++ class R3BPspxReader+; +#pragma link C++ class R3BBunchedFiberReader+; +#pragma link C++ class R3BFi0Reader+; +#pragma link C++ class R3BFi1aReader+; +#pragma link C++ class R3BFi1bReader+; +#pragma link C++ class R3BFi3aReader+; +#pragma link C++ class R3BFi3bReader+; +#pragma link C++ class R3BFi4Reader+; +#pragma link C++ class R3BFi5Reader+; +#pragma link C++ class R3BFi6Reader+; +#pragma link C++ class R3BFi7Reader+; +#pragma link C++ class R3BFi8Reader+; +#pragma link C++ class R3BFi10Reader+; +#pragma link C++ class R3BFi11Reader+; +#pragma link C++ class R3BFi12Reader+; +#pragma link C++ class R3BFi13Reader+; +#pragma link C++ class R3BLosReader+; +#pragma link C++ class R3BRoluReader+; +#pragma link C++ class R3BSci2Reader+; +#pragma link C++ class R3BSci8Reader+; +#pragma link C++ class R3BTofdReader+; +#pragma link C++ class R3BCalifaFebexReader+; +#pragma link C++ class R3BPtofReader+; +#pragma link C++ class R3BNeulandTamexReader+; +#pragma link C++ class R3BNeulandTacquilaReader+; +#pragma link C++ class R3BStrawtubesReader+; +#pragma link C++ class R3BStartrackReader+; +#pragma link C++ class R3BAmsReader+; #pragma link C++ class R3BMusicReader + ; //#pragma link C++ class R3BFib4Reader+; @@ -80,6 +82,7 @@ #pragma link C++ class EXT_STR_h101_FIBELEVEN_onion_t; #pragma link C++ class EXT_STR_h101_FIBTWELVE_onion_t; #pragma link C++ class EXT_STR_h101_FIBTHIRTEEN_onion_t; +#pragma link C++ class EXT_STR_h101_SCI2_onion_t; #pragma link C++ class EXT_STR_h101_SCI8_onion_t; #pragma link C++ class EXT_STR_h101_LOS_TAMEX_onion_t; #pragma link C++ class EXT_STR_h101_ROLU_onion_t; @@ -95,4 +98,5 @@ #pragma link C++ class EXT_STR_h101_WRCALIFA_onion_t; #pragma link C++ class EXT_STR_h101_WRAMS_onion_t; #pragma link C++ class EXT_STR_h101_MUSIC_onion_t; +#pragma link C++ class EXT_STR_h101_SAMP_onion_t; #endif diff --git a/r3bsource/R3BLosReader.cxx b/r3bsource/R3BLosReader.cxx index bcda9a398..444c0f77f 100644 --- a/r3bsource/R3BLosReader.cxx +++ b/r3bsource/R3BLosReader.cxx @@ -1,16 +1,3 @@ -/****************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2019 Members of R3B Collaboration * - * * - * This software is distributed under the terms of the * - * GNU General Public Licence (GPL) version 3, * - * copied verbatim in the file "LICENSE". * - * * - * In applying this license GSI does not waive the privileges and immunities * - * granted to it by virtue of its status as an Intergovernmental Organization * - * or submit itself to any jurisdiction. * - ******************************************************************************/ - #include "R3BLosReader.h" #include "FairLogger.h" #include "FairRootManager.h" @@ -20,17 +7,19 @@ extern "C" { #include "ext_data_client.h" -#include "ext_h101_los_tamex.h" +#include "ext_h101_los_dez19.h" + //#include "ext_h101_los.h" } #include "TMath.h" #define IS_NAN(x) TMath::IsNaN(x) -#define NUM_LOS_DETECTORS 1 +//#define NUM_LOS_DETECTORS 1 +#define NUM_LOS_DETECTORS (sizeof data->LOS / sizeof data->LOS[0]) #define NUM_LOS_CHANNELS 8 #include using namespace std; -R3BLosReader::R3BLosReader(EXT_STR_h101_LOS_TAMEX* data, UInt_t offset) +R3BLosReader::R3BLosReader(EXT_STR_h101_LOS* data, UInt_t offset) : R3BReader("R3BLosReader") , fData(data) , fOffset(offset) @@ -61,7 +50,7 @@ Bool_t R3BLosReader::Init(ext_data_struct_info* a_struct_info) header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); - EXT_STR_h101_LOS_TAMEX_ITEMS_INFO(ok, *a_struct_info, fOffset, EXT_STR_h101_LOS_TAMEX, 0); + EXT_STR_h101_LOS_ITEMS_INFO(ok, *a_struct_info, fOffset, EXT_STR_h101_LOS, 0); if (!ok) { perror("ext_data_struct_info_item"); @@ -82,7 +71,7 @@ Bool_t R3BLosReader::Init(ext_data_struct_info* a_struct_info) // clear struct_writer's output struct. Seems ucesb doesn't do that // for channels that are unknown to the current ucesb config. - EXT_STR_h101_LOS_TAMEX_onion* data = (EXT_STR_h101_LOS_TAMEX_onion*)fData; + EXT_STR_h101_LOS_onion* data = (EXT_STR_h101_LOS_onion*)fData; for (uint32_t d = 0; d < NUM_LOS_DETECTORS; d++) { data->LOS[d].VTFM = 0; @@ -91,6 +80,7 @@ Bool_t R3BLosReader::Init(ext_data_struct_info* a_struct_info) data->LOS[d].TTFTM = 0; data->LOS[d].TTCLM = 0; data->LOS[d].TTCTM = 0; + data->LOS[d].MTM = 0; } return kTRUE; } @@ -99,10 +89,10 @@ Bool_t R3BLosReader::Read() { // Convert plain raw data to multi-dimensional array - EXT_STR_h101_LOS_TAMEX_onion* data = (EXT_STR_h101_LOS_TAMEX_onion*)fData; + EXT_STR_h101_LOS_onion* data = (EXT_STR_h101_LOS_onion*)fData; /* - * For variable definition, see structure EXT_STR_h101_LOS_TAMEX_onion_t + * For variable definition, see structure EXT_STR_h101_LOS_onion_t * in ext_str_h101_los_tamex.h *** VFTX DATA *** * VTF = Size of the array TFv contaning fine VFTX times @@ -135,13 +125,21 @@ Bool_t R3BLosReader::Read() */ // loop over all detectors + // cout<<"*************** READER START ******************"<LOS[d].VTF<<", "<LOS[d].TTFL<<", "<LOS[d].TTFT<LOS[d].VTC<<", "<LOS[d].TTCL<<", "<LOS[d].TTCT<LOS[d].VTF > 0) + { + // cout<<"FINE: iDet "<LOS[d].VTF<<", "<LOS[d].TTFL<<", + // "<LOS[d].TTFT<LOS[d].VTC<<", "<LOS[d].TTCL<<", + // "<LOS[d].TTCT<LOS[d].VTF != data->LOS[d].VTC) return kFALSE; if(data->LOS[d].TTFL != data->LOS[d].TTCL) return kFALSE; @@ -169,7 +167,8 @@ Bool_t R3BLosReader::Read() bool do_increment = false; for (uint32_t i = 0; i < numData; i++) { - uint32_t coarse_vftx = data->LOS[d].VTCv[i]; + uint32_t coarse_vftx = 0. / 0.; + coarse_vftx = data->LOS[d].VTCv[i]; if (coarse_vftx > 3 * c_vftx2_range / 4) { do_increment = true; @@ -202,7 +201,8 @@ Bool_t R3BLosReader::Read() coarse_vftx // VFTX coarse time ); - // cout<<"VFTX: "<LOS[d].VTFv[j]<<", "<LOS[d].VTFv[j]<<", "<GetEntriesFast()]) R3BLosMappedData(d + 1, channel, 1, data->LOS[d].TTFLv[j], coarse_leading); - // cout<<"TAMEX leading: "<< data->LOS[d].TTFLv[j]<<", "<< coarse_leading<LOS[d].TTFLv[j]<<", "<< + // coarse_leading<GetTimeCoarse(); int32_t tot = coarse_trailing - coarse_leading; // 30 units -> 30 * 5 = 150 ns. - if ((tot <= 35) && (tot >= 0)) - { + if ((tot >= 0)) + { // tot <= 135) && new ((*fArray)[fArray->GetEntriesFast()]) R3BLosMappedData(d + 1, channel, 2, data->LOS[d].TTFTv[j], coarse_trailing); - - // cout<<"TAMEX trailing: "<< data->LOS[d].TTFTv[j]<<", "<< coarse_trailing<LOS[d].TTFTv[j]<<", "<< coarse_trailing<LOS[d].MTM; + curChannelStart = 0; + // cout<LOS[d].MTM<LOS[d].MTMI[i]; // = 1..8 + uint32_t nextChannelStart = data->LOS[d].MTME[i]; + /* for (uint32_t j = curChannelStart; j < nextChannelStart; j++) { + new ((*fArray)[fArray->GetEntriesFast()]) + R3BLosMappedData( + d + 1, // detector number + channel, // channel number: 1-8 + 3, // VFTX (0),TAMEX leading (1), TAMEX trailing (2), MTDC32 (3) + data->LOS[d].MTv[j], // MTDC32 time + 0 + ); + + cout<<"MTDC: "<LOS[d].MTv[j] <LOS[d].VTF > 0) + { + // cout<<"nsumv & data->LOS[d].VTF "<LOS[d].VTF<LOS[d].TTFL "<LOS[d].TTFL<LOS[d].TTFT "<LOS[d].TTFT< + +using namespace std; + +R3BSci2Reader::R3BSci2Reader(EXT_STR_h101_SCI2* data, UInt_t offset) + : R3BReader("R3BSci2Reader") + , fData(data) + , fOffset(offset) + , fLogger(FairLogger::GetLogger()) + , fArray(new TClonesArray("R3BSci2MappedData")) +{ +} + +R3BSci2Reader::~R3BSci2Reader() {} + +Bool_t R3BSci2Reader::Init(ext_data_struct_info* a_struct_info) +{ + + int ok; + + EXT_STR_h101_SCI2_ITEMS_INFO(ok, *a_struct_info, fOffset, EXT_STR_h101_SCI2, 0); + + if (!ok) + { + perror("ext_data_struct_info_item"); + LOG(error) << "Failed to setup structure information."; + return kFALSE; + } + + // Register output array in tree + FairRootManager::Instance()->Register("Sci2Mapped", "Land", fArray, kTRUE); + fArray->Clear(); + + // clear struct_writer's output struct. Seems ucesb doesn't do that + // for channels that are unknown to the current ucesb config. + EXT_STR_h101_SCI2_onion* data = (EXT_STR_h101_SCI2_onion*)fData; + + for (int d = 0; d < NUM_SCI2_DETECTORS; d++) + { + data->SCITWO_VTFM = 0; + data->SCITWO_VTCM = 0; + /* no TAMEX present + data->SCITWO_TTFLM=0; + data->SCITWO_TTFTM=0; + data->SCITWO_TTCLM=0; + data->SCITWO_TTCTM=0; + */ + } + return kTRUE; +} + +Bool_t R3BSci2Reader::Read() +{ + // Convert plain raw data to multi-dimensional array + EXT_STR_h101_SCI2_onion* data = (EXT_STR_h101_SCI2_onion*)fData; + + /* + * For variable definition, see structure EXT_STR_h101_SCI2_onion_t + * in ext_str_h101_sci2_tamex.h + *** VFTX DATA *** + * VTF = Size of the array TFv contaning fine VFTX times + * VTFv = Array containing the actual data on the fine times + * VTFM = No of channels having time + * VTFMI = Array of TFM size containing the channel numbers of each channel with data + * VTFME = Array of TFM size containing the index of the first element of the next channel in data array TFv; + * TFME[i]-FTME[i-1] = number of data for channel i; + * + * VTC = Size of the array TCv contaning coarse VFTX times + * VTCv = Array containing the actual data on the coarse times + * VTCM = No of channels having coarse time + * VTCMI = Array of TCM size containing the channel numbers of each channel with data + * VTCME = Array of TCM size containing the index of the first element of the next channel in data array TCv + * + *** TAMEX DATA *** Added by Aleksandra, Oct. 2016 + * TTFL = Size of the array TFLv contaning fine leading times + * TTFLv = Array containing the actual data on the fine leading times + * TTFLM = No of channels having fine leading time + * TTFLMI = Array of TFLM size containing the channel numbers of each channel with data + * TTFLME = Array of TFLM size containing the index of the first element of the next channel in data array TFLv + * + * TTCL = Size of the array TCLv contaning coarse leading times + * TTCLv = Array containing the actual data on the coarse leading times + * TTCLM = No of channels having coarse leading time + * TTCLMI = Array of TCLM size containing the channel numbers of each channel with data + * TTCLME = Array of TCLM size containing the index of the first element of the next channel in data array TCLv + * + * The same logic is for trailing times: TTFT, TTFTv, ..., TTCTMI, TTCTME + */ + + // loop over all detectors + + Bool_t fprint = false; + + for (int d = 0; d < NUM_SCI2_DETECTORS; d++) + { + + Int_t Sum = data->SCITWO_VTF; // no Tamex present+data->SCITWO_TTFT+data->SCITWO_TTFL; + // if(data->S2TTFT != data->S2TTFL) fprint = true; + // if(fNEvents == 9698 || fNEvents == 9701 || fNEvents == 9704) fprint = true; + // First, we prepare time arrays for VFTX + + // VFTX first: + uint32_t numChannels = data->SCITWO_VTFM; // not necessarly number of hits! (b/c multi hit) + // loop over channels + uint32_t curChannelStart = 0; // index in v for first item of current channel + Double_t mean_coarse_vftx = 0.; + int sum_coarse_vftx = 0; + // First get the average coarse time to shift all coarse counters in the same cycle (by calculateing, in the + // second step, deviations from the mean value. If the coarse time is smaller than mean value by more than 200, + // then coarse counter was reseted, and thus, to its value 8192 (in case of VFTX) will be added. + for (int i = 0; i < numChannels; i++) + { + uint32_t channel = data->SCITWO_VTFMI[i]; // = 1..8 + uint32_t nextChannelStart = data->SCITWO_VTFME[i]; // index in v for first item of next channel + + for (int j = curChannelStart; j < nextChannelStart; j++) + { + + int coarse_vftx = data->SCITWO_VTCv[j]; + + mean_coarse_vftx = mean_coarse_vftx + coarse_vftx; + sum_coarse_vftx = sum_coarse_vftx + 1; + } + curChannelStart = nextChannelStart; + } + mean_coarse_vftx = mean_coarse_vftx / float(sum_coarse_vftx); + + curChannelStart = 0; + for (int i = 0; i < numChannels; i++) // VFTX, now do the mapping + { + uint32_t channel = data->SCITWO_VTFMI[i]; // = 1..8 + uint32_t nextChannelStart = data->SCITWO_VTFME[i]; // index in v for first item of next channel + + for (int j = curChannelStart; j < nextChannelStart; j++) + { + + int coarse_vftx = data->SCITWO_VTCv[j]; + if ((mean_coarse_vftx - float(coarse_vftx)) > 200.) + coarse_vftx = coarse_vftx + 8192; + + if (fprint) + cout << "SCI2 READER VFTX: " << fNEvents << ", " << Sum << ", " << channel << ", " + << data->SCITWO_VTFv[j] << ", " << data->SCITWO_VTCv[j] << ", " << coarse_vftx << ", " + << mean_coarse_vftx << endl; + + new ((*fArray)[fArray->GetEntriesFast()]) + R3BSci2MappedData(d + 1, // detector number + channel, // channel number: 1-8 + 0, // VFTX (0),TAMEX leading (1), TAMEX trailing (2) + data->SCITWO_VTFv[j], // VFTX fine time + coarse_vftx // VFTX coarse time + ); + } + curChannelStart = nextChannelStart; + } + + // Next, TAMEX leading; first, first get the average coarse time to shift all coarse counters in the same cycle + // (the same as for VFTX, only here on adds 2048). + // if(data->S2TTFT == data->S2TTFL && data->S2TTCT == data->S2TTCL && data->S2TTFL == data->S2TTCL) + + /* no Tamex present + numChannels = data->SCITWO_TTFLM; + curChannelStart=0; + Double_t mean_coarse_leading = 0.; + int sum_coarse_leading = 0; + for (int i=0;iSCITWO_TTFLMI[i]; + uint32_t nextChannelStart = data->SCITWO_TTFLME[i]; + + for (int j = curChannelStart; j < nextChannelStart; j++){ + + int coarse_leading = data->SCITWO_TTCLv[j]; + + mean_coarse_leading = mean_coarse_leading + coarse_leading; + sum_coarse_leading = sum_coarse_leading + 1; + + } + + curChannelStart = nextChannelStart; + } + + + mean_coarse_leading = mean_coarse_leading / float(sum_coarse_leading); + + + // Next, TAMEX leading into mapped array + curChannelStart=0; + Double_t mean_coarse_lead = 0.; + int sum_coarse_lead = 0; + for (int i=0;iSCITWO_TTFLMI[i]; + uint32_t nextChannelStart = data->SCITWO_TTFLME[i]; + + for (int j = curChannelStart; j < nextChannelStart; j++){ + + int coarse_leading = data->SCITWO_TTCLv[j]; + if((mean_coarse_leading - float(coarse_leading)) > 200.) coarse_leading = coarse_leading + 2048; + // We now calculate again meanv alue of the "shifted" coarse leading times; this will be needed at the + next step in order to + // shift coarse trailing times in the same clock cycle as coarse leading + mean_coarse_lead = mean_coarse_lead + coarse_leading; + sum_coarse_lead = sum_coarse_lead + 1; + + if(fprint) cout<<"SCI2 READER leading edges: "<SCITWO_TTFLv[j]<<", "<SCITWO_TTCLv[j]<< + ", "<GetEntriesFast()]) + R3BSci2MappedData( + d+1, + channel, + 1, + data->SCITWO_TTFLv[j], + coarse_leading + ); + + } + + curChannelStart = nextChannelStart; + } + mean_coarse_lead = mean_coarse_lead / float(sum_coarse_lead); + + // At last, TAMEX trailing: for each mapped leading edge, look for correspondiing trailing edge + + numChannels = data->SCITWO_TTFTM; + + curChannelStart=0; + + for (int i=0;iSCITWO_TTFTM;i++) + { + + uint32_t channel = data->SCITWO_TTFTMI[i]; + uint32_t nextChannelStart = data->SCITWO_TTFTME[i]; + + for (int j = curChannelStart; j < nextChannelStart; j++){ + + int coarse=data->SCITWO_TTCTv[j]; + + if(coarse <= 25 && mean_coarse_lead >= 2023) coarse = coarse + 2048; + + if(fprint) cout<<"SCI2 Reader trailing before sorting: "<SCITWO_TTFTv[j]<<"; "<< coarse<<", "<GetEntriesFast(); + for (int k=0;kAt(k); + + UInt_t iTypeL = hit->GetType(); + UInt_t iCha = hit->GetChannel(); + + + if(iTypeL == 1) //(iCha == channel) + { + int coarse_leading=0; + if(iTypeL == 1) coarse_leading = hit->fTimeCoarse; + + int tot=coarse - coarse_leading; + + + if ((tot<=25) && (tot>=0)) // there is a corresponding leading edge + { + + new ((*fArray)[fArray->GetEntriesFast()]) + R3BSci2MappedData( + d+1, + channel, + 2, + data->SCITWO_TTFTv[j], + coarse + ); + + if(fprint) cout<<"SCI2 Reader trailing edges: "<SCITWO_TTFTv[j]<<"; "<< coarse<<", "<Clear(); +} + +ClassImp(R3BSci2Reader) diff --git a/r3bsource/R3BSci2Reader.h b/r3bsource/R3BSci2Reader.h new file mode 100644 index 000000000..2dedade1f --- /dev/null +++ b/r3bsource/R3BSci2Reader.h @@ -0,0 +1,39 @@ +#ifndef R3BSCI2READER_H +#define R3BSCI2READER_H + +#include "R3BReader.h" +#include "FairTask.h" +struct EXT_STR_h101_SCI2_t; +typedef struct EXT_STR_h101_SCI2_t EXT_STR_h101_SCI2; +class FairLogger; +class TH1F; +class TH2F; + +class R3BSci2Reader : public R3BReader +{ + public: + R3BSci2Reader(EXT_STR_h101_SCI2 *, UInt_t); + ~R3BSci2Reader(); + + Bool_t Init(ext_data_struct_info *); + Bool_t Read(); + void Reset(); + virtual void FinishTask(); + + private: + /* Reader specific data structure from ucesb */ + EXT_STR_h101_SCI2* fData; + /* Data offset */ + UInt_t fOffset; + /* FairLogger */ + FairLogger* fLogger; + /* the structs of type R3BSci2xMappedItem */ + TClonesArray* fArray; /**< Output array. */ + Int_t fNEvents = 0; + + public: + ClassDef(R3BSci2Reader, 0); +}; + +#endif + diff --git a/r3bsource/R3BSci8Reader.cxx b/r3bsource/R3BSci8Reader.cxx index c0cf87cf5..d82372793 100644 --- a/r3bsource/R3BSci8Reader.cxx +++ b/r3bsource/R3BSci8Reader.cxx @@ -65,12 +65,14 @@ Bool_t R3BSci8Reader::Init(ext_data_struct_info* a_struct_info) for (int d = 0; d < NUM_SCI8_DETECTORS; d++) { - data->S8VTFM = 0; - data->S8VTCM = 0; - data->S8TTFLM = 0; - data->S8TTFTM = 0; - data->S8TTCLM = 0; - data->S8TTCTM = 0; + data->SCIEIGHT_VTFM = 0; + data->SCIEIGHT_VTCM = 0; + /* no TAMEX present + data->SCIEIGHT_TTFLM=0; + data->SCIEIGHT_TTFTM=0; + data->SCIEIGHT_TTCLM=0; + data->SCIEIGHT_TTCTM=0; + */ } return kTRUE; } @@ -120,13 +122,13 @@ Bool_t R3BSci8Reader::Read() for (int d = 0; d < NUM_SCI8_DETECTORS; d++) { - Int_t Sum = data->S8VTF + data->S8TTFT + data->S8TTFL; + Int_t Sum = data->SCIEIGHT_VTF; // no Tamex present+data->SCIEIGHT_TTFT+data->SCIEIGHT_TTFL; // if(data->S8TTFT != data->S8TTFL) fprint = true; // if(fNEvents == 9698 || fNEvents == 9701 || fNEvents == 9704) fprint = true; // First, we prepare time arrays for VFTX // VFTX first: - uint32_t numChannels = data->S8VTFM; // not necessarly number of hits! (b/c multi hit) + uint32_t numChannels = data->SCIEIGHT_VTFM; // not necessarly number of hits! (b/c multi hit) // loop over channels uint32_t curChannelStart = 0; // index in v for first item of current channel Double_t mean_coarse_vftx = 0.; @@ -136,13 +138,13 @@ Bool_t R3BSci8Reader::Read() // then coarse counter was reseted, and thus, to its value 8192 (in case of VFTX) will be added. for (int i = 0; i < numChannels; i++) { - uint32_t channel = data->S8VTFMI[i]; // = 1..8 - uint32_t nextChannelStart = data->S8VTFME[i]; // index in v for first item of next channel + uint32_t channel = data->SCIEIGHT_VTFMI[i]; // = 1..8 + uint32_t nextChannelStart = data->SCIEIGHT_VTFME[i]; // index in v for first item of next channel for (int j = curChannelStart; j < nextChannelStart; j++) { - int coarse_vftx = data->S8VTCv[j]; + int coarse_vftx = data->SCIEIGHT_VTCv[j]; mean_coarse_vftx = mean_coarse_vftx + coarse_vftx; sum_coarse_vftx = sum_coarse_vftx + 1; @@ -154,157 +156,31 @@ Bool_t R3BSci8Reader::Read() curChannelStart = 0; for (int i = 0; i < numChannels; i++) // VFTX, now do the mapping { - uint32_t channel = data->S8VTFMI[i]; // = 1..8 - uint32_t nextChannelStart = data->S8VTFME[i]; // index in v for first item of next channel + uint32_t channel = data->SCIEIGHT_VTFMI[i]; // = 1..8 + uint32_t nextChannelStart = data->SCIEIGHT_VTFME[i]; // index in v for first item of next channel for (int j = curChannelStart; j < nextChannelStart; j++) { - int coarse_vftx = data->S8VTCv[j]; + int coarse_vftx = data->SCIEIGHT_VTCv[j]; if ((mean_coarse_vftx - float(coarse_vftx)) > 200.) coarse_vftx = coarse_vftx + 8192; if (fprint) cout << "SCI8 READER VFTX: " << fNEvents << ", " << Sum << ", " << channel << ", " - << data->S8VTFv[j] << ", " << data->S8VTCv[j] << ", " << coarse_vftx << ", " + << data->SCIEIGHT_VTFv[j] << ", " << data->SCIEIGHT_VTCv[j] << ", " << coarse_vftx << ", " << mean_coarse_vftx << endl; new ((*fArray)[fArray->GetEntriesFast()]) - R3BSci8MappedData(d + 1, // detector number - channel, // channel number: 1-8 - 0, // VFTX (0),TAMEX leading (1), TAMEX trailing (2) - data->S8VTFv[j], // VFTX fine time - coarse_vftx // VFTX coarse time + R3BSci8MappedData(d + 1, // detector number + channel, // channel number: 1-8 + 0, // VFTX (0),TAMEX leading (1), TAMEX trailing (2) + data->SCIEIGHT_VTFv[j], // VFTX fine time + coarse_vftx // VFTX coarse time ); } curChannelStart = nextChannelStart; } - - // Next, TAMEX leading; first, first get the average coarse time to shift all coarse counters in the same cycle - // (the same as for VFTX, only here on adds 2048). - // if(data->S8TTFT == data->S8TTFL && data->S8TTCT == data->S8TTCL && data->S8TTFL == data->S8TTCL) - if (1 == 1) - { - numChannels = data->S8TTFLM; - curChannelStart = 0; - Double_t mean_coarse_leading = 0.; - int sum_coarse_leading = 0; - for (int i = 0; i < numChannels; i++) - { - uint32_t channel = data->S8TTFLMI[i]; - uint32_t nextChannelStart = data->S8TTFLME[i]; - - for (int j = curChannelStart; j < nextChannelStart; j++) - { - - int coarse_leading = data->S8TTCLv[j]; - - mean_coarse_leading = mean_coarse_leading + coarse_leading; - sum_coarse_leading = sum_coarse_leading + 1; - } - - curChannelStart = nextChannelStart; - } - - mean_coarse_leading = mean_coarse_leading / float(sum_coarse_leading); - - // Next, TAMEX leading into mapped array - curChannelStart = 0; - Double_t mean_coarse_lead = 0.; - int sum_coarse_lead = 0; - for (int i = 0; i < numChannels; i++) - { - uint32_t channel = data->S8TTFLMI[i]; - uint32_t nextChannelStart = data->S8TTFLME[i]; - - for (int j = curChannelStart; j < nextChannelStart; j++) - { - - int coarse_leading = data->S8TTCLv[j]; - if ((mean_coarse_leading - float(coarse_leading)) > 200.) - coarse_leading = coarse_leading + 2048; - // We now calculate again meanv alue of the "shifted" coarse leading times; this will be needed at - // the next step in order to shift coarse trailing times in the same clock cycle as coarse leading - mean_coarse_lead = mean_coarse_lead + coarse_leading; - sum_coarse_lead = sum_coarse_lead + 1; - - if (fprint) - cout << "SCI8 READER leading edges: " << fNEvents << ", " << Sum << ", " << channel << ", " - << data->S8TTFLv[j] << ", " << data->S8TTCLv[j] << ", " << coarse_leading << "; " - << mean_coarse_leading << endl; - - new ((*fArray)[fArray->GetEntriesFast()]) - R3BSci8MappedData(d + 1, channel, 1, data->S8TTFLv[j], coarse_leading); - } - - curChannelStart = nextChannelStart; - } - mean_coarse_lead = mean_coarse_lead / float(sum_coarse_lead); - - // At last, TAMEX trailing: for each mapped leading edge, look for correspondiing trailing edge - - numChannels = data->S8TTFTM; - - curChannelStart = 0; - - for (int i = 0; i < data->S8TTFTM; i++) - { - - uint32_t channel = data->S8TTFTMI[i]; - uint32_t nextChannelStart = data->S8TTFTME[i]; - - for (int j = curChannelStart; j < nextChannelStart; j++) - { - - int coarse = data->S8TTCTv[j]; - - if (coarse <= 25 && mean_coarse_lead >= 2023) - coarse = coarse + 2048; - - if (fprint) - cout << "SCI8 Reader trailing before sorting: " << fNEvents << ", " << Sum << ", " << channel - << ", " << data->S8TTFTv[j] << "; " << coarse << ", " << mean_coarse_lead << endl; - - R3BSci8MappedData* mapped = NULL; - - Int_t n = fArray->GetEntriesFast(); - for (int k = 0; k < n; k++) - { - // Get the leading coarse time from mapped array: - R3BSci8MappedData* hit = (R3BSci8MappedData*)fArray->At(k); - - UInt_t iTypeL = hit->GetType(); - UInt_t iCha = hit->GetChannel(); - - if (iTypeL == 1) //(iCha == channel) - { - int coarse_leading = 0; - if (iTypeL == 1) - coarse_leading = hit->fTimeCoarse; - - int tot = coarse - coarse_leading; - - if ((tot <= 25) && (tot >= 0)) // there is a corresponding leading edge - { - - new ((*fArray)[fArray->GetEntriesFast()]) - R3BSci8MappedData(d + 1, channel, 2, data->S8TTFTv[j], coarse); - - if (fprint) - cout << "SCI8 Reader trailing edges: " << fNEvents << ", " << Sum << ", " << channel - << ", " << data->S8TTFTv[j] << "; " << coarse << ", " << tot << endl; - - break; - } - } - } - } - curChannelStart = nextChannelStart; - } - } - else - { - } } fNEvents += 1; diff --git a/r3bsource/R3BTimestampMasterReader.cxx b/r3bsource/R3BTimestampMasterReader.cxx index b1cba454a..e21ac2301 100644 --- a/r3bsource/R3BTimestampMasterReader.cxx +++ b/r3bsource/R3BTimestampMasterReader.cxx @@ -23,4 +23,6 @@ extern "C" #include "ext_h101_timestamp_master.h" } -R3B_WHITERABBIT_READER_IMPL(TimestampMaster, timestamp_master, 0x100); +R3B_WHITERABBIT_READER_IMPL(TimestampMaster, timestamp_master, 0x300); +// 0x300 for dec2019 +// 0x100 for data before dec2019 diff --git a/r3bsource/R3BTrloiiSampReader.cxx b/r3bsource/R3BTrloiiSampReader.cxx new file mode 100644 index 000000000..98440c160 --- /dev/null +++ b/r3bsource/R3BTrloiiSampReader.cxx @@ -0,0 +1,89 @@ +#include "R3BTrloiiSampReader.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "R3BEventHeader.h" +#include "R3BSamplerMappedData.h" +#include "TClonesArray.h" + +extern "C" +{ +#include "ext_data_client.h" +#include "ext_h101_samp.h" +} + +using namespace std; + +R3BTrloiiSampReader::R3BTrloiiSampReader(EXT_STR_h101_SAMP* data, UInt_t offset) + : R3BReader("R3BTrloiiSampReader") + , fNEvent(0) + , fData(data) + , fOffset(offset) + , fLogger(FairLogger::GetLogger()) + , fEventHeader(nullptr) + , fArray(new TClonesArray("R3BSamplerMappedData")) +{ +} + +R3BTrloiiSampReader::~R3BTrloiiSampReader() +{ + if (fArray) + { + delete fArray; + } +} + +Bool_t R3BTrloiiSampReader::Init(ext_data_struct_info* a_struct_info) +{ + int ok; + + EXT_STR_h101_SAMP_ITEMS_INFO(ok, *a_struct_info, fOffset, EXT_STR_h101_SAMP, 0); + + if (!ok) + { + perror("ext_data_struct_info_item"); + LOG(ERROR) << "Failed to setup structure information."; + return kFALSE; + } + + auto mgr = FairRootManager::Instance(); + fEventHeader = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); + + FairRootManager::Instance()->Register("SamplerMapped", "Land", fArray, kTRUE); + fArray->Clear(); + + fData->SAMP = 0; + + return kTRUE; +} + +Bool_t R3BTrloiiSampReader::Read() +{ + if (fEventHeader) + { + fNEvent = fEventHeader->GetEventno(); + } + else + { + fNEvent++; + } + + for (uint32_t i = 0; i < fData->SAMP; ++i) + { + auto ch = fData->SAMPI[i]; + auto v = fData->SAMPv[i]; + + new ((*fArray)[fArray->GetEntriesFast()]) R3BSamplerMappedData(v); + + // std::cout << "Test" << v << '\n'; + } + + return kTRUE; +} + +void R3BTrloiiSampReader::Reset() +{ + // Reset the output array + fArray->Clear(); +} + +ClassImp(R3BTrloiiSampReader) diff --git a/r3bsource/R3BTrloiiSampReader.h b/r3bsource/R3BTrloiiSampReader.h new file mode 100644 index 000000000..77d5cdb37 --- /dev/null +++ b/r3bsource/R3BTrloiiSampReader.h @@ -0,0 +1,38 @@ +#ifndef R3BTRLOIISAMPREADER_H +#define R3BTRLOIISAMPREADER_H +#include "R3BReader.h" + +struct EXT_STR_h101_SAMP_t; +typedef struct EXT_STR_h101_SAMP_t EXT_STR_h101_SAMP; + +class FairLogger; +class R3BEventHeader; + +class R3BTrloiiSampReader : public R3BReader +{ + public: + R3BTrloiiSampReader(EXT_STR_h101_SAMP *, UInt_t); + ~R3BTrloiiSampReader(); + + Bool_t Init(ext_data_struct_info *); + Bool_t Read(); + void Reset(); + + private: + /* An event counter */ + UInt_t fNEvent; + /* Reader specific data structure from ucesb */ + EXT_STR_h101_SAMP* fData; + /* Offset of detector specific data in full data structure */ + UInt_t fOffset; + /* FairLogger */ + FairLogger *fLogger; + /* A pointer to the R3BEventHeader structure */ + R3BEventHeader *fEventHeader; + TClonesArray* fArray; /**< Output array. */ + + public: + ClassDef(R3BTrloiiSampReader, 0); +}; + +#endif diff --git a/r3bsource/ext_h101_los.h b/r3bsource/ext_h101_los.h new file mode 100644 index 000000000..658500ba1 --- /dev/null +++ b/r3bsource/ext_h101_los.h @@ -0,0 +1,451 @@ +/******************************************************** + * + * Structure for ext_data_fetch_event() filling. + * + * Do not edit - automatically generated. + */ + +#ifndef __GUARD_H101_LOS_EXT_H101_LOS_H__ +#define __GUARD_H101_LOS_EXT_H101_LOS_H__ + +#ifndef __CINT__ +# include +#else +/* For CINT (old version trouble with stdint.h): */ +# ifndef uint32_t +typedef unsigned int uint32_t; +typedef int int32_t; +# endif +#endif +#ifndef EXT_STRUCT_CTRL +# define EXT_STRUCT_CTRL(x) +#endif + +/******************************************************** + * + * Plain structure (layout as ntuple/root file): + */ + +typedef struct EXT_STR_h101_LOS_t +{ + /* RAW */ + uint32_t LOS1VTFM /* [1,8] */; + uint32_t LOS1VTFMI[8 EXT_STRUCT_CTRL(LOS1VTFM)] /* [1,8] */; + uint32_t LOS1VTFME[8 EXT_STRUCT_CTRL(LOS1VTFM)] /* [1,80] */; + uint32_t LOS1VTF /* [0,80] */; + uint32_t LOS1VTFv[80 EXT_STRUCT_CTRL(LOS1VTF)] /* [0,65535] */; + uint32_t LOS1VTCM /* [1,8] */; + uint32_t LOS1VTCMI[8 EXT_STRUCT_CTRL(LOS1VTCM)] /* [1,8] */; + uint32_t LOS1VTCME[8 EXT_STRUCT_CTRL(LOS1VTCM)] /* [1,80] */; + uint32_t LOS1VTC /* [0,80] */; + uint32_t LOS1VTCv[80 EXT_STRUCT_CTRL(LOS1VTC)] /* [0,65535] */; + uint32_t LOS1MTM /* [1,8] */; + uint32_t LOS1MTMI[8 EXT_STRUCT_CTRL(LOS1MTM)] /* [1,8] */; + uint32_t LOS1MTME[8 EXT_STRUCT_CTRL(LOS1MTM)] /* [1,80] */; + uint32_t LOS1MT /* [0,80] */; + uint32_t LOS1MTv[80 EXT_STRUCT_CTRL(LOS1MT)] /* [0,65535] */; + uint32_t LOS1TTFLM /* [1,8] */; + uint32_t LOS1TTFLMI[8 EXT_STRUCT_CTRL(LOS1TTFLM)] /* [1,8] */; + uint32_t LOS1TTFLME[8 EXT_STRUCT_CTRL(LOS1TTFLM)] /* [1,80] */; + uint32_t LOS1TTFL /* [0,80] */; + uint32_t LOS1TTFLv[80 EXT_STRUCT_CTRL(LOS1TTFL)] /* [0,65535] */; + uint32_t LOS1TTFTM /* [1,8] */; + uint32_t LOS1TTFTMI[8 EXT_STRUCT_CTRL(LOS1TTFTM)] /* [1,8] */; + uint32_t LOS1TTFTME[8 EXT_STRUCT_CTRL(LOS1TTFTM)] /* [1,80] */; + uint32_t LOS1TTFT /* [0,80] */; + uint32_t LOS1TTFTv[80 EXT_STRUCT_CTRL(LOS1TTFT)] /* [0,65535] */; + uint32_t LOS1TTCLM /* [1,8] */; + uint32_t LOS1TTCLMI[8 EXT_STRUCT_CTRL(LOS1TTCLM)] /* [1,8] */; + uint32_t LOS1TTCLME[8 EXT_STRUCT_CTRL(LOS1TTCLM)] /* [1,80] */; + uint32_t LOS1TTCL /* [0,80] */; + uint32_t LOS1TTCLv[80 EXT_STRUCT_CTRL(LOS1TTCL)] /* [0,65535] */; + uint32_t LOS1TTCTM /* [1,8] */; + uint32_t LOS1TTCTMI[8 EXT_STRUCT_CTRL(LOS1TTCTM)] /* [1,8] */; + uint32_t LOS1TTCTME[8 EXT_STRUCT_CTRL(LOS1TTCTM)] /* [1,80] */; + uint32_t LOS1TTCT /* [0,80] */; + uint32_t LOS1TTCTv[80 EXT_STRUCT_CTRL(LOS1TTCT)] /* [0,65535] */; + +} EXT_STR_h101_LOS; + +/******************************************************** + * + * Structure with multiple levels of arrays (partially) + * recovered (recommended): + */ + +typedef struct EXT_STR_h101_LOS_onion_t +{ + /* RAW */ + struct { + uint32_t VTFM; + uint32_t VTFMI[8 /* VTFM */]; + uint32_t VTFME[8 /* VTFM */]; + uint32_t VTF; + uint32_t VTFv[80 /* VTF */]; + uint32_t VTCM; + uint32_t VTCMI[8 /* VTCM */]; + uint32_t VTCME[8 /* VTCM */]; + uint32_t VTC; + uint32_t VTCv[80 /* VTC */]; + uint32_t MTM; + uint32_t MTMI[8 /* MTM */]; + uint32_t MTME[8 /* MTM */]; + uint32_t MT; + uint32_t MTv[80 /* MT */]; + uint32_t TTFLM; + uint32_t TTFLMI[8 /* TTFLM */]; + uint32_t TTFLME[8 /* TTFLM */]; + uint32_t TTFL; + uint32_t TTFLv[80 /* TTFL */]; + uint32_t TTFTM; + uint32_t TTFTMI[8 /* TTFTM */]; + uint32_t TTFTME[8 /* TTFTM */]; + uint32_t TTFT; + uint32_t TTFTv[80 /* TTFT */]; + uint32_t TTCLM; + uint32_t TTCLMI[8 /* TTCLM */]; + uint32_t TTCLME[8 /* TTCLM */]; + uint32_t TTCL; + uint32_t TTCLv[80 /* TTCL */]; + uint32_t TTCTM; + uint32_t TTCTMI[8 /* TTCTM */]; + uint32_t TTCTME[8 /* TTCTM */]; + uint32_t TTCT; + uint32_t TTCTv[80 /* TTCT */]; + } LOS[1]; + +} EXT_STR_h101_LOS_onion; + +/*******************************************************/ + +#define EXT_STR_h101_LOS_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* RAW */ \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTFM, UINT32,\ + "LOS1VTFM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTFMI, UINT32,\ + "LOS1VTFMI", "LOS1VTFM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTFME, UINT32,\ + "LOS1VTFME", "LOS1VTFM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTF, UINT32,\ + "LOS1VTF",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTFv, UINT32,\ + "LOS1VTFv", "LOS1VTF"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTCM, UINT32,\ + "LOS1VTCM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTCMI, UINT32,\ + "LOS1VTCMI", "LOS1VTCM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTCME, UINT32,\ + "LOS1VTCME", "LOS1VTCM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTC, UINT32,\ + "LOS1VTC",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTCv, UINT32,\ + "LOS1VTCv", "LOS1VTC"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1MTM, UINT32,\ + "LOS1MTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1MTMI, UINT32,\ + "LOS1MTMI", "LOS1MTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1MTME, UINT32,\ + "LOS1MTME", "LOS1MTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1MT, UINT32,\ + "LOS1MT",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1MTv, UINT32,\ + "LOS1MTv", "LOS1MT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFLM, UINT32,\ + "LOS1TTFLM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFLMI, UINT32,\ + "LOS1TTFLMI", "LOS1TTFLM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFLME, UINT32,\ + "LOS1TTFLME", "LOS1TTFLM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFL, UINT32,\ + "LOS1TTFL",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFLv, UINT32,\ + "LOS1TTFLv", "LOS1TTFL"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFTM, UINT32,\ + "LOS1TTFTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFTMI, UINT32,\ + "LOS1TTFTMI", "LOS1TTFTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFTME, UINT32,\ + "LOS1TTFTME", "LOS1TTFTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFT, UINT32,\ + "LOS1TTFT",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFTv, UINT32,\ + "LOS1TTFTv", "LOS1TTFT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCLM, UINT32,\ + "LOS1TTCLM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCLMI, UINT32,\ + "LOS1TTCLMI", "LOS1TTCLM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCLME, UINT32,\ + "LOS1TTCLME", "LOS1TTCLM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCL, UINT32,\ + "LOS1TTCL",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCLv, UINT32,\ + "LOS1TTCLv", "LOS1TTCL"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCTM, UINT32,\ + "LOS1TTCTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCTMI, UINT32,\ + "LOS1TTCTMI", "LOS1TTCTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCTME, UINT32,\ + "LOS1TTCTME", "LOS1TTCTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCT, UINT32,\ + "LOS1TTCT",80); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCTv, UINT32,\ + "LOS1TTCTv", "LOS1TTCT"); \ + \ +} while (0); + +/******************************************************** + * + * For internal use by the network data reader: + * (version checks, etc) + */ + +typedef struct EXT_STR_h101_LOS_layout_t +{ + uint32_t _magic; + uint32_t _size_info; + uint32_t _size_struct; + uint32_t _size_struct_onion; + uint32_t _pack_list_items; + + uint32_t _num_items; + struct { + uint32_t _offset; + uint32_t _size; + uint32_t _xor; + const char *_name; + } _items[1]; + uint32_t _pack_list[716]; +} EXT_STR_h101_LOS_layout; + +#define EXT_STR_h101_LOS_LAYOUT_INIT { \ + 0x57e65c96, \ + sizeof(EXT_STR_h101_LOS_layout), \ + sizeof(EXT_STR_h101_LOS), \ + sizeof(EXT_STR_h101_LOS_onion), \ + 716, \ + 1, \ + { \ + { 0, sizeof(EXT_STR_h101_LOS), 0xa864eccd, "h101_LOS" }, \ + }, \ + { \ + 0x40000000, 0x40000004, 0xc0000008, 0x00000008, \ + 0x00000002, 0x4000000c, 0x4000002c, 0x40000010, \ + 0x40000030, 0x40000014, 0x40000034, 0x40000018, \ + 0x40000038, 0x4000001c, 0x4000003c, 0x40000020, \ + 0x40000040, 0x40000024, 0x40000044, 0x40000028, \ + 0x40000048, 0xc000004c, 0x00000050, 0x00000001, \ + 0x40000050, 0x40000054, 0x40000058, 0x4000005c, \ + 0x40000060, 0x40000064, 0x40000068, 0x4000006c, \ + 0x40000070, 0x40000074, 0x40000078, 0x4000007c, \ + 0x40000080, 0x40000084, 0x40000088, 0x4000008c, \ + 0x40000090, 0x40000094, 0x40000098, 0x4000009c, \ + 0x400000a0, 0x400000a4, 0x400000a8, 0x400000ac, \ + 0x400000b0, 0x400000b4, 0x400000b8, 0x400000bc, \ + 0x400000c0, 0x400000c4, 0x400000c8, 0x400000cc, \ + 0x400000d0, 0x400000d4, 0x400000d8, 0x400000dc, \ + 0x400000e0, 0x400000e4, 0x400000e8, 0x400000ec, \ + 0x400000f0, 0x400000f4, 0x400000f8, 0x400000fc, \ + 0x40000100, 0x40000104, 0x40000108, 0x4000010c, \ + 0x40000110, 0x40000114, 0x40000118, 0x4000011c, \ + 0x40000120, 0x40000124, 0x40000128, 0x4000012c, \ + 0x40000130, 0x40000134, 0x40000138, 0x4000013c, \ + 0x40000140, 0x40000144, 0x40000148, 0x4000014c, \ + 0x40000150, 0x40000154, 0x40000158, 0x4000015c, \ + 0x40000160, 0x40000164, 0x40000168, 0x4000016c, \ + 0x40000170, 0x40000174, 0x40000178, 0x4000017c, \ + 0x40000180, 0x40000184, 0x40000188, 0x4000018c, \ + 0xc0000190, 0x00000008, 0x00000002, 0x40000194, \ + 0x400001b4, 0x40000198, 0x400001b8, 0x4000019c, \ + 0x400001bc, 0x400001a0, 0x400001c0, 0x400001a4, \ + 0x400001c4, 0x400001a8, 0x400001c8, 0x400001ac, \ + 0x400001cc, 0x400001b0, 0x400001d0, 0xc00001d4, \ + 0x00000050, 0x00000001, 0x400001d8, 0x400001dc, \ + 0x400001e0, 0x400001e4, 0x400001e8, 0x400001ec, \ + 0x400001f0, 0x400001f4, 0x400001f8, 0x400001fc, \ + 0x40000200, 0x40000204, 0x40000208, 0x4000020c, \ + 0x40000210, 0x40000214, 0x40000218, 0x4000021c, \ + 0x40000220, 0x40000224, 0x40000228, 0x4000022c, \ + 0x40000230, 0x40000234, 0x40000238, 0x4000023c, \ + 0x40000240, 0x40000244, 0x40000248, 0x4000024c, \ + 0x40000250, 0x40000254, 0x40000258, 0x4000025c, \ + 0x40000260, 0x40000264, 0x40000268, 0x4000026c, \ + 0x40000270, 0x40000274, 0x40000278, 0x4000027c, \ + 0x40000280, 0x40000284, 0x40000288, 0x4000028c, \ + 0x40000290, 0x40000294, 0x40000298, 0x4000029c, \ + 0x400002a0, 0x400002a4, 0x400002a8, 0x400002ac, \ + 0x400002b0, 0x400002b4, 0x400002b8, 0x400002bc, \ + 0x400002c0, 0x400002c4, 0x400002c8, 0x400002cc, \ + 0x400002d0, 0x400002d4, 0x400002d8, 0x400002dc, \ + 0x400002e0, 0x400002e4, 0x400002e8, 0x400002ec, \ + 0x400002f0, 0x400002f4, 0x400002f8, 0x400002fc, \ + 0x40000300, 0x40000304, 0x40000308, 0x4000030c, \ + 0x40000310, 0x40000314, 0xc0000318, 0x00000008, \ + 0x00000002, 0x4000031c, 0x4000033c, 0x40000320, \ + 0x40000340, 0x40000324, 0x40000344, 0x40000328, \ + 0x40000348, 0x4000032c, 0x4000034c, 0x40000330, \ + 0x40000350, 0x40000334, 0x40000354, 0x40000338, \ + 0x40000358, 0xc000035c, 0x00000050, 0x00000001, \ + 0x40000360, 0x40000364, 0x40000368, 0x4000036c, \ + 0x40000370, 0x40000374, 0x40000378, 0x4000037c, \ + 0x40000380, 0x40000384, 0x40000388, 0x4000038c, \ + 0x40000390, 0x40000394, 0x40000398, 0x4000039c, \ + 0x400003a0, 0x400003a4, 0x400003a8, 0x400003ac, \ + 0x400003b0, 0x400003b4, 0x400003b8, 0x400003bc, \ + 0x400003c0, 0x400003c4, 0x400003c8, 0x400003cc, \ + 0x400003d0, 0x400003d4, 0x400003d8, 0x400003dc, \ + 0x400003e0, 0x400003e4, 0x400003e8, 0x400003ec, \ + 0x400003f0, 0x400003f4, 0x400003f8, 0x400003fc, \ + 0x40000400, 0x40000404, 0x40000408, 0x4000040c, \ + 0x40000410, 0x40000414, 0x40000418, 0x4000041c, \ + 0x40000420, 0x40000424, 0x40000428, 0x4000042c, \ + 0x40000430, 0x40000434, 0x40000438, 0x4000043c, \ + 0x40000440, 0x40000444, 0x40000448, 0x4000044c, \ + 0x40000450, 0x40000454, 0x40000458, 0x4000045c, \ + 0x40000460, 0x40000464, 0x40000468, 0x4000046c, \ + 0x40000470, 0x40000474, 0x40000478, 0x4000047c, \ + 0x40000480, 0x40000484, 0x40000488, 0x4000048c, \ + 0x40000490, 0x40000494, 0x40000498, 0x4000049c, \ + 0xc00004a0, 0x00000008, 0x00000002, 0x400004a4, \ + 0x400004c4, 0x400004a8, 0x400004c8, 0x400004ac, \ + 0x400004cc, 0x400004b0, 0x400004d0, 0x400004b4, \ + 0x400004d4, 0x400004b8, 0x400004d8, 0x400004bc, \ + 0x400004dc, 0x400004c0, 0x400004e0, 0xc00004e4, \ + 0x00000050, 0x00000001, 0x400004e8, 0x400004ec, \ + 0x400004f0, 0x400004f4, 0x400004f8, 0x400004fc, \ + 0x40000500, 0x40000504, 0x40000508, 0x4000050c, \ + 0x40000510, 0x40000514, 0x40000518, 0x4000051c, \ + 0x40000520, 0x40000524, 0x40000528, 0x4000052c, \ + 0x40000530, 0x40000534, 0x40000538, 0x4000053c, \ + 0x40000540, 0x40000544, 0x40000548, 0x4000054c, \ + 0x40000550, 0x40000554, 0x40000558, 0x4000055c, \ + 0x40000560, 0x40000564, 0x40000568, 0x4000056c, \ + 0x40000570, 0x40000574, 0x40000578, 0x4000057c, \ + 0x40000580, 0x40000584, 0x40000588, 0x4000058c, \ + 0x40000590, 0x40000594, 0x40000598, 0x4000059c, \ + 0x400005a0, 0x400005a4, 0x400005a8, 0x400005ac, \ + 0x400005b0, 0x400005b4, 0x400005b8, 0x400005bc, \ + 0x400005c0, 0x400005c4, 0x400005c8, 0x400005cc, \ + 0x400005d0, 0x400005d4, 0x400005d8, 0x400005dc, \ + 0x400005e0, 0x400005e4, 0x400005e8, 0x400005ec, \ + 0x400005f0, 0x400005f4, 0x400005f8, 0x400005fc, \ + 0x40000600, 0x40000604, 0x40000608, 0x4000060c, \ + 0x40000610, 0x40000614, 0x40000618, 0x4000061c, \ + 0x40000620, 0x40000624, 0xc0000628, 0x00000008, \ + 0x00000002, 0x4000062c, 0x4000064c, 0x40000630, \ + 0x40000650, 0x40000634, 0x40000654, 0x40000638, \ + 0x40000658, 0x4000063c, 0x4000065c, 0x40000640, \ + 0x40000660, 0x40000644, 0x40000664, 0x40000648, \ + 0x40000668, 0xc000066c, 0x00000050, 0x00000001, \ + 0x40000670, 0x40000674, 0x40000678, 0x4000067c, \ + 0x40000680, 0x40000684, 0x40000688, 0x4000068c, \ + 0x40000690, 0x40000694, 0x40000698, 0x4000069c, \ + 0x400006a0, 0x400006a4, 0x400006a8, 0x400006ac, \ + 0x400006b0, 0x400006b4, 0x400006b8, 0x400006bc, \ + 0x400006c0, 0x400006c4, 0x400006c8, 0x400006cc, \ + 0x400006d0, 0x400006d4, 0x400006d8, 0x400006dc, \ + 0x400006e0, 0x400006e4, 0x400006e8, 0x400006ec, \ + 0x400006f0, 0x400006f4, 0x400006f8, 0x400006fc, \ + 0x40000700, 0x40000704, 0x40000708, 0x4000070c, \ + 0x40000710, 0x40000714, 0x40000718, 0x4000071c, \ + 0x40000720, 0x40000724, 0x40000728, 0x4000072c, \ + 0x40000730, 0x40000734, 0x40000738, 0x4000073c, \ + 0x40000740, 0x40000744, 0x40000748, 0x4000074c, \ + 0x40000750, 0x40000754, 0x40000758, 0x4000075c, \ + 0x40000760, 0x40000764, 0x40000768, 0x4000076c, \ + 0x40000770, 0x40000774, 0x40000778, 0x4000077c, \ + 0x40000780, 0x40000784, 0x40000788, 0x4000078c, \ + 0x40000790, 0x40000794, 0x40000798, 0x4000079c, \ + 0x400007a0, 0x400007a4, 0x400007a8, 0x400007ac, \ + 0xc00007b0, 0x00000008, 0x00000002, 0x400007b4, \ + 0x400007d4, 0x400007b8, 0x400007d8, 0x400007bc, \ + 0x400007dc, 0x400007c0, 0x400007e0, 0x400007c4, \ + 0x400007e4, 0x400007c8, 0x400007e8, 0x400007cc, \ + 0x400007ec, 0x400007d0, 0x400007f0, 0xc00007f4, \ + 0x00000050, 0x00000001, 0x400007f8, 0x400007fc, \ + 0x40000800, 0x40000804, 0x40000808, 0x4000080c, \ + 0x40000810, 0x40000814, 0x40000818, 0x4000081c, \ + 0x40000820, 0x40000824, 0x40000828, 0x4000082c, \ + 0x40000830, 0x40000834, 0x40000838, 0x4000083c, \ + 0x40000840, 0x40000844, 0x40000848, 0x4000084c, \ + 0x40000850, 0x40000854, 0x40000858, 0x4000085c, \ + 0x40000860, 0x40000864, 0x40000868, 0x4000086c, \ + 0x40000870, 0x40000874, 0x40000878, 0x4000087c, \ + 0x40000880, 0x40000884, 0x40000888, 0x4000088c, \ + 0x40000890, 0x40000894, 0x40000898, 0x4000089c, \ + 0x400008a0, 0x400008a4, 0x400008a8, 0x400008ac, \ + 0x400008b0, 0x400008b4, 0x400008b8, 0x400008bc, \ + 0x400008c0, 0x400008c4, 0x400008c8, 0x400008cc, \ + 0x400008d0, 0x400008d4, 0x400008d8, 0x400008dc, \ + 0x400008e0, 0x400008e4, 0x400008e8, 0x400008ec, \ + 0x400008f0, 0x400008f4, 0x400008f8, 0x400008fc, \ + 0x40000900, 0x40000904, 0x40000908, 0x4000090c, \ + 0x40000910, 0x40000914, 0x40000918, 0x4000091c, \ + 0x40000920, 0x40000924, 0x40000928, 0x4000092c, \ + 0x40000930, 0x40000934, 0xc0000938, 0x00000008, \ + 0x00000002, 0x4000093c, 0x4000095c, 0x40000940, \ + 0x40000960, 0x40000944, 0x40000964, 0x40000948, \ + 0x40000968, 0x4000094c, 0x4000096c, 0x40000950, \ + 0x40000970, 0x40000954, 0x40000974, 0x40000958, \ + 0x40000978, 0xc000097c, 0x00000050, 0x00000001, \ + 0x40000980, 0x40000984, 0x40000988, 0x4000098c, \ + 0x40000990, 0x40000994, 0x40000998, 0x4000099c, \ + 0x400009a0, 0x400009a4, 0x400009a8, 0x400009ac, \ + 0x400009b0, 0x400009b4, 0x400009b8, 0x400009bc, \ + 0x400009c0, 0x400009c4, 0x400009c8, 0x400009cc, \ + 0x400009d0, 0x400009d4, 0x400009d8, 0x400009dc, \ + 0x400009e0, 0x400009e4, 0x400009e8, 0x400009ec, \ + 0x400009f0, 0x400009f4, 0x400009f8, 0x400009fc, \ + 0x40000a00, 0x40000a04, 0x40000a08, 0x40000a0c, \ + 0x40000a10, 0x40000a14, 0x40000a18, 0x40000a1c, \ + 0x40000a20, 0x40000a24, 0x40000a28, 0x40000a2c, \ + 0x40000a30, 0x40000a34, 0x40000a38, 0x40000a3c, \ + 0x40000a40, 0x40000a44, 0x40000a48, 0x40000a4c, \ + 0x40000a50, 0x40000a54, 0x40000a58, 0x40000a5c, \ + 0x40000a60, 0x40000a64, 0x40000a68, 0x40000a6c, \ + 0x40000a70, 0x40000a74, 0x40000a78, 0x40000a7c, \ + 0x40000a80, 0x40000a84, 0x40000a88, 0x40000a8c, \ + 0x40000a90, 0x40000a94, 0x40000a98, 0x40000a9c, \ + 0x40000aa0, 0x40000aa4, 0x40000aa8, 0x40000aac, \ + 0x40000ab0, 0x40000ab4, 0x40000ab8, 0x40000abc, \ + } \ +}; + +#endif/*__GUARD_H101_LOS_EXT_H101_LOS_H__*/ + +/*******************************************************/ diff --git a/r3bsource/ext_h101_los_dez19.h b/r3bsource/ext_h101_los_dez19.h new file mode 100644 index 000000000..b9bef031b --- /dev/null +++ b/r3bsource/ext_h101_los_dez19.h @@ -0,0 +1,1386 @@ +/******************************************************** + * + * Structure for ext_data_fetch_event() filling. + * + * Do not edit - automatically generated. + */ + +#ifndef __GUARD_H101_LOS_EXT_H101_LOS_DEZ19_H__ +#define __GUARD_H101_LOS_EXT_H101_LOS_DEZ19_H__ + +#ifndef __CINT__ +# include +#else +/* For CINT (old version trouble with stdint.h): */ +# ifndef uint32_t +typedef unsigned int uint32_t; +typedef int int32_t; +# endif +#endif +#ifndef EXT_STRUCT_CTRL +# define EXT_STRUCT_CTRL(x) +#endif + +/******************************************************** + * + * Plain structure (layout as ntuple/root file): + */ + +typedef struct EXT_STR_h101_LOS_t +{ + /* RAW */ + uint32_t LOS1VTFM /* [1,8] */; + uint32_t LOS1VTFMI[8 EXT_STRUCT_CTRL(LOS1VTFM)] /* [1,8] */; + uint32_t LOS1VTFME[8 EXT_STRUCT_CTRL(LOS1VTFM)] /* [1,256] */; + uint32_t LOS1VTF /* [0,256] */; + uint32_t LOS1VTFv[256 EXT_STRUCT_CTRL(LOS1VTF)] /* [0,65535] */; + uint32_t LOS1VTCM /* [1,8] */; + uint32_t LOS1VTCMI[8 EXT_STRUCT_CTRL(LOS1VTCM)] /* [1,8] */; + uint32_t LOS1VTCME[8 EXT_STRUCT_CTRL(LOS1VTCM)] /* [1,256] */; + uint32_t LOS1VTC /* [0,256] */; + uint32_t LOS1VTCv[256 EXT_STRUCT_CTRL(LOS1VTC)] /* [0,65535] */; + uint32_t LOS1MTM /* [1,8] */; + uint32_t LOS1MTMI[8 EXT_STRUCT_CTRL(LOS1MTM)] /* [1,8] */; + uint32_t LOS1MTME[8 EXT_STRUCT_CTRL(LOS1MTM)] /* [1,256] */; + uint32_t LOS1MT /* [0,256] */; + uint32_t LOS1MTv[256 EXT_STRUCT_CTRL(LOS1MT)] /* [0,65535] */; + uint32_t LOS1TTFLM /* [1,8] */; + uint32_t LOS1TTFLMI[8 EXT_STRUCT_CTRL(LOS1TTFLM)] /* [1,8] */; + uint32_t LOS1TTFLME[8 EXT_STRUCT_CTRL(LOS1TTFLM)] /* [1,256] */; + uint32_t LOS1TTFL /* [0,256] */; + uint32_t LOS1TTFLv[256 EXT_STRUCT_CTRL(LOS1TTFL)] /* [0,65535] */; + uint32_t LOS1TTFTM /* [1,8] */; + uint32_t LOS1TTFTMI[8 EXT_STRUCT_CTRL(LOS1TTFTM)] /* [1,8] */; + uint32_t LOS1TTFTME[8 EXT_STRUCT_CTRL(LOS1TTFTM)] /* [1,256] */; + uint32_t LOS1TTFT /* [0,256] */; + uint32_t LOS1TTFTv[256 EXT_STRUCT_CTRL(LOS1TTFT)] /* [0,65535] */; + uint32_t LOS1TTCLM /* [1,8] */; + uint32_t LOS1TTCLMI[8 EXT_STRUCT_CTRL(LOS1TTCLM)] /* [1,8] */; + uint32_t LOS1TTCLME[8 EXT_STRUCT_CTRL(LOS1TTCLM)] /* [1,256] */; + uint32_t LOS1TTCL /* [0,256] */; + uint32_t LOS1TTCLv[256 EXT_STRUCT_CTRL(LOS1TTCL)] /* [0,65535] */; + uint32_t LOS1TTCTM /* [1,8] */; + uint32_t LOS1TTCTMI[8 EXT_STRUCT_CTRL(LOS1TTCTM)] /* [1,8] */; + uint32_t LOS1TTCTME[8 EXT_STRUCT_CTRL(LOS1TTCTM)] /* [1,256] */; + uint32_t LOS1TTCT /* [0,256] */; + uint32_t LOS1TTCTv[256 EXT_STRUCT_CTRL(LOS1TTCT)] /* [0,65535] */; + uint32_t LOS2VTFM /* [1,8] */; + uint32_t LOS2VTFMI[8 EXT_STRUCT_CTRL(LOS2VTFM)] /* [1,8] */; + uint32_t LOS2VTFME[8 EXT_STRUCT_CTRL(LOS2VTFM)] /* [1,256] */; + uint32_t LOS2VTF /* [0,256] */; + uint32_t LOS2VTFv[256 EXT_STRUCT_CTRL(LOS2VTF)] /* [0,65535] */; + uint32_t LOS2VTCM /* [1,8] */; + uint32_t LOS2VTCMI[8 EXT_STRUCT_CTRL(LOS2VTCM)] /* [1,8] */; + uint32_t LOS2VTCME[8 EXT_STRUCT_CTRL(LOS2VTCM)] /* [1,256] */; + uint32_t LOS2VTC /* [0,256] */; + uint32_t LOS2VTCv[256 EXT_STRUCT_CTRL(LOS2VTC)] /* [0,65535] */; + uint32_t LOS2MTM /* [1,8] */; + uint32_t LOS2MTMI[8 EXT_STRUCT_CTRL(LOS2MTM)] /* [1,8] */; + uint32_t LOS2MTME[8 EXT_STRUCT_CTRL(LOS2MTM)] /* [1,256] */; + uint32_t LOS2MT /* [0,256] */; + uint32_t LOS2MTv[256 EXT_STRUCT_CTRL(LOS2MT)] /* [0,65535] */; + uint32_t LOS2TTFLM /* [1,8] */; + uint32_t LOS2TTFLMI[8 EXT_STRUCT_CTRL(LOS2TTFLM)] /* [1,8] */; + uint32_t LOS2TTFLME[8 EXT_STRUCT_CTRL(LOS2TTFLM)] /* [1,256] */; + uint32_t LOS2TTFL /* [0,256] */; + uint32_t LOS2TTFLv[256 EXT_STRUCT_CTRL(LOS2TTFL)] /* [0,65535] */; + uint32_t LOS2TTFTM /* [1,8] */; + uint32_t LOS2TTFTMI[8 EXT_STRUCT_CTRL(LOS2TTFTM)] /* [1,8] */; + uint32_t LOS2TTFTME[8 EXT_STRUCT_CTRL(LOS2TTFTM)] /* [1,256] */; + uint32_t LOS2TTFT /* [0,256] */; + uint32_t LOS2TTFTv[256 EXT_STRUCT_CTRL(LOS2TTFT)] /* [0,65535] */; + uint32_t LOS2TTCLM /* [1,8] */; + uint32_t LOS2TTCLMI[8 EXT_STRUCT_CTRL(LOS2TTCLM)] /* [1,8] */; + uint32_t LOS2TTCLME[8 EXT_STRUCT_CTRL(LOS2TTCLM)] /* [1,256] */; + uint32_t LOS2TTCL /* [0,256] */; + uint32_t LOS2TTCLv[256 EXT_STRUCT_CTRL(LOS2TTCL)] /* [0,65535] */; + uint32_t LOS2TTCTM /* [1,8] */; + uint32_t LOS2TTCTMI[8 EXT_STRUCT_CTRL(LOS2TTCTM)] /* [1,8] */; + uint32_t LOS2TTCTME[8 EXT_STRUCT_CTRL(LOS2TTCTM)] /* [1,256] */; + uint32_t LOS2TTCT /* [0,256] */; + uint32_t LOS2TTCTv[256 EXT_STRUCT_CTRL(LOS2TTCT)] /* [0,65535] */; + +} EXT_STR_h101_LOS; + +/******************************************************** + * + * Structure with multiple levels of arrays (partially) + * recovered (recommended): + */ + +typedef struct EXT_STR_h101_LOS_onion_t +{ + /* RAW */ + struct { + uint32_t VTFM; + uint32_t VTFMI[8 /* VTFM */]; + uint32_t VTFME[8 /* VTFM */]; + uint32_t VTF; + uint32_t VTFv[256 /* VTF */]; + uint32_t VTCM; + uint32_t VTCMI[8 /* VTCM */]; + uint32_t VTCME[8 /* VTCM */]; + uint32_t VTC; + uint32_t VTCv[256 /* VTC */]; + uint32_t MTM; + uint32_t MTMI[8 /* MTM */]; + uint32_t MTME[8 /* MTM */]; + uint32_t MT; + uint32_t MTv[256 /* MT */]; + uint32_t TTFLM; + uint32_t TTFLMI[8 /* TTFLM */]; + uint32_t TTFLME[8 /* TTFLM */]; + uint32_t TTFL; + uint32_t TTFLv[256 /* TTFL */]; + uint32_t TTFTM; + uint32_t TTFTMI[8 /* TTFTM */]; + uint32_t TTFTME[8 /* TTFTM */]; + uint32_t TTFT; + uint32_t TTFTv[256 /* TTFT */]; + uint32_t TTCLM; + uint32_t TTCLMI[8 /* TTCLM */]; + uint32_t TTCLME[8 /* TTCLM */]; + uint32_t TTCL; + uint32_t TTCLv[256 /* TTCL */]; + uint32_t TTCTM; + uint32_t TTCTMI[8 /* TTCTM */]; + uint32_t TTCTME[8 /* TTCTM */]; + uint32_t TTCT; + uint32_t TTCTv[256 /* TTCT */]; + } LOS[2]; + +} EXT_STR_h101_LOS_onion; + +/*******************************************************/ + +#define EXT_STR_h101_LOS_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* RAW */ \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTFM, UINT32,\ + "LOS1VTFM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTFMI, UINT32,\ + "LOS1VTFMI", "LOS1VTFM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTFME, UINT32,\ + "LOS1VTFME", "LOS1VTFM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTF, UINT32,\ + "LOS1VTF",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTFv, UINT32,\ + "LOS1VTFv", "LOS1VTF"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTCM, UINT32,\ + "LOS1VTCM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTCMI, UINT32,\ + "LOS1VTCMI", "LOS1VTCM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTCME, UINT32,\ + "LOS1VTCME", "LOS1VTCM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1VTC, UINT32,\ + "LOS1VTC",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1VTCv, UINT32,\ + "LOS1VTCv", "LOS1VTC"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1MTM, UINT32,\ + "LOS1MTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1MTMI, UINT32,\ + "LOS1MTMI", "LOS1MTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1MTME, UINT32,\ + "LOS1MTME", "LOS1MTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1MT, UINT32,\ + "LOS1MT",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1MTv, UINT32,\ + "LOS1MTv", "LOS1MT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFLM, UINT32,\ + "LOS1TTFLM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFLMI, UINT32,\ + "LOS1TTFLMI", "LOS1TTFLM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFLME, UINT32,\ + "LOS1TTFLME", "LOS1TTFLM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFL, UINT32,\ + "LOS1TTFL",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFLv, UINT32,\ + "LOS1TTFLv", "LOS1TTFL"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFTM, UINT32,\ + "LOS1TTFTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFTMI, UINT32,\ + "LOS1TTFTMI", "LOS1TTFTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFTME, UINT32,\ + "LOS1TTFTME", "LOS1TTFTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTFT, UINT32,\ + "LOS1TTFT",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTFTv, UINT32,\ + "LOS1TTFTv", "LOS1TTFT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCLM, UINT32,\ + "LOS1TTCLM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCLMI, UINT32,\ + "LOS1TTCLMI", "LOS1TTCLM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCLME, UINT32,\ + "LOS1TTCLME", "LOS1TTCLM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCL, UINT32,\ + "LOS1TTCL",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCLv, UINT32,\ + "LOS1TTCLv", "LOS1TTCL"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCTM, UINT32,\ + "LOS1TTCTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCTMI, UINT32,\ + "LOS1TTCTMI", "LOS1TTCTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCTME, UINT32,\ + "LOS1TTCTME", "LOS1TTCTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS1TTCT, UINT32,\ + "LOS1TTCT",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS1TTCTv, UINT32,\ + "LOS1TTCTv", "LOS1TTCT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2VTFM, UINT32,\ + "LOS2VTFM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2VTFMI, UINT32,\ + "LOS2VTFMI", "LOS2VTFM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2VTFME, UINT32,\ + "LOS2VTFME", "LOS2VTFM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2VTF, UINT32,\ + "LOS2VTF",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2VTFv, UINT32,\ + "LOS2VTFv", "LOS2VTF"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2VTCM, UINT32,\ + "LOS2VTCM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2VTCMI, UINT32,\ + "LOS2VTCMI", "LOS2VTCM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2VTCME, UINT32,\ + "LOS2VTCME", "LOS2VTCM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2VTC, UINT32,\ + "LOS2VTC",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2VTCv, UINT32,\ + "LOS2VTCv", "LOS2VTC"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2MTM, UINT32,\ + "LOS2MTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2MTMI, UINT32,\ + "LOS2MTMI", "LOS2MTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2MTME, UINT32,\ + "LOS2MTME", "LOS2MTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2MT, UINT32,\ + "LOS2MT",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2MTv, UINT32,\ + "LOS2MTv", "LOS2MT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTFLM, UINT32,\ + "LOS2TTFLM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTFLMI, UINT32,\ + "LOS2TTFLMI", "LOS2TTFLM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTFLME, UINT32,\ + "LOS2TTFLME", "LOS2TTFLM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTFL, UINT32,\ + "LOS2TTFL",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTFLv, UINT32,\ + "LOS2TTFLv", "LOS2TTFL"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTFTM, UINT32,\ + "LOS2TTFTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTFTMI, UINT32,\ + "LOS2TTFTMI", "LOS2TTFTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTFTME, UINT32,\ + "LOS2TTFTME", "LOS2TTFTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTFT, UINT32,\ + "LOS2TTFT",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTFTv, UINT32,\ + "LOS2TTFTv", "LOS2TTFT"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTCLM, UINT32,\ + "LOS2TTCLM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTCLMI, UINT32,\ + "LOS2TTCLMI", "LOS2TTCLM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTCLME, UINT32,\ + "LOS2TTCLME", "LOS2TTCLM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTCL, UINT32,\ + "LOS2TTCL",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTCLv, UINT32,\ + "LOS2TTCLv", "LOS2TTCL"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTCTM, UINT32,\ + "LOS2TTCTM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTCTMI, UINT32,\ + "LOS2TTCTMI", "LOS2TTCTM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTCTME, UINT32,\ + "LOS2TTCTME", "LOS2TTCTM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + LOS2TTCT, UINT32,\ + "LOS2TTCT",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + LOS2TTCTv, UINT32,\ + "LOS2TTCTv", "LOS2TTCT"); \ + \ +} while (0); + +/******************************************************** + * + * For internal use by the network data reader: + * (version checks, etc) + */ + +typedef struct EXT_STR_h101_LOS_layout_t +{ + uint32_t _magic; + uint32_t _size_info; + uint32_t _size_struct; + uint32_t _size_struct_onion; + uint32_t _pack_list_items; + + uint32_t _num_items; + struct { + uint32_t _offset; + uint32_t _size; + uint32_t _xor; + const char *_name; + } _items[1]; + uint32_t _pack_list[3894]; +} EXT_STR_h101_LOS_layout; + +#define EXT_STR_h101_LOS_LAYOUT_INIT { \ + 0x57e65c96, \ + sizeof(EXT_STR_h101_LOS_layout), \ + sizeof(EXT_STR_h101_LOS), \ + sizeof(EXT_STR_h101_LOS_onion), \ + 3894, \ + 1, \ + { \ + { 0, sizeof(EXT_STR_h101_LOS), 0xb4ae8625, "h101_LOS" }, \ + }, \ + { \ + 0x40000000, 0x40000004, 0xc0000008, 0x00000008, \ + 0x00000002, 0x4000000c, 0x4000002c, 0x40000010, \ + 0x40000030, 0x40000014, 0x40000034, 0x40000018, \ + 0x40000038, 0x4000001c, 0x4000003c, 0x40000020, \ + 0x40000040, 0x40000024, 0x40000044, 0x40000028, \ + 0x40000048, 0xc000004c, 0x00000100, 0x00000001, \ + 0x40000050, 0x40000054, 0x40000058, 0x4000005c, \ + 0x40000060, 0x40000064, 0x40000068, 0x4000006c, \ + 0x40000070, 0x40000074, 0x40000078, 0x4000007c, \ + 0x40000080, 0x40000084, 0x40000088, 0x4000008c, \ + 0x40000090, 0x40000094, 0x40000098, 0x4000009c, \ + 0x400000a0, 0x400000a4, 0x400000a8, 0x400000ac, \ + 0x400000b0, 0x400000b4, 0x400000b8, 0x400000bc, \ + 0x400000c0, 0x400000c4, 0x400000c8, 0x400000cc, \ + 0x400000d0, 0x400000d4, 0x400000d8, 0x400000dc, \ + 0x400000e0, 0x400000e4, 0x400000e8, 0x400000ec, \ + 0x400000f0, 0x400000f4, 0x400000f8, 0x400000fc, \ + 0x40000100, 0x40000104, 0x40000108, 0x4000010c, \ + 0x40000110, 0x40000114, 0x40000118, 0x4000011c, \ + 0x40000120, 0x40000124, 0x40000128, 0x4000012c, \ + 0x40000130, 0x40000134, 0x40000138, 0x4000013c, \ + 0x40000140, 0x40000144, 0x40000148, 0x4000014c, \ + 0x40000150, 0x40000154, 0x40000158, 0x4000015c, \ + 0x40000160, 0x40000164, 0x40000168, 0x4000016c, \ + 0x40000170, 0x40000174, 0x40000178, 0x4000017c, \ + 0x40000180, 0x40000184, 0x40000188, 0x4000018c, \ + 0x40000190, 0x40000194, 0x40000198, 0x4000019c, \ + 0x400001a0, 0x400001a4, 0x400001a8, 0x400001ac, \ + 0x400001b0, 0x400001b4, 0x400001b8, 0x400001bc, \ + 0x400001c0, 0x400001c4, 0x400001c8, 0x400001cc, \ + 0x400001d0, 0x400001d4, 0x400001d8, 0x400001dc, \ + 0x400001e0, 0x400001e4, 0x400001e8, 0x400001ec, \ + 0x400001f0, 0x400001f4, 0x400001f8, 0x400001fc, \ + 0x40000200, 0x40000204, 0x40000208, 0x4000020c, \ + 0x40000210, 0x40000214, 0x40000218, 0x4000021c, \ + 0x40000220, 0x40000224, 0x40000228, 0x4000022c, \ + 0x40000230, 0x40000234, 0x40000238, 0x4000023c, \ + 0x40000240, 0x40000244, 0x40000248, 0x4000024c, \ + 0x40000250, 0x40000254, 0x40000258, 0x4000025c, \ + 0x40000260, 0x40000264, 0x40000268, 0x4000026c, \ + 0x40000270, 0x40000274, 0x40000278, 0x4000027c, \ + 0x40000280, 0x40000284, 0x40000288, 0x4000028c, \ + 0x40000290, 0x40000294, 0x40000298, 0x4000029c, \ + 0x400002a0, 0x400002a4, 0x400002a8, 0x400002ac, \ + 0x400002b0, 0x400002b4, 0x400002b8, 0x400002bc, \ + 0x400002c0, 0x400002c4, 0x400002c8, 0x400002cc, \ + 0x400002d0, 0x400002d4, 0x400002d8, 0x400002dc, \ + 0x400002e0, 0x400002e4, 0x400002e8, 0x400002ec, \ + 0x400002f0, 0x400002f4, 0x400002f8, 0x400002fc, \ + 0x40000300, 0x40000304, 0x40000308, 0x4000030c, \ + 0x40000310, 0x40000314, 0x40000318, 0x4000031c, \ + 0x40000320, 0x40000324, 0x40000328, 0x4000032c, \ + 0x40000330, 0x40000334, 0x40000338, 0x4000033c, \ + 0x40000340, 0x40000344, 0x40000348, 0x4000034c, \ + 0x40000350, 0x40000354, 0x40000358, 0x4000035c, \ + 0x40000360, 0x40000364, 0x40000368, 0x4000036c, \ + 0x40000370, 0x40000374, 0x40000378, 0x4000037c, \ + 0x40000380, 0x40000384, 0x40000388, 0x4000038c, \ + 0x40000390, 0x40000394, 0x40000398, 0x4000039c, \ + 0x400003a0, 0x400003a4, 0x400003a8, 0x400003ac, \ + 0x400003b0, 0x400003b4, 0x400003b8, 0x400003bc, \ + 0x400003c0, 0x400003c4, 0x400003c8, 0x400003cc, \ + 0x400003d0, 0x400003d4, 0x400003d8, 0x400003dc, \ + 0x400003e0, 0x400003e4, 0x400003e8, 0x400003ec, \ + 0x400003f0, 0x400003f4, 0x400003f8, 0x400003fc, \ + 0x40000400, 0x40000404, 0x40000408, 0x4000040c, \ + 0x40000410, 0x40000414, 0x40000418, 0x4000041c, \ + 0x40000420, 0x40000424, 0x40000428, 0x4000042c, \ + 0x40000430, 0x40000434, 0x40000438, 0x4000043c, \ + 0x40000440, 0x40000444, 0x40000448, 0x4000044c, \ + 0xc0000450, 0x00000008, 0x00000002, 0x40000454, \ + 0x40000474, 0x40000458, 0x40000478, 0x4000045c, \ + 0x4000047c, 0x40000460, 0x40000480, 0x40000464, \ + 0x40000484, 0x40000468, 0x40000488, 0x4000046c, \ + 0x4000048c, 0x40000470, 0x40000490, 0xc0000494, \ + 0x00000100, 0x00000001, 0x40000498, 0x4000049c, \ + 0x400004a0, 0x400004a4, 0x400004a8, 0x400004ac, \ + 0x400004b0, 0x400004b4, 0x400004b8, 0x400004bc, \ + 0x400004c0, 0x400004c4, 0x400004c8, 0x400004cc, \ + 0x400004d0, 0x400004d4, 0x400004d8, 0x400004dc, \ + 0x400004e0, 0x400004e4, 0x400004e8, 0x400004ec, \ + 0x400004f0, 0x400004f4, 0x400004f8, 0x400004fc, \ + 0x40000500, 0x40000504, 0x40000508, 0x4000050c, \ + 0x40000510, 0x40000514, 0x40000518, 0x4000051c, \ + 0x40000520, 0x40000524, 0x40000528, 0x4000052c, \ + 0x40000530, 0x40000534, 0x40000538, 0x4000053c, \ + 0x40000540, 0x40000544, 0x40000548, 0x4000054c, \ + 0x40000550, 0x40000554, 0x40000558, 0x4000055c, \ + 0x40000560, 0x40000564, 0x40000568, 0x4000056c, \ + 0x40000570, 0x40000574, 0x40000578, 0x4000057c, \ + 0x40000580, 0x40000584, 0x40000588, 0x4000058c, \ + 0x40000590, 0x40000594, 0x40000598, 0x4000059c, \ + 0x400005a0, 0x400005a4, 0x400005a8, 0x400005ac, \ + 0x400005b0, 0x400005b4, 0x400005b8, 0x400005bc, \ + 0x400005c0, 0x400005c4, 0x400005c8, 0x400005cc, \ + 0x400005d0, 0x400005d4, 0x400005d8, 0x400005dc, \ + 0x400005e0, 0x400005e4, 0x400005e8, 0x400005ec, \ + 0x400005f0, 0x400005f4, 0x400005f8, 0x400005fc, \ + 0x40000600, 0x40000604, 0x40000608, 0x4000060c, \ + 0x40000610, 0x40000614, 0x40000618, 0x4000061c, \ + 0x40000620, 0x40000624, 0x40000628, 0x4000062c, \ + 0x40000630, 0x40000634, 0x40000638, 0x4000063c, \ + 0x40000640, 0x40000644, 0x40000648, 0x4000064c, \ + 0x40000650, 0x40000654, 0x40000658, 0x4000065c, \ + 0x40000660, 0x40000664, 0x40000668, 0x4000066c, \ + 0x40000670, 0x40000674, 0x40000678, 0x4000067c, \ + 0x40000680, 0x40000684, 0x40000688, 0x4000068c, \ + 0x40000690, 0x40000694, 0x40000698, 0x4000069c, \ + 0x400006a0, 0x400006a4, 0x400006a8, 0x400006ac, \ + 0x400006b0, 0x400006b4, 0x400006b8, 0x400006bc, \ + 0x400006c0, 0x400006c4, 0x400006c8, 0x400006cc, \ + 0x400006d0, 0x400006d4, 0x400006d8, 0x400006dc, \ + 0x400006e0, 0x400006e4, 0x400006e8, 0x400006ec, \ + 0x400006f0, 0x400006f4, 0x400006f8, 0x400006fc, \ + 0x40000700, 0x40000704, 0x40000708, 0x4000070c, \ + 0x40000710, 0x40000714, 0x40000718, 0x4000071c, \ + 0x40000720, 0x40000724, 0x40000728, 0x4000072c, \ + 0x40000730, 0x40000734, 0x40000738, 0x4000073c, \ + 0x40000740, 0x40000744, 0x40000748, 0x4000074c, \ + 0x40000750, 0x40000754, 0x40000758, 0x4000075c, \ + 0x40000760, 0x40000764, 0x40000768, 0x4000076c, \ + 0x40000770, 0x40000774, 0x40000778, 0x4000077c, \ + 0x40000780, 0x40000784, 0x40000788, 0x4000078c, \ + 0x40000790, 0x40000794, 0x40000798, 0x4000079c, \ + 0x400007a0, 0x400007a4, 0x400007a8, 0x400007ac, \ + 0x400007b0, 0x400007b4, 0x400007b8, 0x400007bc, \ + 0x400007c0, 0x400007c4, 0x400007c8, 0x400007cc, \ + 0x400007d0, 0x400007d4, 0x400007d8, 0x400007dc, \ + 0x400007e0, 0x400007e4, 0x400007e8, 0x400007ec, \ + 0x400007f0, 0x400007f4, 0x400007f8, 0x400007fc, \ + 0x40000800, 0x40000804, 0x40000808, 0x4000080c, \ + 0x40000810, 0x40000814, 0x40000818, 0x4000081c, \ + 0x40000820, 0x40000824, 0x40000828, 0x4000082c, \ + 0x40000830, 0x40000834, 0x40000838, 0x4000083c, \ + 0x40000840, 0x40000844, 0x40000848, 0x4000084c, \ + 0x40000850, 0x40000854, 0x40000858, 0x4000085c, \ + 0x40000860, 0x40000864, 0x40000868, 0x4000086c, \ + 0x40000870, 0x40000874, 0x40000878, 0x4000087c, \ + 0x40000880, 0x40000884, 0x40000888, 0x4000088c, \ + 0x40000890, 0x40000894, 0xc0000898, 0x00000008, \ + 0x00000002, 0x4000089c, 0x400008bc, 0x400008a0, \ + 0x400008c0, 0x400008a4, 0x400008c4, 0x400008a8, \ + 0x400008c8, 0x400008ac, 0x400008cc, 0x400008b0, \ + 0x400008d0, 0x400008b4, 0x400008d4, 0x400008b8, \ + 0x400008d8, 0xc00008dc, 0x00000100, 0x00000001, \ + 0x400008e0, 0x400008e4, 0x400008e8, 0x400008ec, \ + 0x400008f0, 0x400008f4, 0x400008f8, 0x400008fc, \ + 0x40000900, 0x40000904, 0x40000908, 0x4000090c, \ + 0x40000910, 0x40000914, 0x40000918, 0x4000091c, \ + 0x40000920, 0x40000924, 0x40000928, 0x4000092c, \ + 0x40000930, 0x40000934, 0x40000938, 0x4000093c, \ + 0x40000940, 0x40000944, 0x40000948, 0x4000094c, \ + 0x40000950, 0x40000954, 0x40000958, 0x4000095c, \ + 0x40000960, 0x40000964, 0x40000968, 0x4000096c, \ + 0x40000970, 0x40000974, 0x40000978, 0x4000097c, \ + 0x40000980, 0x40000984, 0x40000988, 0x4000098c, \ + 0x40000990, 0x40000994, 0x40000998, 0x4000099c, \ + 0x400009a0, 0x400009a4, 0x400009a8, 0x400009ac, \ + 0x400009b0, 0x400009b4, 0x400009b8, 0x400009bc, \ + 0x400009c0, 0x400009c4, 0x400009c8, 0x400009cc, \ + 0x400009d0, 0x400009d4, 0x400009d8, 0x400009dc, \ + 0x400009e0, 0x400009e4, 0x400009e8, 0x400009ec, \ + 0x400009f0, 0x400009f4, 0x400009f8, 0x400009fc, \ + 0x40000a00, 0x40000a04, 0x40000a08, 0x40000a0c, \ + 0x40000a10, 0x40000a14, 0x40000a18, 0x40000a1c, \ + 0x40000a20, 0x40000a24, 0x40000a28, 0x40000a2c, \ + 0x40000a30, 0x40000a34, 0x40000a38, 0x40000a3c, \ + 0x40000a40, 0x40000a44, 0x40000a48, 0x40000a4c, \ + 0x40000a50, 0x40000a54, 0x40000a58, 0x40000a5c, \ + 0x40000a60, 0x40000a64, 0x40000a68, 0x40000a6c, \ + 0x40000a70, 0x40000a74, 0x40000a78, 0x40000a7c, \ + 0x40000a80, 0x40000a84, 0x40000a88, 0x40000a8c, \ + 0x40000a90, 0x40000a94, 0x40000a98, 0x40000a9c, \ + 0x40000aa0, 0x40000aa4, 0x40000aa8, 0x40000aac, \ + 0x40000ab0, 0x40000ab4, 0x40000ab8, 0x40000abc, \ + 0x40000ac0, 0x40000ac4, 0x40000ac8, 0x40000acc, \ + 0x40000ad0, 0x40000ad4, 0x40000ad8, 0x40000adc, \ + 0x40000ae0, 0x40000ae4, 0x40000ae8, 0x40000aec, \ + 0x40000af0, 0x40000af4, 0x40000af8, 0x40000afc, \ + 0x40000b00, 0x40000b04, 0x40000b08, 0x40000b0c, \ + 0x40000b10, 0x40000b14, 0x40000b18, 0x40000b1c, \ + 0x40000b20, 0x40000b24, 0x40000b28, 0x40000b2c, \ + 0x40000b30, 0x40000b34, 0x40000b38, 0x40000b3c, \ + 0x40000b40, 0x40000b44, 0x40000b48, 0x40000b4c, \ + 0x40000b50, 0x40000b54, 0x40000b58, 0x40000b5c, \ + 0x40000b60, 0x40000b64, 0x40000b68, 0x40000b6c, \ + 0x40000b70, 0x40000b74, 0x40000b78, 0x40000b7c, \ + 0x40000b80, 0x40000b84, 0x40000b88, 0x40000b8c, \ + 0x40000b90, 0x40000b94, 0x40000b98, 0x40000b9c, \ + 0x40000ba0, 0x40000ba4, 0x40000ba8, 0x40000bac, \ + 0x40000bb0, 0x40000bb4, 0x40000bb8, 0x40000bbc, \ + 0x40000bc0, 0x40000bc4, 0x40000bc8, 0x40000bcc, \ + 0x40000bd0, 0x40000bd4, 0x40000bd8, 0x40000bdc, \ + 0x40000be0, 0x40000be4, 0x40000be8, 0x40000bec, \ + 0x40000bf0, 0x40000bf4, 0x40000bf8, 0x40000bfc, \ + 0x40000c00, 0x40000c04, 0x40000c08, 0x40000c0c, \ + 0x40000c10, 0x40000c14, 0x40000c18, 0x40000c1c, \ + 0x40000c20, 0x40000c24, 0x40000c28, 0x40000c2c, \ + 0x40000c30, 0x40000c34, 0x40000c38, 0x40000c3c, \ + 0x40000c40, 0x40000c44, 0x40000c48, 0x40000c4c, \ + 0x40000c50, 0x40000c54, 0x40000c58, 0x40000c5c, \ + 0x40000c60, 0x40000c64, 0x40000c68, 0x40000c6c, \ + 0x40000c70, 0x40000c74, 0x40000c78, 0x40000c7c, \ + 0x40000c80, 0x40000c84, 0x40000c88, 0x40000c8c, \ + 0x40000c90, 0x40000c94, 0x40000c98, 0x40000c9c, \ + 0x40000ca0, 0x40000ca4, 0x40000ca8, 0x40000cac, \ + 0x40000cb0, 0x40000cb4, 0x40000cb8, 0x40000cbc, \ + 0x40000cc0, 0x40000cc4, 0x40000cc8, 0x40000ccc, \ + 0x40000cd0, 0x40000cd4, 0x40000cd8, 0x40000cdc, \ + 0xc0000ce0, 0x00000008, 0x00000002, 0x40000ce4, \ + 0x40000d04, 0x40000ce8, 0x40000d08, 0x40000cec, \ + 0x40000d0c, 0x40000cf0, 0x40000d10, 0x40000cf4, \ + 0x40000d14, 0x40000cf8, 0x40000d18, 0x40000cfc, \ + 0x40000d1c, 0x40000d00, 0x40000d20, 0xc0000d24, \ + 0x00000100, 0x00000001, 0x40000d28, 0x40000d2c, \ + 0x40000d30, 0x40000d34, 0x40000d38, 0x40000d3c, \ + 0x40000d40, 0x40000d44, 0x40000d48, 0x40000d4c, \ + 0x40000d50, 0x40000d54, 0x40000d58, 0x40000d5c, \ + 0x40000d60, 0x40000d64, 0x40000d68, 0x40000d6c, \ + 0x40000d70, 0x40000d74, 0x40000d78, 0x40000d7c, \ + 0x40000d80, 0x40000d84, 0x40000d88, 0x40000d8c, \ + 0x40000d90, 0x40000d94, 0x40000d98, 0x40000d9c, \ + 0x40000da0, 0x40000da4, 0x40000da8, 0x40000dac, \ + 0x40000db0, 0x40000db4, 0x40000db8, 0x40000dbc, \ + 0x40000dc0, 0x40000dc4, 0x40000dc8, 0x40000dcc, \ + 0x40000dd0, 0x40000dd4, 0x40000dd8, 0x40000ddc, \ + 0x40000de0, 0x40000de4, 0x40000de8, 0x40000dec, \ + 0x40000df0, 0x40000df4, 0x40000df8, 0x40000dfc, \ + 0x40000e00, 0x40000e04, 0x40000e08, 0x40000e0c, \ + 0x40000e10, 0x40000e14, 0x40000e18, 0x40000e1c, \ + 0x40000e20, 0x40000e24, 0x40000e28, 0x40000e2c, \ + 0x40000e30, 0x40000e34, 0x40000e38, 0x40000e3c, \ + 0x40000e40, 0x40000e44, 0x40000e48, 0x40000e4c, \ + 0x40000e50, 0x40000e54, 0x40000e58, 0x40000e5c, \ + 0x40000e60, 0x40000e64, 0x40000e68, 0x40000e6c, \ + 0x40000e70, 0x40000e74, 0x40000e78, 0x40000e7c, \ + 0x40000e80, 0x40000e84, 0x40000e88, 0x40000e8c, \ + 0x40000e90, 0x40000e94, 0x40000e98, 0x40000e9c, \ + 0x40000ea0, 0x40000ea4, 0x40000ea8, 0x40000eac, \ + 0x40000eb0, 0x40000eb4, 0x40000eb8, 0x40000ebc, \ + 0x40000ec0, 0x40000ec4, 0x40000ec8, 0x40000ecc, \ + 0x40000ed0, 0x40000ed4, 0x40000ed8, 0x40000edc, \ + 0x40000ee0, 0x40000ee4, 0x40000ee8, 0x40000eec, \ + 0x40000ef0, 0x40000ef4, 0x40000ef8, 0x40000efc, \ + 0x40000f00, 0x40000f04, 0x40000f08, 0x40000f0c, \ + 0x40000f10, 0x40000f14, 0x40000f18, 0x40000f1c, \ + 0x40000f20, 0x40000f24, 0x40000f28, 0x40000f2c, \ + 0x40000f30, 0x40000f34, 0x40000f38, 0x40000f3c, \ + 0x40000f40, 0x40000f44, 0x40000f48, 0x40000f4c, \ + 0x40000f50, 0x40000f54, 0x40000f58, 0x40000f5c, \ + 0x40000f60, 0x40000f64, 0x40000f68, 0x40000f6c, \ + 0x40000f70, 0x40000f74, 0x40000f78, 0x40000f7c, \ + 0x40000f80, 0x40000f84, 0x40000f88, 0x40000f8c, \ + 0x40000f90, 0x40000f94, 0x40000f98, 0x40000f9c, \ + 0x40000fa0, 0x40000fa4, 0x40000fa8, 0x40000fac, \ + 0x40000fb0, 0x40000fb4, 0x40000fb8, 0x40000fbc, \ + 0x40000fc0, 0x40000fc4, 0x40000fc8, 0x40000fcc, \ + 0x40000fd0, 0x40000fd4, 0x40000fd8, 0x40000fdc, \ + 0x40000fe0, 0x40000fe4, 0x40000fe8, 0x40000fec, \ + 0x40000ff0, 0x40000ff4, 0x40000ff8, 0x40000ffc, \ + 0x40001000, 0x40001004, 0x40001008, 0x4000100c, \ + 0x40001010, 0x40001014, 0x40001018, 0x4000101c, \ + 0x40001020, 0x40001024, 0x40001028, 0x4000102c, \ + 0x40001030, 0x40001034, 0x40001038, 0x4000103c, \ + 0x40001040, 0x40001044, 0x40001048, 0x4000104c, \ + 0x40001050, 0x40001054, 0x40001058, 0x4000105c, \ + 0x40001060, 0x40001064, 0x40001068, 0x4000106c, \ + 0x40001070, 0x40001074, 0x40001078, 0x4000107c, \ + 0x40001080, 0x40001084, 0x40001088, 0x4000108c, \ + 0x40001090, 0x40001094, 0x40001098, 0x4000109c, \ + 0x400010a0, 0x400010a4, 0x400010a8, 0x400010ac, \ + 0x400010b0, 0x400010b4, 0x400010b8, 0x400010bc, \ + 0x400010c0, 0x400010c4, 0x400010c8, 0x400010cc, \ + 0x400010d0, 0x400010d4, 0x400010d8, 0x400010dc, \ + 0x400010e0, 0x400010e4, 0x400010e8, 0x400010ec, \ + 0x400010f0, 0x400010f4, 0x400010f8, 0x400010fc, \ + 0x40001100, 0x40001104, 0x40001108, 0x4000110c, \ + 0x40001110, 0x40001114, 0x40001118, 0x4000111c, \ + 0x40001120, 0x40001124, 0xc0001128, 0x00000008, \ + 0x00000002, 0x4000112c, 0x4000114c, 0x40001130, \ + 0x40001150, 0x40001134, 0x40001154, 0x40001138, \ + 0x40001158, 0x4000113c, 0x4000115c, 0x40001140, \ + 0x40001160, 0x40001144, 0x40001164, 0x40001148, \ + 0x40001168, 0xc000116c, 0x00000100, 0x00000001, \ + 0x40001170, 0x40001174, 0x40001178, 0x4000117c, \ + 0x40001180, 0x40001184, 0x40001188, 0x4000118c, \ + 0x40001190, 0x40001194, 0x40001198, 0x4000119c, \ + 0x400011a0, 0x400011a4, 0x400011a8, 0x400011ac, \ + 0x400011b0, 0x400011b4, 0x400011b8, 0x400011bc, \ + 0x400011c0, 0x400011c4, 0x400011c8, 0x400011cc, \ + 0x400011d0, 0x400011d4, 0x400011d8, 0x400011dc, \ + 0x400011e0, 0x400011e4, 0x400011e8, 0x400011ec, \ + 0x400011f0, 0x400011f4, 0x400011f8, 0x400011fc, \ + 0x40001200, 0x40001204, 0x40001208, 0x4000120c, \ + 0x40001210, 0x40001214, 0x40001218, 0x4000121c, \ + 0x40001220, 0x40001224, 0x40001228, 0x4000122c, \ + 0x40001230, 0x40001234, 0x40001238, 0x4000123c, \ + 0x40001240, 0x40001244, 0x40001248, 0x4000124c, \ + 0x40001250, 0x40001254, 0x40001258, 0x4000125c, \ + 0x40001260, 0x40001264, 0x40001268, 0x4000126c, \ + 0x40001270, 0x40001274, 0x40001278, 0x4000127c, \ + 0x40001280, 0x40001284, 0x40001288, 0x4000128c, \ + 0x40001290, 0x40001294, 0x40001298, 0x4000129c, \ + 0x400012a0, 0x400012a4, 0x400012a8, 0x400012ac, \ + 0x400012b0, 0x400012b4, 0x400012b8, 0x400012bc, \ + 0x400012c0, 0x400012c4, 0x400012c8, 0x400012cc, \ + 0x400012d0, 0x400012d4, 0x400012d8, 0x400012dc, \ + 0x400012e0, 0x400012e4, 0x400012e8, 0x400012ec, \ + 0x400012f0, 0x400012f4, 0x400012f8, 0x400012fc, \ + 0x40001300, 0x40001304, 0x40001308, 0x4000130c, \ + 0x40001310, 0x40001314, 0x40001318, 0x4000131c, \ + 0x40001320, 0x40001324, 0x40001328, 0x4000132c, \ + 0x40001330, 0x40001334, 0x40001338, 0x4000133c, \ + 0x40001340, 0x40001344, 0x40001348, 0x4000134c, \ + 0x40001350, 0x40001354, 0x40001358, 0x4000135c, \ + 0x40001360, 0x40001364, 0x40001368, 0x4000136c, \ + 0x40001370, 0x40001374, 0x40001378, 0x4000137c, \ + 0x40001380, 0x40001384, 0x40001388, 0x4000138c, \ + 0x40001390, 0x40001394, 0x40001398, 0x4000139c, \ + 0x400013a0, 0x400013a4, 0x400013a8, 0x400013ac, \ + 0x400013b0, 0x400013b4, 0x400013b8, 0x400013bc, \ + 0x400013c0, 0x400013c4, 0x400013c8, 0x400013cc, \ + 0x400013d0, 0x400013d4, 0x400013d8, 0x400013dc, \ + 0x400013e0, 0x400013e4, 0x400013e8, 0x400013ec, \ + 0x400013f0, 0x400013f4, 0x400013f8, 0x400013fc, \ + 0x40001400, 0x40001404, 0x40001408, 0x4000140c, \ + 0x40001410, 0x40001414, 0x40001418, 0x4000141c, \ + 0x40001420, 0x40001424, 0x40001428, 0x4000142c, \ + 0x40001430, 0x40001434, 0x40001438, 0x4000143c, \ + 0x40001440, 0x40001444, 0x40001448, 0x4000144c, \ + 0x40001450, 0x40001454, 0x40001458, 0x4000145c, \ + 0x40001460, 0x40001464, 0x40001468, 0x4000146c, \ + 0x40001470, 0x40001474, 0x40001478, 0x4000147c, \ + 0x40001480, 0x40001484, 0x40001488, 0x4000148c, \ + 0x40001490, 0x40001494, 0x40001498, 0x4000149c, \ + 0x400014a0, 0x400014a4, 0x400014a8, 0x400014ac, \ + 0x400014b0, 0x400014b4, 0x400014b8, 0x400014bc, \ + 0x400014c0, 0x400014c4, 0x400014c8, 0x400014cc, \ + 0x400014d0, 0x400014d4, 0x400014d8, 0x400014dc, \ + 0x400014e0, 0x400014e4, 0x400014e8, 0x400014ec, \ + 0x400014f0, 0x400014f4, 0x400014f8, 0x400014fc, \ + 0x40001500, 0x40001504, 0x40001508, 0x4000150c, \ + 0x40001510, 0x40001514, 0x40001518, 0x4000151c, \ + 0x40001520, 0x40001524, 0x40001528, 0x4000152c, \ + 0x40001530, 0x40001534, 0x40001538, 0x4000153c, \ + 0x40001540, 0x40001544, 0x40001548, 0x4000154c, \ + 0x40001550, 0x40001554, 0x40001558, 0x4000155c, \ + 0x40001560, 0x40001564, 0x40001568, 0x4000156c, \ + 0xc0001570, 0x00000008, 0x00000002, 0x40001574, \ + 0x40001594, 0x40001578, 0x40001598, 0x4000157c, \ + 0x4000159c, 0x40001580, 0x400015a0, 0x40001584, \ + 0x400015a4, 0x40001588, 0x400015a8, 0x4000158c, \ + 0x400015ac, 0x40001590, 0x400015b0, 0xc00015b4, \ + 0x00000100, 0x00000001, 0x400015b8, 0x400015bc, \ + 0x400015c0, 0x400015c4, 0x400015c8, 0x400015cc, \ + 0x400015d0, 0x400015d4, 0x400015d8, 0x400015dc, \ + 0x400015e0, 0x400015e4, 0x400015e8, 0x400015ec, \ + 0x400015f0, 0x400015f4, 0x400015f8, 0x400015fc, \ + 0x40001600, 0x40001604, 0x40001608, 0x4000160c, \ + 0x40001610, 0x40001614, 0x40001618, 0x4000161c, \ + 0x40001620, 0x40001624, 0x40001628, 0x4000162c, \ + 0x40001630, 0x40001634, 0x40001638, 0x4000163c, \ + 0x40001640, 0x40001644, 0x40001648, 0x4000164c, \ + 0x40001650, 0x40001654, 0x40001658, 0x4000165c, \ + 0x40001660, 0x40001664, 0x40001668, 0x4000166c, \ + 0x40001670, 0x40001674, 0x40001678, 0x4000167c, \ + 0x40001680, 0x40001684, 0x40001688, 0x4000168c, \ + 0x40001690, 0x40001694, 0x40001698, 0x4000169c, \ + 0x400016a0, 0x400016a4, 0x400016a8, 0x400016ac, \ + 0x400016b0, 0x400016b4, 0x400016b8, 0x400016bc, \ + 0x400016c0, 0x400016c4, 0x400016c8, 0x400016cc, \ + 0x400016d0, 0x400016d4, 0x400016d8, 0x400016dc, \ + 0x400016e0, 0x400016e4, 0x400016e8, 0x400016ec, \ + 0x400016f0, 0x400016f4, 0x400016f8, 0x400016fc, \ + 0x40001700, 0x40001704, 0x40001708, 0x4000170c, \ + 0x40001710, 0x40001714, 0x40001718, 0x4000171c, \ + 0x40001720, 0x40001724, 0x40001728, 0x4000172c, \ + 0x40001730, 0x40001734, 0x40001738, 0x4000173c, \ + 0x40001740, 0x40001744, 0x40001748, 0x4000174c, \ + 0x40001750, 0x40001754, 0x40001758, 0x4000175c, \ + 0x40001760, 0x40001764, 0x40001768, 0x4000176c, \ + 0x40001770, 0x40001774, 0x40001778, 0x4000177c, \ + 0x40001780, 0x40001784, 0x40001788, 0x4000178c, \ + 0x40001790, 0x40001794, 0x40001798, 0x4000179c, \ + 0x400017a0, 0x400017a4, 0x400017a8, 0x400017ac, \ + 0x400017b0, 0x400017b4, 0x400017b8, 0x400017bc, \ + 0x400017c0, 0x400017c4, 0x400017c8, 0x400017cc, \ + 0x400017d0, 0x400017d4, 0x400017d8, 0x400017dc, \ + 0x400017e0, 0x400017e4, 0x400017e8, 0x400017ec, \ + 0x400017f0, 0x400017f4, 0x400017f8, 0x400017fc, \ + 0x40001800, 0x40001804, 0x40001808, 0x4000180c, \ + 0x40001810, 0x40001814, 0x40001818, 0x4000181c, \ + 0x40001820, 0x40001824, 0x40001828, 0x4000182c, \ + 0x40001830, 0x40001834, 0x40001838, 0x4000183c, \ + 0x40001840, 0x40001844, 0x40001848, 0x4000184c, \ + 0x40001850, 0x40001854, 0x40001858, 0x4000185c, \ + 0x40001860, 0x40001864, 0x40001868, 0x4000186c, \ + 0x40001870, 0x40001874, 0x40001878, 0x4000187c, \ + 0x40001880, 0x40001884, 0x40001888, 0x4000188c, \ + 0x40001890, 0x40001894, 0x40001898, 0x4000189c, \ + 0x400018a0, 0x400018a4, 0x400018a8, 0x400018ac, \ + 0x400018b0, 0x400018b4, 0x400018b8, 0x400018bc, \ + 0x400018c0, 0x400018c4, 0x400018c8, 0x400018cc, \ + 0x400018d0, 0x400018d4, 0x400018d8, 0x400018dc, \ + 0x400018e0, 0x400018e4, 0x400018e8, 0x400018ec, \ + 0x400018f0, 0x400018f4, 0x400018f8, 0x400018fc, \ + 0x40001900, 0x40001904, 0x40001908, 0x4000190c, \ + 0x40001910, 0x40001914, 0x40001918, 0x4000191c, \ + 0x40001920, 0x40001924, 0x40001928, 0x4000192c, \ + 0x40001930, 0x40001934, 0x40001938, 0x4000193c, \ + 0x40001940, 0x40001944, 0x40001948, 0x4000194c, \ + 0x40001950, 0x40001954, 0x40001958, 0x4000195c, \ + 0x40001960, 0x40001964, 0x40001968, 0x4000196c, \ + 0x40001970, 0x40001974, 0x40001978, 0x4000197c, \ + 0x40001980, 0x40001984, 0x40001988, 0x4000198c, \ + 0x40001990, 0x40001994, 0x40001998, 0x4000199c, \ + 0x400019a0, 0x400019a4, 0x400019a8, 0x400019ac, \ + 0x400019b0, 0x400019b4, 0xc00019b8, 0x00000008, \ + 0x00000002, 0x400019bc, 0x400019dc, 0x400019c0, \ + 0x400019e0, 0x400019c4, 0x400019e4, 0x400019c8, \ + 0x400019e8, 0x400019cc, 0x400019ec, 0x400019d0, \ + 0x400019f0, 0x400019d4, 0x400019f4, 0x400019d8, \ + 0x400019f8, 0xc00019fc, 0x00000100, 0x00000001, \ + 0x40001a00, 0x40001a04, 0x40001a08, 0x40001a0c, \ + 0x40001a10, 0x40001a14, 0x40001a18, 0x40001a1c, \ + 0x40001a20, 0x40001a24, 0x40001a28, 0x40001a2c, \ + 0x40001a30, 0x40001a34, 0x40001a38, 0x40001a3c, \ + 0x40001a40, 0x40001a44, 0x40001a48, 0x40001a4c, \ + 0x40001a50, 0x40001a54, 0x40001a58, 0x40001a5c, \ + 0x40001a60, 0x40001a64, 0x40001a68, 0x40001a6c, \ + 0x40001a70, 0x40001a74, 0x40001a78, 0x40001a7c, \ + 0x40001a80, 0x40001a84, 0x40001a88, 0x40001a8c, \ + 0x40001a90, 0x40001a94, 0x40001a98, 0x40001a9c, \ + 0x40001aa0, 0x40001aa4, 0x40001aa8, 0x40001aac, \ + 0x40001ab0, 0x40001ab4, 0x40001ab8, 0x40001abc, \ + 0x40001ac0, 0x40001ac4, 0x40001ac8, 0x40001acc, \ + 0x40001ad0, 0x40001ad4, 0x40001ad8, 0x40001adc, \ + 0x40001ae0, 0x40001ae4, 0x40001ae8, 0x40001aec, \ + 0x40001af0, 0x40001af4, 0x40001af8, 0x40001afc, \ + 0x40001b00, 0x40001b04, 0x40001b08, 0x40001b0c, \ + 0x40001b10, 0x40001b14, 0x40001b18, 0x40001b1c, \ + 0x40001b20, 0x40001b24, 0x40001b28, 0x40001b2c, \ + 0x40001b30, 0x40001b34, 0x40001b38, 0x40001b3c, \ + 0x40001b40, 0x40001b44, 0x40001b48, 0x40001b4c, \ + 0x40001b50, 0x40001b54, 0x40001b58, 0x40001b5c, \ + 0x40001b60, 0x40001b64, 0x40001b68, 0x40001b6c, \ + 0x40001b70, 0x40001b74, 0x40001b78, 0x40001b7c, \ + 0x40001b80, 0x40001b84, 0x40001b88, 0x40001b8c, \ + 0x40001b90, 0x40001b94, 0x40001b98, 0x40001b9c, \ + 0x40001ba0, 0x40001ba4, 0x40001ba8, 0x40001bac, \ + 0x40001bb0, 0x40001bb4, 0x40001bb8, 0x40001bbc, \ + 0x40001bc0, 0x40001bc4, 0x40001bc8, 0x40001bcc, \ + 0x40001bd0, 0x40001bd4, 0x40001bd8, 0x40001bdc, \ + 0x40001be0, 0x40001be4, 0x40001be8, 0x40001bec, \ + 0x40001bf0, 0x40001bf4, 0x40001bf8, 0x40001bfc, \ + 0x40001c00, 0x40001c04, 0x40001c08, 0x40001c0c, \ + 0x40001c10, 0x40001c14, 0x40001c18, 0x40001c1c, \ + 0x40001c20, 0x40001c24, 0x40001c28, 0x40001c2c, \ + 0x40001c30, 0x40001c34, 0x40001c38, 0x40001c3c, \ + 0x40001c40, 0x40001c44, 0x40001c48, 0x40001c4c, \ + 0x40001c50, 0x40001c54, 0x40001c58, 0x40001c5c, \ + 0x40001c60, 0x40001c64, 0x40001c68, 0x40001c6c, \ + 0x40001c70, 0x40001c74, 0x40001c78, 0x40001c7c, \ + 0x40001c80, 0x40001c84, 0x40001c88, 0x40001c8c, \ + 0x40001c90, 0x40001c94, 0x40001c98, 0x40001c9c, \ + 0x40001ca0, 0x40001ca4, 0x40001ca8, 0x40001cac, \ + 0x40001cb0, 0x40001cb4, 0x40001cb8, 0x40001cbc, \ + 0x40001cc0, 0x40001cc4, 0x40001cc8, 0x40001ccc, \ + 0x40001cd0, 0x40001cd4, 0x40001cd8, 0x40001cdc, \ + 0x40001ce0, 0x40001ce4, 0x40001ce8, 0x40001cec, \ + 0x40001cf0, 0x40001cf4, 0x40001cf8, 0x40001cfc, \ + 0x40001d00, 0x40001d04, 0x40001d08, 0x40001d0c, \ + 0x40001d10, 0x40001d14, 0x40001d18, 0x40001d1c, \ + 0x40001d20, 0x40001d24, 0x40001d28, 0x40001d2c, \ + 0x40001d30, 0x40001d34, 0x40001d38, 0x40001d3c, \ + 0x40001d40, 0x40001d44, 0x40001d48, 0x40001d4c, \ + 0x40001d50, 0x40001d54, 0x40001d58, 0x40001d5c, \ + 0x40001d60, 0x40001d64, 0x40001d68, 0x40001d6c, \ + 0x40001d70, 0x40001d74, 0x40001d78, 0x40001d7c, \ + 0x40001d80, 0x40001d84, 0x40001d88, 0x40001d8c, \ + 0x40001d90, 0x40001d94, 0x40001d98, 0x40001d9c, \ + 0x40001da0, 0x40001da4, 0x40001da8, 0x40001dac, \ + 0x40001db0, 0x40001db4, 0x40001db8, 0x40001dbc, \ + 0x40001dc0, 0x40001dc4, 0x40001dc8, 0x40001dcc, \ + 0x40001dd0, 0x40001dd4, 0x40001dd8, 0x40001ddc, \ + 0x40001de0, 0x40001de4, 0x40001de8, 0x40001dec, \ + 0x40001df0, 0x40001df4, 0x40001df8, 0x40001dfc, \ + 0xc0001e00, 0x00000008, 0x00000002, 0x40001e04, \ + 0x40001e24, 0x40001e08, 0x40001e28, 0x40001e0c, \ + 0x40001e2c, 0x40001e10, 0x40001e30, 0x40001e14, \ + 0x40001e34, 0x40001e18, 0x40001e38, 0x40001e1c, \ + 0x40001e3c, 0x40001e20, 0x40001e40, 0xc0001e44, \ + 0x00000100, 0x00000001, 0x40001e48, 0x40001e4c, \ + 0x40001e50, 0x40001e54, 0x40001e58, 0x40001e5c, \ + 0x40001e60, 0x40001e64, 0x40001e68, 0x40001e6c, \ + 0x40001e70, 0x40001e74, 0x40001e78, 0x40001e7c, \ + 0x40001e80, 0x40001e84, 0x40001e88, 0x40001e8c, \ + 0x40001e90, 0x40001e94, 0x40001e98, 0x40001e9c, \ + 0x40001ea0, 0x40001ea4, 0x40001ea8, 0x40001eac, \ + 0x40001eb0, 0x40001eb4, 0x40001eb8, 0x40001ebc, \ + 0x40001ec0, 0x40001ec4, 0x40001ec8, 0x40001ecc, \ + 0x40001ed0, 0x40001ed4, 0x40001ed8, 0x40001edc, \ + 0x40001ee0, 0x40001ee4, 0x40001ee8, 0x40001eec, \ + 0x40001ef0, 0x40001ef4, 0x40001ef8, 0x40001efc, \ + 0x40001f00, 0x40001f04, 0x40001f08, 0x40001f0c, \ + 0x40001f10, 0x40001f14, 0x40001f18, 0x40001f1c, \ + 0x40001f20, 0x40001f24, 0x40001f28, 0x40001f2c, \ + 0x40001f30, 0x40001f34, 0x40001f38, 0x40001f3c, \ + 0x40001f40, 0x40001f44, 0x40001f48, 0x40001f4c, \ + 0x40001f50, 0x40001f54, 0x40001f58, 0x40001f5c, \ + 0x40001f60, 0x40001f64, 0x40001f68, 0x40001f6c, \ + 0x40001f70, 0x40001f74, 0x40001f78, 0x40001f7c, \ + 0x40001f80, 0x40001f84, 0x40001f88, 0x40001f8c, \ + 0x40001f90, 0x40001f94, 0x40001f98, 0x40001f9c, \ + 0x40001fa0, 0x40001fa4, 0x40001fa8, 0x40001fac, \ + 0x40001fb0, 0x40001fb4, 0x40001fb8, 0x40001fbc, \ + 0x40001fc0, 0x40001fc4, 0x40001fc8, 0x40001fcc, \ + 0x40001fd0, 0x40001fd4, 0x40001fd8, 0x40001fdc, \ + 0x40001fe0, 0x40001fe4, 0x40001fe8, 0x40001fec, \ + 0x40001ff0, 0x40001ff4, 0x40001ff8, 0x40001ffc, \ + 0x40002000, 0x40002004, 0x40002008, 0x4000200c, \ + 0x40002010, 0x40002014, 0x40002018, 0x4000201c, \ + 0x40002020, 0x40002024, 0x40002028, 0x4000202c, \ + 0x40002030, 0x40002034, 0x40002038, 0x4000203c, \ + 0x40002040, 0x40002044, 0x40002048, 0x4000204c, \ + 0x40002050, 0x40002054, 0x40002058, 0x4000205c, \ + 0x40002060, 0x40002064, 0x40002068, 0x4000206c, \ + 0x40002070, 0x40002074, 0x40002078, 0x4000207c, \ + 0x40002080, 0x40002084, 0x40002088, 0x4000208c, \ + 0x40002090, 0x40002094, 0x40002098, 0x4000209c, \ + 0x400020a0, 0x400020a4, 0x400020a8, 0x400020ac, \ + 0x400020b0, 0x400020b4, 0x400020b8, 0x400020bc, \ + 0x400020c0, 0x400020c4, 0x400020c8, 0x400020cc, \ + 0x400020d0, 0x400020d4, 0x400020d8, 0x400020dc, \ + 0x400020e0, 0x400020e4, 0x400020e8, 0x400020ec, \ + 0x400020f0, 0x400020f4, 0x400020f8, 0x400020fc, \ + 0x40002100, 0x40002104, 0x40002108, 0x4000210c, \ + 0x40002110, 0x40002114, 0x40002118, 0x4000211c, \ + 0x40002120, 0x40002124, 0x40002128, 0x4000212c, \ + 0x40002130, 0x40002134, 0x40002138, 0x4000213c, \ + 0x40002140, 0x40002144, 0x40002148, 0x4000214c, \ + 0x40002150, 0x40002154, 0x40002158, 0x4000215c, \ + 0x40002160, 0x40002164, 0x40002168, 0x4000216c, \ + 0x40002170, 0x40002174, 0x40002178, 0x4000217c, \ + 0x40002180, 0x40002184, 0x40002188, 0x4000218c, \ + 0x40002190, 0x40002194, 0x40002198, 0x4000219c, \ + 0x400021a0, 0x400021a4, 0x400021a8, 0x400021ac, \ + 0x400021b0, 0x400021b4, 0x400021b8, 0x400021bc, \ + 0x400021c0, 0x400021c4, 0x400021c8, 0x400021cc, \ + 0x400021d0, 0x400021d4, 0x400021d8, 0x400021dc, \ + 0x400021e0, 0x400021e4, 0x400021e8, 0x400021ec, \ + 0x400021f0, 0x400021f4, 0x400021f8, 0x400021fc, \ + 0x40002200, 0x40002204, 0x40002208, 0x4000220c, \ + 0x40002210, 0x40002214, 0x40002218, 0x4000221c, \ + 0x40002220, 0x40002224, 0x40002228, 0x4000222c, \ + 0x40002230, 0x40002234, 0x40002238, 0x4000223c, \ + 0x40002240, 0x40002244, 0xc0002248, 0x00000008, \ + 0x00000002, 0x4000224c, 0x4000226c, 0x40002250, \ + 0x40002270, 0x40002254, 0x40002274, 0x40002258, \ + 0x40002278, 0x4000225c, 0x4000227c, 0x40002260, \ + 0x40002280, 0x40002264, 0x40002284, 0x40002268, \ + 0x40002288, 0xc000228c, 0x00000100, 0x00000001, \ + 0x40002290, 0x40002294, 0x40002298, 0x4000229c, \ + 0x400022a0, 0x400022a4, 0x400022a8, 0x400022ac, \ + 0x400022b0, 0x400022b4, 0x400022b8, 0x400022bc, \ + 0x400022c0, 0x400022c4, 0x400022c8, 0x400022cc, \ + 0x400022d0, 0x400022d4, 0x400022d8, 0x400022dc, \ + 0x400022e0, 0x400022e4, 0x400022e8, 0x400022ec, \ + 0x400022f0, 0x400022f4, 0x400022f8, 0x400022fc, \ + 0x40002300, 0x40002304, 0x40002308, 0x4000230c, \ + 0x40002310, 0x40002314, 0x40002318, 0x4000231c, \ + 0x40002320, 0x40002324, 0x40002328, 0x4000232c, \ + 0x40002330, 0x40002334, 0x40002338, 0x4000233c, \ + 0x40002340, 0x40002344, 0x40002348, 0x4000234c, \ + 0x40002350, 0x40002354, 0x40002358, 0x4000235c, \ + 0x40002360, 0x40002364, 0x40002368, 0x4000236c, \ + 0x40002370, 0x40002374, 0x40002378, 0x4000237c, \ + 0x40002380, 0x40002384, 0x40002388, 0x4000238c, \ + 0x40002390, 0x40002394, 0x40002398, 0x4000239c, \ + 0x400023a0, 0x400023a4, 0x400023a8, 0x400023ac, \ + 0x400023b0, 0x400023b4, 0x400023b8, 0x400023bc, \ + 0x400023c0, 0x400023c4, 0x400023c8, 0x400023cc, \ + 0x400023d0, 0x400023d4, 0x400023d8, 0x400023dc, \ + 0x400023e0, 0x400023e4, 0x400023e8, 0x400023ec, \ + 0x400023f0, 0x400023f4, 0x400023f8, 0x400023fc, \ + 0x40002400, 0x40002404, 0x40002408, 0x4000240c, \ + 0x40002410, 0x40002414, 0x40002418, 0x4000241c, \ + 0x40002420, 0x40002424, 0x40002428, 0x4000242c, \ + 0x40002430, 0x40002434, 0x40002438, 0x4000243c, \ + 0x40002440, 0x40002444, 0x40002448, 0x4000244c, \ + 0x40002450, 0x40002454, 0x40002458, 0x4000245c, \ + 0x40002460, 0x40002464, 0x40002468, 0x4000246c, \ + 0x40002470, 0x40002474, 0x40002478, 0x4000247c, \ + 0x40002480, 0x40002484, 0x40002488, 0x4000248c, \ + 0x40002490, 0x40002494, 0x40002498, 0x4000249c, \ + 0x400024a0, 0x400024a4, 0x400024a8, 0x400024ac, \ + 0x400024b0, 0x400024b4, 0x400024b8, 0x400024bc, \ + 0x400024c0, 0x400024c4, 0x400024c8, 0x400024cc, \ + 0x400024d0, 0x400024d4, 0x400024d8, 0x400024dc, \ + 0x400024e0, 0x400024e4, 0x400024e8, 0x400024ec, \ + 0x400024f0, 0x400024f4, 0x400024f8, 0x400024fc, \ + 0x40002500, 0x40002504, 0x40002508, 0x4000250c, \ + 0x40002510, 0x40002514, 0x40002518, 0x4000251c, \ + 0x40002520, 0x40002524, 0x40002528, 0x4000252c, \ + 0x40002530, 0x40002534, 0x40002538, 0x4000253c, \ + 0x40002540, 0x40002544, 0x40002548, 0x4000254c, \ + 0x40002550, 0x40002554, 0x40002558, 0x4000255c, \ + 0x40002560, 0x40002564, 0x40002568, 0x4000256c, \ + 0x40002570, 0x40002574, 0x40002578, 0x4000257c, \ + 0x40002580, 0x40002584, 0x40002588, 0x4000258c, \ + 0x40002590, 0x40002594, 0x40002598, 0x4000259c, \ + 0x400025a0, 0x400025a4, 0x400025a8, 0x400025ac, \ + 0x400025b0, 0x400025b4, 0x400025b8, 0x400025bc, \ + 0x400025c0, 0x400025c4, 0x400025c8, 0x400025cc, \ + 0x400025d0, 0x400025d4, 0x400025d8, 0x400025dc, \ + 0x400025e0, 0x400025e4, 0x400025e8, 0x400025ec, \ + 0x400025f0, 0x400025f4, 0x400025f8, 0x400025fc, \ + 0x40002600, 0x40002604, 0x40002608, 0x4000260c, \ + 0x40002610, 0x40002614, 0x40002618, 0x4000261c, \ + 0x40002620, 0x40002624, 0x40002628, 0x4000262c, \ + 0x40002630, 0x40002634, 0x40002638, 0x4000263c, \ + 0x40002640, 0x40002644, 0x40002648, 0x4000264c, \ + 0x40002650, 0x40002654, 0x40002658, 0x4000265c, \ + 0x40002660, 0x40002664, 0x40002668, 0x4000266c, \ + 0x40002670, 0x40002674, 0x40002678, 0x4000267c, \ + 0x40002680, 0x40002684, 0x40002688, 0x4000268c, \ + 0xc0002690, 0x00000008, 0x00000002, 0x40002694, \ + 0x400026b4, 0x40002698, 0x400026b8, 0x4000269c, \ + 0x400026bc, 0x400026a0, 0x400026c0, 0x400026a4, \ + 0x400026c4, 0x400026a8, 0x400026c8, 0x400026ac, \ + 0x400026cc, 0x400026b0, 0x400026d0, 0xc00026d4, \ + 0x00000100, 0x00000001, 0x400026d8, 0x400026dc, \ + 0x400026e0, 0x400026e4, 0x400026e8, 0x400026ec, \ + 0x400026f0, 0x400026f4, 0x400026f8, 0x400026fc, \ + 0x40002700, 0x40002704, 0x40002708, 0x4000270c, \ + 0x40002710, 0x40002714, 0x40002718, 0x4000271c, \ + 0x40002720, 0x40002724, 0x40002728, 0x4000272c, \ + 0x40002730, 0x40002734, 0x40002738, 0x4000273c, \ + 0x40002740, 0x40002744, 0x40002748, 0x4000274c, \ + 0x40002750, 0x40002754, 0x40002758, 0x4000275c, \ + 0x40002760, 0x40002764, 0x40002768, 0x4000276c, \ + 0x40002770, 0x40002774, 0x40002778, 0x4000277c, \ + 0x40002780, 0x40002784, 0x40002788, 0x4000278c, \ + 0x40002790, 0x40002794, 0x40002798, 0x4000279c, \ + 0x400027a0, 0x400027a4, 0x400027a8, 0x400027ac, \ + 0x400027b0, 0x400027b4, 0x400027b8, 0x400027bc, \ + 0x400027c0, 0x400027c4, 0x400027c8, 0x400027cc, \ + 0x400027d0, 0x400027d4, 0x400027d8, 0x400027dc, \ + 0x400027e0, 0x400027e4, 0x400027e8, 0x400027ec, \ + 0x400027f0, 0x400027f4, 0x400027f8, 0x400027fc, \ + 0x40002800, 0x40002804, 0x40002808, 0x4000280c, \ + 0x40002810, 0x40002814, 0x40002818, 0x4000281c, \ + 0x40002820, 0x40002824, 0x40002828, 0x4000282c, \ + 0x40002830, 0x40002834, 0x40002838, 0x4000283c, \ + 0x40002840, 0x40002844, 0x40002848, 0x4000284c, \ + 0x40002850, 0x40002854, 0x40002858, 0x4000285c, \ + 0x40002860, 0x40002864, 0x40002868, 0x4000286c, \ + 0x40002870, 0x40002874, 0x40002878, 0x4000287c, \ + 0x40002880, 0x40002884, 0x40002888, 0x4000288c, \ + 0x40002890, 0x40002894, 0x40002898, 0x4000289c, \ + 0x400028a0, 0x400028a4, 0x400028a8, 0x400028ac, \ + 0x400028b0, 0x400028b4, 0x400028b8, 0x400028bc, \ + 0x400028c0, 0x400028c4, 0x400028c8, 0x400028cc, \ + 0x400028d0, 0x400028d4, 0x400028d8, 0x400028dc, \ + 0x400028e0, 0x400028e4, 0x400028e8, 0x400028ec, \ + 0x400028f0, 0x400028f4, 0x400028f8, 0x400028fc, \ + 0x40002900, 0x40002904, 0x40002908, 0x4000290c, \ + 0x40002910, 0x40002914, 0x40002918, 0x4000291c, \ + 0x40002920, 0x40002924, 0x40002928, 0x4000292c, \ + 0x40002930, 0x40002934, 0x40002938, 0x4000293c, \ + 0x40002940, 0x40002944, 0x40002948, 0x4000294c, \ + 0x40002950, 0x40002954, 0x40002958, 0x4000295c, \ + 0x40002960, 0x40002964, 0x40002968, 0x4000296c, \ + 0x40002970, 0x40002974, 0x40002978, 0x4000297c, \ + 0x40002980, 0x40002984, 0x40002988, 0x4000298c, \ + 0x40002990, 0x40002994, 0x40002998, 0x4000299c, \ + 0x400029a0, 0x400029a4, 0x400029a8, 0x400029ac, \ + 0x400029b0, 0x400029b4, 0x400029b8, 0x400029bc, \ + 0x400029c0, 0x400029c4, 0x400029c8, 0x400029cc, \ + 0x400029d0, 0x400029d4, 0x400029d8, 0x400029dc, \ + 0x400029e0, 0x400029e4, 0x400029e8, 0x400029ec, \ + 0x400029f0, 0x400029f4, 0x400029f8, 0x400029fc, \ + 0x40002a00, 0x40002a04, 0x40002a08, 0x40002a0c, \ + 0x40002a10, 0x40002a14, 0x40002a18, 0x40002a1c, \ + 0x40002a20, 0x40002a24, 0x40002a28, 0x40002a2c, \ + 0x40002a30, 0x40002a34, 0x40002a38, 0x40002a3c, \ + 0x40002a40, 0x40002a44, 0x40002a48, 0x40002a4c, \ + 0x40002a50, 0x40002a54, 0x40002a58, 0x40002a5c, \ + 0x40002a60, 0x40002a64, 0x40002a68, 0x40002a6c, \ + 0x40002a70, 0x40002a74, 0x40002a78, 0x40002a7c, \ + 0x40002a80, 0x40002a84, 0x40002a88, 0x40002a8c, \ + 0x40002a90, 0x40002a94, 0x40002a98, 0x40002a9c, \ + 0x40002aa0, 0x40002aa4, 0x40002aa8, 0x40002aac, \ + 0x40002ab0, 0x40002ab4, 0x40002ab8, 0x40002abc, \ + 0x40002ac0, 0x40002ac4, 0x40002ac8, 0x40002acc, \ + 0x40002ad0, 0x40002ad4, 0xc0002ad8, 0x00000008, \ + 0x00000002, 0x40002adc, 0x40002afc, 0x40002ae0, \ + 0x40002b00, 0x40002ae4, 0x40002b04, 0x40002ae8, \ + 0x40002b08, 0x40002aec, 0x40002b0c, 0x40002af0, \ + 0x40002b10, 0x40002af4, 0x40002b14, 0x40002af8, \ + 0x40002b18, 0xc0002b1c, 0x00000100, 0x00000001, \ + 0x40002b20, 0x40002b24, 0x40002b28, 0x40002b2c, \ + 0x40002b30, 0x40002b34, 0x40002b38, 0x40002b3c, \ + 0x40002b40, 0x40002b44, 0x40002b48, 0x40002b4c, \ + 0x40002b50, 0x40002b54, 0x40002b58, 0x40002b5c, \ + 0x40002b60, 0x40002b64, 0x40002b68, 0x40002b6c, \ + 0x40002b70, 0x40002b74, 0x40002b78, 0x40002b7c, \ + 0x40002b80, 0x40002b84, 0x40002b88, 0x40002b8c, \ + 0x40002b90, 0x40002b94, 0x40002b98, 0x40002b9c, \ + 0x40002ba0, 0x40002ba4, 0x40002ba8, 0x40002bac, \ + 0x40002bb0, 0x40002bb4, 0x40002bb8, 0x40002bbc, \ + 0x40002bc0, 0x40002bc4, 0x40002bc8, 0x40002bcc, \ + 0x40002bd0, 0x40002bd4, 0x40002bd8, 0x40002bdc, \ + 0x40002be0, 0x40002be4, 0x40002be8, 0x40002bec, \ + 0x40002bf0, 0x40002bf4, 0x40002bf8, 0x40002bfc, \ + 0x40002c00, 0x40002c04, 0x40002c08, 0x40002c0c, \ + 0x40002c10, 0x40002c14, 0x40002c18, 0x40002c1c, \ + 0x40002c20, 0x40002c24, 0x40002c28, 0x40002c2c, \ + 0x40002c30, 0x40002c34, 0x40002c38, 0x40002c3c, \ + 0x40002c40, 0x40002c44, 0x40002c48, 0x40002c4c, \ + 0x40002c50, 0x40002c54, 0x40002c58, 0x40002c5c, \ + 0x40002c60, 0x40002c64, 0x40002c68, 0x40002c6c, \ + 0x40002c70, 0x40002c74, 0x40002c78, 0x40002c7c, \ + 0x40002c80, 0x40002c84, 0x40002c88, 0x40002c8c, \ + 0x40002c90, 0x40002c94, 0x40002c98, 0x40002c9c, \ + 0x40002ca0, 0x40002ca4, 0x40002ca8, 0x40002cac, \ + 0x40002cb0, 0x40002cb4, 0x40002cb8, 0x40002cbc, \ + 0x40002cc0, 0x40002cc4, 0x40002cc8, 0x40002ccc, \ + 0x40002cd0, 0x40002cd4, 0x40002cd8, 0x40002cdc, \ + 0x40002ce0, 0x40002ce4, 0x40002ce8, 0x40002cec, \ + 0x40002cf0, 0x40002cf4, 0x40002cf8, 0x40002cfc, \ + 0x40002d00, 0x40002d04, 0x40002d08, 0x40002d0c, \ + 0x40002d10, 0x40002d14, 0x40002d18, 0x40002d1c, \ + 0x40002d20, 0x40002d24, 0x40002d28, 0x40002d2c, \ + 0x40002d30, 0x40002d34, 0x40002d38, 0x40002d3c, \ + 0x40002d40, 0x40002d44, 0x40002d48, 0x40002d4c, \ + 0x40002d50, 0x40002d54, 0x40002d58, 0x40002d5c, \ + 0x40002d60, 0x40002d64, 0x40002d68, 0x40002d6c, \ + 0x40002d70, 0x40002d74, 0x40002d78, 0x40002d7c, \ + 0x40002d80, 0x40002d84, 0x40002d88, 0x40002d8c, \ + 0x40002d90, 0x40002d94, 0x40002d98, 0x40002d9c, \ + 0x40002da0, 0x40002da4, 0x40002da8, 0x40002dac, \ + 0x40002db0, 0x40002db4, 0x40002db8, 0x40002dbc, \ + 0x40002dc0, 0x40002dc4, 0x40002dc8, 0x40002dcc, \ + 0x40002dd0, 0x40002dd4, 0x40002dd8, 0x40002ddc, \ + 0x40002de0, 0x40002de4, 0x40002de8, 0x40002dec, \ + 0x40002df0, 0x40002df4, 0x40002df8, 0x40002dfc, \ + 0x40002e00, 0x40002e04, 0x40002e08, 0x40002e0c, \ + 0x40002e10, 0x40002e14, 0x40002e18, 0x40002e1c, \ + 0x40002e20, 0x40002e24, 0x40002e28, 0x40002e2c, \ + 0x40002e30, 0x40002e34, 0x40002e38, 0x40002e3c, \ + 0x40002e40, 0x40002e44, 0x40002e48, 0x40002e4c, \ + 0x40002e50, 0x40002e54, 0x40002e58, 0x40002e5c, \ + 0x40002e60, 0x40002e64, 0x40002e68, 0x40002e6c, \ + 0x40002e70, 0x40002e74, 0x40002e78, 0x40002e7c, \ + 0x40002e80, 0x40002e84, 0x40002e88, 0x40002e8c, \ + 0x40002e90, 0x40002e94, 0x40002e98, 0x40002e9c, \ + 0x40002ea0, 0x40002ea4, 0x40002ea8, 0x40002eac, \ + 0x40002eb0, 0x40002eb4, 0x40002eb8, 0x40002ebc, \ + 0x40002ec0, 0x40002ec4, 0x40002ec8, 0x40002ecc, \ + 0x40002ed0, 0x40002ed4, 0x40002ed8, 0x40002edc, \ + 0x40002ee0, 0x40002ee4, 0x40002ee8, 0x40002eec, \ + 0x40002ef0, 0x40002ef4, 0x40002ef8, 0x40002efc, \ + 0x40002f00, 0x40002f04, 0x40002f08, 0x40002f0c, \ + 0x40002f10, 0x40002f14, 0x40002f18, 0x40002f1c, \ + 0xc0002f20, 0x00000008, 0x00000002, 0x40002f24, \ + 0x40002f44, 0x40002f28, 0x40002f48, 0x40002f2c, \ + 0x40002f4c, 0x40002f30, 0x40002f50, 0x40002f34, \ + 0x40002f54, 0x40002f38, 0x40002f58, 0x40002f3c, \ + 0x40002f5c, 0x40002f40, 0x40002f60, 0xc0002f64, \ + 0x00000100, 0x00000001, 0x40002f68, 0x40002f6c, \ + 0x40002f70, 0x40002f74, 0x40002f78, 0x40002f7c, \ + 0x40002f80, 0x40002f84, 0x40002f88, 0x40002f8c, \ + 0x40002f90, 0x40002f94, 0x40002f98, 0x40002f9c, \ + 0x40002fa0, 0x40002fa4, 0x40002fa8, 0x40002fac, \ + 0x40002fb0, 0x40002fb4, 0x40002fb8, 0x40002fbc, \ + 0x40002fc0, 0x40002fc4, 0x40002fc8, 0x40002fcc, \ + 0x40002fd0, 0x40002fd4, 0x40002fd8, 0x40002fdc, \ + 0x40002fe0, 0x40002fe4, 0x40002fe8, 0x40002fec, \ + 0x40002ff0, 0x40002ff4, 0x40002ff8, 0x40002ffc, \ + 0x40003000, 0x40003004, 0x40003008, 0x4000300c, \ + 0x40003010, 0x40003014, 0x40003018, 0x4000301c, \ + 0x40003020, 0x40003024, 0x40003028, 0x4000302c, \ + 0x40003030, 0x40003034, 0x40003038, 0x4000303c, \ + 0x40003040, 0x40003044, 0x40003048, 0x4000304c, \ + 0x40003050, 0x40003054, 0x40003058, 0x4000305c, \ + 0x40003060, 0x40003064, 0x40003068, 0x4000306c, \ + 0x40003070, 0x40003074, 0x40003078, 0x4000307c, \ + 0x40003080, 0x40003084, 0x40003088, 0x4000308c, \ + 0x40003090, 0x40003094, 0x40003098, 0x4000309c, \ + 0x400030a0, 0x400030a4, 0x400030a8, 0x400030ac, \ + 0x400030b0, 0x400030b4, 0x400030b8, 0x400030bc, \ + 0x400030c0, 0x400030c4, 0x400030c8, 0x400030cc, \ + 0x400030d0, 0x400030d4, 0x400030d8, 0x400030dc, \ + 0x400030e0, 0x400030e4, 0x400030e8, 0x400030ec, \ + 0x400030f0, 0x400030f4, 0x400030f8, 0x400030fc, \ + 0x40003100, 0x40003104, 0x40003108, 0x4000310c, \ + 0x40003110, 0x40003114, 0x40003118, 0x4000311c, \ + 0x40003120, 0x40003124, 0x40003128, 0x4000312c, \ + 0x40003130, 0x40003134, 0x40003138, 0x4000313c, \ + 0x40003140, 0x40003144, 0x40003148, 0x4000314c, \ + 0x40003150, 0x40003154, 0x40003158, 0x4000315c, \ + 0x40003160, 0x40003164, 0x40003168, 0x4000316c, \ + 0x40003170, 0x40003174, 0x40003178, 0x4000317c, \ + 0x40003180, 0x40003184, 0x40003188, 0x4000318c, \ + 0x40003190, 0x40003194, 0x40003198, 0x4000319c, \ + 0x400031a0, 0x400031a4, 0x400031a8, 0x400031ac, \ + 0x400031b0, 0x400031b4, 0x400031b8, 0x400031bc, \ + 0x400031c0, 0x400031c4, 0x400031c8, 0x400031cc, \ + 0x400031d0, 0x400031d4, 0x400031d8, 0x400031dc, \ + 0x400031e0, 0x400031e4, 0x400031e8, 0x400031ec, \ + 0x400031f0, 0x400031f4, 0x400031f8, 0x400031fc, \ + 0x40003200, 0x40003204, 0x40003208, 0x4000320c, \ + 0x40003210, 0x40003214, 0x40003218, 0x4000321c, \ + 0x40003220, 0x40003224, 0x40003228, 0x4000322c, \ + 0x40003230, 0x40003234, 0x40003238, 0x4000323c, \ + 0x40003240, 0x40003244, 0x40003248, 0x4000324c, \ + 0x40003250, 0x40003254, 0x40003258, 0x4000325c, \ + 0x40003260, 0x40003264, 0x40003268, 0x4000326c, \ + 0x40003270, 0x40003274, 0x40003278, 0x4000327c, \ + 0x40003280, 0x40003284, 0x40003288, 0x4000328c, \ + 0x40003290, 0x40003294, 0x40003298, 0x4000329c, \ + 0x400032a0, 0x400032a4, 0x400032a8, 0x400032ac, \ + 0x400032b0, 0x400032b4, 0x400032b8, 0x400032bc, \ + 0x400032c0, 0x400032c4, 0x400032c8, 0x400032cc, \ + 0x400032d0, 0x400032d4, 0x400032d8, 0x400032dc, \ + 0x400032e0, 0x400032e4, 0x400032e8, 0x400032ec, \ + 0x400032f0, 0x400032f4, 0x400032f8, 0x400032fc, \ + 0x40003300, 0x40003304, 0x40003308, 0x4000330c, \ + 0x40003310, 0x40003314, 0x40003318, 0x4000331c, \ + 0x40003320, 0x40003324, 0x40003328, 0x4000332c, \ + 0x40003330, 0x40003334, 0x40003338, 0x4000333c, \ + 0x40003340, 0x40003344, 0x40003348, 0x4000334c, \ + 0x40003350, 0x40003354, 0x40003358, 0x4000335c, \ + 0x40003360, 0x40003364, 0xc0003368, 0x00000008, \ + 0x00000002, 0x4000336c, 0x4000338c, 0x40003370, \ + 0x40003390, 0x40003374, 0x40003394, 0x40003378, \ + 0x40003398, 0x4000337c, 0x4000339c, 0x40003380, \ + 0x400033a0, 0x40003384, 0x400033a4, 0x40003388, \ + 0x400033a8, 0xc00033ac, 0x00000100, 0x00000001, \ + 0x400033b0, 0x400033b4, 0x400033b8, 0x400033bc, \ + 0x400033c0, 0x400033c4, 0x400033c8, 0x400033cc, \ + 0x400033d0, 0x400033d4, 0x400033d8, 0x400033dc, \ + 0x400033e0, 0x400033e4, 0x400033e8, 0x400033ec, \ + 0x400033f0, 0x400033f4, 0x400033f8, 0x400033fc, \ + 0x40003400, 0x40003404, 0x40003408, 0x4000340c, \ + 0x40003410, 0x40003414, 0x40003418, 0x4000341c, \ + 0x40003420, 0x40003424, 0x40003428, 0x4000342c, \ + 0x40003430, 0x40003434, 0x40003438, 0x4000343c, \ + 0x40003440, 0x40003444, 0x40003448, 0x4000344c, \ + 0x40003450, 0x40003454, 0x40003458, 0x4000345c, \ + 0x40003460, 0x40003464, 0x40003468, 0x4000346c, \ + 0x40003470, 0x40003474, 0x40003478, 0x4000347c, \ + 0x40003480, 0x40003484, 0x40003488, 0x4000348c, \ + 0x40003490, 0x40003494, 0x40003498, 0x4000349c, \ + 0x400034a0, 0x400034a4, 0x400034a8, 0x400034ac, \ + 0x400034b0, 0x400034b4, 0x400034b8, 0x400034bc, \ + 0x400034c0, 0x400034c4, 0x400034c8, 0x400034cc, \ + 0x400034d0, 0x400034d4, 0x400034d8, 0x400034dc, \ + 0x400034e0, 0x400034e4, 0x400034e8, 0x400034ec, \ + 0x400034f0, 0x400034f4, 0x400034f8, 0x400034fc, \ + 0x40003500, 0x40003504, 0x40003508, 0x4000350c, \ + 0x40003510, 0x40003514, 0x40003518, 0x4000351c, \ + 0x40003520, 0x40003524, 0x40003528, 0x4000352c, \ + 0x40003530, 0x40003534, 0x40003538, 0x4000353c, \ + 0x40003540, 0x40003544, 0x40003548, 0x4000354c, \ + 0x40003550, 0x40003554, 0x40003558, 0x4000355c, \ + 0x40003560, 0x40003564, 0x40003568, 0x4000356c, \ + 0x40003570, 0x40003574, 0x40003578, 0x4000357c, \ + 0x40003580, 0x40003584, 0x40003588, 0x4000358c, \ + 0x40003590, 0x40003594, 0x40003598, 0x4000359c, \ + 0x400035a0, 0x400035a4, 0x400035a8, 0x400035ac, \ + 0x400035b0, 0x400035b4, 0x400035b8, 0x400035bc, \ + 0x400035c0, 0x400035c4, 0x400035c8, 0x400035cc, \ + 0x400035d0, 0x400035d4, 0x400035d8, 0x400035dc, \ + 0x400035e0, 0x400035e4, 0x400035e8, 0x400035ec, \ + 0x400035f0, 0x400035f4, 0x400035f8, 0x400035fc, \ + 0x40003600, 0x40003604, 0x40003608, 0x4000360c, \ + 0x40003610, 0x40003614, 0x40003618, 0x4000361c, \ + 0x40003620, 0x40003624, 0x40003628, 0x4000362c, \ + 0x40003630, 0x40003634, 0x40003638, 0x4000363c, \ + 0x40003640, 0x40003644, 0x40003648, 0x4000364c, \ + 0x40003650, 0x40003654, 0x40003658, 0x4000365c, \ + 0x40003660, 0x40003664, 0x40003668, 0x4000366c, \ + 0x40003670, 0x40003674, 0x40003678, 0x4000367c, \ + 0x40003680, 0x40003684, 0x40003688, 0x4000368c, \ + 0x40003690, 0x40003694, 0x40003698, 0x4000369c, \ + 0x400036a0, 0x400036a4, 0x400036a8, 0x400036ac, \ + 0x400036b0, 0x400036b4, 0x400036b8, 0x400036bc, \ + 0x400036c0, 0x400036c4, 0x400036c8, 0x400036cc, \ + 0x400036d0, 0x400036d4, 0x400036d8, 0x400036dc, \ + 0x400036e0, 0x400036e4, 0x400036e8, 0x400036ec, \ + 0x400036f0, 0x400036f4, 0x400036f8, 0x400036fc, \ + 0x40003700, 0x40003704, 0x40003708, 0x4000370c, \ + 0x40003710, 0x40003714, 0x40003718, 0x4000371c, \ + 0x40003720, 0x40003724, 0x40003728, 0x4000372c, \ + 0x40003730, 0x40003734, 0x40003738, 0x4000373c, \ + 0x40003740, 0x40003744, 0x40003748, 0x4000374c, \ + 0x40003750, 0x40003754, 0x40003758, 0x4000375c, \ + 0x40003760, 0x40003764, 0x40003768, 0x4000376c, \ + 0x40003770, 0x40003774, 0x40003778, 0x4000377c, \ + 0x40003780, 0x40003784, 0x40003788, 0x4000378c, \ + 0x40003790, 0x40003794, 0x40003798, 0x4000379c, \ + 0x400037a0, 0x400037a4, 0x400037a8, 0x400037ac, \ + 0xc00037b0, 0x00000008, 0x00000002, 0x400037b4, \ + 0x400037d4, 0x400037b8, 0x400037d8, 0x400037bc, \ + 0x400037dc, 0x400037c0, 0x400037e0, 0x400037c4, \ + 0x400037e4, 0x400037c8, 0x400037e8, 0x400037cc, \ + 0x400037ec, 0x400037d0, 0x400037f0, 0xc00037f4, \ + 0x00000100, 0x00000001, 0x400037f8, 0x400037fc, \ + 0x40003800, 0x40003804, 0x40003808, 0x4000380c, \ + 0x40003810, 0x40003814, 0x40003818, 0x4000381c, \ + 0x40003820, 0x40003824, 0x40003828, 0x4000382c, \ + 0x40003830, 0x40003834, 0x40003838, 0x4000383c, \ + 0x40003840, 0x40003844, 0x40003848, 0x4000384c, \ + 0x40003850, 0x40003854, 0x40003858, 0x4000385c, \ + 0x40003860, 0x40003864, 0x40003868, 0x4000386c, \ + 0x40003870, 0x40003874, 0x40003878, 0x4000387c, \ + 0x40003880, 0x40003884, 0x40003888, 0x4000388c, \ + 0x40003890, 0x40003894, 0x40003898, 0x4000389c, \ + 0x400038a0, 0x400038a4, 0x400038a8, 0x400038ac, \ + 0x400038b0, 0x400038b4, 0x400038b8, 0x400038bc, \ + 0x400038c0, 0x400038c4, 0x400038c8, 0x400038cc, \ + 0x400038d0, 0x400038d4, 0x400038d8, 0x400038dc, \ + 0x400038e0, 0x400038e4, 0x400038e8, 0x400038ec, \ + 0x400038f0, 0x400038f4, 0x400038f8, 0x400038fc, \ + 0x40003900, 0x40003904, 0x40003908, 0x4000390c, \ + 0x40003910, 0x40003914, 0x40003918, 0x4000391c, \ + 0x40003920, 0x40003924, 0x40003928, 0x4000392c, \ + 0x40003930, 0x40003934, 0x40003938, 0x4000393c, \ + 0x40003940, 0x40003944, 0x40003948, 0x4000394c, \ + 0x40003950, 0x40003954, 0x40003958, 0x4000395c, \ + 0x40003960, 0x40003964, 0x40003968, 0x4000396c, \ + 0x40003970, 0x40003974, 0x40003978, 0x4000397c, \ + 0x40003980, 0x40003984, 0x40003988, 0x4000398c, \ + 0x40003990, 0x40003994, 0x40003998, 0x4000399c, \ + 0x400039a0, 0x400039a4, 0x400039a8, 0x400039ac, \ + 0x400039b0, 0x400039b4, 0x400039b8, 0x400039bc, \ + 0x400039c0, 0x400039c4, 0x400039c8, 0x400039cc, \ + 0x400039d0, 0x400039d4, 0x400039d8, 0x400039dc, \ + 0x400039e0, 0x400039e4, 0x400039e8, 0x400039ec, \ + 0x400039f0, 0x400039f4, 0x400039f8, 0x400039fc, \ + 0x40003a00, 0x40003a04, 0x40003a08, 0x40003a0c, \ + 0x40003a10, 0x40003a14, 0x40003a18, 0x40003a1c, \ + 0x40003a20, 0x40003a24, 0x40003a28, 0x40003a2c, \ + 0x40003a30, 0x40003a34, 0x40003a38, 0x40003a3c, \ + 0x40003a40, 0x40003a44, 0x40003a48, 0x40003a4c, \ + 0x40003a50, 0x40003a54, 0x40003a58, 0x40003a5c, \ + 0x40003a60, 0x40003a64, 0x40003a68, 0x40003a6c, \ + 0x40003a70, 0x40003a74, 0x40003a78, 0x40003a7c, \ + 0x40003a80, 0x40003a84, 0x40003a88, 0x40003a8c, \ + 0x40003a90, 0x40003a94, 0x40003a98, 0x40003a9c, \ + 0x40003aa0, 0x40003aa4, 0x40003aa8, 0x40003aac, \ + 0x40003ab0, 0x40003ab4, 0x40003ab8, 0x40003abc, \ + 0x40003ac0, 0x40003ac4, 0x40003ac8, 0x40003acc, \ + 0x40003ad0, 0x40003ad4, 0x40003ad8, 0x40003adc, \ + 0x40003ae0, 0x40003ae4, 0x40003ae8, 0x40003aec, \ + 0x40003af0, 0x40003af4, 0x40003af8, 0x40003afc, \ + 0x40003b00, 0x40003b04, 0x40003b08, 0x40003b0c, \ + 0x40003b10, 0x40003b14, 0x40003b18, 0x40003b1c, \ + 0x40003b20, 0x40003b24, 0x40003b28, 0x40003b2c, \ + 0x40003b30, 0x40003b34, 0x40003b38, 0x40003b3c, \ + 0x40003b40, 0x40003b44, 0x40003b48, 0x40003b4c, \ + 0x40003b50, 0x40003b54, 0x40003b58, 0x40003b5c, \ + 0x40003b60, 0x40003b64, 0x40003b68, 0x40003b6c, \ + 0x40003b70, 0x40003b74, 0x40003b78, 0x40003b7c, \ + 0x40003b80, 0x40003b84, 0x40003b88, 0x40003b8c, \ + 0x40003b90, 0x40003b94, 0x40003b98, 0x40003b9c, \ + 0x40003ba0, 0x40003ba4, 0x40003ba8, 0x40003bac, \ + 0x40003bb0, 0x40003bb4, 0x40003bb8, 0x40003bbc, \ + 0x40003bc0, 0x40003bc4, 0x40003bc8, 0x40003bcc, \ + 0x40003bd0, 0x40003bd4, 0x40003bd8, 0x40003bdc, \ + 0x40003be0, 0x40003be4, 0x40003be8, 0x40003bec, \ + 0x40003bf0, 0x40003bf4, \ + } \ +}; + +#endif/*__GUARD_H101_LOS_EXT_H101_LOS_DEZ19_H__*/ + +/*******************************************************/ diff --git a/r3bsource/ext_h101_samp.h b/r3bsource/ext_h101_samp.h new file mode 100644 index 000000000..2278749b4 --- /dev/null +++ b/r3bsource/ext_h101_samp.h @@ -0,0 +1,368 @@ +/******************************************************** + * + * Structure for ext_data_fetch_event() filling. + * + * Do not edit - automatically generated. + */ + +#ifndef __GUARD_H101_SAMP_EXT_H101_SAMP_H__ +#define __GUARD_H101_SAMP_EXT_H101_SAMP_H__ + +#ifndef __CINT__ +# include +#else +/* For CINT (old version trouble with stdint.h): */ +# ifndef uint32_t +typedef unsigned int uint32_t; +typedef int int32_t; +# endif +#endif +#ifndef EXT_STRUCT_CTRL +# define EXT_STRUCT_CTRL(x) +#endif + +/******************************************************** + * + * Plain structure (layout as ntuple/root file): + */ + +typedef struct EXT_STR_h101_SAMP_t +{ + /* RAW */ + uint32_t SAMP /* [0,512] */; + uint32_t SAMPI[512 EXT_STRUCT_CTRL(SAMP)] /* [1,512] */; + uint32_t SAMPv[512 EXT_STRUCT_CTRL(SAMP)] /* [-1,-1] */; + +} EXT_STR_h101_SAMP; + +/******************************************************** + * + * Structure with multiple levels of arrays (partially) + * recovered (recommended): + */ + +typedef struct EXT_STR_h101_SAMP_onion_t +{ + /* RAW */ + uint32_t SAMP; + uint32_t SAMPI[512 /* SAMP */]; + uint32_t SAMPv[512 /* SAMP */]; + +} EXT_STR_h101_SAMP_onion; + +/*******************************************************/ + +#define EXT_STR_h101_SAMP_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* RAW */ \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SAMP, UINT32,\ + "SAMP",512); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SAMPI, UINT32,\ + "SAMPI", "SAMP"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SAMPv, UINT32,\ + "SAMPv", "SAMP"); \ + \ +} while (0); + +/******************************************************** + * + * For internal use by the network data reader: + * (version checks, etc) + */ + +typedef struct EXT_STR_h101_SAMP_layout_t +{ + uint32_t _magic; + uint32_t _size_info; + uint32_t _size_struct; + uint32_t _size_struct_onion; + uint32_t _pack_list_items; + + uint32_t _num_items; + struct { + uint32_t _offset; + uint32_t _size; + uint32_t _xor; + const char *_name; + } _items[1]; + uint32_t _pack_list[1029]; +} EXT_STR_h101_SAMP_layout; + +#define EXT_STR_h101_SAMP_LAYOUT_INIT { \ + 0x57e65c96, \ + sizeof(EXT_STR_h101_SAMP_layout), \ + sizeof(EXT_STR_h101_SAMP), \ + sizeof(EXT_STR_h101_SAMP_onion), \ + 1029, \ + 1, \ + { \ + { 0, sizeof(EXT_STR_h101_SAMP), 0x597a031e, "h101_SAMP" }, \ + }, \ + { \ + 0x40000000, 0x40000004, 0xc0000008, 0x00000200, \ + 0x00000002, 0x4000000c, 0x4000080c, 0x40000010, \ + 0x40000810, 0x40000014, 0x40000814, 0x40000018, \ + 0x40000818, 0x4000001c, 0x4000081c, 0x40000020, \ + 0x40000820, 0x40000024, 0x40000824, 0x40000028, \ + 0x40000828, 0x4000002c, 0x4000082c, 0x40000030, \ + 0x40000830, 0x40000034, 0x40000834, 0x40000038, \ + 0x40000838, 0x4000003c, 0x4000083c, 0x40000040, \ + 0x40000840, 0x40000044, 0x40000844, 0x40000048, \ + 0x40000848, 0x4000004c, 0x4000084c, 0x40000050, \ + 0x40000850, 0x40000054, 0x40000854, 0x40000058, \ + 0x40000858, 0x4000005c, 0x4000085c, 0x40000060, \ + 0x40000860, 0x40000064, 0x40000864, 0x40000068, \ + 0x40000868, 0x4000006c, 0x4000086c, 0x40000070, \ + 0x40000870, 0x40000074, 0x40000874, 0x40000078, \ + 0x40000878, 0x4000007c, 0x4000087c, 0x40000080, \ + 0x40000880, 0x40000084, 0x40000884, 0x40000088, \ + 0x40000888, 0x4000008c, 0x4000088c, 0x40000090, \ + 0x40000890, 0x40000094, 0x40000894, 0x40000098, \ + 0x40000898, 0x4000009c, 0x4000089c, 0x400000a0, \ + 0x400008a0, 0x400000a4, 0x400008a4, 0x400000a8, \ + 0x400008a8, 0x400000ac, 0x400008ac, 0x400000b0, \ + 0x400008b0, 0x400000b4, 0x400008b4, 0x400000b8, \ + 0x400008b8, 0x400000bc, 0x400008bc, 0x400000c0, \ + 0x400008c0, 0x400000c4, 0x400008c4, 0x400000c8, \ + 0x400008c8, 0x400000cc, 0x400008cc, 0x400000d0, \ + 0x400008d0, 0x400000d4, 0x400008d4, 0x400000d8, \ + 0x400008d8, 0x400000dc, 0x400008dc, 0x400000e0, \ + 0x400008e0, 0x400000e4, 0x400008e4, 0x400000e8, \ + 0x400008e8, 0x400000ec, 0x400008ec, 0x400000f0, \ + 0x400008f0, 0x400000f4, 0x400008f4, 0x400000f8, \ + 0x400008f8, 0x400000fc, 0x400008fc, 0x40000100, \ + 0x40000900, 0x40000104, 0x40000904, 0x40000108, \ + 0x40000908, 0x4000010c, 0x4000090c, 0x40000110, \ + 0x40000910, 0x40000114, 0x40000914, 0x40000118, \ + 0x40000918, 0x4000011c, 0x4000091c, 0x40000120, \ + 0x40000920, 0x40000124, 0x40000924, 0x40000128, \ + 0x40000928, 0x4000012c, 0x4000092c, 0x40000130, \ + 0x40000930, 0x40000134, 0x40000934, 0x40000138, \ + 0x40000938, 0x4000013c, 0x4000093c, 0x40000140, \ + 0x40000940, 0x40000144, 0x40000944, 0x40000148, \ + 0x40000948, 0x4000014c, 0x4000094c, 0x40000150, \ + 0x40000950, 0x40000154, 0x40000954, 0x40000158, \ + 0x40000958, 0x4000015c, 0x4000095c, 0x40000160, \ + 0x40000960, 0x40000164, 0x40000964, 0x40000168, \ + 0x40000968, 0x4000016c, 0x4000096c, 0x40000170, \ + 0x40000970, 0x40000174, 0x40000974, 0x40000178, \ + 0x40000978, 0x4000017c, 0x4000097c, 0x40000180, \ + 0x40000980, 0x40000184, 0x40000984, 0x40000188, \ + 0x40000988, 0x4000018c, 0x4000098c, 0x40000190, \ + 0x40000990, 0x40000194, 0x40000994, 0x40000198, \ + 0x40000998, 0x4000019c, 0x4000099c, 0x400001a0, \ + 0x400009a0, 0x400001a4, 0x400009a4, 0x400001a8, \ + 0x400009a8, 0x400001ac, 0x400009ac, 0x400001b0, \ + 0x400009b0, 0x400001b4, 0x400009b4, 0x400001b8, \ + 0x400009b8, 0x400001bc, 0x400009bc, 0x400001c0, \ + 0x400009c0, 0x400001c4, 0x400009c4, 0x400001c8, \ + 0x400009c8, 0x400001cc, 0x400009cc, 0x400001d0, \ + 0x400009d0, 0x400001d4, 0x400009d4, 0x400001d8, \ + 0x400009d8, 0x400001dc, 0x400009dc, 0x400001e0, \ + 0x400009e0, 0x400001e4, 0x400009e4, 0x400001e8, \ + 0x400009e8, 0x400001ec, 0x400009ec, 0x400001f0, \ + 0x400009f0, 0x400001f4, 0x400009f4, 0x400001f8, \ + 0x400009f8, 0x400001fc, 0x400009fc, 0x40000200, \ + 0x40000a00, 0x40000204, 0x40000a04, 0x40000208, \ + 0x40000a08, 0x4000020c, 0x40000a0c, 0x40000210, \ + 0x40000a10, 0x40000214, 0x40000a14, 0x40000218, \ + 0x40000a18, 0x4000021c, 0x40000a1c, 0x40000220, \ + 0x40000a20, 0x40000224, 0x40000a24, 0x40000228, \ + 0x40000a28, 0x4000022c, 0x40000a2c, 0x40000230, \ + 0x40000a30, 0x40000234, 0x40000a34, 0x40000238, \ + 0x40000a38, 0x4000023c, 0x40000a3c, 0x40000240, \ + 0x40000a40, 0x40000244, 0x40000a44, 0x40000248, \ + 0x40000a48, 0x4000024c, 0x40000a4c, 0x40000250, \ + 0x40000a50, 0x40000254, 0x40000a54, 0x40000258, \ + 0x40000a58, 0x4000025c, 0x40000a5c, 0x40000260, \ + 0x40000a60, 0x40000264, 0x40000a64, 0x40000268, \ + 0x40000a68, 0x4000026c, 0x40000a6c, 0x40000270, \ + 0x40000a70, 0x40000274, 0x40000a74, 0x40000278, \ + 0x40000a78, 0x4000027c, 0x40000a7c, 0x40000280, \ + 0x40000a80, 0x40000284, 0x40000a84, 0x40000288, \ + 0x40000a88, 0x4000028c, 0x40000a8c, 0x40000290, \ + 0x40000a90, 0x40000294, 0x40000a94, 0x40000298, \ + 0x40000a98, 0x4000029c, 0x40000a9c, 0x400002a0, \ + 0x40000aa0, 0x400002a4, 0x40000aa4, 0x400002a8, \ + 0x40000aa8, 0x400002ac, 0x40000aac, 0x400002b0, \ + 0x40000ab0, 0x400002b4, 0x40000ab4, 0x400002b8, \ + 0x40000ab8, 0x400002bc, 0x40000abc, 0x400002c0, \ + 0x40000ac0, 0x400002c4, 0x40000ac4, 0x400002c8, \ + 0x40000ac8, 0x400002cc, 0x40000acc, 0x400002d0, \ + 0x40000ad0, 0x400002d4, 0x40000ad4, 0x400002d8, \ + 0x40000ad8, 0x400002dc, 0x40000adc, 0x400002e0, \ + 0x40000ae0, 0x400002e4, 0x40000ae4, 0x400002e8, \ + 0x40000ae8, 0x400002ec, 0x40000aec, 0x400002f0, \ + 0x40000af0, 0x400002f4, 0x40000af4, 0x400002f8, \ + 0x40000af8, 0x400002fc, 0x40000afc, 0x40000300, \ + 0x40000b00, 0x40000304, 0x40000b04, 0x40000308, \ + 0x40000b08, 0x4000030c, 0x40000b0c, 0x40000310, \ + 0x40000b10, 0x40000314, 0x40000b14, 0x40000318, \ + 0x40000b18, 0x4000031c, 0x40000b1c, 0x40000320, \ + 0x40000b20, 0x40000324, 0x40000b24, 0x40000328, \ + 0x40000b28, 0x4000032c, 0x40000b2c, 0x40000330, \ + 0x40000b30, 0x40000334, 0x40000b34, 0x40000338, \ + 0x40000b38, 0x4000033c, 0x40000b3c, 0x40000340, \ + 0x40000b40, 0x40000344, 0x40000b44, 0x40000348, \ + 0x40000b48, 0x4000034c, 0x40000b4c, 0x40000350, \ + 0x40000b50, 0x40000354, 0x40000b54, 0x40000358, \ + 0x40000b58, 0x4000035c, 0x40000b5c, 0x40000360, \ + 0x40000b60, 0x40000364, 0x40000b64, 0x40000368, \ + 0x40000b68, 0x4000036c, 0x40000b6c, 0x40000370, \ + 0x40000b70, 0x40000374, 0x40000b74, 0x40000378, \ + 0x40000b78, 0x4000037c, 0x40000b7c, 0x40000380, \ + 0x40000b80, 0x40000384, 0x40000b84, 0x40000388, \ + 0x40000b88, 0x4000038c, 0x40000b8c, 0x40000390, \ + 0x40000b90, 0x40000394, 0x40000b94, 0x40000398, \ + 0x40000b98, 0x4000039c, 0x40000b9c, 0x400003a0, \ + 0x40000ba0, 0x400003a4, 0x40000ba4, 0x400003a8, \ + 0x40000ba8, 0x400003ac, 0x40000bac, 0x400003b0, \ + 0x40000bb0, 0x400003b4, 0x40000bb4, 0x400003b8, \ + 0x40000bb8, 0x400003bc, 0x40000bbc, 0x400003c0, \ + 0x40000bc0, 0x400003c4, 0x40000bc4, 0x400003c8, \ + 0x40000bc8, 0x400003cc, 0x40000bcc, 0x400003d0, \ + 0x40000bd0, 0x400003d4, 0x40000bd4, 0x400003d8, \ + 0x40000bd8, 0x400003dc, 0x40000bdc, 0x400003e0, \ + 0x40000be0, 0x400003e4, 0x40000be4, 0x400003e8, \ + 0x40000be8, 0x400003ec, 0x40000bec, 0x400003f0, \ + 0x40000bf0, 0x400003f4, 0x40000bf4, 0x400003f8, \ + 0x40000bf8, 0x400003fc, 0x40000bfc, 0x40000400, \ + 0x40000c00, 0x40000404, 0x40000c04, 0x40000408, \ + 0x40000c08, 0x4000040c, 0x40000c0c, 0x40000410, \ + 0x40000c10, 0x40000414, 0x40000c14, 0x40000418, \ + 0x40000c18, 0x4000041c, 0x40000c1c, 0x40000420, \ + 0x40000c20, 0x40000424, 0x40000c24, 0x40000428, \ + 0x40000c28, 0x4000042c, 0x40000c2c, 0x40000430, \ + 0x40000c30, 0x40000434, 0x40000c34, 0x40000438, \ + 0x40000c38, 0x4000043c, 0x40000c3c, 0x40000440, \ + 0x40000c40, 0x40000444, 0x40000c44, 0x40000448, \ + 0x40000c48, 0x4000044c, 0x40000c4c, 0x40000450, \ + 0x40000c50, 0x40000454, 0x40000c54, 0x40000458, \ + 0x40000c58, 0x4000045c, 0x40000c5c, 0x40000460, \ + 0x40000c60, 0x40000464, 0x40000c64, 0x40000468, \ + 0x40000c68, 0x4000046c, 0x40000c6c, 0x40000470, \ + 0x40000c70, 0x40000474, 0x40000c74, 0x40000478, \ + 0x40000c78, 0x4000047c, 0x40000c7c, 0x40000480, \ + 0x40000c80, 0x40000484, 0x40000c84, 0x40000488, \ + 0x40000c88, 0x4000048c, 0x40000c8c, 0x40000490, \ + 0x40000c90, 0x40000494, 0x40000c94, 0x40000498, \ + 0x40000c98, 0x4000049c, 0x40000c9c, 0x400004a0, \ + 0x40000ca0, 0x400004a4, 0x40000ca4, 0x400004a8, \ + 0x40000ca8, 0x400004ac, 0x40000cac, 0x400004b0, \ + 0x40000cb0, 0x400004b4, 0x40000cb4, 0x400004b8, \ + 0x40000cb8, 0x400004bc, 0x40000cbc, 0x400004c0, \ + 0x40000cc0, 0x400004c4, 0x40000cc4, 0x400004c8, \ + 0x40000cc8, 0x400004cc, 0x40000ccc, 0x400004d0, \ + 0x40000cd0, 0x400004d4, 0x40000cd4, 0x400004d8, \ + 0x40000cd8, 0x400004dc, 0x40000cdc, 0x400004e0, \ + 0x40000ce0, 0x400004e4, 0x40000ce4, 0x400004e8, \ + 0x40000ce8, 0x400004ec, 0x40000cec, 0x400004f0, \ + 0x40000cf0, 0x400004f4, 0x40000cf4, 0x400004f8, \ + 0x40000cf8, 0x400004fc, 0x40000cfc, 0x40000500, \ + 0x40000d00, 0x40000504, 0x40000d04, 0x40000508, \ + 0x40000d08, 0x4000050c, 0x40000d0c, 0x40000510, \ + 0x40000d10, 0x40000514, 0x40000d14, 0x40000518, \ + 0x40000d18, 0x4000051c, 0x40000d1c, 0x40000520, \ + 0x40000d20, 0x40000524, 0x40000d24, 0x40000528, \ + 0x40000d28, 0x4000052c, 0x40000d2c, 0x40000530, \ + 0x40000d30, 0x40000534, 0x40000d34, 0x40000538, \ + 0x40000d38, 0x4000053c, 0x40000d3c, 0x40000540, \ + 0x40000d40, 0x40000544, 0x40000d44, 0x40000548, \ + 0x40000d48, 0x4000054c, 0x40000d4c, 0x40000550, \ + 0x40000d50, 0x40000554, 0x40000d54, 0x40000558, \ + 0x40000d58, 0x4000055c, 0x40000d5c, 0x40000560, \ + 0x40000d60, 0x40000564, 0x40000d64, 0x40000568, \ + 0x40000d68, 0x4000056c, 0x40000d6c, 0x40000570, \ + 0x40000d70, 0x40000574, 0x40000d74, 0x40000578, \ + 0x40000d78, 0x4000057c, 0x40000d7c, 0x40000580, \ + 0x40000d80, 0x40000584, 0x40000d84, 0x40000588, \ + 0x40000d88, 0x4000058c, 0x40000d8c, 0x40000590, \ + 0x40000d90, 0x40000594, 0x40000d94, 0x40000598, \ + 0x40000d98, 0x4000059c, 0x40000d9c, 0x400005a0, \ + 0x40000da0, 0x400005a4, 0x40000da4, 0x400005a8, \ + 0x40000da8, 0x400005ac, 0x40000dac, 0x400005b0, \ + 0x40000db0, 0x400005b4, 0x40000db4, 0x400005b8, \ + 0x40000db8, 0x400005bc, 0x40000dbc, 0x400005c0, \ + 0x40000dc0, 0x400005c4, 0x40000dc4, 0x400005c8, \ + 0x40000dc8, 0x400005cc, 0x40000dcc, 0x400005d0, \ + 0x40000dd0, 0x400005d4, 0x40000dd4, 0x400005d8, \ + 0x40000dd8, 0x400005dc, 0x40000ddc, 0x400005e0, \ + 0x40000de0, 0x400005e4, 0x40000de4, 0x400005e8, \ + 0x40000de8, 0x400005ec, 0x40000dec, 0x400005f0, \ + 0x40000df0, 0x400005f4, 0x40000df4, 0x400005f8, \ + 0x40000df8, 0x400005fc, 0x40000dfc, 0x40000600, \ + 0x40000e00, 0x40000604, 0x40000e04, 0x40000608, \ + 0x40000e08, 0x4000060c, 0x40000e0c, 0x40000610, \ + 0x40000e10, 0x40000614, 0x40000e14, 0x40000618, \ + 0x40000e18, 0x4000061c, 0x40000e1c, 0x40000620, \ + 0x40000e20, 0x40000624, 0x40000e24, 0x40000628, \ + 0x40000e28, 0x4000062c, 0x40000e2c, 0x40000630, \ + 0x40000e30, 0x40000634, 0x40000e34, 0x40000638, \ + 0x40000e38, 0x4000063c, 0x40000e3c, 0x40000640, \ + 0x40000e40, 0x40000644, 0x40000e44, 0x40000648, \ + 0x40000e48, 0x4000064c, 0x40000e4c, 0x40000650, \ + 0x40000e50, 0x40000654, 0x40000e54, 0x40000658, \ + 0x40000e58, 0x4000065c, 0x40000e5c, 0x40000660, \ + 0x40000e60, 0x40000664, 0x40000e64, 0x40000668, \ + 0x40000e68, 0x4000066c, 0x40000e6c, 0x40000670, \ + 0x40000e70, 0x40000674, 0x40000e74, 0x40000678, \ + 0x40000e78, 0x4000067c, 0x40000e7c, 0x40000680, \ + 0x40000e80, 0x40000684, 0x40000e84, 0x40000688, \ + 0x40000e88, 0x4000068c, 0x40000e8c, 0x40000690, \ + 0x40000e90, 0x40000694, 0x40000e94, 0x40000698, \ + 0x40000e98, 0x4000069c, 0x40000e9c, 0x400006a0, \ + 0x40000ea0, 0x400006a4, 0x40000ea4, 0x400006a8, \ + 0x40000ea8, 0x400006ac, 0x40000eac, 0x400006b0, \ + 0x40000eb0, 0x400006b4, 0x40000eb4, 0x400006b8, \ + 0x40000eb8, 0x400006bc, 0x40000ebc, 0x400006c0, \ + 0x40000ec0, 0x400006c4, 0x40000ec4, 0x400006c8, \ + 0x40000ec8, 0x400006cc, 0x40000ecc, 0x400006d0, \ + 0x40000ed0, 0x400006d4, 0x40000ed4, 0x400006d8, \ + 0x40000ed8, 0x400006dc, 0x40000edc, 0x400006e0, \ + 0x40000ee0, 0x400006e4, 0x40000ee4, 0x400006e8, \ + 0x40000ee8, 0x400006ec, 0x40000eec, 0x400006f0, \ + 0x40000ef0, 0x400006f4, 0x40000ef4, 0x400006f8, \ + 0x40000ef8, 0x400006fc, 0x40000efc, 0x40000700, \ + 0x40000f00, 0x40000704, 0x40000f04, 0x40000708, \ + 0x40000f08, 0x4000070c, 0x40000f0c, 0x40000710, \ + 0x40000f10, 0x40000714, 0x40000f14, 0x40000718, \ + 0x40000f18, 0x4000071c, 0x40000f1c, 0x40000720, \ + 0x40000f20, 0x40000724, 0x40000f24, 0x40000728, \ + 0x40000f28, 0x4000072c, 0x40000f2c, 0x40000730, \ + 0x40000f30, 0x40000734, 0x40000f34, 0x40000738, \ + 0x40000f38, 0x4000073c, 0x40000f3c, 0x40000740, \ + 0x40000f40, 0x40000744, 0x40000f44, 0x40000748, \ + 0x40000f48, 0x4000074c, 0x40000f4c, 0x40000750, \ + 0x40000f50, 0x40000754, 0x40000f54, 0x40000758, \ + 0x40000f58, 0x4000075c, 0x40000f5c, 0x40000760, \ + 0x40000f60, 0x40000764, 0x40000f64, 0x40000768, \ + 0x40000f68, 0x4000076c, 0x40000f6c, 0x40000770, \ + 0x40000f70, 0x40000774, 0x40000f74, 0x40000778, \ + 0x40000f78, 0x4000077c, 0x40000f7c, 0x40000780, \ + 0x40000f80, 0x40000784, 0x40000f84, 0x40000788, \ + 0x40000f88, 0x4000078c, 0x40000f8c, 0x40000790, \ + 0x40000f90, 0x40000794, 0x40000f94, 0x40000798, \ + 0x40000f98, 0x4000079c, 0x40000f9c, 0x400007a0, \ + 0x40000fa0, 0x400007a4, 0x40000fa4, 0x400007a8, \ + 0x40000fa8, 0x400007ac, 0x40000fac, 0x400007b0, \ + 0x40000fb0, 0x400007b4, 0x40000fb4, 0x400007b8, \ + 0x40000fb8, 0x400007bc, 0x40000fbc, 0x400007c0, \ + 0x40000fc0, 0x400007c4, 0x40000fc4, 0x400007c8, \ + 0x40000fc8, 0x400007cc, 0x40000fcc, 0x400007d0, \ + 0x40000fd0, 0x400007d4, 0x40000fd4, 0x400007d8, \ + 0x40000fd8, 0x400007dc, 0x40000fdc, 0x400007e0, \ + 0x40000fe0, 0x400007e4, 0x40000fe4, 0x400007e8, \ + 0x40000fe8, 0x400007ec, 0x40000fec, 0x400007f0, \ + 0x40000ff0, 0x400007f4, 0x40000ff4, 0x400007f8, \ + 0x40000ff8, 0x400007fc, 0x40000ffc, 0x40000800, \ + 0x40001000, 0x40000804, 0x40001004, 0x40000808, \ + 0x40001008, \ + } \ +}; + +#endif/*__GUARD_H101_SAMP_EXT_H101_SAMP_H__*/ + +/*******************************************************/ diff --git a/r3bsource/ext_h101_sci2.h b/r3bsource/ext_h101_sci2.h new file mode 100644 index 000000000..04b24e2ea --- /dev/null +++ b/r3bsource/ext_h101_sci2.h @@ -0,0 +1,291 @@ +/******************************************************** + * + * Structure for ext_data_fetch_event() filling. + * + * Do not edit - automatically generated. + */ + +#ifndef __GUARD_H101_SCI2_EXT_H101_SCI2_H__ +#define __GUARD_H101_SCI2_EXT_H101_SCI2_H__ + +#ifndef __CINT__ +# include +#else +/* For CINT (old version trouble with stdint.h): */ +# ifndef uint32_t +typedef unsigned int uint32_t; +typedef int int32_t; +# endif +#endif +#ifndef EXT_STRUCT_CTRL +# define EXT_STRUCT_CTRL(x) +#endif + +/******************************************************** + * + * Plain structure (layout as ntuple/root file): + */ + +typedef struct EXT_STR_h101_SCI2_t +{ + /* UNPACK */ + uint32_t TRIGGER /* [0,15] */; + uint32_t EVENTNO /* [-1,-1] */; + /* RAW */ + uint32_t SCITWO_VTFM /* [1,8] */; + uint32_t SCITWO_VTFMI[8 EXT_STRUCT_CTRL(SCITWO_VTFM)] /* [1,8] */; + uint32_t SCITWO_VTFME[8 EXT_STRUCT_CTRL(SCITWO_VTFM)] /* [1,256] */; + uint32_t SCITWO_VTF /* [0,256] */; + uint32_t SCITWO_VTFv[256 EXT_STRUCT_CTRL(SCITWO_VTF)] /* [0,65535] */; + uint32_t SCITWO_VTCM /* [1,8] */; + uint32_t SCITWO_VTCMI[8 EXT_STRUCT_CTRL(SCITWO_VTCM)] /* [1,8] */; + uint32_t SCITWO_VTCME[8 EXT_STRUCT_CTRL(SCITWO_VTCM)] /* [1,256] */; + uint32_t SCITWO_VTC /* [0,256] */; + uint32_t SCITWO_VTCv[256 EXT_STRUCT_CTRL(SCITWO_VTC)] /* [0,65535] */; + +} EXT_STR_h101_SCI2; + +/******************************************************** + * + * Structure with multiple levels of arrays (partially) + * recovered (recommended): + */ + +typedef struct EXT_STR_h101_SCI2_onion_t +{ + /* UNPACK */ + uint32_t TRIGGER; + uint32_t EVENTNO; + /* RAW */ + uint32_t SCITWO_VTFM; + uint32_t SCITWO_VTFMI[8 /* SCITWO_VTFM */]; + uint32_t SCITWO_VTFME[8 /* SCITWO_VTFM */]; + uint32_t SCITWO_VTF; + uint32_t SCITWO_VTFv[256 /* SCITWO_VTF */]; + uint32_t SCITWO_VTCM; + uint32_t SCITWO_VTCMI[8 /* SCITWO_VTCM */]; + uint32_t SCITWO_VTCME[8 /* SCITWO_VTCM */]; + uint32_t SCITWO_VTC; + uint32_t SCITWO_VTCv[256 /* SCITWO_VTC */]; + +} EXT_STR_h101_SCI2_onion; + +/*******************************************************/ + +#define EXT_STR_h101_SCI2_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* RAW */ \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCITWO_VTFM, UINT32,\ + "SCITWO_VTFM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCITWO_VTFMI, UINT32,\ + "SCITWO_VTFMI", "SCITWO_VTFM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCITWO_VTFME, UINT32,\ + "SCITWO_VTFME", "SCITWO_VTFM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCITWO_VTF, UINT32,\ + "SCITWO_VTF",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCITWO_VTFv, UINT32,\ + "SCITWO_VTFv", "SCITWO_VTF"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCITWO_VTCM, UINT32,\ + "SCITWO_VTCM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCITWO_VTCMI, UINT32,\ + "SCITWO_VTCMI", "SCITWO_VTCM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCITWO_VTCME, UINT32,\ + "SCITWO_VTCME", "SCITWO_VTCM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCITWO_VTC, UINT32,\ + "SCITWO_VTC",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCITWO_VTCv, UINT32,\ + "SCITWO_VTCv", "SCITWO_VTC"); \ + \ +} while (0); + +/******************************************************** + * + * For internal use by the network data reader: + * (version checks, etc) + */ + +typedef struct EXT_STR_h101_SCI2_layout_t +{ + uint32_t _magic; + uint32_t _size_info; + uint32_t _size_struct; + uint32_t _size_struct_onion; + uint32_t _pack_list_items; + + uint32_t _num_items; + struct { + uint32_t _offset; + uint32_t _size; + uint32_t _xor; + const char *_name; + } _items[1]; + uint32_t _pack_list[558]; +} EXT_STR_h101_SCI2_layout; + +#define EXT_STR_h101_SCI2_LAYOUT_INIT { \ + 0x57e65c96, \ + sizeof(EXT_STR_h101_SCI2_layout), \ + sizeof(EXT_STR_h101_SCI2), \ + sizeof(EXT_STR_h101_SCI2_onion), \ + 558, \ + 1, \ + { \ + { 0, sizeof(EXT_STR_h101_SCI2), 0x8dc98b0a, "h101_SCI2" }, \ + }, \ + { \ + 0x40000000, 0x40000004, 0xc0000008, 0x00000008, \ + 0x00000002, 0x4000000c, 0x4000002c, 0x40000010, \ + 0x40000030, 0x40000014, 0x40000034, 0x40000018, \ + 0x40000038, 0x4000001c, 0x4000003c, 0x40000020, \ + 0x40000040, 0x40000024, 0x40000044, 0x40000028, \ + 0x40000048, 0xc000004c, 0x00000100, 0x00000001, \ + 0x40000050, 0x40000054, 0x40000058, 0x4000005c, \ + 0x40000060, 0x40000064, 0x40000068, 0x4000006c, \ + 0x40000070, 0x40000074, 0x40000078, 0x4000007c, \ + 0x40000080, 0x40000084, 0x40000088, 0x4000008c, \ + 0x40000090, 0x40000094, 0x40000098, 0x4000009c, \ + 0x400000a0, 0x400000a4, 0x400000a8, 0x400000ac, \ + 0x400000b0, 0x400000b4, 0x400000b8, 0x400000bc, \ + 0x400000c0, 0x400000c4, 0x400000c8, 0x400000cc, \ + 0x400000d0, 0x400000d4, 0x400000d8, 0x400000dc, \ + 0x400000e0, 0x400000e4, 0x400000e8, 0x400000ec, \ + 0x400000f0, 0x400000f4, 0x400000f8, 0x400000fc, \ + 0x40000100, 0x40000104, 0x40000108, 0x4000010c, \ + 0x40000110, 0x40000114, 0x40000118, 0x4000011c, \ + 0x40000120, 0x40000124, 0x40000128, 0x4000012c, \ + 0x40000130, 0x40000134, 0x40000138, 0x4000013c, \ + 0x40000140, 0x40000144, 0x40000148, 0x4000014c, \ + 0x40000150, 0x40000154, 0x40000158, 0x4000015c, \ + 0x40000160, 0x40000164, 0x40000168, 0x4000016c, \ + 0x40000170, 0x40000174, 0x40000178, 0x4000017c, \ + 0x40000180, 0x40000184, 0x40000188, 0x4000018c, \ + 0x40000190, 0x40000194, 0x40000198, 0x4000019c, \ + 0x400001a0, 0x400001a4, 0x400001a8, 0x400001ac, \ + 0x400001b0, 0x400001b4, 0x400001b8, 0x400001bc, \ + 0x400001c0, 0x400001c4, 0x400001c8, 0x400001cc, \ + 0x400001d0, 0x400001d4, 0x400001d8, 0x400001dc, \ + 0x400001e0, 0x400001e4, 0x400001e8, 0x400001ec, \ + 0x400001f0, 0x400001f4, 0x400001f8, 0x400001fc, \ + 0x40000200, 0x40000204, 0x40000208, 0x4000020c, \ + 0x40000210, 0x40000214, 0x40000218, 0x4000021c, \ + 0x40000220, 0x40000224, 0x40000228, 0x4000022c, \ + 0x40000230, 0x40000234, 0x40000238, 0x4000023c, \ + 0x40000240, 0x40000244, 0x40000248, 0x4000024c, \ + 0x40000250, 0x40000254, 0x40000258, 0x4000025c, \ + 0x40000260, 0x40000264, 0x40000268, 0x4000026c, \ + 0x40000270, 0x40000274, 0x40000278, 0x4000027c, \ + 0x40000280, 0x40000284, 0x40000288, 0x4000028c, \ + 0x40000290, 0x40000294, 0x40000298, 0x4000029c, \ + 0x400002a0, 0x400002a4, 0x400002a8, 0x400002ac, \ + 0x400002b0, 0x400002b4, 0x400002b8, 0x400002bc, \ + 0x400002c0, 0x400002c4, 0x400002c8, 0x400002cc, \ + 0x400002d0, 0x400002d4, 0x400002d8, 0x400002dc, \ + 0x400002e0, 0x400002e4, 0x400002e8, 0x400002ec, \ + 0x400002f0, 0x400002f4, 0x400002f8, 0x400002fc, \ + 0x40000300, 0x40000304, 0x40000308, 0x4000030c, \ + 0x40000310, 0x40000314, 0x40000318, 0x4000031c, \ + 0x40000320, 0x40000324, 0x40000328, 0x4000032c, \ + 0x40000330, 0x40000334, 0x40000338, 0x4000033c, \ + 0x40000340, 0x40000344, 0x40000348, 0x4000034c, \ + 0x40000350, 0x40000354, 0x40000358, 0x4000035c, \ + 0x40000360, 0x40000364, 0x40000368, 0x4000036c, \ + 0x40000370, 0x40000374, 0x40000378, 0x4000037c, \ + 0x40000380, 0x40000384, 0x40000388, 0x4000038c, \ + 0x40000390, 0x40000394, 0x40000398, 0x4000039c, \ + 0x400003a0, 0x400003a4, 0x400003a8, 0x400003ac, \ + 0x400003b0, 0x400003b4, 0x400003b8, 0x400003bc, \ + 0x400003c0, 0x400003c4, 0x400003c8, 0x400003cc, \ + 0x400003d0, 0x400003d4, 0x400003d8, 0x400003dc, \ + 0x400003e0, 0x400003e4, 0x400003e8, 0x400003ec, \ + 0x400003f0, 0x400003f4, 0x400003f8, 0x400003fc, \ + 0x40000400, 0x40000404, 0x40000408, 0x4000040c, \ + 0x40000410, 0x40000414, 0x40000418, 0x4000041c, \ + 0x40000420, 0x40000424, 0x40000428, 0x4000042c, \ + 0x40000430, 0x40000434, 0x40000438, 0x4000043c, \ + 0x40000440, 0x40000444, 0x40000448, 0x4000044c, \ + 0xc0000450, 0x00000008, 0x00000002, 0x40000454, \ + 0x40000474, 0x40000458, 0x40000478, 0x4000045c, \ + 0x4000047c, 0x40000460, 0x40000480, 0x40000464, \ + 0x40000484, 0x40000468, 0x40000488, 0x4000046c, \ + 0x4000048c, 0x40000470, 0x40000490, 0xc0000494, \ + 0x00000100, 0x00000001, 0x40000498, 0x4000049c, \ + 0x400004a0, 0x400004a4, 0x400004a8, 0x400004ac, \ + 0x400004b0, 0x400004b4, 0x400004b8, 0x400004bc, \ + 0x400004c0, 0x400004c4, 0x400004c8, 0x400004cc, \ + 0x400004d0, 0x400004d4, 0x400004d8, 0x400004dc, \ + 0x400004e0, 0x400004e4, 0x400004e8, 0x400004ec, \ + 0x400004f0, 0x400004f4, 0x400004f8, 0x400004fc, \ + 0x40000500, 0x40000504, 0x40000508, 0x4000050c, \ + 0x40000510, 0x40000514, 0x40000518, 0x4000051c, \ + 0x40000520, 0x40000524, 0x40000528, 0x4000052c, \ + 0x40000530, 0x40000534, 0x40000538, 0x4000053c, \ + 0x40000540, 0x40000544, 0x40000548, 0x4000054c, \ + 0x40000550, 0x40000554, 0x40000558, 0x4000055c, \ + 0x40000560, 0x40000564, 0x40000568, 0x4000056c, \ + 0x40000570, 0x40000574, 0x40000578, 0x4000057c, \ + 0x40000580, 0x40000584, 0x40000588, 0x4000058c, \ + 0x40000590, 0x40000594, 0x40000598, 0x4000059c, \ + 0x400005a0, 0x400005a4, 0x400005a8, 0x400005ac, \ + 0x400005b0, 0x400005b4, 0x400005b8, 0x400005bc, \ + 0x400005c0, 0x400005c4, 0x400005c8, 0x400005cc, \ + 0x400005d0, 0x400005d4, 0x400005d8, 0x400005dc, \ + 0x400005e0, 0x400005e4, 0x400005e8, 0x400005ec, \ + 0x400005f0, 0x400005f4, 0x400005f8, 0x400005fc, \ + 0x40000600, 0x40000604, 0x40000608, 0x4000060c, \ + 0x40000610, 0x40000614, 0x40000618, 0x4000061c, \ + 0x40000620, 0x40000624, 0x40000628, 0x4000062c, \ + 0x40000630, 0x40000634, 0x40000638, 0x4000063c, \ + 0x40000640, 0x40000644, 0x40000648, 0x4000064c, \ + 0x40000650, 0x40000654, 0x40000658, 0x4000065c, \ + 0x40000660, 0x40000664, 0x40000668, 0x4000066c, \ + 0x40000670, 0x40000674, 0x40000678, 0x4000067c, \ + 0x40000680, 0x40000684, 0x40000688, 0x4000068c, \ + 0x40000690, 0x40000694, 0x40000698, 0x4000069c, \ + 0x400006a0, 0x400006a4, 0x400006a8, 0x400006ac, \ + 0x400006b0, 0x400006b4, 0x400006b8, 0x400006bc, \ + 0x400006c0, 0x400006c4, 0x400006c8, 0x400006cc, \ + 0x400006d0, 0x400006d4, 0x400006d8, 0x400006dc, \ + 0x400006e0, 0x400006e4, 0x400006e8, 0x400006ec, \ + 0x400006f0, 0x400006f4, 0x400006f8, 0x400006fc, \ + 0x40000700, 0x40000704, 0x40000708, 0x4000070c, \ + 0x40000710, 0x40000714, 0x40000718, 0x4000071c, \ + 0x40000720, 0x40000724, 0x40000728, 0x4000072c, \ + 0x40000730, 0x40000734, 0x40000738, 0x4000073c, \ + 0x40000740, 0x40000744, 0x40000748, 0x4000074c, \ + 0x40000750, 0x40000754, 0x40000758, 0x4000075c, \ + 0x40000760, 0x40000764, 0x40000768, 0x4000076c, \ + 0x40000770, 0x40000774, 0x40000778, 0x4000077c, \ + 0x40000780, 0x40000784, 0x40000788, 0x4000078c, \ + 0x40000790, 0x40000794, 0x40000798, 0x4000079c, \ + 0x400007a0, 0x400007a4, 0x400007a8, 0x400007ac, \ + 0x400007b0, 0x400007b4, 0x400007b8, 0x400007bc, \ + 0x400007c0, 0x400007c4, 0x400007c8, 0x400007cc, \ + 0x400007d0, 0x400007d4, 0x400007d8, 0x400007dc, \ + 0x400007e0, 0x400007e4, 0x400007e8, 0x400007ec, \ + 0x400007f0, 0x400007f4, 0x400007f8, 0x400007fc, \ + 0x40000800, 0x40000804, 0x40000808, 0x4000080c, \ + 0x40000810, 0x40000814, 0x40000818, 0x4000081c, \ + 0x40000820, 0x40000824, 0x40000828, 0x4000082c, \ + 0x40000830, 0x40000834, 0x40000838, 0x4000083c, \ + 0x40000840, 0x40000844, 0x40000848, 0x4000084c, \ + 0x40000850, 0x40000854, 0x40000858, 0x4000085c, \ + 0x40000860, 0x40000864, 0x40000868, 0x4000086c, \ + 0x40000870, 0x40000874, 0x40000878, 0x4000087c, \ + 0x40000880, 0x40000884, 0x40000888, 0x4000088c, \ + 0x40000890, 0x40000894, \ + } \ +}; + +#endif/*__GUARD_H101_SCI2_EXT_H101_SCI2_H__*/ + +/*******************************************************/ diff --git a/r3bsource/ext_h101_sci8.h b/r3bsource/ext_h101_sci8.h index 030e61129..1229ab56b 100644 --- a/r3bsource/ext_h101_sci8.h +++ b/r3bsource/ext_h101_sci8.h @@ -41,38 +41,17 @@ typedef int int32_t; typedef struct EXT_STR_h101_SCI8_t { - /* RAW */ - uint32_t S8VTFM /* [1,2] */; - uint32_t S8VTFMI[2 EXT_STRUCT_CTRL(S8VTFM)] /* [1,2] */; - uint32_t S8VTFME[2 EXT_STRUCT_CTRL(S8VTFM)] /* [1,20] */; - uint32_t S8VTF /* [0,20] */; - uint32_t S8VTFv[20 EXT_STRUCT_CTRL(S8VTF)] /* [0,65535] */; - uint32_t S8VTCM /* [1,2] */; - uint32_t S8VTCMI[2 EXT_STRUCT_CTRL(S8VTCM)] /* [1,2] */; - uint32_t S8VTCME[2 EXT_STRUCT_CTRL(S8VTCM)] /* [1,20] */; - uint32_t S8VTC /* [0,20] */; - uint32_t S8VTCv[20 EXT_STRUCT_CTRL(S8VTC)] /* [0,65535] */; - uint32_t S8TTFLM /* [1,2] */; - uint32_t S8TTFLMI[2 EXT_STRUCT_CTRL(S8TTFLM)] /* [1,2] */; - uint32_t S8TTFLME[2 EXT_STRUCT_CTRL(S8TTFLM)] /* [1,20] */; - uint32_t S8TTFL /* [0,20] */; - uint32_t S8TTFLv[20 EXT_STRUCT_CTRL(S8TTFL)] /* [0,65535] */; - uint32_t S8TTFTM /* [1,2] */; - uint32_t S8TTFTMI[2 EXT_STRUCT_CTRL(S8TTFTM)] /* [1,2] */; - uint32_t S8TTFTME[2 EXT_STRUCT_CTRL(S8TTFTM)] /* [1,20] */; - uint32_t S8TTFT /* [0,20] */; - uint32_t S8TTFTv[20 EXT_STRUCT_CTRL(S8TTFT)] /* [0,65535] */; - uint32_t S8TTCLM /* [1,2] */; - uint32_t S8TTCLMI[2 EXT_STRUCT_CTRL(S8TTCLM)] /* [1,2] */; - uint32_t S8TTCLME[2 EXT_STRUCT_CTRL(S8TTCLM)] /* [1,20] */; - uint32_t S8TTCL /* [0,20] */; - uint32_t S8TTCLv[20 EXT_STRUCT_CTRL(S8TTCL)] /* [0,65535] */; - uint32_t S8TTCTM /* [1,2] */; - uint32_t S8TTCTMI[2 EXT_STRUCT_CTRL(S8TTCTM)] /* [1,2] */; - uint32_t S8TTCTME[2 EXT_STRUCT_CTRL(S8TTCTM)] /* [1,20] */; - uint32_t S8TTCT /* [0,20] */; - uint32_t S8TTCTv[20 EXT_STRUCT_CTRL(S8TTCT)] /* [0,65535] */; - + /* RAW */ + uint32_t SCIEIGHT_VTFM /* [1,8] */; + uint32_t SCIEIGHT_VTFMI[8 EXT_STRUCT_CTRL(SCIEIGHT_VTFM)] /* [1,8] */; + uint32_t SCIEIGHT_VTFME[8 EXT_STRUCT_CTRL(SCIEIGHT_VTFM)] /* [1,256] */; + uint32_t SCIEIGHT_VTF /* [0,256] */; + uint32_t SCIEIGHT_VTFv[256 EXT_STRUCT_CTRL(SCIEIGHT_VTF)] /* [0,65535] */; + uint32_t SCIEIGHT_VTCM /* [1,8] */; + uint32_t SCIEIGHT_VTCMI[8 EXT_STRUCT_CTRL(SCIEIGHT_VTCM)] /* [1,8] */; + uint32_t SCIEIGHT_VTCME[8 EXT_STRUCT_CTRL(SCIEIGHT_VTCM)] /* [1,256] */; + uint32_t SCIEIGHT_VTC /* [0,256] */; + uint32_t SCIEIGHT_VTCv[256 EXT_STRUCT_CTRL(SCIEIGHT_VTC)] /* [0,65535] */; } EXT_STR_h101_SCI8; /******************************************************** @@ -83,79 +62,55 @@ typedef struct EXT_STR_h101_SCI8_t typedef struct EXT_STR_h101_SCI8_onion_t { - /* RAW */ - uint32_t S8VTFM; - uint32_t S8VTFMI[2 /* S8VTFM */]; - uint32_t S8VTFME[2 /* S8VTFM */]; - uint32_t S8VTF; - uint32_t S8VTFv[20 /* S8VTF */]; - uint32_t S8VTCM; - uint32_t S8VTCMI[2 /* S8VTCM */]; - uint32_t S8VTCME[2 /* S8VTCM */]; - uint32_t S8VTC; - uint32_t S8VTCv[20 /* S8VTC */]; - uint32_t S8TTFLM; - uint32_t S8TTFLMI[2 /* S8TTFLM */]; - uint32_t S8TTFLME[2 /* S8TTFLM */]; - uint32_t S8TTFL; - uint32_t S8TTFLv[20 /* S8TTFL */]; - uint32_t S8TTFTM; - uint32_t S8TTFTMI[2 /* S8TTFTM */]; - uint32_t S8TTFTME[2 /* S8TTFTM */]; - uint32_t S8TTFT; - uint32_t S8TTFTv[20 /* S8TTFT */]; - uint32_t S8TTCLM; - uint32_t S8TTCLMI[2 /* S8TTCLM */]; - uint32_t S8TTCLME[2 /* S8TTCLM */]; - uint32_t S8TTCL; - uint32_t S8TTCLv[20 /* S8TTCL */]; - uint32_t S8TTCTM; - uint32_t S8TTCTMI[2 /* S8TTCTM */]; - uint32_t S8TTCTME[2 /* S8TTCTM */]; - uint32_t S8TTCT; - uint32_t S8TTCTv[20 /* S8TTCT */]; - + uint32_t SCIEIGHT_VTFM; + uint32_t SCIEIGHT_VTFMI[8 /* SCIEIGHT_VTFM */]; + uint32_t SCIEIGHT_VTFME[8 /* SCIEIGHT_VTFM */]; + uint32_t SCIEIGHT_VTF; + uint32_t SCIEIGHT_VTFv[256 /* SCIEIGHT_VTF */]; + uint32_t SCIEIGHT_VTCM; + uint32_t SCIEIGHT_VTCMI[8 /* SCIEIGHT_VTCM */]; + uint32_t SCIEIGHT_VTCME[8 /* SCIEIGHT_VTCM */]; + uint32_t SCIEIGHT_VTC; + uint32_t SCIEIGHT_VTCv[256 /* SCIEIGHT_VTC */]; } EXT_STR_h101_SCI8_onion; /*******************************************************/ -#define EXT_STR_h101_SCI8_ITEMS_INFO(ok, si, offset, struct_t, printerr) \ - do \ - { \ - ok = 1; \ - /* RAW */ \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8VTFM, UINT32, "S8VTFM", 2); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8VTFMI, UINT32, "S8VTFMI", "S8VTFM"); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8VTFME, UINT32, "S8VTFME", "S8VTFM"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8VTF, UINT32, "S8VTF", 20); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8VTFv, UINT32, "S8VTFv", "S8VTF"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8VTCM, UINT32, "S8VTCM", 2); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8VTCMI, UINT32, "S8VTCMI", "S8VTCM"); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8VTCME, UINT32, "S8VTCME", "S8VTCM"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8VTC, UINT32, "S8VTC", 20); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8VTCv, UINT32, "S8VTCv", "S8VTC"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTFLM, UINT32, "S8TTFLM", 2); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTFLMI, UINT32, "S8TTFLMI", "S8TTFLM"); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTFLME, UINT32, "S8TTFLME", "S8TTFLM"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTFL, UINT32, "S8TTFL", 20); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTFLv, UINT32, "S8TTFLv", "S8TTFL"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTFTM, UINT32, "S8TTFTM", 2); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTFTMI, UINT32, "S8TTFTMI", "S8TTFTM"); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTFTME, UINT32, "S8TTFTME", "S8TTFTM"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTFT, UINT32, "S8TTFT", 20); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTFTv, UINT32, "S8TTFTv", "S8TTFT"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTCLM, UINT32, "S8TTCLM", 2); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTCLMI, UINT32, "S8TTCLMI", "S8TTCLM"); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTCLME, UINT32, "S8TTCLME", "S8TTCLM"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTCL, UINT32, "S8TTCL", 20); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTCLv, UINT32, "S8TTCLv", "S8TTCL"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTCTM, UINT32, "S8TTCTM", 2); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTCTMI, UINT32, "S8TTCTMI", "S8TTCTM"); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTCTME, UINT32, "S8TTCTME", "S8TTCTM"); \ - EXT_STR_ITEM_INFO_LIM(ok, si, offset, struct_t, printerr, S8TTCT, UINT32, "S8TTCT", 20); \ - EXT_STR_ITEM_INFO_ZZP(ok, si, offset, struct_t, printerr, S8TTCTv, UINT32, "S8TTCTv", "S8TTCT"); \ - \ - } while (0); +#define EXT_STR_h101_SCI8_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* RAW */ \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTFM, UINT32,\ + "SCIEIGHT_VTFM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTFMI, UINT32,\ + "SCIEIGHT_VTFMI", "SCIEIGHT_VTFM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTFME, UINT32,\ + "SCIEIGHT_VTFME", "SCIEIGHT_VTFM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTF, UINT32,\ + "SCIEIGHT_VTF",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTFv, UINT32,\ + "SCIEIGHT_VTFv", "SCIEIGHT_VTF"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTCM, UINT32,\ + "SCIEIGHT_VTCM",8); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTCMI, UINT32,\ + "SCIEIGHT_VTCMI", "SCIEIGHT_VTCM"); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTCME, UINT32,\ + "SCIEIGHT_VTCME", "SCIEIGHT_VTCM"); \ + EXT_STR_ITEM_INFO_LIM(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTC, UINT32,\ + "SCIEIGHT_VTC",256); \ + EXT_STR_ITEM_INFO_ZZP(ok,si,offset,struct_t,printerr,\ + SCIEIGHT_VTCv, UINT32,\ + "SCIEIGHT_VTCv", "SCIEIGHT_VTC"); \ + \ +} while (0); /******************************************************** * @@ -165,56 +120,176 @@ typedef struct EXT_STR_h101_SCI8_onion_t typedef struct EXT_STR_h101_SCI8_layout_t { - uint32_t _magic; - uint32_t _size_info; - uint32_t _size_struct; - uint32_t _size_struct_onion; - uint32_t _pack_list_items; + uint32_t _magic; + uint32_t _size_info; + uint32_t _size_struct; + uint32_t _size_struct_onion; + uint32_t _pack_list_items; - uint32_t _num_items; - struct - { - uint32_t _offset; - uint32_t _size; - uint32_t _xor; - const char* _name; - } _items[1]; - uint32_t _pack_list[180]; + uint32_t _num_items; + struct { + uint32_t _offset; + uint32_t _size; + uint32_t _xor; + const char *_name; + } _items[1]; + uint32_t _pack_list[558]; } EXT_STR_h101_SCI8_layout; -#define EXT_STR_h101_SCI8_LAYOUT_INIT \ - { 0x57e65c93, \ - sizeof(EXT_STR_h101_SCI8_layout), \ - sizeof(EXT_STR_h101_SCI8), \ - sizeof(EXT_STR_h101_SCI8_onion), \ - 180, \ - 1, \ - { \ - { 0, sizeof(EXT_STR_h101_SCI8), 0xbd53b92d, "h101_SCI8" }, \ - }, \ - { \ - 0xc0000000, 0x00000002, 0x00000002, 0x40000004, 0x4000000c, 0x40000008, 0x40000010, 0xc0000014, 0x00000014, \ - 0x00000001, 0x40000018, 0x4000001c, 0x40000020, 0x40000024, 0x40000028, 0x4000002c, 0x40000030, 0x40000034, \ - 0x40000038, 0x4000003c, 0x40000040, 0x40000044, 0x40000048, 0x4000004c, 0x40000050, 0x40000054, 0x40000058, \ - 0x4000005c, 0x40000060, 0x40000064, 0xc0000068, 0x00000002, 0x00000002, 0x4000006c, 0x40000074, 0x40000070, \ - 0x40000078, 0xc000007c, 0x00000014, 0x00000001, 0x40000080, 0x40000084, 0x40000088, 0x4000008c, 0x40000090, \ - 0x40000094, 0x40000098, 0x4000009c, 0x400000a0, 0x400000a4, 0x400000a8, 0x400000ac, 0x400000b0, 0x400000b4, \ - 0x400000b8, 0x400000bc, 0x400000c0, 0x400000c4, 0x400000c8, 0x400000cc, 0xc00000d0, 0x00000002, 0x00000002, \ - 0x400000d4, 0x400000dc, 0x400000d8, 0x400000e0, 0xc00000e4, 0x00000014, 0x00000001, 0x400000e8, 0x400000ec, \ - 0x400000f0, 0x400000f4, 0x400000f8, 0x400000fc, 0x40000100, 0x40000104, 0x40000108, 0x4000010c, 0x40000110, \ - 0x40000114, 0x40000118, 0x4000011c, 0x40000120, 0x40000124, 0x40000128, 0x4000012c, 0x40000130, 0x40000134, \ - 0xc0000138, 0x00000002, 0x00000002, 0x4000013c, 0x40000144, 0x40000140, 0x40000148, 0xc000014c, 0x00000014, \ - 0x00000001, 0x40000150, 0x40000154, 0x40000158, 0x4000015c, 0x40000160, 0x40000164, 0x40000168, 0x4000016c, \ - 0x40000170, 0x40000174, 0x40000178, 0x4000017c, 0x40000180, 0x40000184, 0x40000188, 0x4000018c, 0x40000190, \ - 0x40000194, 0x40000198, 0x4000019c, 0xc00001a0, 0x00000002, 0x00000002, 0x400001a4, 0x400001ac, 0x400001a8, \ - 0x400001b0, 0xc00001b4, 0x00000014, 0x00000001, 0x400001b8, 0x400001bc, 0x400001c0, 0x400001c4, 0x400001c8, \ - 0x400001cc, 0x400001d0, 0x400001d4, 0x400001d8, 0x400001dc, 0x400001e0, 0x400001e4, 0x400001e8, 0x400001ec, \ - 0x400001f0, 0x400001f4, 0x400001f8, 0x400001fc, 0x40000200, 0x40000204, 0xc0000208, 0x00000002, 0x00000002, \ - 0x4000020c, 0x40000214, 0x40000210, 0x40000218, 0xc000021c, 0x00000014, 0x00000001, 0x40000220, 0x40000224, \ - 0x40000228, 0x4000022c, 0x40000230, 0x40000234, 0x40000238, 0x4000023c, 0x40000240, 0x40000244, 0x40000248, \ - 0x4000024c, 0x40000250, 0x40000254, 0x40000258, 0x4000025c, 0x40000260, 0x40000264, 0x40000268, 0x4000026c, \ - } }; +#define EXT_STR_h101_SCI8_LAYOUT_INIT { \ + 0x57e65c96, \ + sizeof(EXT_STR_h101_SCI8_layout), \ + sizeof(EXT_STR_h101_SCI8), \ + sizeof(EXT_STR_h101_SCI8_onion), \ + 558, \ + 1, \ + { \ + { 0, sizeof(EXT_STR_h101_SCI8), 0x804fe6be, "h101_SCI8" }, \ + }, \ + { \ + 0x40000000, 0x40000004, 0xc0000008, 0x00000008, \ + 0x00000002, 0x4000000c, 0x4000002c, 0x40000010, \ + 0x40000030, 0x40000014, 0x40000034, 0x40000018, \ + 0x40000038, 0x4000001c, 0x4000003c, 0x40000020, \ + 0x40000040, 0x40000024, 0x40000044, 0x40000028, \ + 0x40000048, 0xc000004c, 0x00000100, 0x00000001, \ + 0x40000050, 0x40000054, 0x40000058, 0x4000005c, \ + 0x40000060, 0x40000064, 0x40000068, 0x4000006c, \ + 0x40000070, 0x40000074, 0x40000078, 0x4000007c, \ + 0x40000080, 0x40000084, 0x40000088, 0x4000008c, \ + 0x40000090, 0x40000094, 0x40000098, 0x4000009c, \ + 0x400000a0, 0x400000a4, 0x400000a8, 0x400000ac, \ + 0x400000b0, 0x400000b4, 0x400000b8, 0x400000bc, \ + 0x400000c0, 0x400000c4, 0x400000c8, 0x400000cc, \ + 0x400000d0, 0x400000d4, 0x400000d8, 0x400000dc, \ + 0x400000e0, 0x400000e4, 0x400000e8, 0x400000ec, \ + 0x400000f0, 0x400000f4, 0x400000f8, 0x400000fc, \ + 0x40000100, 0x40000104, 0x40000108, 0x4000010c, \ + 0x40000110, 0x40000114, 0x40000118, 0x4000011c, \ + 0x40000120, 0x40000124, 0x40000128, 0x4000012c, \ + 0x40000130, 0x40000134, 0x40000138, 0x4000013c, \ + 0x40000140, 0x40000144, 0x40000148, 0x4000014c, \ + 0x40000150, 0x40000154, 0x40000158, 0x4000015c, \ + 0x40000160, 0x40000164, 0x40000168, 0x4000016c, \ + 0x40000170, 0x40000174, 0x40000178, 0x4000017c, \ + 0x40000180, 0x40000184, 0x40000188, 0x4000018c, \ + 0x40000190, 0x40000194, 0x40000198, 0x4000019c, \ + 0x400001a0, 0x400001a4, 0x400001a8, 0x400001ac, \ + 0x400001b0, 0x400001b4, 0x400001b8, 0x400001bc, \ + 0x400001c0, 0x400001c4, 0x400001c8, 0x400001cc, \ + 0x400001d0, 0x400001d4, 0x400001d8, 0x400001dc, \ + 0x400001e0, 0x400001e4, 0x400001e8, 0x400001ec, \ + 0x400001f0, 0x400001f4, 0x400001f8, 0x400001fc, \ + 0x40000200, 0x40000204, 0x40000208, 0x4000020c, \ + 0x40000210, 0x40000214, 0x40000218, 0x4000021c, \ + 0x40000220, 0x40000224, 0x40000228, 0x4000022c, \ + 0x40000230, 0x40000234, 0x40000238, 0x4000023c, \ + 0x40000240, 0x40000244, 0x40000248, 0x4000024c, \ + 0x40000250, 0x40000254, 0x40000258, 0x4000025c, \ + 0x40000260, 0x40000264, 0x40000268, 0x4000026c, \ + 0x40000270, 0x40000274, 0x40000278, 0x4000027c, \ + 0x40000280, 0x40000284, 0x40000288, 0x4000028c, \ + 0x40000290, 0x40000294, 0x40000298, 0x4000029c, \ + 0x400002a0, 0x400002a4, 0x400002a8, 0x400002ac, \ + 0x400002b0, 0x400002b4, 0x400002b8, 0x400002bc, \ + 0x400002c0, 0x400002c4, 0x400002c8, 0x400002cc, \ + 0x400002d0, 0x400002d4, 0x400002d8, 0x400002dc, \ + 0x400002e0, 0x400002e4, 0x400002e8, 0x400002ec, \ + 0x400002f0, 0x400002f4, 0x400002f8, 0x400002fc, \ + 0x40000300, 0x40000304, 0x40000308, 0x4000030c, \ + 0x40000310, 0x40000314, 0x40000318, 0x4000031c, \ + 0x40000320, 0x40000324, 0x40000328, 0x4000032c, \ + 0x40000330, 0x40000334, 0x40000338, 0x4000033c, \ + 0x40000340, 0x40000344, 0x40000348, 0x4000034c, \ + 0x40000350, 0x40000354, 0x40000358, 0x4000035c, \ + 0x40000360, 0x40000364, 0x40000368, 0x4000036c, \ + 0x40000370, 0x40000374, 0x40000378, 0x4000037c, \ + 0x40000380, 0x40000384, 0x40000388, 0x4000038c, \ + 0x40000390, 0x40000394, 0x40000398, 0x4000039c, \ + 0x400003a0, 0x400003a4, 0x400003a8, 0x400003ac, \ + 0x400003b0, 0x400003b4, 0x400003b8, 0x400003bc, \ + 0x400003c0, 0x400003c4, 0x400003c8, 0x400003cc, \ + 0x400003d0, 0x400003d4, 0x400003d8, 0x400003dc, \ + 0x400003e0, 0x400003e4, 0x400003e8, 0x400003ec, \ + 0x400003f0, 0x400003f4, 0x400003f8, 0x400003fc, \ + 0x40000400, 0x40000404, 0x40000408, 0x4000040c, \ + 0x40000410, 0x40000414, 0x40000418, 0x4000041c, \ + 0x40000420, 0x40000424, 0x40000428, 0x4000042c, \ + 0x40000430, 0x40000434, 0x40000438, 0x4000043c, \ + 0x40000440, 0x40000444, 0x40000448, 0x4000044c, \ + 0xc0000450, 0x00000008, 0x00000002, 0x40000454, \ + 0x40000474, 0x40000458, 0x40000478, 0x4000045c, \ + 0x4000047c, 0x40000460, 0x40000480, 0x40000464, \ + 0x40000484, 0x40000468, 0x40000488, 0x4000046c, \ + 0x4000048c, 0x40000470, 0x40000490, 0xc0000494, \ + 0x00000100, 0x00000001, 0x40000498, 0x4000049c, \ + 0x400004a0, 0x400004a4, 0x400004a8, 0x400004ac, \ + 0x400004b0, 0x400004b4, 0x400004b8, 0x400004bc, \ + 0x400004c0, 0x400004c4, 0x400004c8, 0x400004cc, \ + 0x400004d0, 0x400004d4, 0x400004d8, 0x400004dc, \ + 0x400004e0, 0x400004e4, 0x400004e8, 0x400004ec, \ + 0x400004f0, 0x400004f4, 0x400004f8, 0x400004fc, \ + 0x40000500, 0x40000504, 0x40000508, 0x4000050c, \ + 0x40000510, 0x40000514, 0x40000518, 0x4000051c, \ + 0x40000520, 0x40000524, 0x40000528, 0x4000052c, \ + 0x40000530, 0x40000534, 0x40000538, 0x4000053c, \ + 0x40000540, 0x40000544, 0x40000548, 0x4000054c, \ + 0x40000550, 0x40000554, 0x40000558, 0x4000055c, \ + 0x40000560, 0x40000564, 0x40000568, 0x4000056c, \ + 0x40000570, 0x40000574, 0x40000578, 0x4000057c, \ + 0x40000580, 0x40000584, 0x40000588, 0x4000058c, \ + 0x40000590, 0x40000594, 0x40000598, 0x4000059c, \ + 0x400005a0, 0x400005a4, 0x400005a8, 0x400005ac, \ + 0x400005b0, 0x400005b4, 0x400005b8, 0x400005bc, \ + 0x400005c0, 0x400005c4, 0x400005c8, 0x400005cc, \ + 0x400005d0, 0x400005d4, 0x400005d8, 0x400005dc, \ + 0x400005e0, 0x400005e4, 0x400005e8, 0x400005ec, \ + 0x400005f0, 0x400005f4, 0x400005f8, 0x400005fc, \ + 0x40000600, 0x40000604, 0x40000608, 0x4000060c, \ + 0x40000610, 0x40000614, 0x40000618, 0x4000061c, \ + 0x40000620, 0x40000624, 0x40000628, 0x4000062c, \ + 0x40000630, 0x40000634, 0x40000638, 0x4000063c, \ + 0x40000640, 0x40000644, 0x40000648, 0x4000064c, \ + 0x40000650, 0x40000654, 0x40000658, 0x4000065c, \ + 0x40000660, 0x40000664, 0x40000668, 0x4000066c, \ + 0x40000670, 0x40000674, 0x40000678, 0x4000067c, \ + 0x40000680, 0x40000684, 0x40000688, 0x4000068c, \ + 0x40000690, 0x40000694, 0x40000698, 0x4000069c, \ + 0x400006a0, 0x400006a4, 0x400006a8, 0x400006ac, \ + 0x400006b0, 0x400006b4, 0x400006b8, 0x400006bc, \ + 0x400006c0, 0x400006c4, 0x400006c8, 0x400006cc, \ + 0x400006d0, 0x400006d4, 0x400006d8, 0x400006dc, \ + 0x400006e0, 0x400006e4, 0x400006e8, 0x400006ec, \ + 0x400006f0, 0x400006f4, 0x400006f8, 0x400006fc, \ + 0x40000700, 0x40000704, 0x40000708, 0x4000070c, \ + 0x40000710, 0x40000714, 0x40000718, 0x4000071c, \ + 0x40000720, 0x40000724, 0x40000728, 0x4000072c, \ + 0x40000730, 0x40000734, 0x40000738, 0x4000073c, \ + 0x40000740, 0x40000744, 0x40000748, 0x4000074c, \ + 0x40000750, 0x40000754, 0x40000758, 0x4000075c, \ + 0x40000760, 0x40000764, 0x40000768, 0x4000076c, \ + 0x40000770, 0x40000774, 0x40000778, 0x4000077c, \ + 0x40000780, 0x40000784, 0x40000788, 0x4000078c, \ + 0x40000790, 0x40000794, 0x40000798, 0x4000079c, \ + 0x400007a0, 0x400007a4, 0x400007a8, 0x400007ac, \ + 0x400007b0, 0x400007b4, 0x400007b8, 0x400007bc, \ + 0x400007c0, 0x400007c4, 0x400007c8, 0x400007cc, \ + 0x400007d0, 0x400007d4, 0x400007d8, 0x400007dc, \ + 0x400007e0, 0x400007e4, 0x400007e8, 0x400007ec, \ + 0x400007f0, 0x400007f4, 0x400007f8, 0x400007fc, \ + 0x40000800, 0x40000804, 0x40000808, 0x4000080c, \ + 0x40000810, 0x40000814, 0x40000818, 0x4000081c, \ + 0x40000820, 0x40000824, 0x40000828, 0x4000082c, \ + 0x40000830, 0x40000834, 0x40000838, 0x4000083c, \ + 0x40000840, 0x40000844, 0x40000848, 0x4000084c, \ + 0x40000850, 0x40000854, 0x40000858, 0x4000085c, \ + 0x40000860, 0x40000864, 0x40000868, 0x4000086c, \ + 0x40000870, 0x40000874, 0x40000878, 0x4000087c, \ + 0x40000880, 0x40000884, 0x40000888, 0x4000088c, \ + 0x40000890, 0x40000894, \ + } \ +}; -#endif /*__GUARD_H101_SCI8_EXT_H101_SCI8_H__*/ +#endif/*__GUARD_H101_SCI8_EXT_H101_SCI8_H__*/ /*******************************************************/ diff --git a/sci2/CMakeLists.txt b/sci2/CMakeLists.txt new file mode 100644 index 000000000..8d8f4ce81 --- /dev/null +++ b/sci2/CMakeLists.txt @@ -0,0 +1,54 @@ +# Create a library called "libR3BCal" which includes the source files given in +# the array . +# The extension is already found. Any number of sources could be listed here. + +Set(SYSTEM_INCLUDE_DIRECTORIES +${SYSTEM_INCLUDE_DIRECTORIES} +${BASE_INCLUDE_DIRECTORIES} +) + +set(INCLUDE_DIRECTORIES +#put here all directories where header files are located +${R3BROOT_SOURCE_DIR}/r3bbase +${R3BROOT_SOURCE_DIR}/passive +${R3BROOT_SOURCE_DIR}/sci2 +${R3BROOT_SOURCE_DIR}/r3bdata/ +${R3BROOT_SOURCE_DIR}/r3bdata/calData +${R3BROOT_SOURCE_DIR}/r3bdata/dchData +${R3BROOT_SOURCE_DIR}/r3bdata/gfiData +${R3BROOT_SOURCE_DIR}/r3bdata/mtofData +${R3BROOT_SOURCE_DIR}/r3bdata/tofData +${R3BROOT_SOURCE_DIR}/r3bdata/landData +${R3BROOT_SOURCE_DIR}/r3bdata/losData +${R3BROOT_SOURCE_DIR}/r3bdata/sci2Data +${R3BROOT_SOURCE_DIR}/r3bdata/trackerData +${R3BROOT_SOURCE_DIR}/tcal +) + +include_directories( ${INCLUDE_DIRECTORIES}) +include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) + +set(LINK_DIRECTORIES +${ROOT_LIBRARY_DIR} +${FAIRROOT_LIBRARY_DIR} +) + +link_directories( ${LINK_DIRECTORIES}) + +set(SRCS +R3BSci2Mapped2Cal.cxx +R3BSci2Mapped2CalPar.cxx +R3BSci2Cal2Hit.cxx +) + +# fill list of header files from list of source files +# by exchanging the file extension +CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") + +Set(LINKDEF Sci2LinkDef.h) +Set(LIBRARY_NAME R3BSci2) +Set(DEPENDENCIES + R3Bbase R3BData R3BPassive R3BTCal) + +GENERATE_LIBRARY() + diff --git a/sci2/R3BSci2Cal2Hit.cxx b/sci2/R3BSci2Cal2Hit.cxx new file mode 100644 index 000000000..3fcfab9a5 --- /dev/null +++ b/sci2/R3BSci2Cal2Hit.cxx @@ -0,0 +1,318 @@ +// ------------------------------------------------------------ +// ----- R3BSci2Cal2Hit ----- +// ----- Created December 6th 2019 by M. Heil ----- +// ------------------------------------------------------------ + +#include "R3BSci2Cal2Hit.h" +#include "FairLogger.h" +#include "R3BSci2CalData.h" +#include "R3BSci2HitData.h" +#include "R3BSci2Mapped2Cal.h" +#include "R3BSci2MappedData.h" +#include "R3BTCalEngine.h" +#include "R3BTCalPar.h" + +#include "TClonesArray.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include +#include +#include +using namespace std; +#define IS_NAN(x) TMath::IsNaN(x) + +R3BSci2Cal2Hit::R3BSci2Cal2Hit() + : FairTask("Sci2Cal2Hit", 1) + , fCalItems(NULL) + , fHitItems(new TClonesArray("R3BSci2HitData")) + , fNofHitItems(0) + , fsci2VeffX(1.) + , fsci2OffsetX(0.) + , fsci2VeffXT(1.) + , fsci2OffsetXT(0.) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) +{ + fhTres_M = NULL; + fhTres_T = NULL; + fhQ_L = NULL; + fhQ_R = NULL; + fhQ = NULL; + fhQ_vs_X = NULL; + fhQ1_vs_Q2 = NULL; +} + +R3BSci2Cal2Hit::R3BSci2Cal2Hit(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fCalItems(NULL) + , fHitItems(new TClonesArray("R3BSci2HitData")) + , fNofHitItems(0) + , fsci2VeffX(1.) + , fsci2OffsetX(0.) + , fsci2VeffXT(1.) + , fsci2OffsetXT(0.) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) +{ + fhTres_M = NULL; + fhTres_T = NULL; + fhQ_L = NULL; + fhQ_R = NULL; + fhQ = NULL; + fhQ_vs_X = NULL; + fhQ1_vs_Q2 = NULL; +} + +R3BSci2Cal2Hit::~R3BSci2Cal2Hit() +{ + if (fhTres_M) + delete (fhTres_M); + if (fhTres_T) + delete (fhTres_T); + if (fhQ_L) + delete (fhQ_L); + if (fhQ_R) + delete (fhQ_R); + if (fhQ) + delete (fhQ); + if (fhQ_vs_X) + delete (fhQ_vs_X); + if (fhQ1_vs_Q2) + delete (fhQ1_vs_Q2); + + if (fHitItems) + { + delete fHitItems; + fHitItems = NULL; + } +} + +InitStatus R3BSci2Cal2Hit::Init() +{ + // get access to Cal data + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + LOG(fatal) << "FairRootManager not found"; + + fCalItems = (TClonesArray*)mgr->GetObject("Sci2Cal"); + if (NULL == fCalItems) + LOG(fatal) << "Branch Sci2Cal not found"; + + // request storage of Hit data in output tree + mgr->Register("Sci2Hit", "Land", fHitItems, kTRUE); + + Icount = 0; + + return kSUCCESS; +} + +InitStatus R3BSci2Cal2Hit::ReInit() { return kSUCCESS; } + +/* + * Calculate a single hit time for SCI2 detector + */ +void R3BSci2Cal2Hit::Exec(Option_t* option) +{ + Icount++; + + // missing times are NAN, hence other times will also + // be NAN if one time is missing. + Double_t time_V[10][2] = { 0.0 / 0.0 }; // [multihit][pm] + Double_t time_L[10][2] = { 0.0 / 0.0 }; + Double_t time_T[10][2] = { 0.0 / 0.0 }; + Double_t timeM[10] = { 0.0 }; + Double_t TresM[10] = { 0.0 / 0.0 }; + Double_t timeT[10] = { 0.0 }; + Double_t TresT[10] = { 0.0 / 0.0 }; + Double_t totsum[10] = { 0.0 }; + Double_t tot[10][2] = { 0.0 / 0.0 }; + Double_t x_cm[10] = { 0.0 / 0.0 }; + Double_t xT_cm[10] = { 0.0 / 0.0 }; + Double_t Z[10] = { 0.0 }; + Double_t t_hit[10] = { 0.0 }; + + Double_t fhdTxmin = 0.; + Double_t fhdTxmax = 100.; + Int_t fhdTxbin = 20; + // min,max,Nbins for time spectra + Double_t fhTmin = -20.; //-5.; //-10 + Double_t fhTmax = 20.; // 5.; // 10 + Int_t fhTbin = 2000; // 10000; // 20000 + // min,max,Nbins for ToT spectra + Double_t fhQmin = 0.; + Double_t fhQmax = 200; // 300.; //150 + Int_t fhQbin = 4000; // 0; //3000; //1500 + // min,max,Nbins for X and Y spectra + Double_t fhXmin = -5.; //-5 + Double_t fhXmax = 5.; // 5 + Int_t fhXbin = 2000; // 1000 + // min,max,Nbins for radius spectra + Double_t fhRmin = -2.; // 0.; + Double_t fhRmax = 2.; // 10.; + Int_t fhRbin = 1000; + + if (NULL == fhTres_M) + { + char strName[255]; + sprintf(strName, "SCI2_dt_MCFD"); + fhTres_M = new TH1F(strName, "", fhTbin, fhTmin, fhTmax); + } + + if (NULL == fhTres_T) + { + char strName[255]; + sprintf(strName, "SCI2_dt_TAMEX"); + fhTres_T = new TH1F(strName, "", fhTbin, fhTmin, fhTmax); + } + + if (NULL == fhQ_L) + { + char strName[255]; + sprintf(strName, "SCI2_QL_vs_X"); + fhQ_L = new TH2F(strName, "", fhRbin, fhRmin, fhRmax, fhQbin, fhQmin, fhQmax); + } + + if (NULL == fhQ_R) + { + char strName[255]; + sprintf(strName, "SCI2_QR_vs_X"); + fhQ_R = new TH2F(strName, "", fhRbin, fhRmin, fhRmax, fhQbin, fhQmin, fhQmax); + } + + if (NULL == fhQ) + { + char strName[255]; + sprintf(strName, "SCI2_Q"); + fhQ = new TH1F(strName, "", 10000, fhQmin, fhQmax); + } + + if (NULL == fhQ_vs_X) + { + char strName[255]; + sprintf(strName, "SCI2_Q_vs_X"); + fhQ_vs_X = new TH2F(strName, "", fhXbin, fhXmin, fhXmax, fhQbin, fhQmin, fhQmax); + } + + if (NULL == fhQ1_vs_Q2) + { + char strName[255]; + sprintf(strName, "SCI2_QPM1_vs_QPM5"); + fhQ1_vs_Q2 = new TH2F(strName, "", fhQbin, fhQmin, fhQmax, fhQbin, fhQmin, fhQmax); + } + + Int_t nPart = fCalItems->GetEntriesFast(); + Int_t nDet = 0; + + for (Int_t iPart = 0; iPart < nPart; iPart++) + { + + /* + * nPart is the number of particle passing through Sci2 detector in one event + */ + R3BSci2CalData* calItem = (R3BSci2CalData*)fCalItems->At(iPart); + nDet = calItem->GetDetector(); + + // VFTX Channels 1-2: + if (!(IS_NAN(calItem->fTimeV_r_ns))) + { + time_V[iPart][0] = calItem->fTimeV_r_ns; + } + if (!(IS_NAN(calItem->fTimeV_l_ns))) + { + time_V[iPart][1] = calItem->fTimeV_l_ns; + } + // TAMEX Channels 1-2: + if (!(IS_NAN(calItem->fTimeL_r_ns))) + { + time_L[iPart][0] = calItem->fTimeL_r_ns; + } + if (!(IS_NAN(calItem->fTimeT_r_ns))) + { + time_T[iPart][0] = calItem->fTimeT_r_ns; + } + if (!(IS_NAN(calItem->fTimeL_l_ns))) + { + time_L[iPart][1] = calItem->fTimeL_l_ns; + } + if (!(IS_NAN(calItem->fTimeT_l_ns))) + { + time_T[iPart][1] = calItem->fTimeT_l_ns; + } + + for (int ipm = 0; ipm < 2; ipm++) + { + if (time_T[iPart][ipm] > 0. && time_L[iPart][ipm] > 0. && !(IS_NAN(time_T[iPart][ipm])) && + !(IS_NAN(time_L[iPart][ipm]))) + { + while (time_T[iPart][ipm] - time_L[iPart][ipm] < 0.) + { + time_T[iPart][ipm] = time_T[iPart][ipm] + 2048. * fClockFreq; + } + + tot[iPart][ipm] = time_T[iPart][ipm] - time_L[iPart][ipm]; + } + + totsum[iPart] += tot[iPart][ipm]; + + if (time_L[iPart][ipm] > 0. && !(IS_NAN(time_L[iPart][ipm]))) + timeT[iPart] += time_L[iPart][ipm]; + + if (time_V[iPart][ipm] > 0. && !(IS_NAN(time_V[iPart][ipm]))) + timeM[iPart] += time_V[iPart][ipm]; + } + + totsum[iPart] = totsum[iPart] / 2.; + Z[iPart] = totsum[iPart]; + + xT_cm[iPart] = (time_L[iPart][1] - time_L[iPart][0] - fsci2OffsetXT) * fsci2VeffXT; + x_cm[iPart] = (time_V[iPart][1] - time_V[iPart][0] - fsci2OffsetX) * fsci2VeffX; + + timeT[iPart] = timeT[iPart] / 2.; + timeM[iPart] = timeM[iPart] / 2.; + t_hit[iPart] = timeM[iPart]; + + TresM[iPart] = time_V[iPart][1] - time_V[iPart][0]; + TresT[iPart] = time_L[iPart][1] - time_L[iPart][0]; + + fhTres_M->Fill(TresM[iPart]); + fhTres_T->Fill(TresT[iPart]); + + fhQ1_vs_Q2->Fill(tot[iPart][0], tot[iPart][1]); + fhQ_L->Fill(x_cm[iPart], tot[iPart][1]); + fhQ_R->Fill(x_cm[iPart], tot[iPart][0]); + fhQ->Fill(totsum[iPart]); + fhQ_vs_X->Fill(x_cm[iPart], totsum[iPart]); + + new ((*fHitItems)[fNofHitItems]) R3BSci2HitData(nDet, t_hit[iPart], x_cm[iPart], Z[iPart]); + fNofHitItems += 1; + } +} + +void R3BSci2Cal2Hit::FinishEvent() +{ + + if (fHitItems) + { + fHitItems->Clear(); + fNofHitItems = 0; + } +} + +void R3BSci2Cal2Hit::FinishTask() +{ + if (fhTres_M) + fhTres_M->Write(); + if (fhTres_T) + fhTres_T->Write(); + if (fhQ) + fhQ->Write(); + if (fhQ_vs_X) + fhQ_vs_X->Write(); + if (fhQ1_vs_Q2) + fhQ1_vs_Q2->Write(); + if (fhQ_L) + fhQ_L->Write(); + if (fhQ_R) + fhQ_R->Write(); +} + +ClassImp(R3BSci2Cal2Hit) diff --git a/sci2/R3BSci2Cal2Hit.h b/sci2/R3BSci2Cal2Hit.h new file mode 100644 index 000000000..fbb2c72c3 --- /dev/null +++ b/sci2/R3BSci2Cal2Hit.h @@ -0,0 +1,134 @@ +// ------------------------------------------------------------------ +// ----- R3BSci2Cal2Hit ----- +// ----- Created December 6th 2019 by M. Heil ----- +// ----- Convert time calibrated data to hit level (single time) ---- +// ----- Following R3BLosCal2Hit +// ------------------------------------------------------------------ + + + +#ifndef R3BSCI2CAL2HIT +#define R3BSCI2CAL2HIT + +#include + +#include "FairTask.h" + +class TClonesArray; +class TH1F; +class TH2F; +/* + * TODO: This explanation is humbug. + * An analysis task to apply TCAL calibration for NeuLAND. + * This class reads NeuLAND mapped items with TDC values and + * produces time items with time in [ns]. It requires TCAL + * calibration parameters, which are produced in a separate + * analysis run containing R3BSci2Cal2HitFill task. + */ +class R3BSci2Cal2Hit : public FairTask +{ + + public: + /* + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BSci2Cal2Hit(); + + /* + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BSci2Cal2Hit(const char* name, Int_t iVerbose = 1); + + /* + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BSci2Cal2Hit(); + + /* + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + /* + * Method for re-initialization of parameter containers + * in case the Run ID has changed. + */ + virtual InitStatus ReInit(); + + /* + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /* + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /* + * Methods for setting position offset and effective velocity of light + */ + inline void SetSci2ParamMCFD(Double_t offsetX, Double_t veffX) + { + fsci2OffsetX = offsetX; + fsci2VeffX = veffX; + } + + + inline void SetSci2ParamTAMEX(Double_t offsetXT, Double_t veffXT) + { + fsci2OffsetXT = offsetXT; + fsci2VeffXT = veffXT; + } + + + /* + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + private: + TClonesArray* fCalItems; /* < Array with Cal items - input data. */ + TClonesArray* fHitItems; /* < Array with Hit items - output data. */ + UInt_t fNofHitItems; /* < Number of hit items for cur event. */ + Double_t fClockFreq; /* < Clock cycle in [ns]. */ + Double_t fsci2VeffX; + Double_t fsci2OffsetX; + Double_t fsci2OffsetXT; + Double_t fsci2VeffXT; + + TClonesArray* fMapped; /* < Array with mapped data - input data. */ + + TH1F* fhTres_M; + TH1F* fhTres_T; + TH1F* fhQ; + + TH2F* fhQ_L; + TH2F* fhQ_R; + TH2F* fhQ_vs_X; + TH2F* fhQ1_vs_Q2; + + + + Int_t Icount=0; + + + public: + ClassDef(R3BSci2Cal2Hit, 1) +}; + +#endif + diff --git a/sci2/R3BSci2Mapped2Cal.cxx b/sci2/R3BSci2Mapped2Cal.cxx new file mode 100644 index 000000000..8b700a05a --- /dev/null +++ b/sci2/R3BSci2Mapped2Cal.cxx @@ -0,0 +1,348 @@ +// ------------------------------------------------------------ +// ----- R3BSci2Mapped2Cal ----- +// ----- Created December 6th 2019 by M. Heil ----- +// ------------------------------------------------------------ + +/* + * Following R3BLosMapped2Cal + */ + +#include "R3BSci2Mapped2Cal.h" + +#include "R3BEventHeader.h" +#include "R3BSci2MappedData.h" +#include "R3BTCalEngine.h" +#include "R3BTCalPar.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRunOnline.h" +#include "FairRuntimeDb.h" +#include "TH1F.h" +#include "TH2F.h" + +#include "TClonesArray.h" +#include "TMath.h" + +#define SCI2_COINC_WINDOW_V_NS 280 +#define SCI2_COINC_WINDOW_T_NS 50 // Same as VFTX, as leading and trailing times are separately treated +#define IS_NAN(x) TMath::IsNaN(x) + +R3BSci2Mapped2Cal::R3BSci2Mapped2Cal() + : FairTask("Sci2Tcal", 1) + , fMappedItems(NULL) + , fCalItems(new TClonesArray("R3BSci2CalData")) + , fNofCalItems(0) + , fNofTcalPars(0) + , fNofModules(0) + , fTcalPar(NULL) + , fTrigger(-1) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fNEvent(0) +{ +} + +R3BSci2Mapped2Cal::R3BSci2Mapped2Cal(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fMappedItems(NULL) + , fCalItems(new TClonesArray("R3BSci2CalData")) + , fNofCalItems(0) + , fNofTcalPars(0) + , fNofModules(0) + , fTcalPar(NULL) + , fTrigger(-1) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fNEvent(0) +{ +} + +R3BSci2Mapped2Cal::~R3BSci2Mapped2Cal() +{ + if (fCalItems) + { + delete fCalItems; + fCalItems = NULL; + fNofCalItems = 0; + } +} + +InitStatus R3BSci2Mapped2Cal::Init() +{ + fNofTcalPars = fTcalPar->GetNumModulePar(); + if (fNofTcalPars == 0) + { + LOG(ERROR) << "There are no TCal parameters in container Sci2TCalPar"; + return kFATAL; + } + + LOG(INFO) << "R3BSci2Mapped2Cal::Init : read " << fNofModules << " modules"; + + // try to get a handle on the EventHeader. EventHeader may not be + // present though and hence may be null. Take care when using. + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + LOG(fatal) << "FairRootManager not found"; + header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); + + // get access to Mapped data + fMappedItems = (TClonesArray*)mgr->GetObject("Sci2Mapped"); + + if (NULL == fMappedItems) + LOG(fatal) << "Branch Sci2Mapped not found"; + + // request storage of Cal data in output tree + mgr->Register("Sci2Cal", "Land", fCalItems, kTRUE); + fCalItems->Clear(); + + return kSUCCESS; +} + +// Note that the container may still be empty at this point. +void R3BSci2Mapped2Cal::SetParContainers() +{ + fTcalPar = (R3BTCalPar*)FairRuntimeDb::instance()->getContainer("Sci2TCalPar"); + if (!fTcalPar) + { + LOG(ERROR) << "Could not get access to Sci2TCalPar-Container."; + fNofTcalPars = 0; + return; + } +} + +InitStatus R3BSci2Mapped2Cal::ReInit() +{ + SetParContainers(); + return kSUCCESS; +} + +void R3BSci2Mapped2Cal::Exec(Option_t* option) +{ + // check for requested trigger (Todo: should be done globablly / somewhere else) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + + Int_t nHits = fMappedItems->GetEntriesFast(); + + for (Int_t ihit = 0; ihit < nHits; ihit++) // nHits = Nchannel_Sci2 * NTypes = 2 * 3 + { + + R3BSci2MappedData* hit = (R3BSci2MappedData*)fMappedItems->At(ihit); + if (!hit) + continue; + + // channel numbers are stored 1-based (1..n) + UInt_t iDet = hit->GetDetector(); // 1.. + UInt_t iCha = hit->GetChannel(); // 1.. + UInt_t iType = hit->GetType(); // 0,1,2 + + if ((iDet < 1) || (iDet > fNofDetectors)) + { + LOG(INFO) << "R3BSci2Mapped2Cal::Exec : Detector number out of range: " << iDet; + continue; + } + + // Fetch calib data for current channel + // new: + + R3BTCalModulePar* par = fTcalPar->GetModuleParAt(iDet, iCha, iType + 1); + + if (!par) + { + LOG(INFO) << "R3BSci2Mapped2Cal::Exec : Tcal par not found, Detector: " << iDet << ", Channel: " << iCha + << ", Type: " << iType; + continue; + } + + // Convert TDC to [ns] ... + + Double_t times_raw_ns = par->GetTimeVFTX(hit->GetTimeFine()); + + if (times_raw_ns < 0. || times_raw_ns > fClockFreq || IS_NAN(times_raw_ns)) + { + + LOG(INFO) << "R3BSci2Mapped2Cal::Exec : Bad time in ns: det= " << iDet << ", ch= " << iCha + << ", type= " << iType << ", time in channels = " << hit->GetTimeFine() + << ", time in ns = " << times_raw_ns; + continue; + } + + // ... and add clock time + Double_t times_ns = fClockFreq - times_raw_ns + hit->GetTimeCoarse() * fClockFreq; + + /* Note: we have multi-hit data... + * + * So the map needs to have one item per detector and (multi-)hit + * Then we need to establish a time window + * Here, we have the hits unsorted in time and channel. If we + * reconstruct a detector hit using a time window, So: + * + * For each single hit, search the list of detector hits. If a + * matching hit is found (dt < window and item not yet set), add + * item. Else create new detector hit. + * + * This way, we theoretically *might* end up with two calItems + * which are actually just one. Hm... this should be very rare. + * Care about that later if it becomes necessary. + * + */ + + // see if there is already a detector hit around that time + R3BSci2CalData* calItem = NULL; + + int iCal; + for (iCal = 0; iCal < fNofCalItems; iCal++) + { + R3BSci2CalData* aCalItem = (R3BSci2CalData*)fCalItems->At(iCal); + + if (aCalItem->GetDetector() != iDet) + { + // Do not consider an item for another detector. + continue; + } + + Double_t SCI2_COINC_WINDOW_NS; + Double_t Tdev; + Bool_t SCI2_COINC = false; + + if (iType == 0) + { + SCI2_COINC_WINDOW_NS = SCI2_COINC_WINDOW_V_NS; + Tdev = fabs(aCalItem->GetMeanTimeVFTX() - times_ns); + if (Tdev < SCI2_COINC_WINDOW_NS) + SCI2_COINC = true; + } + if (iType == 1) + { + SCI2_COINC_WINDOW_NS = SCI2_COINC_WINDOW_T_NS; + Tdev = fabs(aCalItem->GetMeanTimeTAMEXL() - times_ns); + if (Tdev < SCI2_COINC_WINDOW_NS && aCalItem->GetTAMEXLNcha() > 0) + SCI2_COINC = true; + if (IS_NAN(Tdev) && aCalItem->GetTAMEXLNcha() == 0) + SCI2_COINC = true; // First Tamex leading time + } + if (iType == 2) + { + SCI2_COINC_WINDOW_NS = SCI2_COINC_WINDOW_T_NS; + Tdev = fabs(aCalItem->GetMeanTimeTAMEXT() - times_ns); + if (Tdev < SCI2_COINC_WINDOW_NS && aCalItem->GetTAMEXTNcha() > 0) + SCI2_COINC = true; + if (IS_NAN(Tdev) && aCalItem->GetTAMEXTNcha() == 0) + SCI2_COINC = true; // First Tamex trailing time + } + + if (SCI2_COINC) + { + // check if item is already set. If so, we need to skip this event! + switch (iCha) + { + + case 0: + { + if (iType == 0 && !IS_NAN(aCalItem->fTimeV_r_ns)) + goto skip_event_pileup; + if (iType == 1 && !IS_NAN(aCalItem->fTimeL_r_ns)) + goto skip_event_pileup; + if (iType == 2 && !IS_NAN(aCalItem->fTimeT_r_ns)) + goto skip_event_pileup; + } + break; + case 1: + { + if (iType == 0 && !IS_NAN(aCalItem->fTimeV_l_ns)) + goto skip_event_pileup; + if (iType == 1 && !IS_NAN(aCalItem->fTimeL_l_ns)) + goto skip_event_pileup; + if (iType == 2 && !IS_NAN(aCalItem->fTimeT_l_ns)) + goto skip_event_pileup; + } + break; + } + if (!calItem) + calItem = aCalItem; + } + } + if (!calItem) + { + // there is no detector hit with matching time. Hence, create a new one. + calItem = new ((*fCalItems)[fNofCalItems]) R3BSci2CalData(iDet); + fNofCalItems += 1; + } + // set the time to the correct cal item + if (iCha == 1) + { + + if (iType == 0) + { + calItem->fTimeV_r_ns = times_ns; + if (calItem->fTimeV_r_ns < 0. || IS_NAN(calItem->fTimeV_r_ns)) + LOG(INFO) << "Problem with fTimeV_r_ns: " << calItem->fTimeV_r_ns << " " << times_ns << " " + << endl; + } + + if (iType == 1) + { + calItem->fTimeL_r_ns = times_ns; + if (calItem->fTimeL_r_ns < 0. || IS_NAN(calItem->fTimeL_r_ns)) + LOG(INFO) << "Problem with fTimeL_r_ns: " << calItem->fTimeL_r_ns << " " << times_ns << " " + << endl; + } + + if (iType == 2) + { + calItem->fTimeT_r_ns = times_ns; + if (calItem->fTimeT_r_ns < 0. || IS_NAN(calItem->fTimeT_r_ns)) + LOG(INFO) << "Problem with fTimeT_r_ns: " << calItem->fTimeT_r_ns << " " << times_ns << " " + << endl; + } + } + + if (iCha == 2) + { + + if (iType == 0) + { + calItem->fTimeV_l_ns = times_ns; + if (calItem->fTimeV_l_ns < 0. || IS_NAN(calItem->fTimeV_l_ns)) + LOG(INFO) << "Problem with fTimeV_l_ns: " << calItem->fTimeV_l_ns << " " << times_ns << " " + << endl; + } + + if (iType == 1) + { + calItem->fTimeL_l_ns = times_ns; + if (calItem->fTimeL_l_ns < 0. || IS_NAN(calItem->fTimeL_l_ns)) + LOG(INFO) << "Problem with fTimeL_l_ns: " << calItem->fTimeL_l_ns << " " << times_ns << " " + << endl; + } + + if (iType == 2) + { + calItem->fTimeT_l_ns = times_ns; + if (calItem->fTimeT_l_ns < 0. || IS_NAN(calItem->fTimeT_l_ns)) + LOG(INFO) << "Problem with fTimeT_l_ns: " << calItem->fTimeT_l_ns << " " << times_ns << " " + << endl; + } + } + + continue; + skip_event_pileup: + LOG(WARNING) << "R3BSci2Mapped2Cal::Exec : " << fNEvent << " iCha: " << iCha << " iType: " << iType + << " iCal: " << iCal << " Skip event because of pileup."; + } + + ++fNEvent; +} + +void R3BSci2Mapped2Cal::FinishEvent() +{ + if (fCalItems) + { + fCalItems->Clear(); + fNofCalItems = 0; + } +} + +void R3BSci2Mapped2Cal::FinishTask() {} + +ClassImp(R3BSci2Mapped2Cal) diff --git a/sci2/R3BSci2Mapped2Cal.h b/sci2/R3BSci2Mapped2Cal.h new file mode 100644 index 000000000..aa788caf3 --- /dev/null +++ b/sci2/R3BSci2Mapped2Cal.h @@ -0,0 +1,144 @@ +// --------------------------------------------------------------- +// ----- R3BSci2Mapped2Cal ----- +// ----- Created August 6th 2019 by M. Heil ----- +// ----- Convert mapped data to time calibrated data ----- +// ----- Following R3BLosMapped2Cal ----- +// --------------------------------------------------------------- + + + +#ifndef R3BSCI2MAPPED2CAL +#define R3BSCI2MAPPED2CAL + +#include + +#include "FairTask.h" +#include "R3BSci2CalData.h" + +class TClonesArray; +class TH1F; +class TH2F; +class R3BTCalModulePar; +class R3BTCalPar; +class R3BEventHeader; + +/** + * An analysis task to apply TCAL calibration for NeuLAND. + * This class reads NeuLAND mapped items with TDC values and + * produces time items with time in [ns]. It requires TCAL + * calibration parameters, which are produced in a separate + * analysis run containing R3BSci2Mapped2CalFill task. + */ +class R3BSci2Mapped2Cal : public FairTask +{ + + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BSci2Mapped2Cal(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BSci2Mapped2Cal(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BSci2Mapped2Cal(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + /** + * Method for initialization of the parameter containers. + * Called by the framework prior to Init() method. + */ + virtual void SetParContainers(); + + /** + * Method for re-initialization of parameter containers + * in case the Run ID has changed. + */ + virtual InitStatus ReInit(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Method for setting the trigger value. + * @param trigger 1 - onspill, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) + { + fTrigger = trigger; + } + + /** + * Method for setting the number of NeuLAND modules. + * @param nPMTs a number of photomultipliers. + * @param n17 a number of channels with stop signal (17-th channel). + */ + inline void SetNofModules(Int_t nDets, Int_t nChs) + { + fNofDetectors = nDets; + fNofChannels = nChs; //=2 + fNofTypes = 3; + fNofModules = nChs * nDets * 3 ; + } + + private: + //std::map fMapPar; /**< Map for matching mdoule ID with parameter container. */ + TClonesArray* fMappedItems; /**< Array with mapped items - input data. */ + TClonesArray* fCalItems; /**< Array with cal items - output data. */ + Int_t fNofCalItems; /**< Number of produced time items per event. */ + Int_t Icounts_good = 0; + Int_t Icounts_tot = 0; + + R3BTCalPar* fTcalPar; /**< TCAL parameter container. */ + UInt_t fNofTcalPars; /**< Number of modules in parameter file. */ + + // check for trigger should be done globablly (somewhere else) + R3BEventHeader* header; /**< Event header. */ + Int_t fTrigger; /**< Trigger value. */ + + UInt_t fNofDetectors; /**< Number of detectors. */ + UInt_t fNofChannels; /**< Number of channels per detector. */ + UInt_t fNofTypes = 3; + UInt_t fNofModules; /**< Total number of channels. */ + Double_t fClockFreq; /**< Clock cycle in [ns]. */ + UInt_t fNEvent; + + public: + ClassDef(R3BSci2Mapped2Cal, 1) +}; + +#endif diff --git a/sci2/R3BSci2Mapped2CalPar.cxx b/sci2/R3BSci2Mapped2CalPar.cxx new file mode 100644 index 000000000..c32541373 --- /dev/null +++ b/sci2/R3BSci2Mapped2CalPar.cxx @@ -0,0 +1,185 @@ +// ---------------------------------------------------------------- +// ----- R3BSci2Mapped2CalPar (7ps VFTX) ----- +// ----- Created August 6th by M. Heil ----- +// ----- Following R3BLosMapped2CalPar ----- +// ---------------------------------------------------------------- + +/* Some notes: + * + * This file handles 7ps VFTX and TAMEX2, hence we have three times per channel. + * + */ + +#include "R3BSci2Mapped2CalPar.h" +#include "R3BEventHeader.h" +#include "R3BSci2MappedData.h" +#include "R3BTCalEngine.h" +#include "R3BTCalPar.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRtdbRun.h" +#include "FairRunIdGenerator.h" +#include "FairRuntimeDb.h" + +#include "TClonesArray.h" +#include "TF1.h" +#include "TH1F.h" +#include "math.h" + +#include +#include + +using namespace std; + +R3BSci2Mapped2CalPar::R3BSci2Mapped2CalPar() + : FairTask("R3BSci2Mapped2CalPar", 1) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fNofDetectors(0) + , fNofChannels(0) + , fNofTypes(0) + , fNEvents(0) + , fCal_Par(NULL) +{ +} + +R3BSci2Mapped2CalPar::R3BSci2Mapped2CalPar(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fNofDetectors(0) + , fNofChannels(0) + , fNofTypes(0) + , fNEvents(0) + , fCal_Par(NULL) +{ +} + +R3BSci2Mapped2CalPar::~R3BSci2Mapped2CalPar() +{ + if (fCal_Par) + { + delete fCal_Par; + } + if (fEngine) + { + delete fEngine; + } +} + +InitStatus R3BSci2Mapped2CalPar::Init() +{ + + for (UInt_t i = 0; i < 2; i++) + { + for (UInt_t k = 0; k < 3; k++) + { + Icount[i][k] = 0; + } + } + FairRootManager* rm = FairRootManager::Instance(); + if (!rm) + { + return kFATAL; + } + + header = (R3BEventHeader*)rm->GetObject("R3BEventHeader"); + // may be = NULL! + + fMapped = (TClonesArray*)rm->GetObject("Sci2Mapped"); + if (!fMapped) + { + return kFATAL; + } + + fCal_Par = (R3BTCalPar*)FairRuntimeDb::instance()->getContainer("Sci2TCalPar"); + fCal_Par->setChanged(); + + if (!fNofModules) + { + LOG(ERROR) << "R3BSci2Mapped2CalPar::Init() Number of modules not set. "; + return kFATAL; + } + + fEngine = new R3BTCalEngine(fCal_Par, fMinStats); + + return kSUCCESS; +} + +void R3BSci2Mapped2CalPar::Exec(Option_t* option) +{ + // test for requested trigger (if possible) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + + UInt_t nHits = fMapped->GetEntries(); + + // Loop over mapped hits + for (UInt_t i = 0; i < nHits; i++) + { + + R3BSci2MappedData* hit = (R3BSci2MappedData*)fMapped->At(i); + if (!hit) + { + continue; // should not happen + } + + // channel numbers are supposed to be 1-based (1..n) + UInt_t iDetector = hit->GetDetector() - 1; // now 0..n-1 + UInt_t iChannel = hit->GetChannel() - 1; // now 0..n-1 + UInt_t iType = hit->GetType(); // 0,1,2 + + if (iDetector > (fNofDetectors - 1)) + { + LOG(ERROR) << "R3BSci2Mapped2CalPar::Exec() : more detectors than expected! Det: " << (iDetector + 1) + << " allowed are 1.." << fNofDetectors; + continue; + } + if (iChannel > (fNofChannels - 1)) + { + LOG(ERROR) << "R3BSci2Mapped2CalPar::Exec() : more channels than expected! Channel: " << (iChannel + 1) + << " allowed are 1.." << fNofChannels; + continue; + } + + if (iType > (fNofTypes - 1)) + { + LOG(ERROR) << "R3BSci2Mapped2CalPar::Exec() : more time-types than expected! Type: " << iType + << " allowed are 0.." << (fNofTypes - 1); + continue; + } + + // Fill TAC histogram for VFTX and TAMEX + + Icount[iChannel][iType]++; + + fEngine->Fill(iDetector + 1, iChannel + 1, iType + 1, hit->GetTimeFine()); + } + + // Increment events + fNEvents += 1; +} + +void R3BSci2Mapped2CalPar::FinishEvent() {} + +void R3BSci2Mapped2CalPar::FinishTask() +{ + fEngine->CalculateParamVFTX(); + + fCal_Par->printParams(); + + for (UInt_t i = 0; i < 2; i++) + { + for (UInt_t k = 0; k < 3; k++) + { + if (Icount[i][k] > 0) + cout << "R3BSci2Mapped2CalPar::FinishTask Channel: " << i << ", Type: " << k + << ", Count: " << Icount[i][k] << endl; + } + } +} + +ClassImp(R3BSci2Mapped2CalPar) diff --git a/sci2/R3BSci2Mapped2CalPar.h b/sci2/R3BSci2Mapped2CalPar.h new file mode 100644 index 000000000..ca653d526 --- /dev/null +++ b/sci2/R3BSci2Mapped2CalPar.h @@ -0,0 +1,143 @@ +// ---------------------------------------------------------------- +// ----- Create time calib parameters for Sci2 via VFTX ----- +// ------ Created December 6th by M. Heil ----- +// ----- Following R3BLosMapped2CalPar ----- +// ---------------------------------------------------------------- + +#ifndef R3BSCI2MAPPED2CALPAR_H +#define R3BSCI2MAPPED2CALPAR_H + +#include "FairTask.h" + +class R3BTCalPar; +class TClonesArray; +class R3BEventHeader; +class R3BTCalEngine; + +/** + * An analysis task for TCAL calibration of NeuLAND Tamex data. + * This class fills TDC distribution for each Photomultiplier + * of the NeuLAND detector and calculates the calibration + * parameters using the R3BTCalEngine. + * @author D. Kresan + * @since September 7, 2015 + */ +class R3BSci2Mapped2CalPar : public FairTask +{ + + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BSci2Mapped2CalPar(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BSci2Mapped2CalPar(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BSci2Mapped2CalPar(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Method for setting the update rate for control histograms + * @param rate an update rate value (events). + */ + inline void SetUpdateRate(Int_t rate) + { + fUpdateRate = rate; + } + + /** + * Method for setting minimum required statistics per module. + * Only detector modules with number of entries in TDC + * distribution greater than minimum statistics will be + * calibrated. + * @param minStats a value of minimum statistics required. + */ + inline void SetMinStats(Int_t minStats) + { + fMinStats = minStats; + } + + /** + * Method for selecting events with certain trigger value. + * @param trigger 1 - onspill, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) + { + fTrigger = trigger; + } + + /** + * Method for setting number of SCI2 detectors and channels. + * @param nDets number of detectors. + * @param nCh number of channels per detector (4+master trigger?) + */ + inline void SetNofModules(Int_t nDets, Int_t nCh) + { + fNofDetectors = nDets; + fNofChannels = nCh; // = 2 + fNofTypes = 3; + fNofModules = nDets * nCh * 3 ; + } + + private: + Int_t fUpdateRate; /**< An update rate. */ + Int_t fMinStats; /**< Minimum statistics required per module. */ + Int_t fTrigger; /**< Trigger value. */ + Int_t Icount[2][3]{}; + + UInt_t fNofDetectors; /**< Number of detectors. */ + UInt_t fNofChannels; /**< Number of channels per detector. */ + UInt_t fNofTypes = 3; /**< Number of time-types per channel (VFTX, TAMEX leading/trailing). */ + UInt_t fNofModules; /**< Total number of modules (=edges) to calibrate */ + + Int_t fNEvents; /**< Event counter. */ + R3BTCalPar* fCal_Par; /**< Parameter container. */ + TClonesArray* fMapped; /**< Array with mapped data - input data. */ + R3BEventHeader* header; /**< Event header - input data. */ + + R3BTCalEngine* fEngine; /**< Instance of the TCAL engine. */ + + public: + ClassDef(R3BSci2Mapped2CalPar, 1) +}; + +#endif + diff --git a/sci2/Sci2LinkDef.h b/sci2/Sci2LinkDef.h new file mode 100644 index 000000000..f6aab4428 --- /dev/null +++ b/sci2/Sci2LinkDef.h @@ -0,0 +1,12 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class R3BSci2Mapped2Cal+; +#pragma link C++ class R3BSci2Mapped2CalPar+; +#pragma link C++ class R3BSci2Cal2Hit+; + +#endif + diff --git a/tcal/R3BTCalContFact.cxx b/tcal/R3BTCalContFact.cxx index 391cc706f..d52290d93 100644 --- a/tcal/R3BTCalContFact.cxx +++ b/tcal/R3BTCalContFact.cxx @@ -58,7 +58,8 @@ void R3BTCalContFact::setAllContainers() * them to the list of containers.*/ addContainer("LandTCalPar", "NeuLAND TCAL Calibration Parameters"); addContainer("LosTCalPar", "LOS TCAL Calibration Parameters"); - addContainer("RoluTCalPar", "LOS TCAL Calibration Parameters"); + addContainer("RoluTCalPar", "ROLU TCAL Calibration Parameters"); + addContainer("Sci2TCalPar", "SCI2 TCAL Calibration Parameters"); addContainer("Sci8TCalPar", "SCI8 TCAL Calibration Parameters"); addContainer("TofdTCalPar", "TOFD TCAL Calibration Parameters"); addContainer("StrawtubesTCalPar", "Strawtubes TCAL Calibration Parameters"); @@ -86,6 +87,7 @@ void R3BTCalContFact::setAllContainers() ADD_FIBER(Fi12, FI12); ADD_FIBER(Fi13, FI13); addContainer("PtofTCalPar", "PTOF TCAL Calibration Parameters"); + addContainer("Sci2TCalPar", "S2 TCAL Calibration Parameters"); addContainer("Sci8TCalPar", "S8 TCAL Calibration Parameters"); } @@ -102,6 +104,7 @@ FairParSet* R3BTCalContFact::createContainer(FairContainer* c) containerNames.push_back("LandTCalPar"); containerNames.push_back("LosTCalPar"); containerNames.push_back("RoluTCalPar"); + containerNames.push_back("Sci2TCalPar"); containerNames.push_back("Sci8TCalPar"); containerNames.push_back("TofdTCalPar"); containerNames.push_back("StrawtubesTCalPar"); @@ -129,6 +132,7 @@ FairParSet* R3BTCalContFact::createContainer(FairContainer* c) PUSH_FIBER(Fi12); PUSH_FIBER(Fi13); containerNames.push_back("PtofTCalPar"); + containerNames.push_back("Sci2TCalPar"); containerNames.push_back("Sci8TCalPar"); bool found = false; diff --git a/tcal/R3BTCalEngine.cxx b/tcal/R3BTCalEngine.cxx index 28807f130..d5f3aa92f 100644 --- a/tcal/R3BTCalEngine.cxx +++ b/tcal/R3BTCalEngine.cxx @@ -81,9 +81,19 @@ void R3BTCalEngine::Fill(Int_t plane, Int_t paddle, Int_t side, Int_t tdc) // - 1]->GetEntries(); } -void R3BTCalEngine::CalculateParamClockTDC() +void R3BTCalEngine::CalculateParamClockTDC(enum CTDCVariant a_variant) { - fClockFreq = 1. / CLOCK_TDC_MHZ * 1000.; + switch (a_variant) + { + case CTDC_8_12_FWD_250: + fClockFreq = 1000. / 250; + break; + case CTDC_16_BWD_150: + fClockFreq = 1000. / 150; + break; + default: + assert(0 && "Invalid CTDC variant!"); + } for (Int_t i = 0; i < N_PLANE_MAX; i++) { diff --git a/tcal/R3BTCalEngine.h b/tcal/R3BTCalEngine.h index a25ca6fe8..447eb0b46 100644 --- a/tcal/R3BTCalEngine.h +++ b/tcal/R3BTCalEngine.h @@ -19,9 +19,8 @@ #define MAX_TACQUILA_MODULE 20 // 0 .. 20 #define TACQUILA_NUM_GEOM ((MAX_TACQUILA_SAM + 1) * (MAX_TACQUILA_GTB + 1) * (MAX_TACQUILA_MODULE + 1)) -#define CLOCK_TDC_MHZ 250 #define TACQUILA_CLOCK_MHZ 40.002903 -#define VFTX_CLOCK_MHZ 200 +#define VFTX_CLOCK_MHZ 200 #include "R3BTCalPar.h" #include "TObject.h" @@ -41,6 +40,20 @@ class TH1F; class R3BTCalEngine : public TObject { public: + // CTDC variants. + enum CTDCVariant { + // To make sure the user doesn't just put a 0... + CTDC_INVALID = 0, + // 8..12 bins for fine time. + // Fine time forwards from last cycle. + // 250 Mhz. + CTDC_8_12_FWD_250, + // 16 bins for fine time. + // Fine time backwards from last cycle. + // 150 Mhz. + CTDC_16_BWD_150 + }; + /** * Standard constructor. * Creates instance of TCAL engine. To be used in @@ -70,7 +83,7 @@ class R3BTCalEngine : public TObject * electronics. Parameters will be automatically stored. * To be called from FinishTask() method of an analysis task. */ - void CalculateParamClockTDC(); + void CalculateParamClockTDC(enum CTDCVariant); /** * A method to calculate calibration parameters for Tacquila diff --git a/tof/CMakeLists.txt b/tof/CMakeLists.txt index 1eb4b2b6b..a87e8b89c 100644 --- a/tof/CMakeLists.txt +++ b/tof/CMakeLists.txt @@ -37,7 +37,9 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/tofData ${R3BROOT_SOURCE_DIR}/r3bdata/landData ${R3BROOT_SOURCE_DIR}/r3bdata/neulandData ${R3BROOT_SOURCE_DIR}/r3bdata/trackerData -${R3BROOT_SOURCE_DIR}/r3bdata/ptofData ) +${R3BROOT_SOURCE_DIR}/r3bdata/ptofData +${R3BROOT_SOURCE_DIR}/tracking +) include_directories( ${INCLUDE_DIRECTORIES}) include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) @@ -63,9 +65,13 @@ R3BTof2pDigitizer.cxx R3BTofdMapped2Cal.cxx R3BTofdMapped2CalPar.cxx R3BTofdCal2HitPar.cxx +R3BTofdCal2Histo.cxx +R3BTofdCal2HistoPar.cxx +R3BTofdChangePar.cxx R3BTofdCal2Hit.cxx R3BTofdHitModulePar.cxx R3BTofdHitPar.cxx +R3BTofdDigitizer.cxx R3BPtofMapped2CalPar.cxx R3BPtofMapped2Cal.cxx calibration/R3BPtofCal2HitPar.cxx diff --git a/tof/R3BTofdCal2Histo.cxx b/tof/R3BTofdCal2Histo.cxx new file mode 100644 index 000000000..16d781ff4 --- /dev/null +++ b/tof/R3BTofdCal2Histo.cxx @@ -0,0 +1,719 @@ +#include "R3BTofdCal2Histo.h" +#include "R3BEventHeader.h" +#include "R3BLosCalData.h" +#include "R3BLosMappedData.h" +#include "R3BTofdCalData.h" +#include "R3BTofdHitPar.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRtdbRun.h" +#include "FairRunIdGenerator.h" +#include "FairRuntimeDb.h" + +#include "TCanvas.h" +#include "TClonesArray.h" +#include "TF1.h" +#include "TFile.h" +#include "TGraph.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TProfile.h" +#include "TSpectrum.h" +#include "TVirtualFitter.h" + +#include +#include + +#define IS_NAN(x) TMath::IsNaN(x) +using namespace std; + +namespace +{ + double c_range_ns = 2048 * 5; + double c_bar_coincidence_ns = 20; // nanoseconds. +} // namespace + +R3BTofdCal2Histo::R3BTofdCal2Histo() + : FairTask("R3BTofdCal2Histo", 1) + , fCalItemsLos(NULL) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fTpat(-1) + , fNofPlanes(5) + , fPaddlesPerPlane(6) + , fNEvents(0) + , fCal_Par(NULL) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fTofdY(0.) + , fTofdQ(0.) + , fTofdZ(false) + , fParaFile("") +{ + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + fh_tofd_TotPm[i] = NULL; + fhTdiff[i] = NULL; + fhTsync[i] = NULL; + fhQPm1[i] = NULL; + fhQPm2[i] = NULL; + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + fhTotPm1[i][j] = NULL; + fhTotPm2[i][j] = NULL; + fhTot1vsTot2[i][j] = NULL; + fhTot1vsPos[i][j] = NULL; + fhTot2vsPos[i][j] = NULL; + fhSqrtQvsPos[i][j] = NULL; + fhQvsPos[i][j] = NULL; + } + } +} + +R3BTofdCal2Histo::R3BTofdCal2Histo(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fCalItemsLos(NULL) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fTpat(-1) + , fNofPlanes(5) + , fPaddlesPerPlane(6) + , fNEvents(0) + , fCal_Par(NULL) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fTofdY(0.) + , fTofdQ(0.) + , fTofdZ(0.) + , fParaFile("") + , maxevent(0) +{ + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + fh_tofd_TotPm[i] = NULL; + fhTdiff[i] = NULL; + fhTsync[i] = NULL; + fhQPm1[i] = NULL; + fhQPm2[i] = NULL; + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + fhTotPm1[i][j] = NULL; + fhTotPm2[i][j] = NULL; + fhTot1vsTot2[i][j] = NULL; + fhTot1vsPos[i][j] = NULL; + fhTot2vsPos[i][j] = NULL; + fhSqrtQvsPos[i][j] = NULL; + fhQvsPos[i][j] = NULL; + } + } +} + +R3BTofdCal2Histo::~R3BTofdCal2Histo() +{ + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + if (fh_tofd_TotPm[i]) + delete fh_tofd_TotPm[i]; + if (fhTdiff[i]) + delete fhTdiff[i]; + if (fhTsync[i]) + delete fhTsync[i]; + if (fhQPm1[i]) + delete fhQPm1[i]; + if (fhQPm2[i]) + delete fhQPm2[i]; + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + if (fhTotPm1[i][j]) + delete fhTotPm1[i][j]; + if (fhTotPm2[i][j]) + delete fhTotPm2[i][j]; + if (fhTot1vsTot2[i][j]) + delete fhTot1vsTot2[i][j]; + if (fhTot1vsPos[i][j]) + delete fhTot1vsPos[i][j]; + if (fhTot2vsPos[i][j]) + delete fhTot2vsPos[i][j]; + if (fhSqrtQvsPos[i][j]) + delete fhSqrtQvsPos[i][j]; + if (fhQvsPos[i][j]) + delete fhQvsPos[i][j]; + } + } + if (fCal_Par) + { + delete fCal_Par; + } +} + +InitStatus R3BTofdCal2Histo::Init() +{ + FairRootManager* rm = FairRootManager::Instance(); + if (!rm) + { + return kFATAL; + } + + header = (R3BEventHeader*)rm->GetObject("R3BEventHeader"); + // may be = NULL! + + fCalData = (TClonesArray*)rm->GetObject("TofdCal"); + if (!fCalData) + { + return kFATAL; + } + maxevent = rm->CheckMaxEventNo(); + + if (!fNofModules) + { + LOG(ERROR) << "R3BTofdCal2Histo::Init() Number of modules not set. "; + return kFATAL; + } + fCalItemsLos = (TClonesArray*)rm->GetObject("LosCal"); + if (NULL == fCalItemsLos) + LOG(fatal) << "Branch LosCal not found"; + return kSUCCESS; +} + +void R3BTofdCal2Histo::SetParContainers() +{ + // container needs to be created in tcal/R3BTCalContFact.cxx AND R3BTCal needs + // to be set as dependency in CMakelists.txt (in this case in the tof directory) + fCal_Par = (R3BTofdHitPar*)FairRuntimeDb::instance()->getContainer("TofdHitPar"); + if (!fCal_Par) + { + LOG(ERROR) << "R3BTofdCal2Histo::Init() Couldn't get handle on TofdHitPar. "; + } + // fCal_Par->setChanged(); +} + +void R3BTofdCal2Histo::Exec(Option_t* option) +{ + if (fNEvents / 10000. == (int)fNEvents / 10000) + std::cout << "Events: " << fNEvents << " / " << maxevent << " (" << (int)(fNEvents * 100. / maxevent) + << " %) \r" << std::flush; + + // test for requested trigger (if possible) + if ((fTrigger >= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + + // fTpat = 1-16; fTpat_bit = 0-15 + Int_t fTpat_bit = fTpat - 1; + if (fTpat_bit >= 0) + { + Int_t itpat = header->GetTpat(); + Int_t tpatvalue = (itpat & (1 << fTpat_bit)) >> fTpat_bit; + if ((header) && (tpatvalue == 0)) + return; + } + + Double_t timeLos = 0.; + Double_t time_r_V = 0.; + Double_t time_t_V = 0.; + Double_t time_l_V = 0.; + Double_t time_b_V = 0.; + Double_t time_rt_V = 0.; + Double_t time_lt_V = 0.; + Double_t time_lb_V = 0.; + Double_t time_rb_V = 0.; + + // Los detector + if (fCalItemsLos) + { + Int_t nHits = fCalItemsLos->GetEntriesFast(); + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + R3BLosCalData* calData = (R3BLosCalData*)fCalItemsLos->At(ihit); + Int_t iDet = calData->GetDetector(); + // Int_t iCha=calData->GetChannel(); + if (!(IS_NAN(calData->GetTimeV_ns(5)))) + time_r_V = calData->GetTimeV_ns(5); + if (!(IS_NAN(calData->GetTimeV_ns(7)))) + time_t_V = calData->GetTimeV_ns(7); + if (!(IS_NAN(calData->GetTimeV_ns(1)))) + time_l_V = calData->GetTimeV_ns(1); + if (!(IS_NAN(calData->GetTimeV_ns(3)))) + time_b_V = calData->GetTimeV_ns(3); + if (!(IS_NAN(calData->GetTimeV_ns(6)))) + time_rt_V = calData->GetTimeV_ns(6); + if (!(IS_NAN(calData->GetTimeV_ns(0)))) + time_lt_V = calData->GetTimeV_ns(0); + if (!(IS_NAN(calData->GetTimeV_ns(2)))) + time_lb_V = calData->GetTimeV_ns(2); + if (!(IS_NAN(calData->GetTimeV_ns(4)))) + time_rb_V = calData->GetTimeV_ns(4); + } + timeLos = (time_r_V + time_t_V + time_l_V + time_b_V + time_rt_V + time_lt_V + time_lb_V + time_rb_V) / 8.; + } + + // ToFD detector + std::vector> multihits(N_TOFD_HIT_PLANE_MAX, std::vector(N_TOFD_HIT_PADDLE_MAX)); + Int_t nHits = fCalData->GetEntries(); + // Organize cals into bars. + struct Entry + { + std::vector top; + std::vector bot; + }; + std::map bar_map; + for (Int_t ihit = 0; ihit < nHits; ihit++) + { + auto* hit = (R3BTofdCalData*)fCalData->At(ihit); + size_t idx = hit->GetDetectorId() * fPaddlesPerPlane * hit->GetBarId(); + // std::cout << "Hits: " << hit->GetDetectorId() << ' ' << hit->GetBarId() << ' ' << hit->GetSideId() << ' ' + // << hit->GetTimeLeading_ns() << ' ' << hit->GetTimeTrailing_ns() << '\n'; + auto ret = bar_map.insert(std::pair(idx, Entry())); + auto& vec = 1 == hit->GetSideId() ? ret.first->second.top : ret.first->second.bot; + vec.push_back(hit); + } + // Find coincident PMT hits. + // std::cout << "Print:\n"; + for (auto it = bar_map.begin(); bar_map.end() != it; ++it) + { + // for (auto it2 = it->second.top.begin(); it->second.top.end() != it2; ++it2) { + // std::cout << "Top: " << (*it2)->GetDetectorId() << ' ' << (*it2)->GetBarId() << ' ' << + // (*it2)->GetTimeLeading_ns() << '\n'; + //} + // for (auto it2 = it->second.bot.begin(); it->second.bot.end() != it2; ++it2) { + // std::cout << "Bot: " << (*it2)->GetDetectorId() << ' ' << (*it2)->GetBarId() << ' ' << + // (*it2)->GetTimeLeading_ns() << '\n'; + //} + auto const& top_vec = it->second.top; + auto const& bot_vec = it->second.bot; + size_t top_i = 0; + size_t bot_i = 0; + for (; top_i < top_vec.size() && bot_i < bot_vec.size();) + { + auto top = top_vec.at(top_i); + auto bot = bot_vec.at(bot_i); + auto top_ns = top->GetTimeLeading_ns(); + auto bot_ns = bot->GetTimeLeading_ns(); + auto dt = top_ns - bot_ns; + // Handle wrap-around. + auto dt_mod = fmod(dt + c_range_ns, c_range_ns); + if (dt < 0) + { + // We're only interested in the short time-differences, so we + // want to move the upper part of the coarse counter range close + // to the lower range, i.e. we cut the middle of the range and + // glue zero and the largest values together. + dt_mod -= c_range_ns; + } + // std::cout << top_i << ' ' << bot_i << ": " << top_ns << ' ' << bot_ns << " = " << dt << ' ' << + // std::abs(dt_mod) << '\n'; + if (std::abs(dt_mod) < c_bar_coincidence_ns) + { + // Hit! + // std::cout << "Hit!\n"; + Int_t iPlane = top->GetDetectorId(); // 1..n + Int_t iBar = top->GetBarId(); // 1..n + if (iPlane > fNofPlanes) // this also errors for iDetector==0 + { + LOG(ERROR) << "R3BTofdCal2HitPar::Exec() : more detectors than expected! Det: " << iPlane + << " allowed are 1.." << fNofPlanes; + continue; + } + if (iBar > fPaddlesPerPlane) // same here + { + LOG(ERROR) << "R3BTofdCal2HitPar::Exec() : more bars then expected! Det: " << iBar + << " allowed are 1.." << fPaddlesPerPlane; + continue; + } + auto top_tot = fmod(top->GetTimeTrailing_ns() - top->GetTimeLeading_ns() + c_range_ns, c_range_ns); + auto bot_tot = fmod(bot->GetTimeTrailing_ns() - bot->GetTimeLeading_ns() + c_range_ns, c_range_ns); + // register multi hits + multihits[iPlane - 1][iBar - 1] += 1; + /* + for(int i=0; iFill(bot_tot); + fhTotPm2[iPlane - 1][iBar - 1]->Fill(top_tot); + fhTot1vsTot2[iPlane - 1][iBar - 1]->Fill(top_tot, bot_tot); + fh_tofd_TotPm[iPlane - 1]->Fill(iBar, top_tot); + fh_tofd_TotPm[iPlane - 1]->Fill(-iBar - 1, bot_tot); + // Time differences of one paddle + fhTdiff[iPlane - 1]->Fill(iBar, tdiff); + // ToF + auto ToF = (top_ns + bot_ns) / 2 - timeLos; + while (ToF < -c_range_ns / 2) + ToF += c_range_ns; + while (ToF > c_range_ns / 2) + ToF -= c_range_ns; + fhTsync[iPlane - 1]->Fill(iBar, ToF); + } + else + { + // get parameter + R3BTofdHitModulePar* para = fCal_Par->GetModuleParAt(iPlane, iBar); + if (!para) + { + LOG(INFO) << "R3BTofdCal2Hit::Exec : Hit par not found, Plane: " << top->GetDetectorId() + << ", Bar: " << top->GetBarId(); + continue; + } + // calculate tdiff with offest + auto tdiff = (bot_ns + para->GetOffset1()) - (top_ns + para->GetOffset2()); + // walk corrections + bot_ns = bot_ns - walk(bot_tot); + top_ns = top_ns - walk(top_tot); + // create histograms + CreateHistograms(iPlane, iBar); + // fill control histograms + fhTotPm1[iPlane - 1][iBar - 1]->Fill(bot_tot); + fhTotPm2[iPlane - 1][iBar - 1]->Fill(top_tot); + fhTot1vsTot2[iPlane - 1][iBar - 1]->Fill(top_tot, bot_tot); + // Time differences of one paddle + fhTdiff[iPlane - 1]->Fill(iBar, tdiff); + // calculate time-of-flight + auto ToF = (bot_ns + top_ns) / 2. - timeLos - para->GetSync(); + while (ToF < -c_range_ns / 2) + ToF += c_range_ns; + while (ToF > c_range_ns / 2) + ToF -= c_range_ns; + // Sync of one plane + fhTsync[iPlane - 1]->Fill(iBar, ToF); + } + // prepare double exponential fit + if (fTofdQ != 0 && fTofdZ == false) + { + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(iPlane, iBar); + if (!par) + { + LOG(INFO) << "R3BTofdCal2Hit::Exec : Hit par not found, Plane: " << top->GetDetectorId() + << ", Bar: " << top->GetBarId(); + continue; + } + // calculate y position + Double_t Pos = ((bot_ns + par->GetOffset1()) - (top_ns + par->GetOffset2())) * par->GetVeff(); + // fill fitting histograms and smiley histogram + fhTot1vsPos[iPlane - 1][iBar - 1]->Fill(Pos, bot_tot); + fhTot2vsPos[iPlane - 1][iBar - 1]->Fill(Pos, top_tot); + fhSqrtQvsPos[iPlane - 1][iBar - 1]->Fill(Pos, sqrt(top_tot * bot_tot)); + } + // prepare charge fit + if (fTofdZ == true) + { + // get parameter + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(iPlane, iBar); + if (!par) + { + LOG(INFO) << "R3BTofdCal2Hit::Exec : Hit par not found, Plane: " << top->GetDetectorId() + << ", Bar: " << top->GetBarId(); + continue; + } + // calculate y position + auto pos = ((bot_ns + par->GetOffset1()) - (top_ns + par->GetOffset2())) * par->GetVeff(); + // calculate position independent charge + Double_t parq[4]; + parq[0] = par->GetPar1a(); + parq[1] = par->GetPar1b(); + parq[2] = par->GetPar1c(); + parq[3] = par->GetPar1d(); + auto q1 = + bot_tot / (parq[0] * (exp(-parq[1] * (pos + 100.)) + exp(-parq[2] * (pos + 100.))) + parq[3]); + parq[0] = par->GetPar2a(); + parq[1] = par->GetPar2b(); + parq[2] = par->GetPar2c(); + parq[3] = par->GetPar2d(); + auto q2 = + top_tot / (parq[0] * (exp(-parq[1] * (pos + 100.)) + exp(-parq[2] * (pos + 100.))) + parq[3]); + q1 = q1 * fTofdQ; + q2 = q2 * fTofdQ; + // fill smiley histogram + fhSqrtQvsPos[iPlane - 1][iBar - 1]->Fill(pos, sqrt(top_tot * bot_tot)); + // fill control histograms and Q vs Pos without multihits + if (multihits[iPlane - 1][iBar - 1] < 2 && (q1 > 0. && q2 > 0.)) + { + fhQvsPos[iPlane - 1][iBar - 1]->Fill(pos, (q1 + q2) / 2.); + fhQPm1[iPlane - 1]->Fill(iBar, q1); + fhQPm2[iPlane - 1]->Fill(iBar, q2); + } + } + ++top_i; + ++bot_i; + // Increment events + fNEvents += 1; + } + else if (dt < 0 && dt > -c_range_ns / 2) + { + ++top_i; + } + else + { + ++bot_i; + } + } + } +} + +void R3BTofdCal2Histo::CreateHistograms(Int_t iPlane, Int_t iBar) +{ + Double_t max_charge = 80.; + if (NULL == fhTdiff[iPlane - 1]) + { + char strName1[255]; + char strName2[255]; + sprintf(strName1, "Time_Diff_Plane_%d", iPlane); + sprintf(strName2, "Time Diff Plane %d", iPlane); + fhTdiff[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, 4000, -20., 20.); + fhTdiff[iPlane - 1]->GetXaxis()->SetTitle("Bar #"); + fhTdiff[iPlane - 1]->GetYaxis()->SetTitle("Time difference (PM1 - PM2) in ns"); + } + if (NULL == fhTsync[iPlane - 1]) + { + char strName[255]; + char strName2[255]; + sprintf(strName, "Time_Sync_Plane_%d", iPlane); + sprintf(strName2, "Time Sync Plane %d", iPlane); + fhTsync[iPlane - 1] = new TH2F(strName, strName2, 50, 0, 50, 10000, -10, 90.); + fhTsync[iPlane - 1]->GetXaxis()->SetTitle("Bar #"); + fhTsync[iPlane - 1]->GetYaxis()->SetTitle("ToF in ns"); + } + if (NULL == fh_tofd_TotPm[iPlane - 1]) + { + char strName[255]; + sprintf(strName, "Tofd_ToT_plane_%d", iPlane); + char strName2[255]; + sprintf(strName2, "Tofd ToT plane %d", iPlane); + fh_tofd_TotPm[iPlane - 1] = new TH2F(strName, strName2, 90, -45, 45, 3000, 0., 300.); + fh_tofd_TotPm[iPlane - 1]->GetXaxis()->SetTitle("Bar #"); + fh_tofd_TotPm[iPlane - 1]->GetYaxis()->SetTitle("ToT / ns"); + } + if (NULL == fhTotPm1[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "ToT_Plane_%d_Bar_%d_PM_1", iPlane, iBar); + fhTotPm1[iPlane - 1][iBar - 1] = new TH1F(strName, "", 300, 0., 300.); + fhTotPm1[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("ToT of PM1 in ns"); + fhTotPm1[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Counts"); + } + if (NULL == fhTotPm2[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "ToT_Plane_%d_Bar_%d_PM_2", iPlane, iBar); + fhTotPm2[iPlane - 1][iBar - 1] = new TH1F(strName, "", 300, 0., 300.); + fhTotPm2[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("ToT of PM2 in ns"); + fhTotPm2[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Counts"); + } + if (NULL == fhTot1vsTot2[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "Plane_%d_Bar_%d_ToT1vsToT2", iPlane, iBar); + fhTot1vsTot2[iPlane - 1][iBar - 1] = new TH2F(strName, "", 300, 0., 300., 300, 0., 300.); + fhTot1vsTot2[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("ToT of PM2 in ns"); + fhTot1vsTot2[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("ToT of PM1 in ns"); + } + if (NULL == fhTot1vsPos[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "Tot1_vs_Pos_Plane_%d_Bar_%d", iPlane, iBar); + if (iPlane < 3) + fhTot1vsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, 400, 0., 200.); + if (iPlane > 2) + fhTot1vsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, 400, 0., 200.); + fhTot1vsPos[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("ToT of PM2 in ns"); + fhTot1vsPos[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Tot of PM1 in ns"); + } + if (NULL == fhTot2vsPos[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "Tot2_vs_Pos_Plane_%d_Bar_%d", iPlane, iBar); + if (iPlane < 3) + fhTot2vsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, 400, 0., 200.); + if (iPlane > 2) + fhTot2vsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, 400, 0., 200.); + } + if (NULL == fhSqrtQvsPos[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "SqrtQ_vs_Pos_Plane_%d_Bar_%d", iPlane, iBar); + fhSqrtQvsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, max_charge * 10, 0., max_charge); + fhSqrtQvsPos[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("sqrt(PM1*PM2)"); + fhSqrtQvsPos[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("Position in cm"); + } + if (NULL == fhQvsPos[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "Q_vs_Pos_Plane_%d_Bar_%d", iPlane, iBar); + fhQvsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, max_charge * 50, 0., max_charge); + fhQvsPos[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Charge"); + fhQvsPos[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("Position in cm"); + } + if (NULL == fhQPm1[iPlane - 1]) + { + char strName1[255]; + sprintf(strName1, "Q_Plane_%d_PM_1", iPlane); + char strName2[255]; + sprintf(strName2, "Q Plane %d PM1", iPlane); + fhQPm1[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge * 50, 0., max_charge); + fhQPm1[iPlane - 1]->GetYaxis()->SetTitle("Charge PM1"); + fhQPm1[iPlane - 1]->GetXaxis()->SetTitle("Paddle number"); + } + if (NULL == fhQPm2[iPlane - 1]) + { + char strName1[255]; + sprintf(strName1, "Q_Plane_%d_PM_2", iPlane); + char strName2[255]; + sprintf(strName2, "Q Plane %d PM2", iPlane); + fhQPm2[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge * 50, 0., max_charge); + fhQPm2[iPlane - 1]->GetYaxis()->SetTitle("Charge PM2"); + fhQPm2[iPlane - 1]->GetXaxis()->SetTitle("Paddle number"); + } +} + +void R3BTofdCal2Histo::FinishEvent() +{ + if (fCalItemsLos) + { + fCalItemsLos->Clear(); + } +} + +void R3BTofdCal2Histo::FinishTask() +{ + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + if (fh_tofd_TotPm[i]) + fh_tofd_TotPm[i]->Write(); // control histogram for ToT + if (fhTsync[i]) + fhTsync[i]->Write(); // histogram for sync calculation + if (fhTdiff[i]) + fhTdiff[i]->Write(); // histogram for offset and veff calculation + if (fhQPm1[i]) + fhQPm1[i]->Write(); // histogram for charge fit PM1 + if (fhQPm2[i]) + fhQPm2[i]->Write(); // histogram for charge fit PM2 + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + if (fhTotPm1[i][j]) + fhTotPm1[i][j]->Write(); // control histogram ToT Pm1 + if (fhTotPm2[i][j]) + fhTotPm2[i][j]->Write(); // control histogram ToT Pm2 + if (fhTot1vsTot2[i][j]) + fhTot1vsTot2[i][j]->Write(); // control histogram ToT Pm1 vs ToT Pm2 + if (fhSqrtQvsPos[i][j]) + fhSqrtQvsPos[i][j]->Write(); // control histogram for charge correction + if (fhTot1vsPos[i][j]) + fhTot1vsPos[i][j]->Write(); // histogram for position dependence of charge 1 + if (fhTot2vsPos[i][j]) + fhTot2vsPos[i][j]->Write(); // histogram for position dependence of charge 2 + if (fhQvsPos[i][j]) + fhQvsPos[i][j]->Write(); // histogram for charge fit + } + } +} + +Double_t R3BTofdCal2Histo::walk(Double_t Q) +{ + Double_t y = 0; + Double_t par1, par2, par3, par4, par5; + Int_t voltage = 444; + /* if(voltage==444){ + par1= 1.179535e+01 ; + par2= 3.030475e-01 ; + par3= 3.213015e+02 ; + par4=-2.125546e-01 ; + par5= 3.812241e-04 ; + } + */ + if (voltage == 444) + { + par1 = 2.178871e+01; + par2 = -3.565959e-03; + par3 = 5.713045e+01; + par4 = 4.007571e-02; + par5 = -9.537515e-05; + } + if (voltage == 500) + { + par1 = 1.64344e+01; + par2 = 2.84000e-01; + par3 = 3.47659e+02; + par4 = -2.70050e-01; + par5 = 3.61515e-04; + } + if (voltage == 600) + { + par1 = 1.22606e+01; + par2 = 3.12697e-01; + par3 = 4.40109e+02; + par4 = -1.86328e-01; + par5 = 1.49519e-04; + } + y = -30.2 + par1 * TMath::Power(Q, par2) + par3 / Q + par4 * Q + par5 * Q * Q; + return y; +} + +Double_t R3BTofdCal2Histo::saturation(Double_t x) +{ + Double_t kor; + Int_t voltage = 600; + if (voltage == 600) + { + if (x < 173) + { + kor = 0.; + } + else if (x > 208) + { + kor = -1.73665e+03 + 2.82009e+01 * 208. - 1.53846e-01 * (208. * 208.) + 2.82425e-04 * (208. * 208. * 208.); + } + else + { + kor = -1.73665e+03 + 2.82009e+01 * x - 1.53846e-01 * (x * x) + 2.82425e-04 * (x * x * x); + } + } + if (voltage == 500) + { + if (x < 95.5) + { + kor = 0.; + } + else if (x > 124) + { + kor = 1.08 * x - 112.44; + } + else + { + kor = 643.257 - 16.7823 * x + 0.139822 * (x * x) - 0.000362154 * (x * x * x); + } + } + if (voltage == 700) + { + if (x < 198) + { + kor = 0.; + } + else if (x > 298) + { + kor = 0.21 * x - 45.54; + } + else + { + kor = -19067 + 383.93 * x - 3.05794 * (x * x) + 0.0120429 * (x * x * x) - 2.34619e-05 * (x * x * x * x) + + 1.81076e-08 * (x * x * x * x * x); + } + } + return kor; +} + +ClassImp(R3BTofdCal2Histo) diff --git a/tof/R3BTofdCal2Histo.h b/tof/R3BTofdCal2Histo.h new file mode 100644 index 000000000..ba4bde94d --- /dev/null +++ b/tof/R3BTofdCal2Histo.h @@ -0,0 +1,182 @@ +// ---------------------------------------------------------- +// ----- Create histograms for parameters for TOFD ----- +// ----- Mai 2016 from M.Heil ----- +// ----- July 2019 from Lukas Bott ----- +// ---------------------------------------------------------- + +#ifndef R3BTOFDCAL2HISTO_H +#define R3BTOFDCAL2HISTO_H + +#define N_TOFD_HIT_PLANE_MAX 4 +#define N_TOFD_HIT_PADDLE_MAX 44 + +#include "FairTask.h" +#include "R3BTCalEngine.h" +#include "TObject.h" + +class R3BTofdHitPar; +class TClonesArray; +class R3BEventHeader; +class TH1F; +class TH2F; + +#pragma link C++ class R3BTofdHitModulePar + ; +class R3BTofdCal2Histo : public FairTask +{ + + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BTofdCal2Histo(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BTofdCal2Histo(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BTofdCal2Histo(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + virtual void SetParContainers(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Method for setting the update rate for control histograms + * @param rate an update rate value (events). + */ + inline void SetUpdateRate(Int_t rate) { fUpdateRate = rate; } + + /** + * Method for setting minimum required statistics per module. + * Only detector modules with number of entries in TDC + * distribution greater than minimum statistics will be + * calibrated. + * @param minStats a value of minimum statistics required. + */ + inline void SetMinStats(Int_t minStats) { fMinStats = minStats; } + + /** + * Method for selecting events with certain trigger value. + * @param trigger 1 - onspill, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) { fTrigger = trigger; } + inline void SetTpat(Int_t tpat) { fTpat = tpat; } + + /** + * Method for setting number of LOS detectors and channels. + * @param nDets number of detectors. + * @param nCh number of channels per detector (4+master trigger?) + */ + inline void SetNofModules(Int_t nDets, Int_t nCh) + { + fNofPlanes = nDets; + fPaddlesPerPlane = nCh; + fNofModules = nDets * nCh * 1; // 1 edge per channel + } + /** + * Method for setting the y-position of a horizonzal sweep run for calibration of effective velocity of light + */ + inline void SetTofdPos(Double_t Y) { fTofdY = Y; } + /** + * Method for setting the nuclear charge of main beam + */ + inline void SetTofdQ(Double_t Q) { fTofdQ = Q; } + /** + * Method for setting charge correction + */ + inline void SetTofdZ(Bool_t Z) { fTofdZ = Z; } + /** + * Method for setting the y-position of a horizonzal sweep run for calibration of effective velocity of light + */ + inline void ReadParaFile(TString file) { fParaFile = file; } + /** + * Method for walk calculation. + */ + virtual Double_t walk(Double_t Q); + + /** + * Method for creating histograms. + */ + virtual void CreateHistograms(Int_t iPlane, Int_t iBar); + + /** + * Method for calculation of saturation. + */ + virtual Double_t saturation(Double_t x); + + private: + Int_t fUpdateRate; /**< An update rate. */ + Int_t fMinStats; /**< Minimum statistics required per module. */ + Int_t fTrigger; /**< Trigger value. */ + Int_t fTpat; + + UInt_t fNofPlanes; /**< Number of planes. */ + UInt_t fPaddlesPerPlane; /**< Number of bars per plane. */ + UInt_t fNofModules; /**< Total number of modules (=edges) to calibrate */ + + Int_t fNEvents; /**< Event counter. */ + R3BTofdHitPar* fCal_Par; /**< Parameter container. */ + TClonesArray* fCalItemsLos; /**< Array with cal items. */ + TClonesArray* fCalData; /**< Array with mapped data - input data. */ + R3BEventHeader* header; /**< Event header - input data. */ + Double_t fClockFreq; /**< Clock cycle in [ns]. */ + Double_t fTofdY; + Double_t fTofdQ; + Bool_t fTofdZ; + TString fParaFile; + Int_t maxevent; + + // arrays of control histograms + TH2F* fh_tofd_TotPm[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhTdiff[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhTsync[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhQPm1[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhQPm2[N_TOFD_HIT_PLANE_MAX]; + TH1F* fhTotPm1[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + TH1F* fhTotPm2[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + TH2F* fhTot1vsTot2[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + TH2F* fhTot1vsPos[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + TH2F* fhTot2vsPos[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + TH2F* fhSqrtQvsPos[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + TH2F* fhQvsPos[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; + + public: + ClassDef(R3BTofdCal2Histo, 1) +}; + +#endif diff --git a/tof/R3BTofdCal2HistoPar.cxx b/tof/R3BTofdCal2HistoPar.cxx new file mode 100644 index 000000000..8c8a9635e --- /dev/null +++ b/tof/R3BTofdCal2HistoPar.cxx @@ -0,0 +1,556 @@ +// ----------------------------------------------------- +// ----- R3BTofdCal2HistoPar ----- +// ----------------------------------------------------- + +/* Some notes: + * + * + */ + +#include "R3BTofdCal2HistoPar.h" +#include "R3BEventHeader.h" +#include "R3BLosCalData.h" +#include "R3BLosMappedData.h" +#include "R3BTofdCalData.h" +#include "R3BTofdHitPar.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRtdbRun.h" +#include "FairRunIdGenerator.h" +#include "FairRuntimeDb.h" + +#include "TCanvas.h" +#include "TClonesArray.h" +#include "TF1.h" +#include "TFile.h" +#include "TGraph.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TProfile.h" +#include "TSpectrum.h" +#include "TVirtualFitter.h" + +#include +#include +#include + +#include "TSystem.h" + +#define IS_NAN(x) TMath::IsNaN(x) +using namespace std; + +namespace +{ + double c_range_ns = 2048 * 5; + double c_bar_coincidence_ns = 20; // nanoseconds. +} // namespace + +TFile* hfilename; + +R3BTofdCal2HistoPar::R3BTofdCal2HistoPar() + : FairTask("R3BTofdCal2HistoPar", 1) + , fCalItemsLos(NULL) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fParameter(1) + , fNofPlanes(5) + , fPaddlesPerPlane(6) + , fNEvents(0) + , fCal_Par(NULL) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fTofdY(0.) + , fTofdQ(0.) + , fParaFile("") + , fHistoFile("") +{ +} + +R3BTofdCal2HistoPar::R3BTofdCal2HistoPar(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fCalItemsLos(NULL) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fParameter(1) + , fNofPlanes(5) + , fPaddlesPerPlane(6) + , fNEvents(0) + , fCal_Par(NULL) + , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , fTofdY(0.) + , fTofdQ(0.) + , fParaFile("") + , fHistoFile("") +{ +} + +R3BTofdCal2HistoPar::~R3BTofdCal2HistoPar() +{ + if (fCal_Par) + { + delete fCal_Par; + } +} + +InitStatus R3BTofdCal2HistoPar::Init() +{ + FairRootManager* rm = FairRootManager::Instance(); + if (!rm) + { + return kFATAL; + } + header = (R3BEventHeader*)rm->GetObject("R3BEventHeader"); + // may be = NULL! + fCalData = (TClonesArray*)rm->GetObject("TofdCal"); + if (!fCalData) + { + return kFATAL; + } + if (!fNofModules) + { + LOG(ERROR) << "R3BTofdCal2HistoPar::Init() Number of modules not set. "; + return kFATAL; + } + fCalItemsLos = (TClonesArray*)rm->GetObject("LosCal"); + if (NULL == fCalItemsLos) + LOG(fatal) << "Branch LosCal not found"; + LOG(INFO) << "Histo filename: " << fHistoFile; + hfilename = TFile::Open(fHistoFile); + if (hfilename == 0) + { + LOG(ERROR) << "Cannot open Histo file!"; + return kFATAL; + } + return kSUCCESS; +} + +void R3BTofdCal2HistoPar::SetParContainers() +{ + // container needs to be created in tcal/R3BTCalContFact.cxx AND R3BTCal needs + // to be set as dependency in CMakelists.txt (in this case in the tof directory) + fCal_Par = (R3BTofdHitPar*)FairRuntimeDb::instance()->getContainer("TofdHitPar"); + if (!fCal_Par) + { + LOG(ERROR) << "R3BTofdCal2HistoPar::Init() Couldn't get handle on TofdHitPar. "; + } + // fCal_Par->setChanged(); +} + +void R3BTofdCal2HistoPar::Exec(Option_t* option) {} + +void R3BTofdCal2HistoPar::FinishEvent() {} + +void R3BTofdCal2HistoPar::FinishTask() +{ + if (fParameter == 1) + { + // Determine time offset of the 2 PMTs of one paddle. This procedure + // assumes a sweep run in the middle of the ToF wall horizontally. + // Since all paddles are mounted vertically one can determine the offset. + // Half of the offset is added to PM1 and half to PM2. + LOG(WARNING) << "Calling function calcOffset"; + calcOffset(); + // Determine sync offset between paddles + LOG(WARNING) << "Calling function calcSync"; + calcSync(); + } + + if (fParameter == 2) + { + // Determine effective speed of light in [cm/s] for each paddle + LOG(WARNING) << "Calling function calcVeff"; + calcVeff(); + } + + if (fParameter == 3) + { + // calculation of position dependend charge + LOG(WARNING) << "Calling function doubleExp"; + Double_t para[4]; + Double_t min = -40.; // effective bar length + Double_t max = 40.; // effective bar length = 80 cm + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + if (hfilename->Get(Form("Tot1_vs_Pos_Plane_%i_Bar_%i", i + 1, j + 1))) + { + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(i + 1, j + 1); + doubleExp((TH2F*)hfilename->Get(Form("Tot1_vs_Pos_Plane_%i_Bar_%i", i + 1, j + 1)), min, max, para); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t veff = par->GetVeff(); + Double_t sync = par->GetSync(); + par->SetPar1a(para[0]); + par->SetPar1b(para[1]); + par->SetPar1c(para[2]); + par->SetPar1d(para[3]); + } + if (hfilename->Get(Form("Tot2_vs_Pos_Plane_%i_Bar_%i", i + 1, j + 1))) + { + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(i + 1, j + 1); + doubleExp((TH2F*)hfilename->Get(Form("Tot2_vs_Pos_Plane_%i_Bar_%i", i + 1, j + 1)), min, max, para); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t veff = par->GetVeff(); + Double_t sync = par->GetSync(); + par->SetPar2a(para[0]); + par->SetPar2b(para[1]); + par->SetPar2c(para[2]); + par->SetPar2d(para[3]); + } + } + } + fCal_Par->setChanged(); + } + + if (fParameter == 4) + { + // Z correction for each plane + LOG(WARNING) << "Calling function zcorr"; + Double_t para[8]; + Double_t pars[3]; + Int_t min = 1, max = 15; // select range for peak search + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + if (hfilename->Get(Form("Q_vs_Pos_Plane_%i_Bar_%i", i + 1, j + 1))) + { + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(i + 1, j + 1); + zcorr((TH2F*)hfilename->Get(Form("Q_vs_Pos_Plane_%i_Bar_%i", i + 1, j + 1)), min, max, pars); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t veff = par->GetVeff(); + Double_t sync = par->GetSync(); + para[0] = par->GetPar1a(); + para[1] = par->GetPar1b(); + para[2] = par->GetPar1c(); + para[3] = par->GetPar1d(); + para[4] = par->GetPar2a(); + para[5] = par->GetPar2b(); + para[6] = par->GetPar2c(); + para[7] = par->GetPar2d(); + cout << "Write parameter: " << pars[0] << " " << pars[1] << " " << pars[2] << endl; + par->SetPar1za(pars[0]); + par->SetPar1zb(pars[1]); + par->SetPar1zc(pars[2]); + } + } + } + fCal_Par->setChanged(); + } +} + +void R3BTofdCal2HistoPar::calcOffset() +{ + TCanvas* cOffset = new TCanvas("cOffset", "cOffset", 10, 10, 1000, 900); + cOffset->Divide(2, 2); + R3BTofdHitModulePar* mpar; + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + if (hfilename->Get(Form("Time_Diff_Plane_%i", i + 1))) + { + LOG(WARNING) << "Found histo Time_Diff_Plane_" << i + 1; + auto* h = (TH2F*)hfilename->Get(Form("Time_Diff_Plane_%i", i + 1))->Clone(); + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + mpar = new R3BTofdHitModulePar(); + Double_t offset = 0.; + cOffset->cd(i + 1); + h->Draw("colz"); + TH1F* histo_py = (TH1F*)h->ProjectionY("histo_py", j + 2, j + 2, ""); + Double_t veff = mpar->GetVeff(); + Int_t binmax = histo_py->GetMaximumBin(); + Double_t Max = histo_py->GetXaxis()->GetBinCenter(binmax); + TF1* fgaus = new TF1("fgaus", "gaus(0)", Max - 0.3, Max + 0.3); + histo_py->Fit("fgaus", "QR0"); + offset = fgaus->GetParameter(1); // histo_py->GetXaxis()->GetBinCenter(binmax); + LOG(WARNING) << " Plane " << i + 1 << " Bar " << j + 1 << " Offset " << offset; + mpar->SetPlane(i + 1); + mpar->SetPaddle(j + 1); + mpar->SetOffset1(-offset / 2.); + mpar->SetOffset2(offset / 2.); + // mpar->SetVeff(veff); + fCal_Par->AddModulePar(mpar); + } + } + } + fCal_Par->setChanged(); +} + +void R3BTofdCal2HistoPar::calcSync() +{ + TCanvas* cSync = new TCanvas("cSync", "cSync", 10, 10, 1000, 900); + cSync->Divide(2, 2); + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + if (hfilename->Get(Form("Time_Sync_Plane_%i", i + 1))) + { + LOG(WARNING) << "Found histo Time_Sync_Plane_" << i + 1; + auto* h = (TH2F*)hfilename->Get(Form("Time_Sync_Plane_%i", i + 1))->Clone(); + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + cSync->cd(i + 1); + h->Draw("colz"); + auto* histo_py = (TH1F*)h->ProjectionY("histo_py", j + 2, j + 2, ""); + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(i + 1, j + 1); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Int_t binmax = histo_py->GetMaximumBin(); + Double_t Max = histo_py->GetXaxis()->GetBinCenter(binmax); + Double_t MaxEntry = histo_py->GetBinContent(binmax); + TF1* fgaus = new TF1("fgaus", "gaus(0)", Max - 0.3, Max + 0.3); + fgaus->SetParameters(MaxEntry, Max, 20); + histo_py->Fit("fgaus", "QR0"); + Double_t sync = fgaus->GetParameter(1); // histo_py->GetXaxis()->GetBinCenter(binmax); + par->SetOffset1(offset1); + par->SetOffset2(offset2); + par->SetSync(sync); + LOG(WARNING) << " Plane " << i + 1 << " Bar " << j + 1 << " Sync " << sync; + } + } + } + fCal_Par->setChanged(); +} + +void R3BTofdCal2HistoPar::calcVeff() +{ + TCanvas* cVeff = new TCanvas("cVeff", "cVeff", 10, 10, 1000, 900); + cVeff->Divide(2, 2); + for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + { + for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) + { + Double_t max = 0.; + Double_t veff = 7.; + if (hfilename->Get(Form("Time_Diff_Plane_%i", i + 1))) + { + LOG(WARNING) << "Found histo Time_Diff_Plane_" << i + 1; + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(i + 1, j + 1); + if (!par) + { + LOG(INFO) << "Hit par not found, Plane: " << i + 1 << ", Bar: " << j + 1; + continue; + } + auto* h = (TH2F*)hfilename->Get(Form("Time_Diff_Plane_%i", i + 1))->Clone(); + cVeff->cd(i + 1); + h->Draw("colz"); + TH1F* histo_py = (TH1F*)h->ProjectionY("histo_py", j + 2, j + 2, ""); + Int_t binmax = histo_py->GetMaximumBin(); + max = histo_py->GetXaxis()->GetBinCenter(binmax); + Double_t maxEntry = histo_py->GetBinContent(binmax); + auto* fgaus = new TF1("fgaus", "gaus(0)", max - 0.3, max + 0.3); + fgaus->SetParameters(maxEntry, max, 20); + histo_py->Fit("fgaus", "QR0"); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t sync = par->GetSync(); + max = fgaus->GetParameter(1) + offset1 - offset2; /// TODO: needs to be tested + // max = max+offset1-offset2; + veff = fTofdY / max; // effective speed of light in [cm/s] + LOG(WARNING) << " Plane " << i + 1 << " Bar " << j + 1 << " offset " << par->GetOffset1(); + LOG(WARNING) << " Plane " << i + 1 << " Bar " << j + 1 << " max " << max; + LOG(WARNING) << " Plane " << i + 1 << " Bar " << j + 1 << " veff " << veff; + par->SetVeff(veff); + } + } + } + fCal_Par->setChanged(); +} + +void R3BTofdCal2HistoPar::doubleExp(TH2F* histo, Double_t min, Double_t max, Double_t* para) +{ + // This fits the exponential decay of the light in a paddle. The 2 PMTs are fit with the same function but one + // side will deliver negative attenuation parameters and the other positive. + Double_t y[1000], x[1000]; + Int_t n = 0; + for (Int_t j = 0; j <= 3; j++) + { + para[j] = 0; + } + TGraph* gr1 = new TGraph(); + TGraph* gr2 = new TGraph(); + TCanvas* cfit_exp = new TCanvas("cfit_exp", "fit exponential", 100, 100, 800, 800); + cfit_exp->Clear(); + cfit_exp->Divide(1, 3); + cfit_exp->cd(1); + TH2F* histo1 = (TH2F*)histo->Clone(); + TH2F* histo2 = (TH2F*)histo->Clone(); + histo1->Draw("colz"); + cfit_exp->cd(2); + for (Int_t i = 1; i < histo1->GetNbinsX() - 1; i++) + { + TH1F* histo_py = (TH1F*)histo1->ProjectionY("histo_py", i, i, ""); + histo_py->Draw(); + x[n] = histo1->GetXaxis()->GetBinCenter(i); + Int_t binmax = histo_py->GetMaximumBin(); + y[n] = histo_py->GetXaxis()->GetBinCenter(binmax); + if ((x[n] < -40. || x[n] > 40.) || y[n] < 50.) + { + delete histo_py; + continue; + } + if (histo_py->GetMaximum() > 5) + n++; + delete histo_py; + } + gr1 = new TGraph(n, x, y); + gr1->Draw("A*"); + TF1* f1 = new TF1("f1", "[0]*(exp(-[1]*(x+100.))+exp(-[2]*(x+100.)))+[3]", min, max); + f1->SetParameters(520., 0.001, 17234, -485.); + f1->SetLineColor(2); + gr1->Fit("f1", "", "", min, max); + for (Int_t j = 0; j <= 3; j++) + { + para[j] = f1->GetParameter(j); + cout << "Parameter: " << para[j] << endl; + } + // fit again but with more information and better cuts + n = 0; + cfit_exp->cd(3); + for (Int_t i = 1; i < histo2->GetNbinsX(); i++) + { + Double_t pos = histo2->GetXaxis()->GetBinCenter(i); + Double_t ymean = para[0] * (exp(-para[1] * (pos + 100.)) + exp(-para[2] * (pos + 100.))) + para[3]; + histo2->SetAxisRange(ymean - 5., ymean + 5., "Y"); + histo2->Draw("colz"); + TH1F* histo_py = (TH1F*)histo2->ProjectionY("histo_py", i, i, ""); + histo_py->Draw(); + x[n] = histo2->GetXaxis()->GetBinCenter(i); + Int_t binmax = histo_py->GetMaximumBin(); + y[n] = histo_py->GetXaxis()->GetBinCenter(binmax); + if (histo_py->GetMaximum() > 2) + n++; + delete histo_py; + } + gr2 = new TGraph(n, x, y); + gr2->Draw("A*"); + TF1* f2 = new TF1("f2", "[0]*(exp(-[1]*(x+100.))+exp(-[2]*(x+100.)))+[3]", min, max); + f2->SetParameters(para[0], para[1], para[2], para[3]); + f2->SetLineColor(2); + gr2->Fit("f2", "", "", min, max); + for (Int_t j = 0; j <= 3; j++) + { + para[j] = f2->GetParameter(j); + cout << "Parameter: " << para[j] << endl; + } + cfit_exp->Update(); + // gPad->WaitPrimitive(); + // gSystem->Sleep(3000); + delete gr1; + delete gr2; + delete f1; + delete f2; +} + +void R3BTofdCal2HistoPar::zcorr(TH2F* histo, Int_t min, Int_t max, Double_t* pars) +{ + Double_t par[3000] = { 0 }; + Int_t maxplane = 1, maxbar = 44, nPeaks = 180; + Double_t x[3000] = { 0 }; + TCanvas* c1 = new TCanvas("c1", "c1", 100, 100, 800, 800); + c1->Divide(1, 3); + c1->cd(1); + auto* h = (TH2F*)histo->Clone(); + h->Draw("colz"); + h->SetAxisRange(min, max, "Y"); + // Projection of charge axis + auto* h1 = h->ProjectionY("p_y"); + c1->cd(2); + h1->Draw(); + // Use TSpectrum to find the peak candidates + TSpectrum* s = new TSpectrum(nPeaks); + Int_t nfound = s->Search(h1, 1, "", 0.005); // lower threshold than default 0.05 + std::cout << "Found " << nfound << " candidate peaks to fit\n"; + c1->Update(); + // Eliminate background peaks + nPeaks = 0; + Double_t* xpeaks = s->GetPositionX(); + for (Int_t p = 0; p <= nfound; p++) + { + Float_t xp = xpeaks[p]; + Int_t bin = h1->GetXaxis()->FindBin(xp); + Float_t yp = h1->GetBinContent(bin); + if (yp - TMath::Sqrt(yp) < 1.) + continue; + par[2 * nPeaks] = yp; + par[2 * nPeaks + 1] = xp; + nPeaks++; + } + if (nPeaks < 2) + return; + + Double_t peaks[nPeaks]; + + for (Int_t i = 0; i < nPeaks; i++) + { + // printf("Found peak @ %f\n",xpeaks[i]); + peaks[i] = par[2 * i + 1]; + } + c1->Update(); + + // select useful peaks + sort(peaks, peaks + nPeaks); + Double_t zpeaks[3000] = { 0 }; + string doagain = "y"; + Int_t nfp; + do + { + nfp = 0; + for (Int_t i = 0; i < nPeaks; i++) + { + std::cout << "Peak @ " << peaks[i]; + Int_t z = 0; + while ((std::cout << " corresponds to Z=") && !(std::cin >> z)) + { + std::cout << "That's not a number;"; + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + } + if (z == 0) + continue; + x[nfp] = (Double_t)z; + zpeaks[nfp] = peaks[i]; + // cout<<"z real " << x[nfp] << " z found " << zpeaks[nfp] <> doagain; + } while (doagain != "n"); + if (nfp < 2) + { + delete s; + delete c1; + return; + } + // fit charge axis + std::cout << "Selected " << nfp << " useful peaks to fit\nStart fitting...\n"; + auto* gr1 = new TGraph(); + TF1* fitz = new TF1("fitz", "[0]*TMath::Power(x,[2])+[1]", min, max); + fitz->SetParameters(1.5, 2., .1); + c1->cd(3); + gr1 = new TGraph(nfp, zpeaks, x); + gr1->Draw("A*"); + gr1->Fit("fitz", "Q", "", min, max); + // write parameters + std::cout << "Optimise the fit, double click to finish\n"; + gPad->WaitPrimitive(); + auto* fitzr = gr1->GetFunction("fitz"); + for (Int_t j = 0; j < 3; j++) + { + pars[j] = fitzr->GetParameter(j); + // std::cout<WaitPrimitive(); + gSystem->Sleep(3000); + delete s; + delete gr1; + delete c1; + delete fitz; +} + +ClassImp(R3BTofdCal2HistoPar) diff --git a/tof/R3BTofdCal2HistoPar.h b/tof/R3BTofdCal2HistoPar.h new file mode 100644 index 000000000..e60e5a795 --- /dev/null +++ b/tof/R3BTofdCal2HistoPar.h @@ -0,0 +1,176 @@ +// ---------------------------------------------------------- +// ----- Create hit parameters for TOFD ----- +// ---------------------------------------------------------- + +#ifndef R3BTOFDCAL2HISTOPAR_H +#define R3BTOFDCAL2HISTOPAR_H + +#define N_TOFD_HIT_PLANE_MAX 4 +#define N_TOFD_HIT_PADDLE_MAX 44 + +#include "FairTask.h" +#include "R3BTCalEngine.h" +#include "TObject.h" + +class R3BTofdHitPar; +class TClonesArray; +class R3BEventHeader; +class TH1F; +class TH2F; + +#pragma link C++ class R3BTofdHitModulePar + ; +class R3BTofdCal2HistoPar : public FairTask +{ + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BTofdCal2HistoPar(); + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BTofdCal2HistoPar(const char* name, Int_t iVerbose = 1); + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BTofdCal2HistoPar(); + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + virtual void SetParContainers(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Method for setting the update rate for control histograms + * @param rate an update rate value (events). + */ + inline void SetUpdateRate(Int_t rate) { fUpdateRate = rate; } + + /** + * Method for setting minimum required statistics per module. + * Only detector modules with number of entries in TDC + * distribution greater than minimum statistics will be + * calibrated. + * @param minStats a value of minimum statistics required. + */ + inline void SetMinStats(Int_t minStats) { fMinStats = minStats; } + + /** + * Method for selecting events with certain trigger value. + * @param trigger 1 - onspill, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) { fTrigger = trigger; } + + /** + * Method for selecting a certain paramter calculation. + */ + inline void SetParameter(Int_t parameter) { fParameter = parameter; } + + /** + * Method for setting number of LOS detectors and channels. + * @param nDets number of detectors. + * @param nCh number of channels per detector (4+master trigger?) + */ + inline void SetNofModules(Int_t nDets, Int_t nCh) + { + fNofPlanes = nDets; + fPaddlesPerPlane = nCh; + fNofModules = nDets * nCh * 1; // 1 edge per channel + } + /** + * Method for setting the y-position of a horizonzal sweep run for calibration of effective velocity of light + */ + inline void SetTofdPos(Double_t Y) { fTofdY = Y; } + /** + * Method for setting the nuclear charge of main beam + */ + inline void SetTofdQ(Double_t Q) { fTofdQ = Q; } + /** + * + */ + inline void ReadParaFile(TString file) { fParaFile = file; } + /** + * + */ + inline void ReadHistoFile(TString file) { fHistoFile = file; } + + /** + * Method for calculation of offset. + */ + virtual void calcOffset(); + + /** + * Method for calculation of sync offset between paddles. + */ + virtual void calcSync(); + + /** + * Method for calculation of effective speed of light. + */ + virtual void calcVeff(); + + /** + * Method for calculation of position dependence of scintillator. + */ + virtual void doubleExp(TH2F* histo, Double_t min, Double_t max, Double_t*); + + /** + * Method for calculation of z correction. + */ + virtual void zcorr(TH2F* histo, Int_t min, Int_t max, Double_t*); + + private: + Int_t fUpdateRate; /**< An update rate. */ + Int_t fMinStats; /**< Minimum statistics required per module. */ + Int_t fTrigger; /**< Trigger value. */ + Int_t fParameter; /**< Parameter #. */ + + UInt_t fNofPlanes; /**< Number of planes. */ + UInt_t fPaddlesPerPlane; /**< Number of bars per plane. */ + UInt_t fNofModules; /**< Total number of modules (=edges) to calibrate */ + + Int_t fNEvents; /**< Event counter. */ + R3BTofdHitPar* fCal_Par; /**< Parameter container. */ + TClonesArray* fCalItemsLos; /**< Array with cal items. */ + TClonesArray* fCalData; /**< Array with mapped data - input data. */ + R3BEventHeader* header; /**< Event header - input data. */ + Double_t fClockFreq; /**< Clock cycle in [ns]. */ + Double_t fTofdY; + Double_t fTofdQ; + TString fParaFile; + TString fHistoFile; + + public: + ClassDef(R3BTofdCal2HistoPar, 1) +}; + +#endif diff --git a/tof/R3BTofdCal2Hit.cxx b/tof/R3BTofdCal2Hit.cxx index acbfc3d74..ced33d6fb 100644 --- a/tof/R3BTofdCal2Hit.cxx +++ b/tof/R3BTofdCal2Hit.cxx @@ -1,22 +1,11 @@ -/****************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2019 Members of R3B Collaboration * - * * - * This software is distributed under the terms of the * - * GNU General Public Licence (GPL) version 3, * - * copied verbatim in the file "LICENSE". * - * * - * In applying this license GSI does not waive the privileges and immunities * - * granted to it by virtue of its status as an Intergovernmental Organization * - * or submit itself to any jurisdiction. * - ******************************************************************************/ - // ------------------------------------------------------------ // ----- R3BTofdCal2Hit ----- -// ----- Created May 2016 by M.Heil ----- +// ----- Created May 2016 by M.Heil ----- +// ----- Modified Dec 2019 by L.Bott ----- // ------------------------------------------------------------ #include "R3BTofdCal2Hit.h" +#include "R3BEventHeader.h" #include "R3BLosCalData.h" #include "R3BLosHitData.h" #include "R3BTCalEngine.h" @@ -55,25 +44,26 @@ R3BTofdCal2Hit::R3BTofdCal2Hit() , fNofHitPars(0) , fHitPar(NULL) , fTrigger(-1) + , fTpat(-1) , fNofPlanes(5) , fPaddlesPerPlane(6) , fTofdQ(1) , fnEvents(0) , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.) + , maxevent(0) { fhxy = NULL; fhCharge = NULL; + fhTimeP = NULL; fhChargevsTof = NULL; fhChargevsPos = NULL; fhQp12 = NULL; fhQp34 = NULL; - // fhSaturation1 = NULL; // fhSaturation2 = NULL; fhLosXYP = NULL; fhChargeLosTofD = NULL; fh_los_pos = NULL; - for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) { /* @@ -83,24 +73,25 @@ R3BTofdCal2Hit::R3BTofdCal2Hit() fhTotPm1Sat[i] = NULL; fhTotPm2Sat[i] = NULL; */ - fhQPm1[i] = NULL; - fhQPm2[i] = NULL; + // fhQPm1[i] = NULL; + // fhQPm2[i] = NULL; fhQ[i] = NULL; - - fhTdiff[i] = NULL; - fhSync[i] = NULL; - fhTof[i] = NULL; - + fhQM[i] = NULL; + fhMvsQ[i] = NULL; + // fhTdiff[i] = NULL; + // fhTsync[i] = NULL; + // fhTof[i] = NULL; + fhTdvsQ[i] = NULL; for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) { - fhQvsPos[i][j] = NULL; - + // fhQvsTp[i][2*j] = NULL; + // fhQvsTp[i][2*j+1] = NULL; /* fhQ1vsPos[i][j] = NULL; fhQ2vsPos[i][j] = NULL; - fhSqrtQvsPos[i][j] = NULL; */ + // fhSqrtQvsPos[i][j] = NULL; /* fhTotPm1vsTotPm2[i][j] = NULL; fhTotPm1satvsTotPm2sat[i][j] = NULL; @@ -109,9 +100,12 @@ R3BTofdCal2Hit::R3BTofdCal2Hit() */ fhTdiffvsQ[i][2 * j] = NULL; fhTdiffvsQ[i][2 * j + 1] = NULL; + fhQp12vsTdiff[2 * j] = NULL; + fhQp12vsTdiff[2 * j + 1] = NULL; fhQvsQ[i][2 * j] = NULL; fhQvsQ[i][2 * j + 1] = NULL; - fhQvsTof[i][j] = NULL; + // fhQvsTof[i][j] = NULL; + // fhQvsTofw[i][j] = NULL; } } } @@ -126,6 +120,7 @@ R3BTofdCal2Hit::R3BTofdCal2Hit(const char* name, Int_t iVerbose) , fNofHitPars(0) , fHitPar(NULL) , fTrigger(-1) + , fTpat(-1) , fNofPlanes(5) , fPaddlesPerPlane(6) , fTofdQ(1) @@ -134,6 +129,7 @@ R3BTofdCal2Hit::R3BTofdCal2Hit(const char* name, Int_t iVerbose) { fhxy = NULL; fhCharge = NULL; + fhTimeP = NULL; fhChargevsTof = NULL; fhChargevsPos = NULL; fhQp12 = NULL; @@ -144,7 +140,6 @@ R3BTofdCal2Hit::R3BTofdCal2Hit(const char* name, Int_t iVerbose) fhLosXYP = NULL; fhChargeLosTofD = NULL; fh_los_pos = NULL; - for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) { /* @@ -154,24 +149,25 @@ R3BTofdCal2Hit::R3BTofdCal2Hit(const char* name, Int_t iVerbose) fhTotPm1Sat[i] = NULL; fhTotPm2Sat[i] = NULL; */ - fhQPm1[i] = NULL; - fhQPm2[i] = NULL; + // fhQPm1[i] = NULL; + // fhQPm2[i] = NULL; fhQ[i] = NULL; - - fhTdiff[i] = NULL; - fhSync[i] = NULL; - fhTof[i] = NULL; - + fhQM[i] = NULL; + fhMvsQ[i] = NULL; + // fhTdiff[i] = NULL; + // fhTsync[i] = NULL; + // fhTof[i] = NULL; + fhTdvsQ[i] = NULL; for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) { - fhQvsPos[i][j] = NULL; - + // fhQvsTp[i][2*j] = NULL; + // fhQvsTp[i][2*j+1] = NULL; /* fhQ1vsPos[i][j] = NULL; fhQ2vsPos[i][j] = NULL; - fhSqrtQvsPos[i][j] = NULL; */ + // fhSqrtQvsPos[i][j] = NULL; /* fhTotPm1vsTotPm2[i][j] = NULL; fhTotPm1satvsTotPm2sat[i][j] = NULL; @@ -180,9 +176,12 @@ R3BTofdCal2Hit::R3BTofdCal2Hit(const char* name, Int_t iVerbose) */ fhTdiffvsQ[i][2 * j] = NULL; fhTdiffvsQ[i][2 * j + 1] = NULL; + fhQp12vsTdiff[2 * j] = NULL; + fhQp12vsTdiff[2 * j + 1] = NULL; fhQvsQ[i][2 * j] = NULL; fhQvsQ[i][2 * j + 1] = NULL; - fhQvsTof[i][j] = NULL; + // fhQvsTof[i][j] = NULL; + // fhQvsTofw[i][j] = NULL; } } } @@ -201,7 +200,8 @@ R3BTofdCal2Hit::~R3BTofdCal2Hit() delete fhQp34; if (fhCharge) delete fhCharge; - + if (fhTimeP) + delete fhTimeP; // if (fhSaturation1) delete fhSaturation1; // if (fhSaturation2) delete fhSaturation2; if (fhLosXYP) @@ -210,8 +210,7 @@ R3BTofdCal2Hit::~R3BTofdCal2Hit() delete fhChargeLosTofD; if (fh_los_pos) delete fh_los_pos; - - for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + for (Int_t i = 0; i < fNofPlanes; i++) { /* if (fhPos[i]) delete fhPos[i]; @@ -220,35 +219,38 @@ R3BTofdCal2Hit::~R3BTofdCal2Hit() if (fhTotPm1Sat[i]) delete fhTotPm1[i]; if (fhTotPm2Sat[i]) delete fhTotPm2[i]; */ - if (fhQPm1[i]) - delete fhQPm1[i]; - if (fhQPm2[i]) - delete fhQPm2[i]; + // if (fhQPm1[i]) delete fhQPm1[i]; + // if (fhQPm2[i]) delete fhQPm2[i]; if (fhQ[i]) delete fhQ[i]; - - if (fhTdiff[i]) - delete fhTdiff[i]; - if (fhSync[i]) - delete fhSync[i]; - if (fhTof[i]) - delete fhTof[i]; - + if (fhQM[i]) + delete fhQM[i]; + if (fhMvsQ[i]) + delete fhMvsQ[i]; + // if (fhTdiff[i]) delete fhTdiff[i]; + // if (fhTsync[i]) delete fhTsync[i]; + // if (fhTof[i]) delete fhTof[i]; + if (fhTdvsQ[i]) + delete fhTdvsQ[i]; for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) { - if (fhQvsPos[i][j]) delete fhQvsPos[i][j]; - + // if (fhQvsTp[i][2*j]) delete fhQvsTp[i][2*j]; + // if (fhQvsTp[i][2*j+1]) delete fhQvsTp[i][2*j+1]; /* if (fhQ1vsPos[i][j]) delete fhQ1vsPos[i][j]; if (fhQ2vsPos[i][j]) delete fhQ2vsPos[i][j]; - if (fhSqrtQvsPos[i][j]) delete fhSqrtQvsPos[i][j]; */ + // if (fhSqrtQvsPos[i][j]) delete fhSqrtQvsPos[i][j]; if (fhTdiffvsQ[i][2 * j]) delete fhTdiffvsQ[i][2 * j]; if (fhTdiffvsQ[i][2 * j + 1]) delete fhTdiffvsQ[i][2 * j + 1]; + if (fhQp12vsTdiff[2 * j]) + delete fhQp12vsTdiff[2 * j]; + if (fhQp12vsTdiff[2 * j + 1]) + delete fhQp12vsTdiff[2 * j + 1]; /* if (fhTotPm1vsTotPm2[i][j]) delete fhTotPm1vsTotPm2[i][j]; if (fhTotPm1satvsTotPm2sat[i][j]) delete fhTotPm1satvsTotPm2sat[i][j]; @@ -259,8 +261,8 @@ R3BTofdCal2Hit::~R3BTofdCal2Hit() delete fhQvsQ[i][2 * j]; if (fhQvsQ[i][2 * j + 1]) delete fhQvsQ[i][2 * j + 1]; - if (fhQvsTof[i][j]) - delete fhQvsTof[i][j]; + // if (fhQvsTof[i][j]) delete fhQvsTof[i][j]; + // if (fhQvsTofw[i][j]) delete fhQvsTof[i][j]; } } if (fHitItems) @@ -279,34 +281,29 @@ InitStatus R3BTofdCal2Hit::Init() fNofHitPars = 0; return kFATAL; } - fNofHitPars = fHitPar->GetNumModulePar(); if (fNofHitPars == 0) { LOG(ERROR) << "There are no Hit parameters in container TofdHitPar"; return kFATAL; } - // get access to Cal data FairRootManager* mgr = FairRootManager::Instance(); if (NULL == mgr) LOG(fatal) << "FairRootManager not found"; - + header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); fCalItems = (TClonesArray*)mgr->GetObject("TofdCal"); if (NULL == fCalItems) LOG(fatal) << "Branch TofdCal not found"; - + maxevent = mgr->CheckMaxEventNo(); fCalItemsLos = (TClonesArray*)mgr->GetObject("LosCal"); if (NULL == fCalItemsLos) LOG(WARNING) << "Branch LosCal not found"; - fHitItemsLos = (TClonesArray*)mgr->GetObject("LosHit"); if (NULL == fHitItemsLos) LOG(WARNING) << "Branch LosHit not found"; - // request storage of Hit data in output tree mgr->Register("TofdHit", "Land", fHitItems, kTRUE); - return kSUCCESS; } @@ -330,35 +327,50 @@ InitStatus R3BTofdCal2Hit::ReInit() void R3BTofdCal2Hit::Exec(Option_t* option) { - if (fnEvents / 10000. == (int)fnEvents / 10000) - cout << "Events: " << fnEvents << " \r" << std::flush; - // cout<<"Event # :"<< fnEvents<= 0) && (header) && (header->GetTrigger() != fTrigger)) + return; + // fTpat = 1-16; fTpat_bit = 0-15 + Int_t fTpat_bit = fTpat - 1; + if (fTpat_bit >= 0) + { + Int_t itpat = header->GetTpat(); + Int_t tpatvalue = (itpat & (1 << fTpat_bit)) >> fTpat_bit; + if ((header) && (tpatvalue == 0)) + return; + } Double_t timeRef = 0.; Double_t timeLos = 0; + Double_t timeP0 = 0.; Double_t LosTresM = 0; Double_t LosQ = 0; Double_t xLosP = 1000; Double_t yLosP = 1000; Double_t randx; - - // Double_t t[N_TOFD_HIT_PLANE_MAX+1][N_TOFD_HIT_PADDLE_MAX*2+1],x[N_PLANE_MAX+1][N_PADDLE_MAX*2+1]; - Double_t t[N_TOFD_HIT_PLANE_MAX + 1][N_TOFD_HIT_PADDLE_MAX * 2 + 1], x[5][89]; - Double_t y[N_TOFD_HIT_PLANE_MAX + 1][N_TOFD_HIT_PADDLE_MAX * 2 + 1], Q[N_PLANE_MAX + 1][N_PADDLE_MAX * 2 + 1]; - Double_t Qbeta[N_PLANE_MAX + 1][N_PADDLE_MAX * 2 + 1]; - Double_t tof[N_TOFD_HIT_PLANE_MAX + 1][N_TOFD_HIT_PADDLE_MAX * 2 + 1]; + std::vector>> q; + std::vector>> tof; + std::vector>> x; + std::vector>> y; + UInt_t vmultihits[N_PLANE_MAX + 1][N_TOFD_HIT_PADDLE_MAX * 2 + 1]; for (Int_t i = 0; i <= fNofPlanes; i++) { - for (Int_t j = 0; j <= 2 * fPaddlesPerPlane; j++) + q.push_back(std::vector>()); + tof.push_back(std::vector>()); + x.push_back(std::vector>()); + y.push_back(std::vector>()); + for (Int_t j = 0; j <= 2 * N_TOFD_HIT_PADDLE_MAX; j++) { - t[i][j] = 0.; - tof[i][j] = 0.; - x[i][j] = 0.; - y[i][j] = 0.; - Q[i][j] = 0.; - Qbeta[i][j] = 0.; + vmultihits[i][j] = 0; + q[i].push_back(std::vector()); + tof[i].push_back(std::vector()); + x[i].push_back(std::vector()); + y[i].push_back(std::vector()); } } - if (fHitItemsLos) { Int_t nHits = fHitItemsLos->GetEntriesFast(); @@ -390,22 +402,17 @@ void R3BTofdCal2Hit::Exec(Option_t* option) } } } - /* if(fCalItemsLos) { Int_t nHits = fCalItemsLos->GetEntriesFast(); for (Int_t ihit = 0; ihit < nHits; ihit++) { - LOG(WARNING) << "LOS Ihit "<< ihit<<" "<At(ihit); timeLos=(calData->fTimeV_r_ns+calData->fTimeV_l_ns+calData->fTimeV_t_ns+calData->fTimeV_b_ns)/4.; LosTresM=(calData->fTimeV_r_ns+calData->fTimeV_l_ns)/2.-(calData->fTimeV_t_ns+calData->fTimeV_b_ns)/2.; - - LOG(WARNING) << "LOS MCFD "<< LosTresM<<" "<Fill((calData->fTimeV_r_ns-calData->fTimeV_l_ns+2.15)*5.3, (calData->fTimeV_b_ns-calData->fTimeV_t_ns+1.28)*5.2); // Xe: (2.15,5.3), (1.28,5.2) - if (NULL == fhLosTimeM ) { char strName[255]; @@ -424,20 +430,14 @@ void R3BTofdCal2Hit::Exec(Option_t* option) fhLosTimeM = new TH1F(strName, "", 4000, -2000., 2000.); } fhLosTimeM->Fill(LosTresM); - } } */ - // cout<<"new event!*************************************"< multPlane1(N_TOFD_HIT_PADDLE_MAX); - std::vector multPlane2(N_TOFD_HIT_PADDLE_MAX); - std::vector multPlane3(N_TOFD_HIT_PADDLE_MAX); - std::vector multPlane4(N_TOFD_HIT_PADDLE_MAX); + // std::cout<<"new event!*************************************\n"; Int_t nHits = fCalItems->GetEntries(); - + Int_t nHitsEvent = 0; // Organize cals into bars. struct Entry { @@ -449,10 +449,8 @@ void R3BTofdCal2Hit::Exec(Option_t* option) { auto* hit = (R3BTofdCalData*)fCalItems->At(ihit); size_t idx = hit->GetDetectorId() * fPaddlesPerPlane * hit->GetBarId(); - // std::cout << "Hits: " << hit->GetDetectorId() << ' ' << hit->GetBarId() << ' ' << hit->GetSideId() << ' ' // << hit->GetTimeLeading_ns() << ' ' << hit->GetTimeTrailing_ns() << '\n'; - auto ret = bar_map.insert(std::pair(idx, Entry())); auto& vec = 1 == hit->GetSideId() ? ret.first->second.top : ret.first->second.bot; vec.push_back(hit); @@ -462,6 +460,7 @@ void R3BTofdCal2Hit::Exec(Option_t* option) // std::cout << "Print:\n"; for (auto it = bar_map.begin(); bar_map.end() != it; ++it) { + reset: // for (auto it2 = it->second.top.begin(); it->second.top.end() != it2; ++it2) { // std::cout << "Top: " << (*it2)->GetDetectorId() << ' ' << (*it2)->GetBarId() << ' ' << // (*it2)->GetTimeLeading_ns() << '\n'; @@ -516,19 +515,19 @@ void R3BTofdCal2Hit::Exec(Option_t* option) auto bot_tot = fmod(bot->GetTimeTrailing_ns() - bot->GetTimeLeading_ns() + c_range_ns, c_range_ns); // register multi hits - if (iPlane == 1) - ++multPlane1.at(iBar - 1); // multihit of a given bar - if (iPlane == 2) - ++multPlane2.at(iBar - 1); // multihit of a given bar - if (iPlane == 3) - ++multPlane3.at(iBar - 1); // multihit of a given bar - if (iPlane == 4) - ++multPlane4.at(iBar - 1); // multihit of a given bar + // we increase the number of bars by a factor of 2 in order to compare planes with half bar width + // overlap + if (iPlane == 1 || iPlane == 3) + vmultihits[iPlane][iBar * 2 - 2] += 1; + if (iPlane == 2 || iPlane == 4) + vmultihits[iPlane][iBar * 2] += 1; + vmultihits[iPlane][iBar * 2 - 1] += 1; + + nHitsEvent += 1; // walk corrections bot_ns = bot_ns - walk(bot_tot); top_ns = top_ns - walk(top_tot); - R3BTofdHitModulePar* par = fHitPar->GetModuleParAt(iPlane, iBar); if (!par) { @@ -539,90 +538,147 @@ void R3BTofdCal2Hit::Exec(Option_t* option) // calculate tdiff auto tdiff = ((bot_ns + par->GetOffset1()) - (top_ns + par->GetOffset2())); - // calculate y-position - auto pos = ((bot_ns + par->GetOffset1()) - (top_ns + par->GetOffset2())) * par->GetVeff(); - - if (iPlane == 1 || iPlane == 3) - y[iPlane][iBar * 2 - 2] = pos; - if (iPlane == 2 || iPlane == 4) - y[iPlane][iBar * 2] = pos; - y[iPlane][iBar * 2 - 1] = pos; - // calculate time-of-flight if (timeLos == 0) LOG(WARNING) << "Los Time is zero! "; auto ToF = (bot_ns + top_ns) / 2. - timeLos - par->GetSync(); - while (ToF < -c_range_ns / 2) + if (timeP0 == 0.) + timeP0 = ToF; + + // Find first hit timeP0 + /// What to do here: + /// check if all ToF in one event are in a range of 3000ns (readout window) and shift times according to + /// that + /// + /// this is the first hit + /// I + /// e.g. 171; 9439; 179; 1117; 175 -->> 171+c_range_ns; 9439; 179+c_range_ns; 1117+c_range_ns; + /// 175+c_range_ns + /// I + /// this should be the first hit -> counter resets -> other hits follow + if (ToF - timeP0 < -3000.) + { ToF += c_range_ns; - while (ToF > c_range_ns / 2) - ToF -= c_range_ns; + } + if (ToF - timeP0 > 3000.) + { + timeP0 = ToF; + it = bar_map.begin(); + for (Int_t i = 0; i <= fNofPlanes; i++) + { + for (Int_t j = 0; j <= 2 * N_TOFD_HIT_PADDLE_MAX; j++) + { + tof[i][j].clear(); + x[i][j].clear(); + y[i][j].clear(); + q[i][j].clear(); + vmultihits[i][j] = 0; + nHitsEvent = 0; + } + } + LOG(WARNING) << "Found new first hit -> will reset"; + goto reset; /// TODO: how to do without goto? + } + // no LOS in s454: while(ToF < -c_range_ns/2) ToF += c_range_ns; + // no LOS in s454: while(ToF > c_range_ns/2) ToF -= c_range_ns; - // cout << "test " << timeLos << ' ' << ToF << ' ' << par->GetSync() << '\n'; + // we increase the number of bars by a factor of 2 in order to compare planes with half bar width + // overlap + if (iPlane == 1 || iPlane == 3) + tof[iPlane][iBar * 2 - 2].push_back(ToF); + if (iPlane == 2 || iPlane == 4) + tof[iPlane][iBar * 2].push_back(ToF); + tof[iPlane][iBar * 2 - 1].push_back(ToF); + // calculate y-position + auto pos = ((bot_ns + par->GetOffset1()) - (top_ns + par->GetOffset2())) * par->GetVeff(); + // we increase the number of bars by a factor of 2 in order to compare planes with half bar width + // overlap if (iPlane == 1 || iPlane == 3) - tof[iPlane][iBar * 2 - 2] = ToF; + y[iPlane][iBar * 2 - 2].push_back(pos); if (iPlane == 2 || iPlane == 4) - tof[iPlane][iBar * 2] = ToF; - tof[iPlane][iBar * 2 - 1] = ToF; + y[iPlane][iBar * 2].push_back(pos); + y[iPlane][iBar * 2 - 1].push_back(pos); // calculate x-position randx = (std::rand() / (float)RAND_MAX); + // we increase the number of bars by a factor of 2 in order to compare planes with half bar width + // overlap if (iPlane == 1 || iPlane == 3) - { - x[iPlane][iBar * 2 - 2] = iBar * 2.8 - 21. * 2.8 - 1.4 - 1.4 * randx; - x[iPlane][iBar * 2 - 1] = iBar * 2.8 - 21. * 2.8 - 1.4 * randx; - } - else if (iPlane == 2 || iPlane == 4) - { - x[iPlane][iBar * 2] = iBar * 2.8 - 21. * 2.8 + 1.4 - 1.4 * randx; - x[iPlane][iBar * 2 - 1] = iBar * 2.8 - 21. * 2.8 - 1.4 * randx; - } - + x[iPlane][iBar * 2 - 2].push_back(iBar * 2.8 - 21. * 2.8 - 1.4 - 1.4 * randx); + if (iPlane == 2 || iPlane == 4) + x[iPlane][iBar * 2].push_back(iBar * 2.8 - 21. * 2.8 + 1.4 - 1.4 * randx); + x[iPlane][iBar * 2 - 1].push_back(iBar * 2.8 - 21. * 2.8 - 1.4 * randx); // correct for position dependence and calculate nuclear charge Z Double_t para[4]; para[0] = par->GetPar1a(); para[1] = par->GetPar1b(); para[2] = par->GetPar1c(); para[3] = par->GetPar1d(); - auto q1 = bot_tot / (para[0] * (exp(-para[1] * (pos + 50)) + exp(-para[2] * (pos + 50.))) + para[3]); - + auto q1 = bot_tot / (para[0] * (exp(-para[1] * (pos + 100.)) + exp(-para[2] * (pos + 100.))) + para[3]); para[0] = par->GetPar2a(); para[1] = par->GetPar2b(); para[2] = par->GetPar2c(); para[3] = par->GetPar2d(); - auto q2 = top_tot / (para[0] * (exp(-para[1] * (pos + 50.)) + exp(-para[2] * (pos + 50.))) + para[3]); - + auto q2 = top_tot / (para[0] * (exp(-para[1] * (pos + 100.)) + exp(-para[2] * (pos + 100.))) + para[3]); q1 = q1 * fTofdQ; q2 = q2 * fTofdQ; - - if (iPlane == 1 || iPlane == 3) - Q[iPlane][iBar * 2 - 2] = (q1 + q2) / 2.; - if (iPlane == 2 || iPlane == 4) - Q[iPlane][iBar * 2] = (q1 + q2) / 2.; - Q[iPlane][iBar * 2 - 1] = (q1 + q2) / 2.; + Double_t parz[3]; + parz[0] = par->GetPar1za(); + parz[1] = par->GetPar1zb(); + parz[2] = par->GetPar1zc(); + + /* + std::cout<<"Charges in this event "< 0 && parz[2] > 0) + { + if (iPlane == 1 || iPlane == 3) + q[iPlane][iBar * 2 - 2].push_back(parz[0] * TMath::Power((q1 + q2) / 2., parz[2]) + parz[1]); + if (iPlane == 2 || iPlane == 4) + q[iPlane][iBar * 2].push_back(parz[0] * TMath::Power((q1 + q2) / 2., parz[2]) + parz[1]); + q[iPlane][iBar * 2 - 1].push_back(parz[0] * TMath::Power((q1 + q2) / 2., parz[2]) + parz[1]); + } + else + { + if (iPlane == 1 || iPlane == 3) + q[iPlane][iBar * 2 - 2].push_back((q1 + q2) / 2.); + if (iPlane == 2 || iPlane == 4) + q[iPlane][iBar * 2].push_back((q1 + q2) / 2.); + q[iPlane][iBar * 2 - 1].push_back((q1 + q2) / 2.); + } // fill control histograms CreateHistograms(iPlane, iBar); - fhTof[iPlane - 1]->Fill(iBar, ToF); - fhTdiff[iPlane - 1]->Fill(iBar, tdiff); - // fhSync[iPlane-1]->Fill(iBar,ToF); - fhQPm1[iPlane - 1]->Fill(iBar, q1); - fhQPm2[iPlane - 1]->Fill(iBar, q2); - fhQ[iPlane - 1]->Fill(iBar, (q1 + q2) / 2.); - // fhQ1vsPos[iPlane-1][iBar-1]->Fill(pos, q1); - // fhQ2vsPos[iPlane-1][iBar-1]->Fill(pos, q2); - fhQvsPos[iPlane - 1][iBar - 1]->Fill(pos, (q1 + q2) / 2.); - // fhSqrtQvsPos[iPlane-1][iBar-1]->Fill(pos, sqrt(tot1*tot2)); - // fhTot1vsPos[iPlane-1][iBar-1]->Fill(pos, tot1); - // fhTot2vsPos[iPlane-1][iBar-1]->Fill(pos, tot2); - fhQvsTof[iPlane - 1][iBar - 1]->Fill(ToF, (q1 + q2) / 2.); + // fhTof[iPlane-1]->Fill(iBar,ToF); + // fhTdiff[iPlane-1]->Fill(iBar,tdiff); + // fhTsync[iPlane-1]->Fill(iBar,ToF); + // fhQPm1[iPlane-1]->Fill(iBar,parz[0]*TMath::Power(q1,parz[2])+parz[1]);//q1); + // fhQPm2[iPlane-1]->Fill(iBar,parz[0]*TMath::Power(q2,parz[2])+parz[1]);//q2); + // fhQ1vsPos[iPlane-1][iBar-1]->Fill(pos, q1); + // fhQ2vsPos[iPlane-1][iBar-1]->Fill(pos, q2); + fhQvsPos[iPlane - 1][iBar - 1]->Fill( + pos, parz[0] * TMath::Power((q1 + q2) / 2., parz[2]) + parz[1]); //(q1 + q2)/2.); + // fhSqrtQvsPos[iPlane-1][iBar-1]->Fill(pos, sqrt(tot1*tot2)); + // fhTot1vsPos[iPlane-1][iBar-1]->Fill(pos, tot1); + // fhTot2vsPos[iPlane-1][iBar-1]->Fill(pos, tot2); + // fhQvsTof[iPlane-1][iBar-1]->Fill(ToF,parz[0]*TMath::Power((q1+q2)/2.,parz[2])+parz[1]);//(q1 + // + q2) / 2.); fhQvsTofw[iPlane-1][iBar-1]->Fill((bot_tot + top_tot) / 2.,ToF); //needed + // to get TOF w/o walk correction // Time reference in case on has the master signal in one of the TDC channels. // Not used at the moment. timeRef = 0; - new ((*fHitItems)[fNofHitItems++]) - R3BTofdHitData((top_ns + bot_ns) / 2, top->GetBarId(), pos, 1, 1, top_tot, 1); ++top_i; ++bot_i; } @@ -637,244 +693,305 @@ void R3BTofdCal2Hit::Exec(Option_t* option) } } - // Now, since all hits are analyzed we take the one with the largest - // charge in each plane and average them + // Now all hits in this event are analyzed - Double_t max_Z[5], max_t[5], max_x[5], max_y[5]; - Double_t maxmax_Z = 0.; - Double_t maxmax_t = 0.; - Double_t maxmax_x = 0.; - Double_t maxmax_y = 0.; - Double_t Qp12[fPaddlesPerPlane * 2 + 1]; // average of plane 1 and 2 - Double_t Qp34[fPaddlesPerPlane * 2 + 1]; // average of plane 3 and 4 - Int_t maxmax_plane = 0; - Int_t maxmax_bar = 0; - Int_t max_bar[5]; - Int_t hitBars[5]; + Double_t hit_coinc = 5.; // coincidence window for hits in one event in ns. physics says max 250 ps + Double_t maxChargeDiff = 80.; // maximum charge difference between two planes for averaged hits - // find hit with highest signal in each plane - for (Int_t i = 1; i <= fNofPlanes; i++) - { - max_Z[i] = 0.; - max_t[i] = 0; - max_bar[i] = 0; - max_x[i] = -1000.; - max_y[i] = -1000.; - hitBars[i] = 0; - for (Int_t j = 1; j < fPaddlesPerPlane * 2; j++) - { - if (i == fNofPlanes) - { - if (tof[i][j] > 0. && tof[i - 1][j] > 0. && Q[i][j] > 0.) - { - Double_t delta = tof[i][j] - tof[i - 1][j]; - Qbeta[i][j] = Q[i][j] + betaCorr(delta); - fhTdiffvsQ[i - 1][j - 1]->Fill(delta, Qbeta[i][j]); - Q[i][j] = Qbeta[i][j]; - } - } - else - { - if (tof[i][j] > 0. && tof[i + 1][j] > 0. && Q[i][j] > 0.) - { - Double_t delta = tof[i + 1][j] - tof[i][j]; - Qbeta[i][j] = Q[i][j] + betaCorr(delta); - fhTdiffvsQ[i - 1][j - 1]->Fill(delta, Qbeta[i][j]); - Q[i][j] = Qbeta[i][j]; - } - } - if (Q[i][j] > 0. && Q[i + 1][j] > 0.) - { - /* Double_t v[2]; - v[0] = Q[1][j]; - v[1] = Q[i][j]; - fhQvsQ[i-1][j-1]->Fill(v);*/ - fhQvsQ[i - 1][j - 1]->Fill(Q[i + 1][j], Q[i][j]); - } - if (Q[i][j] > 0. && Q[1][j] > 0. && i == fNofPlanes) - { - // if last plane use first plane instead - /* Double_t v[2]; - v[0] = Q[1][j]; - v[1] = Q[i][j]; - fhQvsQ[i-1][j-1]->Fill(v);*/ - fhQvsQ[i - 1][j - 1]->Fill(Q[1][j], Q[i][j]); - } + LOG(DEBUG) << "Hits in this event: " << nHitsEvent; - if (i == 1 && j == 40 && LosQ > 0.) - { - if (Q[i][j] > 0.) - fhChargeLosTofD->Fill(Q[i][j], LosQ); - } - // average plane 1 and 2 - if (i == 1 && Q[1][j] > 0 && Q[2][j] > 0 && abs(Q[1][j] - Q[2][j]) < 2.5) - { - Qp12[j] = (Q[1][j] + Q[2][j]) / 2.; - fhQp12->Fill(j, Qp12[j]); - } - // average plane 3 and 4 - if (i == 3 && Q[3][j] > 0 && Q[4][j] > 0 && abs(Q[3][j] - Q[4][j]) < 2.5) - { - Qp34[j] = (Q[3][j] + Q[4][j]) / 2.; - fhQp34->Fill(j, Qp34[j]); - } + // init arrays to store hits + Double_t tArrQ[2 * nHitsEvent + 1] = { -1. }; + Double_t tArrT[2 * nHitsEvent + 1] = { -1. }; + Double_t tArrX[2 * nHitsEvent + 1] = { -1. }; + Double_t tArrY[2 * nHitsEvent + 1] = { -1. }; + Double_t tArrP[2 * nHitsEvent + 1] = { -1. }; + Double_t tArrB[2 * nHitsEvent + 1] = { -1. }; + Bool_t tArrU[2 * nHitsEvent + 1] = { false }; - if (Q[i][j] > max_Z[i]) - { - max_t[i] = tof[i][j]; - max_x[i] = x[i][j]; - // cout << "TESTIT: " << x[0][j] << endl; - // printf("%d\n",x[0][j]); - max_y[i] = y[i][j]; - max_Z[i] = Q[i][j]; - max_bar[i] = j; - if (Q[i][j] > maxmax_Z) - { - maxmax_t = tof[i][j]; - maxmax_x = x[i][j]; - maxmax_y = y[i][j]; - maxmax_Z = Q[i][j]; - maxmax_plane = i; - maxmax_bar = j; + // order events for time + for (Int_t i = 1; i <= fNofPlanes; i++) + { // loop over planes i + for (Int_t j = 0; j < fPaddlesPerPlane * 2 + 1; j++) + { // loop over virtual paddles j + if (tof[i][j].empty() == false) + { // check paddle for entries + for (Int_t m = 0; m < tof[i][j].size(); m++) + { // loop over multihits m + Int_t p = 0; + if (tArrT[0] == -1.) + { // first entry + LOG(DEBUG) << "First entry " << i << " " << j; + tArrQ[0] = q[i][j].at(m); + tArrT[0] = tof[i][j].at(m); + tArrX[0] = x[i][j].at(m); + tArrY[0] = y[i][j].at(m); + tArrP[0] = i; + tArrB[0] = j; + } + else + { + if (tof[i][j].at(m) < tArrT[0]) + { // new first entry with smaller time + LOG(DEBUG) << "Insert new first " << i << " " << j; + insertX(2 * nHitsEvent, tArrQ, q[i][j].at(m), 1); + insertX(2 * nHitsEvent, tArrT, tof[i][j].at(m), 1); + insertX(2 * nHitsEvent, tArrX, x[i][j].at(m), 1); + insertX(2 * nHitsEvent, tArrY, y[i][j].at(m), 1); + insertX(2 * nHitsEvent, tArrP, i, 1); + insertX(2 * nHitsEvent, tArrB, j, 1); + } + else + { + while (tof[i][j].at(m) > tArrT[p] && tArrT[p] != 0.) + p++; // find insert position + + LOG(DEBUG) << "Will insert at " << p; + if (p > 0 && tof[i][j].at(m) > tArrT[p - 1] && tof[i][j].at(m) != tArrT[p]) + { // insert at right position + LOG(DEBUG) << "Insert at " << p << " " << i << " " << j; + insertX(2 * nHitsEvent, tArrQ, q[i][j].at(m), p + 1); + insertX(2 * nHitsEvent, tArrT, tof[i][j].at(m), p + 1); + insertX(2 * nHitsEvent, tArrX, x[i][j].at(m), p + 1); + insertX(2 * nHitsEvent, tArrY, y[i][j].at(m), p + 1); + insertX(2 * nHitsEvent, tArrP, i, p + 1); + insertX(2 * nHitsEvent, tArrB, j, p + 1); + } + else + { + if (tof[i][j].at(m) == tArrT[p]) + { // handle virtual bars + LOG(DEBUG) << "Insert virtual bar " << i << " " << j; + insertX(2 * nHitsEvent, tArrQ, q[i][j].at(m), p + 2); + insertX(2 * nHitsEvent, tArrT, tof[i][j].at(m), p + 2); + insertX(2 * nHitsEvent, tArrX, x[i][j].at(m), p + 2); + insertX(2 * nHitsEvent, tArrY, y[i][j].at(m), p + 2); + insertX(2 * nHitsEvent, tArrP, i, p + 2); + insertX(2 * nHitsEvent, tArrB, j, p + 2); + } + } + } + } } } } - - if (max_Z[i] > 0.) - { - hitBars[i]++; - } } - // average measurements of 4 planes + /* - maxmax_Z=max_Z[1]; - maxmax_x=max_x[1]; - maxmax_y=max_y[1]; - maxmax_t=max_t[1]; - maxmax_bar=max_bar[1]; - maxmax_plane=1; + if(tArrT[0]!=-1.){ + + for (Int_t a = 0; a < 2*nHitsEvent; a++) + std::cout << tArrQ[a] << " "; + std::cout << "\n"; + for (Int_t a = 0; a < 2*nHitsEvent; a++) + std::cout << tArrT[a] << " "; + std::cout << "\n"; + for (Int_t a = 0; a < 2*nHitsEvent; a++) + std::cout << tArrX[a] << " "; + std::cout << "\n"; + for (Int_t a = 0; a < 2*nHitsEvent; a++) + std::cout << tArrY[a] << " "; + std::cout << "\n"; + for (Int_t a = 0; a < 2*nHitsEvent; a++) + std::cout << tArrP[a] << " "; + std::cout << "\n"; + for (Int_t a = 0; a < 2*nHitsEvent; a++) + std::cout << tArrB[a] << " "; + std::cout << "\n"; + } */ - Double_t Z_ave = maxmax_Z; - Double_t x_ave = maxmax_x; - Double_t y_ave = maxmax_y; - Double_t t_ave = maxmax_t; - for (Int_t p = 1; p < 5; p++) - { - // only add to average if they have seen similar Q, otherwise a reaction took place or no hit - if (abs(maxmax_Z - max_Z[p]) < 2.5 && abs(maxmax_bar - max_bar[p]) < 2 && p != maxmax_plane) - { - Z_ave = (Z_ave + max_Z[p]) / 2.; - x_ave = (x_ave + max_x[p]) / 2.; - y_ave = (y_ave + max_y[p]) / 2.; - t_ave = (t_ave + max_t[p]) / 2.; - } - } + // Now we can analyze the hits in this event - if (Z_ave > 35. && Z_ave < 32.) - { - cout << "Average: " << Z_ave << endl; - cout << "p1: " << max_Z[1] << " p2: " << max_Z[2] << " p3: " << max_Z[3] << " p4: " << max_Z[4] << endl; + for (Int_t a = 0; a < 2 * nHitsEvent; a++) + { // loop over all hits + fhQ[((Int_t)tArrP[a]) - 1]->Fill(tArrB[a], tArrQ[a]); // charge per plane } - if (Z_ave > 0) - { - fhCharge->Fill(Z_ave); - fhxy->Fill(x_ave, y_ave); - fhChargevsTof->Fill(t_ave, Z_ave); - fhChargevsPos->Fill(maxmax_bar, Z_ave); - - // cout<<"Average: "<0.){ - // new ((*fHitItems)[fNofHitItems]) R3BTofdHitData(tof[2][j], x[2][j], y[2][j], Q[2][j], tof[2][j], Q[2][j], 1); - // fNofHitItems += 1; - // } + while (tArrT[ihit] < time0 + hit_coinc) + { // check if in coincidence window - if (Q[1][j] > 0. && Q[2][j] > 0.) - { /* - cout << x[1][j] << endl; - cout << y[1][j] << endl; - cout << (Q[1][j]+Q[2][j])/2. << endl; - cout << (tof[1][j]+tof[2][j])/2. << endl; - cout << tof[1][j] << endl; - - t_ave=(tof[1][j]+tof[2][j])/2.; - x_ave=(x[1][j]+x[2][j])/2.; - y_ave=(y[1][j]+y[2][j])/2.; - Z_ave=(Q[1][j]+Q[2][j])/2.; + std::cout<<"Used up hits in this coincidence window:\n"; + for(Int_t a=0; a<2*nHitsEvent; a++) + std::cout << tArrP[a] << " "; + std::cout << "\n"; + for(Int_t a=0; a<2*nHitsEvent; a++) + std::cout << tArrB[a] << " "; + std::cout << "\n"; + for(Int_t a=0; a<2*nHitsEvent; a++) + std::cout << tArrU[a] << " "; + std::cout << "\n"; */ - new ((*fHitItems)[fNofHitItems]) R3BTofdHitData((tof[1][j] + tof[2][j]) / 2., - (x[1][j] + x[2][j]) / 2., - (y[1][j] + y[2][j]) / 2., - (Q[1][j] + Q[2][j]) / 2., - (tof[1][j] + tof[2][j]) / 2., - (Q[1][j] + Q[2][j]) / 2., - 1); - fNofHitItems += 1; - // break; - } - else if (Q[1][j] > 0. && Q[2][j] < 0.001) + hitscoinc++; // number of hits in coincidence + + if (tArrP[ihit] == 1 && charge0 != tArrQ[ihit]) + fhQM[0]->Fill(charge0, tArrQ[ihit]); + if (tArrP[ihit] == 2 && charge0 != tArrQ[ihit]) + fhQM[1]->Fill(charge0, tArrQ[ihit]); + + LOG(DEBUG) << "Hit in coincidence window: " << tArrP[ihit] << " " << tArrB[ihit] << " " << tArrT[ihit] + << " " << tArrQ[ihit]; + + // try to average plane 1&2 + for (Int_t i = hitscoinc; i-- > 1;) + { // loop over hits in coincidence + if (hitscoinc > 0 && tArrP[ihit] != tArrP[ihit - i]) + { // check if planes differ + + // find overlapping virtualbars similar charge in both planes? bar wasn't used + // for other average? + if (tArrB[ihit - i] == tArrB[ihit] && abs(tArrQ[ihit - i] - tArrQ[ihit]) < maxChargeDiff && + tArrU[ihit] == false && tArrU[ihit - i] == false) + { + + LOG(DEBUG) << "Try to average " << tArrQ[ihit] << " " << tArrP[ihit] << " " << tArrB[ihit] + << " and " << tArrQ[ihit - i] << " " << tArrP[ihit - i] << " " << tArrB[ihit - i]; + + noaverage++; // number of averaged hits in this coincidence window + + sumQ += (tArrQ[ihit] + tArrQ[ihit - i]) / 2.; // average charges and add to sum + + tArrU[ihit] = tArrU[ihit - i] = true; // set involved bars as used + if ((ihit - i) % 2 != 0) + tArrU[ihit - (i + 1)] = true; // set the associated virtual bars of the used bars as used + else + tArrU[ihit - (i - 1)] = true; + if ((ihit - i) % 2 != 0) + tArrU[ihit + 1] = true; + else + tArrU[ihit - 1] = true; + + fhCharge->Fill((tArrQ[ihit] + tArrQ[ihit - i]) / 2.); // Fill charge histogram + if (((Int_t)tArrP[ihit]) == fNofPlanes) + fhQvsQ[((Int_t)tArrP[ihit]) - 1][((Int_t)tArrB[ihit]) - 1]->Fill( + tArrQ[ihit - i], tArrQ[ihit]); // Fill charge vs charge histogram + else + fhQvsQ[((Int_t)tArrP[ihit]) - 1][((Int_t)tArrB[ihit]) - 1]->Fill(tArrQ[ihit], + tArrQ[ihit - i]); + + // store average + new ((*fHitItems)[fNofHitItems++]) R3BTofdHitData((tArrT[ihit] + tArrT[ihit - i]) / 2., + (tArrX[ihit] + tArrX[ihit - i]) / 2., + (tArrY[ihit] + tArrY[ihit - i]) / 2., + (tArrQ[ihit] + tArrQ[ihit - i]) / 2., + abs(tArrT[ihit] - tArrT[ihit - i]), + (tArrQ[ihit] + tArrQ[ihit - i]) / 2., + 12); + } + + /* + std::cout<<"Used up averaged hits in this coincidence window:\n"; + for(Int_t a=0; a<2*nHitsEvent; a++) + std::cout << tArrU[a] << " "; + std::cout << "\n"; + */ + } + } + ihit++; + if (ihit >= 2 * nHitsEvent) + break; + } + if (noaverage > 0) { - // cout << " PLANE 1" << endl; - new ((*fHitItems)[fNofHitItems]) - R3BTofdHitData(tof[1][j], x[1][j], y[1][j], Q[1][j], tof[1][j], Q[1][j], 1); - fNofHitItems += 1; + // std::cout<Fill(sumQ, noaverage); // Fill histogram number of averaged hits vs summed up charge } + } - else if (Q[2][j] > 0. && Q[1][j] < 0.001) + for (Int_t hit = 0; hit < 2 * nHitsEvent; hit++) + { // loop over not averaged hits + if (tArrU[hit] == false) { - // cout << " PLANE 2" << endl; - new ((*fHitItems)[fNofHitItems]) - R3BTofdHitData(tof[2][j], x[2][j], y[2][j], Q[2][j], tof[2][j], Q[2][j], 1); - fNofHitItems += 1; + LOG(DEBUG) << "Single Hit for Plane " << tArrP[hit] << " " << tArrB[hit]; + tArrU[hit] = tArrU[hit + 1] = true; + if (tArrP[hit] == 1) + { + // store hits only seen in plane 1 + new ((*fHitItems)[fNofHitItems++]) R3BTofdHitData( + tArrT[hit], (tArrX[hit] + tArrX[hit + 1]) / 2., tArrY[hit], tArrQ[hit], 0., tArrQ[hit], 1); + } + if (tArrP[hit] == 2) + { + // store hits only seen in plane 2 + new ((*fHitItems)[fNofHitItems++]) R3BTofdHitData( + tArrT[hit], (tArrX[hit] + tArrX[hit]) / 2., tArrY[hit], tArrQ[hit], 0., tArrQ[hit], 2); + } + hit++; } } + /* + //std::cout<<"Used up hits in this event:\n"; + for(Int_t a=0; a<2*nHitsEvent; a++){ + //std::cout << tArrU[a] << " "; + if(tArrU[a]!=true)LOG(FATAL); + } + //std::cout << "\n"; + */ + LOG(DEBUG) << "------------------------------------------------------\n"; fnEvents++; } void R3BTofdCal2Hit::CreateHistograms(Int_t iPlane, Int_t iBar) { + Double_t max_charge = 80.; // create histograms if not already existing - + /* if (NULL == fhTdiff[iPlane - 1]) { char strName1[255]; char strName2[255]; sprintf(strName1, "Time_Diff_Plane_%d", iPlane); sprintf(strName2, "Time Diff Plane %d", iPlane); - fhTdiff[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, 400, -8., 8.); + fhTdiff[iPlane - 1] = new TH2F(strName1, strName2, 50,0,50,400, -8., 8.); fhTdiff[iPlane - 1]->GetXaxis()->SetTitle("Bar #"); fhTdiff[iPlane - 1]->GetYaxis()->SetTitle("Time difference (PM1 - PM2) in ns"); } + */ + /* + if (NULL == fhTsync[iPlane - 1]) + { + char strName[255]; + sprintf(strName, "Time_Sync_Plane_%d", iPlane); + fhTsync[iPlane - 1] = new TH2F(strName, "", 50,0,50,10000, -10, 90.); + fhTsync[iPlane - 1]->GetXaxis()->SetTitle("Bar #"); + fhTsync[iPlane - 1]->GetYaxis()->SetTitle("ToF in ns"); + } + */ + /* if (NULL == fhTof[iPlane - 1]) { char strName[255]; sprintf(strName, "ToF_Plane_%d", iPlane); - fhTof[iPlane - 1] = new TH2F(strName, "", 50, 0, 50, 40000, -200, 200.); + fhTof[iPlane - 1] = new TH2F(strName, "", 50,0,50,40000, -200, 200.); fhTof[iPlane - 1]->GetXaxis()->SetTitle("Bar #"); fhTof[iPlane - 1]->GetYaxis()->SetTitle("ToF in ns"); } + */ + + if (NULL == fhTdvsQ[iPlane - 1]) + { + char strName[255]; + sprintf(strName, "Tdiff_vs_Q_Plane_%d", iPlane); + fhTdvsQ[iPlane - 1] = new TH2F(strName, "", 30000, 0, 3000, max_charge * 10, 0, max_charge); + fhTdvsQ[iPlane - 1]->GetXaxis()->SetTitle("Tdiff particles in ns"); + fhTdvsQ[iPlane - 1]->GetYaxis()->SetTitle("Charge"); + } /* if (NULL == fhPos[iPlane - 1]) @@ -942,38 +1059,51 @@ void R3BTofdCal2Hit::CreateHistograms(Int_t iPlane, Int_t iBar) fhTot2vsPos[iPlane - 1][iBar - 1] = new TH2F(strName, "", 200, -100, 100, 200, 0., 200.); } */ - Double_t max_charge = 80.; - + /* if (NULL == fhQPm1[iPlane - 1]) { char strName1[255]; sprintf(strName1, "Q_Plane_%d_PM_1", iPlane); char strName2[255]; sprintf(strName2, "Q_Plane %d PM1", iPlane); - fhQPm1[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge * 10, 0., max_charge); + fhQPm1[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge*10, 0., max_charge); fhQPm1[iPlane - 1]->GetYaxis()->SetTitle("Charge PM1"); fhQPm1[iPlane - 1]->GetXaxis()->SetTitle("Paddle number"); } + */ + /* if (NULL == fhQPm2[iPlane - 1]) { char strName1[255]; sprintf(strName1, "Q_Plane_%d_PM_2", iPlane); char strName2[255]; sprintf(strName2, "Q_Plane %d PM2", iPlane); - fhQPm2[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge * 10, 0., max_charge); + fhQPm2[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge*10, 0., max_charge); fhQPm2[iPlane - 1]->GetYaxis()->SetTitle("Charge PM2"); fhQPm2[iPlane - 1]->GetXaxis()->SetTitle("Paddle number"); } - if (NULL == fhQ[iPlane - 1]) + */ + /* + if (NULL == fhQvsTof[iPlane - 1][iBar - 1]) { - char strName1[255]; - sprintf(strName1, "Q_Plane_%d", iPlane); - char strName2[255]; - sprintf(strName2, "Q_Plane %d ", iPlane); - fhQ[iPlane - 1] = new TH2F(strName1, strName2, 50, 0, 50, max_charge * 10, 0., max_charge); - fhQ[iPlane - 1]->GetYaxis()->SetTitle("Charge"); - fhQ[iPlane - 1]->GetXaxis()->SetTitle("Paddle number"); + char strName[255]; + sprintf(strName, "Q_vs_ToF_Plane_%d_Bar_%d", iPlane, iBar); + fhQvsTof[iPlane - 1][iBar - 1] = new TH2F(strName, "", 1000, -10, 40 , 1000, 0., max_charge); + fhQvsTof[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("ToF in ns"); + fhQvsTof[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Charge"); } + */ + /* + if (NULL == fhQvsTofw[iPlane - 1][iBar - 1]) + { + char strName[255]; + sprintf(strName, "Q_vs_ToF_Plane_%d_Bar_%d_w", iPlane, iBar); + fhQvsTofw[iPlane - 1][iBar - 1] = new TH2F(strName, "", 1000, 0., 200, 1000, -10, 40); + fhQvsTofw[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("Charge"); + fhQvsTofw[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("ToF in ns"); + } + */ + if (NULL == fhQvsPos[iPlane - 1][iBar - 1]) { char strName[255]; @@ -982,7 +1112,71 @@ void R3BTofdCal2Hit::CreateHistograms(Int_t iPlane, Int_t iBar) fhQvsPos[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Charge"); fhQvsPos[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("Position in cm"); } + if (NULL == fhQ[iPlane - 1]) + { + char strName1[255]; + sprintf(strName1, "Q_Plane_%d", iPlane); + char strName2[255]; + sprintf(strName2, "Q Plane %d ", iPlane); + fhQ[iPlane - 1] = new TH2F(strName1, strName2, 90, 0, 90, max_charge * 10, 0., max_charge); + fhQ[iPlane - 1]->GetYaxis()->SetTitle("Charge"); + fhQ[iPlane - 1]->GetXaxis()->SetTitle("Paddle number"); + } + // Multiplicity + if (NULL == fhQM[iPlane - 1]) + { + char strName1[255]; + sprintf(strName1, "QvsQt0_Plane_%d", iPlane); + char strName2[255]; + sprintf(strName2, "Q vs Q_time0 Plane %d ", iPlane); + fhQM[iPlane - 1] = + new TH2F(strName1, strName2, max_charge * 10, 0., max_charge, max_charge * 10, 0., max_charge); + fhQM[iPlane - 1]->GetYaxis()->SetTitle("Charge particle i"); + fhQM[iPlane - 1]->GetXaxis()->SetTitle("Charge first particle"); + } + if (NULL == fhMvsQ[iPlane - 1]) + { + char strName1[255]; + sprintf(strName1, "QvsHits_Plane_%d", iPlane); + char strName2[255]; + sprintf(strName2, "Q vs Hit # Plane %d ", iPlane); + fhMvsQ[iPlane - 1] = new TH2F(strName1, strName2, max_charge * 10, 0., max_charge, 20, 0., 20); + fhMvsQ[iPlane - 1]->GetYaxis()->SetTitle("Hits in both planes in coincidence window"); + fhMvsQ[iPlane - 1]->GetXaxis()->SetTitle("#sum Charge"); + } + /* + if (NULL == fhQvsTp[iPlane - 1][2*iBar - 2]) + { + char strName[255]; + sprintf(strName, "Q_vs_Tdiff_MultHit_Plane_%d_Bar_%d", iPlane, iBar*2-1); + fhQvsTp[iPlane - 1][iBar*2 - 2] = new TH2F(strName, "", 10240, 0., 10240/3.2, 500, 0., max_charge/2); + fhQvsTp[iPlane - 1][iBar*2 - 2]->GetYaxis()->SetTitle("Charge"); + fhQvsTp[iPlane - 1][iBar*2 - 2]->GetXaxis()->SetTitle("dt in ns"); + } + if(iPlane == 1 || iPlane == 3){ + if (NULL == fhQvsTp[iPlane - 1][2*iBar - 3]) + { + char strName[255]; + sprintf(strName, "Q_vs_Tdiff_MultHit_Plane_%d_Bar_%d", iPlane, iBar*2-2); + fhQvsTp[iPlane - 1][iBar*2 - 3] = new TH2F(strName, "", 10240, 0., 10240/3.2, 500, 0., max_charge/2); + fhQvsTp[iPlane - 1][iBar*2 - 3]->GetYaxis()->SetTitle("Charge"); + fhQvsTp[iPlane - 1][iBar*2 - 3]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register plane "<GetYaxis()->SetTitle("Charge"); + fhQvsTp[iPlane - 1][iBar*2 - 1]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register plane "<GetYaxis()->SetTitle("Charge PM2"); fhQ2vsPos[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("Position in cm"); } + */ + /* if (NULL == fhSqrtQvsPos[iPlane - 1][iBar - 1]) { char strName[255]; @@ -1009,47 +1205,67 @@ void R3BTofdCal2Hit::CreateHistograms(Int_t iPlane, Int_t iBar) fhSqrtQvsPos[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("Position in cm"); } */ - if (NULL == fhTdiffvsQ[iPlane - 1][2 * iBar - 2]) + /* + if (NULL == fhTdiffvsQ[iPlane - 1][2*iBar - 2]) { char strName[255]; - sprintf(strName, "Tdiff_Plane_%dand%d_Bar_%dvsQ", iPlane, iPlane + 1, iBar * 2 - 1); - fhTdiffvsQ[iPlane - 1][iBar * 2 - 2] = new TH2F(strName, "", 1000, -10, 10, 1200, 0., 60.); - fhTdiffvsQ[iPlane - 1][iBar * 2 - 2]->GetYaxis()->SetTitle("charge"); - fhTdiffvsQ[iPlane - 1][iBar * 2 - 2]->GetXaxis()->SetTitle("dt in ns"); - // cout<<"register plane "<GetYaxis()->SetTitle("charge"); + fhTdiffvsQ[iPlane - 1][iBar*2 - 2]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register plane "<GetYaxis()->SetTitle("charge"); - fhTdiffvsQ[iPlane - 1][iBar * 2 - 3]->GetXaxis()->SetTitle("dt in ns"); - // cout<<"register plane "<GetYaxis()->SetTitle("charge"); + fhTdiffvsQ[iPlane - 1][iBar*2 - 3]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register plane "<GetYaxis()->SetTitle("charge"); + fhTdiffvsQ[iPlane - 1][iBar*2 - 1]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register plane "<GetYaxis()->SetTitle("charge"); + fhQp12vsTdiff[iBar * 2 - 2]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register Bar "<GetYaxis()->SetTitle("charge"); - fhTdiffvsQ[iPlane - 1][iBar * 2 - 1]->GetXaxis()->SetTitle("dt in ns"); - // cout<<"register plane "<GetYaxis()->SetTitle("charge"); + fhQp12vsTdiff[iBar * 2 - 3]->GetXaxis()->SetTitle("dt in ns"); + // cout<<"register Bar "<GetXaxis()->SetTitle(strNamex); } } - - /* - - if (NULL == fhQvsQ[iPlane - 1][iBar*2 - 2]) { - char strName[255]; - sprintf(strName, "Q_vs_Q_Plane_%d_Bar_%d", iPlane, iBar*2-1); - Int_t bins[2] = {1000, 1000}; - Double_t min[2] = {0., 0.}; - Double_t max[2] = {100., 100.}; - fhQvsQ[iPlane - 1][iBar*2 - 2] = new THnSparseF(strName, "", 2, bins, min, max); - } - if(iPlane == 1 || iPlane == 3){ - if (NULL == fhQvsQ[iPlane - 1][iBar*2 - 3]) { - char strName[255]; - sprintf(strName, "Q_vs_Q_Plane_%d_Bar_%d", iPlane, iBar*2-2); - Int_t bins[2] = {1000, 1000}; - Double_t min[2] = {0., 0.}; - Double_t max[2] = {100., 100.}; - fhQvsQ[iPlane - 1][iBar*2 - 3] = new THnSparseF(strName, "", 2, bins, min, max); - } - } - if(iPlane == 2 || iPlane == 4){ - if (NULL == fhQvsQ[iPlane - 1][iBar*2 - 1]) { - char strName[255]; - sprintf(strName, "Q_vs_Q_Plane_%d_Bar_%d", iPlane, iBar*2); - Int_t bins[2] = {1000, 1000}; - Double_t min[2] = {0., 0.}; - Double_t max[2] = {100., 100.}; - fhQvsQ[iPlane - 1][iBar*2 - 1] = new THnSparseF(strName, "", 2, bins, min, max); - } - } - */ - if (NULL == fhxy) { char strName[255]; - sprintf(strName, "xy_of_TofD"); + sprintf(strName, "xy_of_ToFD"); fhxy = new TH2F(strName, "", 200, -100, 100, 200, -100., 100.); fhxy->GetYaxis()->SetTitle("y-position in cm"); fhxy->GetXaxis()->SetTitle("x-position in cm"); } - - if (NULL == fhQvsTof[iPlane - 1][iBar - 1]) - { - char strName[255]; - sprintf(strName, "Q_vs_ToF_Plane_%d_Bar_%d", iPlane, iBar); - fhQvsTof[iPlane - 1][iBar - 1] = new TH2F(strName, "", 1000, -10, 40, 1000, 0., max_charge); - fhQvsTof[iPlane - 1][iBar - 1]->GetXaxis()->SetTitle("ToF in ns"); - fhQvsTof[iPlane - 1][iBar - 1]->GetYaxis()->SetTitle("Charge"); - } if (NULL == fhCharge) { char strName[255]; sprintf(strName, "Charge_of_TofD"); - fhCharge = new TH1F(strName, "", 1000, 0., max_charge); + fhCharge = new TH1F(strName, "Charge of ToFD", 1000, 0., max_charge); fhCharge->GetYaxis()->SetTitle("Counts"); fhCharge->GetXaxis()->SetTitle("Charge"); } + if (NULL == fhTimeP) + { + char strName[255]; + sprintf(strName, "Time_particles_TofD"); + fhTimeP = new TH1F(strName, "Time hit - Time0", 5500000, 0., 11000); + fhTimeP->GetYaxis()->SetTitle("counts"); + fhTimeP->GetXaxis()->SetTitle("time in ns"); + } if (NULL == fhChargevsTof) { char strName[255]; @@ -1180,16 +1362,14 @@ void R3BTofdCal2Hit::CreateHistograms(Int_t iPlane, Int_t iBar) fhChargevsPos->GetYaxis()->SetTitle("Charge"); fhChargevsPos->GetXaxis()->SetTitle("Bar number"); } - if (NULL == fhQp12) { char strName[255]; sprintf(strName, "Charge_vs_Pos_p12"); - fhQp12 = new TH2F(strName, "", 100, 0, 100, 1000, 0., max_charge); + fhQp12 = new TH2F(strName, "", 100, 0, 100, 5000, 0., max_charge); fhQp12->GetYaxis()->SetTitle("Average charge of plane 1 and 2"); fhQp12->GetXaxis()->SetTitle("Bar number"); } - if (NULL == fhQp34) { char strName[255]; @@ -1201,7 +1381,6 @@ void R3BTofdCal2Hit::CreateHistograms(Int_t iPlane, Int_t iBar) } void R3BTofdCal2Hit::FinishEvent() { - if (fHitItems) { fHitItems->Clear(); @@ -1219,8 +1398,7 @@ void R3BTofdCal2Hit::FinishEvent() void R3BTofdCal2Hit::FinishTask() { - - for (Int_t i = 0; i < N_TOFD_HIT_PLANE_MAX; i++) + for (Int_t i = 0; i < fNofPlanes; i++) { /* if (fhPos[i]) fhPos[i]->Write(); @@ -1229,62 +1407,59 @@ void R3BTofdCal2Hit::FinishTask() if (fhTotPm1Sat[i]) fhTotPm1Sat[i]->Write(); if (fhTotPm2Sat[i]) fhTotPm2Sat[i]->Write(); */ - if (fhQPm1[i]) - fhQPm1[i]->Write(); - if (fhQPm2[i]) - fhQPm2[i]->Write(); + // if (fhQPm1[i]) fhQPm1[i]->Write(); + // if (fhQPm2[i]) fhQPm2[i]->Write(); if (fhQ[i]) fhQ[i]->Write(); - - if (fhTof[i]) - fhTof[i]->Write(); - if (fhTdiff[i]) - fhTdiff[i]->Write(); - + if (fhQM[i]) + fhQM[i]->Write(); + if (fhMvsQ[i]) + fhMvsQ[i]->Write(); + // if (fhTof[i]) fhTof[i]->Write(); + // if (fhTdvsQ[i]) fhTdvsQ[i]->Write(); + // if (fhTdiff[i]) fhTdiff[i]->Write(); + // if (fhTsync[i]) fhTsync[i]->Write(); for (Int_t j = 0; j < N_TOFD_HIT_PADDLE_MAX; j++) { - if (fhQvsPos[i][j]) - fhQvsPos[i][j]->Write(); - + // control histogram time particles + // if (fhQvsPos[i][j]) fhQvsPos[i][j]->Write(); + // if (fhQvsTp[i][2*j]) fhQvsTp[i][2*j]->Write(); + // if (fhQvsTp[i][2*j+1]) fhQvsTp[i][2*j+1]->Write(); /* if (fhQ1vsPos[i][j]) fhQ1vsPos[i][j]->Write(); if (fhQ2vsPos[i][j]) fhQ2vsPos[i][j]->Write(); - if (fhSqrtQvsPos[i][j]) fhSqrtQvsPos[i][j]->Write(); */ + // if (fhSqrtQvsPos[i][j]) fhSqrtQvsPos[i][j]->Write(); /* if (fhTotPm1vsTotPm2[i][j]) fhTotPm1vsTotPm2[i][j]->Write(); if (fhTotPm1satvsTotPm2sat[i][j]) fhTotPm1satvsTotPm2sat[i][j]->Write(); if (fhTot1vsPos[i][j]) fhTot1vsPos[i][j]->Write(); if (fhTot2vsPos[i][j]) fhTot2vsPos[i][j]->Write(); */ - if (fhTdiffvsQ[i][2 * j]) - fhTdiffvsQ[i][2 * j]->Write(); - if (fhTdiffvsQ[i][2 * j + 1]) - fhTdiffvsQ[i][2 * j + 1]->Write(); + // if (fhTdiffvsQ[i][2*j]) fhTdiffvsQ[i][2*j]->Write(); + // if (fhTdiffvsQ[i][2*j+1]) fhTdiffvsQ[i][2*j+1]->Write(); + // if (fhQp12vsTdiff[2*j]) fhQp12vsTdiff[2*j]->Write(); + // if (fhQp12vsTdiff[2*j+1]) fhQp12vsTdiff[2*j+1]->Write(); + if (fhQvsQ[i][2 * j]) fhQvsQ[i][2 * j]->Write(); if (fhQvsQ[i][2 * j + 1]) fhQvsQ[i][2 * j + 1]->Write(); - if (fhQvsTof[i][j]) - fhQvsTof[i][j]->Write(); + // if (fhQvsTof[i][j]) fhQvsTof[i][j]->Write(); + // if (fhQvsTofw[i][j]) fhQvsTofw[i][j]->Write(); } } - if (fhxy) - fhxy->Write(); + // if (fhxy) fhxy->Write(); if (fhCharge) fhCharge->Write(); - if (fhChargevsTof) - fhChargevsTof->Write(); - if (fhChargevsPos) - fhChargevsPos->Write(); - if (fhQp12) - fhQp12->Write(); - if (fhQp34) - fhQp34->Write(); + // if (fhTimeP) fhTimeP->Write(); + // if (fhChargevsTof) fhChargevsTof->Write(); + // if (fhChargevsPos) fhChargevsPos->Write(); + // if (fhQp12) fhQp12->Write(); + // if (fhQp34) fhQp34->Write(); // if (fhSaturation1) fhSaturation1->Write(); // if (fhSaturation2) fhSaturation2->Write(); - if (fhLosXYP) fhLosXYP->Write(); if (fhChargeLosTofD) @@ -1295,45 +1470,33 @@ void R3BTofdCal2Hit::FinishTask() Double_t R3BTofdCal2Hit::betaCorr(Double_t delta) { - // Double_t corr=-3.*delta; //correction for Ag - Double_t corr = -1. * delta; // correction for 12C + // Double_t corr=-3.*delta; //correction for Ag + Double_t corr = -1. * delta; // correction for 12C corr = 0.; return corr; } -Double_t R3BTofdCal2Hit::walk(Double_t Q) +Double_t R3BTofdCal2Hit::walk(Double_t q) { Double_t y; /* Double_t p0 = 18.; Double_t p1 = -0.5; - y = p0 * TMath::Power(Q,p1); + y = p0 * TMath::Power(q,p1); */ - Double_t par1, par2, par3, par4, par5; - - Int_t voltage = 443; - - if (voltage == 443) - { - par1 = 5.121991e+01; - par2 = -9.9738836e-02; - par3 = 5.817890e+01; - par4 = 8.208630e-03; - par5 = -2.719159e-05; - } + Int_t voltage = 444; if (voltage == 444) - { - par1 = 1.16631e+01; - par2 = 3.03014e-01; - par3 = 3.25826e+02; - par4 = -2.04208e-01; - par5 = 3.47279e-04; + { // voltage set in s444 + par1 = 2.178871e+01; + par2 = -3.565959e-03; + par3 = 5.713045e+01; + par4 = 4.007571e-02; + par5 = -9.537515e-05; } - if (voltage == 500) { par1 = 1.64344e+01; @@ -1342,7 +1505,6 @@ Double_t R3BTofdCal2Hit::walk(Double_t Q) par4 = -2.70050e-01; par5 = 3.61515e-04; } - if (voltage == 600) { par1 = 1.22606e+01; @@ -1351,9 +1513,19 @@ Double_t R3BTofdCal2Hit::walk(Double_t Q) par4 = -1.86328e-01; par5 = 1.49519e-04; } + y = -30.2 + par1 * TMath::Power(q, par2) + par3 / q + par4 * q + par5 * q * q; + return y; +} - y = -30.2 + par1 * TMath::Power(Q, par2) + par3 / Q + par4 * Q + par5 * Q * Q; - +/// obsolete +Double_t R3BTofdCal2Hit::Eloss(Double_t q) +{ + Double_t y; + Double_t par0, par1, par2; + par0 = 0.770316; // 0.762793; + par1 = -0.867169; //-0.992662; + par2 = 1.13888; // 1.1524; + y = par0 * TMath::Power(q, par2) + par1; return y; } @@ -1361,7 +1533,6 @@ Double_t R3BTofdCal2Hit::saturation(Double_t x) { Double_t kor; Int_t voltage = 600; - if (voltage == 600) { if (x < 173) @@ -1377,7 +1548,6 @@ Double_t R3BTofdCal2Hit::saturation(Double_t x) kor = -1.73665e+03 + 2.82009e+01 * x - 1.53846e-01 * (x * x) + 2.82425e-04 * (x * x * x); } } - if (voltage == 500) { if (x < 95.5) @@ -1393,7 +1563,6 @@ Double_t R3BTofdCal2Hit::saturation(Double_t x) kor = 643.257 - 16.7823 * x + 0.139822 * (x * x) - 0.000362154 * (x * x * x); } } - if (voltage == 700) { if (x < 198) @@ -1410,8 +1579,24 @@ Double_t R3BTofdCal2Hit::saturation(Double_t x) 1.81076e-08 * (x * x * x * x * x); } } - return kor; } +Double_t* R3BTofdCal2Hit::insertX(Int_t n, Double_t arr[], Double_t x, Int_t pos) +{ + Int_t i; + + // increase the size by 1 + n++; + + // shift elements forward + for (i = n; i >= pos; i--) + arr[i] = arr[i - 1]; + + // insert x at pos + arr[pos - 1] = x; + + return arr; +} + ClassImp(R3BTofdCal2Hit) diff --git a/tof/R3BTofdCal2Hit.h b/tof/R3BTofdCal2Hit.h index eb25dc202..57500cecf 100644 --- a/tof/R3BTofdCal2Hit.h +++ b/tof/R3BTofdCal2Hit.h @@ -1,16 +1,3 @@ -/****************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2019 Members of R3B Collaboration * - * * - * This software is distributed under the terms of the * - * GNU General Public Licence (GPL) version 3, * - * copied verbatim in the file "LICENSE". * - * * - * In applying this license GSI does not waive the privileges and immunities * - * granted to it by virtue of its status as an Intergovernmental Organization * - * or submit itself to any jurisdiction. * - ******************************************************************************/ - // ------------------------------------------------------------------ // ----- R3BTofdCal2Hit ----- // ----- Created May 30th 2016 by M.Heil ----- @@ -30,6 +17,7 @@ class TClonesArray; class R3BTofdHitModulePar; class R3BTofdHitPar; +class R3BEventHeader; class TH1F; class TH2F; @@ -113,11 +101,25 @@ class R3BTofdCal2Hit : public FairTask * Method for beta correction. */ virtual Double_t betaCorr(Double_t delta); - + /** + * Method for Eloss correction. + */ + virtual Double_t Eloss(Double_t Q); /** * Method for calculation of saturation. */ virtual Double_t saturation(Double_t x); + /** + * Method for insert. + */ + virtual Double_t* insertX(Int_t n, Double_t arr[], Double_t x, Int_t pos); + + /** + * Method for selecting events with certain trigger value. + * @param trigger 1 - onspill, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) { fTrigger = trigger; } + inline void SetTpat(Int_t tpat) { fTpat = tpat; } /** * Methods for setting number of planes and paddles */ @@ -135,12 +137,15 @@ class R3BTofdCal2Hit : public FairTask UInt_t fNofHitItems; /**< Number of hit items for cur event. */ R3BTofdHitPar* fHitPar; /**< Hit parameter container. */ UInt_t fNofHitPars; /**< Number of modules in parameter file. */ + R3BEventHeader* header; /**< Event header - input data. */ Double_t fClockFreq; /**< Clock cycle in [ns]. */ Int_t fTrigger; /**< Trigger value. */ + Int_t fTpat; Double_t fTofdQ; UInt_t fnEvents; UInt_t fNofPlanes; UInt_t fPaddlesPerPlane; /**< Number of paddles per plane. */ + Int_t maxevent; // arrays of control histograms TH2F* fhQ1vsPos[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; @@ -151,15 +156,18 @@ class R3BTofdCal2Hit : public FairTask TH2F* fhQvsQ[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX * 2 + 1]; TH2F* fhQvsTof[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; TH2F* fhSqrtQvsPos[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; - + TH2F* fhQvsTofw[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; TH2F* fhQPm1[N_TOFD_HIT_PLANE_MAX]; TH2F* fhQPm2[N_TOFD_HIT_PLANE_MAX]; TH2F* fhQ[N_TOFD_HIT_PLANE_MAX]; - + TH2F* fhQM[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhMvsQ[N_TOFD_HIT_PLANE_MAX]; + // TH2F* fhQvsTp[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX*2+1]; TH2F* fhTof[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhTdvsQ[N_TOFD_HIT_PLANE_MAX]; TH2F* fhTdiff[N_TOFD_HIT_PLANE_MAX]; - TH2F* fhSync[N_TOFD_HIT_PLANE_MAX]; + TH2F* fhTsync[N_TOFD_HIT_PLANE_MAX]; /* TH2F* fhTotPm1vsTotPm2[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX]; @@ -175,10 +183,13 @@ class R3BTofdCal2Hit : public FairTask TH2F* fhxy; TH1F* fhCharge; + TH1F* fhTimePB[N_TOFD_HIT_PLANE_MAX][N_TOFD_HIT_PADDLE_MAX * 2 + 1]; + TH1F* fhTimeP; TH2F* fhChargevsTof; TH2F* fhChargevsPos; TH2F* fhQp12; TH2F* fhQp34; + TH2F* fhQp12vsTdiff[N_TOFD_HIT_PADDLE_MAX * 2 + 1]; // TH2F* fhSaturation1; // TH2F* fhSaturation2; diff --git a/tof/R3BTofdChangePar.cxx b/tof/R3BTofdChangePar.cxx new file mode 100644 index 000000000..5fd1dbf4b --- /dev/null +++ b/tof/R3BTofdChangePar.cxx @@ -0,0 +1,372 @@ +// ---------------------------------------------------------------- +// ----- R3BTofdChangePar ----- +// ----- ----- +// ---------------------------------------------------------------- + +/* Some notes: + * + * + */ + +#include "R3BTofdChangePar.h" +#include "R3BEventHeader.h" +#include "R3BLosCalData.h" +#include "R3BLosMappedData.h" +#include "R3BTofdCalData.h" +#include "R3BTofdHitPar.h" + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRtdbRun.h" +#include "FairRunIdGenerator.h" +#include "FairRuntimeDb.h" + +#include "TCanvas.h" +#include "TClonesArray.h" +#include "TF1.h" +#include "TFile.h" +#include "TGraph.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TProfile.h" +#include "TSpectrum.h" +#include "TVirtualFitter.h" + +#include +#include + +#define IS_NAN(x) TMath::IsNaN(x) +using namespace std; + +namespace +{ + double c_range_ns = 2048 * 5; + double c_bar_coincidence_ns = 20; // nanoseconds. +} // namespace + +R3BTofdChangePar::R3BTofdChangePar() + : FairTask("R3BTofdChangePar", 1) + , fCalItemsLos(NULL) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fNofPlanes(5) + , fPaddlesPerPlane(6) + , fNEvents(0) + , fCal_Par(NULL) + , fParaFile("") +{ +} + +R3BTofdChangePar::R3BTofdChangePar(const char* name, Int_t iVerbose) + : FairTask(name, iVerbose) + , fCalItemsLos(NULL) + , fUpdateRate(1000000) + , fMinStats(100000) + , fTrigger(-1) + , fNofPlanes(5) + , fPaddlesPerPlane(6) + , fNEvents(0) + , fCal_Par(NULL) + , fParaFile("") +{ +} + +R3BTofdChangePar::~R3BTofdChangePar() +{ + if (fCal_Par) + { + delete fCal_Par; + } +} + +InitStatus R3BTofdChangePar::Init() +{ + FairRootManager* rm = FairRootManager::Instance(); + if (!rm) + { + return kFATAL; + } + + header = (R3BEventHeader*)rm->GetObject("R3BEventHeader"); + // may be = NULL! + + fCalData = (TClonesArray*)rm->GetObject("TofdCal"); + if (!fCalData) + { + return kFATAL; + } + + if (!fNofModules) + { + LOG(ERROR) << "R3BTofdChangePar::Init() Number of modules not set. "; + return kFATAL; + } + /* + fCalItemsLos = (TClonesArray*)rm->GetObject("LosCal"); + if (NULL == fCalItemsLos) + LOG(fatal) << "Branch LosCal not found"; + */ + + return kSUCCESS; +} + +void R3BTofdChangePar::SetParContainers() +{ + // container needs to be created in tcal/R3BTCalContFact.cxx AND R3BTCal needs + // to be set as dependency in CMakelists.txt (in this case in the tof directory) + fCal_Par = (R3BTofdHitPar*)FairRuntimeDb::instance()->getContainer("TofdHitPar"); + if (!fCal_Par) + { + LOG(ERROR) << "R3BTofdChangePar::Init() Couldn't get handle on TofdHitPar. "; + } + // fCal_Par->setChanged(); +} + +void R3BTofdChangePar::Exec(Option_t* option) {} + +void R3BTofdChangePar::FinishEvent() {} + +void R3BTofdChangePar::FinishTask() +{ + // set new parameters + Double_t pars[4]; + Double_t parameter; + Int_t plane, pplane, bar, pbar, pm, ppm, p, pp, i; + if (fParaFile != "") + { + ifstream a_file(fParaFile); + if (!a_file) + { + cout << "Could not open file!!!" << endl; + exit(1); + } + i = 0; + while (a_file.good()) + { + for (Int_t a = 0; a < 4; a++) + { + pars[a] = 0.; + } + pplane = plane; + pbar = bar; + ppm = pm; + pp = p; + a_file >> plane >> bar >> pm >> p >> parameter; + if (plane != pplane || bar != pbar || pm != ppm || p != pp) + i = 0; + pars[i] = parameter; + if (a_file.eof()) + break; + cout << "Reading Parameter, plane " << plane << " bar " << bar << " PM " << pm << " #" << p << " : " + << "i " << i << " = " << pars[i] << endl; + i++; + + if (p == 0) + changeAll0(plane, bar, pm, pars); + if (p == 1) + changeOffset(plane, bar, pm, pars); + if (p == 2) + changeSync(plane, bar, pm, pars); + if (p == 3) + changeVeff(plane, bar, pm, pars); + if (p == 4) + changeDoubleExp(plane, bar, pm, pars); + if (p == 5) + changeZ(plane, bar, pm, pars); + } + a_file.close(); + } + fCal_Par->setChanged(); +} + +void R3BTofdChangePar::changeAll0(Int_t plane, Int_t bar, Int_t pm, Double_t* pars) +{ + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(plane, bar); + par->SetOffset1(0.); + par->SetOffset2(0.); + par->SetVeff(0.); + par->SetSync(0.); + par->SetPar1a(0.); + par->SetPar1b(0.); + par->SetPar1c(0.); + par->SetPar1d(0.); + par->SetPar1za(0.); + par->SetPar1zb(0.); + par->SetPar1zc(0.); + par->SetPar2a(0.); + par->SetPar2b(0.); + par->SetPar2c(0.); + par->SetPar2d(0.); + par->SetPar1za(0.); + par->SetPar1zb(0.); + par->SetPar1zc(0.); +} + +void R3BTofdChangePar::changeOffset(Int_t plane, Int_t bar, Int_t pm, Double_t* pars) +{ + Double_t para1[4]; + Double_t para2[3]; + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(plane, bar); + if (pm == 1) + { + if (pars[0] == 0.) + pars[0] = par->GetOffset1(); + par->SetOffset1(pars[0]); + } + if (pm == 2) + { + if (pars[0] == 0.) + pars[0] = par->GetOffset2(); + par->SetOffset2(pars[0]); + } + Double_t veff = par->GetVeff(); + Double_t sync = par->GetSync(); + if (pm == 1) + { + para1[0] = par->GetPar1a(); + para1[1] = par->GetPar1b(); + para1[2] = par->GetPar1c(); + para1[3] = par->GetPar1d(); + para2[0] = par->GetPar1za(); + para2[1] = par->GetPar1zb(); + para2[2] = par->GetPar1zc(); + } + else + { + para1[0] = par->GetPar2a(); + para1[1] = par->GetPar2b(); + para1[2] = par->GetPar2c(); + para1[3] = par->GetPar2d(); + para2[0] = par->GetPar1za(); + para2[1] = par->GetPar1zb(); + para2[2] = par->GetPar1zc(); + } +} + +void R3BTofdChangePar::changeSync(Int_t plane, Int_t bar, Int_t pm, Double_t* pars) +{ + Double_t para1[4]; + Double_t para2[3]; + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(plane, bar); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t veff = par->GetVeff(); + if (pars[0] == 0.) + pars[0] = par->GetSync(); + par->SetSync(pars[0]); + if (pm == 1) + { + para1[0] = par->GetPar1a(); + para1[1] = par->GetPar1b(); + para1[2] = par->GetPar1c(); + para1[3] = par->GetPar1d(); + para2[0] = par->GetPar1za(); + para2[1] = par->GetPar1zb(); + para2[2] = par->GetPar1zc(); + } + else + { + para1[0] = par->GetPar2a(); + para1[1] = par->GetPar2b(); + para1[2] = par->GetPar2c(); + para1[3] = par->GetPar2d(); + para2[0] = par->GetPar1za(); + para2[1] = par->GetPar1zb(); + para2[2] = par->GetPar1zc(); + } +} +void R3BTofdChangePar::changeVeff(Int_t plane, Int_t bar, Int_t pm, Double_t* pars) +{ + Double_t para1[4]; + Double_t para2[3]; + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(plane, bar); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + if (pars[0] == 0.) + pars[0] = par->GetVeff(); + par->SetVeff(pars[0]); + Double_t sync = par->GetSync(); + if (pm == 1) + { + para1[0] = par->GetPar1a(); + para1[1] = par->GetPar1b(); + para1[2] = par->GetPar1c(); + para1[3] = par->GetPar1d(); + para2[0] = par->GetPar1za(); + para2[1] = par->GetPar1zb(); + para2[2] = par->GetPar1zc(); + } + else + { + para1[0] = par->GetPar2a(); + para1[1] = par->GetPar2b(); + para1[2] = par->GetPar2c(); + para1[3] = par->GetPar2d(); + para2[0] = par->GetPar1za(); + para2[1] = par->GetPar1zb(); + para2[2] = par->GetPar1zc(); + } +} +void R3BTofdChangePar::changeDoubleExp(Int_t plane, Int_t bar, Int_t pm, Double_t* pars) +{ + Double_t para[3]; + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(plane, bar); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t veff = par->GetVeff(); + Double_t sync = par->GetSync(); + if (pars[0] == 0.) + pars[0] = par->GetPar1a(); + if (pars[1] == 0.) + pars[1] = par->GetPar1b(); + if (pars[2] == 0.) + pars[2] = par->GetPar1c(); + if (pars[3] == 0.) + pars[3] = par->GetPar1d(); + if (pm == 1) + { + par->SetPar1a(pars[0]); + par->SetPar1b(pars[1]); + par->SetPar1c(pars[2]); + par->SetPar1d(pars[3]); + para[0] = par->GetPar1za(); + para[1] = par->GetPar1zb(); + para[2] = par->GetPar1zc(); + } + else + { + par->SetPar2a(pars[0]); + par->SetPar2b(pars[1]); + par->SetPar2c(pars[2]); + par->SetPar2d(pars[3]); + para[0] = par->GetPar1za(); + para[1] = par->GetPar1zb(); + para[2] = par->GetPar1zc(); + } +} +void R3BTofdChangePar::changeZ(Int_t plane, Int_t bar, Int_t pm, Double_t* pars) +{ + Double_t para[4]; + R3BTofdHitModulePar* par = fCal_Par->GetModuleParAt(plane, bar); + Double_t offset1 = par->GetOffset1(); + Double_t offset2 = par->GetOffset2(); + Double_t veff = par->GetVeff(); + Double_t sync = par->GetSync(); + if (pars[0] == 0.) + pars[0] = par->GetPar1za(); + if (pars[1] == 0.) + pars[1] = par->GetPar1zb(); + if (pars[2] == 0.) + pars[2] = par->GetPar1zc(); + para[0] = par->GetPar1a(); + para[1] = par->GetPar1b(); + para[2] = par->GetPar1c(); + para[3] = par->GetPar1d(); + par->SetPar1za(pars[0]); + par->SetPar1zb(pars[1]); + par->SetPar1zc(pars[2]); +} + +ClassImp(R3BTofdChangePar) diff --git a/tof/R3BTofdChangePar.h b/tof/R3BTofdChangePar.h new file mode 100644 index 000000000..99c2a2283 --- /dev/null +++ b/tof/R3BTofdChangePar.h @@ -0,0 +1,147 @@ +// ---------------------------------------------------------- +// ----- Change hit parameters for TOFD ----- +// ----- ----- +// --------------------------------------------------------- + +#ifndef R3BTOFDCHANGEPAR_H +#define R3BTOFDCHANGEPAR_H + +#define N_TOFD_HIT_PLANE_MAX 4 +#define N_TOFD_HIT_PADDLE_MAX 44 + +#include "FairTask.h" +#include "R3BTCalEngine.h" +#include "TObject.h" + +class R3BTofdHitPar; +class TClonesArray; +class R3BEventHeader; +class TH1F; +class TH2F; + +#pragma link C++ class R3BTofdHitModulePar + ; +class R3BTofdChangePar : public FairTask +{ + + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BTofdChangePar(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BTofdChangePar(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BTofdChangePar(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + virtual void SetParContainers(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Method for setting the update rate for control histograms + * @param rate an update rate value (events). + */ + inline void SetUpdateRate(Int_t rate) { fUpdateRate = rate; } + + /** + * Method for setting minimum required statistics per module. + * Only detector modules with number of entries in TDC + * distribution greater than minimum statistics will be + * calibrated. + * @param minStats a value of minimum statistics required. + */ + inline void SetMinStats(Int_t minStats) { fMinStats = minStats; } + + /** + * Method for selecting events with certain trigger value. + * @param trigger 1 - onspill, 2 - offspill, -1 - all events. + */ + inline void SetTrigger(Int_t trigger) { fTrigger = trigger; } + + /** + * Method for setting number of LOS detectors and channels. + * @param nDets number of detectors. + * @param nCh number of channels per detector (4+master trigger?) + */ + inline void SetNofModules(Int_t nDets, Int_t nCh) + { + fNofPlanes = nDets; + fPaddlesPerPlane = nCh; + fNofModules = nDets * nCh * 1; // 1 edge per channel + } + + /** + * + */ + inline void ReadParaFile(TString file) { fParaFile = file; } + + /** + * Methods for parameter changes. + */ + virtual void changeAll0(Int_t plane, Int_t bar, Int_t pm, Double_t*); + virtual void changeOffset(Int_t plane, Int_t bar, Int_t pm, Double_t*); + virtual void changeSync(Int_t plane, Int_t bar, Int_t pm, Double_t*); + virtual void changeVeff(Int_t plane, Int_t bar, Int_t pm, Double_t*); + virtual void changeDoubleExp(Int_t plane, Int_t bar, Int_t pm, Double_t*); + virtual void changeZ(Int_t plane, Int_t bar, Int_t pm, Double_t*); + + private: + Int_t fUpdateRate; /**< An update rate. */ + Int_t fMinStats; /**< Minimum statistics required per module. */ + Int_t fTrigger; /**< Trigger value. */ + + UInt_t fNofPlanes; /**< Number of planes. */ + UInt_t fPaddlesPerPlane; /**< Number of bars per plane. */ + UInt_t fNofModules; /**< Total number of modules (=edges) to calibrate */ + + Int_t fNEvents; /**< Event counter. */ + R3BTofdHitPar* fCal_Par; /**< Parameter container. */ + TClonesArray* fCalItemsLos; /**< Array with cal items. */ + TClonesArray* fCalData; /**< Array with mapped data - input data. */ + R3BEventHeader* header; /**< Event header - input data. */ + Double_t fClockFreq; /**< Clock cycle in [ns]. */ + TString fParaFile; + + public: + ClassDef(R3BTofdChangePar, 1) +}; + +#endif diff --git a/tof/R3BTofdDigitizer.cxx b/tof/R3BTofdDigitizer.cxx new file mode 100644 index 000000000..ccf1ab9a9 --- /dev/null +++ b/tof/R3BTofdDigitizer.cxx @@ -0,0 +1,283 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BTofdDigitizer.h" +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "TClonesArray.h" + +// includes for modeling +#include "TGeoBBox.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoShapeAssembly.h" +#include "TParticle.h" +#include "TVirtualMC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TMath.h" +#include "TRandom.h" +#include "TRandom3.h" +#include "TVector3.h" +#include +#include +#include +#include + +#include "R3BMCTrack.h" +#include "R3BTofPoint.h" + +using namespace std; +using std::cout; +using std::endl; + +R3BTofdDigitizer::R3BTofdDigitizer() + : FairTask("R3B Tofd Digitization scheme ") +{ + + // set default values for smearing + fsigma_y = 10.; + fsigma_t = 1.; + fsigma_ELoss = 0.1; +} + +R3BTofdDigitizer::~R3BTofdDigitizer() {} + +InitStatus R3BTofdDigitizer::Init() +{ + + // cout<<"Init "<GetObject("TofPoint"); + fMCTrack = (TClonesArray*)ioman->GetObject("MCTrack"); + + // Register output array fTofdHits + fTofdHits = new TClonesArray("R3BTofdHitData", 1000); + ioman->Register("TofdHit", "Digital response in Tofd", fTofdHits, kTRUE); + + // Get random number for smearing in y, t, ELoss + + fRnd = new TRandom3(); + + fHist1 = new TH1F("fHist1", "Energy loss histogram of Monte Carlo Points", 5000, 0., 5.); + fHist2 = new TH1F("fHist2", "Energy loss histogram without merging", 5000, 0., 5.); + fHist3 = new TH1F("fHist3", "Energy loss histogram with merging", 5000, 0., 5.); + + return kSUCCESS; +} + +void R3BTofdDigitizer::Exec(Option_t* opt) +{ + + Reset(); + + // detector parameter + Int_t number_layers = 2; // number of layers + Int_t number_paddles = 44; // number of paddles per layer + + Float_t paddle_width = 2.70000; + Float_t paddle_thickness = 0.50000; + Float_t air_gap_paddles = 0.04; + Float_t air_gap_layer = 5.; + + Float_t detector_width = number_paddles * paddle_width + (number_paddles - 1) * air_gap_paddles + paddle_width; + Float_t detector_thickness = (number_layers - 1) * air_gap_layer + number_layers * paddle_thickness; + + vector vPoints[1000]; + Int_t n_entries = fTofdPoints->GetEntries(); + Bool_t ChannelFired[1000] = { kFALSE }; + + Float_t X_Pos[1000] = { 0 }; + Float_t Y_Pos[1000] = { 0 }; + Float_t Time[1000] = { 0 }; + Float_t Energy_Loss[1000] = { 0 }; + Int_t number_paddles_hit = 0; + + for (Int_t entry = 0; entry < n_entries; entry++) + { + + R3BTofPoint* data_element = (R3BTofPoint*)fTofdPoints->At(entry); + + Int_t DetectorID = data_element->GetDetectorID(); + Double_t energy_loss = data_element->GetEnergyLoss(); + + cout << "det ID " << DetectorID << endl; + // discard all hits with an energy loss < cut + if (energy_loss < 0.01) + continue; + + // add hits to vector + vPoints[DetectorID].push_back(data_element); + + ChannelFired[DetectorID] = kTRUE; + } + + R3BTofdHitData* hit = nullptr; + map MapOfHits; + + for (Int_t channel = 0; channel < 1000; channel++) + { + if (ChannelFired[channel] == kTRUE) + { + + sort(vPoints[channel].begin(), vPoints[channel].end(), [](const R3BTofPoint* lhs, const R3BTofPoint* rhs) { + return lhs->GetTime() < rhs->GetTime(); + }); + + for (Int_t point = 0; point < vPoints[channel].size(); point++) + { + + // energy threshold + if (vPoints[channel].at(point)->GetEnergyLoss() < 0.01) + continue; + fHist1->Fill(vPoints[channel].at(point)->GetEnergyLoss()); + + if (0 == point || (vPoints[channel].at(point)->GetTime() - MapOfHits[channel]->GetTime()) > 30) + { // add new hits + + int layer_label; + int paddle_number; + if (channel < number_paddles) + { + layer_label = 0; + paddle_number = channel; + } + else if (channel - 100 < number_paddles) + { + layer_label = 1; + paddle_number = channel - number_paddles * layer_label; + } + + // Float_t paddle_xposition = -detector_width/2 + paddle_width/2*(1+layer_label) + + // paddle_number*paddle_width+paddle_number*air_gap_paddles; + + X_Pos[channel] = -detector_width / 2. + paddle_width / 2. * (1 + layer_label) + + paddle_number * paddle_width + paddle_number * air_gap_paddles; + Y_Pos[channel] = vPoints[channel].at(point)->GetYIn() - 0.523976; // get y-position //local + Time[channel] = vPoints[channel].at(point)->GetTime(); + Energy_Loss[channel] = vPoints[channel].at(point)->GetEnergyLoss(); + + // add to HitData and introduce smearing of y-position, time and energy loss + cout << "Hit: ch = " << channel << " paddle = " << paddle_number << " x = " << X_Pos[channel] + << " y = " << Y_Pos[channel] << " t = " << Time[channel] << " eloss = " << Energy_Loss[channel] + << endl; + MapOfHits.insert(pair( + channel, + new R3BTofdHitData(0., + fRnd->Uniform((X_Pos[channel] - 1.35), (X_Pos[channel] + 1.35)), + fRnd->Gaus(Y_Pos[channel], fsigma_y), + 0., + fRnd->Gaus(Time[channel], fsigma_t), + fRnd->Gaus(Energy_Loss[channel], fsigma_ELoss), + channel))); + } + + else + { // update hit + MapOfHits[channel]->SetTime(vPoints[channel].at(point)->GetTime()); + MapOfHits[channel]->SetEloss(vPoints[channel].at(point)->GetEnergyLoss() + + MapOfHits[channel]->GetEloss()); + } + } + } + } + + // merge energy loss of adjacent paddles in different layers + + Int_t counter = 0; + vector vHits; + + for (auto& i : MapOfHits) + { + + fHist2->Fill(i.second->GetEloss()); + + if (i.first >= number_paddles) + { + continue; + } + + vHits.push_back(i.second); + + Int_t k1 = i.first + number_paddles; + Int_t k2 = i.first + number_paddles - 1; + + // check which paddle(s) in 2nd layer were hit + if (MapOfHits.count(k1)) + { + vHits.push_back(MapOfHits[k1]); + } + + if (i.first != 0) + { + if (MapOfHits.count(k2)) + { + vHits.push_back(MapOfHits[k2]); + } + } + + // sum over energy loss + Double_t sum_eloss = 0; + for (Int_t j = 0; j < vHits.size(); j++) + { + sum_eloss += vHits[j]->GetEloss(); + } + + // average over energy loss + Double_t merged_eloss = sum_eloss / (vHits.size()); + + // set merged energy loss as new energy loss for hits + for (Int_t j = 0; j < vHits.size(); j++) + { + vHits[j]->SetEloss(merged_eloss); + } + + vHits.clear(); + } + + for (auto& i : MapOfHits) + { + new ((*fTofdHits)[counter]) R3BTofdHitData(*(i.second)); + fHist3->Fill(i.second->GetEloss()); + delete i.second; + counter++; + } +} +// ------------------------------------------------------------------------- + +void R3BTofdDigitizer::Reset() +{ + // Clear the structure + // cout << " -I- Digit Reset() called " << endl; + + if (fTofdHits) + fTofdHits->Clear(); +} + +void R3BTofdDigitizer::Finish() +{ + fHist1->Write(); + fHist2->Write(); + fHist3->Write(); +} + +ClassImp(R3BTofdDigitizer) diff --git a/tof/R3BTofdDigitizer.h b/tof/R3BTofdDigitizer.h new file mode 100644 index 000000000..be1f135aa --- /dev/null +++ b/tof/R3BTofdDigitizer.h @@ -0,0 +1,69 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// dTofDigitzer 07 aug 2017 created by Alicia Wongel + +#ifndef R3BTOFDDIGITIZER_H +#define R3BTOFDDIGITIZER_H 1 + +#include "FairTask.h" +#include "R3BTofdHitData.h" +#include +#include + +class TClonesArray; +class TH1F; +class TH2F; +class TRandom3; + +class R3BTofdDigitizer : public FairTask +{ + + public: + /** Default constructor **/ + R3BTofdDigitizer(); + + /** Destructor **/ + ~R3BTofdDigitizer(); + + /** Virtual method Init **/ + virtual InitStatus Init(); + + /** Virtual method Exec **/ + virtual void Exec(Option_t* opt); + + virtual void Finish(); + virtual void Reset(); + + /** Setters for sigmas **/ + void SetSigma_y(Float_t sigma_y) { fsigma_y = sigma_y; } + void SetSigma_t(Float_t sigma_t) { fsigma_t = sigma_t; } + void SetSigma_ELoss(Float_t sigma_ELoss) { fsigma_ELoss = sigma_ELoss; } + + protected: + TClonesArray* fTofdPoints; + TClonesArray* fMCTrack; + TClonesArray* fTofdHits; + TRandom3* fRnd; + TH1F* fHist1; + TH1F* fHist2; + TH1F* fHist3; + + Float_t fsigma_y; + Float_t fsigma_t; + Float_t fsigma_ELoss; + + ClassDef(R3BTofdDigitizer, 1); +}; + +#endif diff --git a/tof/R3BTofdHitModulePar.cxx b/tof/R3BTofdHitModulePar.cxx index eb6ec5201..ec9671e75 100644 --- a/tof/R3BTofdHitModulePar.cxx +++ b/tof/R3BTofdHitModulePar.cxx @@ -1,16 +1,3 @@ -/****************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2019 Members of R3B Collaboration * - * * - * This software is distributed under the terms of the * - * GNU General Public Licence (GPL) version 3, * - * copied verbatim in the file "LICENSE". * - * * - * In applying this license GSI does not waive the privileges and immunities * - * granted to it by virtue of its status as an Intergovernmental Organization * - * or submit itself to any jurisdiction. * - ******************************************************************************/ - #include "R3BTofdHitModulePar.h" #include "FairLogger.h" @@ -40,6 +27,14 @@ R3BTofdHitModulePar::R3BTofdHitModulePar(const char* name, const char* title, co , fPar2b(0) , fPar2c(0) , fPar2d(0) + , fPar1za(0) + , fPar1zb(0) + , fPar1zc(0) + , fPar1walk(0) + , fPar2walk(0) + , fPar3walk(0) + , fPar4walk(0) + , fPar5walk(0) { // Reset all parameters clear(); @@ -93,6 +88,9 @@ void R3BTofdHitModulePar::printParams() LOG(INFO) << " fParams1: " << fPar1a << " " << fPar1b << " " << fPar1c << " " << fPar1d; LOG(INFO) << " fParams2: " << fPar2a << " " << fPar2b << " " << fPar2c << " " << fPar2d; LOG(INFO) << " fSync2: " << fSync; + LOG(INFO) << " fParaZ1: " << fPar1za << " " << fPar1zb << " " << fPar1zc; + LOG(INFO) << " fParaWalk: " << fPar1walk << " " << fPar2walk << " " << fPar3walk << " " << fPar4walk << " " + << fPar5walk; } void R3BTofdHitModulePar::DrawParams() diff --git a/tof/R3BTofdHitModulePar.h b/tof/R3BTofdHitModulePar.h index ccb957a9e..ded615e8f 100644 --- a/tof/R3BTofdHitModulePar.h +++ b/tof/R3BTofdHitModulePar.h @@ -1,16 +1,3 @@ -/****************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * - * Copyright (C) 2019 Members of R3B Collaboration * - * * - * This software is distributed under the terms of the * - * GNU General Public Licence (GPL) version 3, * - * copied verbatim in the file "LICENSE". * - * * - * In applying this license GSI does not waive the privileges and immunities * - * granted to it by virtue of its status as an Intergovernmental Organization * - * or submit itself to any jurisdiction. * - ******************************************************************************/ - #ifndef R3BTOFDHITMODULEPAR_H #define R3BTOFDHITMODULEPAR_H @@ -90,7 +77,14 @@ class R3BTofdHitModulePar : public FairParGenericSet Double_t GetPar2b() const { return fPar2b; } Double_t GetPar2c() const { return fPar2c; } Double_t GetPar2d() const { return fPar2d; } - + Double_t GetPar1za() const { return fPar1za; } + Double_t GetPar1zb() const { return fPar1zb; } + Double_t GetPar1zc() const { return fPar1zc; } + Double_t GetPar1walk() const { return fPar1walk; } + Double_t GetPar2walk() const { return fPar2walk; } + Double_t GetPar3walk() const { return fPar3walk; } + Double_t GetPar4walk() const { return fPar4walk; } + Double_t GetPar5walk() const { return fPar5walk; } void SetPlane(Int_t i) { fPlane = i; } void SetPaddle(Int_t i) { fPaddle = i; } void SetSync(Double_t t) { fSync = t; } @@ -104,6 +98,14 @@ class R3BTofdHitModulePar : public FairParGenericSet void SetPar2b(Double_t par2b) { fPar2b = par2b; } void SetPar2c(Double_t par2c) { fPar2c = par2c; } void SetPar2d(Double_t par2d) { fPar2d = par2d; } + void SetPar1za(Double_t par1za) { fPar1za = par1za; } + void SetPar1zb(Double_t par1zb) { fPar1zb = par1zb; } + void SetPar1zc(Double_t par1zc) { fPar1zc = par1zc; } + void SetPar1walk(Double_t par1walk) { fPar1walk = par1walk; } + void SetPar2walk(Double_t par2walk) { fPar2walk = par2walk; } + void SetPar3walk(Double_t par3walk) { fPar3walk = par3walk; } + void SetPar4walk(Double_t par4walk) { fPar4walk = par4walk; } + void SetPar5walk(Double_t par5walk) { fPar5walk = par5walk; } void SetVeff(Double_t v) { fVeff = v; } private: @@ -115,6 +117,8 @@ class R3BTofdHitModulePar : public FairParGenericSet Double_t fSync; /**< time offset between paddles */ Double_t fPar1a, fPar1b, fPar1c, fPar1d; Double_t fPar2a, fPar2b, fPar2c, fPar2d; + Double_t fPar1za, fPar1zb, fPar1zc, fPar1zd; + Double_t fPar1walk, fPar2walk, fPar3walk, fPar4walk, fPar5walk; ClassDef(R3BTofdHitModulePar, 1); }; diff --git a/tof/TofLinkDef.h b/tof/TofLinkDef.h index d2f89d981..c8beee155 100644 --- a/tof/TofLinkDef.h +++ b/tof/TofLinkDef.h @@ -31,8 +31,12 @@ #pragma link C++ class R3BTofdMapped2Cal+; #pragma link C++ class R3BTofdMapped2CalPar+; #pragma link C++ class R3BTofdCal2HitPar+; +#pragma link C++ class R3BTofdCal2Histo+; +#pragma link C++ class R3BTofdCal2HistoPar+; +#pragma link C++ class R3BTofdChangePar+; #pragma link C++ class R3BTofdCal2Hit+; #pragma link C++ class R3BTofdHitModulePar+; +#pragma link C++ class R3BTofdDigitizer+; #pragma link C++ class R3BTofdHitPar+; #pragma link C++ class R3BPtofMapped2CalPar+; #pragma link C++ class R3BPtofMapped2Cal+; diff --git a/tracker_rene/CMakeLists.txt b/tracker_rene/CMakeLists.txt new file mode 100644 index 000000000..ba012cdbe --- /dev/null +++ b/tracker_rene/CMakeLists.txt @@ -0,0 +1,3 @@ +# Note the Fortran project mention in the main CMakeLists.txt. +include(CheckFortran) +add_library(R3BTraRene SHARED tracker_routines.f95) diff --git a/tracker_rene/tracker_routines.f95 b/tracker_rene/tracker_routines.f95 new file mode 100644 index 000000000..5dc135376 --- /dev/null +++ b/tracker_rene/tracker_routines.f95 @@ -0,0 +1,2778 @@ +module vars + implicit none + logical :: grafical_output=.true. ! determines if global grafical output is wanted + logical :: reference_track ! determines if text output is set during tracking + logical :: debug_track=.true. ! if tracking is done in debugging mode + logical :: get_new_derivatives ! determines if the derivatives have to be freshly calculated + logical,parameter :: derivative_ini_from_file=.false. ! determines if the derivatives ar freshly calculated with track data from file, special use + logical, allocatable :: det_hit(:) ! .true. if detector was hit during current track + logical, allocatable :: det_passed(:) ! .true. if xy-plane of detector was hit during current track + character(LEN=256) :: ini_file, output_file(3), geometry_file,magnetic_field_file, derivative_file + character(LEN=256), parameter :: track_debug_file='single_track.dat' + character(LEN=256), parameter :: track_debug_gle_file='single_track.gle' + double precision :: dt, t, t_total, dt_fine, dt_coarse + integer,parameter :: nbr_dimensions=6 ! (x,y,z,px,py,pz) + double precision :: x(nbr_dimensions), dx(nbr_dimensions), derivative_b_field(nbr_dimensions) + double precision :: x_start(nbr_dimensions), p_start(3), x_reference_step(nbr_dimensions) + double precision :: x_track1(nbr_dimensions), x_track2(nbr_dimensions), x_reference(nbr_dimensions) + double precision :: b_field(3), v(3) ! magnetic field, velocity + double precision :: b_field_position_in_lab(4) ! position of magnetic field coordinate system in lab-frame (x,y,z,rotation_around_y-axis) + double precision :: glad_current ! magnetic field map will be multiplied with this number divided by 3584... + double precision,parameter :: glad_current_nominal_current=3584.d0 ! current for which the field map is calculated + double precision :: m_amu, m, m2 ! mass of particle, AMU + SI + double precision :: q_e, q ! charge of particle in elementary unit + SI + double precision :: master_borders(3,2) ! borders of master volume ((xmin,xmax),(ymin,ymax),(zmin,zmax)) + double precision :: b_field_borders(3,2) ! borders of magnetic field ((xmin,xmax),(ymin,ymax),(zmin,zmax)) + double precision :: spatial_resolution ! spatial resolution of the entire geometry, given by best detector resolution... + double precision :: slope_parameter(4) ! parameters of the linear slope describing the particle track outside the magnetic field area + double precision,parameter,dimension(3) :: norm_x = (/1.d0,0.d0,0.d0/) ! norm-vector in x-direction ... + double precision,parameter,dimension(3) :: norm_y = (/0.d0,1.d0,0.d0/) ! norm-vector in y-direction ... + double precision,parameter,dimension(3) :: norm_z = (/0.d0,0.d0,1.d0/) ! norm-vector in z-direction ... + double precision, parameter :: c=299792458.d0 ! speed of light, SI units + double precision, parameter :: c2=c*c + double precision, parameter :: e=1.60217662d-19 ! elementary charge, SI units + double precision, parameter :: amu=1.660539040d-27 ! atomic mass, SI units + double precision, allocatable :: b_field_map(:,:,:,:) ! map of magnetic field... (x,y,z,1:3) , last entry for Bx,By,Bz + integer , parameter :: b_field_map_resolution=5 ! resolution of the field in cm !! , hence the integer ... + integer , parameter :: b_field_resolution_factor=100/b_field_map_resolution ! this is to convert position in m into channels in the b-field map + integer :: nbr_steps(2), nbr_detectors, nbr_tracks=1000 + double precision, allocatable :: detector_position_in_lab(:,:) ! position of detector coordinate system in lab-frame (detector_ID:x,y,z,rotation_around_y-axis) + double precision, allocatable :: detector_xy_plane(:,:) ! x-y-plane of detector in lab-frame (detector_ID:4) last 4 values correspond to parameters in: a1*x+a2*y+a3*z+a4=0) + double precision, allocatable :: detector_track_interactions_lab_frame(:,:) ! intersection of track point with z=0 plane of detector in lab coordinates (detector_ID,3) last 3: x,y,z + double precision, allocatable :: detector_track_interactions_det_frame(:,:) ! intersection of track point with z=0 plane of detector in detector coordinates (detector_ID,3) last 3: x,y,z) + double precision, allocatable :: detector_track_interactions_time(:) ! time of intersection of track point with z=0 plane of detector + double precision, allocatable :: detector_track_interactions_path(:) ! flightpath between starting point and intersection of track point with z=0 plane of detector + double precision, allocatable :: detector_track_interactions_det_frame_ref(:,:) ! intersection of track point with z=0 plane of detector in detector coordinates (detector_ID,3) last 3: x,y,z), reference track + double precision, allocatable :: detector_track_interactions_det_frame_ref_step(:,:) ! intersection of track point with z=0 plane of detector in detector coordinates (detector_ID,3) last 3: x,y,z), reference during step-wise initialization + double precision, allocatable :: track_lab_frame(:,:) ! experimental track in lab coordinates (detector_ID,3) last 3: x,y,z + double precision, allocatable :: track_det_frame(:,:),track_det_frame1(:,:),track_det_frame2(:,:) ! experimental track in detector coordinates (detector_ID,3) last 3: x,y,z + double precision, allocatable :: sigma_track(:,:) ! absolute unctertainties of experimental track + double precision, allocatable :: sigma_track2(:,:) ! square of sigma_track + double precision :: pos_target(3),sigma_target(3),sigma_target2(3) ! target position, absolute uncertainty and it's square (x,y,z) + logical, allocatable :: track_hit_pattern(:),track_hit_pattern1(:),track_hit_pattern2(:) ! true, if detector provided data (detector_ID) + double precision, allocatable :: detector_range(:,:,:) ! range of detector in detector-frame (detector_ID:x,y,z:min,max,delta) + double precision, allocatable :: derivative_theta(:),offset_theta(:) ! derivative and offset of x-position in detector-frame (detector_ID) when theta_yz is varied + double precision, allocatable :: derivative_x(:),offset_x(:) ! derivative and offset of x-position in detector-frame (detector_ID) when theta_yz is varied + double precision, allocatable :: derivative_q_over_a(:),offset_q_over_a(:) ! derivative and offset of x-position in detector-frame (detector_ID) when q/a of particle is varied + double precision, allocatable :: derivative_p(:),offset_p(:) ! derivative and offset of x-position in detector-frame (detector_ID) when momentum of particle is varied + integer , parameter :: nbr_variables=5 ! variable to be fitted during tracking routine + double precision, allocatable :: derivative_variable(:,:),offset_variable(:,:) ! derivative and offset of x-position in detector-frame (detector_ID) when any variable is varied + double precision, allocatable :: offset_ave_x(:) ! x-position in detector-frame (detector_ID) when x or theta_yz is varied (averaged), reference track + double precision, allocatable :: offset_ave_y(:) ! y-position in detector-frame (detector_ID) reference track + character (LEN=10), allocatable :: detector_name(:) ! name of detector (detector_ID) + double precision, allocatable :: stopping_power(:) ! relative stopping power in detector material (detector_ID) (dE/dx / E) for kinetic energy + integer , parameter :: nbr_channels_position_spectra=1000 + integer , parameter :: nbr_paramters_position_spectra=6 ! mean, 1-sigma variance, 2x first channel with content > 0, last channel with content > 0, (1..4 values already converted to in m!!!, 5,6 in channels) + integer, allocatable :: detector_position_spectra(:,:,:) ! spectra about xyz distribution of tracks going through detectors (detector_ID:Dimension(1..x,2..y,3..z):Channel_x,y,z) + double precision, allocatable :: detector_position_spectra_paramter(:,:,:) ! spectra about xyz distribution of tracks going through detectors (detector_ID:Dimension(1..x,2..y,3..z):Paramter_type) + double precision :: x_pos_target, theta_xz_target ! origin of track at target, theta in x-z plane at target + double precision :: det + double precision, allocatable :: sum_yi(:), sum_xiyi(:),sum_det_xi(:), sum_det_xixi(:), sum_det_tracks(:), det_det(:) + double precision, allocatable :: sum_xi(:), sum_xixi(:), sum_tracks(:) +! +! this is for theta_yz, p, x +! + double precision :: a3_matrix(3,3), a3_matrix_inv(3,3), a5_matrix(5,5), a5_matrix_inv(5,5) + double precision, allocatable :: a3_matrix_array(:,:,:) ! set of matrizes to retrieve single track parameters from detector positions + double precision, allocatable :: a3_matrix_inv_array(:,:,:) ! set of matrizes to retrieve single track parameters from detector positions + double precision, allocatable :: t3_matrix_inv_array(:,:,:) ! set of matrizes to retrieve single track parameters from detector positions, target position also constrained + double precision, allocatable :: a5_matrix_inv_array(:,:,:) ! set of matrizes to retrieve double track parameters from detector positions + double precision, allocatable :: t5_matrix_inv_array(:,:,:) ! set of matrizes to retrieve double track parameters from detector positions, target position also constrained +! +! this is for theta_xz, y +! + double precision :: a2_matrix(2,2), a2_matrix_inv(2,2) + double precision, allocatable :: a2_matrix_array(:,:,:) ! set of matrizes to retrieve single track parameters from detector positions + double precision, allocatable :: a2_matrix_inv_array(:,:,:) ! set of matrizes to retrieve single track parameters from detector positions + double precision, allocatable :: t2_matrix_inv_array(:,:,:) ! set of matrizes to retrieve single track parameters from detector positions, target position also constrained +! + double precision :: chi2_single_red, chi2_single,chi2_double_red(3), chi2_double(3) + double precision :: theta_yz, y_target + integer zero_crossing, b_field_map_limits(3,2) + character*1,parameter, dimension(3) :: ch_xyz=(/'x','y','z'/) + integer , parameter :: nbr_channels_2d_spectra=200 + integer :: spectrum_dthetay_dpx(0:nbr_channels_2d_spectra,0:nbr_channels_2d_spectra) + integer :: spectrum_dpy_dpx(0:nbr_channels_2d_spectra,0:nbr_channels_2d_spectra) + logical :: constrain_target_x, constrain_target_y ! true, if target position is constrained during fitting +end module vars + +subroutine init_from_cpp + use vars + implicit none +! + call init + call get_derivatives + call initialize_matrizes +end + +subroutine single_track_from_cpp(n_det,det_coordinates,x_positions_in,y_positions_in,z_positions_in, hit_pattern_in, & + track_parameter_out, chi_parameter_out) + use vars + implicit none + integer n_det, i + logical*1 hit_pattern_in(n_det), det_coordinates + double precision x_positions_in(n_det),track_parameter_out(6), chi_parameter_out(2) + double precision y_positions_in(n_det) + double precision z_positions_in(n_det) + double precision x_local_lab(3), x_local_det(3) + character*1 response +! + if (n_det == nbr_detectors) then + if (det_coordinates) then + track_det_frame(:,1) = x_positions_in (:) + track_det_frame(:,2) = y_positions_in (:) + track_det_frame(:,3) = z_positions_in (:) + else + do i=1,nbr_detectors + x_local_lab(1) = x_positions_in(i) + x_local_lab(2) = y_positions_in(i) + x_local_lab(3) = z_positions_in(i) + call get_det_position(i,x_local_lab,x_local_det ) + track_det_frame(i,:) = x_local_det + end do + end if + track_hit_pattern = hit_pattern_in +! + call get_single_track_parameter_var5 +! + track_parameter_out(1:3) = x_track1(1:3) + track_parameter_out(4:6) = x_track1(4:6)/e*c/1.d6 +! + chi_parameter_out(1) = chi2_single + chi_parameter_out(2) = chi2_single_red +! + if (debug_track) then + print* + print*,'Return values to r3broot' + print* + print*,' Position at Target (m):', track_parameter_out(1:3) + print* + print*,' Momentum at Target (MeV/c/q):', track_parameter_out(4:6) + print* + print*,' Momentum at Target (MeV/c/q):', chi_parameter_out + end if + else + print*,'Missmatch between number of detectors called from cpp and expected inside fortran', n_det, nbr_detectors + stop + end if + if (debug_track .and. grafical_output) then + print* + write(*,'(A24)', advance='no') ', continue (q = quit) : ' + read(*,*) response + if ( (response == 'q') ) stop + end if + +end + +subroutine double_track_from_cpp(n_det,x1_in,y1_in,z1_in, hit1_in,x2_in,y2_in,z2_in, hit2_in, & + track1_out,track2_out, chi_parameter_out) + use vars + implicit none + integer n_det, i + logical*1 hit1_in(n_det),hit2_in(n_det) + double precision x1_in(n_det),y1_in(n_det),z1_in(n_det) + double precision x2_in(n_det),y2_in(n_det),z2_in(n_det) + double precision track1_out(6),track2_out(6),chi_parameter_out(6) +! + if (n_det == nbr_detectors) then + track_det_frame1(:,1) = x1_in + track_det_frame1(:,2) = y1_in + track_det_frame1(:,3) = z1_in + track_det_frame2(:,1) = x2_in + track_det_frame2(:,2) = y2_in + track_det_frame2(:,3) = z2_in + track_hit_pattern1 = hit1_in + track_hit_pattern2 = hit2_in +! + call get_double_track_parameter_var5 + track1_out(1:6) = x_track1 + track2_out(1:6) = x_track2 + chi_parameter_out(1) = chi2_double(1) + chi_parameter_out(2) = chi2_double_red(1) + chi_parameter_out(3) = chi2_double(2) + chi_parameter_out(4) = chi2_double_red(2) + chi_parameter_out(5) = chi2_double(3) + chi_parameter_out(6) = chi2_double_red(3) +! + else + print*,'Missmatch between number of detectors called from cpp and expected inside fortran', n_det, nbr_detectors + stop + end if +end + + + +subroutine called_from_cpp(n,dp) + use vars + implicit none + integer n + double precision dp +! + print*,' fortran: ',n,dp +end + + +subroutine called_from_cpp2(n,dp_in, lo_in, dp_out) + use vars + implicit none + integer n + logical*1 lo_in(n) + double precision dp_in(n),dp_out(n) +! + print*,' fortran: ',n,dp_in + print*,' fortran: ',n,lo_in + dp_out = 2*dp_in+1d-8 + lo_in = .true. + print*,' fortran: ',n,dp_out + print*,' fortran: ',n,lo_in + +end + +subroutine initialize_matrizes + use vars + implicit none + if (debug_track) print*,'start a2 matrix initialization' + call initialize_a_t_2 + if (debug_track) print*,'start a3 matrix initialization' + call initialize_a_t_3 + if (debug_track) print*,'start a5 matrix initialization' +! call initialize_a_t_5 + if (debug_track) print*,'finished matrix initialization' +end + +subroutine calc + use vars + implicit none + integer tr, d, local_nbr_tracks, det_off, chx, chy,i + character (LEN=1) :: response + double precision GAUSSVER, keep_track(nbr_detectors,3),dxpos(nbr_detectors),dypos(nbr_detectors) +! + local_nbr_tracks = nbr_tracks*100000 + local_nbr_tracks = nbr_tracks*10 + spectrum_dthetay_dpx = 0 + spectrum_dpy_dpx = 0 +! + track_hit_pattern = .true. +! +! open (unit=21, file='simulation_data/default/tracker_out_vary_start_angle_xz.dat') ! get tracks data from file +! open (unit=21, file='simulation_data/default/tracker_out_vary_1_over_p.dat') ! get tracks data from file +! open (unit=21, file='simulation_data/default/tracker_out_vary_start_position.dat') ! get tracks data from file +! read(21,*) response ! skip one line + do tr = 1,local_nbr_tracks + if (debug_track) then + print* + write(*,'(A6,I8,A24)', advance='no') 'Track ',tr,', continue (q = quit) : ' + read(*,*) response + if ( (response == 'q') ) exit + call get_single_track_data + else +! if (1000000*int(tr/1000000) == tr) then + if (1000*int(tr/1000) == tr) then + print*,tr , ' of ', local_nbr_tracks, ' tracks' + if (grafical_output) call make_gle_dthetay_dpx + end if + end if +! + call get_single_track_data + track_hit_pattern = det_hit + keep_track = track_det_frame + do d=1, nbr_detectors + dxpos(d) = GAUSSVER(sigma_track(d,1)) ! vary x-positions of detector track in each detector + dypos(d) = GAUSSVER(sigma_track(d,2)) ! vary x-positions of detector track in each detector + end do + track_det_frame(:,1) = dxpos(:) + keep_track(:,1) + track_det_frame(:,2) = dxpos(:) + keep_track(:,2) + call get_single_track_parameter_var5 +! + chy = int(1.d3*datan(x_reference_step(4)/x_reference_step(6)))+nbr_channels_2d_spectra/2 ! theta_yz, 1mrad/channel, 0 at center + chx = int(1.d3*(x_track1(4)-x_reference_step(4))/x_reference_step(4) )+ nbr_channels_2d_spectra/2 ! dpx/px, 0.1% / channel, 0 at center +! + if (chx >= 0 .and. chx <= nbr_channels_2d_spectra .and. chy >= 0 .and. chy <= nbr_channels_2d_spectra) then + spectrum_dthetay_dpx(chx,chy) = spectrum_dthetay_dpx(chx,chy) + 1 + end if +! + chy = int(1.d3*(x_track1(5)-x_reference_step(5))/x_reference_step(5) )+ nbr_channels_2d_spectra/2 ! dpy/py, 0.1% / channel, 0 at center +! + if (chx >= 0 .and. chx <= nbr_channels_2d_spectra .and. chy >= 0 .and. chy <= nbr_channels_2d_spectra) then + spectrum_dpy_dpx(chx,chy) = spectrum_dthetay_dpx(chx,chy) + 1 + end if +! + if (debug_track) then + print* + print*,det_hit + print*,'Original :', real(x_reference_step) + print*,'Tracked :', real(x_track1) + print*,'Delta :', real(x_track1-x_reference_step) + print*,'Delta-rel :', real(2.d0*(x_track1-x_reference_step)/(x_track1+x_reference_step+1d-100)) + print* + end if +! + end do + call make_gle_dthetay_dpx + call make_gle_dpy_dpx +! close(21) +end + +subroutine make_gle_dpy_dpx + use vars + implicit none + character (LEN=256) :: local_output_file(3), shell_command + integer slash_position,length, chx, chy, z_max + real spectrum_dpy_dpx_local(0:nbr_channels_2d_spectra,0:nbr_channels_2d_spectra) + logical backwards +! + backwards = .true. + slash_position = index(output_file(1),'/',backwards) + length = len(trim(output_file(1))) + local_output_file(1) = output_file(1)(slash_position+1:length) // '_dpy_dpx.z' + local_output_file(2) = trim(output_file(1)) // '_dpy_dpx.z' + local_output_file(3) = trim(output_file(1)) // '_dpy_dpx.gle' +! +! write gle file +! + z_max = maxval(spectrum_dpy_dpx) + if (z_max .eq. 0.) then + print*,'no data in spectrum_dpy_dpx' + else + spectrum_dpy_dpx_local = float(spectrum_dpy_dpx) / float(z_max) + open (unit=30, file=local_output_file(3)) + write(30,*) 'size 16 16' + write(30,*) 'include "color.gle"' + write(30,*) 'amove 1 1' + write(30,*) 'begin graph' + write(30,*) ' size 14 14' + write(30,*) ' xtitle "dp_{x}/p_{x} (%)" hei 0.6' + write(30,*) ' ytitle "dp_{y}/p_{y} (%)" hei 0.6' + write(30,*) ' title "dp_{x} vs.dp_{y}" ' +! write(30,*) ' colormap "',trim(local_output_file(1)),'" 500 500 zmin 0 zmax 1 color ! palette palette_rene ' + write(30,*) ' colormap "',trim(local_output_file(1)),'" 500 500 zmin 0 zmax 1 palette palette_rene ' + write(30,*) 'end graph' + write(30,*) 'amove xg(xgmax)+0.3 yg(ygmin)' + write(30,*) 'color_range_vertical zmin 0 zmax 1 zstep 0.1 format "fix 1" palette palette_rene' + write(30,*) 'sub palette_rene z' + write(30,*) 'local r = 1' + write(30,*) 'local g = 1' + write(30,*) 'local b = 1' + write(30,*) 'if (z > 0.0) then b = 1-z*z' + write(30,*) 'if (z > 0.0) then r = sqrt(z)' + write(30,*) 'if (z > 0.0) then g = 0' + write(30,*) 'return rgb(r,g,b)' + write(30,*) 'end sub' + close(30) +! +! write data file +! + open (unit=30, file=local_output_file(2)) + write(30,*) '! nx ',nbr_channels_2d_spectra+1,' ny ',nbr_channels_2d_spectra+1, 'xmin -10 xmax 10 ymin -10 ymax 10' + do chy=0,nbr_channels_2d_spectra + do chx=0,nbr_channels_2d_spectra + write(30,'(F14.10)', ADVANCE='NO') spectrum_dpy_dpx_local(chx,chy) + end do + write(30,*)'' + end do + close(30) +! +! execute gle to create pdf and jpg +! + shell_command = 'gle -d pdf ' // trim(local_output_file(3)) // ' >/dev/null' + if (grafical_output) call execute_command_line (shell_command) + shell_command = 'gle -d jpg -resolution 400 ' // trim(local_output_file(3)) // ' >/dev/null' + ! if (grafical_output) call execute_command_line (shell_command) + end if +! +end + +subroutine make_gle_dthetay_dpx + use vars + implicit none + character (LEN=256) :: local_output_file(3), shell_command + integer slash_position,length, chx, chy, z_max + real spectrum_dthetay_dpx_local(0:nbr_channels_2d_spectra,0:nbr_channels_2d_spectra) + logical backwards +! + backwards = .true. + slash_position = index(output_file(1),'/',backwards) + length = len(trim(output_file(1))) + local_output_file(1) = output_file(1)(slash_position+1:length) // '_dthetay_dpx.z' + local_output_file(2) = trim(output_file(1)) // '_dthetay_dpx.z' + local_output_file(3) = trim(output_file(1)) // '_dthetay_dpx.gle' +! +! write gle file +! + z_max = maxval(spectrum_dthetay_dpx) + spectrum_dthetay_dpx_local = float(spectrum_dthetay_dpx) / float(z_max) + open (unit=30, file=local_output_file(3)) + write(30,*) 'size 16 16' + write(30,*) 'include "color.gle"' + write(30,*) 'amove 1 1' + write(30,*) 'begin graph' + write(30,*) ' size 14 14' + write(30,*) ' xtitle "dp_{x}/p_{x} (%)" hei 0.6' + write(30,*) ' ytitle "\theta_{yz} (mrad)" hei 0.6' + write(30,*) ' title "dp_{x} vs. \theta_{yz}" ' +! write(30,*) ' colormap "',trim(local_output_file(1)),'" 500 500 zmin 0 zmax 1 color ! palette palette_rene ' + write(30,*) ' colormap "',trim(local_output_file(1)),'" 500 500 zmin 0 zmax 1 palette palette_rene ' + write(30,*) 'end graph' + write(30,*) 'amove xg(xgmax)+0.3 yg(ygmin)' + write(30,*) 'color_range_vertical zmin 0 zmax 1 zstep 0.1 format "fix 1" palette palette_rene' + write(30,*) 'sub palette_rene z' + write(30,*) 'local r = 1' + write(30,*) 'local g = 1' + write(30,*) 'local b = 1' + write(30,*) 'if (z > 0.0) then b = 1-z*z' + write(30,*) 'if (z > 0.0) then r = sqrt(z)' + write(30,*) 'if (z > 0.0) then g = 0' + write(30,*) 'return rgb(r,g,b)' + write(30,*) 'end sub' + close(30) +! +! write data file +! + open (unit=30, file=local_output_file(2)) + write(30,*) '! nx ',nbr_channels_2d_spectra+1,' ny ',nbr_channels_2d_spectra+1, 'xmin -10 xmax 10 ymin -80 ymax 80' + do chy=0,nbr_channels_2d_spectra + do chx=0,nbr_channels_2d_spectra + write(30,'(F14.10)', ADVANCE='NO') spectrum_dthetay_dpx_local(chx,chy) + end do + write(30,*)'' + end do + close(30) +! +! execute gle to create pdf and jpg +! + shell_command = 'gle -d pdf ' // trim(local_output_file(3)) // ' >/dev/null' + if (grafical_output) call execute_command_line (shell_command) + shell_command = 'gle -d jpg -resolution 400 ' // trim(local_output_file(3)) // ' >/dev/null' + if (grafical_output) call execute_command_line (shell_command) +! +end + +subroutine get_double_track_parameter_var5 ! determines theta, p, x for the current set of track-detector data + use vars + implicit none + integer detector, i,j,k,det_pattern_id,pattern_id + integer, parameter :: n_var_local = 5 ! e.g. d_x, d_theta, d_1_over_p + double precision b_vector(n_var_local), p_vector(n_var_local) ! we will solve a*b = p + double precision v1(nbr_detectors),v2(nbr_detectors), dth + logical local_hit_pattern(2*nbr_detectors) +! +! nbr_of_detectors_hit = count(track_hit_pattern) + b_vector = 0.d0 +! +! populate b, a with data from current track +! + v1 = (track_det_frame1(:,1) - offset_ave_x)/sigma_track2(:,1) ! (:,1) is the x-component + v2 = (track_det_frame2(:,1) - offset_ave_x)/sigma_track2(:,1) ! (:,1) is the x-component + do detector=1,nbr_detectors + if (track_hit_pattern1(detector) ) then + b_vector(1:2) = b_vector(1:2) + v1(detector)*derivative_variable(detector,1:2) + b_vector(5) = b_vector(5) + (v1(detector))*derivative_variable(detector,3) + end if + if (track_hit_pattern2(detector) ) then + b_vector(3:4) = b_vector(3:4) + v2(detector)*derivative_variable(detector,1:2) + b_vector(5) = b_vector(5) + (v2(detector))*derivative_variable(detector,3) + end if + end do + local_hit_pattern(1:nbr_detectors) = track_hit_pattern1 + local_hit_pattern(1+nbr_detectors:2*nbr_detectors) = track_hit_pattern2 + pattern_id = det_pattern_id(2*nbr_detectors,local_hit_pattern) + +! + p_vector = matmul(a5_matrix_inv_array(pattern_id,:,:),b_vector) + +! +! dtheta +! + dth = p_vector(1) + x_track1(4) = x_reference(4)*dcos(dth) + x_reference(6)*dsin(dth) + x_track1(6) = x_reference(6)*dcos(dth) - x_reference(4)*dsin(dth) + x_track1(5) = x_reference(5) ! y-component +! + dth = p_vector(3) + x_track2(4) = x_reference(4)*dcos(dth) + x_reference(6)*dsin(dth) + x_track2(6) = x_reference(6)*dcos(dth) - x_reference(4)*dsin(dth) + x_track2(5) = x_reference(5) ! y-component +! +! dp +! + x_track1(4:6) = x_track1(4:6)/(p_vector(2)+1.d0) ! relative change of p, length of start momentum + x_track2(4:6) = x_track2(4:6)/(p_vector(4)+1.d0) ! relative change of p, length of start momentum +! +! dx +! + x_track1(1) = x_reference(1) + p_vector(5) ! x-position on target + x_track1(2) = x_reference(2) ! y-position on target + x_track1(3) = x_reference(3) ! z-position on target +! + x_track2(1) = x_reference(1) + p_vector(5) ! x-position on target + x_track2(2) = x_reference(2) ! y-position on target + x_track2(3) = x_reference(3) ! z-position on target +! + detector_track_interactions_det_frame(:,1) = offset_ave_x + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,1)*p_vector(1) + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,2)*p_vector(2) + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,3)*p_vector(5) +! + v1 = (detector_track_interactions_det_frame(:,1) - track_det_frame1(:,1) )/sigma_track(:,1) + chi2_double(1) = dot_product(v1,v1) + chi2_double_red(1) = chi2_double(1)/(nbr_detectors - 3) +! + detector_track_interactions_det_frame(:,1) = offset_ave_x + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,1)*p_vector(3) + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,2)*p_vector(4) + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,3)*p_vector(5) +! + v1 = (detector_track_interactions_det_frame(:,1) - track_det_frame2(:,1) )/sigma_track(:,1) + chi2_double(2) = dot_product(v1,v1) + chi2_double_red(2) = chi2_double(2)/(nbr_detectors - 3) +! + chi2_double(3) = chi2_double(2)+chi2_double(1) + chi2_double_red(3) = chi2_double(3)/(2*nbr_detectors - 5) +! + if (debug_track) then + print* + print*,'p_vector: ',real(p_vector) + print* + print*,'reference track params: ',real(x_reference) + print*,' new track params: ',real(x_track1) + print* + print*,'linear track points: ',real(detector_track_interactions_det_frame(:,1)) + print*,'det values: ',real(track_det_frame(:,1)) + print*,'diff to det values: ',real(track_det_frame(:,1)-detector_track_interactions_det_frame(:,1)) + print*,'diff to ref track: ',real(offset_ave_x-detector_track_interactions_det_frame(:,1)) + print* + print*,'chi-square: ',real(chi2_single) + print*,'reduced chi-square: ',real(chi2_single_red) + print* + x_start = x_track1 + v1 = detector_track_interactions_det_frame(:,1) + if (grafical_output) then + open (unit = 22, file=trim(track_debug_file)) + call single_track + close(22) + call make_gle_single_track + call make_single_track_pic + end if + print*,'R-K-track points : ',real(detector_track_interactions_det_frame(:,1)) + print*,'diff to det values: ',real(track_det_frame(:,1)-detector_track_interactions_det_frame(:,1)) + print*,'diff to linear track:',real(v1-detector_track_interactions_det_frame(:,1)) + print* + detector_track_interactions_det_frame(:,1) = v1 + x_start = x_reference + end if +end + +subroutine get_single_track_parameter_var5 ! determines theta_xz, theta_yz, p, x, theta_yz, y for the current set of track-detector data + use vars + implicit none + double precision theta_correction, d_track_x(nbr_detectors) +! + call get_single_track_y +! + theta_correction = 1.d0-1.d0/dcos(theta_yz) +! + d_track_x = derivative_variable(1:nbr_detectors,4)*theta_correction + if (debug_track) then + print*,'derivative ',derivative_variable(1:nbr_detectors,4) + print*,'theta-correction',d_track_x + print*,'track ',track_det_frame(:,1) + end if + track_det_frame(:,1) = track_det_frame(:,1) - d_track_x +! + call get_single_track_parameter_var3 +! +end + + +subroutine get_single_track_y ! theta_yz, y for the current set of track-detector data + use vars + implicit none + integer detector, i,j,k,det_pattern_id,pattern_id + integer, parameter :: n_var_local = 2 ! e.g. d_y, y + double precision b_vector(n_var_local), p_vector(n_var_local) ! we will solve a*p = b + double precision v1(nbr_detectors) +! +! quick & dirty fix for the y-component. Will need to change this later. +! + if (debug_track) then + y_target = 0. + do i=nbr_detectors,1,-1 + if (track_det_frame(i,2) .ne. 0. .and. track_hit_pattern(i) ) exit + end do + if (i.eq.0) then + theta_yz = 0. + else + theta_yz = dasin(track_det_frame(i,2)) / detector_track_interactions_path(i) + print*,'Quick fix 0: detector',i,' ',detector_name(i) + print*,'Quick fix 1: theta_yz, y_target', theta_yz, y_target + theta_yz = dasin(track_det_frame(i,2)) / derivative_variable(i+nbr_detectors,4) + print*,'Quick fix 2: theta_yz, y_target', theta_yz, y_target + end if + end if +! + b_vector = 0.d0 +! +! populate b, a with data from current track +! + v1 = (track_det_frame(:,2) - offset_ave_y)/sigma_track2(:,2) ! (:,2) is the y-component + do detector=1,nbr_detectors + if (track_hit_pattern(detector) ) then + b_vector = b_vector + v1(detector)*derivative_variable(detector+nbr_detectors,4:3+n_var_local) + end if + end do +! +! get the correct matrix +! + pattern_id = det_pattern_id(nbr_detectors,track_hit_pattern) +! +! calculate p +! + if (constrain_target_y) then + b_vector(n_var_local) = b_vector(n_var_local) + pos_target(2)/sigma_target2(2) + p_vector = matmul(t2_matrix_inv_array(pattern_id,:,:),b_vector) + else + p_vector = matmul(a2_matrix_inv_array(pattern_id,:,:),b_vector) + end if +! + theta_yz = p_vector(1) + y_target = p_vector(2) +! + if (debug_track) then + print*,'2x2 Matrix fix: theta_yz, y_target', theta_yz, y_target + end if +end + +subroutine get_single_track_parameter_var3 ! determines theta_xz, p, x for the current set of track-detector data + use vars + implicit none + integer detector, i,j,k,det_pattern_id,pattern_id, nbr_detectors_hit + integer, parameter :: n_var_local = 3 ! e.g. d_x, d_theta, d_1_over_p + double precision b_vector(n_var_local), p_vector(n_var_local) ! we will solve a*p = b + double precision v1(nbr_detectors), dth +! +! nbr_of_detectors_hit = count(track_hit_pattern) + b_vector = 0.d0 +! +! populate b, a with data from current track +! + v1 = (track_det_frame(:,1) - offset_ave_x)/sigma_track2(:,1) ! (:,1) is the x-component + do detector=1,nbr_detectors + if (track_hit_pattern(detector) ) then + b_vector = b_vector + v1(detector)*derivative_variable(detector,1:n_var_local) + end if + end do +! +! get the correct matrix +! + pattern_id = det_pattern_id(nbr_detectors,track_hit_pattern) +! +! calculate p +! + if (constrain_target_x) then + b_vector(n_var_local) = b_vector(n_var_local) + pos_target(1)/sigma_target2(1) + p_vector = matmul(t3_matrix_inv_array(pattern_id,:,:),b_vector) + else + p_vector = matmul(a3_matrix_inv_array(pattern_id,:,:),b_vector) + end if +! +! dtheta +! + dth = p_vector(1) + x_track1(4) = x_reference(4)*dcos(dth) + x_reference(6)*dsin(dth) + x_track1(6) = x_reference(6)*dcos(dth) - x_reference(4)*dsin(dth) +! +! dp +! + x_track1(4:6) = x_track1(4:6)/(p_vector(2)+1.d0) ! relative change of p, length of start momentum + x_track1(5) = x_track1(6)*dsin(theta_yz) ! y-component +! +! dx +! + x_track1(1) = x_reference(1) + p_vector(3) ! x-position on target + x_track1(2) = y_target ! y-position on target + x_track1(3) = x_reference(3) ! z-position on target +! +! detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame_ref(:,1) + detector_track_interactions_det_frame(:,1) = offset_ave_x + do k=1,n_var_local + detector_track_interactions_det_frame(:,1) = detector_track_interactions_det_frame(:,1) + & + derivative_variable(:,k)*p_vector(k) + end do +! + v1 = (detector_track_interactions_det_frame(:,1) - track_det_frame(:,1) )/sigma_track(:,1) + chi2_single = 0.d0 + do i=1,nbr_detectors + if (track_hit_pattern(i)) chi2_single = v1(i)*v1(i) + chi2_single + end do + nbr_detectors_hit = count(track_hit_pattern) + if (nbr_detectors_hit >n_var_local ) then + chi2_single_red = chi2_single/(nbr_detectors - n_var_local) + else + chi2_single_red = 0.d0 + end if +! + if (debug_track) then + print* + print*,'p_vector: ',real(p_vector) + print* + print*,'reference track params: ',real(x_reference) + print*,' new track params: ',real(x_track1) + print* + print*,'track_hit_pattern: ',track_hit_pattern + print*,'linear track points: ',real(detector_track_interactions_det_frame(:,1)) + print*,'det values: ',real(track_det_frame(:,1)) + print*,'diff to det values: ',real(track_det_frame(:,1)-detector_track_interactions_det_frame(:,1)) + print*,'diff to ref track: ',real(offset_ave_x-detector_track_interactions_det_frame(:,1)) + print* + print*,'chi-square: ',real(chi2_single) + print*,'reduced chi-square: ',real(chi2_single_red) + print*,'number of detectors: ',nbr_detectors_hit + print* + x_start = x_track1 + v1 = detector_track_interactions_det_frame(:,1) + if (grafical_output) then + open (unit = 22, file=trim(track_debug_file)) + call single_track + close(22) + call make_gle_single_track + call make_single_track_pic + end if + print*,'track_hit_pattern: ',track_hit_pattern + print*,'R-K-track points : ',real(detector_track_interactions_det_frame(:,1)) + print*,'diff to det values: ',real(track_det_frame(:,1)-detector_track_interactions_det_frame(:,1)) + print*,'diff to linear track:',real(v1-detector_track_interactions_det_frame(:,1)) + print* + detector_track_interactions_det_frame(:,1) = v1 + x_start = x_reference + end if +end + +subroutine initialize_a_t_2 ! initializes the matrizes necessary to get the linear optimization of the y-tracks + use vars + implicit none + integer, parameter :: n_var_local = 2 + integer i,j,k,detector, pattern_id + double precision e_vector(n_var_local),x_vector(n_var_local), einheit(n_var_local,n_var_local) + logical local_hit_pattern(nbr_detectors) +! + do pattern_id=1,2**nbr_detectors-1 + a2_matrix = 0. + call get_hit_pattern(nbr_detectors,pattern_id,local_hit_pattern) + do k=1, n_var_local + do j=1, n_var_local + do detector=1,nbr_detectors + if (local_hit_pattern(detector) ) then + a2_matrix(k,j) = a2_matrix(k,j) + & + derivative_variable(detector+nbr_detectors,j+3) * & + derivative_variable(detector+nbr_detectors,k+3)/sigma_track2(detector,2) + end if + end do + end do + end do +! + call invert_matrix(n_var_local,a2_matrix,a2_matrix_inv) + + a2_matrix_inv_array(pattern_id,:,:) = a2_matrix_inv(:,:) + a2_matrix_array(pattern_id,:,:) = a2_matrix(:,:) +! + a2_matrix(n_var_local,n_var_local) = a2_matrix(n_var_local,n_var_local) + 1.d0/sigma_target2(2) +! +! + do k=1, n_var_local + e_vector = 0.d0 + e_vector(k) = 1.d0 + call solve_linear_equation_system(n_var_local,a2_matrix,e_vector,x_vector) + a2_matrix_inv(:,k) = x_vector + end do + t2_matrix_inv_array(pattern_id,:,:) = a2_matrix_inv(:,:) + end do +end + +subroutine initialize_a_t_3 ! initializes the matrizes necessary to get the linear optimization of the x-tracks + use vars + implicit none + integer, parameter :: n_var_local = 3 + integer i,j,k,detector, pattern_id + double precision e_vector(n_var_local),x_vector(n_var_local), einheit(n_var_local,n_var_local) + logical local_hit_pattern(nbr_detectors) +! + do pattern_id=1,2**nbr_detectors-1 + a3_matrix = 0. + call get_hit_pattern(nbr_detectors,pattern_id,local_hit_pattern) + ! print*,'a3-ini',pattern_id, local_hit_pattern + do k=1, n_var_local + do j=1, n_var_local + do detector=1,nbr_detectors + if (local_hit_pattern(detector) ) then + a3_matrix(k,j) = a3_matrix(k,j) + & + derivative_variable(detector,j)*derivative_variable(detector,k)/sigma_track2(detector,1) + end if + end do + end do + end do +! + call invert_matrix(n_var_local,a3_matrix,a3_matrix_inv) + + a3_matrix_inv_array(pattern_id,:,:) = a3_matrix_inv(:,:) + a3_matrix_array(pattern_id,:,:) = a3_matrix(:,:) +! + a3_matrix(n_var_local,n_var_local) = a3_matrix(n_var_local,n_var_local) + 1.d0/sigma_target2(1) +! +! + do k=1, n_var_local + e_vector = 0.d0 + e_vector(k) = 1.d0 + call solve_linear_equation_system(n_var_local,a3_matrix,e_vector,x_vector) + a3_matrix_inv(:,k) = x_vector + end do + t3_matrix_inv_array(pattern_id,:,:) = a3_matrix_inv(:,:) + end do +end + +subroutine invert_matrix(n,a_in,a_inv_out) + implicit none + integer n,k + double precision a_in(n,n),a_inv_out(n,n),e_vector(n),x_vector(n) +! + do k=1, n + e_vector = 0.d0 + e_vector(k) = 1.d0 + call solve_linear_equation_system(n,a_in,e_vector,x_vector) + a_inv_out(:,k) = x_vector + end do +end + + +subroutine initialize_a_t_5 ! initializes the matrizes necessary to get the linear optimization of the tracks + use vars + implicit none + integer, parameter :: n_var_local = 5 + integer i,j,k,detector, pattern_id, pattern_id1, pattern_id2, det_pattern_id + double precision e_vector(n_var_local),x_vector(n_var_local), einheit(n_var_local,n_var_local) + logical local_hit_pattern(2*nbr_detectors), local_hit_pattern1(nbr_detectors), local_hit_pattern2(nbr_detectors) +! + do pattern_id1=1,2**nbr_detectors-1 + do pattern_id2=1,2**nbr_detectors-1 + a5_matrix = 0. + pattern_id = pattern_id2 + 2**nbr_detectors * (pattern_id1 - 1) + call get_hit_pattern(2*nbr_detectors,pattern_id,local_hit_pattern) + call get_hit_pattern(nbr_detectors,pattern_id1,local_hit_pattern1) + call get_hit_pattern(nbr_detectors,pattern_id2,local_hit_pattern2) + local_hit_pattern(1:nbr_detectors) = local_hit_pattern1 + local_hit_pattern(nbr_detectors+1:2*nbr_detectors) = local_hit_pattern2 + +! print*,'a5-ini',det_pattern_id(2*nbr_detectors,local_hit_pattern), local_hit_pattern + do k=1, 2 + do detector=1,nbr_detectors + if (local_hit_pattern(detector) ) then +! + a5_matrix(k,5) = a5_matrix(k,5) + & + derivative_variable(detector,3)*derivative_variable(detector,k)/sigma_track2(detector,1) +! + do j=1,2 +! + a5_matrix(k,j) = a5_matrix(k,j) + & + derivative_variable(detector,j)*derivative_variable(detector,k)/sigma_track2(detector,1) +! + end do + end if + if (local_hit_pattern(detector+nbr_detectors) ) then +! + a5_matrix(k+2,5) = a5_matrix(k+2,5) + & + derivative_variable(detector,3)*derivative_variable(detector,k)/sigma_track2(detector,1) +! + do j=1,2 +! + a5_matrix(k+2,j+2) = a5_matrix(k+2,j+2) + & + derivative_variable(detector,j)*derivative_variable(detector,k)/sigma_track2(detector,1) +! + end do + end if + end do + end do + do i=1,4 + a5_matrix(5,i) = a5_matrix(i,5) + end do + do detector=1,nbr_detectors + if (local_hit_pattern(detector) ) then + a5_matrix(5,5) = a5_matrix(5,5) + derivative_variable(detector,3)**2/sigma_track2(detector,1) + end if + if (local_hit_pattern(detector+nbr_detectors) ) then + a5_matrix(5,5) = a5_matrix(5,5) + derivative_variable(detector,3)**2/sigma_track2(detector,1) + end if + end do +! + do k=1, n_var_local + e_vector = 0.d0 + e_vector(k) = 1.d0 + call solve_linear_equation_system(n_var_local,a5_matrix,e_vector,x_vector) + a5_matrix_inv(:,k) = x_vector + end do + a5_matrix_inv_array(pattern_id,:,:) = a5_matrix_inv(:,:) +! + a5_matrix(n_var_local,n_var_local) = a5_matrix(n_var_local,n_var_local) + 1.d0/sigma_target2(1) +! +! + do k=1, n_var_local + e_vector = 0.d0 + e_vector(k) = 1.d0 + call solve_linear_equation_system(n_var_local,a3_matrix,e_vector,x_vector) + a5_matrix_inv(:,k) = x_vector + end do + t5_matrix_inv_array(pattern_id,:,:) = a5_matrix_inv(:,:) + end do + end do +end + +subroutine get_single_track_data ! at a later stage, we will here read in experimental data + use vars + implicit none + double precision theta_step, t1, t2 +! + do + call random_number(theta_step) + theta_step = theta_step*0.16 - 0.08 +! theta_step = 0.01 + t1 = theta_step +! + x_reference_step = x_reference + x_reference_step(4) = x_reference(4)*dcos(theta_step) + x_reference(6)*dsin(theta_step) + x_reference_step(6) = x_reference(6)*dcos(theta_step) - x_reference(4)*dsin(theta_step) +! + call random_number(theta_step) + theta_step = theta_step*0.16 - 0.08 +! theta_step = 0.d0 + t2 = theta_step +! + x_start = x_reference_step + x_reference_step(5) = x_start(5)*dcos(theta_step) + x_start(6)*dsin(theta_step) + x_reference_step(6) = x_start(6)*dcos(theta_step) - x_start(5)*dsin(theta_step) +! + x_start = x_reference_step + call single_track + if ( (det_hit(1).or.det_hit(2)) .and. (det_hit(7).or.det_hit(8)) ) exit + end do + track_det_frame = detector_track_interactions_det_frame + if (debug_track) print*,'theta_xz = ',t1*1000, 'mrad' + if (debug_track) print*,'theta_yz = ',t2*1000, 'mrad' +end + +subroutine read_single_track_data ! at a later stage, we will here read in experimental data + use vars + implicit none + integer tr, d, local_nbr_tracks, eastat + double precision dxpos(nbr_detectors), dxpos0, GAUSSVER, vektor(3*nbr_detectors) +! + read(21,*,iostat=eastat) vektor, dxpos0 + if (eastat /= 0) then + rewind(21) + read(21,*,iostat=eastat) vektor ! skip one line + print*,'rewind' + read(21,*) vektor, dxpos0 + end if + do d=1,nbr_detectors + tr = 3*(d-1) + track_det_frame(d,:) = vektor(tr+1:tr+3) + end do +! + do d=1, nbr_detectors + dxpos(d) = GAUSSVER(sigma_track(d,1)) ! vary x-positions of detector track in each detector + if (debug_track) print*,dxpos(d), sigma_track(d,1) + end do + track_det_frame(:,1) = dxpos(:) + track_det_frame(:,1) +! + if (debug_track) then + print*,'dxpos0: ', real(dxpos0) + end if +end + +subroutine get_x_theta + use vars + implicit none + integer d + double precision sum_aizi, sum_bizi, sum_aiai, sum_aibi, sum_bibi +! + sum_aizi = 0. + sum_bizi = 0. + sum_aiai = 0. + sum_aibi = 0. + sum_bibi = 0. +! + do d = 1, nbr_detectors + if (track_hit_pattern(d)) then + sum_aizi = sum_aizi + derivative_x(d)* (track_det_frame(d,1) - offset_ave_x(d) ) + sum_bizi = sum_bizi + derivative_theta(d)*(track_det_frame(d,1) - offset_ave_x(d) ) + sum_bibi = sum_bibi + derivative_theta(d)*derivative_theta(d) + sum_aibi = sum_aibi + derivative_x(d)*derivative_theta(d) + sum_aiai = sum_aiai + derivative_x(d)*derivative_x(d) + end if + end do + det = sum_aiai*sum_bibi - 2.d0*sum_aibi + x_pos_target = (sum_aizi*sum_bibi - sum_bizi*sum_aibi) / det + theta_xz_target = -(sum_aizi*sum_aibi - sum_bizi*sum_aiai) / det +end + +subroutine vary_parameter(var,io_unit) + use vars + implicit none + integer io_unit, var, i, j,event_id, local_nbr_tracks, d, eastatus + double precision dx_vary, dtheta, dtheta0, max_q_over_a, dp, theta0, v0(3),v_local(3), dy_vary,p0 + double precision variable(2) + double precision GAUSSVER, dth, theta, d_1_over_p, ra,dx1, x_local(3), x_simu(3), p_simu(3), dummy, dy1 + double precision theta_step + character (LEN=10) :: detector_name_local + character (LEN=80) :: d_out,o_ouT, first_line, gle_extension, first_line_tof + character (LEN=256) :: local_output_file, simu_file(3), local_output_file_tof + logical inside_detector_only +! + select case(var) + case(1) ! theta_xz + dtheta0 = 0.02d0 ! 80 mrad is acceptance of GLAD + inside_detector_only = .true. + local_output_file = trim(output_file(1)) // '_vary_start_angle_xz.dat' + local_output_file_tof = trim(output_file(1)) // '_tof_vary_start_angle_xz.dat' + first_line = 'nbr_of_detectors*(x,y,z), det system ; dth(rad)' + first_line_tof = 'TOF (s) ; dth(rad)' + gle_extension = 'theta_xz_target' + case(2) ! d_1_over_p + d_1_over_p = 0.02d0 ! relative change of 1/p + inside_detector_only = .true. + local_output_file = trim(output_file(1)) // '_vary_1_over_p.dat' + local_output_file_tof = trim(output_file(1)) // '_tof_vary_1_over_p.dat' + first_line = 'nbr_of_detectors*(x,y,z), det system ; d_1_over_p (relative change)' + first_line_tof = 'TOF (s) ; d_1_over_p (relative change)' + gle_extension = '1_over_p' + case(3) ! dx_vary + dx_vary = 0.005d0 ! in m + inside_detector_only = .true. + local_output_file = trim(output_file(1)) // '_vary_start_position_x.dat' + local_output_file_tof = trim(output_file(1)) // '_tof_vary_start_position_x.dat' + first_line = 'nbr_of_detectors*(x,y,z), det system ; (dx,dy,dz at target in m)' + first_line_tof = 'TOF (s) ; (dx,dy,dz at target in m)' + gle_extension = 'x_target' + case(4) ! theta_yz + dtheta = 0.08d0 ! 80 mrad is acceptance of GLAD + inside_detector_only = .false. + local_output_file = trim(output_file(1)) // '_vary_1_over_cos_start_angle_yz.dat' + local_output_file_tof = trim(output_file(1)) // '_tof_vary_1_over_cos_start_angle_yz.dat' + first_line = 'nbr_of_detectors*(x,y,z), det system ; d_cosd(theta_yz)' + first_line_tof = 'TOF (s) ; d_cosd(theta_yz)' + gle_extension = '1_over_cos_theta_yz_target' + case(5) ! dy_vary + dy_vary = 0.005d0 ! in m + inside_detector_only = .false. + local_output_file = trim(output_file(1)) // '_vary_start_position_y.dat' + local_output_file_tof = trim(output_file(1)) // '_tof_vary_start_position_y.dat' + first_line = 'nbr_of_detectors*(x,y,z), det system ; (dx,dy,dz at target in m)' + first_line_tof = 'TOF (s) ; (dx,dy,dz at target in m)' + gle_extension = 'y_target' + case default + print*,' do not know what to do in subroutine vary_parameter' + end select + if (var <= nbr_variables) then + ! + sum_xi = 0. + sum_det_xi = 0. + sum_yi = 0. + sum_xixi = 0. + sum_det_xixi = 0. + sum_xiyi = 0. + sum_tracks = 0. + sum_det_tracks = 0. + detector_position_spectra = 0. + detector_position_spectra_paramter = 0. +! + if (grafical_output) then + open (unit=20,file=local_output_file) + open (unit=23,file=local_output_file_tof) + write(20,*) first_line + write(23,*) first_line_tof + end if + write(*,*) 'vary: ', var, ' (',trim(gle_extension),')' + if (derivative_ini_from_file .and. var<4) then ! read track data from Michaels file + simu_file(1) = 'simulation_data/events_vary_angle.dat' + simu_file(2) = 'simulation_data/events_vary_p.dat' + simu_file(3) = 'simulation_data/events_vary_x.dat' + open (unit=21,file=simu_file(var)) + read(21,*,iostat=eastatus) event_id, local_nbr_tracks, x_simu, p_simu + do while (eastatus == 0) + do i=1,local_nbr_tracks + read(21,*) detector_name_local + read(21,*) x_local(1) + read(21,*) x_local(2) + read(21,*) x_local(3) + read(21,*) dummy + read(21,*) dummy + x_local = x_local/1.d2 + d=0 + if (trim(detector_name_local) == 'Fib3a') d = 1 + if (trim(detector_name_local) == 'Fib3b') d = 2 + if (trim(detector_name_local) == 'Fib10') d = 3 + if (trim(detector_name_local) == 'Fib11') d = 4 + if (trim(detector_name_local) == 'Fib12') d = 5 + if (trim(detector_name_local) == 'Fib13') d = 6 + if (trim(detector_name_local) == 'ToFD') d = 7 + if (d==0) then + print*,'Detector not recognized!! ', detector_name_local + stop + end if + x_start = x_reference + select case (var) + case(1) ! dx_theta + dth =datan(p_simu(1)/p_simu(3)) + x_start(4:6) = p_simu*1.d9*e/c +! print*,p_simu, dsqrt(dot_product(p_simu,p_simu)) +! print*,x_reference(4:6) + variable = dth + case(2) ! dp_vary + x_start(4:6) = p_simu*1.d9*e/c + dp = dsqrt(dot_product(x_start(4:6),x_start(4:6)) / dot_product(x_reference(4:6),x_reference(4:6)) ) + variable = 1.d0/dp -1.d0 + case(3) ! dx_vary + x_start(1:3) = x_simu / 1.d0 + dx1 = x_reference(1) - x_start(1) + variable = dx1 + end select + call get_det_position(d,x_local,detector_track_interactions_det_frame(d,1:3)) + call store_detector_track(d,variable) + end do + read(21,*,iostat=eastatus) event_id, local_nbr_tracks, x_simu, p_simu + end do + close(21) + write(*,*) ' read all track data ' + ! + det_det = sum_det_xixi*sum_det_tracks - sum_det_xi*sum_det_xi + derivative_variable(:,var) = (sum_xiyi*sum_det_tracks - sum_yi*sum_det_xi) / det_det + offset_variable(:,var) = -(sum_xiyi*sum_det_xi - sum_yi*sum_det_xixi) / det_det +! print*,'tracks:',sum_det_tracks +! print*,derivative_variable(:,var) +! print*,offset_variable(:,var) + else ! do internal Runge-Kutta variation +! do j=-8,8 + do j=-0,0 + theta_step = 1.d-2*dble(j) + x_reference_step = x_reference + x_reference_step(4) = x_reference(4)*dcos(theta_step) + x_reference(6)*dsin(theta_step) + x_reference_step(6) = x_reference(6)*dcos(theta_step) - x_reference(4)*dsin(theta_step) + x_start = x_reference_step + call single_track + detector_track_interactions_det_frame_ref_step = detector_track_interactions_det_frame +! + do i=1,nbr_tracks*10 + call random_number(ra) + ra = ra*2.0-1.d0 + select case(var) + case(1) ! dx_theta + ! dth = GAUSSVER(dtheta) + ! dtheta = 1.d0 + ! do while (abs(dtheta) > 0.08) + ! dtheta = GAUSSVER(dtheta0) + ! end do + dth = ra*dtheta0 + p0 = dot_product(x_start(4:6),x_start(4:6)) + x_start(4) = x_reference(4)*dcos(dth) + x_reference(6)*dsin(dth) + x_start(6) = x_reference(6)*dcos(dth) - x_reference(4)*dsin(dth) + x_start(5) = x_reference(5) + p0 = p0/dot_product(x_start(4:6),x_start(4:6)) + p0 = dsqrt(p0) + variable = dth ! same variable for pos_x and pos_y + case(2) ! dp_vary + dp = -2.d0 + ! do while (dp <= -1.d0) + ! dp = GAUSSVER(d_1_over_p) + ! end do + dp = 1.d0 + d_1_over_p*ra + x_start(4:6) = x_reference_step(4:6) * dp ! dp is relative change ... Gauss around 1, always > 0 + variable = 1.d0/dp -1.d0 ! same variable for pos_x and pos_y + case(3) ! dx_vary + ! dx1 = x_reference(1) + GAUSSVER(dx_vary) + dx1 = ra*dx_vary + x_start(1) = x_reference_step(1) + dx1 + variable = dx1 ! same variable for pos_x and pos_y + case(4) ! dy_theta + ! dth = GAUSSVER(dtheta) + dth =ra*dtheta + x_start(5) = x_reference_step(5)*dcos(dth) + x_reference_step(6)*dsin(dth) + x_start(6) = x_reference_step(6)*dcos(dth) - x_reference_step(5)*dsin(dth) + x_start(4) = x_reference_step(4) + variable(1) = 1.d0-1.d0/dcos(dth) ! variable for pos_x + variable(2) = dth ! variable for pos_y + case(5) ! dy_vary + ! dx1 = x_reference(1) + GAUSSVER(dx_vary) + dy1 = ra*dy_vary + x_start(2) = x_reference_step(2) + dy1 + variable = dy1 ! same variable for pos_x and pos_y + end select + call single_track +! detector_track_interactions_det_frame = detector_track_interactions_det_frame - detector_track_interactions_det_frame_ref_step + call store_track(variable,inside_detector_only) + call store_times(variable) + if (100*int(i/100) == int(i)) then + write(*,'(A1)',advance='no') '.' + end if + end do + write(*,*) '.' + end do + ! + write(*,*) ' ' + ! + do i=1, nbr_detectors + offset_variable(i,var) = detector_track_interactions_det_frame_ref(i,1) + offset_variable(i+nbr_detectors,var) = detector_track_interactions_det_frame_ref(i,2) + if (sum_tracks(i) > 100 ) then + derivative_variable(i,var) = sum_xiyi(i) / sum_xixi(i) + else + print*,'Detector ',i, ' not hit often enough to determine derivative ', sum_tracks(i) + derivative_variable(i,var) = 0.d0 + end if + derivative_variable(i+nbr_detectors,var) = sum_xiyi(i+nbr_detectors) / sum_xixi(i+nbr_detectors) + end do + ! + if (grafical_output) then + close(20) + close(23) + call get_detector_position_spectra_parameter + call make_gle_positions(trim(gle_extension)) + end if + end if + x_start = x_reference +! + end if +end + +subroutine get_derivatives + use vars + implicit none + integer io_unit, var, d + double precision dx_vary, dtheta, max_q_over_a, dp + character (LEN=20) :: dummy + logical debug_track_backup +! + io_unit = 19 +! + m2=m*m + reference_track = .true. + call single_track +! + detector_track_interactions_det_frame_ref = detector_track_interactions_det_frame + reference_track = .false. + open (unit=io_unit, file=trim(derivative_file)) + if (get_new_derivatives) then +! + debug_track_backup = debug_track + debug_track = .false. +! + print* + print*,'initialization of derivatives' + do var=1,nbr_variables + call vary_parameter(var,io_unit) + end do + write(io_unit,*) 'theta_xz, momentum, x_target, theta_yz, y_target' + do d=1,nbr_detectors + write(io_unit,*) detector_name(d), ' x' + write(io_unit,*) derivative_variable(d,:), ' derivative' + write(io_unit,*) offset_variable(d,:), ' offset' + write(io_unit,*) detector_name(d), ' y' + write(io_unit,*) derivative_variable(d+nbr_detectors,:), ' derivative' + write(io_unit,*) offset_variable(d+nbr_detectors,:), ' offset' + end do + debug_track = debug_track_backup +! + else + read(io_unit,*) dummy + do d=1,nbr_detectors + read(io_unit,*) dummy + read(io_unit,*) derivative_variable(d,:) + read(io_unit,*) offset_variable(d,:) + read(io_unit,*) dummy + read(io_unit,*) derivative_variable(d+nbr_detectors,:) + read(io_unit,*) offset_variable(d+nbr_detectors,:) + print*,detector_name(d),' x ',derivative_variable(d,:) + print*,detector_name(d),' y ',derivative_variable(d+nbr_detectors,:) + end do + end if + close(io_unit) + offset_ave_x = 0. + offset_ave_y = 0. + do var = 1, nbr_variables + offset_ave_x = offset_ave_x + offset_variable(:,var) ! x-deviations, theta + end do + offset_ave_x = offset_ave_x / nbr_variables + + offset_ave_x = detector_track_interactions_det_frame_ref(:,1) + offset_ave_y = detector_track_interactions_det_frame_ref(:,2) + +! print*,'offset x :',real(offset_variable(:,1)) +! print*,'offset theta:',real(offset_variable(:,2)) +! print*,'offset 1/dp :',real(offset_variable(:,3)) +! print*,'offset_ave :',real(offset_ave) +! print*,'offset ref :',real(detector_track_interactions_det_frame_ref(:,1)) +! print* +! print*,'Diff offset x :',real(offset_variable(:,1)-detector_track_interactions_det_frame_ref(:,1)) +! print*,'Diff offset theta:',real(offset_variable(:,2)-detector_track_interactions_det_frame_ref(:,1)) +! print*,'Diff offset 1/dp :',real(offset_variable(:,3)-detector_track_interactions_det_frame_ref(:,1)) +! print*,'Diff offset_ave :',real(offset_ave-detector_track_interactions_det_frame_ref(:,1)) +! print*,'Diff offset ref :',real(detector_track_interactions_det_frame_ref(:,1)-detector_track_interactions_det_frame_ref(:,1)) + if (grafical_output) then + call make_gle + call make_pics + end if +end + +subroutine vary_p(dp_vary) + use vars + implicit none + integer i, j, k, channel + double precision dp_vary, x_save(nbr_dimensions), GAUSSVER, dp, variable(2) + character*256 local_output_file +! + x_save = x_start +! + sum_xi = 0. + sum_yi = 0. + sum_xixi = 0. + sum_xiyi = 0. + sum_tracks = 0. + detector_position_spectra = 0. + detector_position_spectra_paramter = 0. +! + if (grafical_output) then + local_output_file = trim(output_file(1)) // '_vary_p.dat' + open (unit=20,file=local_output_file) + write(20,*) 'nbr_of_detectors*(x,y,z), det system ; (dp ... relative change of p)' + end if + write(*,*) 'dp_vary ' + do i=1,nbr_tracks + dp = -2.d0 + do while (dp <= -1.d0) + dp = GAUSSVER(dp_vary) + end do + dp = 1.d0 + dp + x_start(4:6) = x_save(4:6) * dp ! dp is relative change ... Gauss around 1, but always positive + call single_track + variable = dp +! call store_track(variable) + end do + write(*,*) +! +!! det = sum_xixi*sum_tracks - sum_xi*sum_xi +!! derivative_p = (sum_xiyi*sum_tracks - sum_yi*sum_xi) / det +!! offset_p = -(sum_xiyi*sum_xi - sum_yi*sum_xixi) / det +! + if (grafical_output) then + close(20) + call get_detector_position_spectra_parameter + call make_gle_positions('p') + end if + x_start = x_save +end + + + + +subroutine vary_q_over_a(max_q_over_a) + use vars + implicit none + integer i, j, k, channel + double precision qa, GAUSSVER, m_save, max_q_over_a, x_save(nbr_dimensions), variable(2) + character*256 local_output_file +! + m_save = m + x_save = x_start +! + sum_xi = 0. + sum_yi = 0. + sum_xixi = 0. + sum_xiyi = 0. + sum_tracks = 0. + detector_position_spectra = 0. + detector_position_spectra_paramter = 0. +! + if (grafical_output) then + local_output_file = trim(output_file(1)) // '_vary_q_over_a.dat' + open (unit=20,file=local_output_file) + write(20,*) 'nbr_of_detectors*(x,y,z), det system ; q/a' + end if + write(*,*) 'q_over_a ' + do i=1,nbr_tracks + call random_number(qa) + qa = qa * max_q_over_a + m = q / qa + m2 = m*m + x_start(4:6) = m / m_save * x_save(4:6) + call single_track + variable = qa/e*amu +! call store_track(variable) + end do + write(*,*) +! +!! det = sum_xixi*sum_tracks - sum_xi*sum_xi +!! derivative_q_over_a = (sum_xiyi*sum_tracks - sum_yi*sum_xi) / det +!! offset_q_over_a = -(sum_xiyi*sum_xi - sum_yi*sum_xixi) / det +! + if (grafical_output) then + close(20) + call get_detector_position_spectra_parameter + call make_gle_positions('particle_q_over_a') + end if + m = m_save + m2 = m*m + x_start = x_save +end + + +subroutine store_times(variable) + use vars + implicit none + double precision variable(2) + integer j +! + if (grafical_output) then +! do j=1,nbr_detectors +! write(23,'(ES20.10)', advance='no') detector_track_interactions_time(j) +! end do + write(23,*) detector_track_interactions_time, variable + end if +end + +subroutine store_track(variable,inside_detector_only) + use vars + implicit none + double precision variable(2), y + integer i,j,k, channel + logical inside_detector,inside_detector_only + +! if (det_hit(nbr_detectors) .and. det_hit(nbr_detectors-1)) then +! print*,'both TOFD detectors are hit!' +! print*,detector_track_interactions_det_frame(nbr_detectors,1) +! print*,detector_track_interactions_det_frame(nbr_detectors-1,1) +! print*,detector_track_interactions_lab_frame(nbr_detectors,1) +! print*,detector_track_interactions_lab_frame(nbr_detectors-1,1) +! print*,inside_detector(nbr_detectors, detector_track_interactions_lab_frame(nbr_detectors,:)) +! print*,inside_detector(nbr_detectors-1, detector_track_interactions_lab_frame(nbr_detectors-1,:)) +! stop +! end if + do j=1,nbr_detectors + if(det_hit(j) ) then + do k=1,3 + channel = (detector_track_interactions_det_frame(j,k)-detector_range(j,k,1))/detector_range(j,k,3)* & + nbr_channels_position_spectra + 1 + if (channel >0 .and. channel <= nbr_channels_position_spectra) then + detector_position_spectra(j,k,channel) = detector_position_spectra(j,k,channel) + 1 + end if + end do + end if + if(det_hit(j) .or. .not. inside_detector_only) then + y = detector_track_interactions_det_frame(j,1) - detector_track_interactions_det_frame_ref_step(j,1) ! x-component of each detector + sum_xi(j) = sum_xi(j) + variable(1) + sum_xixi(j) = sum_xixi(j) + variable(1)*variable(1) + sum_yi(j) = sum_yi(j) + y + sum_xiyi(j) = sum_xiyi(j) + y*variable(1) + sum_tracks(j) = sum_tracks(j) + 1.d0 + end if + y = detector_track_interactions_det_frame(j,2) - detector_track_interactions_det_frame_ref_step(j,2) ! y-component of each detector + sum_xi(j+nbr_detectors) = sum_xi(j+nbr_detectors) + variable(2) + sum_xixi(j+nbr_detectors) = sum_xixi(j+nbr_detectors) + variable(2)*variable(2) + sum_yi(j+nbr_detectors) = sum_yi(j+nbr_detectors) + y + sum_xiyi(j+nbr_detectors) = sum_xiyi(j+nbr_detectors) + y*variable(2) + sum_tracks(j+nbr_detectors) = sum_tracks(j+nbr_detectors) + 1.d0 + end do +! + if (grafical_output) then + do j=1,nbr_detectors + write(20,'(3F15.10)', advance='no') detector_track_interactions_det_frame(j,:) + end do + write(20,*) variable + end if +! +end + +subroutine store_detector_track(det_local,variable) + use vars + implicit none + double precision variable(2) + integer i,j,k, channel,det_local +! + sum_det_xi(det_local) = sum_det_xi(det_local) + variable(1) + sum_det_xixi(det_local) = sum_det_xixi(det_local) + variable(1)*variable(1) + sum_yi(det_local) = sum_yi(det_local) + detector_track_interactions_det_frame(det_local,1) ! x-component of each detector + sum_xiyi(det_local) = sum_xiyi(det_local) + detector_track_interactions_det_frame(det_local,1)*variable(1) + sum_det_tracks(det_local) = sum_det_tracks(det_local) +1.d0 +! + if (10000*int(sum(sum_det_tracks)/10000) == int(sum(sum_det_tracks))) then + write(*,'(A1)',advance='no') '.' + end if +end + +subroutine get_detector_position_spectra_parameter + use vars + implicit none + double precision sigma(3), ave(3), channel_sum + integer i, j, k, channel, minimum, maximum + + do i=1,nbr_detectors + ave = 0. + sigma = 0. + minimum = 0 + maximum = 0 + do j=1,3 + channel_sum = sum(detector_position_spectra(i,j,:)) + if (channel_sum > 0.) then + do channel=1,nbr_channels_position_spectra + if (detector_position_spectra(i,j,channel) > 0) then + if (minimum == 0) minimum = channel + maximum = channel + end if + ave(j) = ave(j) + dble(channel)*dble(detector_position_spectra(i,j,channel)) + sigma(j) = sigma(j) + dble(channel)**2*dble(detector_position_spectra(i,j,channel)) + end do + ave(j) = ave(j) / channel_sum + sigma(j) = sigma(j) / channel_sum + sigma(j) = dsqrt( sigma(j) - ave(j)*ave(j) ) + ave(j) = (ave(j) - 0.5d0) / dble(nbr_channels_position_spectra) * & + detector_range(i,j,3) + detector_range(i,j,1) + sigma(j) = sigma(j) / dble(nbr_channels_position_spectra) * detector_range(i,j,3) + detector_position_spectra_paramter(i,j,5) = dble(minimum) + detector_position_spectra_paramter(i,j,6) = dble(maximum) + detector_position_spectra_paramter(i,j,3) = (dble(minimum) - 0.5d0) / & + dble(nbr_channels_position_spectra) * detector_range(i,j,3) + detector_range(i,j,1) + detector_position_spectra_paramter(i,j,4) = (dble(maximum) - 0.5d0) / & + dble(nbr_channels_position_spectra) * detector_range(i,j,3) + detector_range(i,j,1) + end if + end do + detector_position_spectra_paramter(i,:,1) = ave + detector_position_spectra_paramter(i,:,2) = sigma + end do +end + +subroutine init + use vars + implicit none + integer eastat, dot + character*300 buffer + integer unit_read + double precision x1(3), x0(3),distance_detector_plane + logical inside_b_field + integer i, j, k +! + call getarg(1,BUFFER) + if (buffer.eq.'-') then + unit_read = 5 + print*,'Kein ini file!' + ini_file='' + else + if (buffer.eq.'') then + print*,'Give name of init file: ' + ini_file='tracker.ini' +! read(*,*) ini_file + else + ini_file=buffer(1:len_trim(buffer)) + end if + print*,'Init file: ',ini_file(1:40) + unit_read = 8 + open (unit=unit_read, file=ini_file , status='old') + end if +! + read(unit_read,*) geometry_file + print*,'Geometry definition: ',trim(geometry_file) +! + read(unit_read,*) derivative_file + get_new_derivatives = (trim(derivative_file) == '') + if (get_new_derivatives) then + derivative_file = 'derivatives.out' + print*,'NEW derivatives will be stored in: ',trim(derivative_file) + else + print*,'Derivatives definition: ',trim(derivative_file) + end if +! + do i=1,3 + read(unit_read,*) x_start(i) , sigma_target(i) + print*,'Start location: ',real(x_start(i)), ' +- ',real(sigma_target(i)) + end do + sigma_target2 = sigma_target + pos_target = x_start(1:3) +! + do i=1,3 + read(unit_read,*) p_start(i) + print*,'Start momentum (MeV/c/u)',p_start(i) + end do +! + read(unit_read,*) m_amu ! this is now a/q + print*,'Mass of particle (AMU): ',m_amu + m = m_amu * amu + print*,'Mass of particle (MeV/c2): ',m/e*c2/1d6 +! +! read(unit_read,*) q_e + q_e = 1.d0 ! calculate always with q == 1 + print*,'Charge of particle (e): ',q_e + q = q_e * e +! + x_start(4:6) = p_start(1:3)*e/c*1.d6*m_amu +! + x_reference = x_start +! + read(unit_read,*) spatial_resolution + print*,'Spatial resolution (m): ',spatial_resolution +! + read(unit_read,*) constrain_target_x + if (constrain_target_x) then + print*,'Constrain x-position on target: yes' + else + print*,'Constrain x-position on target: no' + end if +! + read(unit_read,*) constrain_target_y + if (constrain_target_x) then + print*,'Constrain y-position on target: yes' + else + print*,'Constrain y-position on target: no' + end if +! + read(unit_read,*) debug_track + if (debug_track) then + print*,'Debugging mode: yes' + else + print*,'Debugging mode: no' + end if +! + read(unit_read,*) grafical_output + read(unit_read,*) output_file(1) + print*,'Root of output file: ',trim(output_file(1)) + output_file(2) = trim(output_file(1)) // '.dat' + output_file(3) = trim(output_file(1)) // '.gle' +! + if (grafical_output) then + print*,'Grafical output: yes' +! + open (unit=9, file=trim(output_file(2))) + else + print*,'Grafical output: no' + end if +! + if (unit_read .eq. 8) close(8) + unit_read = 8 + open (unit=unit_read, file=geometry_file, status='old') +! +! b-field +! + read(unit_read,*) master_borders(1,1) + read(unit_read,*) master_borders(1,2) + read(unit_read,*) master_borders(2,1) + read(unit_read,*) master_borders(2,2) + read(unit_read,*) master_borders(3,1) + read(unit_read,*) master_borders(3,2) + read(unit_read,*) magnetic_field_file + read(unit_read,*) b_field_position_in_lab(1) + read(unit_read,*) b_field_position_in_lab(2) + read(unit_read,*) b_field_position_in_lab(3) + read(unit_read,*) b_field_position_in_lab(4) + b_field_position_in_lab(4) = b_field_position_in_lab(4)/180.d0*datan(1.d0)*4.d0 ! conversion of deg into rad + read(unit_read,*) glad_current + read(unit_read,*) b_field_borders(1,1) + read(unit_read,*) b_field_borders(1,2) + read(unit_read,*) b_field_borders(2,1) + read(unit_read,*) b_field_borders(2,2) + read(unit_read,*) b_field_borders(3,1) + read(unit_read,*) b_field_borders(3,2) +! +! detectors +! + read(unit_read,*) nbr_detectors + allocate( detector_position_in_lab(0:nbr_detectors,4) ) + allocate( detector_xy_plane(nbr_detectors,4) ) + allocate( derivative_variable(2*nbr_detectors,nbr_variables) ) + allocate( offset_variable(2*nbr_detectors,nbr_variables) ) + allocate( detector_name(nbr_detectors) ) + allocate( sum_tracks(2*nbr_detectors) ) + allocate( sum_xi(2*nbr_detectors) ) + allocate( sum_xixi(2*nbr_detectors) ) + allocate( sum_yi(2*nbr_detectors) ) + allocate( sum_xiyi(2*nbr_detectors) ) + allocate( sum_det_xi(2*nbr_detectors) ) + allocate( sum_det_xixi(2*nbr_detectors) ) + allocate( sum_det_tracks(nbr_detectors) ) + allocate( det_det(nbr_detectors) ) + allocate( det_hit(nbr_detectors) ) + allocate( det_passed(nbr_detectors) ) + allocate( stopping_power(nbr_detectors) ) + allocate( detector_range(nbr_detectors,3,3) ) + allocate( derivative_theta(nbr_detectors) ) + allocate( offset_theta(nbr_detectors) ) + allocate( derivative_x(nbr_detectors) ) + allocate( offset_x(nbr_detectors) ) + allocate( derivative_q_over_a(nbr_detectors) ) + allocate( offset_q_over_a(nbr_detectors) ) + allocate( offset_ave_x(nbr_detectors) ) + allocate( offset_ave_y(nbr_detectors) ) + allocate( detector_track_interactions_lab_frame(nbr_detectors,3) ) + allocate( detector_track_interactions_time(nbr_detectors) ) + allocate( detector_track_interactions_path(nbr_detectors) ) + allocate( detector_track_interactions_det_frame(nbr_detectors,3) ) + allocate( detector_track_interactions_det_frame_ref(nbr_detectors,3) ) + allocate( detector_track_interactions_det_frame_ref_step(nbr_detectors,3) ) + allocate( track_det_frame(nbr_detectors,3) ) + allocate( track_det_frame1(nbr_detectors,3) ) + allocate( track_det_frame2(nbr_detectors,3) ) + allocate( track_lab_frame(nbr_detectors,3) ) + allocate( sigma_track(nbr_detectors,3) ) + allocate( sigma_track2(nbr_detectors,3) ) + allocate( track_hit_pattern(nbr_detectors) ) + allocate( track_hit_pattern1(nbr_detectors) ) + allocate( track_hit_pattern2(nbr_detectors) ) + allocate( detector_position_spectra(nbr_detectors,3,nbr_channels_position_spectra) ) + allocate( detector_position_spectra_paramter(nbr_detectors,3,nbr_paramters_position_spectra) ) + allocate( a2_matrix_inv_array(2**nbr_detectors-1,2,2) ) + allocate( a2_matrix_array(2**nbr_detectors-1,2,2) ) + allocate( t2_matrix_inv_array(2**nbr_detectors-1,2,2) ) + allocate( a3_matrix_inv_array(2**nbr_detectors-1,3,3) ) + allocate( a3_matrix_array(2**nbr_detectors-1,3,3) ) + allocate( t3_matrix_inv_array(2**nbr_detectors-1,3,3) ) + allocate( a5_matrix_inv_array( 2**(2*nbr_detectors),5,5 ) ) + allocate( t5_matrix_inv_array( 2**(2*nbr_detectors),5,5 ) ) + detector_position_spectra = 0. + detector_position_in_lab = 0. + detector_position_in_lab(0,:) = b_field_position_in_lab + do i=1,nbr_detectors + read(unit_read,*) detector_name(i) + do j=1,4 + read(unit_read,*) detector_position_in_lab(i,j) + end do + do j=1,3 + read(unit_read,*) detector_range(i,j,1:2) + end do + read(unit_read,*) stopping_power(i) + do j=1,3 + read(unit_read,*) sigma_track(i,j) + end do + detector_position_in_lab(i,4) = detector_position_in_lab(i,4)/180.d0*datan(1.d0)*4.d0 ! conversion of deg into rad + x1 = 0. + call get_lab_position(i,x1,x0) ! x0 is now the detector coordinate's origin in the lab frame + call get_lab_position(i,norm_z,x1) ! x1 is now the detector coordinate's (0,0,1) point in the lab frame + detector_xy_plane(i,1:3) = x1-x0 ! vector perpendicular to the detector's xy-plane in te lab frame + detector_xy_plane(i,4 ) = dot_product(x0,detector_xy_plane(i,1:3)) + x1 = ( detector_range(i,:,2) + detector_range(i,:,1) ) / 2. + if ( inside_b_field(x1) ) print*, 'Detector ',trim(detector_name(i)),' is inside the B-field.' + end do + detector_range(:,:,3) = dabs( detector_range(:,:,2) - detector_range(:,:,1) ) + close(unit_read) + sigma_track2 = sigma_track**2 +! + print*,'x-borders (m): ',master_borders(1,:) + print*,'y-borders (m): ',master_borders(2,:) + print*,'z-borders (m): ',master_borders(3,:) +! + print*,'x-b-field-borders (m): ',b_field_borders(1,:) + print*,'y-b-field-borders (m): ',b_field_borders(2,:) + print*,'z-b-field-borders (m): ',b_field_borders(3,:) +! + print* + call b_field_init + print* + print*,'init done' + print* + +end + +subroutine single_track + use vars + implicit none + logical x_sign, inside_master, inside_b_field, inside_detector, inside + double precision d_xy_det(nbr_detectors), d_xy_det_old(nbr_detectors) + double precision distance_detector_plane, x_local(3), ekin, p_total, p(3) + integer i, j, k +! + t = 0. + x = x_start +! + call get_velocity(x(4:6)) + dt_fine = spatial_resolution / dsqrt(dot_product(v,v)) + if (reference_track) then + dt_fine = dt_fine/5.d0 + print*,'Mass, Momentum: ', m, x(4:6) + print*,'Velocity: ', v, dsqrt(dot_product(v,v)) + print*,'dt inside B-field: ', dt_fine , ' s' + print*,'dt outside B-field: ', dt_coarse , ' s' + end if + dt_coarse = dt_fine *10.d0 + nbr_steps = 0 + detector_track_interactions_lab_frame = 0. + detector_track_interactions_time = 0. + detector_track_interactions_det_frame = 0. + det_hit = .false. + det_passed = .false. + do i=1,nbr_detectors + d_xy_det_old(i) = distance_detector_plane( i, x(1:3) ) + end do + do while ( inside_master(x(1:3)) .and. t<1.d-3) + if (inside_b_field(x(1:3)) ) then + dt = dt_fine + nbr_steps(1) = nbr_steps(1)+1 + else + dt = dt_coarse + nbr_steps(2) = nbr_steps(2)+1 + end if + call runge_kutta + if (reference_track .and. grafical_output) write(9,*) x(1:3) + if (debug_track) write(22,*) x(1:3) + t = t + dt + x = x + dx +! + do i=1,nbr_detectors + if (.not. det_passed(i)) then ! intersection point of this detector not yet determined + d_xy_det(i) = distance_detector_plane( i, x(1:3) ) + if (d_xy_det(i) * d_xy_det_old(i) < 0. ) then ! sign has changed in last step + ! + ! here we can easily include the stopping power, since we know that the detector was crossed + ! + detector_track_interactions_lab_frame(i,:) = x(1:3) -d_xy_det(i)/(d_xy_det(i) - d_xy_det_old(i)) * dx(1:3) + detector_track_interactions_time(i) = t -d_xy_det(i)/(d_xy_det(i) - d_xy_det_old(i)) * dt + call get_det_position(i,detector_track_interactions_lab_frame(i,:),detector_track_interactions_det_frame(i,:)) + x_local = detector_track_interactions_lab_frame(i,:) + inside = inside_detector( i,x_local ) + if (inside ) then + if (stopping_power(i) > 0.d0) then +! print*,detector_name(i), inside, 'will consider stopping power' + p = x(4:6) + ekin = dsqrt((m*c2)**2+dot_product(p,p)*c2 ) - m*c2 + ekin = ekin*(1.d0-stopping_power(i)) + p_total = dsqrt( (ekin+m*c2)**2-(m*c2)**2)/c + x(4:6) = p*p_total/dsqrt(dot_product(p,p)) +! call get_velocity(x(4:6)) + end if + det_hit(i) = .true. + end if + det_passed(i) = .true. + end if + d_xy_det_old(i) = d_xy_det(i) + end if + end do + end do +! + if (reference_track) then + print*,'Final:' , t,x(1:3), inside_master(x(1:3)) + call get_velocity(x(4:6)) + print*,'Final angle:' , atan(v(1)/v(3)) * 180/3.14,' deg' + call get_linear_slope_parameters(x_start) + print*,'Slope incoming:' , real(slope_parameter) + call get_linear_slope_parameters(x) + print*,'Slope outgoing:' , real(slope_parameter) + print*,'Outgoing angle (x):' , abs(datan(slope_parameter(1))*180/3.14),' deg' + print*,'Number of steps (fine/coarse):' , nbr_steps + print* + print*,'Interception points of reference track in det-frame: ' + print*,'detector x (m) y (m) z (m)' + do i=1,nbr_detectors + write(*,'(A10,A2)',advance='no')detector_name(i),': ' + if (det_passed(i)) then + print*,real(detector_track_interactions_det_frame(i,:)) + else + print*,'no hit' + end if + end do + print* + print*,'Interception points of reference track in lab-frame: ' + print*,'detector x (m) y (m) z (m)' + do i=1,nbr_detectors + write(*,'(A10,A2)',advance='no')detector_name(i),': ' + if (det_passed(i)) then + print*,real(detector_track_interactions_lab_frame(i,:)) + else + print*,'no hit' + end if + end do + print* + print*,'Interception time and flightpath of reference track: ' + print*,'detector : t (s) , flightpath (m)' + detector_track_interactions_path = detector_track_interactions_time*dsqrt(dot_product(v,v)) + do i=1,nbr_detectors + write(*,'(A10,A2)',advance='no')detector_name(i),': ' + if (det_passed(i)) then + print*,real(detector_track_interactions_time(i)) , real(detector_track_interactions_path(i)) + else + print*,'no hit' + end if + end do + print* + end if +end + +subroutine get_derivative_b_field(t_local,x_local) + use vars + implicit none + double precision :: t_local,x_local(nbr_dimensions) +! + call get_velocity(x_local(4:6)) ! momentum -> velocity + derivative_b_field(1:3) = v ! (x',y',z') +! + call get_b_field(x_local(1:3)) +! + derivative_b_field(4) = q*(v(2)*b_field(3) - v(3)*b_field(2)) ! px' , Lorentz-Force + derivative_b_field(5) = q*(v(3)*b_field(1) - v(1)*b_field(3)) ! py' + derivative_b_field(6) = q*(v(1)*b_field(2) - v(2)*b_field(1)) ! pz' +! +end + +subroutine get_velocity(p) + use vars + implicit none + double precision :: p(3) +! + v = p/dsqrt(m2+dot_product(p,p)/c2 ) ! relativistic expression +end + +subroutine get_linear_slope_parameters(x_local) + use vars + implicit none + double precision :: x_local(nbr_dimensions), v_local(3) +! + v_local = x_local(4:6)/dsqrt(m2+dot_product(x_local(4:6),x_local(4:6))/c2 ) ! relativistic expression +! +! x - Parameters x(z) = slope_parameter(1) * z + slope_parameter(2) +! + slope_parameter(1) = v_local(1)/v_local(3) + slope_parameter(2) = slope_parameter(1)*x_local(3) + x_local(1) +! +! y - Parameters y(z) = slope_parameter(3) * z + slope_parameter(4) +! + slope_parameter(3) = v_local(2)/v_local(3) + slope_parameter(4) = slope_parameter(3)*x_local(3) + x_local(2) +! +end + + +subroutine get_b_field(xyz_local) + use vars + implicit none + double precision :: xyz_local(3) ,xyz(3) , b(3) + double precision :: d_l(3), d_h(3), f(8) + integer h_l(3),h_h(3) + logical inside_local +! + b_field = 0. + xyz = b_field_resolution_factor*xyz_local + h_l = floor(xyz) + h_h = h_l + 1 + inside_local = (h_l(1) >= b_field_map_limits(1,1)) .and. (h_h(1) <= b_field_map_limits(1,2)) .and. & + (h_l(2) >= b_field_map_limits(2,1)) .and. (h_h(2) <= b_field_map_limits(2,2)) .and. & + (h_l(3) >= b_field_map_limits(3,1)) .and. (h_h(3) <= b_field_map_limits(3,2)) + if (inside_local) then + d_l = xyz - h_l + d_h = h_h - xyz + f(1) = (d_h(1)*d_h(2)*d_h(3)) + f(2) = (d_h(1)*d_h(2)*d_l(3)) + f(3) = (d_h(1)*d_l(2)*d_h(3)) + f(4) = (d_l(1)*d_h(2)*d_h(3)) + f(5) = (d_l(1)*d_l(2)*d_h(3)) + f(6) = (d_l(1)*d_h(2)*d_l(3)) + f(7) = (d_h(1)*d_l(2)*d_l(3)) + f(8) = (d_l(1)*d_l(2)*d_l(3)) + + f = f / sum(f) + + b = f(1)*b_field_map(h_l(1),h_l(2),h_l(3),:) + b = b + f(2)*b_field_map(h_l(1),h_l(2),h_h(3),:) + b = b + f(3)*b_field_map(h_l(1),h_h(2),h_l(3),:) + b = b + f(4)*b_field_map(h_h(1),h_l(2),h_l(3),:) + b = b + f(5)*b_field_map(h_h(1),h_h(2),h_l(3),:) + b = b + f(6)*b_field_map(h_h(1),h_l(2),h_h(3),:) + b = b + f(7)*b_field_map(h_l(1),h_h(2),h_h(3),:) + b = b + f(8)*b_field_map(h_h(1),h_h(2),h_h(3),:) + b_field = b + end if +end + +subroutine runge_kutta + use vars + implicit none + double precision k1(nbr_dimensions),k2(nbr_dimensions),k3(nbr_dimensions),k4(nbr_dimensions) + double precision :: t_local,x_local(nbr_dimensions) +! + t_local = t + x_local = x + call get_derivative_b_field(t_local,x_local) + k1 = derivative_b_field +! + t_local = t + dt/2.d0 + x_local = x + dt*k1/2.d0 + call get_derivative_b_field(t_local,x_local) + k2 = derivative_b_field +! +! t_local = t + dt/2.d0 + x_local = x + dt*k2/2.d0 + call get_derivative_b_field(t_local,x_local) + k3 = derivative_b_field +! + t_local = t + dt + x_local = x + dt*k3 + call get_derivative_b_field(t_local,x_local) + k4 = derivative_b_field +! + dx = (k1 + k2 + k2 + k3 + k3 + k4)*dt/6.d0 +end + +subroutine make_pics + use vars + implicit none + character*200 sh_command +! +!! sh_command = 'gle -d png ' // trim(output_file(3)) // ' >/dev/null' +!! call execute_command_line (sh_command) +! + sh_command = 'gle -d pdf ' // trim(output_file(3)) // ' >/dev/null' + call execute_command_line (sh_command) +! +end + +subroutine make_single_track_pic + use vars + implicit none + character*200 sh_command +! + sh_command = 'gle -d pdf ' // trim(track_debug_gle_file) // ' >/dev/null' + sh_command = 'gle -d pdf ' // trim(track_debug_gle_file) + call execute_command_line (sh_command) +! +end + +subroutine make_gle_positions(variable) + use vars + implicit none + integer uc, i, j, k, det_id, koordinate,slash_position, length + logical backwards + character (LEN=256) local_output_file(3), shell_command + character (LEN=10) :: ch10 + CHARACTER(LEN=*), INTENT(IN) :: variable + character*7 param(2) + real off_set(2), frame_size(2), graph_size(2), axis_range(2,2),xyz +! + uc=10 + backwards=.true. +! + frame_size = 20. ! frame size (20 ; 20) + off_set = 3. ! graph-offset of drawing inside frame (3 ; 3) + graph_size = 15. ! graph size (15 ; 15) +! + do det_id = 1,nbr_detectors ! tofd + write(ch10,'(I3.3)') det_id + do koordinate=1,1 ! x-axis + if (detector_position_spectra_paramter(det_id,koordinate,6) > 0.) then + ch10 = trim(ch10) // '_' // ch_xyz(koordinate) + slash_position = index(output_file(1),'/',backwards) + length = len(output_file(1)) + local_output_file(2) = output_file(1)(slash_position+1:length) + local_output_file(3) = trim(local_output_file(2)) // '_detector_' // trim(ch10) // '_' // trim(variable) // '.dat' + local_output_file(1) = trim(output_file(1)) // '_detector_' // trim(ch10) // '_' // trim(variable) // '.dat' + local_output_file(2) = trim(output_file(1)) // '_detector_' // trim(ch10) // '_' // trim(variable) // '.gle' + open(unit=uc, file=local_output_file(1)) + do k= int(detector_position_spectra_paramter(det_id,koordinate,5)),& + int(detector_position_spectra_paramter(det_id,koordinate,6)) + xyz = (real(k) - 0.5) / real(nbr_channels_position_spectra) * & + detector_range(det_id,koordinate,3) + detector_range(det_id,koordinate,1) + write(uc,*) xyz,detector_position_spectra(det_id,koordinate,k) + end do + close(uc) + axis_range(1,:) = detector_position_spectra_paramter(det_id,koordinate,3:4) ! xmin, xmax on x-axis +! print*,axis_range(1,:) +! axis_range(2,1) = -3.5 ! ymin on y-axis +! axis_range(2,2) = 1.5 ! ymax on y-axis + open(unit=uc, file=local_output_file(2)) + write(uc, *) 'size ', frame_size + write(uc, *) 'amove ', off_set + write(uc, *) 'begin graph' + write(uc, *) ' nobox' + write(uc, *) ' fullsize' + write(uc, *) ' size ', graph_size + write(param(1:2),'(f7.5)') real(detector_position_spectra_paramter(det_id,koordinate,1:2)) + write(uc, *) ' title "',trim(detector_name(det_id)),' x_{mean} = ', & + param(1),', \sigma = ',param(2),' m " hei 0.7' + write(uc, *) ' xtitle "',ch_xyz(koordinate),'-position (m)" hei 0.6' + write(uc, *) ' ytitle "Number of hits" hei 0.6' + write(uc, *) ' xaxis min ',axis_range(1,1), ' max ',axis_range(1,2) +! write(uc, *) ' yaxis min ',axis_range(2,1), ' max ',axis_range(2,2) + ! write(uc, *) ' xaxis min 55 max 200' + ! write(uc, *) ' yaxis max 1.2 log' + write(uc, *) ' x2axis off' + write(uc, *) ' y2axis off' + write(uc, *) ' xlabels hei 0.6' + write(uc, *) ' ylabels hei 0.6' + write(uc, *) ' key pos tl hei 0.6' + write(uc, *) ' data ',trim(local_output_file(3)),' d4=c1,c2 ' + ! write(uc, *) ' d4 marker fcircle msize 0.01 color steelblue' + write(uc, *) ' d4 line lwidth 0.03 color blue ' + write(uc, *) 'end graph' + close(uc) + shell_command = 'gle -d pdf ' // trim(local_output_file(2)) // ' >/dev/null' + call execute_command_line (shell_command) + end if + end do + end do +end + +subroutine make_gle + use vars + implicit none + integer uc, i, j, k,slash_position,length + real off_set(2), frame_size(2), graph_size(2), axis_range(2,2), x_target(2), x_magnet(2), x_lab(2), x_det(2) + real x_vec(2) + double precision x_b(3), x_l(3), x_d(3) + character*256 data_link + logical backwards +! + uc=10 + frame_size(1) = 40. ! frame size (40 ; 20) + frame_size(2) = 20. ! frame size (40 ; 20) + off_set = 3. ! graph-offset of drawing inside frame (3 ; 3) + graph_size(1) = 30. ! graph size (30 ; 15) + graph_size(2) = 15. ! graph size (30 ; 15) + axis_range(1,1) = -1. ! xmin on x-axis + axis_range(1,2) = 9. ! xmax on x-axis + axis_range(2,1) = -3.5 ! ymin on y-axis + axis_range(2,2) = 1.5 ! ymax on y-axis + backwards=.true. + slash_position = index(output_file(2),'/',backwards) + length = len(output_file(2)) + data_link = output_file(2)(slash_position+1:length) + open(unit=uc, file=output_file(3)) + write(uc, *) 'size ', frame_size + write(uc, *) 'include "shape.gle" ' + write(uc, *) 'amove ', off_set + write(uc, *) 'begin graph' + write(uc, *) ' nobox' + write(uc, *) ' fullsize' + write(uc, *) ' size ', graph_size + write(uc, *) ' title "A track through GLAD... ',nbr_steps(1),' steps " hei 0.7' + write(uc, *) ' ytitle "x-position (m)" hei 0.6' + write(uc, *) ' xtitle "z-position (m)" hei 0.6' + write(uc, *) ' xaxis min ',axis_range(1,1), ' max ',axis_range(1,2) + write(uc, *) ' yaxis min ',axis_range(2,1), ' max ',axis_range(2,2) +! write(uc, *) ' xaxis min 55 max 200' +! write(uc, *) ' yaxis max 1.2 log' + write(uc, *) ' x2axis off' + write(uc, *) ' y2axis off' + write(uc, *) ' xlabels hei 0.6' + write(uc, *) ' ylabels hei 0.6' + write(uc, *) ' key pos tl hei 0.6' + write(uc, *) ' data ',trim(data_link),' d4=c3,c1 ' +! write(uc, *) ' d4 marker fcircle msize 0.01 color steelblue' + write(uc, *) ' d4 line lstyle 1 lwidth 0.01 color black ' + write(uc, *) 'end graph' +! +! some extra drawing... +! + if ((axis_range(1,1)*axis_range(1,2) < 0) .and.(axis_range(2,1)*axis_range(2,2) < 0)) then ! will draw the target, if 0 is on the plot + x_lab = 0. + x_target=off_set + (x_lab - axis_range(:,1))*graph_size/(axis_range(:,2)-axis_range(:,1)) ! 3+1*15/10 3+3.5*15/5 + write(uc, *) ' set color steelblue ' + write(uc, *) ' amove ', x_target + write(uc, *) ' circle ', graph_size(1)/70, ' fill steelblue' + write(uc, *) ' amove ', x_target(1)-graph_size(1)/40, x_target(2)+graph_size(1)/40 + write(uc, *) ' set hei', graph_size(1)/40 + write(uc, *) ' text Target' + end if +! +! magnetic field +! + x_b = 0. + call get_lab_position(0,x_b, x_l) + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_magnet=off_set + (x_lab - axis_range(:,1))*graph_size/(axis_range(:,2)-axis_range(:,1)) + write(uc, *) ' set color firebrick ' + write(uc, *) ' amove ', x_magnet + write(uc, *) ' circle ', graph_size(1)/100, ' fill firebrick' + write(uc, *) ' set hei', graph_size(1)/40 + write(uc, *) ' amove ', x_magnet(1)-0*graph_size(1)/10, x_magnet(2)+2*graph_size(1)/40 + write(uc, *) ' text Magnet' + write(uc, *) ' amove ', x_magnet(1)-0*graph_size(1)/10, x_magnet(2)+1*graph_size(1)/40 + write(uc, *) ' text Reference' + write(uc, *) ' amove ', x_magnet + x_b(3) = 1.d0 + call get_lab_position(0,x_b, x_l) ! ID 0 .. magnet + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_vec=off_set + (x_lab - axis_range(:,1))*graph_size/(axis_range(:,2)-axis_range(:,1)) + write(uc, *) ' amove ', x_magnet + write(uc, *) ' aline ', x_vec, ' arrow end' + write(uc, *) ' line_label ', x_magnet, x_vec, ' " z-axis " -0.3' +! +! detectors +! + do i= 1, nbr_detectors + x_d = 0. ! origin in detector frame + x_d(1) = detector_range(i,1,1) ! minimum range in x-axis in det frame + call get_lab_position(i,x_d, x_l) + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_det=off_set + (x_lab - axis_range(:,1))*graph_size/(axis_range(:,2)-axis_range(:,1)) + x_d = 0. ! origin in detector frame + x_d(1) = detector_range(i,1,1) ! minimum range in x-axis in det frame + x_d(3) = 0.3 ! + call get_lab_position(i,x_d, x_l) + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_vec=off_set + (x_lab - axis_range(:,1))*graph_size/(axis_range(:,2)-axis_range(:,1)) + write(uc, *) ' amove ', x_det + write(uc, *) ' set color green ' + write(uc, *) ' aline ', x_vec, ' arrow end' + write(uc, *) ' line_label ', x_det, x_vec, ' "z" 0.1' + x_d = 0. ! origin in detector frame + x_d(1) = detector_range(i,1,2) ! maximum range in x-axis in det frame + call get_lab_position(i,x_d, x_l) + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_vec=off_set + (x_lab - axis_range(:,1))*graph_size/(axis_range(:,2)-axis_range(:,1)) + write(uc, *) ' amove ', x_det + write(uc, *) ' set color blue ' + write(uc, *) ' aline ', x_vec, ' arrow end' + write(uc, *) ' line_label ', x_det, x_vec, ' " ', trim(detector_name(i)),' " 0.1' + end do + + close(uc) +end + +subroutine make_gle_single_track + use vars + implicit none + integer uc, i, j, k + real frame_size(2), graph_size(2), x_target(2), x_magnet(2), x_lab(2), x_det(2) + real off_set_x(2),off_set_y(2), axis_range_x(2,2), axis_range_y(2,2) + real x_vec(2), y_lab(2), y_t(2), y_det(2) + double precision x_b(3), x_l(3), x_d(3) +! + uc=10 + frame_size(1) = 40. ! frame size (40 ; 40) + frame_size(2) = 40. ! frame size (40 ; 40) + off_set_x(1) = 3. ! graph-offset of x-track-drawing inside frame + off_set_x(2) = 23. ! graph-offset of x-track-drawing inside frame + off_set_y(1) = 3. ! graph-offset of y-track-drawing inside frame + off_set_y(2) = 3. ! graph-offset of y-track-drawing inside frame + graph_size(1) = 30. ! graph size (30 ; 15) + graph_size(2) = 15. ! graph size (30 ; 15) + axis_range_x(1,1) = -1. ! xmin on x-axis + axis_range_x(1,2) = 9. ! xmax on x-axis + axis_range_x(2,1) = -3.5 ! ymin on y-axis , x-track + axis_range_x(2,2) = 1.5 ! ymax on y-axis , x-track + axis_range_y(1,:) = axis_range_x(1,:) + axis_range_y(2,1) = -2.5 ! ymin on y-axis , y-track + axis_range_y(2,2) = 2.5 ! ymax on y-axis , y-track + open(unit=uc, file=trim(track_debug_gle_file)) + write(uc, *) 'size ', frame_size + write(uc, *) 'include "shape.gle" ' + write(uc, *) 'amove ', off_set_x + write(uc, *) 'begin graph' + write(uc, *) ' nobox' + write(uc, *) ' fullsize' + write(uc, *) ' size ', graph_size + write(uc, *) ' title "x-track through GLAD... ',nbr_steps(1),' steps " hei 0.7' + write(uc, *) ' ytitle "x-position (m)" hei 0.6' + write(uc, *) ' xtitle "z-position (m)" hei 0.6' + write(uc, *) ' xaxis min ',axis_range_x(1,1), ' max ',axis_range_x(1,2) + write(uc, *) ' yaxis min ',axis_range_x(2,1), ' max ',axis_range_x(2,2) + write(uc, *) ' x2axis off' + write(uc, *) ' y2axis off' + write(uc, *) ' xlabels hei 0.6' + write(uc, *) ' ylabels hei 0.6' + write(uc, *) ' key pos tr hei 0.6' + write(uc, *) ' data ',trim(track_debug_file),' d4=c3,c1 ' + write(uc, *) ' data ',trim(output_file(2)),' d5=c3,c1 ' + + write(uc, *) ' d4 line lstyle 1 lwidth 0.01 color blue key "current track"' + write(uc, *) ' d5 line lstyle 1 lwidth 0.01 color black key "reference track" ' + write(uc, *) 'end graph' +! + write(uc, *) 'amove ', off_set_y + write(uc, *) 'begin graph' + write(uc, *) ' nobox' + write(uc, *) ' fullsize' + write(uc, *) ' size ', graph_size + write(uc, *) ' title "y-track through GLAD... ',nbr_steps(1),' steps " hei 0.7' + write(uc, *) ' ytitle "y-position (m)" hei 0.6' + write(uc, *) ' xtitle "z-position (m)" hei 0.6' + write(uc, *) ' xaxis min ',axis_range_y(1,1), ' max ',axis_range_y(1,2) + write(uc, *) ' yaxis min ',axis_range_y(2,1), ' max ',axis_range_y(2,2) + write(uc, *) ' x2axis off' + write(uc, *) ' y2axis off' + write(uc, *) ' xlabels hei 0.6' + write(uc, *) ' ylabels hei 0.6' + write(uc, *) ' key pos tr hei 0.6' + write(uc, *) ' data ',trim(track_debug_file),' d4=c3,c2 ' + write(uc, *) ' data ',trim(output_file(2)),' d5=c3,c2 ' + + write(uc, *) ' d4 line lstyle 1 lwidth 0.01 color blue key "current track"' + write(uc, *) ' d5 line lstyle 1 lwidth 0.01 color black key "reference track" ' + write(uc, *) 'end graph' +! +! some extra drawing... +! + if ((axis_range_x(1,1)*axis_range_x(1,2) < 0) .and.(axis_range_x(2,1)*axis_range_x(2,2) < 0)) then ! will draw the target, if 0 is on the plot + x_lab = 0. + x_target=off_set_x + (x_lab - axis_range_x(:,1))*graph_size/(axis_range_x(:,2)-axis_range_x(:,1)) ! 3+1*15/10 3+3.5*15/5 + write(uc, *) ' set color steelblue ' + write(uc, *) ' amove ', x_target + write(uc, *) ' circle ', graph_size(1)/200, ' fill steelblue' + write(uc, *) ' amove ', x_target(1)-graph_size(1)/40, x_target(2)+graph_size(1)/40 + write(uc, *) ' set hei', graph_size(1)/40 + write(uc, *) ' text Target' + end if + if ((axis_range_y(1,1)*axis_range_y(1,2) < 0) .and.(axis_range_y(2,1)*axis_range_y(2,2) < 0)) then ! will draw the target, if 0 is on the plot + y_lab = 0. + y_t=off_set_y + (y_lab - axis_range_y(:,1))*graph_size/(axis_range_y(:,2)-axis_range_y(:,1)) ! 3+1*15/10 3+3.5*15/5 + write(uc, *) ' set color steelblue ' + write(uc, *) ' amove ', y_t + write(uc, *) ' circle ', graph_size(1)/200, ' fill steelblue' + write(uc, *) ' amove ', y_t(1)-graph_size(1)/40, y_t(2)+graph_size(1)/40 + write(uc, *) ' set hei', graph_size(1)/40 + write(uc, *) ' text Target' + end if +! +! magnetic field +! + x_b = 0. + call get_lab_position(0,x_b, x_l) + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_magnet=off_set_x + (x_lab - axis_range_x(:,1))*graph_size/(axis_range_x(:,2)-axis_range_x(:,1)) + write(uc, *) ' set color firebrick ' + write(uc, *) ' amove ', x_magnet + write(uc, *) ' circle ', graph_size(1)/100, ' fill firebrick' + write(uc, *) ' set hei', graph_size(1)/40 + write(uc, *) ' amove ', x_magnet(1)-0*graph_size(1)/10, x_magnet(2)+2*graph_size(1)/40 + write(uc, *) ' text Magnet' + write(uc, *) ' amove ', x_magnet(1)-0*graph_size(1)/10, x_magnet(2)+1*graph_size(1)/40 + write(uc, *) ' text Reference' + write(uc, *) ' amove ', x_magnet + x_b(3) = 1.d0 + call get_lab_position(0,x_b, x_l) ! ID 0 .. magnet + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_vec=off_set_x + (x_lab - axis_range_x(:,1))*graph_size/(axis_range_x(:,2)-axis_range_x(:,1)) + write(uc, *) ' amove ', x_magnet + write(uc, *) ' aline ', x_vec, ' arrow end' + write(uc, *) ' line_label ', x_magnet, x_vec, ' " z-axis " -0.3' +! +! detectors +! + do i= 1, nbr_detectors + if (track_hit_pattern(i)) then + x_d = track_det_frame(i,:) + call get_lab_position(i,x_d, x_l) +! + x_lab(1) = x_l(3) ! z-component goes to x-axis + x_lab(2) = x_l(1) ! x-component goes to y-axis + x_det=off_set_x + (x_lab - axis_range_x(:,1))*graph_size/(axis_range_x(:,2)-axis_range_x(:,1)) + write(uc, *) ' amove ', x_det + write(uc, *) ' set color green ' + write(uc, *) ' circle ', graph_size(1)/200, ' fill green' +! + y_lab(1) = x_l(3) ! z-component goes to x-axis + y_lab(2) = x_l(2) ! y-component goes to y-axis + y_det=off_set_y + (y_lab - axis_range_y(:,1))*graph_size/(axis_range_y(:,2)-axis_range_y(:,1)) + write(uc, *) ' amove ', y_det + write(uc, *) ' set color green ' + write(uc, *) ' circle ', graph_size(1)/200, ' fill green' + end if + end do + + close(uc) +end + + +double precision function distance_detector_plane(volume_id,x_det) + use vars + implicit none + double precision :: x_det(3) + integer volume_id +! + distance_detector_plane = dot_product(x_det,detector_xy_plane(volume_id,1:3)) - detector_xy_plane(volume_id,4) +end + +! +! convertes detector-coordinates into lab-coordinates +! +subroutine get_lab_position(volume_id,x_det, x_lab ) + use vars + implicit none + double precision :: x_det(3), x_lab(3) + integer volume_id +! + x_lab(1) = x_det(1) * dcos(detector_position_in_lab(volume_id,4)) - x_det(3) * dsin(detector_position_in_lab(volume_id,4)) + x_lab(2) = x_det(2) + x_lab(3) = x_det(3) * dcos(detector_position_in_lab(volume_id,4)) + x_det(1) * dsin(detector_position_in_lab(volume_id,4)) + x_lab = x_lab + detector_position_in_lab(volume_id,1:3) +end + +! +! convertes lab-coordinates into detector-coordinates +! +subroutine get_det_position(volume_id,x_lab, x_det ) + use vars + implicit none + double precision :: x_det(3), x_lab(3) , x_tmp(3) + integer volume_id +! + x_tmp = x_lab - detector_position_in_lab(volume_id,1:3) + x_det(1) = x_tmp(1) * dcos(detector_position_in_lab(volume_id,4)) + x_tmp(3) * dsin(detector_position_in_lab(volume_id,4)) + x_det(2) = x_tmp(2) + x_det(3) = x_tmp(3) * dcos(detector_position_in_lab(volume_id,4)) - x_tmp(1) * dsin(detector_position_in_lab(volume_id,4)) +end + +! +! determines, if lab-coordinates are inside a detector +! +logical function inside_detector(volume_id, x_lab) + use vars + implicit none + integer volume_id, i, j + logical inside + double precision x_det(3),x_lab(3) +! + call get_det_position(volume_id,x_lab, x_det ) + inside = .true. + do i=1,3 + inside = inside .and. (x_det(i) > detector_range(volume_id,i,1)) + inside = inside .and. (x_det(i) < detector_range(volume_id,i,2)) + end do + inside_detector = inside +end + +logical function inside_master(xyz_local) + use vars + implicit none + double precision :: xyz_local(3) +! + inside_master = (xyz_local(1) > master_borders(1,1)) .and. (xyz_local(1) < master_borders(1,2)) .and. & + (xyz_local(2) > master_borders(2,1)) .and. (xyz_local(2) < master_borders(2,2)) .and. & + (xyz_local(3) > master_borders(3,1)) .and. (xyz_local(3) < master_borders(3,2)) +end + +logical function inside_b_field(xyz_local) + use vars + implicit none + double precision :: xyz_local(3) +! + inside_b_field = (xyz_local(1) > b_field_borders(1,1)) .and. (xyz_local(1) < b_field_borders(1,2)) .and. & + (xyz_local(2) > b_field_borders(2,1)) .and. (xyz_local(2) < b_field_borders(2,2)) .and. & + (xyz_local(3) > b_field_borders(3,1)) .and. (xyz_local(3) < b_field_borders(3,2)) +end + +subroutine b_field_init + use vars + implicit none + integer limits(3,3), ch(3), ch_l(3), ch_h(3), h_l(3), h_h(3) + double precision dummy(3), x_lab(3), x_b(3), x_t(3), phi, xyz(3) + double precision b_low(3), b_high(3), b(3) + double precision, allocatable :: b_field_map_orig(:,:,:,:) ! map of magnetic field... (x,y,z,1:3) , last entry for Bx,By,Bz + double precision range_b_field(3,2), d_l(3), d_h(3), f(8) + logical l1, l2, l3 + integer ii + integer i, j, k +! + range_b_field = 0. + open (unit=8, file=magnetic_field_file, status='old') + read(8,*) + do i=1,3 + read(8,*) limits(i,:) + end do + limits(:,1:2) = limits(:,1:2) / 5 ! this is fixed, see map! + limits(:,3) = limits(:,3) + 1 + allocate(b_field_map_orig(limits(1,1)-1:limits(1,2)+1,limits(2,1)-1:limits(2,2)+1,limits(3,1)-1:limits(3,2)+1,3 ) ) + b_field_map_orig = 0. + do i=limits(1,1),limits(1,2) + do j=limits(2,1),limits(2,2) + do k=limits(3,1),limits(3,2) + read(8,*) dummy , b_field + b_field_map_orig(i,j,k,:) = b_field + if (j==0 .and. dabs(b_field(2)) > 0.) then +! if (i==0) print*,i,j,k,dummy,b_field + do ii=1,3 + if (b_field(ii) < range_b_field(ii,1) ) range_b_field(ii,1) = b_field(ii) + if (b_field(ii) > range_b_field(ii,2) ) range_b_field(ii,2) = b_field(ii) + end do + end if + end do + end do + end do + close(8) + do ii=1,3 + print*,'Range b-field for y==0', range_b_field(ii,1) , range_b_field(ii,2) + end do + + ch_l = b_field_resolution_factor*b_field_borders(:,1) + ch_h = b_field_resolution_factor*b_field_borders(:,2) + ch = ch_h - ch_l +1 + allocate(b_field_map(ch_l(1):ch_h(1),ch_l(2):ch_h(2),ch_l(3):ch_h(3),3 ) ) + b_field_map = 0. + phi = b_field_position_in_lab(4) + print*,'phi ',phi + do i=ch_l(1),ch_h(1) + do j=ch_l(2),ch_h(2) + do k=ch_l(3),ch_h(3) +! do i=0,0 +! do j=-6,-6 +! do k=ch_l(3),ch_h(3) + x_lab(1) = dble(i) / dble(b_field_resolution_factor) + x_lab(2) = dble(j) / dble(b_field_resolution_factor) + x_lab(3) = dble(k) / dble(b_field_resolution_factor) + x_t = x_lab - b_field_position_in_lab(1:3) ! transition + x_b(1) = x_t(1)*dcos(phi) + x_t(3)*dsin(phi) ! rotation around y-axis + x_b(2) = x_t(2) ! rotation around y-axis + x_b(3) = x_t(3)*dcos(phi) - x_t(1)*dsin(phi) ! rotation around y-axis +! + xyz = b_field_resolution_factor*x_b ! now we are in the frame of the glad-magnet + h_l = floor(xyz) + if ( (h_l(1) > limits(1,1)-2).and. & + (h_l(2) > limits(2,1)-2).and. & + (h_l(3) > limits(3,1)-2) ) then + h_h = h_l + 1 + if ( (h_h(1) <= limits(1,2)+1) .and. (h_h(2) <= limits(2,2)+1) .and. (h_h(3) <= limits(3,2)+1) ) then ! inside boundaries + d_l = xyz - h_l + d_h = h_h - xyz + + f(1) = (d_h(1)*d_h(2)*d_h(3)) + f(2) = (d_h(1)*d_h(2)*d_l(3)) + f(3) = (d_h(1)*d_l(2)*d_h(3)) + f(4) = (d_l(1)*d_h(2)*d_h(3)) + f(5) = (d_l(1)*d_l(2)*d_h(3)) + f(6) = (d_l(1)*d_h(2)*d_l(3)) + f(7) = (d_h(1)*d_l(2)*d_l(3)) + f(8) = (d_l(1)*d_l(2)*d_l(3)) + + f = f / sum(f) +! print*,f +! print*,sum(f) + if (i==0 .and.j==0 .and. k==2) print*,'b-field-orig: ',b_field_map_orig(i,j,k,:) + + b = f(1)*b_field_map_orig(h_l(1),h_l(2),h_l(3),:) + b = b + f(2)*b_field_map_orig(h_l(1),h_l(2),h_h(3),:) + b = b + f(3)*b_field_map_orig(h_l(1),h_h(2),h_l(3),:) + b = b + f(4)*b_field_map_orig(h_h(1),h_l(2),h_l(3),:) + b = b + f(5)*b_field_map_orig(h_h(1),h_h(2),h_l(3),:) + b = b + f(6)*b_field_map_orig(h_h(1),h_l(2),h_h(3),:) + b = b + f(7)*b_field_map_orig(h_l(1),h_h(2),h_h(3),:) + b = b + f(8)*b_field_map_orig(h_h(1),h_h(2),h_h(3),:) +! + if (i==0 .and.j==0 .and. k==2) print*,'b-field-interpol: ',b + +! + b_field_map(i,j,k,1) = b(1)*dcos(phi) - b(3)*dsin(phi) ! rotation around y-axis, now backwards + b_field_map(i,j,k,2) = b(2) ! rotation around y-axis, now backwards + b_field_map(i,j,k,3) = b(3)*dcos(phi) + b(1)*dsin(phi) ! rotation around y-axis, now backwards + if (i==0 .and.j==0 .and. k==2) print*,'b-field-rotate: ',b_field_map(i,j,k,:) +! +! b_field_map(i,j,k,1) = 0. +! b_field_map(i,j,k,2) = (b(2)) +! b_field_map(i,j,k,3) = 0. +! if (j==0 .and. dabs(b(2)) > 0.) print*,i,j,k,b(2) + end if + end if + if (i == ch_l(1) .and. dot_product(b_field_map(i,j,k,:),b_field_map(i,j,k,:)) >0.) & + print*,'problem with b-field area, decrease x_min', i,j,k,b_field_map(i,j,k,:) + if (i == ch_h(1) .and. dot_product(b_field_map(i,j,k,:),b_field_map(i,j,k,:)) >0.) & + print*,'problem with b-field area, increase x_max', i,j,k,b_field_map(i,j,k,:) + if (j == ch_l(2) .and. dot_product(b_field_map(i,j,k,:),b_field_map(i,j,k,:)) >0.) & + print*,'problem with b-field area, decrease y_min', i,j,k,b_field_map(i,j,k,:) + if (j == ch_h(2) .and. dot_product(b_field_map(i,j,k,:),b_field_map(i,j,k,:)) >0.) & + print*,'problem with b-field area, increase y_max', i,j,k,b_field_map(i,j,k,:) + if (k == ch_l(3) .and. dot_product(b_field_map(i,j,k,:),b_field_map(i,j,k,:)) >0.) & + print*,'problem with b-field area, decrease z_min', i,j,k,b_field_map(i,j,k,:) + if (k == ch_h(3) .and. dot_product(b_field_map(i,j,k,:),b_field_map(i,j,k,:)) >0.) & + print*,'problem with b-field area, increase z_max', i,j,k,b_field_map(i,j,k,:) + end do + end do + end do +! + b_field_map_limits(:,1) = ch_l + b_field_map_limits(:,2) = ch_h + b_field_map = b_field_map * glad_current / glad_current_nominal_current +end + +!-- Author : Rene Reifarth +! +!User routine: Liefert Gaussverschmierung bei geg. sigma +! UM WERT NULL -> MUSS ZUM EIGENTL. WERT ADDIERT (!!) WERDEN +! EINHEITEN: GLEICHE EINHEIT WIE HALBWERTSBREITE +! EINGABE: HALB +! RUECKGABE: ENER +! +double precision function GAUSSVER(SIGMA) + Implicit none + double precision SIGMA,ENER,RA,Y,SHIFT,GAU,sig2,maxi, HALB + INTEGER RECHT + DIMENSION RA(4) + + if (SIGMA > 0.) then +! +! maxi= summe(2**-(k**2)) k,0,infinity +! + maxi=1.564468413606d0 +! SIGMA**2=HALB**2/LN(64) +! HALB = 2sqrt(2ln(2)) sigma +! sig2=halb**2/alog(64.) + sig2 = sigma*sigma + halb = sigma * 2.35482004503d0 + GAU=0. + Y=1. +! +! WUERFELN BIS UNTER DER GAUSSFUNKTION +! + DO WHILE (Y.GT.GAU) + call random_number(RA) + RA(1)= RA(1)*maxi +! +! WELCHES RECHTECK? +! + RECHT=1 + Y=1. + DO WHILE (RA(1).GT.Y) + RECHT=RECHT+1 + Y=Y+0.5**((RECHT-1)**2) + ENDDO +! +! WO IN DIESEM RECHTECK? LAENGE=HALB,HOEHE +! 0.5**((RECHT-1)**2) +! + ENER=(FLOAT(RECHT-1)+RA(2))*HALB + Y=0.5**((RECHT-1)**2)*RA(3) +! +! GAUSSFUNKTION +! + GAU=DEXP(-(ENER**2)/sig2/2) + END DO + IF (RA(4).GT.0.5) THEN + ENER=-ENER + END IF + GAUSSVER = ENER + else + GAUSSVER = 0. + end if +END + +! +! stand alone routine to solve the LES m*b=x ; n is the dimension of the system +! +subroutine solve_linear_equation_system(n,m,b,x) + implicit none + integer, intent(in) :: n ! rank of nxn matrix + integer i + double precision m_tmp(n,n), det_m, det_n(n) + double precision, intent(out) :: x(n) + double precision, intent(in) :: m(n,n), b(n) +! +! will solve using Cramer's rule +! + call determinant(n,m,det_m) +! + m_tmp = m + if (det_m /= 0.) then + do i=1,n + m_tmp(:,i) = b + if (i>1) m_tmp(:,i-1) = m(:,i-1) + call determinant(n,m_tmp,det_n(i)) + end do + x = det_n / det_m + else + x = 0. + end if + +end +! +! stand alone routine to determine the determinant of a nxn matrix. +! The select case could be reduced to the cases 1 and default, but the explicit treatment +! of cases 2 and 3 enhances execution speed by a factor of ~5 +! +recursive subroutine determinant(n,m,d) + implicit none + integer, intent(in) :: n ! rank of nxn matrix + integer i,j + double precision d_tmp + double precision, intent(out) :: d + double precision, intent(in) :: m(n,n) + double precision :: m_red(n-1,n-1) +! + select case(n) + case (1) + d = m(1,1) + case (2) + d = m(1,1)*m(2,2) - m(2,1)*m(1,2) + case (3) + d = m(1,1) * (m(2,2)*m(3,3) - m(2,3)*m(3,2)) & + - m(1,2) * (m(2,1)*m(3,3) - m(2,3)*m(3,1)) & + + m(1,3) * (m(2,1)*m(3,2) - m(2,2)*m(3,1)) + case default + d = 0.d0 + do i=1,n + do j=1,i-1 + m_red(:,j) = m(2:n,j) + end do + do j=i+1,n + m_red(:,j-1) = m(2:n,j) + end do + call determinant(n-1, m_red,d_tmp) + d = d_tmp * m(1,i) - d + end do + if (modulo(n,2) == 0) d = -d + end select +! +end + +! +! converts a id-number into a detector hit pattern. inverse to the function det_pattern_id +! + +subroutine get_hit_pattern(n,det_id,l) +implicit none +integer n,i, det_id, two_power, x1,x2 +logical l(n) +! + l = .false. + x1 = det_id + do i=1,n-1 + two_power = 2**(n-i) + x2 = x1 / two_power + if (x2 > 0) then + x1 = modulo(det_id,two_power) + l(i) = .true. + end if + end do + if (x1 > 0) l(n) = .true. +end + +integer function det_pattern_id(n,l) +implicit none +integer n,i, pattern_id +logical l(n) +! + pattern_id = 0 + do i=1, n-1 + if (l(i)) pattern_id = pattern_id + 1 + pattern_id = pattern_id*2 + end do + if (l(n)) pattern_id = pattern_id + 1 + det_pattern_id = pattern_id +end + +! c) von außen kommen direkt die Parameter für 2 Spuren! Schon vorsortiert, sodass der Tracker weiß, welche Punkte zu einer Spur gehören. Dann werden beide Spuren mit gemeinsamen Punkt auf dem Target gefittet. Das ist, denke ich, der goldene Weg. Denn dann kannst du wiederum außen die Permutationen durchgehen, die Dir sinnvoll erscheinen (Kombination von Ladungen auf TOFD etc). Zurück bekommst du dann 2 x den 3er Impuls / q + ch2. + +!von außen gesehen gibt es dann quasi mehrere Routinen: +!a) 1 Spur, keine Vorgaben für Target Position +!b) 1 Spur, Target Position auch eingeschränkt (die Mathematik ist etwas anders, kann ich dir gleich mal zeigen. Deshalb 2 !Routinen) +!c) 2 Spuren, gemeinsamer Target Punkt, sonst keine Einschränkungen +!d) 2 Spuren, gemeinsamer Target Punkt, Target Punkt zusätzlich eingeschränkt + +!die Spuren übergibst du dann quasi aus c++ so: +! +! int nbr_of_detectors = 7; +! double x_positions[nbr_of_detectors] ; +! double y_positions[nbr_of_detectors] ; +! double z_positions[nbr_of_detectors] ; +! bool hit_pattern[nbr_of_detectors] ; +! double track_parameter[7] ; +! single_track_from_cpp_(n_det,x_positions, y_positions, z_positions, hit_pattern, track_parameter) +! +! track paramer : 3er Impuls, chi2, position auf Target (xyz) diff --git a/tracker_rene/tracker_routines.h b/tracker_rene/tracker_routines.h new file mode 100644 index 000000000..031584ac1 --- /dev/null +++ b/tracker_rene/tracker_routines.h @@ -0,0 +1,16 @@ +#ifndef TRACKER_ROUTINES_H +#define TRACKER_ROUTINES_H + +extern"C" { + +void init_from_cpp_(); +void single_track_from_cpp_(int *n, bool *dc, double x[], double y[], double z[], bool pat[], double param[], double chi[]); +void double_track_from_cpp_(int *n,double x1[], double y1[], double z1[], bool pat1[],double x2[], double y2[], double z2[], bool pat2[] , double param1[], double param2[], double chi[]); + +// for testing purposes +void called_from_cpp_(int *n,double *db); +void called_from_cpp2_(int *n,double db2[], bool bo[], double db3[]); + +} + +#endif