diff --git a/Detectors/FIT/FDD/simulation/CMakeLists.txt b/Detectors/FIT/FDD/simulation/CMakeLists.txt index ec217c4419830..e7d672c920e2e 100644 --- a/Detectors/FIT/FDD/simulation/CMakeLists.txt +++ b/Detectors/FIT/FDD/simulation/CMakeLists.txt @@ -12,8 +12,12 @@ o2_add_library(FDDSimulation SOURCES src/Detector.cxx src/Digitizer.cxx +<<<<<<< Updated upstream PUBLIC_LINK_LIBRARIES O2::CommonUtils O2::SimulationDataFormat +======= + PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat +>>>>>>> Stashed changes O2::FDDBase O2::DataFormatsFDD O2::DetectorsRaw diff --git a/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h b/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h index 943babc0a23d0..8a38664547fba 100644 --- a/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h +++ b/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h @@ -28,6 +28,7 @@ #include #include #include +#include "FDDSimulation/FDDDigParam.h" namespace o2 { diff --git a/Detectors/FIT/FDD/simulation/include/FDDSimulation/FDDDigParam.h b/Detectors/FIT/FDD/simulation/include/FDDSimulation/FDDDigParam.h index 36f85bff24d6f..8caccc3ccf848 100644 --- a/Detectors/FIT/FDD/simulation/include/FDDSimulation/FDDDigParam.h +++ b/Detectors/FIT/FDD/simulation/include/FDDSimulation/FDDDigParam.h @@ -22,10 +22,15 @@ namespace o2::fdd { struct FDDDigParam : o2::conf::ConfigurableParamHelper { +<<<<<<< Updated upstream float hitTimeOffsetA = 0; ///< Hit time offset on the A side [ns] float hitTimeOffsetC = 0; ///< Hit time offset on the C side [ns] float pmGain = 1e6; ///< PM gain +======= + float hitTimeOffsetA = 0; ///< Hit time offset on the A side [ns] + float hitTimeOffsetC = 0; ///< Hit time offset on the C side [ns] +>>>>>>> Stashed changes O2ParamDef(FDDDigParam, "FDDDigParam"); }; diff --git a/Detectors/FIT/FDD/simulation/src/Digitizer.cxx b/Detectors/FIT/FDD/simulation/src/Digitizer.cxx index daa3ae33f3c23..da5f51408809c 100644 --- a/Detectors/FIT/FDD/simulation/src/Digitizer.cxx +++ b/Detectors/FIT/FDD/simulation/src/Digitizer.cxx @@ -11,8 +11,13 @@ #include "FDDSimulation/Digitizer.h" +<<<<<<< Updated upstream #include "CommonDataFormat/InteractionRecord.h" #include "FDDSimulation/FDDDigParam.h" +======= +#include "FDDSimulation/FDDDigParam.h" +#include "CommonDataFormat/InteractionRecord.h" +>>>>>>> Stashed changes #include "SimulationDataFormat/MCTruthContainer.h" #include "TMath.h" @@ -74,10 +79,18 @@ void Digitizer::process(const std::vector& hits, double delayScintillator = mRndScintDelay.getNextValue(); double timeHit = delayScintillator + hit.GetTime(); +<<<<<<< Updated upstream // Subtract time-of-flight from hit time const float timeOfFlight = hit.GetPos().R() / o2::constants::physics::LightSpeedCm2NS; const float timeOffset = iChannel < 8 ? FDDDigParam::Instance().hitTimeOffsetC : FDDDigParam::Instance().hitTimeOffsetA; +======= + // Time-of-flight subtracted from hit time + // timeHit -= getTOFCorrection(int(iChannel / 4)); + const float timeOfFlight = hit.GetPos().R() / o2::constants::physics::LightSpeedCm2NS; + const float timeOffset = 0; // TODO: why instance not working? + // const float timeOffset = hit.GetDetectorID() > 7 ? FDDDigParam::Instance().hitTimeOffsetA : FDDDigParam::Instance().hitTimeOffsetC; // TODO double check ch IDs +>>>>>>> Stashed changes timeHit += -timeOfFlight + timeOffset; timeHit += mIntRecord.getTimeNS(); o2::InteractionRecord irHit(timeHit); // BC in which the hit appears (might be different from interaction BC for slow particles) diff --git a/Detectors/FIT/FT0/base/include/FT0Base/FT0DigParam.h b/Detectors/FIT/FT0/base/include/FT0Base/FT0DigParam.h index 2bf774859aa22..7c8c20b815947 100644 --- a/Detectors/FIT/FT0/base/include/FT0Base/FT0DigParam.h +++ b/Detectors/FIT/FT0/base/include/FT0Base/FT0DigParam.h @@ -29,6 +29,11 @@ struct FT0DigParam : o2::conf::ConfigurableParamHelper { float mAmp_trsh = 100; // [ph.e] float mAmpRecordLow = -4; // integrate charge from float mAmpRecordUp = 15; // to [ns] +<<<<<<< Updated upstream +======= + // float mC_side_cable_cmps = 2.86; // ns + // float mA_side_cable_cmps = 11.110; // ns +>>>>>>> Stashed changes float hitTimeOffsetA = 0; ///< hit time offset on the A side [ns] float hitTimeOffsetC = 0; ///< hit time offset on the C side [ns] int mtrg_central_trh = 600.; // channels diff --git a/Detectors/FIT/FT0/simulation/src/Digitizer.cxx b/Detectors/FIT/FT0/simulation/src/Digitizer.cxx index a261475df31f5..470544b27bd67 100644 --- a/Detectors/FIT/FT0/simulation/src/Digitizer.cxx +++ b/Detectors/FIT/FT0/simulation/src/Digitizer.cxx @@ -216,12 +216,20 @@ void Digitizer::process(const std::vector* hits, const auto& params = FT0DigParam::Instance(); Bool_t is_A_side = (hit_ch < 4 * mGeometry.NCellsA); +<<<<<<< Updated upstream // Subtract time-of-flight from hit time const Float_t timeOfFlight = hit.GetPos().R() / o2::constants::physics::LightSpeedCm2NS; const Float_t timeOffset = is_A_side ? params.hitTimeOffsetA : params.hitTimeOffsetC; Double_t hit_time = hit.GetTime() - timeOfFlight + timeOffset; +======= + // Time-of-flight subtracted from hit time + const Float_t timeOfFlight = hit.GetPos().R() / o2::constants::physics::LightSpeedCm2NS; + const Float_t timeOffset = is_A_side ? params.hitTimeOffsetA : params.hitTimeOffsetC; + // Float_t time_compensate = is_A_side ? params.mA_side_cable_cmps : params.mC_side_cable_cmps; + Double_t hit_time = hit.GetTime() - timeOfFlight + timeOffset; +>>>>>>> Stashed changes if (hit_time > 150) { continue; // not collect very slow particles } diff --git a/Detectors/FIT/FV0/simulation/include/FV0Simulation/Digitizer.h b/Detectors/FIT/FV0/simulation/include/FV0Simulation/Digitizer.h index 6956d8126ce53..7887e3d6c2f0a 100644 --- a/Detectors/FIT/FV0/simulation/include/FV0Simulation/Digitizer.h +++ b/Detectors/FIT/FV0/simulation/include/FV0Simulation/Digitizer.h @@ -96,7 +96,11 @@ class Digitizer /// \param hitTime Time of the hit /// \param hitR Length to IP from the position of the hit /// \param cachedIR Cached interaction records +<<<<<<< Updated upstream /// \param nCachedIR Number of cached interaction records +======= + /// \param nCachedIR Mumber of cached interaction records +>>>>>>> Stashed changes /// \param detID Detector cell ID void createPulse(float mipFraction, int parID, const double hitTime, const float hitR, std::array const& cachedIR, int nCachedIR, const int detID); diff --git a/Detectors/FIT/FV0/simulation/include/FV0Simulation/FV0DigParam.h b/Detectors/FIT/FV0/simulation/include/FV0Simulation/FV0DigParam.h index 383fa4cb494c1..c2ddb11643ab8 100644 --- a/Detectors/FIT/FV0/simulation/include/FV0Simulation/FV0DigParam.h +++ b/Detectors/FIT/FV0/simulation/include/FV0Simulation/FV0DigParam.h @@ -57,6 +57,11 @@ struct FV0DigParam : o2::conf::ConfigurableParamHelper { bool isIntegrateFull = false; // Full charge integration widow in 25 ns float cfdCheckWindow = 2.5; // time window for the cfd in ns to trigger the charge integration int avgNumberPhElectronPerMip = 201; // avg number of photo-electrons per MIP +<<<<<<< Updated upstream +======= + // float globalTimeOfFlight = 315.0 / o2::constants::physics::LightSpeedCm2NS; // TODO [check the correct value for distance of FV0 to IP] + float hitTimeOffset = 0.0; ///< Hit time offset [ns] +>>>>>>> Stashed changes float mCfdDeadTime = 15.6; // [ns] float mCFD_trsh = 3.; // [mV] float getCFDTrshInAdc() const { return mCFD_trsh * getChannelsPerMilivolt(); } // [ADC channels] diff --git a/Detectors/FIT/FV0/simulation/src/Digitizer.cxx b/Detectors/FIT/FV0/simulation/src/Digitizer.cxx index 1c94b14f029cf..c26dd48948e9b 100644 --- a/Detectors/FIT/FV0/simulation/src/Digitizer.cxx +++ b/Detectors/FIT/FV0/simulation/src/Digitizer.cxx @@ -162,7 +162,11 @@ void Digitizer::createPulse(float mipFraction, int parID, const double hitTime, } } +<<<<<<< Updated upstream // Subtract time-of-flight from hit time +======= + // Time-of-flight subtracted from hit time +>>>>>>> Stashed changes const float timeOfFlight = hitR / o2::constants::physics::LightSpeedCm2NS; Int_t const NBinShift = std::lround((hitTime - timeOfFlight + FV0DigParam::Instance().hitTimeOffset) / FV0DigParam::Instance().waveformBinWidth); diff --git a/Detectors/FIT/macros/AnalyzeFITDigits.C b/Detectors/FIT/macros/AnalyzeFITDigits.C new file mode 100644 index 0000000000000..28fa949fdc2e2 --- /dev/null +++ b/Detectors/FIT/macros/AnalyzeFITDigits.C @@ -0,0 +1,278 @@ +#include +#if !defined(__CLING__) || defined(__ROOTCLING__) + +#include + +#include +#include +#include +#include +#include + +#include "TCanvas.h" +#include "TFile.h" +#include "TH1.h" +#include "TLegend.h" +#include "TPaveStats.h" +#include "TTree.h" +#include "TTreeReader.h" + +#include "DataFormatsFIT/Triggers.h" + +#include "DataFormatsFT0/ChannelData.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsFV0/ChannelData.h" +#include "DataFormatsFV0/Digit.h" +#include "DataFormatsFDD/ChannelData.h" +#include "DataFormatsFDD/Digit.h" + +#endif + +// #include "DataFormatsFT0/ChannelData.h" +// #include "DataFormatsFT0/Digit.h" +// #include "DataFormatsFV0/ChannelData.h" +// #include "DataFormatsFV0/Digit.h" +// #include "DataFormatsFDD/ChannelData.h" +// #include "DataFormatsFDD/Digit.h" + +// class o2::ft0::Digit; +// class o2::ft0::ChannelData; + +// Utilities +void UpdateStatBox(TObject* h, const int iSet) { + TPaveStats* stats = (TPaveStats*)h->FindObject("stats"); + if (stats) { + stats->SetTextColor(iSet + 2); + stats->SetX1NDC(0.7); + stats->SetX2NDC(0.9); + stats->SetY1NDC(0.7 - iSet * 0.2); + stats->SetY2NDC(0.9 - iSet * 0.2); + } +} + +// Read one digit file +template +int ReadFITDigits(std::string detector = "FT0", + std::string fileName = "ft0digits.root", + const bool draw = false, + const bool writeToFile = true) { + const bool isFT0 = detector == "FT0"; + const bool isFV0 = detector == "FV0"; + const bool isFDD = detector == "FDD"; + + if (!isFT0 && !isFV0 && !isFDD) { + std::cout << "Detector must be FT0/FV0/FDD" << std::endl; + return 1; + } + + // Strip the file name of the .root extension + size_t pos = fileName.find(".root"); + if (pos != std::string::npos) { + fileName.erase(pos); + } + + // Open input digit file and tree + std::unique_ptr digitFile(TFile::Open(Form("%s.root", fileName.c_str()), "READ")); + if (!digitFile || digitFile->IsZombie()) { + std::cout << "Could not open file " << fileName << std::endl; + return 1; + } + + std::unique_ptr digitTree(dynamic_cast(digitFile->Get("o2sim"))); + if (!digitTree) { + std::cout << "Could not find tree o2sim in file " << fileName << std::endl; + return 1; + } + + std::vector digits; + std::vector* pDigits = &digits; + std::vector channelData; + std::vector* pChannels = &channelData; + + std::string digitBranchName = isFT0 ? "FT0DIGITSBC" : isFV0 ? "FV0DigitBC" : isFDD ? "FDDDIGITBC" : ""; + std::string channelBranchName = isFT0 ? "FT0DIGITSCH" : isFV0 ? "FV0DigitCh" : isFDD ? "FDDDIGITSCH" : ""; + + digitTree->SetBranchAddress(digitBranchName.c_str(), &pDigits); + digitTree->SetBranchAddress(channelBranchName.c_str(), &pChannels); + + // Declare histograms + TH1I* hBcTimeA = new TH1I("hBcTimeA", "BC time A;Time [TDC]", 1001, -500, 500); + TH1I* hBcTimeC = new TH1I("hBcTimeC", "BC time C;Time [TDC]", 1001, -500, 500); + TH1I* hChID = new TH1I("hChID", "Channel ID;Channel ID;counts", 208, 0, 208); + + for (Long64_t iEntry = 0; iEntry < digitTree->GetEntries(); iEntry++) { + digitTree->GetEntry(iEntry); + + for (auto& digit : digits) { + hBcTimeA->Fill(digit.mTriggers.getTimeA()); + hBcTimeC->Fill(digit.mTriggers.getTimeC()); + + const gsl::span channels = digit.getBunchChannelData(channelData); + for (const auto& channel : channels) { + hChID->Fill(channel.ChId); + } + } + } + + // Draw histogams + if (draw) { + TCanvas* cTimeA = new TCanvas("cBcTimeA", "BC Time A"); + hBcTimeA->DrawCopy(); + + TCanvas* cTimeC = new TCanvas("cBcTimeC", "BC Time C"); + hBcTimeC->DrawCopy(); + + TCanvas* cChID = new TCanvas("cChID", "Channel ID"); + hChID->DrawCopy(); + } + + // Write histograms to file + if (writeToFile) { + std::string outputFileName = Form("%sread.root", fileName.c_str()); + std::cout << "Writing histograms to file " << outputFileName << std::endl; + TFile* fOutputFile = new TFile(outputFileName.c_str(), "RECREATE"); + + fOutputFile->cd(); + hBcTimeA->Write(); + hBcTimeC->Write(); + hChID->Write(); + + fOutputFile->Close(); + } + + return 0; +} + +// Read one (or more) digit file(s) (and compare them in case of many) +int AnalyzeFITDigits(std::string detector = "FT0", + const bool read = true, + const bool writeToFile = true, + std::initializer_list fileNames = {"ft0digits.root"}, + std::initializer_list labels = {"1"}) { + const bool isFT0 = detector == "FT0"; + const bool isFV0 = detector == "FV0"; + const bool isFDD = detector == "FDD"; + + if (!isFT0 && !isFV0 && !isFDD) { + std::cout << "Detector must be FT0/FV0/FDD" << std::endl; + return 1; + } + + const int nSets = fileNames.size(); + + std::vector digitFileNames; + digitFileNames.insert(digitFileNames.end(), fileNames.begin(), fileNames.end()); + + std::vector setLabels; + setLabels.insert(setLabels.end(), labels.begin(), labels.end()); + + if (digitFileNames.size() != setLabels.size()) { + std::cout << "Number of file names and labels must be the same" << std::endl; + return 1; + } + + // Strip the file names of the .root extension + for (auto& digitFileName : digitFileNames) { + size_t pos = digitFileName.find(".root"); + if (pos != std::string::npos) { + digitFileName.erase(pos); + } + } + + if (read) { + for (int iSet = 0; iSet < nSets; iSet++) { + std::cout << "Reading " << digitFileNames.at(iSet) << std::endl; + bool readResult = 1; + if (isFT0) { + readResult = ReadFITDigits("FT0", digitFileNames.at(iSet), false, true); + } else if (isFV0) { + readResult = ReadFITDigits("FV0", digitFileNames.at(iSet), false, true); + // } else if (isFDD) { + // readResult = ReadFITDigits("FDD", digitFileNames.at(iSet), false, true); + } + + if (readResult) { + std::cout << "Could not read file " << digitFileNames.at(iSet) << std::endl; + return 1; + } + } + } + + std::vector> digitFiles; + std::vector hTimeA; + std::vector hTimeC; + std::vector hChID; + + for (int iSet = 0; iSet < nSets; iSet++) { + std::cout << "Set up files and trees etc." << std::endl; + digitFiles.push_back(std::unique_ptr(TFile::Open(TString::Format("%sread.root", digitFileNames.at(iSet).c_str()), "READ"))); + if (!digitFiles.back() || digitFiles.back()->IsZombie()) { + std::cout << "Could not open file " << digitFileNames.at(iSet) << std::endl; + return 1; + } + + hTimeA.push_back(dynamic_cast(digitFiles.back()->Get("hBcTimeA"))); + hTimeA.back()->SetName(hTimeA.back()->GetName() + TString::Format("_%s", setLabels.at(iSet).c_str())); + + hTimeC.push_back(dynamic_cast(digitFiles.back()->Get("hBcTimeC"))); + hTimeC.back()->SetName(hTimeC.back()->GetName() + TString::Format("_%s", setLabels.at(iSet).c_str())); + + hChID.push_back(dynamic_cast(digitFiles.back()->Get("hChID"))); + hChID.back()->SetName(hChID.back()->GetName() + TString::Format("_%s", setLabels.at(iSet).c_str())); + } + + // Draw histograms + + // Time A + TCanvas* cTimeA = new TCanvas("cTimeA", "Time A"); + TLegend* legTimeA = new TLegend(0.1, 0.7, 0.48, 0.9); + for (int iSet = 0; iSet < nSets; iSet++) { + TH1* h = hTimeA[iSet]->DrawCopy(iSet == 0 ? "" : "sames", ""); + h->SetLineColor(iSet + 2); + legTimeA->AddEntry(h, setLabels.at(iSet).c_str(), "l"); + cTimeA->Update(); + UpdateStatBox(h, iSet); + } + legTimeA->Draw(); + + // Time C + TCanvas* cTimeC = new TCanvas("cTimeC", "Time C"); + TLegend* legTimeC = new TLegend(0.1, 0.7, 0.48, 0.9); + for (int iSet = 0; iSet < nSets; iSet++) { + TH1* h = hTimeC[iSet]->DrawCopy(iSet == 0 ? "" : "sames", ""); + h->SetLineColor(iSet + 2); + legTimeC->AddEntry(h, setLabels.at(iSet).c_str(), "l"); + cTimeC->Update(); + UpdateStatBox(h, iSet); + } + legTimeC->Draw(); + + // Channel ID + TCanvas* cChID = new TCanvas("cChID", "Channel ID"); + TLegend* legChID = new TLegend(0.1, 0.7, 0.48, 0.9); + for (int iSet = 0; iSet < nSets; iSet++) { + TH1* h = hChID[iSet]->DrawCopy(iSet == 0 ? "" : "sames", ""); + h->SetLineColor(iSet + 2); + legChID->AddEntry(h, setLabels.at(iSet).c_str(), "l"); + cChID->Update(); + UpdateStatBox(h, iSet); + } + legChID->Draw(); + + // Write histograms to file + if (writeToFile) { + TString outputFileName = TString::Format("comparedDigits.root"); + std::cout << "Writing histograms to file " << outputFileName.Data() << std::endl; + TFile* fOutputFile = new TFile(outputFileName, "RECREATE"); + fOutputFile->cd(); + for (int iSet = 0; iSet < nSets; iSet++) { + hTimeA[iSet]->Write(); + hTimeC[iSet]->Write(); + } + cTimeA->Write(); + cTimeC->Write(); + fOutputFile->Close(); + } + + return 0; +} diff --git a/Detectors/FIT/macros/AnalyzeFITRecPoints.C b/Detectors/FIT/macros/AnalyzeFITRecPoints.C new file mode 100644 index 0000000000000..4dfcfab3c27c2 --- /dev/null +++ b/Detectors/FIT/macros/AnalyzeFITRecPoints.C @@ -0,0 +1,183 @@ +#include +#include +#include +#include +#if !defined(__CLING__) || defined(__ROOTCLING__) + +#include "TFile.h" +#include "TH1.h" +#include "TPaveStats.h" +#include "TTree.h" + +#include +#include +#include +#include +#include +#include + +#include "FT0Base/Constants.h" +#include "DataFormatsFT0/RecPoints.h" + +#endif + +// Utilities +void UpdateStatBox(TObject* h, const int iSet) { + TPaveStats* stats = (TPaveStats*)h->FindObject("stats"); + if (stats) { + stats->SetTextColor(iSet + 2); + stats->SetX1NDC(0.7); + stats->SetX2NDC(0.9); + stats->SetY1NDC(0.7 - iSet * 0.2); + stats->SetY2NDC(0.9 - iSet * 0.2); + } +} + +// Read one FT0 RecPoint file +int ReadFT0RecPoints(std::string fileName = "o2reco_ft0", const bool draw = false, const bool writeToFile = true) { + // Strip the file name of the .root extension + size_t pos = fileName.find(".root"); + if (pos != std::string::npos) { + fileName.erase(pos); + } + + // Open input recpoint file and tree + std::unique_ptr recpointFile(TFile::Open(Form("%s.root", fileName.c_str()), "READ")); + if (!recpointFile || recpointFile->IsZombie()) { + std::cout << "Could not open file " << fileName << std::endl; + return 1; + } + + std::unique_ptr recpointTree((TTree*)recpointFile->Get("o2sim")); + if (!recpointTree) { + std::cout << "Could not find tree o2sim in file " << fileName << std::endl; + return 1; + } + + std::vector recpoints; + std::vector* pRecpoints = &recpoints; + std::vector channelData; + std::vector* pChannelData = &channelData; + + recpointTree->SetBranchAddress("FT0Cluster", &pRecpoints); + recpointTree->SetBranchAddress("FT0RecChData", &pChannelData); + + TH1I* hChannels = new TH1I("hChannels", "Channel statistics;channel ID;counts", o2::ft0::Constants::sNTOTAL_CHANNELS_PM, 0, o2::ft0::Constants::sNTOTAL_CHANNELS_PM); + + for (Long64_t iEntry = 0; iEntry < recpointTree->GetEntries(); ++iEntry) { + recpointTree->GetEntry(iEntry); + + for (const auto& recpoint : recpoints) { + gsl::span channels = recpoint.getBunchChannelData(channelData); + for (const auto& channel : channels) { + hChannels->Fill(channel.ChId); + } + } + } + + // Draw histograms + if (draw) { + TCanvas* cChannels = new TCanvas("cChannels", "Channel statistics"); + hChannels->DrawCopy(); + } + + // Write histgrams to file + if (writeToFile) { + std::string outputFileName = Form("%sread.root", fileName.c_str()); + std::cout << "Writing histograms to file " << outputFileName << std::endl; + std::unique_ptr outputFile(TFile::Open(outputFileName.c_str(), "RECREATE")); + outputFile->cd(); + hChannels->Write(); + outputFile->Close(); + } + + return 0; +} + +int AnalyzeFITRecPoints(std::string detector = "FT0", + const bool read = true, + const bool writeToFile = true, + std::initializer_list fileNames = {"o2reco_ft0.root"}, + std::initializer_list labels = {"1"}) { + const bool isFT0 = detector == "FT0"; + const bool isFV0 = detector == "FV0"; + const bool isFDD = detector == "FDD"; + + if (!isFT0 && !isFV0 && !isFDD) { + std::cout << "Detector must be FT0/FV0/FDD" << std::endl; + return 1; + } + + const int nSets = fileNames.size(); + + std::vector recPointFileNames(fileNames); + std::vector setLabels(labels); + + if (recPointFileNames.size() != setLabels.size()) { + std::cout << "Number of file names and labels must be the same" << std::endl; + return 1; + } + + // Strip the file names of the .root extension + for (auto& fileName : recPointFileNames) { + size_t pos = fileName.find(".root"); + if (pos != std::string::npos) { + fileName.erase(pos); + } + } + + if (read) { + for (int iSet = 0; iSet < nSets; ++iSet) { + std::cout << "Reading " << recPointFileNames[iSet] << std::endl; + if (isFT0) { + ReadFT0RecPoints(recPointFileNames[iSet], false, true); + } + else { + std::cout << "FV0/FDD not implemented" << std::endl; + return 1; + } + } + } + + std::vector> recPointFiles; + std::vector hChannels; + + for (int iSet = 0; iSet < nSets; ++iSet) { + std::string recPointFileName = Form("%sread.root", recPointFileNames[iSet].c_str()); + std::cout << "Reading " << recPointFileName << std::endl; + recPointFiles.emplace_back(TFile::Open(recPointFileName.c_str(), "READ")); + if (!recPointFiles[iSet] || recPointFiles[iSet]->IsZombie()) { + std::cout << "Could not open file " << recPointFileName << std::endl; + return 1; + } + + hChannels.emplace_back((TH1I*)recPointFiles[iSet]->Get("hChannels")); + hChannels.back()->SetName(Form("hChannels_%s", setLabels[iSet].c_str())); + } + + // Draw histograms + TCanvas* cChannels = new TCanvas("cChannels", "Channel statistics"); + TLegend* legChannels = new TLegend(0.1, 0.7, 0.48, 0.9); + for (int iSet = 0; iSet < nSets; ++iSet) { + TH1* h = hChannels[iSet]->DrawCopy(iSet == 0 ? "" : "sames", ""); + h->SetLineColor(iSet + 2); + legChannels->AddEntry(h, setLabels[iSet].c_str(), "l"); + cChannels->Update(); + UpdateStatBox(h, iSet); + } + legChannels->Draw(); + + // Write histgrams to file + if (writeToFile) { + std::string outputFileName = Form("%s_comparedrecpoints.root", detector.c_str()); + std::cout << "Writing histograms to file " << outputFileName << std::endl; + std::unique_ptr outputFile(TFile::Open(outputFileName.c_str(), "RECREATE")); + outputFile->cd(); + for (int iSet = 0; iSet < nSets; ++iSet) { + hChannels[iSet]->Write(); + } + outputFile->Close(); + } + + return 0; +} \ No newline at end of file diff --git a/Detectors/FIT/macros/CMakeLists.txt b/Detectors/FIT/macros/CMakeLists.txt index 81f2cc05e0b25..cca400c2e5bd2 100644 --- a/Detectors/FIT/macros/CMakeLists.txt +++ b/Detectors/FIT/macros/CMakeLists.txt @@ -40,5 +40,19 @@ o2_add_test_root_macro(readFITDCSdata.C O2::CCDB LABELS fit) +<<<<<<< Updated upstream o2_data_file(COPY readFITDCSdata.C DESTINATION Detectors/FIT/macros/) -o2_data_file(COPY readFITDeadChannelMap.C DESTINATION Detectors/FIT/macros/) \ No newline at end of file +o2_data_file(COPY readFITDeadChannelMap.C DESTINATION Detectors/FIT/macros/) +======= +o2_add_test_root_macro(AnalyzeFITDigits.C + PUBLIC_LINK_LIBRARIES O2::DataFormatsFIT + O2::DataFormatsFT0 + O2::DataFormatsFV0 + O2::DataFormatsFDD + LABELS fit) + +o2_add_test_root_macro(AnalyzeFITRecPoints.C + LABELS fit) + +o2_data_file(COPY readFITDCSdata.C DESTINATION Detectors/FIT/macros/readFITDCSdata.C) +>>>>>>> Stashed changes diff --git a/Detectors/FIT/macros/readFV0digits.C b/Detectors/FIT/macros/readFV0digits.C index 95ce1a0aae42b..d43ce2c281f03 100644 --- a/Detectors/FIT/macros/readFV0digits.C +++ b/Detectors/FIT/macros/readFV0digits.C @@ -1,32 +1,33 @@ -#if !defined(__CLING__) || defined(__ROOTCLING__) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "DataFormatsFV0/Digit.h" -#include "DataFormatsFV0/ChannelData.h" -#include "SimulationDataFormat/MCTruthContainer.h" -#include "SimulationDataFormat/MCCompLabel.h" -#include "FV0Base/Constants.h" -#include "DataFormatsFV0/MCLabel.h" -#include +// #if !defined(__CLING__) || defined(__ROOTCLING__) + +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include + +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include "DataFormatsFIT/Triggers.h" +// #include "DataFormatsFV0/Digit.h" +// #include "DataFormatsFV0/ChannelData.h" +// #include "SimulationDataFormat/MCTruthContainer.h" +// #include "SimulationDataFormat/MCCompLabel.h" +// #include "FV0Base/Constants.h" +// #include "DataFormatsFV0/MCLabel.h" +// #include void AdjustStatBox(TH1* h, float x1ndc, float x2ndc, float y1ndc, float y2ndc) { @@ -460,4 +461,4 @@ int compareFV0Digits(std::string digiFName1 = "fv0digi-rawhistos.root", std::str return 0; } -#endif +// #endif \ No newline at end of file