Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:46

0001 //----------Author's Name: B.Fabbro DSM/IRFU/SPP CEA-Saclay
0002 //----------Copyright: Those valid for CEA sofware
0003 //----------Modified: 30/01/2014
0004 
0005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaWrite.h"
0006 
0007 //--------------------------------------
0008 //  TEcnaWrite.cc
0009 //  Class creation: 19 May 2005
0010 //  Documentation: see TEcnaWrite.h
0011 //--------------------------------------
0012 
0013 ClassImp(TEcnaWrite);
0014 //______________________________________________________________________________
0015 //
0016 
0017 TEcnaWrite::~TEcnaWrite() {
0018   //destructor
0019 
0020   //if (fEcal          != 0){delete fEcal;          fCdelete++;}
0021   //if (fEcalNumbering != 0){delete fEcalNumbering; fCdelete++;}
0022   //if (fCnaParPaths   != 0){delete fCnaParPaths;   fCdelete++;}
0023   //if (fCnaParCout    != 0){delete fCnaParCout;    fCdelete++;}
0024 
0025   // std::cout << "[Info Management] CLASS: TEcnaWrite.         DESTROY OBJECT: this = " << this << std::endl;
0026 }
0027 
0028 //===================================================================
0029 //
0030 //                   Constructors
0031 //
0032 //===================================================================
0033 TEcnaWrite::TEcnaWrite() {
0034   // std::cout << "[Info Management] CLASS: TEcnaWrite.         CREATE OBJECT: this = " << this << std::endl;
0035 
0036   Init();
0037 }
0038 
0039 TEcnaWrite::TEcnaWrite(TEcnaObject* pObjectManager, const TString& SubDet) {
0040   // std::cout << "[Info Management] CLASS: TEcnaWrite.         CREATE OBJECT: this = " << this << std::endl;
0041 
0042   Init();
0043   Long_t i_this = (Long_t)this;
0044   pObjectManager->RegisterPointer("TEcnaWrite", i_this);
0045 
0046   //............................ fCnaParCout
0047   fCnaParCout = nullptr;
0048   Long_t iCnaParCout = pObjectManager->GetPointerValue("TEcnaParCout");
0049   if (iCnaParCout == 0) {
0050     fCnaParCout = new TEcnaParCout(pObjectManager); /*fCnew++*/
0051   } else {
0052     fCnaParCout = (TEcnaParCout*)iCnaParCout;
0053   }
0054   fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
0055 
0056   //............................ fCnaParPaths
0057   fCnaParPaths = nullptr;
0058   Long_t iCnaParPaths = pObjectManager->GetPointerValue("TEcnaParPaths");
0059   if (iCnaParPaths == 0) {
0060     fCnaParPaths = new TEcnaParPaths(pObjectManager); /*fCnew++*/
0061   } else {
0062     fCnaParPaths = (TEcnaParPaths*)iCnaParPaths;
0063   }
0064 
0065   //fCfgResultsRootFilePath    = fCnaParPaths->ResultsRootFilePath();
0066   //fCfgHistoryRunListFilePath = fCnaParPaths->HistoryRunListFilePath();
0067 
0068   fCnaParPaths->GetPathForResultsRootFiles();
0069   fCnaParPaths->GetPathForResultsAsciiFiles();
0070 
0071   //............................ fEcal  => should be changed in fParEcal
0072   fEcal = nullptr;
0073   Long_t iParEcal = pObjectManager->GetPointerValue("TEcnaParEcal");
0074   if (iParEcal == 0) {
0075     fEcal = new TEcnaParEcal(pObjectManager, SubDet.Data()); /*fCnew++*/
0076   } else {
0077     fEcal = (TEcnaParEcal*)iParEcal;
0078   }
0079 
0080   //............................ fEcalNumbering
0081   fEcalNumbering = nullptr;
0082   Long_t iEcalNumbering = pObjectManager->GetPointerValue("TEcnaNumbering");
0083   if (iEcalNumbering == 0) {
0084     fEcalNumbering = new TEcnaNumbering(pObjectManager, SubDet.Data()); /*fCnew++*/
0085   } else {
0086     fEcalNumbering = (TEcnaNumbering*)iEcalNumbering;
0087   }
0088 
0089   SetEcalSubDetector(SubDet.Data());
0090 }
0091 
0092 TEcnaWrite::TEcnaWrite(const TString& SubDet,
0093                        TEcnaParPaths* pCnaParPaths,
0094                        TEcnaParCout* pCnaParCout,
0095                        TEcnaParEcal* pEcal,
0096                        TEcnaNumbering* pEcalNumbering) {
0097   // std::cout << "[Info Management] CLASS: TEcnaWrite.         CREATE OBJECT: this = " << this << std::endl;
0098 
0099   Init();
0100 
0101   //----------------------------- Object management
0102   fCnaParPaths = nullptr;
0103   if (pCnaParPaths == nullptr) {
0104     fCnaParPaths = new TEcnaParPaths(); /*fCnew++*/
0105     ;
0106   } else {
0107     fCnaParPaths = pCnaParPaths;
0108   }
0109 
0110   //................. Get paths from ECNA directory
0111 
0112   fCnaParPaths->GetPathForResultsRootFiles();
0113   fCnaParPaths->GetPathForResultsAsciiFiles();
0114 
0115   fCnaParCout = nullptr;
0116   if (pCnaParCout == nullptr) {
0117     fCnaParCout = new TEcnaParCout(); /*fCnew++*/
0118     ;
0119   } else {
0120     fCnaParCout = pCnaParCout;
0121   }
0122   fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
0123 
0124   fEcal = nullptr;
0125   if (pEcal == nullptr) {
0126     fEcal = new TEcnaParEcal(SubDet.Data()); /*fCnew++*/
0127     ;
0128   } else {
0129     fEcal = pEcal;
0130   }
0131 
0132   fEcalNumbering = nullptr;
0133   if (pEcalNumbering == nullptr) {
0134     fEcalNumbering = new TEcnaNumbering(SubDet.Data(), fEcal); /*fCnew++*/
0135     ;
0136   } else {
0137     fEcalNumbering = pEcalNumbering;
0138   }
0139 
0140   SetEcalSubDetector(SubDet.Data(), fEcal, fEcalNumbering);
0141 }
0142 
0143 void TEcnaWrite::Init() {
0144   //----------------------------- Parameters values
0145   fTTBELL = '\007';
0146 
0147   fgMaxCar = (Int_t)512;  // max number of characters in TStrings
0148   fCodeHeaderAscii = 0;
0149   fCodeRoot = 1;
0150 
0151   //------------------------------------------- Codes
0152   //................. presently used codes
0153   fCodeNbOfEvts = 101;
0154   fCodePed = 102;
0155   fCodeTno = 103;
0156   fCodeLfn = 104;
0157   fCodeHfn = 105;
0158   fCodeMeanCorss = 106;
0159   fCodeSigCorss = 107;
0160 
0161   fCodeCovCss = 201;
0162   fCodeCorCss = 202;
0163 
0164   //................. not yet used codes
0165   //fCodeAdcEvt      =  3;
0166   //fCodeMSp         =  4;
0167   //fCodeSSp         =  5;
0168 
0169   //fCodeAvPed       = 17;
0170   //fCodeAvTno       =  6;
0171   //fCodeAvMeanCorss = 18;
0172   //fCodeAvSigCorss  = 19;
0173 
0174   //fCodeLfCov       = 11;
0175   //fCodeLfCor       = 12;
0176   //fCodeHfCov       =  9;
0177   //fCodeHfCor       = 10;
0178 
0179   //fCodeLFccMoStins = 13;
0180   //fCodeHFccMoStins = 14;
0181 
0182   //----------------------------------------
0183 
0184   fUserSamp = 0;
0185   fStexStinUser = 0;
0186   fStinEchaUser = 0;
0187 
0188   fjustap_2d_ev = nullptr;
0189   fjustap_1d_ev = nullptr;
0190 
0191   fjustap_2d_var = nullptr;
0192   fjustap_1d_var = nullptr;
0193 
0194   fjustap_2d_cc = nullptr;
0195   fjustap_1d_cc = nullptr;
0196 
0197   fjustap_2d_ss = nullptr;
0198   fjustap_1d_ss = nullptr;
0199 }
0200 // end of Init()
0201 
0202 //===================================================================
0203 //
0204 //                   Methods
0205 //
0206 //===================================================================
0207 
0208 void TEcnaWrite::SetEcalSubDetector(const TString& SubDet) {
0209   // Set Subdetector (EB or EE)
0210 
0211   Int_t MaxCar = fgMaxCar;
0212   fFlagSubDet.Resize(MaxCar);
0213   fFlagSubDet = fEcal->GetEcalSubDetector();
0214 
0215   //........................................................................
0216   //
0217   //             (for ASCII files writing methods only) ...
0218   //
0219   //                DEFINITION OF THE SECTOR SIZES
0220   //       FOR THE CORRELATION AND COVARIANCE MATRICES DISPLAY
0221   //
0222   //            MUST BE A DIVISOR OF THE TOTAL NUMBER.
0223   //            ======================================
0224   //
0225   //     Examples:
0226   //
0227   //      (1)    25 channels => size = 25 or 5 (divisors of 25)
0228   //
0229   //             25 => matrix = 1 x 1 sector  of size (25 x 25)
0230   //                          = (1 x 1) x (25 x 25) = 1 x 625 = 625
0231   //              5 => matrix = 5 x 5 sectors of size (5 x 5)
0232   //                          = (5 x 5) x ( 5 x  5) = 25 x 25 = 625
0233   //
0234   //      (2)    10 samples  => size = 10, 5 or 2 (divisors of 10)
0235   //
0236   //             10 => matrix = 1 X 1 sectors of size (10 x 10)
0237   //                          = (1 x 1) x (10 x 10) =  1 x 100 = 100
0238   //              5 => matrix = 2 x 2 sectors of size (5 x 5)
0239   //                          = (2 x 2) x ( 5 x  5) =  4 x  25 = 100
0240   //              2 => matrix = 5 x 5 sectors of size (2 x 2)
0241   //                          = (5 x 5) x ( 2 x  2) = 25 x  4  = 100
0242   //
0243   //........................................................................
0244   fSectChanSizeX = fEcal->MaxCrysHocoInStin();
0245   fSectChanSizeY = fEcal->MaxCrysVecoInStin();
0246   fSectSampSizeX = fEcal->MaxSampADC();
0247   fSectSampSizeY = fEcal->MaxSampADC();
0248 
0249   //........................................................................
0250   //
0251   //                DEFINITION OF THE NUMBER OF VALUES BY LINE
0252   //                for the Expectation Values, Variances and.
0253   //                Event distributions by (channel,sample)
0254   //
0255   //               MUST BE A DIVISOR OF THE TOTAL NUMBER.
0256   //               ======================================
0257   //
0258   //     Examples:
0259   //                1) For expectation values and variances:
0260   //
0261   //                25 channels => size = 5
0262   //                => sample sector = 5 lines of 5 values
0263   //                                 = 5 x 5 = 25 values
0264   //
0265   //                10 samples  => size = 10
0266   //                => channel sector = 1 lines of 10 values
0267   //                                  = 1 x 10 = 10 values
0268   //
0269   //                2) For event distributions:
0270   //
0271   //                100 bins  => size = 10
0272   //                => sample sector = 10 lines of 10 values
0273   //                                 = 10 x 10 = 100 values
0274   //
0275   //........................................................................
0276   fNbChanByLine = fEcal->MaxCrysHocoInStin();
0277   fNbSampByLine = fEcal->MaxSampADC();
0278 }  //---------- (end of SetEcalSubDetector) ------------------
0279 
0280 void TEcnaWrite::SetEcalSubDetector(const TString& SubDet, TEcnaParEcal* pEcal, TEcnaNumbering* pEcalNumbering) {
0281   // Set Subdetector (EB or EE)
0282 
0283   fEcal = nullptr;
0284   if (pEcal == nullptr) {
0285     fEcal = new TEcnaParEcal(SubDet.Data());
0286     fCnew++;
0287   } else {
0288     fEcal = pEcal;
0289   }
0290 
0291   Int_t MaxCar = fgMaxCar;
0292   fFlagSubDet.Resize(MaxCar);
0293   fFlagSubDet = fEcal->GetEcalSubDetector();
0294 
0295   fEcalNumbering = nullptr;
0296   if (pEcalNumbering == nullptr) {
0297     fEcalNumbering = new TEcnaNumbering(SubDet.Data(), fEcal);
0298     fCnew++;
0299   } else {
0300     fEcalNumbering = pEcalNumbering;
0301   }
0302 
0303   //........................................................................
0304   //
0305   //             (for ASCII files writing methods only) ...
0306   //
0307   //                DEFINITION OF THE SECTOR SIZES
0308   //       FOR THE CORRELATION AND COVARIANCE MATRICES DISPLAY
0309   //
0310   //            MUST BE A DIVISOR OF THE TOTAL NUMBER.
0311   //            ======================================
0312   //
0313   //     Examples:
0314   //
0315   //      (1)    25 channels => size = 25 or 5 (divisors of 25)
0316   //
0317   //             25 => matrix = 1 x 1 sector  of size (25 x 25)
0318   //                          = (1 x 1) x (25 x 25) = 1 x 625 = 625
0319   //              5 => matrix = 5 x 5 sectors of size (5 x 5)
0320   //                          = (5 x 5) x ( 5 x  5) = 25 x 25 = 625
0321   //
0322   //      (2)    10 samples  => size = 10, 5 or 2 (divisors of 10)
0323   //
0324   //             10 => matrix = 1 X 1 sectors of size (10 x 10)
0325   //                          = (1 x 1) x (10 x 10) =  1 x 100 = 100
0326   //              5 => matrix = 2 x 2 sectors of size (5 x 5)
0327   //                          = (2 x 2) x ( 5 x  5) =  4 x  25 = 100
0328   //              2 => matrix = 5 x 5 sectors of size (2 x 2)
0329   //                          = (5 x 5) x ( 2 x  2) = 25 x  4  = 100
0330   //
0331   //........................................................................
0332   fSectChanSizeX = fEcal->MaxCrysHocoInStin();
0333   fSectChanSizeY = fEcal->MaxCrysVecoInStin();
0334   fSectSampSizeX = fEcal->MaxSampADC();
0335   fSectSampSizeY = fEcal->MaxSampADC();
0336 
0337   //........................................................................
0338   //
0339   //                DEFINITION OF THE NUMBER OF VALUES BY LINE
0340   //                for the Expectation Values, Variances and.
0341   //                Event distributions by (channel,sample)
0342   //
0343   //               MUST BE A DIVISOR OF THE TOTAL NUMBER.
0344   //               ======================================
0345   //
0346   //     Examples:
0347   //                1) For expectation values and variances:
0348   //
0349   //                25 channels => size = 5
0350   //                => sample sector = 5 lines of 5 values
0351   //                                 = 5 x 5 = 25 values
0352   //
0353   //                10 samples  => size = 10
0354   //                => channel sector = 1 lines of 10 values
0355   //                                  = 1 x 10 = 10 values
0356   //
0357   //                2) For event distributions:
0358   //
0359   //                100 bins  => size = 10
0360   //                => sample sector = 10 lines of 10 values
0361   //                                 = 10 x 10 = 100 values
0362   //
0363   //........................................................................
0364   fNbChanByLine = fEcal->MaxCrysHocoInStin();
0365   fNbSampByLine = fEcal->MaxSampADC();
0366 }  //---------- (end of SetEcalSubDetector) ------------------
0367 
0368 //-------------------------------------------------------------------------
0369 //
0370 //    Get methods for different run or file parameters
0371 //
0372 //    W A R N I N G :  some of these methods are called by external code
0373 //
0374 //                D O N ' T    S U P P R E S S !
0375 //
0376 //
0377 //     TString  fRootFileNameShort
0378 //     TString  fAnaType       = typ_ana
0379 //     Int_t    fRunNumber     = run_number
0380 //     Int_t    fFirstReqEvtNumber = nfirst
0381 //     Int_t    fReqNbOfEvts = nevents
0382 //     Int_t    fStexNumber    = super_module
0383 //
0384 //-------------------------------------------------------------------------
0385 const TString& TEcnaWrite::GetAsciiFileName() const { return fAsciiFileName; }
0386 const TString& TEcnaWrite::GetRootFileName() const { return fRootFileName; }
0387 const TString& TEcnaWrite::GetRootFileNameShort() const { return fRootFileNameShort; }
0388 const TString& TEcnaWrite::GetAnalysisName() const { return fAnaType; }
0389 Int_t TEcnaWrite::GetNbOfSamples() { return fNbOfSamples; }
0390 Int_t TEcnaWrite::GetRunNumber() { return fRunNumber; }
0391 Int_t TEcnaWrite::GetFirstReqEvtNumber() { return fFirstReqEvtNumber; }
0392 Int_t TEcnaWrite::GetReqNbOfEvts() { return fReqNbOfEvts; }
0393 Int_t TEcnaWrite::GetStexNumber() { return fStexNumber; }
0394 
0395 //---------------------------------------------------------------------------------------------------
0396 //
0397 //  NumberOfEventsAnalysis(...) : Analyses the number of events found in data
0398 //                                channel by channel OR sample by sample
0399 //                                an output ERROR message is delivered if differences are detected
0400 //
0401 //            channel by channel: called by TEcnaRead object (3 arguments)
0402 //            sample  by sample : called by TEcnaRun  object (4 arguments)
0403 //
0404 //    This method must be a TEcnaWrite method since it can be called by objects
0405 //    of class TEcnaRead OR TEcnaRun
0406 //
0407 //---------------------------------------------------------------------------------------------------
0408 //.............................................................................................
0409 Int_t TEcnaWrite::NumberOfEventsAnalysis(Int_t* ArrayNbOfEvts,
0410                                          const Int_t& MaxArray,
0411                                          const Int_t& NbOfReqEvts,
0412                                          const Int_t& StexNumber) {
0413   //  CHECK THE NUMBER OF FOUND EVENTS, return rNumberOfEvents (NumberOfEvents())
0414   //  (number used to compute the average values over the events)
0415   //
0416   //  1D array: called by TEcnaRead object
0417 
0418   Int_t rNumberOfEvents = 0;
0419   Int_t PresentNumber = 0;
0420   Int_t EmptyChannel = 0;
0421   Int_t DifferentMinusValue = 0;
0422   Int_t DifferentPlusValue = 0;
0423 
0424   //........................................................ i_SSoSE = StexStin or StinEcha
0425   for (Int_t i_SSoSE = 0; i_SSoSE < MaxArray; i_SSoSE++) {
0426     Int_t NbOfEvts = ArrayNbOfEvts[i_SSoSE];
0427 
0428     if (NbOfEvts > 0) {
0429       if (PresentNumber == 0)  // first channel
0430       {
0431         PresentNumber = NbOfEvts;
0432       } else  // current channel
0433       {
0434         if (NbOfEvts > PresentNumber)  // warning
0435         {
0436           PresentNumber = NbOfEvts;
0437           DifferentPlusValue++;
0438         }
0439         if (NbOfEvts < PresentNumber)  // warning
0440         {
0441           DifferentMinusValue++;
0442         }
0443       }
0444     } else {
0445       EmptyChannel++;
0446     }
0447   }
0448 
0449   rNumberOfEvents = PresentNumber;
0450 
0451   if (EmptyChannel > 0) {
0452     if (MaxArray == fEcal->MaxCrysInSM())  // (EB)
0453     {
0454       std::cout << "!TEcnaWrite::NumberOfEventsAnalysis()> *** WARNING *** " << EmptyChannel
0455                 << " empty channels detected in SM " << StexNumber << " (EB "
0456                 << fEcalNumbering->PlusMinusSMNumber(StexNumber) << ")" << std::endl;
0457     }
0458     if (MaxArray == fEcal->MaxCrysEcnaInDee())  // (EE)
0459     {
0460       EmptyChannel -= fEcal->EmptyChannelsInDeeMatrixIncompleteSCIncluded();
0461       if (EmptyChannel > 0) {
0462         std::cout << "!TEcnaWrite::NumberOfEventsAnalysis()> *** WARNING *** " << EmptyChannel
0463                   << " empty channels detected in Dee " << StexNumber << std::endl;
0464       }
0465     }
0466   }
0467 
0468   if (DifferentMinusValue > 0 || DifferentPlusValue > 0) {
0469     std::cout << "!TEcnaWrite::NumberOfEventsAnalysis()> " << std::endl;
0470 
0471     if (MaxArray == fEcal->MaxCrysInSM())  // (EB)
0472     {
0473       std::cout << "************** W A R N I N G  :  NUMBER OF EVENTS NOT CONSTANT FOR SM " << StexNumber << " (EB "
0474                 << fEcalNumbering->PlusMinusSMNumber(StexNumber) << ")  *********************";
0475     }
0476 
0477     if (MaxArray == fEcal->MaxCrysEcnaInDee())  // (EE)
0478     {
0479       std::cout << "****************** W A R N I N G  :  NUMBER OF EVENTS NOT CONSTANT FOR Dee " << StexNumber
0480                 << " **************************";
0481     }
0482 
0483     std::cout
0484         << std::endl
0485         << "  Result ROOT file: " << fRootFileName << std::endl
0486         << "  The number of events is not the same for all the non-empty channels." << std::endl
0487         << "  The maximum number (" << rNumberOfEvents << ") is considered as the number of events for calculations "
0488         << std::endl
0489         << "  of pedestals, noises and correlations." << std::endl
0490         << "  Number of channels with 0 < nb of evts < " << rNumberOfEvents << " : " << DifferentMinusValue
0491         << std::endl
0492         // << "  Number of channels with nb of evts > " << rNumberOfEvents << " = " << DifferentPlusValue  << std::endl
0493         << "  Number of empty channels : " << EmptyChannel << std::endl
0494         << "  Some values of pedestals, noises and correlations may be wrong for channels" << std::endl
0495         << "  with number of events different from " << rNumberOfEvents << "." << std::endl
0496         << "  Please, check the histogram 'Numbers of events'." << std::endl
0497         << "*******************************************************************************************************"
0498         << std::endl;
0499   } else {
0500     if (fFlagPrint == fCodePrintAllComments) {
0501       if (rNumberOfEvents < NbOfReqEvts) {
0502         std::cout << "*TEcnaWrite::NumberOfEventsAnalysis()> *** INFO *** Number of events found in data = "
0503                   << rNumberOfEvents << ": less than number of requested events ( = " << NbOfReqEvts << ")"
0504                   << std::endl;
0505       }
0506     }
0507   }
0508   return rNumberOfEvents;
0509 }
0510 
0511 //.............................................................................................
0512 Int_t TEcnaWrite::NumberOfEventsAnalysis(Int_t** T2d_NbOfEvts,
0513                                          const Int_t& MaxCrysEcnaInStex,
0514                                          const Int_t& MaxNbOfSamples,
0515                                          const Int_t& NbOfReqEvts) {
0516   //  CHECK OF THE NUMBER OF FOUND EVENTS, return rNumberOfEvents (NumberOfEvents())
0517   //       (number used to compute the average values over the events)
0518   //
0519   //  2D array: called by TEcnaRun object
0520 
0521   Int_t rNumberOfEvents = 0;
0522   Int_t PresentNumber = 0;
0523   Int_t DifferentMinusValue = 0;
0524   Int_t DifferentPlusValue = 0;
0525 
0526   for (Int_t i0StexEcha = 0; i0StexEcha < MaxCrysEcnaInStex; i0StexEcha++) {
0527     for (Int_t i_samp = 0; i_samp < MaxNbOfSamples; i_samp++) {
0528       Int_t NbOfEvts = T2d_NbOfEvts[i0StexEcha][i_samp];
0529 
0530       if (NbOfEvts > 0) {
0531         if (PresentNumber == 0) {
0532           PresentNumber = NbOfEvts;
0533         } else {
0534           if (NbOfEvts > PresentNumber) {
0535             PresentNumber = NbOfEvts;
0536             DifferentPlusValue++;
0537           }
0538           if (NbOfEvts < PresentNumber) {
0539             DifferentMinusValue++;
0540           }
0541         }
0542       }
0543     }
0544   }
0545   //.............................................................  (NumberOfEvents())
0546   rNumberOfEvents = PresentNumber;
0547 
0548   if (DifferentMinusValue > 0 || DifferentPlusValue > 0) {
0549     std::cout
0550         << "!TEcnaWrite::NumberOfEventsAnalysis()> " << std::endl
0551         << "****************** W A R N I N G  :  NUMBER OF EVENTS NOT CONSTANT !  *********************************"
0552         << std::endl
0553         << "  Result ROOT file: " << fRootFileName << std::endl
0554         << "  The number of events is not the same for all the non-empty channels" << std::endl
0555         << "  The maximum number (" << rNumberOfEvents << ") is considered as the number of events " << std::endl
0556         << "  for calculations of pedestals, noises and correlations." << std::endl
0557         << "  Number of channels with 0 < nb of evts < " << rNumberOfEvents << " : " << DifferentMinusValue
0558         << std::endl
0559         // << "  Number of channels with nb of evts > " << rNumberOfEvents << " : " << DifferentPlusValue  << std::endl
0560         // << "  Number of empty channels : " << EmptyChannel << std::endl
0561         << "  Some values of pedestals, noises and correlations may be wrong for channels" << std::endl
0562         << "  with number of events different from " << rNumberOfEvents << "." << std::endl
0563         << "  Please, check the histogram 'Numbers of events'." << std::endl
0564         << "*******************************************************************************************************"
0565         << std::endl;
0566   } else {
0567     if (fFlagPrint == fCodePrintAllComments) {
0568       if (rNumberOfEvents < NbOfReqEvts) {
0569         std::cout << "*TEcnaWrite::NumberOfEventsAnalysis()> *** INFO *** Number of events found in data = "
0570                   << rNumberOfEvents << ": less than number of requested events ( = " << NbOfReqEvts << ")"
0571                   << std::endl;
0572       }
0573     }
0574   }
0575   return rNumberOfEvents;
0576 
0577 }  //----- ( end of NumberOfEvents(...) ) ----------------
0578 
0579 void TEcnaWrite::RegisterFileParameters(const TString& ArgAnaType,
0580                                         const Int_t& ArgNbOfSamples,
0581                                         const Int_t& ArgRunNumber,
0582                                         const Int_t& ArgFirstReqEvtNumber,
0583                                         const Int_t& ArgLastReqEvtNumber,
0584                                         const Int_t& ArgReqNbOfEvts,
0585                                         const Int_t& ArgStexNumber) {
0586   fAnaType = ArgAnaType;
0587   fNbOfSamples = ArgNbOfSamples;
0588   fRunNumber = ArgRunNumber;
0589   fFirstReqEvtNumber = ArgFirstReqEvtNumber;
0590   fLastReqEvtNumber = ArgLastReqEvtNumber;
0591   fReqNbOfEvts = ArgReqNbOfEvts;
0592   fStexNumber = ArgStexNumber;
0593 }
0594 
0595 void TEcnaWrite::RegisterFileParameters(const TString& ArgAnaType,
0596                                         const Int_t& ArgNbOfSamples,
0597                                         const Int_t& ArgRunNumber,
0598                                         const Int_t& ArgFirstReqEvtNumber,
0599                                         const Int_t& ArgLastReqEvtNumber,
0600                                         const Int_t& ArgReqNbOfEvts,
0601                                         const Int_t& ArgStexNumber,
0602                                         const TString& ArgStartDate,
0603                                         const TString& ArgStopDate,
0604                                         const time_t ArgStartTime,
0605                                         const time_t ArgStopTime) {
0606   fAnaType = ArgAnaType;
0607   fNbOfSamples = ArgNbOfSamples;
0608   fRunNumber = ArgRunNumber;
0609   fFirstReqEvtNumber = ArgFirstReqEvtNumber;
0610   fLastReqEvtNumber = ArgLastReqEvtNumber;
0611   fReqNbOfEvts = ArgReqNbOfEvts;
0612   fStexNumber = ArgStexNumber;
0613   fStartDate = ArgStartDate;
0614 
0615   fStopDate = ArgStopDate;
0616   fStartTime = ArgStartTime;
0617   fStopTime = ArgStopTime;
0618 }
0619 //=======================================================================
0620 //
0621 //                      FILE NAMES MANAGEMENT
0622 //
0623 //=======================================================================
0624 //==============================================================================
0625 //
0626 //                     Results Filename Making  (private)
0627 //
0628 //==============================================================================
0629 void TEcnaWrite::fMakeResultsFileName() { fMakeResultsFileName(fCodeRoot); }
0630 void TEcnaWrite::fMakeResultsFileName(const Int_t& i_code) {
0631   //Results filename making  (private)
0632 
0633   //----------------------------------------------------------------------
0634   //
0635   //     Making of the name of the result file from the parameters set
0636   //     by call to RegisterFileParameters(...)
0637   //
0638   //     Put the names in the following class attributes:
0639   //
0640   //     fRootFileName,  fRootFileNameShort,
0641   //     fAsciiFileName, fAsciiFileNameShort
0642   //
0643   //     (Short means: without the directory path)
0644   //
0645   //     set indications (run number, type of quantity, ...)
0646   //     and add the extension ".ascii" or ".root"
0647   //
0648   //     ROOT:  only one ROOT file:  i_code = fCodeRoot.
0649   //                                          All the types of quantities
0650   //
0651   //     ASCII: several ASCII files: i_code = code for one type of quantity
0652   //            each i_code which is not equal to fCodeRoot is also implicitly
0653   //            a code "fCodeAscii" (this last attribute is not in the class)
0654   //
0655   //----------------------------------------------------------------------
0656 
0657   char* f_in = new char[fgMaxCar];
0658   fCnew++;
0659   char* f_in_short = new char[fgMaxCar];
0660   fCnew++;
0661 
0662   Int_t MaxCar = fgMaxCar;
0663   fStexName.Resize(MaxCar);
0664   fStexName = "SM or Dee?";
0665 
0666   MaxCar = fgMaxCar;
0667   fStinName.Resize(MaxCar);
0668   fStinName = "tower or SC?";
0669 
0670   if (fFlagSubDet == "EB") {
0671     fStexName = "SM";
0672     fStinName = "tower";
0673   }
0674   if (fFlagSubDet == "EE") {
0675     fStexName = "Dee";
0676     fStinName = "SC";
0677   }
0678 
0679   //  switch (i_code){
0680 
0681   //===================================  R O O T  =========================  (fMakeResultsFileName)
0682   TString sPointInterrog = "?";
0683   TString sDollarHome = "$HOME";
0684 
0685   if (i_code == fCodeRoot) {
0686     if (fCnaParPaths->ResultsRootFilePath().Data() == sPointInterrog.Data()) {
0687       std::cout << "!TEcnaWrite::fMakeResultsFileName>  * * * W A R N I N G * * * " << std::endl
0688                 << std::endl
0689                 << "    Path for results .root file not defined. Default option will be used here:" << std::endl
0690                 << "    your results files will be written in your HOME directory." << std::endl
0691                 << std::endl
0692                 << "    In order to write the .root results file in a specific directory," << std::endl
0693                 << "    you have to create a file named path_results_root in a subdirectory named ECNA" << std::endl
0694                 << "    previously created in your home directory." << std::endl
0695                 << "    This file must have only one line containing the path of the directory" << std::endl
0696                 << "    where must be the .root result files." << std::endl
0697                 << std::endl;
0698 
0699       TString home_path = gSystem->Getenv("HOME");
0700       fCnaParPaths->SetResultsRootFilePath(home_path.Data());
0701     }
0702 
0703     if (fCnaParPaths->BeginningOfResultsRootFilePath().Data() == sDollarHome.Data()) {
0704       fCnaParPaths->TruncateResultsRootFilePath(0, 5);
0705       const Text_t* t_file_nohome = (const Text_t*)fCnaParPaths->ResultsRootFilePath().Data();  //  /scratch0/cna/...
0706 
0707       TString home_path = gSystem->Getenv("HOME");
0708       fCnaParPaths->SetResultsRootFilePath(home_path.Data());  //  /afs/cern.ch/u/USER
0709       fCnaParPaths->AppendResultsRootFilePath(t_file_nohome);  //  /afs/cern.ch/u/USER/scratch0/cna/...
0710     }
0711 
0712     sprintf(f_in,
0713             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d",
0714             fCnaParPaths->ResultsRootFilePath().Data(),
0715             fAnaType.Data(),
0716             fNbOfSamples,
0717             fRunNumber,
0718             fFirstReqEvtNumber,
0719             fLastReqEvtNumber,
0720             fReqNbOfEvts,
0721             fStexName.Data(),
0722             fStexNumber);
0723     sprintf(f_in_short,
0724             "%s_S1_%d_R%d_%d_%d_%d_%s%d",
0725             fAnaType.Data(),
0726             fNbOfSamples,
0727             fRunNumber,
0728             fFirstReqEvtNumber,
0729             fLastReqEvtNumber,
0730             fReqNbOfEvts,
0731             fStexName.Data(),
0732             fStexNumber);
0733   }
0734 
0735   //===================================  A S C I I  ====================  (fMakeResultsFileName)
0736   //fCnaParPaths->GetPathForResultsAsciiFiles();
0737   if (i_code != fCodeRoot) {
0738     if (i_code == fCodeHeaderAscii) {
0739       if (fCnaParPaths->ResultsAsciiFilePath().Data() == sPointInterrog.Data()) {
0740         std::cout << "!TEcnaWrite::fMakeResultsFileName>  * * * W A R N I N G * * * " << std::endl
0741                   << std::endl
0742                   << "    Path for results .ascii file not defined. Default option will be used here:" << std::endl
0743                   << "    your results files will be written in your HOME directory." << std::endl
0744                   << std::endl
0745                   << "    In order to write the .ascii results file in a specific directory," << std::endl
0746                   << "    you have to create a file named path_results_ascii in a subdirectory named ECNA" << std::endl
0747                   << "    previously created in your home directory." << std::endl
0748                   << "    This file must have only one line containing the path of the directory" << std::endl
0749                   << "    where must be the .ascii result files." << std::endl
0750                   << std::endl;
0751 
0752         TString home_path = gSystem->Getenv("HOME");
0753         fCnaParPaths->SetResultsAsciiFilePath(home_path.Data());
0754       }
0755 
0756       if (fCnaParPaths->BeginningOfResultsAsciiFilePath().Data() == sDollarHome.Data()) {
0757         fCnaParPaths->TruncateResultsAsciiFilePath(0, 5);
0758         const Text_t* t_file_nohome = (const Text_t*)fCnaParPaths->ResultsAsciiFilePath().Data();  // /scratch0/cna/...
0759 
0760         TString home_path = gSystem->Getenv("HOME");
0761         fCnaParPaths->SetResultsAsciiFilePath(home_path.Data());  //  /afs/cern.ch/u/USER
0762         fCnaParPaths->AppendResultsAsciiFilePath(t_file_nohome);  //  /afs/cern.ch/u/USER/scratch0/cna/...
0763       }
0764     }
0765 
0766     sprintf(f_in,
0767             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_header",
0768             fCnaParPaths->ResultsAsciiFilePath().Data(),
0769             fAnaType.Data(),
0770             fNbOfSamples,
0771             fRunNumber,
0772             fFirstReqEvtNumber,
0773             fLastReqEvtNumber,
0774             fReqNbOfEvts,
0775             fStexName.Data(),
0776             fStexNumber);
0777     sprintf(f_in_short,
0778             "%s_S1_%d_R%d_%d_%d_%d_%s%d_header",
0779             fAnaType.Data(),
0780             fNbOfSamples,
0781             fRunNumber,
0782             fFirstReqEvtNumber,
0783             fLastReqEvtNumber,
0784             fReqNbOfEvts,
0785             fStexName.Data(),
0786             fStexNumber);
0787   }
0788 
0789   //--------------------------------------------------------------  (fMakeResultsFileName)
0790   if (i_code == fCodeNbOfEvts) {
0791     sprintf(f_in,
0792             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_NbOfEvents",
0793             fCnaParPaths->ResultsAsciiFilePath().Data(),
0794             fAnaType.Data(),
0795             fNbOfSamples,
0796             fRunNumber,
0797             fFirstReqEvtNumber,
0798             fLastReqEvtNumber,
0799             fReqNbOfEvts,
0800             fStexName.Data(),
0801             fStexNumber);
0802     sprintf(f_in_short,
0803             "%s_S1_%d_R%d_%d_%d_%d_%s%d_NbOfEvents",
0804             fAnaType.Data(),
0805             fNbOfSamples,
0806             fRunNumber,
0807             fFirstReqEvtNumber,
0808             fLastReqEvtNumber,
0809             fReqNbOfEvts,
0810             fStexName.Data(),
0811             fStexNumber);
0812   }
0813 
0814   if (i_code == fCodePed) {
0815     sprintf(f_in,
0816             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Pedestals",
0817             fCnaParPaths->ResultsAsciiFilePath().Data(),
0818             fAnaType.Data(),
0819             fNbOfSamples,
0820             fRunNumber,
0821             fFirstReqEvtNumber,
0822             fLastReqEvtNumber,
0823             fReqNbOfEvts,
0824             fStexName.Data(),
0825             fStexNumber);
0826     sprintf(f_in_short,
0827             "%s_S1_%d_R%d_%d_%d_%d_%s%d_Pedestals",
0828             fAnaType.Data(),
0829             fNbOfSamples,
0830             fRunNumber,
0831             fFirstReqEvtNumber,
0832             fLastReqEvtNumber,
0833             fReqNbOfEvts,
0834             fStexName.Data(),
0835             fStexNumber);
0836   }
0837 
0838   if (i_code == fCodeTno) {
0839     sprintf(f_in,
0840             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_TotalNoise",
0841             fCnaParPaths->ResultsAsciiFilePath().Data(),
0842             fAnaType.Data(),
0843             fNbOfSamples,
0844             fRunNumber,
0845             fFirstReqEvtNumber,
0846             fLastReqEvtNumber,
0847             fReqNbOfEvts,
0848             fStexName.Data(),
0849             fStexNumber);
0850     sprintf(f_in_short,
0851             "%s_S1_%d_R%d_%d_%d_%d_%s%d_TotalNoise",
0852             fAnaType.Data(),
0853             fNbOfSamples,
0854             fRunNumber,
0855             fFirstReqEvtNumber,
0856             fLastReqEvtNumber,
0857             fReqNbOfEvts,
0858             fStexName.Data(),
0859             fStexNumber);
0860   }
0861 
0862   if (i_code == fCodeLfn) {
0863     sprintf(f_in,
0864             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LFNoise",
0865             fCnaParPaths->ResultsAsciiFilePath().Data(),
0866             fAnaType.Data(),
0867             fNbOfSamples,
0868             fRunNumber,
0869             fFirstReqEvtNumber,
0870             fLastReqEvtNumber,
0871             fReqNbOfEvts,
0872             fStexName.Data(),
0873             fStexNumber);
0874     sprintf(f_in_short,
0875             "%s_S1_%d_R%d_%d_%d_%d_%s%d_LFNoise",
0876             fAnaType.Data(),
0877             fNbOfSamples,
0878             fRunNumber,
0879             fFirstReqEvtNumber,
0880             fLastReqEvtNumber,
0881             fReqNbOfEvts,
0882             fStexName.Data(),
0883             fStexNumber);
0884   }
0885 
0886   if (i_code == fCodeHfn) {
0887     sprintf(f_in,
0888             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_HFNoise",
0889             fCnaParPaths->ResultsAsciiFilePath().Data(),
0890             fAnaType.Data(),
0891             fNbOfSamples,
0892             fRunNumber,
0893             fFirstReqEvtNumber,
0894             fLastReqEvtNumber,
0895             fReqNbOfEvts,
0896             fStexName.Data(),
0897             fStexNumber);
0898     sprintf(f_in_short,
0899             "%s_S1_%d_R%d_%d_%d_%d_%s%d_HFNoise",
0900             fAnaType.Data(),
0901             fNbOfSamples,
0902             fRunNumber,
0903             fFirstReqEvtNumber,
0904             fLastReqEvtNumber,
0905             fReqNbOfEvts,
0906             fStexName.Data(),
0907             fStexNumber);
0908   }
0909 
0910   if (i_code == fCodeMeanCorss) {
0911     sprintf(f_in,
0912             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_MeanCorss",
0913             fCnaParPaths->ResultsAsciiFilePath().Data(),
0914             fAnaType.Data(),
0915             fNbOfSamples,
0916             fRunNumber,
0917             fFirstReqEvtNumber,
0918             fLastReqEvtNumber,
0919             fReqNbOfEvts,
0920             fStexName.Data(),
0921             fStexNumber);
0922     sprintf(f_in_short,
0923             "%s_S1_%d_R%d_%d_%d_%d_%s%d_MeanCorss",
0924             fAnaType.Data(),
0925             fNbOfSamples,
0926             fRunNumber,
0927             fFirstReqEvtNumber,
0928             fLastReqEvtNumber,
0929             fReqNbOfEvts,
0930             fStexName.Data(),
0931             fStexNumber);
0932   }
0933 
0934   if (i_code == fCodeSigCorss) {
0935     sprintf(f_in,
0936             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SigmaCorss",
0937             fCnaParPaths->ResultsAsciiFilePath().Data(),
0938             fAnaType.Data(),
0939             fNbOfSamples,
0940             fRunNumber,
0941             fFirstReqEvtNumber,
0942             fLastReqEvtNumber,
0943             fReqNbOfEvts,
0944             fStexName.Data(),
0945             fStexNumber);
0946     sprintf(f_in_short,
0947             "%s_S1_%d_R%d_%d_%d_%d_%s%d_SigmaCorss",
0948             fAnaType.Data(),
0949             fNbOfSamples,
0950             fRunNumber,
0951             fFirstReqEvtNumber,
0952             fLastReqEvtNumber,
0953             fReqNbOfEvts,
0954             fStexName.Data(),
0955             fStexNumber);
0956   }
0957 
0958   if (i_code == fCodeCovCss) {
0959     sprintf(f_in,
0960             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Covss_%s%d_Channel_%d",
0961             fCnaParPaths->ResultsAsciiFilePath().Data(),
0962             fAnaType.Data(),
0963             fNbOfSamples,
0964             fRunNumber,
0965             fFirstReqEvtNumber,
0966             fLastReqEvtNumber,
0967             fReqNbOfEvts,
0968             fStexName.Data(),
0969             fStexNumber,
0970             fStinName.Data(),
0971             fStexStinUser,
0972             fStinEchaUser);
0973     sprintf(f_in_short,
0974             "%s_S1_%d_R%d_%d_%d_%d_%s%d_Covss_%s%d_Channel_%d",
0975             fAnaType.Data(),
0976             fNbOfSamples,
0977             fRunNumber,
0978             fFirstReqEvtNumber,
0979             fLastReqEvtNumber,
0980             fReqNbOfEvts,
0981             fStexName.Data(),
0982             fStexNumber,
0983             fStinName.Data(),
0984             fStexStinUser,
0985             fStinEchaUser);
0986   }
0987 
0988   if (i_code == fCodeCorCss) {
0989     sprintf(f_in,
0990             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Corss_%s%d_Channel_%d",
0991             fCnaParPaths->ResultsAsciiFilePath().Data(),
0992             fAnaType.Data(),
0993             fNbOfSamples,
0994             fRunNumber,
0995             fFirstReqEvtNumber,
0996             fLastReqEvtNumber,
0997             fReqNbOfEvts,
0998             fStexName.Data(),
0999             fStexNumber,
1000             fStinName.Data(),
1001             fStexStinUser,
1002             fStinEchaUser);
1003     sprintf(f_in_short,
1004             "%s_S1_%d_R%d_%d_%d_%d_%s%d_Corss_%s%d_Channel_%d",
1005             fAnaType.Data(),
1006             fNbOfSamples,
1007             fRunNumber,
1008             fFirstReqEvtNumber,
1009             fLastReqEvtNumber,
1010             fReqNbOfEvts,
1011             fStexName.Data(),
1012             fStexNumber,
1013             fStinName.Data(),
1014             fStexStinUser,
1015             fStinEchaUser);
1016   }
1017 
1018   //------- (not used yet)
1019 #define OCOD
1020 #ifndef OCOD
1021   if (i_code == fCodeMSp) {
1022     sprintf(f_in,
1023             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleMeans",
1024             fCnaParPaths->ResultsAsciiFilePath().Data(),
1025             fAnaType.Data(),
1026             fNbOfSamples,
1027             fRunNumber,
1028             fFirstReqEvtNumber,
1029             fLastReqEvtNumber,
1030             fReqNbOfEvts,
1031             fStexName.Data(),
1032             fStexNumber);
1033     sprintf(f_in_short,
1034             "%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleMeans",
1035             fAnaType.Data(),
1036             fNbOfSamples,
1037             fRunNumber,
1038             fFirstReqEvtNumber,
1039             fLastReqEvtNumber,
1040             fReqNbOfEvts,
1041             fStexName.Data(),
1042             fStexNumber);
1043   }
1044 
1045   if (i_code == fCodeSSp) {
1046     sprintf(f_in,
1047             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleSigmas",
1048             fCnaParPaths->ResultsAsciiFilePath().Data(),
1049             fAnaType.Data(),
1050             fNbOfSamples,
1051             fRunNumber,
1052             fFirstReqEvtNumber,
1053             fLastReqEvtNumber,
1054             fReqNbOfEvts,
1055             fStexName.Data(),
1056             fStexNumber);
1057     sprintf(f_in_short,
1058             "%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleSigmas",
1059             fAnaType.Data(),
1060             fNbOfSamples,
1061             fRunNumber,
1062             fFirstReqEvtNumber,
1063             fLastReqEvtNumber,
1064             fReqNbOfEvts,
1065             fStexName.Data(),
1066             fStexNumber);
1067   }
1068 
1069   if (i_code == fCodeAvTno) {
1070     sprintf(f_in,
1071             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageTotalNoise_c%d",
1072             fCnaParPaths->ResultsAsciiFilePath().Data(),
1073             fAnaType.Data(),
1074             fNbOfSamples,
1075             fRunNumber,
1076             fFirstReqEvtNumber,
1077             fLastReqEvtNumber,
1078             fReqNbOfEvts,
1079             fStexName.Data(),
1080             fStexNumber,
1081             fStinEchaUser);
1082     sprintf(f_in_short,
1083             "%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageTotalNoise_c%d",
1084             fAnaType.Data(),
1085             fNbOfSamples,
1086             fRunNumber,
1087             fFirstReqEvtNumber,
1088             fLastReqEvtNumber,
1089             fReqNbOfEvts,
1090             fStexName.Data(),
1091             fStexNumber,
1092             fStinEchaUser);
1093   }
1094 
1095   if (i_code == fCodeLfCov) {
1096     sprintf(f_in,
1097             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cov",
1098             fCnaParPaths->ResultsAsciiFilePath().Data(),
1099             fAnaType.Data(),
1100             fNbOfSamples,
1101             fRunNumber,
1102             fFirstReqEvtNumber,
1103             fLastReqEvtNumber,
1104             fReqNbOfEvts,
1105             fStexName.Data(),
1106             fStexNumber);
1107     sprintf(f_in_short,
1108             "%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cov",
1109             fAnaType.Data(),
1110             fNbOfSamples,
1111             fRunNumber,
1112             fFirstReqEvtNumber,
1113             fLastReqEvtNumber,
1114             fReqNbOfEvts,
1115             fStexName.Data(),
1116             fStexNumber);
1117   }
1118 
1119   if (i_code == fCodeLfCor) {
1120     sprintf(f_in,
1121             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cor",
1122             fCnaParPaths->ResultsAsciiFilePath().Data(),
1123             fAnaType.Data(),
1124             fNbOfSamples,
1125             fRunNumber,
1126             fFirstReqEvtNumber,
1127             fLastReqEvtNumber,
1128             fReqNbOfEvts,
1129             fStexName.Data(),
1130             fStexNumber);
1131     sprintf(f_in_short,
1132             "%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cor",
1133             fAnaType.Data(),
1134             fNbOfSamples,
1135             fRunNumber,
1136             fFirstReqEvtNumber,
1137             fLastReqEvtNumber,
1138             fReqNbOfEvts,
1139             fStexName.Data(),
1140             fStexNumber);
1141   }
1142 
1143   if (i_code == fCodeAvPed) {
1144     sprintf(f_in,
1145             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragePedestals",
1146             fCnaParPaths->ResultsAsciiFilePath().Data(),
1147             fAnaType.Data(),
1148             fNbOfSamples,
1149             fRunNumber,
1150             fFirstReqEvtNumber,
1151             fLastReqEvtNumber,
1152             fReqNbOfEvts,
1153             fStexName.Data(),
1154             fStexNumber);
1155     sprintf(f_in_short,
1156             "%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragePedestals",
1157             fAnaType.Data(),
1158             fNbOfSamples,
1159             fRunNumber,
1160             fFirstReqEvtNumber,
1161             fLastReqEvtNumber,
1162             fReqNbOfEvts,
1163             fStexName.Data(),
1164             fStexNumber);
1165   }
1166 
1167   if (i_code == fCodeAvMeanCorss) {
1168     sprintf(f_in,
1169             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageMeanCorss%d",
1170             fCnaParPaths->ResultsAsciiFilePath().Data(),
1171             fAnaType.Data(),
1172             fNbOfSamples,
1173             fRunNumber,
1174             fFirstReqEvtNumber,
1175             fLastReqEvtNumber,
1176             fReqNbOfEvts,
1177             fStexName.Data(),
1178             fStexNumber,
1179             fStinEchaUser);
1180     sprintf(f_in_short,
1181             "%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageMeanCorss%d",
1182             fAnaType.Data(),
1183             fNbOfSamples,
1184             fRunNumber,
1185             fFirstReqEvtNumber,
1186             fLastReqEvtNumber,
1187             fReqNbOfEvts,
1188             fStexName.Data(),
1189             fStexNumber,
1190             fStinEchaUser);
1191   }
1192 
1193   if (i_code == fCodeAvSigCorss) {
1194     sprintf(f_in,
1195             "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageSigmaCorss%d",
1196             fCnaParPaths->ResultsAsciiFilePath().Data(),
1197             fAnaType.Data(),
1198             fNbOfSamples,
1199             fRunNumber,
1200             fFirstReqEvtNumber,
1201             fLastReqEvtNumber,
1202             fReqNbOfEvts,
1203             fStexName.Data(),
1204             fStexNumber,
1205             fStinEchaUser);
1206     sprintf(f_in_short,
1207             "%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageSigmaCorss%d",
1208             fAnaType.Data(),
1209             fNbOfSamples,
1210             fRunNumber,
1211             fFirstReqEvtNumber,
1212             fLastReqEvtNumber,
1213             fReqNbOfEvts,
1214             fStexName.Data(),
1215             fStexNumber,
1216             fStinEchaUser);
1217   }
1218 #endif  // OCOD
1219 
1220   //----------------------------------------------------------- (fMakeResultsFileName)
1221 
1222   // default:
1223   //    std::cout << "*TEcnaWrite::fMakeResultsFileName(const Int_t&  i_code)> "
1224   //     << "wrong header code , i_code = " << i_code << std::endl;
1225   //  }
1226 
1227   //======================================= f_name
1228 
1229   char* f_name = new char[fgMaxCar];
1230   fCnew++;
1231 
1232   for (Int_t i = 0; i < fgMaxCar; i++) {
1233     f_name[i] = '\0';
1234   }
1235 
1236   Int_t ii = 0;
1237   for (Int_t i = 0; i < fgMaxCar; i++) {
1238     if (f_in[i] != '\0') {
1239       f_name[i] = f_in[i];
1240       ii++;
1241     } else {
1242       break;
1243     }  // va directement a if ( ii+5 < fgMaxCar ) puis... f_name[ii] = '.';
1244   }
1245 
1246   if (ii + 5 < fgMaxCar) {
1247     //.......... writing of the file extension (.root or .ascii)  (fMakeResultsFileName)
1248 
1249     //------------------------------------------- extension .ascii
1250     if (i_code != fCodeRoot || i_code == fCodeNbOfEvts) {
1251       f_name[ii] = '.';
1252       f_name[ii + 1] = 'a';
1253       f_name[ii + 2] = 's';
1254       f_name[ii + 3] = 'c';
1255       f_name[ii + 4] = 'i';
1256       f_name[ii + 5] = 'i';
1257 
1258       fAsciiFileName = f_name;
1259     }
1260     //------------------------------------------- extension .root
1261     if (i_code == fCodeRoot) {
1262       f_name[ii] = '.';
1263       f_name[ii + 1] = 'r';
1264       f_name[ii + 2] = 'o';
1265       f_name[ii + 3] = 'o';
1266       f_name[ii + 4] = 't';
1267 
1268       fRootFileName = f_name;
1269     }
1270   } else {
1271     std::cout << "*TEcnaWrite::fMakeResultsFileName(...)> Name too long (for f_name)."
1272               << " No room enough for the extension. (ii = " << ii << ")" << fTTBELL << std::endl;
1273   }
1274 
1275   //====================================== f_name_short  (fMakeResultsFileName)
1276 
1277   char* f_name_short = new char[fgMaxCar];
1278   fCnew++;
1279 
1280   for (Int_t i = 0; i < fgMaxCar; i++) {
1281     f_name_short[i] = '\0';
1282   }
1283 
1284   ii = 0;
1285   for (Int_t i = 0; i < fgMaxCar; i++) {
1286     if (f_in_short[i] != '\0') {
1287       f_name_short[i] = f_in_short[i];
1288       ii++;
1289     } else {
1290       break;
1291     }  // va directement a f_name_short[ii] = '.';
1292   }
1293 
1294   if (ii + 5 < fgMaxCar) {
1295     //.......... writing of the file extension (.root or .ascii)
1296 
1297     //-------------------------------------------extension .ascii
1298     if (i_code != fCodeRoot || i_code == fCodeNbOfEvts) {
1299       f_name_short[ii] = '.';
1300       f_name_short[ii + 1] = 'a';
1301       f_name_short[ii + 2] = 's';
1302       f_name_short[ii + 3] = 'c';
1303       f_name_short[ii + 4] = 'i';
1304       f_name_short[ii + 5] = 'i';
1305 
1306       fAsciiFileNameShort = f_name_short;
1307     }
1308 
1309     //-------------------------------------------- extension .root
1310     if (i_code == fCodeRoot) {
1311       f_name_short[ii] = '.';
1312       f_name_short[ii + 1] = 'r';
1313       f_name_short[ii + 2] = 'o';
1314       f_name_short[ii + 3] = 'o';
1315       f_name_short[ii + 4] = 't';
1316 
1317       fRootFileNameShort = f_name_short;
1318     }
1319   } else {
1320     std::cout << "*TEcnaWrite::fMakeResultsFileName(...)> Name too long (for f_name_short)."
1321               << " No room enough for the extension. (ii = " << ii << ")" << fTTBELL << std::endl;
1322   }
1323   delete[] f_name;
1324   f_name = nullptr;
1325   fCdelete++;
1326   delete[] f_name_short;
1327   f_name_short = nullptr;
1328   fCdelete++;
1329 
1330   delete[] f_in;
1331   f_in = nullptr;
1332   fCdelete++;
1333   delete[] f_in_short;
1334   f_in_short = nullptr;
1335   fCdelete++;
1336 
1337 }  // end of fMakeResultsFileName
1338 
1339 //==========================================================================================
1340 //
1341 //
1342 //
1343 //==========================================================================================
1344 
1345 void TEcnaWrite::fAsciiFileWriteHeader(const Int_t& i_code) {
1346   //Ascii results file header writing  (private). Called by the WriteAscii...() methods
1347 
1348   //-----------------------------------------------
1349   //
1350   //     opening of the ASCII results file
1351   //     and writing of its header
1352   //
1353   //-----------------------------------------------
1354 
1355   if (fAsciiFileName.BeginsWith("$HOME")) {
1356     fAsciiFileName.Remove(0, 5);
1357     TString EndOfAsciiFileName = fAsciiFileName;
1358     const Text_t* t_file_nohome = (const Text_t*)EndOfAsciiFileName.Data();  //  const Text_t* -> EndOfAsciiFileName
1359     // ( /scratch0/cna/... )
1360     TString home_path = gSystem->Getenv("HOME");
1361     fAsciiFileName = home_path;            // fAsciiFileName = absolute HOME path ( /afs/cern.ch/u/USER )
1362     fAsciiFileName.Append(t_file_nohome);  // Append  (const Text_t* -> EndOfAsciiFileName) to fAsciiFileName
1363     // ( /afs/cern.ch/u/USER/scratch0/cna/... )
1364   }
1365 
1366   fFcout_f.open(fAsciiFileName.Data());
1367 
1368   fFcout_f << "*** File: " << fAsciiFileName << " *** " << std::endl << std::endl;
1369   fFcout_f << "*Analysis name                : " << fAnaType << std::endl;
1370   fFcout_f << "*First-Last samples           : 1 - " << fNbOfSamples << std::endl;
1371   fFcout_f << "*Run number                   : " << fRunNumber << std::endl;
1372   fFcout_f << "*First requested event number : " << fFirstReqEvtNumber << std::endl;
1373   fFcout_f << "*Last  requested event number : " << fLastReqEvtNumber << std::endl;
1374   fFcout_f << "*Requested number of events   : " << fReqNbOfEvts << std::endl;
1375   if (fFlagSubDet == "EB") {
1376     fFcout_f << "*SuperModule number           : " << fStexNumber << std::endl;
1377   }
1378   if (fFlagSubDet == "EE") {
1379     fFcout_f << "*Dee number                   : " << fStexNumber << std::endl;
1380   }
1381   fFcout_f << "*Date first requested event   : " << fStartDate;
1382   fFcout_f << "*Date last requested event    : " << fStopDate << std::endl;
1383   fFcout_f << std::endl;
1384 
1385   //=========================================================================
1386   //   closing of the results file if i_code = fCodeHeaderAscii only.
1387   //   closing is done in the fT1dWriteAscii() and fT2dWriteAscii() methods
1388   //   except for i_code = fCodeHeaderAscii
1389   //=========================================================================
1390   if (i_code == fCodeHeaderAscii) {
1391     fFcout_f.close();
1392   }
1393 }
1394 
1395 //=========================================================================
1396 //
1397 //         W R I T I N G   M E T H O D S :    R O O T    F I L E S
1398 //
1399 //    The root files are written by TEcnaRun since the arrays are computed
1400 //    by this class (arrays fT2d_..., fT1d_..) and are private attributes.
1401 //    No writing method in ROOT file here.
1402 //    Just the making of the file name
1403 //
1404 //=========================================================================
1405 
1406 //=========================================================================
1407 //
1408 //    W R I T I N G   M E T H O D S :    A S C I I    F I L E S
1409 //
1410 //    Ascii file are treated on the same footing as plots in the
1411 //    TEcnaHistos methods.
1412 //    The arrays are TVectorD or TMatrixD and are arguments of the
1413 //    writting methods (WriteAsciiHisto, fT2dWriteAscii)
1414 //
1415 //=========================================================================
1416 //
1417 //  In the following, we describe:
1418 //
1419 //     (1) The method which gets the path for the results ASCII files
1420 //         from a "cna-configuration" file
1421 //     (2) The codification for the names of the ASCII files
1422 //     (3) The methods which writes the results in the ASCII files
1423 //
1424 //
1425 //
1426 // (1)-----------> Method to set the path for the results ASCII files
1427 //
1428 //      void  MyCnaRun->GetPathForResultsAsciiFiles(pathname);
1429 //
1430 //            TString pathname = name of a "cna-config" file located
1431 //            in the user's HOME directory and containing one line which
1432 //            specifies the path where must be written the .ascii result files.
1433 //            (no slash at the end of the string)
1434 //
1435 //   DEFAULT:
1436 //            void  MyCnaRun->GetPathForResultsAsciiFiles();
1437 //            If there is no argument, the "cna-config" file must be named
1438 //            "path_results_ascii.ecna" and must be located in the user's HOME
1439 //            directory
1440 //
1441 //
1442 // (2)-----------> Codification for the names of the ASCII files (examples):
1443 //
1444 //       aaa_nnnS_Rrrr_fff_ttt_SMnnn_pedestals.ascii   OR  aaa_nnnS_Rrrr_fff_ttt_Deennn_pedestals.ascii
1445 //       aaa_nnnS_Rrrr_fff_ttt_SMnnn_HF_noise.ascii    OR  aaa_nnnS_Rrrr_fff_ttt_Deennn_HF_noise.ascii
1446 //       aaa_nnnS_Rrrr_fff_ttt_SMnnn_corss_cCCC.ascii  OR  aaa_nnnS_Rrrr_fff_ttt_Deennn_corss_cCCC.ascii
1447 //       etc...
1448 //
1449 //  with:
1450 //       aaa = Analysis name
1451 //       rrr = Run number
1452 //       fff = First requested event number
1453 //       ttt = Number of requested events
1454 //       CCC = Electronic Channel number in Stex
1455 //       nnn = SM number or Dee number
1456 //
1457 //  Examples:
1458 //       StdPed12_10S_R66689_1_50_SM1_pedestals.ascii
1459 //       StdPed6_10S_R66689_1_50_Dee3_cor_ss_c2234.ascii
1460 //
1461 //
1462 // (3)-----------> Methods which write the ASCII files:
1463 //
1464 //  The methods which write the ASCII files are the following:
1465 //
1466 //      void  WriteAsciiCovariancesBetweenSamples(Channel, MatrixSize, TMatrixD matrix);
1467 //      void  WriteAsciiCorrelationsBetweenSamples(Channel, MatrixSize, TMatrixD matrix);
1468 //      void  fT2dWriteAscii(code, px, py, MatrixSize, TMatrixD matrix) [private]
1469 //      void  WriteAsciiHisto(CodeHisto, HistoSize, TVectorD histo)
1470 //
1471 //  Each of these methods corresponds to a "calculation method" of TEcnaRun.
1472 //  The calculation method of TEcnaRun must have been been called before
1473 //  using the writing method of TEcnaWrite.
1474 //==========================================================================================
1475 
1476 //-------------------------------------------------------------------------------------------
1477 //
1478 //          WriteAsciiHisto()
1479 //
1480 //          Stex = SM or Dee , Stin = Tower or SC
1481 //
1482 //-------------------------------------------------------------------------------------------
1483 void TEcnaWrite::WriteAsciiHisto(const TString& HistoCode, const Int_t& HisSize, const TVectorD& read_histo) {
1484   //Write histo with correspondance CNA-channel <-> xtal number in SM or Dee
1485 
1486   // BuildCrysTable() is called in the method Init() which is called by the constructor
1487 
1488   Int_t i_code = fCodeNbOfEvts;
1489 
1490   //--------------------------------------------------------------------------------
1491   if (HistoCode == "D_NOE_ChNb") {
1492     i_code = fCodeNbOfEvts;
1493   }
1494   if (HistoCode == "D_Ped_ChNb") {
1495     i_code = fCodePed;
1496   }
1497   if (HistoCode == "D_TNo_ChNb") {
1498     i_code = fCodeTno;
1499   }
1500   if (HistoCode == "D_LFN_ChNb") {
1501     i_code = fCodeLfn;
1502   }
1503   if (HistoCode == "D_HFN_ChNb") {
1504     i_code = fCodeHfn;
1505   }
1506   if (HistoCode == "D_MCs_ChNb") {
1507     i_code = fCodeMeanCorss;
1508   }
1509   if (HistoCode == "D_SCs_ChNb") {
1510     i_code = fCodeSigCorss;
1511   }
1512 
1513   fMakeResultsFileName(i_code);   // => Making of the results .ascii file name
1514   fAsciiFileWriteHeader(i_code);  // => Open of the file associated with stream fFcout_f
1515 
1516   //..................................... format numerical values
1517   fFcout_f << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1518   fFcout_f << std::setprecision(3) << std::setw(6);
1519   fFcout_f.setf(std::ios::dec, std::ios::basefield);
1520   fFcout_f.setf(std::ios::fixed, std::ios::floatfield);
1521   fFcout_f.setf(std::ios::left, std::ios::adjustfield);
1522   fFcout_f.setf(std::ios::right, std::ios::adjustfield);
1523 
1524   std::cout << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1525   std::cout << std::setprecision(3) << std::setw(6);
1526   std::cout.setf(std::ios::dec, std::ios::basefield);
1527   std::cout.setf(std::ios::fixed, std::ios::floatfield);
1528   std::cout.setf(std::ios::left, std::ios::adjustfield);
1529   std::cout.setf(std::ios::right, std::ios::adjustfield);
1530 
1531   //........................................................ WriteAsciiHisto
1532   TString aStexName;
1533   Int_t MaxCar = fgMaxCar;
1534   aStexName.Resize(MaxCar);
1535   aStexName = "SM or Dee?";
1536 
1537   TString aStinName;
1538   MaxCar = fgMaxCar;
1539   aStinName.Resize(MaxCar);
1540   aStinName = "Tower or SC?";
1541 
1542   TString aHoco;
1543   MaxCar = fgMaxCar;
1544   aHoco.Resize(MaxCar);
1545   aHoco = "Eta or IX?";
1546 
1547   TString aVeco;
1548   MaxCar = fgMaxCar;
1549   aVeco.Resize(MaxCar);
1550   aVeco = "Phi or IY?";
1551 
1552   TString aSpecifa;
1553   MaxCar = fgMaxCar;
1554   aSpecifa.Resize(MaxCar);
1555   aSpecifa = " ";
1556 
1557   TString aSpecifc;
1558   MaxCar = fgMaxCar;
1559   aSpecifc.Resize(MaxCar);
1560   aSpecifc = " ";
1561 
1562   TString aSpecifd;
1563   MaxCar = fgMaxCar;
1564   aSpecifd.Resize(MaxCar);
1565   aSpecifd = " ";
1566 
1567   TString aSpecife;
1568   MaxCar = fgMaxCar;
1569   aSpecife.Resize(MaxCar);
1570   aSpecife = " ";
1571 
1572   TString aSpecif1;
1573   MaxCar = fgMaxCar;
1574   aSpecif1.Resize(MaxCar);
1575   aSpecif1 = " ";
1576 
1577   TString aSpecif2;
1578   MaxCar = fgMaxCar;
1579   aSpecif2.Resize(MaxCar);
1580   aSpecif2 = " ";
1581 
1582   if (fFlagSubDet == "EB") {
1583     aStexName = "SM   ";
1584     aStinName = "tower";
1585     aSpecifa = " channel# ";
1586     aHoco = "   Eta    ";
1587     aVeco = "   Phi    ";
1588     aSpecifc = " channel# ";
1589     aSpecifd = " crystal# ";
1590     aSpecife = "SM    ";
1591   }
1592   if (fFlagSubDet == "EE") {
1593     aStexName = "Dee  ";
1594     aStinName = " SC  ";
1595     aSpecifa = "  Sector# ";
1596     aHoco = "   IX     ";
1597     aVeco = "   IY     ";
1598     aSpecifc = " crystal# ";
1599     aSpecifd = "   SC #   ";
1600     aSpecife = "Sector";
1601   }
1602 
1603   //.............................................................. WriteAsciiHisto
1604   for (Int_t i0StexEcha = 0; i0StexEcha < HisSize; i0StexEcha++) {
1605     Int_t n1StexStin = 0;
1606     Int_t StexStinEcna = 0;
1607     Int_t i0StinEcha = 0;
1608     Int_t n1StinEcha = 0;
1609     Int_t n1StexCrys = 0;
1610     Int_t n1DataSector = 0;
1611     Int_t n1SCinDS = 0;
1612 
1613     if (fFlagSubDet == "EB") {
1614       n1StexStin = fEcalNumbering->Get1SMTowFrom0SMEcha(i0StexEcha);
1615       StexStinEcna = n1StexStin;
1616       i0StinEcha = fEcalNumbering->Get0TowEchaFrom0SMEcha(i0StexEcha);
1617       n1StexCrys = fEcalNumbering->Get1SMCrysFrom1SMTowAnd0TowEcha(n1StexStin, i0StinEcha);
1618     }
1619     if (fFlagSubDet == "EE") {
1620       StexStinEcna = fEcalNumbering->Get1DeeSCEcnaFrom0DeeEcha(i0StexEcha);
1621       n1DataSector = fEcalNumbering->GetDSFrom1DeeSCEcna(fStexNumber, StexStinEcna);
1622       n1SCinDS = fEcalNumbering->GetDSSCFrom1DeeSCEcna(fStexNumber, StexStinEcna);
1623       n1StexStin = fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, StexStinEcna);
1624       n1StinEcha = fEcalNumbering->Get1SCEchaFrom0DeeEcha(i0StexEcha);
1625     }
1626 
1627     if (n1StexStin > 0) {
1628       if ((fFlagSubDet == "EB" && i0StinEcha == 0) || (fFlagSubDet == "EE" && n1StinEcha == 1)) {
1629         if (HistoCode == "D_NOE_ChNb") {
1630           aSpecif1 = "Number of";
1631           aSpecif2 = "     events (requested)";
1632         }
1633         if (HistoCode == "D_Ped_ChNb") {
1634           aSpecif1 = "Pedestals";
1635           aSpecif2 = "             ";
1636         }
1637         if (HistoCode == "D_TNo_ChNb") {
1638           aSpecif1 = "   Total ";
1639           aSpecif2 = "   noise     ";
1640         }
1641         if (HistoCode == "D_MCs_ChNb") {
1642           aSpecif1 = "    Mean ";
1643           aSpecif2 = "   cor(s,s)  ";
1644         }
1645         if (HistoCode == "D_LFN_ChNb") {
1646           aSpecif1 = "   Low Fq";
1647           aSpecif2 = "   noise     ";
1648         }
1649         if (HistoCode == "D_HFN_ChNb") {
1650           aSpecif1 = "  High Fq";
1651           aSpecif2 = "   noise     ";
1652         }
1653         if (HistoCode == "D_SCs_ChNb") {
1654           aSpecif1 = " Sigma of";
1655           aSpecif2 = "   cor(s,s)  ";
1656         }
1657 
1658         fFcout_f << std::endl;
1659 
1660         fFcout_f << aSpecifa.Data() << "  " << aStinName.Data() << "#   " << aSpecifc.Data() << aSpecifd.Data()
1661                  << aHoco.Data() << aVeco.Data() << aSpecif1.Data() << std::endl;
1662 
1663         fFcout_f << "  in " << aStexName.Data() << "  in " << aStexName.Data() << "  in " << aStinName.Data() << "  in "
1664                  << aSpecife.Data() << "  in " << aStexName.Data() << "  in " << aStexName.Data() << aSpecif2.Data()
1665                  << std::endl
1666                  << std::endl;
1667       }
1668 
1669       Double_t value = read_histo(i0StexEcha);
1670 
1671       if (fFlagSubDet == "EB") {
1672         fFcout_f << std::setw(7) << i0StexEcha << std::setw(8) << n1StexStin << std::setw(11)
1673                  << i0StinEcha  // (Electronic channel number in tower)
1674                  << std::setw(10) << n1StexCrys << std::setw(10)
1675                  << (Int_t)fEcalNumbering->GetEta(fStexNumber, StexStinEcna, i0StinEcha) << std::setw(10)
1676                  << (Int_t)fEcalNumbering->GetPhiInSM(fStexNumber, StexStinEcna, i0StinEcha);
1677       }
1678       if (fFlagSubDet == "EE") {
1679         Int_t n1StinEcha_m = n1StinEcha - 1;
1680         fFcout_f << std::setw(7) << n1DataSector << std::setw(8) << n1StexStin << std::setw(11)
1681                  << n1StinEcha  // (Xtal number for construction in SC)
1682                  << std::setw(10) << n1SCinDS << std::setw(10)
1683                  << fEcalNumbering->GetIXCrysInDee(fStexNumber, StexStinEcna, n1StinEcha_m) << std::setw(10)
1684                  << fEcalNumbering->GetJYCrysInDee(fStexNumber, StexStinEcna, n1StinEcha_m);
1685       }
1686 
1687       if (HistoCode == "D_NOE_ChNb") {
1688         Int_t ivalue = (Int_t)value;
1689         fFcout_f << std::setw(13) << ivalue;
1690         fFcout_f << std::setw(4) << "(" << std::setw(6) << fReqNbOfEvts << ")";
1691       } else {
1692         fFcout_f << std::setw(13) << value;
1693       }
1694 
1695       fFcout_f << std::endl;
1696     }
1697   }  // end of loop:  for (Int_t i0StexEcha=0; i0StexEcha<HisSize; i0StexEcha++)
1698 
1699   fFcout_f.close();
1700 
1701   // if(fFlagPrint != fCodePrintNoComment)
1702   // {
1703   std::cout << "*TEcnaWrite::WriteAsciiHisto(...)> INFO: "
1704             << "histo has been written in file: " << std::endl
1705             << "            " << fAsciiFileName.Data() << std::endl;
1706   // }
1707 }  // end of TEcnaWrite::WriteAsciiHisto
1708 
1709 //================================================================================
1710 //
1711 //        W R I T I N G  O F  T H E   C O V   A N D   C O R  M A T R I C E S
1712 //
1713 //================================================================================
1714 
1715 //--------------------------------------------------------------------------------
1716 //
1717 //      Writing of the covariances between samples
1718 //      for a given StexEcha in an ASCII file
1719 //
1720 //--------------------------------------------------------------------------------
1721 void TEcnaWrite::WriteAsciiCovariancesBetweenSamples(const Int_t& user_StexStin,
1722                                                      const Int_t& user_StinEcha,
1723                                                      const Int_t& MatSize,
1724                                                      const TMatrixD& read_matrix) {
1725   //Writing of the covariances between samples for a given StexEcha in an ASCII file
1726 
1727   if (fFlagSubDet == "EB") {
1728     fStexStinUser = user_StexStin;
1729   }
1730   if (fFlagSubDet == "EE") {
1731     fStexStinUser = fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, user_StexStin);
1732   }
1733 
1734   if (fFlagSubDet == "EB") {
1735     fStinEchaUser = user_StinEcha;
1736   }
1737   if (fFlagSubDet == "EE") {
1738     fStinEchaUser = user_StinEcha + 1;
1739   }
1740 
1741   Int_t i_code = fCodeCovCss;  // code for covariances between samples
1742   fMakeResultsFileName(i_code);
1743   fAsciiFileWriteHeader(i_code);
1744 
1745   Int_t i_pasx = fSectSampSizeX;
1746   Int_t i_pasy = fSectSampSizeY;
1747 
1748   fT2dWriteAscii(i_code, i_pasx, i_pasy, MatSize, read_matrix);
1749 }
1750 
1751 //---------------------------------------------------------------------------------
1752 //
1753 //   Writing of the correlations between samples
1754 //   for a given StexEcha in an ASCII file
1755 //
1756 //---------------------------------------------------------------------------------
1757 void TEcnaWrite::WriteAsciiCorrelationsBetweenSamples(const Int_t& user_StexStin,
1758                                                       const Int_t& user_StinEcha,
1759                                                       const Int_t& MatSize,
1760                                                       const TMatrixD& read_matrix) {
1761   //Writing of the correlations between samples for a given StexEcha in an ASCII file
1762 
1763   if (fFlagSubDet == "EB") {
1764     fStexStinUser = user_StexStin;
1765   }
1766   if (fFlagSubDet == "EE") {
1767     fStexStinUser = fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, user_StexStin);
1768   }
1769 
1770   if (fFlagSubDet == "EB") {
1771     fStinEchaUser = user_StinEcha;
1772   }
1773   if (fFlagSubDet == "EE") {
1774     fStinEchaUser = user_StinEcha + 1;
1775   }
1776 
1777   Int_t i_code = fCodeCorCss;  // code for correlations between samples
1778   fMakeResultsFileName(i_code);
1779   fAsciiFileWriteHeader(i_code);
1780 
1781   Int_t i_pasx = fSectSampSizeX;
1782   Int_t i_pasy = fSectSampSizeY;
1783 
1784   fT2dWriteAscii(i_code, i_pasx, i_pasy, MatSize, read_matrix);
1785 }
1786 
1787 //----------------------------------------------------------------------
1788 //
1789 //            fT2dWriteAscii: Array 2D of (n_sctx , n_scty) sectors
1790 //                            of size: i_pasx_arg * i_pasy_arg
1791 //
1792 //                       (private)
1793 //
1794 //----------------------------------------------------------------------
1795 
1796 void TEcnaWrite::fT2dWriteAscii(const Int_t& i_code,
1797                                 const Int_t& i_pasx_arg,
1798                                 const Int_t& i_pasy_arg,
1799                                 const Int_t& MatSize,
1800                                 const TMatrixD& read_matrix) {
1801   //Writing of a matrix by sectors (private)
1802 
1803   Int_t i_pasx = i_pasx_arg;  // taille secteur en x
1804   Int_t i_pasy = i_pasy_arg;  // taille secteur en y
1805 
1806   //------------ formatage des nombres en faisant appel a la classe ios
1807 
1808   fFcout_f << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1809   fFcout_f.setf(std::ios::dec, std::ios::basefield);
1810   fFcout_f.setf(std::ios::fixed, std::ios::floatfield);
1811   fFcout_f.setf(std::ios::left, std::ios::adjustfield);
1812   fFcout_f.setf(std::ios::right, std::ios::adjustfield);
1813   fFcout_f << std::setprecision(3) << std::setw(6);
1814 
1815   std::cout << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1816   std::cout.setf(std::ios::dec, std::ios::basefield);
1817   std::cout.setf(std::ios::fixed, std::ios::floatfield);
1818   std::cout.setf(std::ios::left, std::ios::adjustfield);
1819   std::cout.setf(std::ios::right, std::ios::adjustfield);
1820   std::cout << std::setprecision(3) << std::setw(6);
1821 
1822   //--------------------- fin du formatage standard C++ -------------------
1823 
1824   //-----------------------------------------------------------------------
1825   //  Reservation dynamique d'un array Double_t** de dimensions
1826   //  les multiples de 5 juste au-dessus des dimensions de l'array 2D
1827   //  a ecrire ( array de dimensions
1828   //  (fEcal->MaxSampADC(),fEcal->MaxSampADC())
1829   //  (fEcal->MaxCrysEcnaInStex(),fEcal->MaxCrysEcnaInStex()) )
1830   //-----------------------------------------------------------------------
1831   // Determination des tailles multiples de fSectChanSizeX ou fSectSampSizeX
1832 
1833 #define NOUC
1834 #ifndef NOUC
1835 
1836   //*************** channels *************
1837   Int_t justap_chan = 0;
1838 
1839   if (fEcal->MaxCrysEcnaInStex() % fSectChanSizeX == 0) {
1840     justap_chan = fEcal->MaxCrysEcnaInStex();
1841   } else {
1842     justap_chan = ((fEcal->MaxCrysEcnaInStex() / fSectChanSizeX) + 1) * fSectChanSizeX;
1843   }
1844 
1845   //....................... Allocation fjustap_2d_cc
1846 
1847   if (i_code == fCodeHfCov || i_code == fCodeHfCor || i_code == fCodeLfCov || i_code == fCodeLfCor) {
1848     if (fjustap_2d_cc == 0) {
1849       //................... Allocation
1850       fjustap_2d_cc = new Double_t*[justap_chan];
1851       fCnew++;
1852       fjustap_1d_cc = new Double_t[justap_chan * justap_chan];
1853       fCnew++;
1854       for (Int_t i = 0; i < justap_chan; i++) {
1855         fjustap_2d_cc[i] = &fjustap_1d_cc[0] + i * justap_chan;
1856       }
1857     }
1858 
1859     //............................... Transfert des valeurs dans fjustap_2d_cc  (=init)
1860     for (Int_t i = 0; i < fEcal->MaxCrysEcnaInStex(); i++) {
1861       for (Int_t j = 0; j < fEcal->MaxCrysEcnaInStex(); j++) {
1862         if (i_code == fCodeHfCov) {
1863           fjustap_2d_cc[i][j] = read_matrix(i, j);
1864         }
1865         if (i_code == fCodeHfCor) {
1866           fjustap_2d_cc[i][j] = read_matrix(i, j);
1867         }
1868         if (i_code == fCodeLfCov) {
1869           fjustap_2d_cc[i][j] = read_matrix(i, j);
1870         }
1871         if (i_code == fCodeLfCor) {
1872           fjustap_2d_cc[i][j] = read_matrix(i, j);
1873         }
1874       }
1875     }
1876 
1877     //.......................... mise a zero du reste de la matrice (=init)
1878     for (Int_t i = fEcal->MaxCrysEcnaInStex(); i < justap_chan; i++) {
1879       for (Int_t j = fEcal->MaxCrysEcnaInStex(); j < justap_chan; j++) {
1880         fjustap_2d_cc[i][j] = (Double_t)0.;
1881       }
1882     }
1883   }
1884 
1885 #endif  //NOUC
1886 
1887   //************************************ Samples ***************************
1888   Int_t justap_samp = 0;
1889 
1890   if (fEcal->MaxSampADC() % fSectSampSizeX == 0) {
1891     justap_samp = fEcal->MaxSampADC();
1892   } else {
1893     justap_samp = ((fEcal->MaxSampADC() / fSectSampSizeX) + 1) * fSectSampSizeX;
1894   }
1895 
1896   //....................... allocation fjustap_2d_ss
1897 
1898   if (i_code == fCodeCovCss || i_code == fCodeCorCss || i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss) {
1899     if (fjustap_2d_ss == nullptr) {
1900       //................... Allocation
1901       fjustap_2d_ss = new Double_t*[justap_samp];
1902       fCnew++;
1903       fjustap_1d_ss = new Double_t[justap_samp * justap_samp];
1904       fCnew++;
1905       for (Int_t i = 0; i < justap_samp; i++) {
1906         fjustap_2d_ss[i] = &fjustap_1d_ss[0] + i * justap_samp;
1907       }
1908     }
1909 
1910     //.............................. Transfert des valeurs dans fjustap_2d_ss (=init)
1911     for (Int_t i = 0; i < fEcal->MaxSampADC(); i++) {
1912       for (Int_t j = 0; j < fEcal->MaxSampADC(); j++) {
1913         if (i_code == fCodeCovCss) {
1914           fjustap_2d_ss[i][j] = read_matrix(i, j);
1915         }
1916         if (i_code == fCodeCorCss) {
1917           fjustap_2d_ss[i][j] = read_matrix(i, j);
1918         }
1919         if (i_code == fCodeAvMeanCorss) {
1920           fjustap_2d_ss[i][j] = read_matrix(i, j);
1921         }
1922         if (i_code == fCodeAvSigCorss) {
1923           fjustap_2d_ss[i][j] = read_matrix(i, j);
1924         }
1925       }
1926     }
1927 
1928     //.......................... mise a zero du reste de la matrice (=init)
1929     for (Int_t i = fEcal->MaxSampADC(); i < justap_samp; i++) {
1930       for (Int_t j = fEcal->MaxSampADC(); j < justap_samp; j++) {
1931         fjustap_2d_ss[i][j] = (Double_t)0.;
1932       }
1933     }
1934   }
1935 
1936   //..................... impressions + initialisations selon i_code
1937 
1938   Int_t isx_max = 0;
1939   Int_t isy_max = 0;
1940 
1941 #define COCC
1942 #ifndef COCC
1943   if (i_code == fCodeHfCov) {
1944     fFcout_f << "Covariance matrix between channels "
1945              << "for sample number " << fUserSamp;
1946     isx_max = justap_chan;
1947     isy_max = justap_chan;
1948   }
1949   if (i_code == fCodeHfCor) {
1950     fFcout_f << "*Correlation matrix between channels "
1951              << "for sample number " << fUserSamp;
1952     isx_max = justap_chan;
1953     isy_max = justap_chan;
1954   }
1955 
1956   if (i_code == fCodeLfCov) {
1957     fFcout_f << "Covariance matrix between channels "
1958              << "averaged on the samples ";
1959     isx_max = justap_chan;
1960     isy_max = justap_chan;
1961   }
1962   if (i_code == fCodeLfCor) {
1963     fFcout_f << "Correlation matrix between channels "
1964              << "averaged on the samples ";
1965     isx_max = justap_chan;
1966     isy_max = justap_chan;
1967   }
1968 #endif  // COCC
1969 
1970   Int_t n1StexStin = 0;
1971   Int_t i0StinEcha = 0;
1972   Int_t n1StinEcha = 0;
1973 
1974   if (fFlagSubDet == "EB") {
1975     n1StexStin = fStexStinUser;
1976     i0StinEcha = fEcalNumbering->Get0TowEchaFrom0SMEcha(fStinEchaUser);
1977   }
1978   if (fFlagSubDet == "EE") {
1979     n1StexStin = fStexStinUser;
1980     Int_t fStinEchaUser_m = fStinEchaUser - 1;
1981     n1StinEcha = fEcalNumbering->Get1SCEchaFrom0DeeEcha(fStinEchaUser_m);
1982 
1983     TString sDeeDir = fEcalNumbering->GetDeeDirViewedFromIP(fStexNumber);
1984   }
1985 
1986   if (i_code == fCodeCovCss) {
1987     if (fFlagSubDet == "EB") {
1988       fFcout_f << "Covariance matrix between samples "
1989                << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
1990                << fStinName << ": " << i0StinEcha << ")";
1991     }
1992     if (fFlagSubDet == "EE") {
1993       fFcout_f << "Covariance matrix between samples "
1994                << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
1995                << fStinName << ": " << n1StinEcha << ")";
1996     }
1997     isx_max = justap_samp;
1998     isy_max = justap_samp;
1999   }
2000   if (i_code == fCodeCorCss) {
2001     if (fFlagSubDet == "EB") {
2002       fFcout_f << "Correlation matrix between samples "
2003                << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
2004                << fStinName << ": " << i0StinEcha << ")";
2005     }
2006     if (fFlagSubDet == "EE") {
2007       fFcout_f << "Correlation matrix between samples "
2008                << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
2009                << fStinName << ": " << n1StinEcha << ")";
2010     }
2011     isx_max = justap_samp;
2012     isy_max = justap_samp;
2013   }
2014 
2015   if (i_code == fCodeAvMeanCorss) {
2016     if (fFlagSubDet == "EB") {
2017       fFcout_f << "Correction factors to the covariances "
2018                << "between samples for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin
2019                << " , channel in " << fStinName << ": " << i0StinEcha << ")";
2020     }
2021     if (fFlagSubDet == "EE") {
2022       fFcout_f << "Correction factors to the covariances "
2023                << "between samples for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin
2024                << " , channel in " << fStinName << ": " << n1StinEcha << ")";
2025     }
2026     isx_max = justap_samp;
2027     isy_max = justap_samp;
2028   }
2029 
2030   if (i_code == fCodeAvSigCorss) {
2031     if (fFlagSubDet == "EB") {
2032       fFcout_f << "Correction factors to the correlations "
2033                << "between samples for channel number " << fStinEchaUser << " ( " << fStinName << ": " << n1StexStin
2034                << " , channel in " << fStinName << ": " << i0StinEcha << ")";
2035     }
2036     if (fFlagSubDet == "EE") {
2037       fFcout_f << "Correction factors to the correlations "
2038                << "between samples for channel number " << fStinEchaUser << " ( " << fStinName << ": " << n1StexStin
2039                << " , channel in " << fStinName << ": " << n1StinEcha << ")";
2040     }
2041     isx_max = justap_samp;
2042     isy_max = justap_samp;
2043   }
2044 
2045   fFcout_f << std::endl;
2046 
2047   //............... Calcul des nombres de secteurs selon x
2048   //                i_pasx  = taille secteur en x
2049   //                isx_max = taille de la matrice en x
2050   //                n_sctx  = nombre de secteurs en x
2051   //
2052   if (i_pasx > isx_max) {
2053     i_pasx = isx_max;
2054   }
2055   Int_t n_sctx = 1;
2056   Int_t max_verix;
2057   if (i_pasx > 0) {
2058     n_sctx = isx_max / i_pasx;
2059   }
2060   max_verix = n_sctx * i_pasx;
2061   if (max_verix < isx_max) {
2062     n_sctx++;
2063   }
2064 
2065   //............... Calcul des nombres de secteurs selon y
2066   //                i_pasy  = taille secteur en y
2067   //                isy_max = taille de la matrice en y
2068   //                n_scty  = nombre de secteurs en x
2069   //
2070   if (i_pasy > isy_max) {
2071     i_pasy = isy_max;
2072   }
2073   Int_t n_scty = 1;
2074   Int_t max_veriy;
2075   if (i_pasy > 0) {
2076     n_scty = isy_max / i_pasy;
2077   }
2078   max_veriy = n_scty * i_pasy;
2079   if (max_veriy < isy_max) {
2080     n_scty++;
2081   }
2082 
2083 #define NBSC
2084 #ifndef NBSC
2085   //................ Ecriture de la taille et du nombre des secteurs
2086   if (i_code == fCodeCovCss || i_code == fCodeCorCss || i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss) {
2087     fFcout_f << "sector size = " << fSectSampSizeX << " , number of sectors = " << n_sctx << " x " << n_scty << endl;
2088   }
2089   if (i_code == fCodeHfCov || i_code == fCodeHfCor || i_code == fCodeLfCov || i_code == fCodeLfCor) {
2090     fFcout_f << "sector size = " << fSectChanSizeX << " , number of sectors = " << n_sctx << " x " << n_scty
2091              << std::endl;
2092   }
2093 #endif  // NBSC
2094 
2095   fFcout_f << std::endl;
2096 
2097   //............... impression matrice par secteurs i_pas x i_pas
2098   //........................... boucles pour display des secteurs
2099   Int_t ix_inf = -i_pasx;
2100 
2101   for (Int_t nsx = 0; nsx < n_sctx; nsx++) {
2102     //......................... calcul limites secteur
2103     ix_inf = ix_inf + i_pasx;
2104     Int_t ix_sup = ix_inf + i_pasx;
2105 
2106     Int_t iy_inf = -i_pasy;
2107 
2108     for (Int_t nsy = 0; nsy < n_scty; nsy++) {
2109       iy_inf = iy_inf + i_pasy;
2110       Int_t iy_sup = iy_inf + i_pasy;
2111 
2112       //......................... display du secteur (nsx,nsy)
2113 
2114       if (i_code == fCodeHfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss) {
2115         fFcout_f << "        ";
2116       }
2117       if (i_code == fCodeHfCor || i_code == fCodeCorCss) {
2118         fFcout_f << "      ";
2119       }
2120 
2121       for (Int_t iy_c = iy_inf; iy_c < iy_sup; iy_c++) {
2122         if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss ||
2123             i_code == fCodeAvSigCorss) {
2124           fFcout_f.width(8);
2125         }
2126         if (i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss) {
2127           fFcout_f.width(6);
2128         }
2129         fFcout_f << iy_c << "  ";
2130       }
2131       fFcout_f << std::endl << std::endl;
2132 
2133       for (Int_t ix_c = ix_inf; ix_c < ix_sup; ix_c++) {
2134         if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss ||
2135             i_code == fCodeAvSigCorss) {
2136           fFcout_f.width(8);
2137         }
2138         if (i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss) {
2139           fFcout_f.width(6);
2140         }
2141         fFcout_f << ix_c << "   ";
2142 
2143         for (Int_t iy_c = iy_inf; iy_c < iy_sup; iy_c++) {
2144           if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss ||
2145               i_code == fCodeAvSigCorss) {
2146             fFcout_f.width(8);
2147           }
2148 
2149           if (i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss) {
2150             fFcout_f.width(6);
2151           }
2152 
2153           if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeHfCor) {
2154             fFcout_f << fjustap_2d_cc[ix_c][iy_c] << "  ";
2155           }
2156 
2157           if (i_code == fCodeCovCss || i_code == fCodeCorCss || i_code == fCodeAvMeanCorss ||
2158               i_code == fCodeAvSigCorss) {
2159             fFcout_f << fjustap_2d_ss[ix_c][iy_c] << "  ";
2160           }
2161         }
2162         fFcout_f << std::endl;
2163       }
2164       fFcout_f << std::endl;
2165     }
2166   }
2167 
2168   //........... closing of the results file
2169 
2170   fFcout_f.close();
2171 
2172   if (fFlagPrint != fCodePrintNoComment) {
2173     std::cout << "*TEcnaWrite::fT2dWriteAscii(....)> INFO: "
2174               << "matrix has been written in file: " << std::endl
2175               << "            " << fAsciiFileName.Data() << std::endl;
2176   }
2177 
2178 }  // end of TEcnaWrite::fT2dWriteAscii
2179 
2180 //=========================================================================
2181 //
2182 //   ci-dessous: ===> methodes a implementer plus tard?
2183 //
2184 //=========================================================================
2185 #define WASC
2186 #ifndef WASC
2187 //------------------------------------------------------------
2188 //
2189 //      Writing of the expectation values in an ASCII file
2190 //
2191 //------------------------------------------------------------
2192 
2193 void TEcnaWrite::WriteAsciiSampleMeans() {
2194   //Writing of the expectation values in an ASCII file
2195 
2196   Int_t i_code = fCodeMSp;
2197   fMakeResultsFileName(i_code);
2198   fAsciiFileWriteHeader(i_code);
2199 
2200   Int_t i_lic1 = fNbChanByLine;
2201   Int_t i_lic2 = fNbSampByLine;
2202 
2203   fT1dWriteAscii(i_code, i_lic1, i_lic2);
2204 }
2205 
2206 //-------------------------------------------------------
2207 //
2208 //      Writing of the sigmas in an ASCII file
2209 //
2210 //-------------------------------------------------------
2211 
2212 void TEcnaWrite::WriteAsciiSampleSigmas() {
2213   //Writing of the variances in an ASCII file
2214 
2215   Int_t i_code = fCodeVar;  // code for variance
2216   fMakeResultsFileName(i_code);
2217   fAsciiFileWriteHeader(i_code);
2218 
2219   Int_t i_lic1 = fNbChanByLine;
2220   Int_t i_lic2 = fNbSampByLine;
2221 
2222   fT1dWriteAscii(i_code, i_lic1, i_lic2);
2223 }
2224 #endif  // WASC