File indexing completed on 2024-04-06 11:57:44
0001
0002
0003
0004
0005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRead.h"
0006
0007
0008
0009
0010
0011
0012
0013 R__EXTERN TEcnaRootFile *gCnaRootFile;
0014
0015 ClassImp(TEcnaRead);
0016
0017
0018
0019 TEcnaRead::TEcnaRead() {
0020 Init();
0021
0022 }
0023
0024
0025 TEcnaRead::TEcnaRead(TEcnaObject *pObjectManager, const TString &SubDet) {
0026 fObjectManager = (TEcnaObject *)pObjectManager;
0027 Long_t i_this = (Long_t)this;
0028 pObjectManager->RegisterPointer("TEcnaRead", i_this);
0029
0030
0031
0032 fCnaParCout = nullptr;
0033 Long_t iCnaParCout = pObjectManager->GetPointerValue("TEcnaParCout");
0034 if (iCnaParCout == 0) {
0035 fCnaParCout = new TEcnaParCout(pObjectManager);
0036 } else {
0037 fCnaParCout = (TEcnaParCout *)iCnaParCout;
0038 }
0039
0040
0041 fCnaParPaths = nullptr;
0042 Long_t iCnaParPaths = pObjectManager->GetPointerValue("TEcnaParPaths");
0043 if (iCnaParPaths == 0) {
0044 fCnaParPaths = new TEcnaParPaths(pObjectManager);
0045 } else {
0046 fCnaParPaths = (TEcnaParPaths *)iCnaParPaths;
0047 }
0048
0049
0050 fEcalNumbering = nullptr;
0051 Long_t iEcalNumbering = pObjectManager->GetPointerValue("TEcnaNumbering");
0052 if (iEcalNumbering == 0) {
0053 fEcalNumbering = new TEcnaNumbering(pObjectManager, SubDet.Data());
0054 } else {
0055 fEcalNumbering = (TEcnaNumbering *)iEcalNumbering;
0056 }
0057
0058
0059 fCnaParHistos = nullptr;
0060 Long_t iCnaParHistos = pObjectManager->GetPointerValue("TEcnaParHistos");
0061 if (iCnaParHistos == 0) {
0062 fCnaParHistos = new TEcnaParHistos(pObjectManager, SubDet.Data());
0063 } else {
0064 fCnaParHistos = (TEcnaParHistos *)iCnaParHistos;
0065 }
0066
0067
0068 fCnaWrite = nullptr;
0069 Long_t iCnaWrite = pObjectManager->GetPointerValue("TEcnaWrite");
0070 if (iCnaWrite == 0) {
0071 fCnaWrite = new TEcnaWrite(pObjectManager, SubDet.Data());
0072 } else {
0073 fCnaWrite = (TEcnaWrite *)iCnaWrite;
0074 }
0075
0076
0077
0078 fEcal = nullptr;
0079 Long_t iParEcal = pObjectManager->GetPointerValue("TEcnaParEcal");
0080 if (iParEcal == 0) {
0081 fEcal = new TEcnaParEcal(pObjectManager, SubDet.Data());
0082 } else {
0083 fEcal = (TEcnaParEcal *)iParEcal;
0084 }
0085
0086
0087
0088
0089
0090
0091
0092 const Text_t *h_name = "CnaHeader";
0093 const Text_t *h_title = "CnaHeader";
0094
0095
0096
0097
0098
0099
0100
0101 fFileHeader = nullptr;
0102 Long_t iFileHeader = pObjectManager->GetPointerValue("TEcnaHeader");
0103 if (iFileHeader == 0) {
0104 fFileHeader = new TEcnaHeader(pObjectManager, h_name, h_title);
0105 } else {
0106 fFileHeader = (TEcnaHeader *)iFileHeader;
0107 }
0108
0109 Init();
0110 SetEcalSubDetector(SubDet.Data());
0111
0112
0113 }
0114
0115 void TEcnaRead::Init() {
0116
0117
0118 fCnew = 0;
0119 fCdelete = 0;
0120
0121 fTTBELL = '\007';
0122
0123 fgMaxCar = (Int_t)512;
0124
0125 fCodePrintNoComment = fCnaParCout->GetCodePrint("NoComment");
0126 fCodePrintWarnings = fCnaParCout->GetCodePrint("Warnings ");
0127 fCodePrintComments = fCnaParCout->GetCodePrint("Comments");
0128 fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
0129
0130
0131 fFlagPrint = fCodePrintWarnings;
0132
0133
0134 fTagStinNumbers = nullptr;
0135 fMemoStinNumbers = 0;
0136 fT1d_StexStinFromIndex = nullptr;
0137
0138
0139
0140
0141
0142 fDataExist = kFALSE;
0143
0144
0145 fT3d_AdcValues = nullptr;
0146 fT3d2_AdcValues = nullptr;
0147 fT3d1_AdcValues = nullptr;
0148
0149
0150 Int_t MaxCar = fgMaxCar;
0151 fPathRoot.Resize(MaxCar);
0152 fPathRoot = "fPathRoot not defined";
0153
0154
0155 gCnaRootFile = nullptr;
0156
0157 fOpenRootFile = kFALSE;
0158 fReadyToReadRootFile = 0;
0159 fLookAtRootFile = 0;
0160
0161
0162 fFlagNoFileOpen.Resize(MaxCar);
0163 fFlagNoFileOpen = "No file is open";
0164
0165 fCurrentlyOpenFileName.Resize(MaxCar);
0166 fCurrentlyOpenFileName = fFlagNoFileOpen;
0167
0168 }
0169
0170
0171
0172 void TEcnaRead::SetEcalSubDetector(const TString &SubDet) {
0173
0174
0175 Int_t MaxCar = fgMaxCar;
0176 fFlagSubDet.Resize(MaxCar);
0177 fFlagSubDet = fEcal->GetEcalSubDetector();
0178
0179 if (fFlagSubDet == "EB") {
0180 fStexName = "SM";
0181 fStinName = "tower";
0182 }
0183 if (fFlagSubDet == "EE") {
0184 fStexName = "Dee";
0185 fStinName = "SC";
0186 }
0187 }
0188
0189
0190 void TEcnaRead::Anew(const TString &VarName) {
0191
0192
0193 fCnew++;
0194
0195
0196 }
0197
0198 void TEcnaRead::Adelete(const TString &VarName) {
0199
0200
0201 fCdelete++;
0202
0203
0204 }
0205
0206
0207
0208 void TEcnaRead::fCopy(const TEcnaRead &rund) {
0209
0210
0211 fFileHeader = rund.fFileHeader;
0212 fOpenRootFile = rund.fOpenRootFile;
0213
0214
0215
0216 fCodePrintComments = rund.fCodePrintComments;
0217 fCodePrintWarnings = rund.fCodePrintWarnings;
0218 fCodePrintAllComments = rund.fCodePrintAllComments;
0219 fCodePrintNoComment = rund.fCodePrintNoComment;
0220
0221
0222 fTagStinNumbers = rund.fTagStinNumbers;
0223
0224 fFlagPrint = rund.fFlagPrint;
0225 fPathRoot = rund.fPathRoot;
0226
0227 fCnew = rund.fCnew;
0228 fCdelete = rund.fCdelete;
0229 }
0230
0231
0232
0233
0234
0235
0236
0237 TEcnaRead::TEcnaRead(const TEcnaRead &dcop) : TObject::TObject(dcop) {
0238 std::cout << "*TEcnaRead::TEcnaRead(const TEcnaRead& dcop)> "
0239 << " It is time to write a copy constructor" << std::endl;
0240
0241
0242 }
0243
0244
0245
0246
0247
0248
0249
0250 TEcnaRead &TEcnaRead::operator=(const TEcnaRead &dcop) {
0251
0252
0253 fCopy(dcop);
0254 return *this;
0255 }
0256
0257
0258
0259
0260
0261
0262
0263 TEcnaRead::~TEcnaRead() {
0264
0265
0266
0267
0268 if (fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments) {
0269 std::cout << "*TEcnaRead::~TEcnaRead()> Entering destructor" << std::endl;
0270 }
0271
0272
0273
0274
0275
0276
0277
0278
0279 if (fT1d_StexStinFromIndex != nullptr) {
0280 delete[] fT1d_StexStinFromIndex;
0281 Adelete("fT1d_StexStinFromIndex");
0282 }
0283 if (fTagStinNumbers != nullptr) {
0284 delete[] fTagStinNumbers;
0285 Adelete("fTagStinNumbers");
0286 }
0287
0288 if (fT3d_AdcValues != nullptr) {
0289 delete[] fT3d_AdcValues;
0290 Adelete("fT3d_AdcValues");
0291 }
0292 if (fT3d2_AdcValues != nullptr) {
0293 delete[] fT3d2_AdcValues;
0294 Adelete("fT3d2_AdcValues");
0295 }
0296 if (fT3d1_AdcValues != nullptr) {
0297 delete[] fT3d1_AdcValues;
0298 Adelete("fT3d1_AdcValues");
0299 }
0300
0301 if (fCnew != fCdelete) {
0302 std::cout << "!TEcnaRead/destructor> WRONG MANAGEMENT OF ALLOCATIONS: fCnew = " << fCnew
0303 << ", fCdelete = " << fCdelete << fTTBELL << std::endl;
0304 } else {
0305
0306
0307 }
0308
0309 if (fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments) {
0310 std::cout << "*TEcnaRead::~TEcnaRead()> End of destructor " << std::endl;
0311 }
0312 }
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325 TVectorD TEcnaRead::Read1DHisto(const Int_t &VecDim,
0326 const TString &UserQuantity,
0327 const Int_t &n1StexStin,
0328 const Int_t &i0StinEcha,
0329 const Int_t &n1Sample) {
0330 Int_t VecDimTest = fFileHeader->fReqNbOfEvts;
0331
0332 if (VecDim == VecDimTest) {
0333 TVectorD vec(VecDim);
0334
0335 TString CallingMethod = "1D";
0336 TString StandardQuantity = fCnaParHistos->BuildStandard1DHistoCodeY(CallingMethod, UserQuantity);
0337
0338 if (StandardQuantity == "Adc") {
0339 Int_t i0Sample = n1Sample - 1;
0340 vec = ReadSampleAdcValues(n1StexStin, i0StinEcha, i0Sample, VecDim);
0341 } else {
0342 for (Int_t i = 0; i < VecDim; i++) {
0343 vec(i) = (double_t)0.;
0344 }
0345 std::cout << "!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
0346 << "(StandardQuantity = " << StandardQuantity << "). Wrong code, no file reading." << fTTBELL
0347 << std::endl;
0348 }
0349 return vec;
0350 } else {
0351 TVectorD vec(VecDim);
0352 for (Int_t i = 0; i < VecDim; i++) {
0353 vec(i) = (double_t)0.;
0354 }
0355 std::cout << "!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity << ", VecDim = " << VecDim
0356 << "(VecDimTest = " << VecDimTest << ")"
0357 << ". Wrong code or array dimension. No file reading." << fTTBELL << std::endl;
0358 return vec;
0359 }
0360 }
0361
0362 TVectorD TEcnaRead::Read1DHisto(const Int_t &VecDim, const TString &UserQuantity, const Int_t &n1StexStin) {
0363 Int_t VecDimTest = fEcal->MaxCrysInStin() * fEcal->MaxSampADC();
0364 if (VecDim == VecDimTest) {
0365 TVectorD vec(VecDim);
0366
0367 TString CallingMethod = "1D";
0368 TString StandardQuantity = fCnaParHistos->BuildStandard1DHistoCodeY(CallingMethod, UserQuantity);
0369
0370 if (StandardQuantity == "MSp" || StandardQuantity == "SSp") {
0371 if (StandardQuantity == "MSp") {
0372 vec = ReadSampleMeans(n1StexStin, VecDim);
0373 }
0374 if (StandardQuantity == "SSp") {
0375 vec = ReadSampleSigmas(n1StexStin, VecDim);
0376 }
0377 } else {
0378 for (Int_t i = 0; i < VecDim; i++) {
0379 vec(i) = (double_t)0.;
0380 }
0381 std::cout << "!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
0382 << ", StandardQuantity = " << StandardQuantity << ". Wrong code, no file reading." << fTTBELL
0383 << std::endl;
0384 }
0385 return vec;
0386 } else {
0387 TVectorD vec(VecDim);
0388 for (Int_t i = 0; i < VecDim; i++) {
0389 vec(i) = (double_t)0.;
0390 }
0391 std::cout << "!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity << ", VecDim = " << VecDim
0392 << "(VecDimTest = " << VecDimTest << ")"
0393 << ". Wrong code or array dimension. No file reading." << fTTBELL << std::endl;
0394 return vec;
0395 }
0396 }
0397
0398 TVectorD TEcnaRead::Read1DHisto(const Int_t &VecDim, const TString &UserQuantity, const TString &UserDetector) {
0399
0400
0401
0402 Int_t VecDimTest = 1;
0403 TString StandardDetector = fCnaParHistos->BuildStandardDetectorCode(UserDetector);
0404 if (StandardDetector == "SM" || StandardDetector == "Dee") {
0405 VecDimTest = fEcal->MaxCrysEcnaInStex();
0406 }
0407 if (StandardDetector == "EB" || StandardDetector == "EE") {
0408 VecDimTest = fEcal->MaxStinEcnaInStas();
0409 }
0410
0411 if (VecDim == VecDimTest) {
0412 TVectorD vec(VecDim);
0413
0414 TString CallingMethod = "1D";
0415 TString StandardQuantity = "?";
0416 StandardQuantity = fCnaParHistos->BuildStandard1DHistoCodeY(CallingMethod, UserQuantity);
0417 TString rTechReadCode = GetTechReadCode(StandardQuantity, StandardDetector);
0418
0419 if (rTechReadCode != "?") {
0420 if (StandardDetector == "SM" || StandardDetector == "Dee") {
0421 if (rTechReadCode == "NOEStex") {
0422 vec = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());
0423 }
0424 if (rTechReadCode == "PedStex") {
0425 vec = ReadPedestals(fEcal->MaxCrysEcnaInStex());
0426 }
0427 if (rTechReadCode == "TNoStex") {
0428 vec = ReadTotalNoise(fEcal->MaxCrysEcnaInStex());
0429 }
0430 if (rTechReadCode == "LFNStex") {
0431 vec = ReadLowFrequencyNoise(fEcal->MaxCrysEcnaInStex());
0432 }
0433 if (rTechReadCode == "HFNStex") {
0434 vec = ReadHighFrequencyNoise(fEcal->MaxCrysEcnaInStex());
0435 }
0436 if (rTechReadCode == "MCsStex") {
0437 vec = ReadMeanCorrelationsBetweenSamples(fEcal->MaxCrysEcnaInStex());
0438 }
0439 if (rTechReadCode == "SCsStex") {
0440 vec = ReadSigmaOfCorrelationsBetweenSamples(fEcal->MaxCrysEcnaInStex());
0441 }
0442 }
0443
0444 if (StandardDetector == "EB" || StandardDetector == "EE") {
0445 TVectorD vecStex(fEcal->MaxStinEcnaInStex());
0446 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
0447 vecStex(i) = (Double_t)0.;
0448 }
0449
0450 time_t xStartTime = GetStartTime();
0451 time_t xStopTime = GetStopTime();
0452 TString xStartDate = "sStartDate";
0453 TString xStopDate = "sStopDate";
0454
0455 for (Int_t i0Stex = 0; i0Stex < fEcal->MaxStexInStas(); i0Stex++) {
0456 Int_t n1Stex = i0Stex + 1;
0457 FileParameters(fFileHeader->fTypAna,
0458 fFileHeader->fNbOfSamples,
0459 fFileHeader->fRunNumber,
0460 fFileHeader->fFirstReqEvtNumber,
0461 fFileHeader->fLastReqEvtNumber,
0462 fFileHeader->fReqNbOfEvts,
0463 n1Stex,
0464 fPathRoot);
0465
0466 if (LookAtRootFile() == kTRUE) {
0467 if (rTechReadCode == "NOEStas") {
0468 vecStex = ReadAverageNumberOfEvents(fEcal->MaxStinEcnaInStex());
0469 }
0470 if (rTechReadCode == "PedStas") {
0471 vecStex = ReadAveragePedestals(fEcal->MaxStinEcnaInStex());
0472 }
0473 if (rTechReadCode == "TNoStas") {
0474 vecStex = ReadAverageTotalNoise(fEcal->MaxStinEcnaInStex());
0475 }
0476 if (rTechReadCode == "LFNStas") {
0477 vecStex = ReadAverageLowFrequencyNoise(fEcal->MaxStinEcnaInStex());
0478 }
0479 if (rTechReadCode == "HFNStas") {
0480 vecStex = ReadAverageHighFrequencyNoise(fEcal->MaxStinEcnaInStex());
0481 }
0482 if (rTechReadCode == "MCsStas") {
0483 vecStex = ReadAverageMeanCorrelationsBetweenSamples(fEcal->MaxStinEcnaInStex());
0484 }
0485 if (rTechReadCode == "SCsStas") {
0486 vecStex = ReadAverageSigmaOfCorrelationsBetweenSamples(fEcal->MaxStinEcnaInStex());
0487 }
0488
0489 for (Int_t i0Stin = 0; i0Stin < fEcal->MaxStinEcnaInStex(); i0Stin++) {
0490 vec(fEcal->MaxStinEcnaInStex() * i0Stex + i0Stin) = vecStex(i0Stin);
0491 }
0492
0493
0494 if (i0Stex == 0) {
0495 xStartTime = GetStartTime();
0496 xStopTime = GetStopTime();
0497 xStartDate = GetStartDate();
0498 xStopDate = GetStopDate();
0499 }
0500 time_t cStartTime = GetStartTime();
0501 time_t cStopTime = GetStopTime();
0502 TString cStartDate = GetStartDate();
0503 TString cStopDate = GetStopDate();
0504
0505 if (cStartTime < xStartTime) {
0506 xStartTime = cStartTime;
0507 xStartDate = cStartDate;
0508 }
0509 if (cStopTime > xStopTime) {
0510 xStopTime = cStopTime;
0511 xStopDate = cStopDate;
0512 }
0513
0514 fFileHeader->fStartDate = xStartDate;
0515 fFileHeader->fStopDate = xStopDate;
0516 } else {
0517 std::cout << "!TEcnaRead::Read1DHisto(const TString&, const TString&)> *ERROR* =====> "
0518 << " ROOT file not found" << fTTBELL << std::endl;
0519 }
0520 }
0521 }
0522 } else {
0523 for (Int_t i = 0; i < VecDim; i++) {
0524 vec(i) = (double_t)0.;
0525 }
0526 std::cout << "!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity
0527 << ", UserDetector = " << UserDetector << ". Wrong code(s). No file reading." << fTTBELL << std::endl;
0528 }
0529 return vec;
0530 } else {
0531 TVectorD vec(VecDim);
0532 for (Int_t i = 0; i < VecDim; i++) {
0533 vec(i) = (double_t)0.;
0534 }
0535 std::cout << "!TEcnaRead::Read1DHisto(...)> UserQuantity = " << UserQuantity << ", UserDetector = " << UserDetector
0536 << ", VecDim = " << VecDim << ". Wrong code(s) or array dimension. No file reading." << fTTBELL
0537 << std::endl;
0538 return vec;
0539 }
0540 }
0541
0542
0543
0544
0545
0546
0547 TMatrixD TEcnaRead::ReadMatrix(const Int_t &MatDim,
0548 const TString &UserCorOrCov,
0549 const TString &UserBetweenWhat,
0550 const Int_t &nb_arg_1,
0551 const Int_t &nb_arg_2) {
0552 TMatrixD mat(MatDim, MatDim);
0553 TString CallingMethod = "2D";
0554 TString StandardMatrixType = "?";
0555 TString StandardBetweenWhat = "?";
0556
0557 StandardMatrixType = fCnaParHistos->BuildStandardCovOrCorCode(CallingMethod, UserCorOrCov);
0558 StandardBetweenWhat = fCnaParHistos->BuildStandardBetweenWhatCode(CallingMethod, UserBetweenWhat);
0559
0560 if (StandardMatrixType != "?" && StandardBetweenWhat != "?") {
0561 if (StandardBetweenWhat == "Mss") {
0562 Int_t n1StexStin = nb_arg_1;
0563 Int_t i0StinEcha = nb_arg_2;
0564
0565 if (StandardMatrixType == "Cov") {
0566 mat = ReadCovariancesBetweenSamples(n1StexStin, i0StinEcha, MatDim);
0567 }
0568
0569 if (StandardMatrixType == "Cor") {
0570 mat = ReadCorrelationsBetweenSamples(n1StexStin, i0StinEcha, MatDim);
0571 }
0572 }
0573
0574 if (StandardBetweenWhat != "Mss") {
0575 Int_t n1StexStin_a = nb_arg_1;
0576 Int_t n1StexStin_b = nb_arg_2;
0577
0578 if (StandardMatrixType == "Cov" && StandardBetweenWhat == "MccLF") {
0579 mat = ReadLowFrequencyCovariancesBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);
0580 }
0581
0582 if (StandardMatrixType == "Cor" && StandardBetweenWhat == "MccLF") {
0583 mat = ReadLowFrequencyCorrelationsBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);
0584 }
0585
0586 if (StandardMatrixType == "Cov" && StandardBetweenWhat == "MccHF") {
0587 mat = ReadHighFrequencyCovariancesBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);
0588 }
0589
0590 if (StandardMatrixType == "Cor" && StandardBetweenWhat == "MccHF") {
0591 mat = ReadHighFrequencyCorrelationsBetweenChannels(n1StexStin_a, n1StexStin_b, MatDim);
0592 }
0593 }
0594 } else {
0595 for (Int_t i = 0; i - MatDim < 0; i++) {
0596 for (Int_t j = 0; j - MatDim < 0; j++) {
0597 mat(i, j) = (double_t)0.;
0598 }
0599 }
0600 std::cout << "!TEcnaRead::ReadMatrix(...)> UserCorOrCov = " << UserCorOrCov
0601 << ", UserBetweenWhat = " << UserBetweenWhat << ". Wrong code(s), no file reading." << fTTBELL
0602 << std::endl;
0603 }
0604 return mat;
0605 }
0606
0607 TMatrixD TEcnaRead::ReadMatrix(const Int_t &MatDim, const TString &UserCorOrCov, const TString &UserBetweenWhat) {
0608
0609 TMatrixD mat(MatDim, MatDim);
0610 TString CallingMethod = "2D";
0611 TString StandardMatrixType = "?";
0612 TString StandardBetweenWhat = "?";
0613
0614 StandardMatrixType = fCnaParHistos->BuildStandardCovOrCorCode(CallingMethod, UserCorOrCov);
0615 StandardBetweenWhat = fCnaParHistos->BuildStandardBetweenWhatCode(CallingMethod, UserBetweenWhat);
0616
0617 if (StandardMatrixType != "?" && StandardBetweenWhat != "?") {
0618
0619 if (StandardMatrixType == "Cov" && StandardBetweenWhat == "MccLF") {
0620 mat = ReadLowFrequencyCovariancesBetweenChannels(MatDim);
0621 }
0622
0623 if (StandardMatrixType == "Cor" && StandardBetweenWhat == "MccLF") {
0624 mat = ReadLowFrequencyCorrelationsBetweenChannels(MatDim);
0625 }
0626
0627 if (StandardMatrixType == "Cov" && StandardBetweenWhat == "MccHF") {
0628 mat = ReadHighFrequencyCovariancesBetweenChannels(MatDim);
0629 }
0630
0631 if (StandardMatrixType == "Cor" && StandardBetweenWhat == "MccHF") {
0632 mat = ReadHighFrequencyCorrelationsBetweenChannels(MatDim);
0633 }
0634
0635
0636 if (StandardMatrixType == "Cor" && StandardBetweenWhat == "MttLF") {
0637 mat = ReadLowFrequencyMeanCorrelationsBetweenStins(MatDim);
0638 }
0639
0640 if (StandardMatrixType == "Cor" && StandardBetweenWhat == "MttHF") {
0641 mat = ReadHighFrequencyMeanCorrelationsBetweenStins(MatDim);
0642 }
0643 } else {
0644 for (Int_t i = 0; i - MatDim < 0; i++) {
0645 for (Int_t j = 0; j - MatDim < 0; j++) {
0646 mat(i, j) = (double_t)0.;
0647 }
0648 }
0649 std::cout << "!TEcnaRead::ReadMatrix(...)> UserCorOrCov = " << UserCorOrCov
0650 << ", UserBetweenWhat = " << UserBetweenWhat << ". Wrong code(s), no file reading." << fTTBELL
0651 << std::endl;
0652 }
0653 return mat;
0654 }
0655
0656
0657 TString TEcnaRead::GetTechReadCode(const TString &StandardQuantity, const TString &StandardDetector) {
0658 TString rTechReadCode = "?";
0659 TString dTechDetector = "?";
0660
0661 if (StandardDetector == "SM" || StandardDetector == "Dee") {
0662 dTechDetector = "Stex";
0663 }
0664 if (StandardDetector == "EB" || StandardDetector == "EE") {
0665 dTechDetector = "Stas";
0666 }
0667
0668 if (dTechDetector == "?") {
0669 std::cout << "!TEcnaRead::GetTechReadCode(...)> *** ERROR: wrong standard code *** dTechDetector = "
0670 << dTechDetector << ", StandardDetector = " << StandardDetector << fTTBELL << std::endl;
0671 } else {
0672 if (StandardQuantity == "NOE" && dTechDetector == "Stex") {
0673 rTechReadCode = "NOEStex";
0674 }
0675 if (StandardQuantity == "NOE" && dTechDetector == "Stas") {
0676 rTechReadCode = "NOEStas";
0677 }
0678 if (StandardQuantity == "Ped" && dTechDetector == "Stex") {
0679 rTechReadCode = "PedStex";
0680 }
0681 if (StandardQuantity == "Ped" && dTechDetector == "Stas") {
0682 rTechReadCode = "PedStas";
0683 }
0684 if (StandardQuantity == "TNo" && dTechDetector == "Stex") {
0685 rTechReadCode = "TNoStex";
0686 }
0687 if (StandardQuantity == "TNo" && dTechDetector == "Stas") {
0688 rTechReadCode = "TNoStas";
0689 }
0690 if (StandardQuantity == "LFN" && dTechDetector == "Stex") {
0691 rTechReadCode = "LFNStex";
0692 }
0693 if (StandardQuantity == "LFN" && dTechDetector == "Stas") {
0694 rTechReadCode = "LFNStas";
0695 }
0696 if (StandardQuantity == "HFN" && dTechDetector == "Stex") {
0697 rTechReadCode = "HFNStex";
0698 }
0699 if (StandardQuantity == "HFN" && dTechDetector == "Stas") {
0700 rTechReadCode = "HFNStas";
0701 }
0702 if (StandardQuantity == "MCs" && dTechDetector == "Stex") {
0703 rTechReadCode = "MCsStex";
0704 }
0705 if (StandardQuantity == "MCs" && dTechDetector == "Stas") {
0706 rTechReadCode = "MCsStas";
0707 }
0708 if (StandardQuantity == "SCs" && dTechDetector == "Stex") {
0709 rTechReadCode = "SCsStex";
0710 }
0711 if (StandardQuantity == "SCs" && dTechDetector == "Stas") {
0712 rTechReadCode = "SCsStas";
0713 }
0714 }
0715
0716 if (rTechReadCode == "?") {
0717 std::cout << "!TEcnaRead::GetTechReadCode(...)> *** ERROR: wrong standard code *** rTechReadCode = "
0718 << rTechReadCode << ", StandardQuantity = " << StandardQuantity << fTTBELL << std::endl;
0719 }
0720
0721 return rTechReadCode;
0722 }
0723
0724
0725
0726
0727
0728
0729 void TEcnaRead::FileParameters(const TString &typ_ana,
0730 const Int_t &nb_of_samples,
0731 const Int_t &run_number,
0732 const Int_t &nfirst,
0733 const Int_t &nlast,
0734 const Int_t &nreqevts,
0735 const Int_t &Stex,
0736 const TString &path_root) {
0737
0738
0739
0740
0741 const TString &sTypAna = typ_ana;
0742 Int_t nNbOfSamples = nb_of_samples;
0743 Int_t nRunNumber = run_number;
0744 Int_t nFirstEvt = nfirst;
0745 Int_t nLastEvt = nlast;
0746 Int_t nReqNbOfEvts = nreqevts;
0747 Int_t nStexNumber = Stex;
0748
0749
0750 const Text_t *h_name = "CnaHeader";
0751 const Text_t *h_title = "CnaHeader";
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768 if (fFileHeader == nullptr) {
0769 fFileHeader = new TEcnaHeader(fObjectManager, h_name, h_title);
0770 ;
0771 }
0772 fFileHeader->HeaderParameters(sTypAna, nNbOfSamples, nRunNumber, nFirstEvt, nLastEvt, nReqNbOfEvts, nStexNumber);
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783 fPathRoot = path_root;
0784
0785
0786 fCnaWrite->RegisterFileParameters(typ_ana, nb_of_samples, run_number, nfirst, nlast, nreqevts, Stex);
0787 fCnaWrite->fMakeResultsFileName();
0788
0789
0790
0791 fMemoStinNumbers = 0;
0792
0793 if (fFlagPrint == fCodePrintAllComments || fFlagPrint == fCodePrintComments) {
0794 std::cout << std::endl;
0795 std::cout << "*TEcnaRead::FileParameters(...)>" << std::endl
0796 << " The method has been called with the following argument values:" << std::endl
0797 << " Analysis name = " << fFileHeader->fTypAna << std::endl
0798 << " Nb of required samples = " << fFileHeader->fNbOfSamples << std::endl
0799 << " Run number = " << fFileHeader->fRunNumber << std::endl
0800 << " First requested event number = " << fFileHeader->fFirstReqEvtNumber << std::endl
0801 << " Last requested event number = " << fFileHeader->fLastReqEvtNumber << std::endl
0802 << " Requested number of events = " << fFileHeader->fReqNbOfEvts << std::endl
0803 << " Stex number = " << fFileHeader->fStex << std::endl
0804 << " Path for the ROOT file = " << fPathRoot << std::endl
0805 << std::endl;
0806 }
0807
0808 fReadyToReadRootFile = 1;
0809
0810 }
0811
0812
0813
0814
0815
0816
0817
0818 const TString &TEcnaRead::GetAnalysisName() const { return fFileHeader->fTypAna; }
0819 Int_t TEcnaRead::GetNbOfSamples() { return fFileHeader->fNbOfSamples; }
0820 Int_t TEcnaRead::GetRunNumber() { return fFileHeader->fRunNumber; }
0821 Int_t TEcnaRead::GetFirstReqEvtNumber() { return fFileHeader->fFirstReqEvtNumber; }
0822 Int_t TEcnaRead::GetLastReqEvtNumber() { return fFileHeader->fLastReqEvtNumber; }
0823 Int_t TEcnaRead::GetReqNbOfEvts() { return fFileHeader->fReqNbOfEvts; }
0824 Int_t TEcnaRead::GetStexNumber() { return fFileHeader->fStex; }
0825
0826
0827
0828
0829
0830 time_t TEcnaRead::GetStartTime() { return fFileHeader->fStartTime; }
0831 time_t TEcnaRead::GetStopTime() { return fFileHeader->fStopTime; }
0832 const TString &TEcnaRead::GetStartDate() const { return fFileHeader->fStartDate; }
0833 const TString &TEcnaRead::GetStopDate() const { return fFileHeader->fStopDate; }
0834 TString TEcnaRead::GetRunType() {
0835 TString cType = "run type not defined";
0836 Int_t numtype = fFileHeader->fRunType;
0837
0838
0839 if (numtype == 0) {
0840 cType = "COSMICS";
0841 }
0842 if (numtype == 1) {
0843 cType = "BEAMH4";
0844 }
0845 if (numtype == 2) {
0846 cType = "BEAMH2";
0847 }
0848 if (numtype == 3) {
0849 cType = "MTCC";
0850 }
0851 if (numtype == 4) {
0852 cType = "LASER_STD";
0853 }
0854 if (numtype == 5) {
0855 cType = "LASER_POWER_SCAN";
0856 }
0857 if (numtype == 6) {
0858 cType = "LASER_DELAY_SCAN";
0859 }
0860 if (numtype == 7) {
0861 cType = "TESTPULSE_SCAN_MEM";
0862 }
0863 if (numtype == 8) {
0864 cType = "TESTPULSE_MGPA";
0865 }
0866 if (numtype == 9) {
0867 cType = "PEDESTAL_STD";
0868 }
0869 if (numtype == 10) {
0870 cType = "PEDESTAL_OFFSET_SCAN";
0871 }
0872 if (numtype == 11) {
0873 cType = "PEDESTAL_25NS_SCAN";
0874 }
0875 if (numtype == 12) {
0876 cType = "LED_STD";
0877 }
0878
0879 if (numtype == 13) {
0880 cType = "PHYSICS_GLOBAL";
0881 }
0882 if (numtype == 14) {
0883 cType = "COSMICS_GLOBAL";
0884 }
0885 if (numtype == 15) {
0886 cType = "HALO_GLOBAL";
0887 }
0888
0889 if (numtype == 16) {
0890 cType = "LASER_GAP";
0891 }
0892 if (numtype == 17) {
0893 cType = "TESTPULSE_GAP";
0894 }
0895 if (numtype == 18) {
0896 cType = "PEDESTAL_GAP";
0897 }
0898 if (numtype == 19) {
0899 cType = "LED_GAP";
0900 }
0901
0902 if (numtype == 20) {
0903 cType = "PHYSICS_LOCAL";
0904 }
0905 if (numtype == 21) {
0906 cType = "COSMICS_LOCAL";
0907 }
0908 if (numtype == 22) {
0909 cType = "HALO_LOCAL";
0910 }
0911 if (numtype == 23) {
0912 cType = "CALIB_LOCAL";
0913 }
0914
0915 if (numtype == 24) {
0916 cType = "PEDSIM";
0917 }
0918
0919 return cType;
0920 }
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932 Bool_t TEcnaRead::OpenRootFile(const Text_t *name, const TString &status) {
0933
0934
0935 Bool_t ok_open = kFALSE;
0936
0937 TString s_name;
0938 s_name = fPathRoot;
0939 s_name.Append('/');
0940 s_name.Append(name);
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956 Long_t iCnaRootFile = fObjectManager->GetPointerValue("TEcnaRootFile");
0957 if (iCnaRootFile == 0) {
0958 gCnaRootFile = new TEcnaRootFile(fObjectManager, s_name.Data(), status);
0959 } else {
0960 gCnaRootFile = (TEcnaRootFile *)iCnaRootFile;
0961 gCnaRootFile->ReStart(s_name.Data(), status);
0962 }
0963
0964
0965 if (gCnaRootFile->fRootFileStatus == "RECREATE") {
0966 ok_open = gCnaRootFile->OpenW();
0967 }
0968 if (gCnaRootFile->fRootFileStatus == "READ") {
0969 ok_open = gCnaRootFile->OpenR();
0970 }
0971
0972 if (ok_open == kFALSE) {
0973 std::cout << "!TEcnaRead::OpenRootFile> " << s_name.Data() << ": file not found." << std::endl;
0974
0975
0976 } else {
0977 if (fFlagPrint == fCodePrintAllComments) {
0978 std::cout << "*TEcnaRead::OpenRootFile> Open ROOT file " << s_name.Data() << " OK "
0979 << ", gCnaRootFile = " << gCnaRootFile << std::endl;
0980 }
0981 fOpenRootFile = kTRUE;
0982 fCurrentlyOpenFileName = s_name;
0983 if (fFlagPrint == fCodePrintAllComments) {
0984 std::cout << "*TEcnaRead::OpenRootFile> Open ROOT file: " << fCurrentlyOpenFileName.Data() << " => OK "
0985 << ", gCnaRootFile = " << gCnaRootFile << std::endl
0986 << std::endl;
0987 }
0988 }
0989 return ok_open;
0990 }
0991
0992
0993
0994
0995
0996
0997 Bool_t TEcnaRead::CloseRootFile(const Text_t *name) {
0998
0999
1000 Bool_t ok_close = kFALSE;
1001
1002 if (fOpenRootFile == kTRUE) {
1003 if (gCnaRootFile != nullptr) {
1004 gCnaRootFile->CloseFile();
1005
1006 if (fFlagPrint == fCodePrintAllComments) {
1007 TString e_path;
1008 e_path.Append(name);
1009 std::cout << "*TEcnaRead::CloseRootFile> Close ROOT file " << e_path.Data() << " OK " << std::endl;
1010 }
1011 if (fFlagPrint == fCodePrintAllComments) {
1012 Long_t pointer_value = (Long_t)gCnaRootFile;
1013 std::cout << "*TEcnaRead::CloseRootFile(...)> going to delete gCnaRootFile, gCnaRootFile = " << gCnaRootFile
1014 << ", pointer = " << pointer_value << std::endl;
1015 }
1016
1017
1018
1019 ok_close = kTRUE;
1020 fOpenRootFile = kFALSE;
1021 fCurrentlyOpenFileName = fFlagNoFileOpen;
1022 fReadyToReadRootFile = 0;
1023 } else {
1024 std::cout << "*TEcnaRead::CloseRootFile(...)> RootFile pointer equal to zero. Close not possible. gCnaRootFile = "
1025 << gCnaRootFile << fTTBELL << std::endl;
1026 }
1027 } else {
1028 std::cout << "*TEcnaRead::CloseRootFile(...)> no close since no file is open. fOpenRootFile = " << fOpenRootFile
1029 << std::endl;
1030 }
1031 return ok_close;
1032 }
1033
1034
1035
1036
1037
1038
1039
1040 Bool_t TEcnaRead::LookAtRootFile() {
1041
1042
1043 fLookAtRootFile = 0;
1044
1045 if (fReadyToReadRootFile == 1) {
1046
1047 Int_t iprint = 0;
1048 if (ReadRootFileHeader(iprint) == kTRUE)
1049 {
1050
1051 if (fTagStinNumbers == nullptr) {
1052 fTagStinNumbers = new Int_t[1];
1053 Anew("fTagStinNumbers");
1054 }
1055
1056
1057 if (fT1d_StexStinFromIndex == nullptr) {
1058 fT1d_StexStinFromIndex = new Int_t[fEcal->MaxStinEcnaInStex()];
1059 Anew("fT1d_StexStinFromIndex");
1060 }
1061
1062
1063 TVectorD vec(fEcal->MaxStinEcnaInStex());
1064 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
1065 vec(i) = (Double_t)0.;
1066 }
1067 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
1068
1069 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
1070 fT1d_StexStinFromIndex[i] = (Int_t)vec(i);
1071 }
1072
1073 fTagStinNumbers[0] = 1;
1074 fFileHeader->fStinNumbersCalc++;
1075
1076 fLookAtRootFile = 1;
1077 return kTRUE;
1078 } else {
1079 std::cout << "!TEcnaRead::LookAtRootFile()> *** ERROR ***>"
1080 << " ROOT file not found " << fTTBELL << std::endl;
1081 return kFALSE;
1082 }
1083 } else {
1084 std::cout << "!TEcnaRead::LookAtRootFile()> *** ERROR ***>"
1085 << " FileParameters not called " << fTTBELL << std::endl;
1086 return kFALSE;
1087 }
1088 return kFALSE;
1089 }
1090
1091
1092
1093
1094
1095
1096
1097 Bool_t TEcnaRead::DataExist() {
1098
1099
1100
1101 return fDataExist;
1102 }
1103
1104
1105
1106
1107
1108 Bool_t TEcnaRead::ReadRootFileHeader(const Int_t &i_print) {
1109
1110
1111 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1112 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1113
1114 if (i_print == 1) {
1115 std::cout << "*TEcnaRead::ReadRootFileHeader> file_name = " << fCnaWrite->fRootFileNameShort.Data() << std::endl;
1116 }
1117
1118 Bool_t ok_open = kFALSE;
1119
1120 TString FileNameLong = fCnaWrite->GetRootFileName();
1121 Bool_t allowed_to_read = kFALSE;
1122
1123
1124
1125
1126
1127
1128
1129 if (FileNameLong == fCurrentlyOpenFileName) {
1130 allowed_to_read = kTRUE;
1131 } else {
1132 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1133 CloseRootFile(current_file_name);
1134 }
1135 ok_open = OpenRootFile(file_name, "READ");
1136 if (ok_open) {
1137 allowed_to_read = kTRUE;
1138 } else {
1139 std::cout << "!TEcnaRead::ReadRootFileHeader(...) *** ERROR ***> Open .root file failed for file: " << file_name
1140 << fTTBELL << std::endl;
1141 allowed_to_read = kFALSE;
1142 }
1143 }
1144
1145 if (allowed_to_read == kTRUE) {
1146 TEcnaHeader *headerFile;
1147 headerFile = (TEcnaHeader *)gCnaRootFile->fRootFile->Get("CnaHeader");
1148
1149
1150
1151
1152 fFileHeader->fStartTime = headerFile->fStartTime;
1153 fFileHeader->fStopTime = headerFile->fStopTime;
1154 fFileHeader->fStartDate = headerFile->fStartDate;
1155 fFileHeader->fStopDate = headerFile->fStopDate;
1156
1157 fFileHeader->fRunType = headerFile->fRunType;
1158
1159
1160 fFileHeader->fStinNumbersCalc = headerFile->fStinNumbersCalc;
1161 fFileHeader->fAdcEvtCalc = headerFile->fAdcEvtCalc;
1162 fFileHeader->fMSpCalc = headerFile->fMSpCalc;
1163 fFileHeader->fSSpCalc = headerFile->fSSpCalc;
1164 fFileHeader->fAvTnoCalc = headerFile->fAvTnoCalc;
1165 fFileHeader->fAvLfnCalc = headerFile->fAvLfnCalc;
1166 fFileHeader->fAvHfnCalc = headerFile->fAvHfnCalc;
1167
1168 fFileHeader->fCovCssCalc = headerFile->fCovCssCalc;
1169 fFileHeader->fCorCssCalc = headerFile->fCorCssCalc;
1170 fFileHeader->fHfCovCalc = headerFile->fHfCovCalc;
1171 fFileHeader->fHfCorCalc = headerFile->fHfCorCalc;
1172 fFileHeader->fLfCovCalc = headerFile->fLfCovCalc;
1173 fFileHeader->fLfCorCalc = headerFile->fLfCorCalc;
1174 fFileHeader->fLFccMoStinsCalc = headerFile->fLFccMoStinsCalc;
1175 fFileHeader->fHFccMoStinsCalc = headerFile->fHFccMoStinsCalc;
1176 fFileHeader->fMeanCorssCalc = headerFile->fMeanCorssCalc;
1177 fFileHeader->fSigCorssCalc = headerFile->fSigCorssCalc;
1178
1179 fFileHeader->fAvPedCalc = headerFile->fAvPedCalc;
1180 fFileHeader->fAvMeanCorssCalc = headerFile->fAvMeanCorssCalc;
1181 fFileHeader->fAvSigCorssCalc = headerFile->fAvSigCorssCalc;
1182
1183 if (i_print == 1) {
1184 fFileHeader->Print();
1185 }
1186
1187 CloseRootFile(file_name);
1188 return kTRUE;
1189 }
1190 return kFALSE;
1191 }
1192
1193 void TEcnaRead::TestArrayDimH1(const TString &CallingMethod,
1194 const TString &MaxName,
1195 const Int_t &MaxValue,
1196 const Int_t &VecDim) {
1197
1198
1199 if (MaxValue != VecDim) {
1200 std::cout << "!TEcnaRead::TestArrayDimH1(...)> No matching for array dimension: CallingMethod: "
1201 << CallingMethod.Data() << ", MaxName: " << MaxName.Data() << ", Maxvalue = " << MaxValue
1202 << ", VecDim = " << VecDim << fTTBELL << std::endl;
1203 }
1204 #define NOPM
1205 #ifndef NOPM
1206 else {
1207 std::cout << "!TEcnaRead::TestArrayDimH1(...)> matching array dimension: OK. CallingMethod: "
1208 << CallingMethod.Data() << ", MaxName: " << MaxName.Data() << ", Maxvalue = " << MaxValue
1209 << ", VecDim = " << VecDim << std::endl;
1210 }
1211 #endif
1212 }
1213
1214 void TEcnaRead::TestArrayDimH2(const TString &CallingMethod,
1215 const TString &MaxName,
1216 const Int_t &MaxValue,
1217 const Int_t &MatDim) {
1218
1219
1220 if (MaxValue != MatDim) {
1221 std::cout << "!TEcnaRead::TestArrayDimH2(...)> No matching for array dimension: CallingMethod: "
1222 << CallingMethod.Data() << ", MaxName: " << MaxName.Data() << ", Maxvalue = " << MaxValue
1223 << ", MatDim = " << MatDim << fTTBELL << std::endl;
1224 }
1225 #define NOPN
1226 #ifndef NOPN
1227 else {
1228 std::cout << "!TEcnaRead::TestArrayDimH2(...)> matching array dimension: OK. CallingMethod: "
1229 << CallingMethod.Data() << ", MaxName: " << MaxName.Data() << ", Maxvalue = " << MaxValue
1230 << ", MatDim = " << MatDim << std::endl;
1231 }
1232 #endif
1233 }
1234
1235
1236
1237
1238
1239
1240 TVectorD TEcnaRead::ReadStinNumbers(const Int_t &VecDim) {
1241
1242
1243
1244
1245
1246
1247
1248 TVectorD vec(VecDim);
1249
1250 TestArrayDimH1("ReadStinNumbers", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
1251
1252 for (Int_t i = 0; i < VecDim; i++) {
1253 vec(i) = (Double_t)0.;
1254 }
1255
1256 if (fMemoStinNumbers == 0) {
1257 CnaResultTyp typ = cTypNumbers;
1258 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1259 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1260
1261
1262
1263
1264 Bool_t ok_open = kFALSE;
1265 Bool_t ok_read = kFALSE;
1266
1267 TString FileNameLong = fCnaWrite->GetRootFileName();
1268 Bool_t allowed_to_read = kFALSE;
1269
1270
1271
1272
1273
1274
1275
1276 if (FileNameLong == fCurrentlyOpenFileName) {
1277 allowed_to_read = kTRUE;
1278 } else {
1279 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1280 CloseRootFile(current_file_name);
1281 }
1282 ok_open = OpenRootFile(file_name, "READ");
1283
1284 if (ok_open) {
1285 allowed_to_read = kTRUE;
1286 } else {
1287 std::cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> Open .root file failed for file: " << file_name
1288 << fTTBELL << std::endl;
1289 allowed_to_read = kFALSE;
1290 }
1291 }
1292
1293 if (allowed_to_read == kTRUE) {
1294 Int_t i_zero = 0;
1295 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1296
1297 if (ok_read == kTRUE) {
1298 fDataExist = kTRUE;
1299
1300 for (Int_t i_Stin = 0; i_Stin < VecDim; i_Stin++) {
1301 vec(i_Stin) = gCnaRootFile->fCnaIndivResult->fMatHis(0, i_Stin);
1302 fT1d_StexStinFromIndex[i_Stin] = (Int_t)vec(i_Stin);
1303 }
1304 fMemoStinNumbers++;
1305 } else {
1306 fDataExist = kFALSE;
1307 std::cout << "!TEcnaRead::ReadStinNumbers(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1308 << ": .root file failed" << std::endl
1309 << " -> quantity: <" << GetTypeOfQuantity(typ)
1310 << "> not available in file." << fTTBELL << std::endl;
1311 }
1312 CloseRootFile(file_name);
1313 }
1314
1315 if (ok_read == kTRUE) {
1316
1317 if (fFlagPrint == fCodePrintAllComments) {
1318 for (Int_t i = 0; i < VecDim; i++) {
1319 std::cout << "*TEcnaRead::ReadStinNumbers(...)> StinNumber[" << i << "] = " << vec[i] << std::endl;
1320 }
1321 }
1322 }
1323 } else {
1324 fDataExist = kTRUE;
1325 for (Int_t i_Stin = 0; i_Stin < VecDim; i_Stin++) {
1326 vec(i_Stin) = fT1d_StexStinFromIndex[i_Stin];
1327 }
1328 }
1329 return vec;
1330 }
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343 TVectorD TEcnaRead::ReadSampleAdcValues(const Int_t &n1StexStin,
1344 const Int_t &i0StinEcha,
1345 const Int_t &sample,
1346 const Int_t &VecDim) {
1347
1348
1349
1350
1351
1352 TestArrayDimH1("ReadSampleAdcValues", "fFileHeader->fReqNbOfEvts", fFileHeader->fReqNbOfEvts, VecDim);
1353
1354 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
1355
1356 TVectorD vec(VecDim);
1357 for (Int_t i = 0; i < VecDim; i++) {
1358 vec(i) = (Double_t)0.;
1359 }
1360
1361 CnaResultTyp typ = cTypAdcEvt;
1362
1363 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1364 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1365
1366 Bool_t ok_open = kFALSE;
1367 Bool_t ok_read = kFALSE;
1368
1369 TString FileNameLong = fCnaWrite->GetRootFileName();
1370 Bool_t allowed_to_read = kFALSE;
1371
1372
1373
1374
1375
1376
1377
1378 if (FileNameLong == fCurrentlyOpenFileName) {
1379 allowed_to_read = kTRUE;
1380 } else {
1381 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1382 CloseRootFile(current_file_name);
1383 }
1384 ok_open = OpenRootFile(file_name, "READ");
1385
1386 if (ok_open) {
1387 allowed_to_read = kTRUE;
1388 } else {
1389 std::cout << "!TEcnaRead::ReadSampleAdcValues(...) *** ERROR ***> Open .root file failed for file: " << file_name
1390 << fTTBELL << std::endl;
1391 allowed_to_read = kFALSE;
1392 }
1393 }
1394
1395 if (allowed_to_read == kTRUE) {
1396 ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
1397
1398 if (ok_read == kTRUE) {
1399 fDataExist = kTRUE;
1400 for (Int_t i_bin = 0; i_bin < VecDim; i_bin++) {
1401 vec(i_bin) = gCnaRootFile->fCnaIndivResult->fMatHis(sample, i_bin);
1402 }
1403 } else {
1404 fDataExist = kFALSE;
1405 std::cout << "!TEcnaRead::ReadSampleAdcValues(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1406 << ": .root file failed" << std::endl
1407 << " -> quantity: <" << GetTypeOfQuantity(typ)
1408 << "> not available in file." << fTTBELL << std::endl;
1409 }
1410 CloseRootFile(file_name);
1411 }
1412 return vec;
1413 }
1414
1415
1416
1417
1418
1419
1420
1421 TVectorD TEcnaRead::ReadSampleMeans(const Int_t &n1StexStin, const Int_t &i0StinEcha, const Int_t &VecDim) {
1422
1423
1424
1425
1426
1427
1428 TestArrayDimH1("ReadSampleMeans", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, VecDim);
1429
1430 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
1431
1432 TVectorD vec(VecDim);
1433 for (Int_t i = 0; i < VecDim; i++) {
1434 vec(i) = (Double_t)0.;
1435 }
1436
1437 CnaResultTyp typ = cTypMSp;
1438
1439 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1440 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1441
1442 Bool_t ok_open = kFALSE;
1443 Bool_t ok_read = kFALSE;
1444
1445 TString FileNameLong = fCnaWrite->GetRootFileName();
1446 Bool_t allowed_to_read = kFALSE;
1447
1448
1449
1450
1451
1452
1453
1454 if (FileNameLong == fCurrentlyOpenFileName) {
1455 allowed_to_read = kTRUE;
1456 } else {
1457 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1458 CloseRootFile(current_file_name);
1459 }
1460 ok_open = OpenRootFile(file_name, "READ");
1461 if (ok_open) {
1462 allowed_to_read = kTRUE;
1463 } else {
1464 std::cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> Open .root file failed for file: " << file_name
1465 << fTTBELL << std::endl;
1466 allowed_to_read = kFALSE;
1467 }
1468 }
1469
1470 if (allowed_to_read == kTRUE) {
1471 Int_t i_zero = 0;
1472 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1473
1474 if (ok_read == kTRUE) {
1475 fDataExist = kTRUE;
1476 for (Int_t i_samp = 0; i_samp < VecDim; i_samp++) {
1477 vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
1478 }
1479 } else {
1480 fDataExist = kFALSE;
1481 std::cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1482 << ": .root file failed" << std::endl
1483 << " quantity: <" << GetTypeOfQuantity(typ)
1484 << "> not available in file." << fTTBELL << std::endl;
1485 }
1486 CloseRootFile(file_name);
1487 }
1488 return vec;
1489 }
1490
1491 TVectorD TEcnaRead::ReadSampleMeans(const Int_t &n1StexStin, const Int_t &VecDim) {
1492
1493
1494
1495
1496
1497
1498 TestArrayDimH1("ReadSampleMeans",
1499 "fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin()",
1500 fFileHeader->fNbOfSamples * fEcal->MaxCrysInStin(),
1501 VecDim);
1502
1503 TVectorD vec(VecDim);
1504 for (Int_t i = 0; i < VecDim; i++) {
1505 vec(i) = (Double_t)0.;
1506 }
1507
1508 CnaResultTyp typ = cTypMSp;
1509
1510 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1511 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1512
1513 Bool_t ok_open = kFALSE;
1514 Bool_t ok_read = kFALSE;
1515
1516 TString FileNameLong = fCnaWrite->GetRootFileName();
1517 Bool_t allowed_to_read = kFALSE;
1518
1519
1520
1521
1522
1523
1524
1525 if (FileNameLong == fCurrentlyOpenFileName) {
1526 allowed_to_read = kTRUE;
1527 } else {
1528 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1529 CloseRootFile(current_file_name);
1530 }
1531 ok_open = OpenRootFile(file_name, "READ");
1532
1533 if (ok_open) {
1534 allowed_to_read = kTRUE;
1535 } else {
1536 std::cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> Open .root file failed for file: " << file_name
1537 << fTTBELL << std::endl;
1538 allowed_to_read = kFALSE;
1539 }
1540 }
1541
1542 if (allowed_to_read == kTRUE) {
1543 Int_t i_zero = 0;
1544 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1545
1546 if (ok_read == kTRUE) {
1547 fDataExist = kTRUE;
1548
1549 for (Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++) {
1550 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
1551 for (Int_t i_samp = 0; i_samp < fFileHeader->fNbOfSamples; i_samp++) {
1552 vec(i0StinEcha * fFileHeader->fNbOfSamples + i_samp) =
1553 gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
1554 }
1555 }
1556 } else {
1557 fDataExist = kFALSE;
1558 std::cout << "!TEcnaRead::ReadSampleMeans(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1559 << ": .root file failed" << std::endl
1560 << " -> quantity: <" << GetTypeOfQuantity(typ)
1561 << "> not available in file." << fTTBELL << std::endl;
1562 }
1563 CloseRootFile(file_name);
1564 }
1565 return vec;
1566 }
1567
1568
1569
1570
1571
1572
1573 TVectorD TEcnaRead::ReadSampleSigmas(const Int_t &n1StexStin, const Int_t &i0StinEcha, const Int_t &VecDim) {
1574
1575
1576
1577
1578
1579
1580 TestArrayDimH1("ReadSampleSigmas", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, VecDim);
1581
1582 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
1583
1584 TVectorD vec(VecDim);
1585 vec.Zero();
1586
1587 CnaResultTyp typ = cTypSSp;
1588
1589 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1590 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1591
1592 TString FileNameLong = fCnaWrite->GetRootFileName();
1593
1594
1595
1596
1597
1598
1599
1600 if (FileNameLong != fCurrentlyOpenFileName) {
1601 if (fCurrentlyOpenFileName != fFlagNoFileOpen)
1602 CloseRootFile(current_file_name);
1603
1604 if (!(OpenRootFile(file_name, "READ"))) {
1605 std::cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> Open .root file failed for file: " << file_name
1606 << fTTBELL << std::endl;
1607 return vec;
1608 }
1609 }
1610
1611 Int_t i_zero = 0;
1612
1613 if (gCnaRootFile->ReadElement(typ, i_zero)) {
1614 fDataExist = kTRUE;
1615 for (Int_t i_samp = 0; i_samp < VecDim; i_samp++) {
1616 vec(i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
1617 }
1618 } else {
1619 fDataExist = kFALSE;
1620 std::cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1621 << ": .root file failed" << std::endl
1622 << " -> quantity: <" << GetTypeOfQuantity(typ)
1623 << "> not available in file." << fTTBELL << std::endl;
1624 }
1625 CloseRootFile(file_name);
1626 return vec;
1627 }
1628
1629 TVectorD TEcnaRead::ReadSampleSigmas(const Int_t &n1StexStin, const Int_t &VecDim) {
1630
1631
1632
1633
1634
1635
1636 TestArrayDimH1("ReadSampleSigmas",
1637 "fFileHeader->fNbOfSamples*fEcal->MaxCrysInStin()",
1638 fFileHeader->fNbOfSamples * fEcal->MaxCrysInStin(),
1639 VecDim);
1640
1641 TVectorD vec(VecDim);
1642 for (Int_t i = 0; i < VecDim; i++) {
1643 vec(i) = (Double_t)0.;
1644 }
1645
1646 CnaResultTyp typ = cTypSSp;
1647
1648 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1649 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1650
1651 Bool_t ok_open = kFALSE;
1652 Bool_t ok_read = kFALSE;
1653
1654 TString FileNameLong = fCnaWrite->GetRootFileName();
1655 Bool_t allowed_to_read = kFALSE;
1656
1657
1658
1659
1660
1661
1662
1663 if (FileNameLong == fCurrentlyOpenFileName) {
1664 allowed_to_read = kTRUE;
1665 } else {
1666 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1667 CloseRootFile(current_file_name);
1668 }
1669 ok_open = OpenRootFile(file_name, "READ");
1670
1671 if (ok_open) {
1672 allowed_to_read = kTRUE;
1673 } else {
1674 std::cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> Open .root file failed for file: " << file_name
1675 << fTTBELL << std::endl;
1676 allowed_to_read = kFALSE;
1677 }
1678 }
1679
1680 if (allowed_to_read == kTRUE) {
1681 Int_t i_zero = 0;
1682 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1683
1684 if (ok_read == kTRUE) {
1685 fDataExist = kTRUE;
1686
1687 for (Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++) {
1688 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
1689 for (Int_t i_samp = 0; i_samp < fFileHeader->fNbOfSamples; i_samp++) {
1690 vec(i0StinEcha * fFileHeader->fNbOfSamples + i_samp) =
1691 gCnaRootFile->fCnaIndivResult->fMatHis(i0StexEcha, i_samp);
1692 }
1693 }
1694 } else {
1695 fDataExist = kFALSE;
1696 std::cout << "!TEcnaRead::ReadSampleSigmas(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1697 << ": .root file failed" << std::endl
1698 << " -> quantity: <" << GetTypeOfQuantity(typ)
1699 << "> not available in file." << fTTBELL << std::endl;
1700 }
1701 CloseRootFile(file_name);
1702 }
1703 return vec;
1704 }
1705
1706
1707
1708
1709
1710
1711 TVectorD TEcnaRead::ReadNumberOfEvents(const Int_t &VecDim) {
1712
1713
1714
1715
1716
1717
1718
1719 TestArrayDimH1("ReadNumberOfEvents", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
1720
1721 TVectorD vec(VecDim);
1722 for (Int_t i = 0; i < VecDim; i++) {
1723 vec(i) = (Double_t)0.;
1724 }
1725
1726 TMatrixD mat(fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
1727
1728 for (Int_t iStexStin = 0; iStexStin < fEcal->MaxStinEcnaInStex(); iStexStin++) {
1729
1730 for (Int_t i = 0; i < fEcal->MaxCrysInStin(); i++) {
1731 for (Int_t j = 0; j < fFileHeader->fNbOfSamples; j++) {
1732 mat(i, j) = (Double_t)0.;
1733 }
1734 }
1735
1736 Int_t n1StexStin = iStexStin + 1;
1737 mat = ReadNumberOfEventsForSamples(n1StexStin, fEcal->MaxCrysInStin(), fFileHeader->fNbOfSamples);
1738
1739 for (Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++) {
1740 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
1741 vec(i0StexEcha) = 0;
1742
1743 for (Int_t i_samp = 0; i_samp < fFileHeader->fNbOfSamples; i_samp++) {
1744 vec(i0StexEcha) += mat(i0StinEcha, i_samp);
1745 }
1746 vec(i0StexEcha) = vec(i0StexEcha) / fFileHeader->fNbOfSamples;
1747 }
1748 }
1749 return vec;
1750 }
1751
1752
1753
1754
1755
1756
1757 TMatrixD TEcnaRead::ReadNumberOfEventsForSamples(const Int_t &n1StexStin, const Int_t &MatDimX, const Int_t &MatDimY) {
1758
1759
1760
1761
1762
1763
1764
1765 TMatrixD mat(MatDimX, MatDimY);
1766 for (Int_t i = 0; i - MatDimX < 0; i++) {
1767 for (Int_t j = 0; j - MatDimY < 0; j++) {
1768 mat(i, j) = (Double_t)0.;
1769 }
1770 }
1771
1772 Int_t Stin_index = GetStinIndex(n1StexStin);
1773 if (Stin_index >= 0) {
1774 if (fLookAtRootFile == 1) {
1775 CnaResultTyp typ = cTypNbOfEvts;
1776 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1777 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1778
1779 Bool_t ok_open = kFALSE;
1780 Bool_t ok_read = kFALSE;
1781
1782 TString FileNameLong = fCnaWrite->GetRootFileName();
1783 Bool_t allowed_to_read = kFALSE;
1784
1785
1786
1787
1788
1789
1790
1791 if (FileNameLong == fCurrentlyOpenFileName) {
1792 allowed_to_read = kTRUE;
1793 } else {
1794 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1795 CloseRootFile(current_file_name);
1796 }
1797 ok_open = OpenRootFile(file_name, "READ");
1798 if (ok_open) {
1799 allowed_to_read = kTRUE;
1800 } else {
1801 std::cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> Open .root file failed for file: "
1802 << file_name << fTTBELL << std::endl;
1803 allowed_to_read = kFALSE;
1804 }
1805 }
1806
1807 if (allowed_to_read == kTRUE) {
1808 Int_t i_zero = 0;
1809 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1810
1811 if (ok_read == kTRUE) {
1812 fDataExist = kTRUE;
1813 for (Int_t i_crys = 0; i_crys - MatDimX < 0; i_crys++) {
1814 Int_t j_cna_chan = Stin_index * MatDimX + i_crys;
1815 for (Int_t i_samp = 0; i_samp - MatDimY < 0; i_samp++) {
1816 mat(i_crys, i_samp) = gCnaRootFile->fCnaIndivResult->fMatHis(j_cna_chan, i_samp);
1817 }
1818 }
1819 } else {
1820 fDataExist = kFALSE;
1821 std::cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
1822 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
1823 << " -> quantity: <"
1824 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
1825 }
1826 }
1827 CloseRootFile(file_name);
1828 }
1829 else {
1830 std::cout << "!TEcnaRead::ReadNumberOfEventsForSamples(...) *** ERROR ***> "
1831 << "It is not possible to access the number of found events: the ROOT file has not been read."
1832 << fTTBELL << std::endl;
1833 }
1834 }
1835 return mat;
1836 }
1837
1838
1839
1840
1841
1842
1843 TVectorD TEcnaRead::ReadPedestals(const Int_t &VecDim) {
1844
1845
1846
1847
1848
1849
1850 TestArrayDimH1("ReadPedestals", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
1851
1852 TVectorD vec(VecDim);
1853 for (Int_t i = 0; i < VecDim; i++) {
1854 vec(i) = (Double_t)0.;
1855 }
1856
1857 CnaResultTyp typ = cTypPed;
1858 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1859 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1860
1861 Bool_t ok_open = kFALSE;
1862 Bool_t ok_read = kFALSE;
1863
1864 TString FileNameLong = fCnaWrite->GetRootFileName();
1865 Bool_t allowed_to_read = kFALSE;
1866
1867
1868
1869
1870
1871
1872
1873 if (FileNameLong == fCurrentlyOpenFileName) {
1874 allowed_to_read = kTRUE;
1875 } else {
1876 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1877 CloseRootFile(current_file_name);
1878 }
1879 ok_open = OpenRootFile(file_name, "READ");
1880 if (ok_open) {
1881 allowed_to_read = kTRUE;
1882 } else {
1883 std::cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> Open .root file failed for file: " << file_name
1884 << fTTBELL << std::endl;
1885 allowed_to_read = kFALSE;
1886 }
1887 }
1888
1889 if (allowed_to_read == kTRUE) {
1890 Int_t i_zero = 0;
1891 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1892
1893 if (ok_read == kTRUE) {
1894 fDataExist = kTRUE;
1895 for (Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++) {
1896 vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
1897 }
1898 } else {
1899 fDataExist = kFALSE;
1900 std::cout << "!TEcnaRead::ReadPedestals(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1901 << ": .root file failed" << std::endl
1902 << " -> quantity: <" << GetTypeOfQuantity(typ)
1903 << "> not available in file." << fTTBELL << std::endl;
1904 }
1905 CloseRootFile(file_name);
1906 }
1907 return vec;
1908 }
1909
1910
1911
1912
1913
1914
1915 TVectorD TEcnaRead::ReadTotalNoise(const Int_t &VecDim) {
1916
1917
1918
1919
1920
1921
1922 TestArrayDimH1("ReadTotalNoise", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
1923
1924 TVectorD vec(VecDim);
1925 for (Int_t i = 0; i < VecDim; i++) {
1926 vec(i) = (Double_t)0.;
1927 }
1928 CnaResultTyp typ = cTypTno;
1929 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
1930 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
1931
1932 Bool_t ok_open = kFALSE;
1933 Bool_t ok_read = kFALSE;
1934
1935 TString FileNameLong = fCnaWrite->GetRootFileName();
1936 Bool_t allowed_to_read = kFALSE;
1937
1938
1939
1940
1941
1942
1943
1944 if (FileNameLong == fCurrentlyOpenFileName) {
1945 allowed_to_read = kTRUE;
1946 } else {
1947 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
1948 CloseRootFile(current_file_name);
1949 }
1950 ok_open = OpenRootFile(file_name, "READ");
1951 if (ok_open) {
1952 allowed_to_read = kTRUE;
1953 } else {
1954 std::cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> Open .root file failed for file: " << file_name
1955 << fTTBELL << std::endl;
1956 allowed_to_read = kFALSE;
1957 }
1958 }
1959
1960 if (allowed_to_read == kTRUE) {
1961 Int_t i_zero = 0;
1962 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
1963
1964 if (ok_read == kTRUE) {
1965 fDataExist = kTRUE;
1966 for (Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++) {
1967 vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
1968 }
1969 } else {
1970 fDataExist = kFALSE;
1971 std::cout << "!TEcnaRead::ReadTotalNoise(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
1972 << ": .root file failed" << std::endl
1973 << " -> quantity: <" << GetTypeOfQuantity(typ)
1974 << "> not available in file." << fTTBELL << std::endl;
1975 }
1976 CloseRootFile(file_name);
1977 }
1978 return vec;
1979 }
1980
1981
1982
1983
1984
1985 TVectorD TEcnaRead::ReadMeanCorrelationsBetweenSamples(const Int_t &VecDim) {
1986
1987
1988
1989
1990
1991
1992 TestArrayDimH1(
1993 "ReadMeanCorrelationsBetweenSamples", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
1994
1995 TVectorD vec(VecDim);
1996 for (Int_t i = 0; i < VecDim; i++) {
1997 vec(i) = (Double_t)0.;
1998 }
1999 CnaResultTyp typ = cTypMeanCorss;
2000 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2001 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2002
2003 Bool_t ok_open = kFALSE;
2004 Bool_t ok_read = kFALSE;
2005
2006 TString FileNameLong = fCnaWrite->GetRootFileName();
2007 Bool_t allowed_to_read = kFALSE;
2008
2009
2010
2011
2012
2013
2014
2015 if (FileNameLong == fCurrentlyOpenFileName) {
2016 allowed_to_read = kTRUE;
2017 } else {
2018 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2019 CloseRootFile(current_file_name);
2020 }
2021 ok_open = OpenRootFile(file_name, "READ");
2022 if (ok_open) {
2023 allowed_to_read = kTRUE;
2024 } else {
2025 std::cout
2026 << "!TEcnaRead::ReadMeanCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
2027 << file_name << fTTBELL << std::endl;
2028 allowed_to_read = kFALSE;
2029 }
2030 }
2031
2032 if (allowed_to_read == kTRUE) {
2033 Int_t i_zero = 0;
2034 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2035
2036 if (ok_read == kTRUE) {
2037 fDataExist = kTRUE;
2038 for (Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++) {
2039 vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
2040 }
2041 } else {
2042 fDataExist = kFALSE;
2043 std::cout << "!TEcnaRead::ReadMeanCorrelationsBetweenSamples(...) *** ERROR ***> "
2044 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2045 << " -> quantity: <"
2046 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2047 }
2048 CloseRootFile(file_name);
2049 }
2050 return vec;
2051 }
2052
2053
2054
2055
2056
2057
2058 TVectorD TEcnaRead::ReadLowFrequencyNoise(const Int_t &VecDim) {
2059
2060
2061
2062
2063
2064
2065 TestArrayDimH1("ReadLowFrequencyNoise", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
2066
2067 TVectorD vec(VecDim);
2068 for (Int_t i = 0; i < VecDim; i++) {
2069 vec(i) = (Double_t)0.;
2070 }
2071 CnaResultTyp typ = cTypLfn;
2072 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2073 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2074
2075 Bool_t ok_open = kFALSE;
2076 Bool_t ok_read = kFALSE;
2077
2078 TString FileNameLong = fCnaWrite->GetRootFileName();
2079 Bool_t allowed_to_read = kFALSE;
2080
2081
2082
2083
2084
2085
2086
2087 if (FileNameLong == fCurrentlyOpenFileName) {
2088 allowed_to_read = kTRUE;
2089 } else {
2090 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2091 CloseRootFile(current_file_name);
2092 }
2093 ok_open = OpenRootFile(file_name, "READ");
2094
2095 if (ok_open) {
2096 allowed_to_read = kTRUE;
2097 } else {
2098 std::cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
2099 << file_name << fTTBELL << std::endl;
2100 allowed_to_read = kFALSE;
2101 }
2102 }
2103
2104 if (allowed_to_read == kTRUE) {
2105 Int_t i_zero = 0;
2106 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2107
2108 if (ok_read == kTRUE) {
2109 fDataExist = kTRUE;
2110 for (Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++) {
2111 vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
2112 }
2113 } else {
2114 fDataExist = kFALSE;
2115 std::cout << "!TEcnaRead::ReadLowFrequencyNoise(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
2116 << ": .root file failed" << std::endl
2117 << " -> quantity: <" << GetTypeOfQuantity(typ)
2118 << "> not available in file." << fTTBELL << std::endl;
2119 }
2120 CloseRootFile(file_name);
2121 }
2122 return vec;
2123 }
2124
2125
2126
2127
2128
2129
2130 TVectorD TEcnaRead::ReadHighFrequencyNoise(const Int_t &VecDim) {
2131
2132
2133
2134
2135
2136
2137 TestArrayDimH1("ReadHighFrequencyNoise", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
2138
2139 TVectorD vec(VecDim);
2140 for (Int_t i = 0; i < VecDim; i++) {
2141 vec(i) = (Double_t)0.;
2142 }
2143 CnaResultTyp typ = cTypHfn;
2144 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2145 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2146
2147 Bool_t ok_open = kFALSE;
2148 Bool_t ok_read = kFALSE;
2149
2150 TString FileNameLong = fCnaWrite->GetRootFileName();
2151 Bool_t allowed_to_read = kFALSE;
2152
2153
2154
2155
2156
2157
2158
2159 if (FileNameLong == fCurrentlyOpenFileName) {
2160 allowed_to_read = kTRUE;
2161 } else {
2162 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2163 CloseRootFile(current_file_name);
2164 }
2165 ok_open = OpenRootFile(file_name, "READ");
2166
2167 if (ok_open) {
2168 allowed_to_read = kTRUE;
2169 } else {
2170 std::cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
2171 << file_name << fTTBELL << std::endl;
2172 allowed_to_read = kFALSE;
2173 }
2174 }
2175
2176 if (allowed_to_read == kTRUE) {
2177 Int_t i_zero = 0;
2178 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2179
2180 if (ok_read == kTRUE) {
2181 fDataExist = kTRUE;
2182 for (Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++) {
2183 vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
2184 }
2185 } else {
2186 fDataExist = kFALSE;
2187 std::cout << "!TEcnaRead::ReadHighFrequencyNoise(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
2188 << ": .root file failed" << std::endl
2189 << " -> quantity: <" << GetTypeOfQuantity(typ)
2190 << "> not available in file." << fTTBELL << std::endl;
2191 }
2192 CloseRootFile(file_name);
2193 }
2194 return vec;
2195 }
2196
2197
2198
2199
2200
2201
2202 TVectorD TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(const Int_t &VecDim) {
2203
2204
2205
2206
2207
2208
2209 TestArrayDimH1(
2210 "ReadSigmaOfCorrelationsBetweenSamples", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), VecDim);
2211
2212 TVectorD vec(VecDim);
2213 for (Int_t i = 0; i < VecDim; i++) {
2214 vec(i) = (Double_t)0.;
2215 }
2216 CnaResultTyp typ = cTypSigCorss;
2217 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2218 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2219
2220 Bool_t ok_open = kFALSE;
2221 Bool_t ok_read = kFALSE;
2222
2223 TString FileNameLong = fCnaWrite->GetRootFileName();
2224 Bool_t allowed_to_read = kFALSE;
2225
2226
2227
2228
2229
2230
2231
2232 if (FileNameLong == fCurrentlyOpenFileName) {
2233 allowed_to_read = kTRUE;
2234 } else {
2235 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2236 CloseRootFile(current_file_name);
2237 }
2238 ok_open = OpenRootFile(file_name, "READ");
2239
2240 if (ok_open) {
2241 allowed_to_read = kTRUE;
2242 } else {
2243 std::cout
2244 << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
2245 << file_name << fTTBELL << std::endl;
2246 allowed_to_read = kFALSE;
2247 }
2248 }
2249
2250 if (allowed_to_read == kTRUE) {
2251 Int_t i_zero = 0;
2252 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2253
2254 if (ok_read == kTRUE) {
2255 fDataExist = kTRUE;
2256 for (Int_t i_StexCrys = 0; i_StexCrys < VecDim; i_StexCrys++) {
2257 vec(i_StexCrys) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i_StexCrys);
2258 }
2259 } else {
2260 fDataExist = kFALSE;
2261 std::cout << "!TEcnaRead::ReadSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
2262 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2263 << " -> quantity: <"
2264 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2265 }
2266 CloseRootFile(file_name);
2267 }
2268 return vec;
2269 }
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279 TVectorD TEcnaRead::ReadAverageNumberOfEvents(const Int_t &VecDim) {
2280
2281
2282
2283
2284
2285
2286
2287 TestArrayDimH1("ReadAverageNumberOfEvents", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2288
2289 TVectorD vecAverage(VecDim);
2290 for (Int_t i = 0; i < VecDim; i++) {
2291 vecAverage(i) = (Double_t)0.;
2292 }
2293
2294 TVectorD vecMean(fEcal->MaxCrysEcnaInStex());
2295 for (Int_t i = 0; i < fEcal->MaxCrysEcnaInStex(); i++) {
2296 vecMean(i) = (Double_t)0.;
2297 }
2298
2299 vecMean = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());
2300
2301 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2302 vecAverage(i0StexStin) = 0;
2303
2304 for (Int_t i0StinEcha = 0; i0StinEcha < fEcal->MaxCrysInStin(); i0StinEcha++) {
2305 Int_t n1StexStin = i0StexStin + 1;
2306 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
2307
2308 if (fStexName == "SM") {
2309 vecAverage(i0StexStin) += vecMean(i0StexEcha);
2310 }
2311
2312 if (fStexName == "Dee") {
2313
2314
2315
2316 Int_t n1StinEcha = i0StinEcha + 1;
2317 if (n1StexStin == 10 && n1StinEcha == 11) {
2318 i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(29, i0StinEcha);
2319 }
2320 if (n1StexStin == 11 && n1StinEcha == 11) {
2321 i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(32, i0StinEcha);
2322 }
2323 if (!((n1StexStin == 29 || n1StexStin == 32) && n1StinEcha == 11)) {
2324 vecAverage(i0StexStin) += vecMean(i0StexEcha);
2325 }
2326 }
2327 }
2328
2329 Double_t xdivis = (Double_t)0.;
2330 if (fStexName == "SM") {
2331 xdivis = (Double_t)fEcal->MaxCrysInStin();
2332 }
2333 if (fStexName == "Dee") {
2334 Int_t n1StexStin = i0StexStin + 1;
2335 xdivis = (Double_t)fEcalNumbering->MaxCrysInStinEcna(fFileHeader->fStex, n1StexStin, "TEcnaRead");
2336 }
2337
2338 vecAverage(i0StexStin) = vecAverage(i0StexStin) / xdivis;
2339 }
2340 return vecAverage;
2341 }
2342
2343
2344
2345
2346
2347
2348 TVectorD TEcnaRead::ReadAveragePedestals(const Int_t &VecDim) {
2349
2350
2351
2352
2353
2354
2355 TestArrayDimH1("ReadAveragePedestals", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2356
2357 TVectorD vec(VecDim);
2358 for (Int_t i = 0; i < VecDim; i++) {
2359 vec(i) = (Double_t)0.;
2360 }
2361
2362 CnaResultTyp typ = cTypAvPed;
2363 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2364 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2365
2366 Bool_t ok_open = kFALSE;
2367 Bool_t ok_read = kFALSE;
2368
2369 TString FileNameLong = fCnaWrite->GetRootFileName();
2370 Bool_t allowed_to_read = kFALSE;
2371
2372
2373
2374
2375
2376
2377
2378 if (FileNameLong == fCurrentlyOpenFileName) {
2379 allowed_to_read = kTRUE;
2380 } else {
2381 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2382 CloseRootFile(current_file_name);
2383 }
2384 ok_open = OpenRootFile(file_name, "READ");
2385
2386 if (ok_open) {
2387 allowed_to_read = kTRUE;
2388 } else {
2389 std::cout << "!TEcnaRead::ReadAveragePedestals(...) *** ERROR ***> Open .root file failed for file: " << file_name
2390 << fTTBELL << std::endl;
2391 allowed_to_read = kFALSE;
2392 }
2393 }
2394
2395 if (allowed_to_read == kTRUE) {
2396 Int_t i_zero = 0;
2397 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2398
2399 if (ok_read == kTRUE) {
2400 fDataExist = kTRUE;
2401 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2402 vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
2403 }
2404 } else {
2405 fDataExist = kFALSE;
2406 std::cout << "!TEcnaRead::ReadAveragePedestals(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
2407 << ": .root file failed" << std::endl
2408 << " -> quantity: <" << GetTypeOfQuantity(typ)
2409 << "> not available in file." << fTTBELL << std::endl;
2410 }
2411 CloseRootFile(file_name);
2412 }
2413 return vec;
2414 }
2415
2416
2417
2418
2419
2420
2421 TVectorD TEcnaRead::ReadAverageTotalNoise(const Int_t &VecDim) {
2422
2423
2424
2425
2426
2427
2428 TestArrayDimH1("ReadAverageTotalNoise", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2429
2430 TVectorD vec(VecDim);
2431 for (Int_t i = 0; i < VecDim; i++) {
2432 vec(i) = (Double_t)0.;
2433 }
2434
2435 CnaResultTyp typ = cTypAvTno;
2436 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2437 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2438
2439 Bool_t ok_open = kFALSE;
2440 Bool_t ok_read = kFALSE;
2441
2442 TString FileNameLong = fCnaWrite->GetRootFileName();
2443 Bool_t allowed_to_read = kFALSE;
2444
2445
2446
2447
2448
2449
2450
2451 if (FileNameLong == fCurrentlyOpenFileName) {
2452 allowed_to_read = kTRUE;
2453 } else {
2454 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2455 CloseRootFile(current_file_name);
2456 }
2457 ok_open = OpenRootFile(file_name, "READ");
2458
2459 if (ok_open) {
2460 allowed_to_read = kTRUE;
2461 } else {
2462 std::cout << "!TEcnaRead::ReadAverageTotalNoise(...) *** ERROR ***> Open .root file failed for file: "
2463 << file_name << fTTBELL << std::endl;
2464 allowed_to_read = kFALSE;
2465 }
2466 }
2467
2468 if (allowed_to_read == kTRUE) {
2469 Int_t i_zero = 0;
2470 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2471
2472 if (ok_read == kTRUE) {
2473 fDataExist = kTRUE;
2474 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2475 vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
2476 }
2477 } else {
2478 fDataExist = kFALSE;
2479 std::cout << "!TEcnaRead::ReadAverageTotalNoise(...) *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
2480 << ": .root file failed" << std::endl
2481 << " -> quantity: <" << GetTypeOfQuantity(typ)
2482 << "> not available in file." << fTTBELL << std::endl;
2483 }
2484 CloseRootFile(file_name);
2485 }
2486 return vec;
2487 }
2488
2489
2490
2491
2492
2493
2494 TVectorD TEcnaRead::ReadAverageLowFrequencyNoise(const Int_t &VecDim) {
2495
2496
2497
2498
2499
2500
2501 TestArrayDimH1("ReadAverageLowFrequencyNoise", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2502
2503 TVectorD vec(VecDim);
2504 for (Int_t i = 0; i < VecDim; i++) {
2505 vec(i) = (Double_t)0.;
2506 }
2507
2508 CnaResultTyp typ = cTypAvLfn;
2509 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2510 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2511
2512 Bool_t ok_open = kFALSE;
2513 Bool_t ok_read = kFALSE;
2514
2515 TString FileNameLong = fCnaWrite->GetRootFileName();
2516 Bool_t allowed_to_read = kFALSE;
2517
2518
2519
2520
2521
2522
2523
2524 if (FileNameLong == fCurrentlyOpenFileName) {
2525 allowed_to_read = kTRUE;
2526 } else {
2527 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2528 CloseRootFile(current_file_name);
2529 }
2530 ok_open = OpenRootFile(file_name, "READ");
2531
2532 if (ok_open) {
2533 allowed_to_read = kTRUE;
2534 } else {
2535 std::cout << "!TEcnaRead::ReadAverageLowFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
2536 << file_name << fTTBELL << std::endl;
2537 allowed_to_read = kFALSE;
2538 }
2539 }
2540
2541 if (allowed_to_read == kTRUE) {
2542 Int_t i_zero = 0;
2543 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2544
2545 if (ok_read == kTRUE) {
2546 fDataExist = kTRUE;
2547 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2548 vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
2549 }
2550 } else {
2551 fDataExist = kFALSE;
2552 std::cout << "!TEcnaRead::ReadAverageLowFrequencyNoise(...) *** ERROR ***> "
2553 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2554 << " -> quantity: <"
2555 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2556 }
2557 CloseRootFile(file_name);
2558 }
2559 return vec;
2560 }
2561
2562
2563
2564
2565
2566
2567 TVectorD TEcnaRead::ReadAverageHighFrequencyNoise(const Int_t &VecDim) {
2568
2569
2570
2571
2572
2573
2574 TestArrayDimH1("ReadAverageHighFrequencyNoise", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2575
2576 TVectorD vec(VecDim);
2577 for (Int_t i = 0; i < VecDim; i++) {
2578 vec(i) = (Double_t)0.;
2579 }
2580
2581 CnaResultTyp typ = cTypAvHfn;
2582 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2583 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2584
2585 Bool_t ok_open = kFALSE;
2586 Bool_t ok_read = kFALSE;
2587
2588 TString FileNameLong = fCnaWrite->GetRootFileName();
2589 Bool_t allowed_to_read = kFALSE;
2590
2591
2592
2593
2594
2595
2596
2597 if (FileNameLong == fCurrentlyOpenFileName) {
2598 allowed_to_read = kTRUE;
2599 } else {
2600 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2601 CloseRootFile(current_file_name);
2602 }
2603 ok_open = OpenRootFile(file_name, "READ");
2604
2605 if (ok_open) {
2606 allowed_to_read = kTRUE;
2607 } else {
2608 std::cout << "!TEcnaRead::ReadAverageHighFrequencyNoise(...) *** ERROR ***> Open .root file failed for file: "
2609 << file_name << fTTBELL << std::endl;
2610 allowed_to_read = kFALSE;
2611 }
2612 }
2613
2614 if (allowed_to_read == kTRUE) {
2615 Int_t i_zero = 0;
2616 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2617
2618 if (ok_read == kTRUE) {
2619 fDataExist = kTRUE;
2620 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2621 vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
2622 }
2623 } else {
2624 fDataExist = kFALSE;
2625 std::cout << "!TEcnaRead::ReadAverageHighFrequencyNoise(...) *** ERROR ***> "
2626 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2627 << " -> quantity: <"
2628 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2629 }
2630 CloseRootFile(file_name);
2631 }
2632 return vec;
2633 }
2634
2635
2636
2637
2638
2639
2640 TVectorD TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(const Int_t &VecDim) {
2641
2642
2643
2644
2645
2646
2647 TestArrayDimH1(
2648 "ReadAverageMeanCorrelationsBetweenSamples", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2649
2650 TVectorD vec(VecDim);
2651 for (Int_t i = 0; i < VecDim; i++) {
2652 vec(i) = (Double_t)0.;
2653 }
2654
2655 CnaResultTyp typ = cTypAvMeanCorss;
2656 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2657 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2658
2659 Bool_t ok_open = kFALSE;
2660 Bool_t ok_read = kFALSE;
2661
2662 TString FileNameLong = fCnaWrite->GetRootFileName();
2663 Bool_t allowed_to_read = kFALSE;
2664
2665
2666
2667
2668
2669
2670
2671 if (FileNameLong == fCurrentlyOpenFileName) {
2672 allowed_to_read = kTRUE;
2673 } else {
2674 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2675 CloseRootFile(current_file_name);
2676 }
2677 ok_open = OpenRootFile(file_name, "READ");
2678
2679 if (ok_open) {
2680 allowed_to_read = kTRUE;
2681 } else {
2682 std::cout << "!TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed "
2683 "for file: "
2684 << file_name << fTTBELL << std::endl;
2685 allowed_to_read = kFALSE;
2686 }
2687 }
2688
2689 if (allowed_to_read == kTRUE) {
2690 Int_t i_zero = 0;
2691 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2692
2693 if (ok_read == kTRUE) {
2694 fDataExist = kTRUE;
2695 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2696 vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
2697 }
2698 } else {
2699 fDataExist = kFALSE;
2700 std::cout << "!TEcnaRead::ReadAverageMeanCorrelationsBetweenSamples(...) *** ERROR ***> "
2701 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2702 << " -> quantity: <"
2703 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2704 }
2705 CloseRootFile(file_name);
2706 }
2707 return vec;
2708 }
2709
2710
2711
2712
2713
2714
2715 TVectorD TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(const Int_t &VecDim) {
2716
2717
2718
2719
2720
2721
2722 TestArrayDimH1(
2723 "ReadAverageSigmaOfCorrelationsBetweenSamples", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), VecDim);
2724
2725 TVectorD vec(VecDim);
2726 for (Int_t i = 0; i < VecDim; i++) {
2727 vec(i) = (Double_t)0.;
2728 }
2729
2730 CnaResultTyp typ = cTypAvSigCorss;
2731 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2732 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2733
2734 Bool_t ok_open = kFALSE;
2735 Bool_t ok_read = kFALSE;
2736
2737 TString FileNameLong = fCnaWrite->GetRootFileName();
2738 Bool_t allowed_to_read = kFALSE;
2739
2740
2741
2742
2743
2744
2745
2746 if (FileNameLong == fCurrentlyOpenFileName) {
2747 allowed_to_read = kTRUE;
2748 } else {
2749 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2750 CloseRootFile(current_file_name);
2751 }
2752 ok_open = OpenRootFile(file_name, "READ");
2753
2754 if (ok_open) {
2755 allowed_to_read = kTRUE;
2756 } else {
2757 std::cout << "!TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file "
2758 "failed for file: "
2759 << file_name << fTTBELL << std::endl;
2760 allowed_to_read = kFALSE;
2761 }
2762 }
2763
2764 if (allowed_to_read == kTRUE) {
2765 Int_t i_zero = 0;
2766 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
2767
2768 if (ok_read == kTRUE) {
2769 fDataExist = kTRUE;
2770 for (Int_t i0StexStin = 0; i0StexStin < VecDim; i0StexStin++) {
2771 vec(i0StexStin) = gCnaRootFile->fCnaIndivResult->fMatHis(i_zero, i0StexStin);
2772 }
2773 } else {
2774 fDataExist = kFALSE;
2775 std::cout << "!TEcnaRead::ReadAverageSigmaOfCorrelationsBetweenSamples(...) *** ERROR ***> "
2776 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2777 << " -> quantity: <"
2778 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2779 }
2780 CloseRootFile(file_name);
2781 }
2782 return vec;
2783 }
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795 TMatrixD TEcnaRead::ReadCovariancesBetweenSamples(const Int_t &n1StexStin,
2796 const Int_t &i0StinEcha,
2797 const Int_t &MatDim) {
2798
2799
2800
2801
2802
2803 TestArrayDimH2("ReadCovariancesBetweenSamples", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, MatDim);
2804
2805 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
2806
2807 TMatrixD mat(MatDim, MatDim);
2808 for (Int_t i = 0; i - MatDim < 0; i++) {
2809 for (Int_t j = 0; j - MatDim < 0; j++) {
2810 mat(i, j) = (Double_t)0.;
2811 }
2812 }
2813
2814 CnaResultTyp typ = cTypCovCss;
2815
2816 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2817 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2818
2819 Bool_t ok_open = kFALSE;
2820 Bool_t ok_read = kFALSE;
2821
2822 TString FileNameLong = fCnaWrite->GetRootFileName();
2823 Bool_t allowed_to_read = kFALSE;
2824
2825
2826
2827
2828
2829
2830
2831 if (FileNameLong == fCurrentlyOpenFileName) {
2832 allowed_to_read = kTRUE;
2833 } else {
2834 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2835 CloseRootFile(current_file_name);
2836 }
2837 ok_open = OpenRootFile(file_name, "READ");
2838
2839 if (ok_open) {
2840 allowed_to_read = kTRUE;
2841 } else {
2842 std::cout << "!TEcnaRead::ReadCovariancesBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
2843 << file_name << fTTBELL << std::endl;
2844 allowed_to_read = kFALSE;
2845 }
2846 }
2847
2848 if (allowed_to_read == kTRUE) {
2849 ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
2850
2851 if (ok_read == kTRUE) {
2852 fDataExist = kTRUE;
2853 for (Int_t i_samp = 0; i_samp - MatDim < 0; i_samp++) {
2854 for (Int_t j_samp = 0; j_samp - MatDim < 0; j_samp++) {
2855 mat(i_samp, j_samp) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp, j_samp);
2856 }
2857 }
2858 } else {
2859 fDataExist = kFALSE;
2860 std::cout << "!TEcnaRead::ReadCovariancesBetweenSamples() *** ERROR ***> " << fCnaWrite->fRootFileNameShort.Data()
2861 << ": .root file failed" << std::endl
2862 << " -> quantity: <" << GetTypeOfQuantity(typ)
2863 << "> not available in file." << fTTBELL << std::endl;
2864 }
2865 CloseRootFile(file_name);
2866 }
2867 return mat;
2868 }
2869
2870
2871
2872
2873
2874
2875 TMatrixD TEcnaRead::ReadCorrelationsBetweenSamples(const Int_t &n1StexStin,
2876 const Int_t &i0StinEcha,
2877 const Int_t &MatDim) {
2878
2879
2880
2881
2882
2883 TestArrayDimH2("ReadCorrelationsBetweenSamples", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, MatDim);
2884
2885 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
2886 TMatrixD mat(MatDim, MatDim);
2887 for (Int_t i = 0; i - MatDim < 0; i++) {
2888 for (Int_t j = 0; j - MatDim < 0; j++) {
2889 mat(i, j) = (Double_t)0.;
2890 }
2891 }
2892
2893 CnaResultTyp typ = cTypCorCss;
2894 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2895 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2896
2897 Bool_t ok_open = kFALSE;
2898 Bool_t ok_read = kFALSE;
2899
2900 TString FileNameLong = fCnaWrite->GetRootFileName();
2901 Bool_t allowed_to_read = kFALSE;
2902
2903
2904
2905
2906
2907
2908
2909 if (FileNameLong == fCurrentlyOpenFileName) {
2910 allowed_to_read = kTRUE;
2911 } else {
2912 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2913 CloseRootFile(current_file_name);
2914 }
2915 ok_open = OpenRootFile(file_name, "READ");
2916
2917 if (ok_open) {
2918 allowed_to_read = kTRUE;
2919 } else {
2920 std::cout << "!TEcnaRead::ReadCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
2921 << file_name << fTTBELL << std::endl;
2922 allowed_to_read = kFALSE;
2923 }
2924 }
2925
2926 if (allowed_to_read == kTRUE) {
2927 ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
2928
2929 if (ok_read == kTRUE) {
2930 fDataExist = kTRUE;
2931 for (Int_t i_samp = 0; i_samp - MatDim < 0; i_samp++) {
2932 for (Int_t j_samp = 0; j_samp - MatDim < 0; j_samp++) {
2933 mat(i_samp, j_samp) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp, j_samp);
2934 }
2935 }
2936 } else {
2937 fDataExist = kFALSE;
2938 std::cout << "!TEcnaRead::ReadCorrelationsBetweenSamples() *** ERROR ***> "
2939 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
2940 << " -> quantity: <"
2941 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
2942 }
2943 CloseRootFile(file_name);
2944 }
2945 return mat;
2946 }
2947
2948
2949
2950
2951
2952 TVectorD TEcnaRead::ReadRelevantCorrelationsBetweenSamples(const Int_t &n1StexStin,
2953 const Int_t &i0StinEcha,
2954 const Int_t &InPutMatDim) {
2955
2956
2957
2958
2959
2960
2961
2962 TestArrayDimH2(
2963 "ReadRelevantCorrelationsBetweenSamples", "fFileHeader->fNbOfSamples", fFileHeader->fNbOfSamples, InPutMatDim);
2964
2965 Int_t i0StexEcha = fEcalNumbering->Get0StexEchaFrom1StexStinAnd0StinEcha(n1StexStin, i0StinEcha);
2966 Int_t nb_of_relevant = InPutMatDim * (InPutMatDim - 1) / 2;
2967 TVectorD vec_rel(nb_of_relevant);
2968 for (Int_t i = 0; i < nb_of_relevant; i++) {
2969 vec_rel(i) = (Double_t)0.;
2970 }
2971 CnaResultTyp typ = cTypCorCss;
2972 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
2973 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
2974
2975 Bool_t ok_open = kFALSE;
2976 Bool_t ok_read = kFALSE;
2977
2978 TString FileNameLong = fCnaWrite->GetRootFileName();
2979 Bool_t allowed_to_read = kFALSE;
2980
2981
2982
2983
2984
2985
2986
2987 if (FileNameLong == fCurrentlyOpenFileName) {
2988 allowed_to_read = kTRUE;
2989 } else {
2990 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
2991 CloseRootFile(current_file_name);
2992 }
2993 ok_open = OpenRootFile(file_name, "READ");
2994
2995 if (ok_open) {
2996 allowed_to_read = kTRUE;
2997 } else {
2998 std::cout
2999 << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples(...) *** ERROR ***> Open .root file failed for file: "
3000 << file_name << fTTBELL << std::endl;
3001 allowed_to_read = kFALSE;
3002 }
3003 }
3004
3005 if (allowed_to_read == kTRUE) {
3006 ok_read = gCnaRootFile->ReadElement(typ, i0StexEcha);
3007
3008 if (ok_read == kTRUE) {
3009 fDataExist = kTRUE;
3010 Int_t k_cor = 0;
3011 for (Int_t i_samp = 0; i_samp < InPutMatDim; i_samp++) {
3012 for (Int_t j_samp = 0; j_samp < i_samp; j_samp++) {
3013 vec_rel(k_cor) = gCnaRootFile->fCnaIndivResult->fMatMat(i_samp, j_samp);
3014 k_cor++;
3015 }
3016 }
3017 } else {
3018 fDataExist = kFALSE;
3019 std::cout << "!TEcnaRead::ReadRelevantCorrelationsBetweenSamples() *** ERROR ***> "
3020 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3021 << " -> quantity: <"
3022 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3023 }
3024 CloseRootFile(file_name);
3025 }
3026 return vec_rel;
3027 }
3028
3029
3030
3031
3032
3033
3034
3035 TMatrixD TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(const Int_t &n1StexStin_a,
3036 const Int_t &n1StexStin_b,
3037 const Int_t &MatDim) {
3038
3039
3040
3041
3042
3043 TestArrayDimH2(
3044 "ReadLowFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysInStin()", fEcal->MaxCrysInStin(), MatDim);
3045
3046 Int_t index_Stin_a = GetStinIndex(n1StexStin_a);
3047 Int_t index_Stin_b = GetStinIndex(n1StexStin_b);
3048
3049 TMatrixD mat(MatDim, MatDim);
3050 for (Int_t i = 0; i - MatDim < 0; i++) {
3051 for (Int_t j = 0; j - MatDim < 0; j++) {
3052 mat(i, j) = (Double_t)0.;
3053 }
3054 }
3055
3056 CnaResultTyp typ = cTypLfCov;
3057
3058 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3059 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3060
3061 Bool_t ok_open = kFALSE;
3062 Bool_t ok_read = kFALSE;
3063
3064 TString FileNameLong = fCnaWrite->GetRootFileName();
3065 Bool_t allowed_to_read = kFALSE;
3066
3067
3068
3069
3070
3071
3072
3073 if (FileNameLong == fCurrentlyOpenFileName) {
3074 allowed_to_read = kTRUE;
3075 } else {
3076 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3077 CloseRootFile(current_file_name);
3078 }
3079 ok_open = OpenRootFile(file_name, "READ");
3080
3081 if (ok_open) {
3082 allowed_to_read = kTRUE;
3083 } else {
3084 std::cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed "
3085 "for file: "
3086 << file_name << fTTBELL << std::endl;
3087 allowed_to_read = kFALSE;
3088 }
3089 }
3090
3091 if (allowed_to_read == kTRUE) {
3092 Int_t i_zero = 0;
3093 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3094
3095 if (ok_read == kTRUE) {
3096 fDataExist = kTRUE;
3097 for (Int_t i_crys = 0; i_crys - MatDim < 0; i_crys++) {
3098 Int_t i_cna_chan = index_Stin_a * MatDim + i_crys;
3099 for (Int_t j_crys = 0; j_crys - MatDim < 0; j_crys++) {
3100 Int_t j_cna_chan = index_Stin_b * MatDim + j_crys;
3101 mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3102 }
3103 }
3104 } else {
3105 fDataExist = kFALSE;
3106 std::cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> "
3107 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3108 << " -> quantity: <"
3109 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3110 }
3111 CloseRootFile(file_name);
3112 }
3113 return mat;
3114 }
3115
3116
3117
3118
3119
3120
3121
3122 TMatrixD TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(const Int_t &n1StexStin_a,
3123 const Int_t &n1StexStin_b,
3124 const Int_t &MatDim) {
3125
3126
3127
3128
3129
3130 TestArrayDimH2(
3131 "ReadLowFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysInStin()", fEcal->MaxCrysInStin(), MatDim);
3132
3133 Int_t index_Stin_a = GetStinIndex(n1StexStin_a);
3134 Int_t index_Stin_b = GetStinIndex(n1StexStin_b);
3135
3136 TMatrixD mat(MatDim, MatDim);
3137 for (Int_t i = 0; i - MatDim < 0; i++) {
3138 for (Int_t j = 0; j - MatDim < 0; j++) {
3139 mat(i, j) = (Double_t)0.;
3140 }
3141 }
3142
3143 CnaResultTyp typ = cTypLfCor;
3144
3145 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3146 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3147
3148 Bool_t ok_open = kFALSE;
3149 Bool_t ok_read = kFALSE;
3150
3151 TString FileNameLong = fCnaWrite->GetRootFileName();
3152 Bool_t allowed_to_read = kFALSE;
3153
3154
3155
3156
3157
3158
3159
3160 if (FileNameLong == fCurrentlyOpenFileName) {
3161 allowed_to_read = kTRUE;
3162 } else {
3163 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3164 CloseRootFile(current_file_name);
3165 }
3166 ok_open = OpenRootFile(file_name, "READ");
3167
3168 if (ok_open) {
3169 allowed_to_read = kTRUE;
3170 } else {
3171 std::cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file failed "
3172 "for file: "
3173 << file_name << fTTBELL << std::endl;
3174 allowed_to_read = kFALSE;
3175 }
3176 }
3177
3178 if (allowed_to_read == kTRUE) {
3179 Int_t i_zero = 0;
3180
3181 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3182
3183 if (ok_read == kTRUE) {
3184 fDataExist = kTRUE;
3185 for (Int_t i_crys = 0; i_crys - MatDim < 0; i_crys++) {
3186 Int_t i_cna_chan = index_Stin_a * MatDim + i_crys;
3187 for (Int_t j_crys = 0; j_crys - MatDim < 0; j_crys++) {
3188 Int_t j_cna_chan = index_Stin_b * MatDim + j_crys;
3189 mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3190 }
3191 }
3192 } else {
3193 fDataExist = kFALSE;
3194 std::cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> "
3195 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3196 << " -> quantity: <"
3197 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3198 }
3199 CloseRootFile(file_name);
3200 }
3201 return mat;
3202 }
3203
3204
3205
3206
3207
3208
3209
3210 TMatrixD TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(const Int_t &n1StexStin_a,
3211 const Int_t &n1StexStin_b,
3212 const Int_t &MatDim) {
3213
3214
3215
3216
3217
3218 TestArrayDimH2(
3219 "ReadHighFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysInStin()", fEcal->MaxCrysInStin(), MatDim);
3220
3221 Int_t index_Stin_a = GetStinIndex(n1StexStin_a);
3222 Int_t index_Stin_b = GetStinIndex(n1StexStin_b);
3223
3224 TMatrixD mat(MatDim, MatDim);
3225 for (Int_t i = 0; i - MatDim < 0; i++) {
3226 for (Int_t j = 0; j - MatDim < 0; j++) {
3227 mat(i, j) = (Double_t)0.;
3228 }
3229 }
3230
3231 CnaResultTyp typ = cTypHfCov;
3232
3233 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3234 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3235
3236 Bool_t ok_open = kFALSE;
3237 Bool_t ok_read = kFALSE;
3238
3239 TString FileNameLong = fCnaWrite->GetRootFileName();
3240 Bool_t allowed_to_read = kFALSE;
3241
3242
3243
3244
3245
3246
3247
3248 if (FileNameLong == fCurrentlyOpenFileName) {
3249 allowed_to_read = kTRUE;
3250 } else {
3251 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3252 CloseRootFile(current_file_name);
3253 }
3254 ok_open = OpenRootFile(file_name, "READ");
3255
3256 if (ok_open) {
3257 allowed_to_read = kTRUE;
3258 } else {
3259 std::cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed "
3260 "for file: "
3261 << file_name << fTTBELL << std::endl;
3262 allowed_to_read = kFALSE;
3263 }
3264 }
3265
3266 if (allowed_to_read == kTRUE) {
3267 Int_t i_zero = 0;
3268 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3269
3270 if (ok_read == kTRUE) {
3271 fDataExist = kTRUE;
3272 for (Int_t i_crys = 0; i_crys - MatDim < 0; i_crys++) {
3273 Int_t i_cna_chan = index_Stin_a * MatDim + i_crys;
3274 for (Int_t j_crys = 0; j_crys - MatDim < 0; j_crys++) {
3275 Int_t j_cna_chan = index_Stin_b * MatDim + j_crys;
3276 mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3277 }
3278 }
3279 } else {
3280 fDataExist = kFALSE;
3281 std::cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> "
3282 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3283 << " -> quantity: <"
3284 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3285 }
3286 CloseRootFile(file_name);
3287 }
3288 return mat;
3289 }
3290
3291
3292
3293
3294
3295
3296
3297 TMatrixD TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(const Int_t &n1StexStin_a,
3298 const Int_t &n1StexStin_b,
3299 const Int_t &MatDim) {
3300
3301
3302
3303
3304
3305 TestArrayDimH2(
3306 "ReadHighFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysInStin()", fEcal->MaxCrysInStin(), MatDim);
3307
3308 Int_t index_Stin_a = GetStinIndex(n1StexStin_a);
3309 Int_t index_Stin_b = GetStinIndex(n1StexStin_b);
3310
3311 TMatrixD mat(MatDim, MatDim);
3312 for (Int_t i = 0; i - MatDim < 0; i++) {
3313 for (Int_t j = 0; j - MatDim < 0; j++) {
3314 mat(i, j) = (Double_t)0.;
3315 }
3316 }
3317
3318 CnaResultTyp typ = cTypHfCor;
3319
3320 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3321 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3322
3323 Bool_t ok_open = kFALSE;
3324 Bool_t ok_read = kFALSE;
3325
3326 TString FileNameLong = fCnaWrite->GetRootFileName();
3327 Bool_t allowed_to_read = kFALSE;
3328
3329
3330
3331
3332
3333
3334
3335 if (FileNameLong == fCurrentlyOpenFileName) {
3336 allowed_to_read = kTRUE;
3337 } else {
3338 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3339 CloseRootFile(current_file_name);
3340 }
3341 ok_open = OpenRootFile(file_name, "READ");
3342
3343 if (ok_open) {
3344 allowed_to_read = kTRUE;
3345 } else {
3346 std::cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file "
3347 "failed for file: "
3348 << file_name << fTTBELL << std::endl;
3349 allowed_to_read = kFALSE;
3350 }
3351 }
3352
3353 if (allowed_to_read == kTRUE) {
3354 Int_t i_zero = 0;
3355
3356 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3357
3358 if (ok_read == kTRUE) {
3359 fDataExist = kTRUE;
3360 for (Int_t i_crys = 0; i_crys - MatDim < 0; i_crys++) {
3361 Int_t i_cna_chan = index_Stin_a * MatDim + i_crys;
3362 for (Int_t j_crys = 0; j_crys - MatDim < 0; j_crys++) {
3363 Int_t j_cna_chan = index_Stin_b * MatDim + j_crys;
3364 mat(i_crys, j_crys) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3365 }
3366 }
3367 } else {
3368 fDataExist = kFALSE;
3369 std::cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> "
3370 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3371 << " -> quantity: <"
3372 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3373 }
3374 CloseRootFile(file_name);
3375 }
3376 return mat;
3377 }
3378
3379
3380
3381
3382
3383
3384
3385 TMatrixD TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(const Int_t &MatDim) {
3386
3387
3388
3389
3390
3391 TestArrayDimH2(
3392 "ReadLowFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), MatDim);
3393
3394
3395 TMatrixD mat(MatDim, MatDim);
3396 for (Int_t i = 0; i - MatDim < 0; i++) {
3397 for (Int_t j = 0; j - MatDim < 0; j++) {
3398 mat(i, j) = (Double_t)0.;
3399 }
3400 }
3401
3402 TVectorD vec(fEcal->MaxStinEcnaInStex());
3403 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
3404 vec(i) = (Double_t)0.;
3405 }
3406 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
3407
3408 CnaResultTyp typ = cTypLfCov;
3409
3410 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3411 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3412
3413 Bool_t ok_open = kFALSE;
3414 Bool_t ok_read = kFALSE;
3415
3416 TString FileNameLong = fCnaWrite->GetRootFileName();
3417 Bool_t allowed_to_read = kFALSE;
3418
3419
3420
3421
3422
3423
3424
3425 if (FileNameLong == fCurrentlyOpenFileName) {
3426 allowed_to_read = kTRUE;
3427 } else {
3428 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3429 CloseRootFile(current_file_name);
3430 }
3431 ok_open = OpenRootFile(file_name, "READ");
3432
3433 if (ok_open) {
3434 allowed_to_read = kTRUE;
3435 } else {
3436 std::cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed "
3437 "for file: "
3438 << file_name << fTTBELL << std::endl;
3439 allowed_to_read = kFALSE;
3440 }
3441 }
3442
3443 if (allowed_to_read == kTRUE) {
3444 Int_t i_zero = 0;
3445 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3446
3447 if (ok_read == kTRUE) {
3448 fDataExist = kTRUE;
3449 for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++) {
3450 if (vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex()) {
3451 for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++) {
3452 if (vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex()) {
3453 for (Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++) {
3454 Int_t i_cna_chan = index_Stin_a * fEcal->MaxCrysInStin() + i_crys;
3455 Int_t i_chan_sm = (Int_t)(vec(index_Stin_a) - 1) * fEcal->MaxCrysInStin() + i_crys;
3456 for (Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++) {
3457 Int_t j_cna_chan = index_Stin_b * fEcal->MaxCrysInStin() + j_crys;
3458 Int_t j_chan_sm = (Int_t)(vec(index_Stin_b) - 1) * fEcal->MaxCrysInStin() + j_crys;
3459 mat(i_chan_sm, j_chan_sm) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3460 }
3461 }
3462 }
3463 }
3464 }
3465 }
3466 } else {
3467 fDataExist = kFALSE;
3468 std::cout << "!TEcnaRead::ReadLowFrequencyCovariancesBetweenChannels() *** ERROR ***> "
3469 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3470 << " -> quantity: <"
3471 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3472 }
3473 CloseRootFile(file_name);
3474 }
3475 return mat;
3476 }
3477
3478
3479
3480
3481
3482
3483
3484 TMatrixD TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(const Int_t &MatDim) {
3485
3486
3487
3488
3489
3490 TestArrayDimH2(
3491 "ReadLowFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), MatDim);
3492
3493
3494 TMatrixD mat(MatDim, MatDim);
3495 for (Int_t i = 0; i - MatDim < 0; i++) {
3496 for (Int_t j = 0; j - MatDim < 0; j++) {
3497 mat(i, j) = (Double_t)0.;
3498 }
3499 }
3500
3501 TVectorD vec(fEcal->MaxStinEcnaInStex());
3502 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
3503 vec(i) = (Double_t)0.;
3504 }
3505 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
3506
3507 CnaResultTyp typ = cTypLfCor;
3508
3509 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3510 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3511
3512 Bool_t ok_open = kFALSE;
3513 Bool_t ok_read = kFALSE;
3514
3515 TString FileNameLong = fCnaWrite->GetRootFileName();
3516 Bool_t allowed_to_read = kFALSE;
3517
3518
3519
3520
3521
3522
3523
3524 if (FileNameLong == fCurrentlyOpenFileName) {
3525 allowed_to_read = kTRUE;
3526 } else {
3527 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3528 CloseRootFile(current_file_name);
3529 }
3530 ok_open = OpenRootFile(file_name, "READ");
3531
3532 if (ok_open) {
3533 allowed_to_read = kTRUE;
3534 } else {
3535 std::cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file failed "
3536 "for file: "
3537 << file_name << fTTBELL << std::endl;
3538 allowed_to_read = kFALSE;
3539 }
3540 }
3541
3542 if (allowed_to_read == kTRUE) {
3543 Int_t i_zero = 0;
3544 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3545
3546 if (ok_read == kTRUE) {
3547 fDataExist = kTRUE;
3548 for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++) {
3549 if (vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex()) {
3550 for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++) {
3551 if (vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex()) {
3552 for (Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++) {
3553 Int_t i_cna_chan = index_Stin_a * fEcal->MaxCrysInStin() + i_crys;
3554 Int_t i_chan_sm = (Int_t)(vec(index_Stin_a) - 1) * fEcal->MaxCrysInStin() + i_crys;
3555 for (Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++) {
3556 Int_t j_cna_chan = index_Stin_b * fEcal->MaxCrysInStin() + j_crys;
3557 Int_t j_chan_sm = (Int_t)(vec(index_Stin_b) - 1) * fEcal->MaxCrysInStin() + j_crys;
3558 mat(i_chan_sm, j_chan_sm) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3559 }
3560 }
3561 }
3562 }
3563 }
3564 }
3565 } else {
3566 fDataExist = kFALSE;
3567 std::cout << "!TEcnaRead::ReadLowFrequencyCorrelationsBetweenChannels() *** ERROR ***> "
3568 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3569 << " -> quantity: <"
3570 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3571 }
3572 CloseRootFile(file_name);
3573 }
3574 return mat;
3575 }
3576
3577
3578
3579
3580
3581
3582
3583 TMatrixD TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(const Int_t &MatDim) {
3584
3585
3586
3587
3588
3589 TestArrayDimH2(
3590 "ReadHighFrequencyCovariancesBetweenChannels", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), MatDim);
3591
3592
3593 TMatrixD mat(MatDim, MatDim);
3594 for (Int_t i = 0; i - MatDim < 0; i++) {
3595 for (Int_t j = 0; j - MatDim < 0; j++) {
3596 mat(i, j) = (Double_t)0.;
3597 }
3598 }
3599
3600 TVectorD vec(fEcal->MaxStinEcnaInStex());
3601 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
3602 vec(i) = (Double_t)0.;
3603 }
3604 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
3605
3606 CnaResultTyp typ = cTypHfCov;
3607
3608 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3609 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3610
3611 Bool_t ok_open = kFALSE;
3612 Bool_t ok_read = kFALSE;
3613
3614 TString FileNameLong = fCnaWrite->GetRootFileName();
3615 Bool_t allowed_to_read = kFALSE;
3616
3617
3618
3619
3620
3621
3622
3623 if (FileNameLong == fCurrentlyOpenFileName) {
3624 allowed_to_read = kTRUE;
3625 } else {
3626 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3627 CloseRootFile(current_file_name);
3628 }
3629 ok_open = OpenRootFile(file_name, "READ");
3630
3631 if (ok_open) {
3632 allowed_to_read = kTRUE;
3633 } else {
3634 std::cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels(...) *** ERROR ***> Open .root file failed "
3635 "for file: "
3636 << file_name << fTTBELL << std::endl;
3637 allowed_to_read = kFALSE;
3638 }
3639 }
3640
3641 if (allowed_to_read == kTRUE) {
3642 Int_t i_zero = 0;
3643 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3644
3645 if (ok_read == kTRUE) {
3646 fDataExist = kTRUE;
3647 for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++) {
3648 if (vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex()) {
3649 for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++) {
3650 if (vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex()) {
3651 for (Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++) {
3652 Int_t i_cna_chan = index_Stin_a * fEcal->MaxCrysInStin() + i_crys;
3653 Int_t i_chan_sm = (Int_t)(vec(index_Stin_a) - 1) * fEcal->MaxCrysInStin() + i_crys;
3654 for (Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++) {
3655 Int_t j_cna_chan = index_Stin_b * fEcal->MaxCrysInStin() + j_crys;
3656 Int_t j_chan_sm = (Int_t)(vec(index_Stin_b) - 1) * fEcal->MaxCrysInStin() + j_crys;
3657 mat(i_chan_sm, j_chan_sm) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3658 }
3659 }
3660 }
3661 }
3662 }
3663 }
3664 } else {
3665 fDataExist = kFALSE;
3666 std::cout << "!TEcnaRead::ReadHighFrequencyCovariancesBetweenChannels() *** ERROR ***> "
3667 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3668 << " -> quantity: <"
3669 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3670 }
3671 CloseRootFile(file_name);
3672 }
3673 return mat;
3674 }
3675
3676
3677
3678
3679
3680
3681
3682 TMatrixD TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(const Int_t &MatDim) {
3683
3684
3685
3686
3687
3688 TestArrayDimH2(
3689 "ReadHighFrequencyCorrelationsBetweenChannels", "fEcal->MaxCrysEcnaInStex()", fEcal->MaxCrysEcnaInStex(), MatDim);
3690
3691
3692 TMatrixD mat(MatDim, MatDim);
3693 for (Int_t i = 0; i - MatDim < 0; i++) {
3694 for (Int_t j = 0; j - MatDim < 0; j++) {
3695 mat(i, j) = (Double_t)0.;
3696 }
3697 }
3698
3699 TVectorD vec(fEcal->MaxStinEcnaInStex());
3700 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
3701 vec(i) = (Double_t)0.;
3702 }
3703 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
3704
3705 CnaResultTyp typ = cTypHfCor;
3706
3707 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3708 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3709
3710 Bool_t ok_open = kFALSE;
3711 Bool_t ok_read = kFALSE;
3712
3713 TString FileNameLong = fCnaWrite->GetRootFileName();
3714 Bool_t allowed_to_read = kFALSE;
3715
3716
3717
3718
3719
3720
3721
3722 if (FileNameLong == fCurrentlyOpenFileName) {
3723 allowed_to_read = kTRUE;
3724 } else {
3725 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3726 CloseRootFile(current_file_name);
3727 }
3728 ok_open = OpenRootFile(file_name, "READ");
3729
3730 if (ok_open) {
3731 allowed_to_read = kTRUE;
3732 } else {
3733 std::cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels(...) *** ERROR ***> Open .root file "
3734 "failed for file: "
3735 << file_name << fTTBELL << std::endl;
3736 allowed_to_read = kFALSE;
3737 }
3738 }
3739
3740 if (allowed_to_read == kTRUE) {
3741 Int_t i_zero = 0;
3742 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3743
3744 if (ok_read == kTRUE) {
3745 fDataExist = kTRUE;
3746 for (Int_t index_Stin_a = 0; index_Stin_a < fEcal->MaxStinEcnaInStex(); index_Stin_a++) {
3747 if (vec(index_Stin_a) > 0 && vec(index_Stin_a) <= fEcal->MaxStinEcnaInStex()) {
3748 for (Int_t index_Stin_b = 0; index_Stin_b < fEcal->MaxStinEcnaInStex(); index_Stin_b++) {
3749 if (vec(index_Stin_b) > 0 && vec(index_Stin_b) <= fEcal->MaxStinEcnaInStex()) {
3750 for (Int_t i_crys = 0; i_crys < fEcal->MaxCrysInStin(); i_crys++) {
3751 Int_t i_cna_chan = index_Stin_a * fEcal->MaxCrysInStin() + i_crys;
3752 Int_t i_chan_sm = (Int_t)(vec(index_Stin_a) - 1) * fEcal->MaxCrysInStin() + i_crys;
3753 for (Int_t j_crys = 0; j_crys < fEcal->MaxCrysInStin(); j_crys++) {
3754 Int_t j_cna_chan = index_Stin_b * fEcal->MaxCrysInStin() + j_crys;
3755 Int_t j_chan_sm = (Int_t)(vec(index_Stin_b) - 1) * fEcal->MaxCrysInStin() + j_crys;
3756 mat(i_chan_sm, j_chan_sm) = gCnaRootFile->fCnaIndivResult->fMatMat(i_cna_chan, j_cna_chan);
3757 }
3758 }
3759 }
3760 }
3761 }
3762 }
3763 } else {
3764 fDataExist = kFALSE;
3765 std::cout << "!TEcnaRead::ReadHighFrequencyCorrelationsBetweenChannels() *** ERROR ***> "
3766 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3767 << " -> quantity: <"
3768 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3769 }
3770 CloseRootFile(file_name);
3771 }
3772 return mat;
3773 }
3774
3775
3776
3777
3778
3779
3780
3781 TMatrixD TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins(const Int_t &MatDim) {
3782
3783
3784
3785
3786
3787 TestArrayDimH2(
3788 "ReadLowFrequencyMeanCorrelationsBetweenStins", "fEcal->MaxStinEcnaInStex()", fEcal->MaxStinEcnaInStex(), MatDim);
3789
3790 TMatrixD mat(MatDim, MatDim);
3791 for (Int_t i = 0; i - MatDim < 0; i++) {
3792 for (Int_t j = 0; j - MatDim < 0; j++) {
3793 mat(i, j) = (Double_t)0.;
3794 }
3795 }
3796
3797 TVectorD vec(fEcal->MaxStinEcnaInStex());
3798 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
3799 vec(i) = (Double_t)0.;
3800 }
3801 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
3802
3803 CnaResultTyp typ = cTypLFccMoStins;
3804
3805 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3806 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3807
3808 Bool_t ok_open = kFALSE;
3809 Bool_t ok_read = kFALSE;
3810
3811 TString FileNameLong = fCnaWrite->GetRootFileName();
3812 Bool_t allowed_to_read = kFALSE;
3813
3814
3815
3816
3817
3818
3819
3820 if (FileNameLong == fCurrentlyOpenFileName) {
3821 allowed_to_read = kTRUE;
3822 } else {
3823 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3824 CloseRootFile(current_file_name);
3825 }
3826 ok_open = OpenRootFile(file_name, "READ");
3827
3828 if (ok_open) {
3829 allowed_to_read = kTRUE;
3830 } else {
3831 std::cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins(...) *** ERROR ***> Open .root file "
3832 "failed for file: "
3833 << file_name << fTTBELL << std::endl;
3834 allowed_to_read = kFALSE;
3835 }
3836 }
3837
3838 if (allowed_to_read == kTRUE) {
3839 Int_t i_zero = 0;
3840 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3841
3842 if (ok_read == kTRUE) {
3843 fDataExist = kTRUE;
3844 for (Int_t index_Stin_a = 0; index_Stin_a - MatDim < 0; index_Stin_a++) {
3845 for (Int_t index_Stin_b = 0; index_Stin_b - MatDim < 0; index_Stin_b++) {
3846 if (vec(index_Stin_a) > 0 && vec(index_Stin_a) <= MatDim) {
3847 if (vec(index_Stin_b) > 0 && vec(index_Stin_b) <= MatDim) {
3848 Int_t vec_ia_m = (Int_t)vec(index_Stin_a) - 1;
3849 Int_t vec_ib_m = (Int_t)vec(index_Stin_b) - 1;
3850 mat((Int_t)vec_ia_m, vec_ib_m) = gCnaRootFile->fCnaIndivResult->fMatMat(index_Stin_a, index_Stin_b);
3851 }
3852 }
3853 }
3854 }
3855 } else {
3856 fDataExist = kFALSE;
3857 std::cout << "!TEcnaRead::ReadLowFrequencyMeanCorrelationsBetweenStins() *** ERROR ***> "
3858 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3859 << " -> quantity: <"
3860 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3861 }
3862 CloseRootFile(file_name);
3863 }
3864 return mat;
3865 }
3866
3867
3868
3869
3870
3871
3872
3873 TMatrixD TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins(const Int_t &MatDim) {
3874
3875
3876
3877
3878
3879 TestArrayDimH2("ReadHighFrequencyMeanCorrelationsBetweenStins",
3880 "fEcal->MaxStinEcnaInStex()",
3881 fEcal->MaxStinEcnaInStex(),
3882 MatDim);
3883
3884 TMatrixD mat(MatDim, MatDim);
3885 for (Int_t i = 0; i - MatDim < 0; i++) {
3886 for (Int_t j = 0; j - MatDim < 0; j++) {
3887 mat(i, j) = (Double_t)0.;
3888 }
3889 }
3890
3891 TVectorD vec(fEcal->MaxStinEcnaInStex());
3892 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
3893 vec(i) = (Double_t)0.;
3894 }
3895 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
3896
3897 CnaResultTyp typ = cTypHFccMoStins;
3898
3899 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
3900 const Text_t *current_file_name = (const Text_t *)fCurrentlyOpenFileName.Data();
3901
3902 Bool_t ok_open = kFALSE;
3903 Bool_t ok_read = kFALSE;
3904
3905 TString FileNameLong = fCnaWrite->GetRootFileName();
3906 Bool_t allowed_to_read = kFALSE;
3907
3908
3909
3910
3911
3912
3913
3914 if (FileNameLong == fCurrentlyOpenFileName) {
3915 allowed_to_read = kTRUE;
3916 } else {
3917 if (fCurrentlyOpenFileName != fFlagNoFileOpen) {
3918 CloseRootFile(current_file_name);
3919 }
3920 ok_open = OpenRootFile(file_name, "READ");
3921
3922 if (ok_open) {
3923 allowed_to_read = kTRUE;
3924 } else {
3925 std::cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins(...) *** ERROR ***> Open .root file "
3926 "failed for file: "
3927 << file_name << fTTBELL << std::endl;
3928 allowed_to_read = kFALSE;
3929 }
3930 }
3931
3932 if (allowed_to_read == kTRUE) {
3933 Int_t i_zero = 0;
3934 ok_read = gCnaRootFile->ReadElement(typ, i_zero);
3935
3936 if (ok_read == kTRUE) {
3937 fDataExist = kTRUE;
3938 for (Int_t index_Stin_a = 0; index_Stin_a - MatDim < 0; index_Stin_a++) {
3939 for (Int_t index_Stin_b = 0; index_Stin_b - MatDim < 0; index_Stin_b++) {
3940 if (vec(index_Stin_a) > 0 && vec(index_Stin_a) <= MatDim) {
3941 if (vec(index_Stin_b) > 0 && vec(index_Stin_b) <= MatDim) {
3942 Int_t vec_ia_m = (Int_t)vec(index_Stin_a) - 1;
3943 Int_t vec_ib_m = (Int_t)vec(index_Stin_b) - 1;
3944 mat((Int_t)vec_ia_m, (Int_t)vec_ib_m) =
3945 gCnaRootFile->fCnaIndivResult->fMatMat(index_Stin_a, index_Stin_b);
3946 }
3947 }
3948 }
3949 }
3950 } else {
3951 fDataExist = kFALSE;
3952 std::cout << "!TEcnaRead::ReadHighFrequencyMeanCorrelationsBetweenStins() *** ERROR ***> "
3953 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
3954 << " -> quantity: <"
3955 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
3956 }
3957 CloseRootFile(file_name);
3958 }
3959 return mat;
3960 }
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975 Double_t ***TEcnaRead::ReadSampleAdcValuesSameFile(const Int_t &DimX, const Int_t &DimY, const Int_t &DimZ) {
3976
3977
3978
3979
3980 if (fT3d_AdcValues == nullptr) {
3981
3982 fT3d_AdcValues = new Double_t **[DimX];
3983 fCnew++;
3984 fT3d2_AdcValues = new Double_t *[DimX * DimY];
3985 fCnew++;
3986 fT3d1_AdcValues = new Double_t[DimX * DimY * DimZ];
3987 fCnew++;
3988
3989 for (Int_t i0StexEcha = 0; i0StexEcha < DimX; i0StexEcha++) {
3990 fT3d_AdcValues[i0StexEcha] = &fT3d2_AdcValues[0] + i0StexEcha * DimY;
3991 for (Int_t j_samp = 0; j_samp < DimY; j_samp++) {
3992 fT3d2_AdcValues[DimY * i0StexEcha + j_samp] = &fT3d1_AdcValues[0] + DimZ * (DimY * i0StexEcha + j_samp);
3993 }
3994 }
3995 }
3996
3997
3998 for (Int_t iza = 0; iza < DimX; iza++) {
3999 for (Int_t izb = 0; izb < DimY; izb++) {
4000 for (Int_t izc = 0; izc < DimZ; izc++) {
4001 if (fT3d_AdcValues[iza][izb][izc] != (Double_t)0) {
4002 fT3d_AdcValues[iza][izb][izc] = (Double_t)0;
4003 }
4004 }
4005 }
4006 }
4007
4008
4009 CnaResultTyp typ = cTypAdcEvt;
4010
4011 const Text_t *file_name = (const Text_t *)fCnaWrite->fRootFileNameShort.Data();
4012
4013 Bool_t ok_open = kFALSE;
4014 Bool_t ok_read = kFALSE;
4015
4016 Int_t i_entry = 0;
4017 Int_t i_entry_fail = 0;
4018
4019 ok_open = OpenRootFile(file_name, "READ");
4020
4021 if (ok_open == kTRUE) {
4022 for (Int_t i0StexEcha = 0; i0StexEcha < DimX; i0StexEcha++) {
4023 if (i0StexEcha == 0) {
4024 i_entry = gCnaRootFile->ReadElementNextEntryNumber(typ, i0StexEcha);
4025 if (i_entry >= 0) {
4026 ok_read = kTRUE;
4027 }
4028 }
4029 if (i_entry >= 0)
4030 {
4031 if (i0StexEcha > 0) {
4032 ok_read = gCnaRootFile->ReadElement(i_entry);
4033 i_entry++;
4034 }
4035
4036 if (ok_read == kTRUE) {
4037 fDataExist = kTRUE;
4038 for (Int_t sample = 0; sample < DimY; sample++) {
4039 for (Int_t i_bin = 0; i_bin < DimZ; i_bin++) {
4040 fT3d_AdcValues[i0StexEcha][sample][i_bin] = gCnaRootFile->fCnaIndivResult->fMatHis(sample, i_bin);
4041 }
4042 }
4043 } else
4044 {
4045 fDataExist = kFALSE;
4046 std::cout << "!TEcnaRead::ReadSampleAdcValuesSameFile(...) *** ERROR ***> "
4047 << fCnaWrite->fRootFileNameShort.Data() << ": .root file failed" << std::endl
4048 << " -> quantity: <"
4049 << GetTypeOfQuantity(typ) << "> not available in file." << fTTBELL << std::endl;
4050 }
4051 } else {
4052 i_entry_fail++;
4053 }
4054 }
4055 CloseRootFile(file_name);
4056 } else {
4057 std::cout << "*TEcnaRead::ReadSampleAdcValuesSameFile(...)> *ERROR* =====> "
4058 << " ROOT file not found" << fTTBELL << std::endl;
4059 }
4060
4061 if (i_entry_fail > 0) {
4062 std::cout << "*TEcnaRead::ReadSampleAdcValuesSameFile(...)> *ERROR* =====> "
4063 << " Entry reading failure(s). i_entry_fail = " << i_entry_fail << fTTBELL << std::endl;
4064 }
4065 return fT3d_AdcValues;
4066 }
4067
4068
4069
4070
4071
4072
4073
4074 Int_t TEcnaRead::GetNumberOfEvents(const Int_t &xFapNbOfReqEvts, const Int_t &xStexNumber) {
4075
4076 Int_t xFapNbOfEvts = 0;
4077
4078 TVectorD NOFE_histp(fEcal->MaxCrysEcnaInStex());
4079 for (Int_t i = 0; i < fEcal->MaxCrysEcnaInStex(); i++) {
4080 NOFE_histp(i) = (Double_t)0.;
4081 }
4082 NOFE_histp = ReadNumberOfEvents(fEcal->MaxCrysEcnaInStex());
4083
4084
4085
4086 Int_t *NOFE_int = new Int_t[fEcal->MaxCrysEcnaInStex()];
4087 fCnew++;
4088 for (Int_t i = 0; i < fEcal->MaxCrysEcnaInStex(); i++) {
4089 NOFE_int[i] = (Int_t)NOFE_histp(i);
4090 }
4091
4092 xFapNbOfEvts = fCnaWrite->NumberOfEventsAnalysis(NOFE_int, fEcal->MaxCrysEcnaInStex(), xFapNbOfReqEvts, xStexNumber);
4093
4094 delete[] NOFE_int;
4095 NOFE_int = nullptr;
4096 fCdelete++;
4097
4098 return xFapNbOfEvts;
4099 }
4100
4101
4102
4103
4104
4105
4106 TString TEcnaRead::GetTypeOfQuantity(const CnaResultTyp arg_typ) {
4107 TString quantity_name = "?";
4108
4109 if (arg_typ == cTypNumbers) {
4110 if (fFlagSubDet == "EB") {
4111 quantity_name = "SM numbers";
4112 }
4113 if (fFlagSubDet == "EE") {
4114 quantity_name = "Dee numbers";
4115 }
4116 }
4117 if (arg_typ == cTypMSp) {
4118 quantity_name = "Mean samples";
4119 }
4120 if (arg_typ == cTypSSp) {
4121 quantity_name = "Sigma of samples";
4122 }
4123
4124 if (arg_typ == cTypNbOfEvts) {
4125 quantity_name = "Number of events";
4126 }
4127 if (arg_typ == cTypPed) {
4128 quantity_name = "Pedestals";
4129 }
4130 if (arg_typ == cTypTno) {
4131 quantity_name = "Total noise";
4132 }
4133 if (arg_typ == cTypLfn) {
4134 quantity_name = "LF noise";
4135 }
4136 if (arg_typ == cTypHfn) {
4137 quantity_name = "HF noise";
4138 }
4139 if (arg_typ == cTypMeanCorss) {
4140 quantity_name = "Mean cor(s,s')";
4141 }
4142 if (arg_typ == cTypSigCorss) {
4143 quantity_name = "Sigma of cor(s,s')";
4144 }
4145
4146 if (arg_typ == cTypAvPed) {
4147 quantity_name = "Average pedestals";
4148 }
4149 if (arg_typ == cTypAvTno) {
4150 quantity_name = "Average total noise";
4151 }
4152 if (arg_typ == cTypAvLfn) {
4153 quantity_name = "Average LF noise";
4154 }
4155 if (arg_typ == cTypAvHfn) {
4156 quantity_name = "Average HF noise";
4157 }
4158 if (arg_typ == cTypAvMeanCorss) {
4159 quantity_name = "Average mean cor(s,s')";
4160 }
4161 if (arg_typ == cTypAvSigCorss) {
4162 quantity_name = "Average sigma of cor(s,s')";
4163 }
4164
4165 if (arg_typ == cTypAdcEvt) {
4166 quantity_name = "Sample ADC a.f.o event number";
4167 }
4168
4169 if (arg_typ == cTypCovCss) {
4170 quantity_name = "Cov(s,s')";
4171 }
4172 if (arg_typ == cTypCorCss) {
4173 quantity_name = "Cor(s,s')";
4174 }
4175 if (arg_typ == cTypLfCov) {
4176 quantity_name = "LF Cov(c,c')";
4177 }
4178 if (arg_typ == cTypLfCor) {
4179 quantity_name = "LF Cor(c,c')";
4180 }
4181 if (arg_typ == cTypHfCov) {
4182 quantity_name = "HF Cov(c,c')";
4183 }
4184 if (arg_typ == cTypHfCor) {
4185 quantity_name = "HF Cor(c,c')";
4186 }
4187
4188 if (fFlagSubDet == "EB") {
4189 if (arg_typ == cTypLFccMoStins) {
4190 quantity_name = "Mean LF |Cor(c,c')| in (tow,tow')";
4191 }
4192 if (arg_typ == cTypHFccMoStins) {
4193 quantity_name = "Mean HF |Cor(c,c')| in (tow,tow')";
4194 }
4195 }
4196 if (fFlagSubDet == "EE") {
4197 if (arg_typ == cTypLFccMoStins) {
4198 quantity_name = "Mean LF |Cor(c,c')| in (SC,SC')";
4199 }
4200 if (arg_typ == cTypHFccMoStins) {
4201 quantity_name = "Mean HF |Cor(c,c')| in (SC,SC')";
4202 }
4203 }
4204 return quantity_name;
4205 }
4206
4207
4208
4209
4210
4211
4212 const TString &TEcnaRead::GetRootFileName() const { return fCnaWrite->GetRootFileName(); }
4213 const TString &TEcnaRead::GetRootFileNameShort() const { return fCnaWrite->GetRootFileNameShort(); }
4214
4215
4216
4217
4218
4219
4220
4221 Int_t TEcnaRead::GetStexStinFromIndex(const Int_t &i0StexStinEcna) {
4222
4223
4224 Int_t number = -1;
4225 TVectorD vec(fEcal->MaxStinEcnaInStex());
4226 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
4227 vec(i) = (Double_t)0.;
4228 }
4229 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
4230 number = (Int_t)vec(i0StexStinEcna);
4231 return number;
4232 }
4233
4234
4235
4236 Int_t TEcnaRead::GetNumberOfBinsSampleAsFunctionOfTime() { return GetReqNbOfEvts(); }
4237
4238
4239
4240
4241
4242 Int_t TEcnaRead::GetStinIndex(const Int_t &n1StexStin) {
4243
4244
4245 if (fFlagPrint == fCodePrintAllComments) {
4246 std::cout << "*TEcnaRead::GetStinIndex(...)> fEcal->MaxStinEcnaInStex() = " << fEcal->MaxStinEcnaInStex()
4247 << std::endl
4248 << " n1StexStin = " << n1StexStin << std::endl
4249 << std::endl;
4250 }
4251
4252 Int_t Stin_index = n1StexStin - 1;
4253
4254 #define NOGT
4255 #ifndef NOGT
4256 Int_t Stin_index = -1;
4257 TVectorD vec(fEcal->MaxStinEcnaInStex());
4258 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
4259 vec(i) = (Double_t)0.;
4260 }
4261 vec = ReadStinNumbers(fEcal->MaxStinEcnaInStex());
4262
4263
4264
4265 for (Int_t i = 0; i < fEcal->MaxStinEcnaInStex(); i++) {
4266 if (fFlagPrint == fCodePrintAllComments) {
4267 std::cout << "*TEcnaRead::GetStinIndex(...)> StinNumber[" << i << "] = " << vec[i] << std::endl;
4268 }
4269 if (vec[i] == n1StexStin) {
4270 Stin_index = i;
4271 }
4272 }
4273
4274 if (fFlagPrint == fCodePrintAllComments) {
4275 std::cout << "~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-" << std::endl;
4276 std::cout << "*TEcnaRead::GetStinIndex> Stin number: " << n1StexStin << std::endl
4277 << " Stin index : " << Stin_index << std::endl;
4278 std::cout << "~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-" << std::endl;
4279 }
4280
4281 if (Stin_index < 0) {
4282 if (fFlagPrint == fCodePrintAllComments) {
4283 std::cout << "!TEcnaRead::GetStinIndex *** WARNING ***> n1StexStin" << n1StexStin << " : "
4284 << "index Stin not found" << fTTBELL << std::endl;
4285 }
4286 }
4287 #endif
4288
4289 return Stin_index;
4290 }
4291
4292
4293
4294
4295
4296
4297
4298 void TEcnaRead::PrintComments() {
4299
4300
4301 fFlagPrint = fCodePrintComments;
4302 std::cout << "*TEcnaRead::PrintComments()> Warnings and some comments on init will be printed" << std::endl;
4303 }
4304
4305 void TEcnaRead::PrintWarnings() {
4306
4307
4308 fFlagPrint = fCodePrintWarnings;
4309 std::cout << "*TEcnaRead::PrintWarnings()> Warnings will be printed" << std::endl;
4310 }
4311
4312 void TEcnaRead::PrintAllComments() {
4313
4314
4315 fFlagPrint = fCodePrintAllComments;
4316 std::cout << "*TEcnaRead::PrintAllComments()> All the comments will be printed" << std::endl;
4317 }
4318
4319 void TEcnaRead::PrintNoComment() {
4320
4321
4322 fFlagPrint = fCodePrintNoComment;
4323 }