CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/src/TEcnaWrite.cc

Go to the documentation of this file.
00001 //---------Author's Name: B.Fabbro DSM/IRFU/SPP CEA-Saclay
00002 //----------Copyright: Those valid for CEA sofware
00003 //----------Modified: 29/03/2010
00004 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaWrite.h"
00005 
00006 ClassImp(TEcnaWrite)
00007 //______________________________________________________________________________
00008 //
00009 // TEcnaWrite.
00010 //
00011 //------------------------------------------------------------------------
00012 //
00013 //        For more details on other classes of the CNA package:
00014 //
00015 //                 http://www.cern.ch/cms-fabbro/cna
00016 //
00017 //------------------------------------------------------------------------
00018 //
00019 
00020 //--------------------------- TEcnaWrite.cc -------------------------------
00021 //  
00022 //   Creation (first version): 19 May 2005
00023 //
00024 //   For questions or comments, please send e-mail to Bernard Fabbro:
00025 //             
00026 //   fabbro@hep.saclay.cea.fr 
00027 //
00028 //------------------------------------------------------------------------
00029 
00030   TEcnaWrite::~TEcnaWrite()
00031 {
00032   //destructor
00033   
00034   //if (fEcal          != 0){delete fEcal;          fCdelete++;}
00035   //if (fEcalNumbering != 0){delete fEcalNumbering; fCdelete++;}
00036   //if (fCnaParPaths   != 0){delete fCnaParPaths;   fCdelete++;}
00037   //if (fCnaParCout    != 0){delete fCnaParCout;    fCdelete++;}
00038   
00039   // cout << "[Info Management] CLASS: TEcnaWrite.         DESTROY OBJECT: this = " << this << endl;
00040 }
00041 
00042 //===================================================================
00043 //
00044 //                   Constructors
00045 //
00046 //===================================================================
00047 TEcnaWrite::TEcnaWrite()
00048 {
00049 
00050  // cout << "[Info Management] CLASS: TEcnaWrite.         CREATE OBJECT: this = " << this << endl;
00051 
00052   Init();
00053 }
00054 
00055 TEcnaWrite::TEcnaWrite(const TString SubDet,
00056                      const TEcnaParPaths*    pCnaParPaths, 
00057                      const TEcnaParCout*     pCnaParCout,
00058                      const TEcnaParEcal* pEcal,
00059                      const TEcnaNumbering*  pEcalNumbering)
00060 {
00061 
00062  // cout << "[Info Management] CLASS: TEcnaWrite.         CREATE OBJECT: this = " << this << endl;
00063 
00064   Init();
00065 
00066   //----------------------------- Object management
00067   fCnaParPaths = 0;
00068   if( pCnaParPaths == 0 )
00069     {fCnaParPaths = new TEcnaParPaths();  /*fCnew++*/ ;}
00070   else
00071     {fCnaParPaths = (TEcnaParPaths*)pCnaParPaths;}
00072 
00073   fCnaParCout  = 0;
00074   if( pCnaParCout == 0 )
00075     {fCnaParCout  = new TEcnaParCout();   /*fCnew++*/;}
00076   else
00077     {fCnaParCout = (TEcnaParCout*)pCnaParCout;}
00078 
00079   fEcal = 0;
00080   if( pEcal == 0 )
00081     {fEcal = new TEcnaParEcal(SubDet.Data());  /*fCnew++*/;}
00082   else
00083     {fEcal = (TEcnaParEcal*)pEcal;}
00084 
00085   fEcalNumbering = 0;
00086   if( pEcalNumbering == 0 )
00087     {fEcalNumbering = new TEcnaNumbering(SubDet.Data(), fEcal);  /*fCnew++*/;}
00088   else
00089     {fEcalNumbering = (TEcnaNumbering*)pEcalNumbering;}
00090 
00091 
00092   SetEcalSubDetector(SubDet.Data(), fEcal, fEcalNumbering);
00093 }
00094 
00095 void  TEcnaWrite::Init()
00096 {
00097   //----------------------------- Parameters values
00098 
00099   fgMaxCar = (Int_t)512;              // max number of characters in TStrings
00100   fCodeHeaderAscii =  0;
00101   fCodeRoot        =  1;
00102 
00103   //------------------------------------------- Codes
00104   //................. presently used codes
00105   fCodeNbOfEvts    = 101;
00106   fCodePed         = 102;
00107   fCodeTno         = 103;
00108   fCodeLfn         = 104;
00109   fCodeHfn         = 105;
00110   fCodeMeanCorss   = 106;
00111   fCodeSigCorss    = 107;
00112 
00113   fCodeCovCss      = 201;
00114   fCodeCorCss      = 202;
00115 
00116   //................. not yet used codes 
00117   //fCodeAdcEvt      =  3;
00118   //fCodeMSp         =  4;  
00119   //fCodeSSp         =  5;
00120 
00121   //fCodeAvPed       = 17;
00122   //fCodeAvTno       =  6;
00123   //fCodeAvMeanCorss = 18;
00124   //fCodeAvSigCorss  = 19;
00125 
00126   //fCodeLfCov       = 11;
00127   //fCodeLfCor       = 12;
00128   //fCodeHfCov       =  9;
00129   //fCodeHfCor       = 10;
00130 
00131   //fCodeLFccMoStins = 13;
00132   //fCodeHFccMoStins = 14;
00133   
00134   //----------------------------------------
00135 
00136   fUserSamp     = 0;
00137   fStexStinUser = 0;
00138   fStinEchaUser = 0;
00139 
00140   fjustap_2d_ev  = 0;
00141   fjustap_1d_ev  = 0;
00142 
00143   fjustap_2d_var = 0;
00144   fjustap_1d_var = 0;
00145 
00146   fjustap_2d_cc  = 0;
00147   fjustap_1d_cc  = 0;
00148 
00149   fjustap_2d_ss  = 0;
00150   fjustap_1d_ss  = 0;
00151 
00152   fCodePrintAllComments = fCnaParCout->GetCodePrint("AllComments");
00153 
00154 }
00155 // end of Init()
00156 
00157 //===================================================================
00158 //
00159 //                   Methods
00160 //
00161 //===================================================================
00162 
00163 void TEcnaWrite::SetEcalSubDetector(const TString SubDet,
00164                                    const TEcnaParEcal* pEcal,
00165                                    const TEcnaNumbering*  pEcalNumbering)
00166 {
00167  // Set Subdetector (EB or EE)
00168 
00169 
00170   fEcal = 0;
00171   if( pEcal == 0 )
00172     {fEcal = new TEcnaParEcal(SubDet.Data());  fCnew++;}
00173   else
00174     {fEcal = (TEcnaParEcal*)pEcal;}
00175 
00176   Int_t MaxCar = fgMaxCar;
00177   fFlagSubDet.Resize(MaxCar);
00178   fFlagSubDet = fEcal->GetEcalSubDetector();
00179 
00180   fEcalNumbering = 0;
00181   if( pEcalNumbering == 0 )
00182     {fEcalNumbering = new TEcnaNumbering(SubDet.Data(), fEcal);  fCnew++;}
00183   else
00184     {fEcalNumbering = (TEcnaNumbering*)pEcalNumbering;}
00185 
00186   //........................................................................
00187   //
00188   //             (for ASCII files writing methods only) ...
00189   //
00190   //                DEFINITION OF THE SECTOR SIZES
00191   //       FOR THE CORRELATION AND COVARIANCE MATRICES DISPLAY
00192   //
00193   //            MUST BE A DIVISOR OF THE TOTAL NUMBER.
00194   //            ======================================
00195   //
00196   //     Examples:
00197   //      
00198   //      (1)    25 channels => size = 25 or 5 (divisors of 25)
00199   //
00200   //             25 => matrix = 1 x 1 sector  of size (25 x 25)
00201   //                          = (1 x 1) x (25 x 25) = 1 x 625 = 625 
00202   //              5 => matrix = 5 x 5 sectors of size (5 x 5)
00203   //                          = (5 x 5) x ( 5 x  5) = 25 x 25 = 625 
00204   //
00205   //      (2)    10 samples  => size = 10, 5 or 2 (divisors of 10)
00206   //
00207   //             10 => matrix = 1 X 1 sectors of size (10 x 10) 
00208   //                          = (1 x 1) x (10 x 10) =  1 x 100 = 100
00209   //              5 => matrix = 2 x 2 sectors of size (5 x 5) 
00210   //                          = (2 x 2) x ( 5 x  5) =  4 x  25 = 100
00211   //              2 => matrix = 5 x 5 sectors of size (2 x 2) 
00212   //                          = (5 x 5) x ( 2 x  2) = 25 x  4  = 100
00213   //
00214   //........................................................................
00215   fSectChanSizeX = fEcal->MaxCrysHocoInStin();
00216   fSectChanSizeY = fEcal->MaxCrysVecoInStin();
00217   fSectSampSizeX = fEcal->MaxSampADC(); 
00218   fSectSampSizeY = fEcal->MaxSampADC();
00219 
00220   //........................................................................
00221   //
00222   //                DEFINITION OF THE NUMBER OF VALUES BY LINE
00223   //                for the Expectation Values, Variances and.
00224   //                Event distributions by (channel,sample)
00225   //
00226   //               MUST BE A DIVISOR OF THE TOTAL NUMBER.
00227   //               ======================================
00228   //
00229   //     Examples: 
00230   //                1) For expectation values and variances:
00231   //
00232   //                25 channels => size = 5
00233   //                => sample sector = 5 lines of 5 values
00234   //                                 = 5 x 5 = 25 values 
00235   //
00236   //                10 samples  => size = 10
00237   //                => channel sector = 1 lines of 10 values
00238   //                                  = 1 x 10 = 10 values
00239   //
00240   //                2) For event distributions:
00241   //
00242   //                100 bins  => size = 10
00243   //                => sample sector = 10 lines of 10 values
00244   //                                 = 10 x 10 = 100 values
00245   //
00246   //........................................................................
00247   fNbChanByLine = fEcal->MaxCrysHocoInStin();
00248   fNbSampByLine = fEcal->MaxSampADC();  
00249 }//---------- (end of SetEcalSubDetector) ------------------
00250 
00251 //-------------------------------------------------------------------------
00252 //
00253 //    Get methods for different run or file parameters
00254 //
00255 //    W A R N I N G :  some of these methods are called by external code
00256 //
00257 //                D O N ' T    S U P P R E S S !
00258 //
00259 //
00260 //     TString  fRootFileNameShort
00261 //     TString  fAnaType       = typ_ana
00262 //     Int_t    fRunNumber     = run_number
00263 //     Int_t    fFirstReqEvtNumber = nfirst
00264 //     Int_t    fReqNbOfEvts = nevents
00265 //     Int_t    fStexNumber    = super_module
00266 //
00267 //-------------------------------------------------------------------------
00268 TString TEcnaWrite::GetAsciiFileName()    {return fAsciiFileName;}
00269 TString TEcnaWrite::GetRootFileName()     {return fRootFileName;}
00270 TString TEcnaWrite::GetRootFileNameShort(){return fRootFileNameShort;}
00271 TString TEcnaWrite::GetAnalysisName()     {return fAnaType;}
00272 Int_t   TEcnaWrite::GetNbOfSamples()      {return fNbOfSamples;}
00273 Int_t   TEcnaWrite::GetRunNumber()        {return fRunNumber;}
00274 Int_t   TEcnaWrite::GetFirstReqEvtNumber(){return fFirstReqEvtNumber;}
00275 Int_t   TEcnaWrite::GetReqNbOfEvts()      {return fReqNbOfEvts;}
00276 Int_t   TEcnaWrite::GetStexNumber()       {return fStexNumber;}
00277 
00278 //.............................................................................................
00279 Int_t TEcnaWrite::NumberOfEvents(Int_t* ArrayNbOfEvts,
00280                                 const Int_t& MaxArray,  const Int_t& NbOfReqEvts)
00281 {
00282   //  CHECK THE NUMBER OF FOUND EVENTS, return rNumberOfEvents (NumberOfEvents())
00283   //  (number used to compute the average values over the events)
00284 
00285   Int_t rNumberOfEvents = 0;
00286   Int_t PresentNumber  = 0;
00287   Int_t DifferentValue = 0;
00288   Int_t EmptyChannel   = 0;
00289 
00290   //........................................................ i_SSoSE = StexStin or StinEcha
00291   for(Int_t i_SSoSE=0 ; i_SSoSE<MaxArray ; i_SSoSE++)
00292     {
00293       Int_t NbOfEvts = ArrayNbOfEvts[i_SSoSE];
00294 
00295       if( NbOfEvts > 0 )
00296         {
00297           if( PresentNumber == 0 )
00298             {
00299               PresentNumber = NbOfEvts;
00300             }
00301           else
00302             {
00303               if( NbOfEvts > PresentNumber )
00304                 { 
00305                   PresentNumber = NbOfEvts;
00306                   DifferentValue++;
00307                 }
00308               if( NbOfEvts < PresentNumber )
00309                 {
00310                   DifferentValue++;
00311                 }
00312             }
00313         }
00314       else
00315         {
00316           EmptyChannel++;
00317         }
00318     }
00319 
00320   rNumberOfEvents = PresentNumber;
00321 
00322   if( EmptyChannel > 0 )
00323     {
00324       if(fFlagPrint == fCodePrintAllComments)
00325         {
00326           cout << "*TEcnaWrite::NumberOfEvents()> *** WARNING *** " << EmptyChannel
00327                << " empty channels found." << endl;
00328         }
00329     }
00330 
00331   if( DifferentValue > 0 )
00332     {
00333       cout << "!TEcnaWrite::NumberOfEvents()> ******************************* W A R N I N G ***************************" << endl
00334            << "                                   NUMBER OF EVENTS NOT CONSTANT" << endl
00335            << "  The number of events is not the same for some channels and/or samples (empty channels not included)" << endl
00336            << "  Number of differences = " << DifferentValue << endl
00337            << "  Result ROOT file: " << fRootFileNameShort << endl         
00338            << "  The maximum number (" << rNumberOfEvents << ") is considered as the number " << endl
00339            << "  of events for calculations of pedestals, noises and correlations." << endl
00340            << "  Some values of pedestals, noises and correlations may be wrong for channels" << endl
00341            << "  with number of events different from " << rNumberOfEvents << "." << endl
00342            << "  Please, check the histogram 'Numbers of events'." << endl
00343            << "*******************************************************************************************************"
00344            << fTTBELL << endl;
00345     }
00346   else
00347     {
00348       if(fFlagPrint == fCodePrintAllComments)
00349         {
00350           if( rNumberOfEvents < NbOfReqEvts )
00351             {
00352               cout << "*TEcnaWrite::NumberOfEvents()> *** INFO *** Number of events found in data = "
00353                    << rNumberOfEvents << ": less than number of requested events ( = " << NbOfReqEvts << ")" << endl;
00354             }
00355         }
00356     }
00357   return rNumberOfEvents;  
00358 }
00359 
00360 //.............................................................................................
00361 Int_t TEcnaWrite::NumberOfEvents(Int_t**      T2d_NbOfEvts,   const Int_t& MaxCrysEcnaInStex,
00362                                 const Int_t& MaxNbOfSamples, const Int_t& NbOfReqEvts)
00363 {
00364   //  CHECK OF THE NUMBER OF FOUND EVENTS, return rNumberOfEvents (NumberOfEvents())
00365   //       (number used to compute the average values over the events)
00366 
00367   Int_t rNumberOfEvents = 0;
00368   Int_t PresentNumber  = 0;
00369   Int_t DifferentValue = 0;
00370 
00371   for(Int_t i0StexEcha = 0 ; i0StexEcha < MaxCrysEcnaInStex ; i0StexEcha++)
00372     {
00373       for(Int_t i_samp = 0 ; i_samp < MaxNbOfSamples ; i_samp++)
00374         {
00375           Int_t NbOfEvts = T2d_NbOfEvts[i0StexEcha][i_samp];
00376 
00377           if( NbOfEvts > 0 )
00378             {
00379               if( PresentNumber == 0 )
00380                 {
00381                   PresentNumber = NbOfEvts;
00382                 }
00383               else
00384                 {
00385                   if( NbOfEvts > PresentNumber )
00386                     { 
00387                       PresentNumber = NbOfEvts;
00388                       DifferentValue++;
00389                     }
00390                   if( NbOfEvts < PresentNumber )
00391                     {
00392                       DifferentValue++;
00393                     }
00394                 }
00395             }
00396         }
00397     }
00398   //.............................................................  (NumberOfEvents())
00399   rNumberOfEvents = PresentNumber;
00400 
00401   if( DifferentValue > 0 )
00402     {
00403       cout << "!TEcnaWrite::NumberOfEvents()> ******************************* W A R N I N G ***************************" << endl
00404            << "                                   NUMBER OF EVENTS NOT CONSTANT" << endl
00405            << "  The number of events is not the same for some channels and/or samples (empty channels not included)" << endl
00406            << "  Number of differences = " << DifferentValue << endl
00407            << "  Result ROOT file: " << fRootFileNameShort << endl
00408            << "  The maximum number (" << rNumberOfEvents << ") is considered as the number " << endl
00409            << "  of events for calculations of pedestals, noises and correlations."
00410            << "  Some values of pedestals, noises and correlations may be wrong for channels" << endl
00411            << "  with number of events different from " << rNumberOfEvents << "." << endl
00412            << "  Please, check the histogram 'Numbers of events'." << endl
00413            << "*******************************************************************************************************"
00414            << fTTBELL << endl;
00415     }
00416   else
00417     {
00418       if(fFlagPrint == fCodePrintAllComments)
00419         {
00420           if( rNumberOfEvents < NbOfReqEvts )
00421             {
00422               cout << "*TEcnaWrite::NumberOfEvents()> *** INFO *** Number of events found in data = "
00423                    << rNumberOfEvents << ": less than number of requested events ( = " << NbOfReqEvts << ")" << endl;
00424             }
00425         }
00426     }
00427   return rNumberOfEvents;  
00428   
00429 }//----- ( end of NumberOfEvents(...) ) ----------------
00430 
00431 void TEcnaWrite::RegisterFileParameters(const TString ArgAnaType,
00432                                        const Int_t&  ArgNbOfSamples,       const Int_t& ArgRunNumber,
00433                                        const Int_t&  ArgFirstReqEvtNumber, const Int_t& ArgLastReqEvtNumber,
00434                                        const Int_t&  ArgReqNbOfEvts,       const Int_t& ArgStexNumber)
00435 {
00436 
00437   fAnaType           = ArgAnaType;
00438   fNbOfSamples       = ArgNbOfSamples;
00439   fRunNumber         = ArgRunNumber;
00440   fFirstReqEvtNumber = ArgFirstReqEvtNumber;
00441   fLastReqEvtNumber  = ArgLastReqEvtNumber;
00442   fReqNbOfEvts       = ArgReqNbOfEvts;
00443   fStexNumber        = ArgStexNumber;
00444 }
00445 
00446 void TEcnaWrite::RegisterFileParameters(const TString ArgAnaType, 
00447                                        const Int_t&  ArgNbOfSamples,       const Int_t&  ArgRunNumber,
00448                                        const Int_t&  ArgFirstReqEvtNumber, const Int_t&  ArgLastReqEvtNumber,
00449                                        const Int_t&  ArgReqNbOfEvts,       const Int_t&  ArgStexNumber,
00450                                        const TString ArgStartDate,         const TString ArgStopDate,
00451                                        const time_t  ArgStartTime,         const time_t  ArgStopTime)
00452 {
00453   fAnaType           = ArgAnaType;
00454   fNbOfSamples       = ArgNbOfSamples;
00455   fRunNumber         = ArgRunNumber;
00456   fFirstReqEvtNumber = ArgFirstReqEvtNumber;
00457   fLastReqEvtNumber  = ArgLastReqEvtNumber;
00458   fReqNbOfEvts       = ArgReqNbOfEvts;
00459   fStexNumber        = ArgStexNumber;
00460   fStartDate         = ArgStartDate;
00461 
00462   fStopDate          = ArgStopDate;
00463   fStartTime         = ArgStartTime;
00464   fStopTime          = ArgStopTime;
00465 }
00466 //=======================================================================
00467 //
00468 //                      FILE NAMES MANAGEMENT
00469 //
00470 //=======================================================================
00471 //==============================================================================
00472 //
00473 //                     Results Filename Making  (private)
00474 //
00475 //==============================================================================
00476 void TEcnaWrite::fMakeResultsFileName(){fMakeResultsFileName(fCodeRoot);}
00477 void TEcnaWrite::fMakeResultsFileName(const Int_t&  i_code)
00478 {
00479 //Results filename making  (private)
00480   
00481   //----------------------------------------------------------------------
00482   //
00483   //     Making of the name of the result file from the parameters set
00484   //     by call to RegisterFileParameters(...)
00485   //
00486   //     Put the names in the following class attributes:
00487   //
00488   //     fRootFileName,  fRootFileNameShort,
00489   //     fAsciiFileName, fAsciiFileNameShort
00490   //
00491   //     (Short means: without the directory path)
00492   //
00493   //     set indications (run number, type of quantity, ...)
00494   //     and add the extension ".ascii" or ".root"
00495   //     
00496   //     ROOT:  only one ROOT file:  i_code = fCodeRoot.
00497   //                                          All the types of quantities
00498   //
00499   //     ASCII: several ASCII files: i_code = code for one type of quantity
00500   //            each i_code which is not equal to fCodeRoot is also implicitly
00501   //            a code "fCodeAscii" (this last attribute is not in the class)
00502   //     
00503   //----------------------------------------------------------------------
00504 
00505   char* f_in       = new char[fgMaxCar];                 fCnew++;
00506   char* f_in_short = new char[fgMaxCar];                 fCnew++;
00507 
00508   Int_t MaxCar = fgMaxCar;
00509   fStexName.Resize(MaxCar); 
00510   fStexName  = "SM or Dee?";
00511 
00512   MaxCar = fgMaxCar;
00513   fStinName.Resize(MaxCar); 
00514   fStinName  = "tower or SC?";
00515 
00516   if( fFlagSubDet == "EB" ){fStexName = "SM";  fStinName = "tower";}
00517   if( fFlagSubDet == "EE" ){fStexName = "Dee"; fStinName = "SC";}
00518 
00519   //  switch (i_code){  
00520 
00521   //===================================  R O O T  =========================  (fMakeResultsFileName)
00522   TString sPointInterrog = "?";
00523   TString sDollarHome    = "$HOME";
00524 
00525   if (i_code == fCodeRoot)
00526     {
00527       if( fCnaParPaths->ResultsRootFilePath().Data() == sPointInterrog.Data() )
00528         {
00529           cout << "!TEcnaWrite::fMakeResultsFileName>  * * * W A R N I N G * * * " << endl << endl
00530                << "    Path for results .root file not defined. Default option will be used here:" << endl
00531                << "    your results files will be written in your HOME directory." << endl << endl
00532                << "    In order to write the .root results file in a specific directory," << endl
00533                << "    you have to create a file named path_results_root in a subdirectory named ECNA" << endl
00534                << "    previously created in your home directory." << endl 
00535                << "    This file must have only one line containing the path of the directory" << endl 
00536                << "    where must be the .root result files." << endl
00537                << endl;
00538 
00539           TString home_path = gSystem->Getenv("HOME");
00540           fCnaParPaths->SetResultsRootFilePath(home_path.Data());  
00541         }
00542 
00543       if( fCnaParPaths->BeginningOfResultsRootFilePath().Data() == sDollarHome.Data() )
00544         {
00545           fCnaParPaths->TruncateResultsRootFilePath(0,5);
00546           const Text_t *t_file_nohome = (const Text_t *)fCnaParPaths->ResultsRootFilePath().Data(); //  /scratch0/cna/...
00547           
00548           TString home_path = gSystem->Getenv("HOME");
00549           fCnaParPaths->SetResultsRootFilePath(home_path.Data());   //  /afs/cern.ch/u/USER
00550           fCnaParPaths->AppendResultsRootFilePath(t_file_nohome);   //  /afs/cern.ch/u/USER/scratch0/cna/...
00551         }
00552 
00553       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d",
00554               fCnaParPaths->ResultsRootFilePath().Data(), fAnaType.Data(), fNbOfSamples,
00555               fRunNumber, fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00556       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d",
00557               fAnaType.Data(), fNbOfSamples,
00558               fRunNumber, fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00559     }
00560 
00561   //===================================  A S C I I  ====================  (fMakeResultsFileName)
00562   
00563   if (i_code != fCodeRoot)
00564     {
00565       if (i_code == fCodeHeaderAscii)
00566         {
00567           if( fCnaParPaths->ResultsAsciiFilePath().Data() == sPointInterrog.Data() )
00568             {
00569               cout << "!TEcnaWrite::fMakeResultsFileName>  * * * W A R N I N G * * * " << endl << endl
00570                    << "    Path for results .ascii file not defined. Default option will be used here:" << endl
00571                    << "    your results files will be written in your HOME directory." << endl << endl
00572                    << "    In order to write the .ascii results file in a specific directory," << endl
00573                    << "    you have to create a file named path_results_ascii in a subdirectory named ECNA" << endl
00574                    << "    previously created in your home directory." << endl 
00575                    << "    This file must have only one line containing the path of the directory" << endl 
00576                    << "    where must be the .ascii result files." << endl
00577                    << endl;
00578               
00579               TString home_path = gSystem->Getenv("HOME");
00580               fCnaParPaths->SetResultsAsciiFilePath(home_path.Data());  
00581             } 
00582           
00583           if( fCnaParPaths->BeginningOfResultsAsciiFilePath().Data() == sDollarHome.Data() )
00584             {
00585               fCnaParPaths->TruncateResultsAsciiFilePath(0,5);
00586               const Text_t *t_file_nohome = (const Text_t *)fCnaParPaths->ResultsAsciiFilePath().Data(); // /scratch0/cna/...
00587               
00588               TString home_path = gSystem->Getenv("HOME");
00589               fCnaParPaths->SetResultsAsciiFilePath(home_path.Data());   //  /afs/cern.ch/u/USER
00590               fCnaParPaths->AppendResultsAsciiFilePath(t_file_nohome);   //  /afs/cern.ch/u/USER/scratch0/cna/...
00591             }
00592         }
00593 
00594       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_header",
00595               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00596               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00597       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_header",
00598               fAnaType.Data(), fNbOfSamples, fRunNumber,
00599               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00600     }
00601 
00602   //--------------------------------------------------------------  (fMakeResultsFileName)
00603   if (i_code == fCodeNbOfEvts)
00604     {
00605       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_NbOfEvents",
00606               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00607               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00608       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_NbOfEvents",
00609               fAnaType.Data(), fNbOfSamples, fRunNumber,
00610               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00611     }
00612 
00613   if (i_code == fCodePed)
00614     {
00615       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Pedestals",
00616               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00617               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00618       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_Pedestals",
00619               fAnaType.Data(), fNbOfSamples, fRunNumber,
00620               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00621     } 
00622 
00623   if (i_code == fCodeTno)
00624     {
00625       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_TotalNoise",
00626               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00627               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00628       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_TotalNoise",
00629               fAnaType.Data(), fNbOfSamples, fRunNumber,
00630               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00631     } 
00632 
00633   if (i_code == fCodeLfn)
00634     {
00635       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LFNoise",
00636               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00637               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00638       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_LFNoise",
00639               fAnaType.Data(), fNbOfSamples, fRunNumber,
00640               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00641     } 
00642 
00643   if (i_code == fCodeHfn)
00644     {
00645       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_HFNoise",
00646               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00647               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00648       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_HFNoise",
00649               fAnaType.Data(), fNbOfSamples, fRunNumber,
00650               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00651     }
00652 
00653   if (i_code == fCodeMeanCorss)
00654     {
00655       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_MeanCorss",
00656               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00657               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00658       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_MeanCorss",
00659               fAnaType.Data(), fNbOfSamples, fRunNumber,
00660               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00661     }
00662 
00663   if (i_code == fCodeSigCorss)
00664     {
00665       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SigmaCorss",
00666               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00667               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00668       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_SigmaCorss",
00669               fAnaType.Data(), fNbOfSamples, fRunNumber,
00670               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00671     } 
00672 
00673   if (i_code ==  fCodeCovCss)
00674     {
00675       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Covss_%s%d_Channel_%d",
00676               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00677               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber,
00678               fStinName.Data(), fStexStinUser, fStinEchaUser);
00679       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_Covss_%s%d_Channel_%d",
00680               fAnaType.Data(), fNbOfSamples, fRunNumber,
00681               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber,
00682               fStinName.Data(), fStexStinUser, fStinEchaUser);
00683     }
00684   
00685   if (i_code == fCodeCorCss)
00686     {
00687       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Corss_%s%d_Channel_%d",
00688               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00689               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber,
00690               fStinName.Data(), fStexStinUser, fStinEchaUser);
00691       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_Corss_%s%d_Channel_%d",
00692               fAnaType.Data(), fNbOfSamples, fRunNumber,
00693               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber,
00694               fStinName.Data(), fStexStinUser, fStinEchaUser);
00695     }
00696 
00697   //------- (not used yet)
00698 #define OCOD
00699 #ifndef OCOD
00700   if (i_code == fCodeMSp)
00701     {
00702       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleMeans",
00703               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00704               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00705       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleMeans",
00706               fAnaType.Data(), fNbOfSamples, fRunNumber,
00707               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00708     }
00709   
00710   if (i_code == fCodeSSp)
00711     {
00712       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleSigmas",
00713               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00714               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00715       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleSigmas",
00716               fAnaType.Data(), fNbOfSamples, fRunNumber,
00717               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00718     }
00719   
00720   if( i_code == fCodeAvTno)
00721     {
00722       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedTotalNoise_c%d",
00723               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00724               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber, fStinEchaUser);
00725       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedTotalNoise_c%d",
00726               fAnaType.Data(), fNbOfSamples, fRunNumber,
00727               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber, fStinEchaUser);
00728     }
00729   
00730   if(  i_code == fCodeLfCov)
00731     {
00732       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cov",
00733               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00734               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00735       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cov",
00736               fAnaType.Data(), fNbOfSamples, fRunNumber,
00737               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00738     }
00739   
00740   if ( i_code == fCodeLfCor)
00741     {
00742       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cor",
00743               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00744               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00745       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cor",
00746               fAnaType.Data(), fNbOfSamples, fRunNumber,
00747               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00748     }
00749   
00750   if (i_code == fCodeAvPed)
00751     {
00752       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedPedestals",
00753               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00754               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00755       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedPedestals",
00756               fAnaType.Data(), fNbOfSamples, fRunNumber,
00757               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber);
00758     }
00759   
00760   if (i_code == fCodeAvMeanCorss)
00761     {
00762       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedMeanCorss%d",
00763               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00764               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber, fStinEchaUser);
00765       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedMeanCorss%d",
00766               fAnaType.Data(), fNbOfSamples, fRunNumber,
00767               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber, fStinEchaUser);
00768     }
00769 
00770   if (i_code == fCodeAvSigCorss)
00771     {
00772       sprintf(f_in, "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedSigmaCorss%d",
00773               fCnaParPaths->ResultsAsciiFilePath().Data(), fAnaType.Data(), fNbOfSamples, fRunNumber,
00774               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber, fStinEchaUser);
00775       sprintf(f_in_short, "%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragedSigmaCorss%d",
00776               fAnaType.Data(), fNbOfSamples, fRunNumber,
00777               fFirstReqEvtNumber, fLastReqEvtNumber, fReqNbOfEvts, fStexName.Data(), fStexNumber, fStinEchaUser);
00778     } 
00779 #endif // OCOD
00780 
00781   //----------------------------------------------------------- (fMakeResultsFileName)
00782 
00783   // default:
00784   //    cout << "*TEcnaWrite::fMakeResultsFileName(const Int_t&  i_code)> "
00785   //     << "wrong header code , i_code = " << i_code << endl; 
00786   //  }
00787 
00788   //======================================= f_name
00789   
00790   char* f_name = new char[fgMaxCar];                   fCnew++;
00791   
00792   for (Int_t i = 0 ; i < fgMaxCar ; i++){f_name[i] = '\0';}
00793   
00794   Int_t ii = 0;
00795   for (Int_t i = 0 ; i < fgMaxCar ; i++)
00796     {
00797       if ( f_in[i] != '\0' ){f_name[i] = f_in[i]; ii++;}
00798       else {break;}  // va directement a if ( ii+5 < fgMaxCar ) puis... f_name[ii] = '.';
00799     }
00800  
00801   if ( ii+5 < fgMaxCar )
00802     {
00803       //.......... writing of the file extension (.root or .ascii)  (fMakeResultsFileName)
00804       
00805       //------------------------------------------- extension .ascii
00806       if ( i_code != fCodeRoot  || i_code == fCodeNbOfEvts )
00807         {
00808           f_name[ii] = '.';   f_name[ii+1] = 'a';
00809           f_name[ii+2] = 's'; f_name[ii+3] = 'c';
00810           f_name[ii+4] = 'i'; f_name[ii+5] = 'i';
00811           
00812           fAsciiFileName = f_name;
00813         }
00814       //------------------------------------------- extension .root
00815       if ( i_code == fCodeRoot )
00816         {
00817           f_name[ii] = '.';   f_name[ii+1] = 'r';
00818           f_name[ii+2] = 'o'; f_name[ii+3] = 'o';  f_name[ii+4] = 't';
00819           
00820           fRootFileName = f_name;
00821         }
00822     }
00823   else
00824     {
00825       cout << "*TEcnaWrite::fMakeResultsFileName(...)> Name too long (for f_name)."
00826            << " No room enough for the extension. (ii = " << ii << ")"
00827            << fTTBELL << endl; 
00828     }
00829 
00830 
00831   //====================================== f_name_short  (fMakeResultsFileName)
00832   
00833   char* f_name_short = new char[fgMaxCar];          fCnew++;
00834 
00835   for (Int_t i = 0 ; i < fgMaxCar ; i++){f_name_short[i] = '\0';}
00836   
00837   ii = 0;
00838   for (Int_t i = 0 ; i < fgMaxCar ; i++)
00839     {
00840       if ( f_in_short[i] != '\0' ){f_name_short[i] = f_in_short[i]; ii++;}
00841       else {break;}  // va directement a f_name_short[ii] = '.';
00842     }
00843  
00844   if ( ii+5 < fgMaxCar )
00845     {
00846       //.......... writing of the file extension (.root or .ascii)
00847       
00848       //-------------------------------------------extension .ascii
00849       if ( i_code != fCodeRoot || i_code == fCodeNbOfEvts )
00850         {
00851           f_name_short[ii] = '.';   f_name_short[ii+1] = 'a';
00852           f_name_short[ii+2] = 's'; f_name_short[ii+3] = 'c';
00853           f_name_short[ii+4] = 'i'; f_name_short[ii+5] = 'i';
00854           
00855           fAsciiFileNameShort = f_name_short;
00856         }
00857       
00858       //-------------------------------------------- extension .root
00859       if ( i_code == fCodeRoot )
00860         {
00861           f_name_short[ii] = '.';   f_name_short[ii+1] = 'r';
00862           f_name_short[ii+2] = 'o'; f_name_short[ii+3] = 'o';  f_name_short[ii+4] = 't';
00863           
00864           fRootFileNameShort = f_name_short;
00865         }
00866     }
00867   else
00868     {
00869       cout << "*TEcnaWrite::fMakeResultsFileName(...)> Name too long (for f_name_short)."
00870            << " No room enough for the extension. (ii = " << ii << ")"
00871            << fTTBELL  << endl; 
00872     }
00873     delete [] f_name;        f_name       = 0;         fCdelete++;
00874     delete [] f_name_short;  f_name_short = 0;         fCdelete++;
00875 
00876     delete [] f_in;          f_in       = 0;           fCdelete++;
00877     delete [] f_in_short;    f_in_short = 0;           fCdelete++;
00878 
00879 }  // end of fMakeResultsFileName
00880 
00881 //==========================================================================================
00882 //
00883 //
00884 //
00885 //==========================================================================================
00886 
00887 void TEcnaWrite::fAsciiFileWriteHeader(const Int_t&  i_code)
00888 {
00889 //Ascii results file header writing  (private). Called by the WriteAscii...() methods
00890   
00891   //-----------------------------------------------
00892   //
00893   //     opening of the ASCII results file
00894   //     and writing of its header
00895   //
00896   //-----------------------------------------------
00897 
00898   if(fAsciiFileName.BeginsWith("$HOME"))
00899     {
00900       fAsciiFileName.Remove(0,5);
00901       TString EndOfAsciiFileName = fAsciiFileName;
00902       const Text_t *t_file_nohome = (const Text_t *)EndOfAsciiFileName.Data(); //  const Text_t* -> EndOfAsciiFileName
00903       // ( /scratch0/cna/... )
00904       TString home_path = gSystem->Getenv("HOME");
00905       fAsciiFileName = home_path;             // fAsciiFileName = absolute HOME path ( /afs/cern.ch/u/USER )
00906       fAsciiFileName.Append(t_file_nohome);   // Append  (const Text_t* -> EndOfAsciiFileName) to fAsciiFileName
00907       // ( /afs/cern.ch/u/USER/scratch0/cna/... )
00908     }
00909 
00910   fFcout_f.open(fAsciiFileName.Data());
00911 
00912   fFcout_f << "*** File: " << fAsciiFileName
00913            << " *** " << endl << endl;
00914   fFcout_f << "*Analysis name                : " << fAnaType       << endl;
00915   fFcout_f << "*First-Last samples           : 1 - " << fNbOfSamples   << endl; 
00916   fFcout_f << "*Run number                   : " << fRunNumber     << endl;
00917   fFcout_f << "*First requested event number : " << fFirstReqEvtNumber << endl;
00918   fFcout_f << "*Last  requested event number : " << fLastReqEvtNumber << endl;
00919   fFcout_f << "*Requested number of events   : " << fReqNbOfEvts << endl;
00920   if( fFlagSubDet == "EB" )
00921     {fFcout_f << "*SuperModule number           : " << fStexNumber   << endl;}
00922   if( fFlagSubDet == "EE" )
00923     {fFcout_f << "*Dee number                   : " << fStexNumber   << endl;}
00924   fFcout_f << "*Date first requested event   : " << fStartDate;
00925   fFcout_f << "*Date last requested event    : " << fStopDate      << endl;
00926   fFcout_f << endl;
00927 
00928   //========================================================================= 
00929   //   closing of the results file if i_code = fCodeHeaderAscii only.
00930   //   closing is done in the fT1dWriteAscii() and fT2dWriteAscii() methods
00931   //   except for i_code = fCodeHeaderAscii
00932   //=========================================================================
00933   if(i_code == fCodeHeaderAscii){fFcout_f.close();}
00934 }
00935 
00936 //=========================================================================
00937 //
00938 //         W R I T I N G   M E T H O D S :    R O O T    F I L E S
00939 //
00940 //    The root files are written by TEcnaRun since the arrays are computed
00941 //    by this class (arrays fT2d_..., fT1d_..) and are private attributes.
00942 //    No writing method in ROOT file here.
00943 //    Just the making of the file name
00944 //
00945 //=========================================================================
00946 
00947 //=========================================================================
00948 //
00949 //    W R I T I N G   M E T H O D S :    A S C I I    F I L E S   
00950 //
00951 //    Ascii file are treated on the same footing as plots in the
00952 //    TEcnaHistos methods.
00953 //    The arrays are TVectorD or TMatrixD and are arguments of the
00954 //    writting methods (WriteAsciiHisto, fT2dWriteAscii)
00955 //
00956 //=========================================================================
00957 //
00958 //  In the following, we describe:
00959 //  
00960 //     (1) The method which gets the path for the results ASCII files
00961 //         from a "cna-configuration" file
00962 //     (2) The codification for the names of the ASCII files
00963 //     (3) The methods which writes the results in the ASCII files
00964 //
00965 //
00966 //
00967 // (1)-----------> Method to set the path for the results ASCII files
00968 //
00969 //      void  MyCnaRun->GetPathForResultsAsciiFiles(pathname);
00970 //
00971 //            TString pathname = name of a "cna-config" file located
00972 //            in the user's HOME directory and containing one line which
00973 //            specifies the path where must be written the .ascii result files.
00974 //            (no slash at the end of the string)
00975 //    
00976 //   DEFAULT: 
00977 //            void  MyCnaRun->GetPathForResultsAsciiFiles();
00978 //            If there is no argument, the "cna-config" file must be named
00979 //            "path_results_ascii.ecna" and must be located in the user's HOME
00980 //            directory
00981 //
00982 //
00983 // (2)-----------> Codification for the names of the ASCII files (examples):
00984 //
00985 //       aaa_nnnS_Rrrr_fff_ttt_SMnnn_pedestals.ascii   OR  aaa_nnnS_Rrrr_fff_ttt_Deennn_pedestals.ascii
00986 //       aaa_nnnS_Rrrr_fff_ttt_SMnnn_HF_noise.ascii    OR  aaa_nnnS_Rrrr_fff_ttt_Deennn_HF_noise.ascii 
00987 //       aaa_nnnS_Rrrr_fff_ttt_SMnnn_corss_cCCC.ascii  OR  aaa_nnnS_Rrrr_fff_ttt_Deennn_corss_cCCC.ascii 
00988 //       etc...  
00989 //
00990 //  with:
00991 //       aaa = Analysis name
00992 //       rrr = Run number
00993 //       fff = First requested event number
00994 //       ttt = Number of requested events
00995 //       CCC = Electronic Channel number in Stex
00996 //       nnn = SM number or Dee number
00997 //
00998 //  Examples:
00999 //       StdPed12_10S_R66689_1_50_SM1_pedestals.ascii
01000 //       StdPed6_10S_R66689_1_50_Dee3_cor_ss_c2234.ascii
01001 //
01002 //
01003 // (3)-----------> Methods which write the ASCII files:
01004 //
01005 //  The methods which write the ASCII files are the following:
01006 //
01007 //      void  WriteAsciiCovariancesBetweenSamples(Channel, MatrixSize, TMatrixD matrix);
01008 //      void  WriteAsciiCorrelationsBetweenSamples(Channel, MatrixSize, TMatrixD matrix);
01009 //      void  fT2dWriteAscii(code, px, py, MatrixSize, TMatrixD matrix) [private]
01010 //      void  WriteAsciiHisto(CodeHisto, HistoSize, TVectorD histo)
01011 //
01012 //  Each of these methods corresponds to a "calculation method" of TEcnaRun.
01013 //  The calculation method of TEcnaRun must have been been called before
01014 //  using the writing method of TEcnaWrite.
01015 //==========================================================================================
01016 
01017 //-------------------------------------------------------------------------------------------
01018 //
01019 //          WriteAsciiHisto()
01020 //
01021 //          Stex = SM or Dee , Stin = Tower or SC
01022 //
01023 //-------------------------------------------------------------------------------------------
01024 void TEcnaWrite::WriteAsciiHisto(const TString HistoCode, const Int_t& HisSize, 
01025                                 const TVectorD& read_histo)
01026 {
01027 //Write histo with correspondance CNA-channel <-> xtal number in SM or Dee
01028 
01029   // BuildCrysTable() is called in the method Init() which is called by the constructor
01030 
01031   Int_t i_code = fCodeNbOfEvts;
01032 
01033   //--------------------------------------------------------------------------------
01034   if( HistoCode == "D_NOE_ChNb" ){i_code = fCodeNbOfEvts;}
01035   if( HistoCode == "D_Ped_ChNb" ){i_code = fCodePed;}
01036   if( HistoCode == "D_TNo_ChNb" ){i_code = fCodeTno;}
01037   if( HistoCode == "D_LFN_ChNb" ){i_code = fCodeLfn;}
01038   if( HistoCode == "D_HFN_ChNb" ){i_code = fCodeHfn;}
01039   if( HistoCode == "D_MCs_ChNb" ){i_code = fCodeMeanCorss;}
01040   if( HistoCode == "D_SCs_ChNb" ){i_code = fCodeSigCorss;}
01041 
01042   fMakeResultsFileName(i_code);    // => Making of the results .ascii file name
01043   fAsciiFileWriteHeader(i_code);   // => Open of the file associated with stream fFcout_f
01044 
01045   //..................................... format numerical values
01046   fFcout_f << setiosflags(ios::showpoint | ios::uppercase);
01047   fFcout_f << setprecision(3) << setw(6);
01048   fFcout_f.setf(ios::dec, ios::basefield);
01049   fFcout_f.setf(ios::fixed, ios::floatfield);
01050   fFcout_f.setf(ios::left, ios::adjustfield);
01051   fFcout_f.setf(ios::right, ios::adjustfield);
01052   
01053   cout << setiosflags(ios::showpoint | ios::uppercase);
01054   cout << setprecision(3) << setw(6);
01055   cout.setf(ios::dec, ios::basefield);
01056   cout.setf(ios::fixed, ios::floatfield);
01057   cout.setf(ios::left, ios::adjustfield);
01058   cout.setf(ios::right, ios::adjustfield);
01059 
01060   //........................................................ WriteAsciiHisto
01061   TString aStexName;
01062   Int_t MaxCar = fgMaxCar;
01063   aStexName.Resize(MaxCar); 
01064   aStexName  = "SM or Dee?";
01065   
01066   TString aStinName;     
01067   MaxCar = fgMaxCar;
01068   aStinName.Resize(MaxCar); 
01069   aStinName  = "Tower or SC?";
01070   
01071   TString aHoco;
01072   MaxCar = fgMaxCar;
01073   aHoco.Resize(MaxCar); 
01074   aHoco  = "Eta or IX?";
01075   
01076   TString aVeco;
01077   MaxCar = fgMaxCar;
01078   aVeco.Resize(MaxCar); 
01079   aVeco  = "Phi or IY?";
01080   
01081   TString aSpecifa;     
01082   MaxCar = fgMaxCar;
01083   aSpecifa.Resize(MaxCar); 
01084   aSpecifa  = " ";
01085   
01086   TString aSpecifc;     
01087   MaxCar = fgMaxCar;
01088   aSpecifc.Resize(MaxCar); 
01089   aSpecifc  = " ";
01090 
01091   TString aSpecifd;     
01092   MaxCar = fgMaxCar;
01093   aSpecifd.Resize(MaxCar); 
01094   aSpecifd  = " ";
01095 
01096   TString aSpecife;     
01097   MaxCar = fgMaxCar;
01098   aSpecife.Resize(MaxCar); 
01099   aSpecife  = " ";
01100     
01101   TString aSpecif1;     
01102   MaxCar = fgMaxCar;
01103   aSpecif1.Resize(MaxCar); 
01104   aSpecif1  = " ";
01105   
01106   TString aSpecif2;
01107   MaxCar = fgMaxCar;
01108   aSpecif2.Resize(MaxCar); 
01109   aSpecif2  = " ";
01110   
01111   if( fFlagSubDet == "EB" )
01112     {
01113       aStexName = "SM   "     ; aStinName = "tower"     ; aSpecifa = " channel# ";
01114       aHoco     = "   Eta    "; aVeco     = "   Phi    "; aSpecifc = " channel# ";
01115       aSpecifd  = " crystal# "; aSpecife  = "SM    ";
01116     }
01117   if( fFlagSubDet == "EE" )
01118     {
01119       aStexName = "Dee  "     ; aStinName = " SC  "     ; aSpecifa = "  Sector# ";
01120       aHoco     = "   IX     "; aVeco     = "   IY     "; aSpecifc = " crystal# ";
01121       aSpecifd  = "   SC #   "; aSpecife  = "Sector";
01122     }
01123   
01124   //........................................................ WriteAsciiHisto
01125 
01126   for (Int_t i0StexEcha=0; i0StexEcha<HisSize; i0StexEcha++)
01127     {
01128       Int_t n1StexStin   = 0;
01129       Int_t StexStinEcna = 0;
01130       Int_t i0StinEcha   = 0;
01131       Int_t n1StinEcha   = 0;
01132       Int_t n1StexCrys   = 0;
01133       Int_t n1DataSector = 0;
01134       Int_t n1SCinDS     = 0;
01135 
01136       if( fFlagSubDet == "EB")
01137         {
01138           n1StexStin   = fEcalNumbering->Get1SMTowFrom0SMEcha(i0StexEcha);
01139           StexStinEcna = n1StexStin;
01140           i0StinEcha   = fEcalNumbering->Get0TowEchaFrom0SMEcha(i0StexEcha);
01141           n1StexCrys   = fEcalNumbering->Get1SMCrysFrom1SMTowAnd0TowEcha(n1StexStin, i0StinEcha);
01142         }
01143       if( fFlagSubDet == "EE")
01144         {
01145           StexStinEcna = fEcalNumbering->Get1DeeSCEcnaFrom0DeeEcha(i0StexEcha);
01146           n1DataSector = fEcalNumbering->GetDSFrom1DeeSCEcna(fStexNumber, StexStinEcna);
01147           n1SCinDS     = fEcalNumbering->GetDSSCFrom1DeeSCEcna(fStexNumber, StexStinEcna);
01148           n1StexStin   = fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, StexStinEcna);
01149           n1StinEcha   = fEcalNumbering->Get1SCEchaFrom0DeeEcha(i0StexEcha);
01150         }
01151       
01152       if( n1StexStin > 0 )
01153         {
01154           if( (fFlagSubDet == "EB" && i0StinEcha == 0) || (fFlagSubDet == "EE" && n1StinEcha == 1) )
01155             {
01156               if( HistoCode == "D_NOE_ChNb" ){aSpecif1 = "Number of"; aSpecif2 = "     Events (requested)";}
01157               if( HistoCode == "D_Ped_ChNb" ){aSpecif1 = "Pedestals"; aSpecif2 = "             ";}
01158               if( HistoCode == "D_TNo_ChNb" ){aSpecif1 = "   Total "; aSpecif2 = "   Noise     ";}
01159               if( HistoCode == "D_MCs_ChNb" ){aSpecif1 = " Mean of "; aSpecif2 = "   Cor(s,s)  ";}
01160               if( HistoCode == "D_LFN_ChNb" ){aSpecif1 = "   Low Fq"; aSpecif2 = "   Noise     ";}
01161               if( HistoCode == "D_HFN_ChNb" ){aSpecif1 = "  High Fq"; aSpecif2 = "   Noise     ";}
01162               if( HistoCode == "D_SCs_ChNb" ){aSpecif1 = " Sigma of"; aSpecif2 = "   Cor(s,s)  ";}
01163               
01164               fFcout_f << endl;
01165           
01166               fFcout_f << aSpecifa.Data()
01167                        << "  " << aStinName.Data() << "#   "
01168                        << aSpecifc.Data()
01169                        << aSpecifd.Data()
01170                        << aHoco.Data()
01171                        << aVeco.Data()
01172                        << aSpecif1.Data() << endl;
01173           
01174               fFcout_f << "  in " << aStexName.Data()
01175                        << "  in " << aStexName.Data()
01176                        << "  in " << aStinName.Data()
01177                        << "  in " << aSpecife.Data()
01178                        << "  in " << aStexName.Data()
01179                        << "  in " << aStexName.Data()
01180                        << aSpecif2.Data()  << endl << endl;
01181             }
01182  
01183           Double_t value = read_histo(i0StexEcha);
01184 
01185           if( fFlagSubDet == "EB" )
01186             {
01187               fFcout_f  << setw(7)  << i0StexEcha
01188                         << setw(8)  << n1StexStin
01189                         << setw(11) << i0StinEcha   // (Electronic channel number in tower)
01190                         << setw(10) << n1StexCrys
01191                         << setw(10) << (Int_t)fEcalNumbering->GetEta(fStexNumber, StexStinEcna, i0StinEcha)
01192                         << setw(10) << (Int_t)fEcalNumbering->GetPhiInSM(fStexNumber, StexStinEcna, i0StinEcha);
01193             }
01194           if( fFlagSubDet == "EE" )
01195             {
01196               fFcout_f  << setw(7)  << n1DataSector
01197                         << setw(8)  << n1StexStin
01198                         << setw(11) << n1StinEcha   // (Xtal number for construction in SC)
01199                         << setw(10) << n1SCinDS
01200                         << setw(10) << fEcalNumbering->GetIXCrysInDee(fStexNumber, StexStinEcna, n1StinEcha-1)
01201                         << setw(10) << fEcalNumbering->GetJYCrysInDee(fStexNumber, StexStinEcna, n1StinEcha-1);
01202             }
01203 
01204           if( HistoCode == "D_NOE_ChNb")
01205             {
01206               Int_t ivalue = (Int_t)value;
01207               fFcout_f  << setw(13) << ivalue;
01208               fFcout_f  << setw(4) << "(" << setw(6) << fReqNbOfEvts << ")";
01209             }
01210           else
01211             {
01212               fFcout_f  << setw(13) << value;
01213             }
01214 
01215           fFcout_f  << endl;
01216         }
01217     } // end of loop:  for (Int_t i0StexEcha=0; i0StexEcha<HisSize; i0StexEcha++)
01218 
01219   fFcout_f.close();
01220   
01221   // if(fFlagPrint != fCodePrintNoComment)
01222   // {
01223       cout << "*TEcnaWrite::WriteAsciiHisto(...)> INFO: "
01224            << "histo has been written in file: " << endl
01225            << "            " << fAsciiFileName.Data() << endl;
01226       // }
01227 } // end of TEcnaWrite::WriteAsciiHisto
01228 
01229 //================================================================================
01230 //
01231 //        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 
01232 //
01233 //================================================================================
01234 
01235 //--------------------------------------------------------------------------------
01236 //
01237 //      Writing of the covariances between samples
01238 //      for a given StexEcha in an ASCII file
01239 //
01240 //--------------------------------------------------------------------------------
01241 void TEcnaWrite::WriteAsciiCovariancesBetweenSamples(const Int_t& user_StexStin,
01242                                                     const Int_t& user_StinEcha,
01243                                                     const Int_t& MatSize,
01244                                                     const TMatrixD& read_matrix)
01245 {
01246 //Writing of the covariances between samples for a given StexEcha in an ASCII file
01247 
01248   if( fFlagSubDet == "EB" ){fStexStinUser = user_StexStin;}
01249   if( fFlagSubDet == "EE" ){fStexStinUser =
01250                               fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, user_StexStin);}
01251 
01252   if( fFlagSubDet == "EB" ){fStinEchaUser = user_StinEcha;}
01253   if( fFlagSubDet == "EE" ){fStinEchaUser = user_StinEcha+1;}
01254 
01255   Int_t i_code = fCodeCovCss;  // code for covariances between samples
01256   fMakeResultsFileName(i_code);  
01257   fAsciiFileWriteHeader(i_code);
01258 
01259   Int_t i_pasx = fSectSampSizeX;
01260   Int_t i_pasy = fSectSampSizeY;
01261 
01262   fT2dWriteAscii(i_code, i_pasx, i_pasy, MatSize, read_matrix);
01263 }
01264 
01265 //---------------------------------------------------------------------------------
01266 //
01267 //   Writing of the correlations between samples
01268 //   for a given StexEcha in an ASCII file
01269 //
01270 //---------------------------------------------------------------------------------
01271 void TEcnaWrite::WriteAsciiCorrelationsBetweenSamples(const Int_t& user_StexStin,
01272                                                      const Int_t& user_StinEcha,
01273                                                      const Int_t& MatSize,
01274                                                      const TMatrixD& read_matrix)
01275 {
01276 //Writing of the correlations between samples for a given StexEcha in an ASCII file
01277 
01278 
01279   if( fFlagSubDet == "EB" ){fStexStinUser = user_StexStin;}
01280   if( fFlagSubDet == "EE" ){fStexStinUser =
01281                               fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, user_StexStin);}
01282 
01283   if( fFlagSubDet == "EB" ){fStinEchaUser = user_StinEcha;}
01284   if( fFlagSubDet == "EE" ){fStinEchaUser = user_StinEcha+1;}
01285 
01286   Int_t i_code = fCodeCorCss; // code for correlations between samples
01287   fMakeResultsFileName(i_code); 
01288   fAsciiFileWriteHeader(i_code);
01289 
01290   Int_t i_pasx = fSectSampSizeX;
01291   Int_t i_pasy = fSectSampSizeY;
01292 
01293   fT2dWriteAscii(i_code, i_pasx, i_pasy, MatSize, read_matrix);
01294 }
01295 
01296 //----------------------------------------------------------------------
01297 //
01298 //            fT2dWriteAscii: Array 2D of (n_sctx , n_scty) sectors
01299 //                            of size: i_pasx_arg * i_pasy_arg 
01300 //
01301 //                       (private)
01302 //
01303 //----------------------------------------------------------------------
01304 
01305 void  TEcnaWrite::fT2dWriteAscii(const Int_t&    i_code,
01306                                 const Int_t&    i_pasx_arg,
01307                                 const Int_t&    i_pasy_arg,
01308                                 const Int_t&    MatSize,
01309                                 const TMatrixD& read_matrix)
01310 {
01311 //Writing of a matrix by sectors (private)
01312 
01313   Int_t i_pasx = i_pasx_arg;           // taille secteur en x
01314   Int_t i_pasy = i_pasy_arg;           // taille secteur en y
01315   
01316   //------------ formatage des nombres en faisant appel a la classe ios
01317   
01318   fFcout_f << setiosflags(ios::showpoint | ios::uppercase);
01319   fFcout_f.setf(ios::dec, ios::basefield);
01320   fFcout_f.setf(ios::fixed, ios::floatfield);
01321   fFcout_f.setf(ios::left, ios::adjustfield);
01322   fFcout_f.setf(ios::right, ios::adjustfield);
01323   fFcout_f << setprecision(3) << setw(6);
01324   
01325   cout << setiosflags(ios::showpoint | ios::uppercase);
01326   cout.setf(ios::dec, ios::basefield);
01327   cout.setf(ios::fixed, ios::floatfield);
01328   cout.setf(ios::left, ios::adjustfield);
01329   cout.setf(ios::right, ios::adjustfield);
01330   cout << setprecision(3) << setw(6);  
01331 
01332   //--------------------- fin du formatage standard C++ -------------------
01333 
01334   //-----------------------------------------------------------------------
01335   //  Reservation dynamique d'un array Double_t** de dimensions
01336   //  les multiples de 5 juste au-dessus des dimensions de l'array 2D
01337   //  a ecrire ( array de dimensions
01338   //  (fEcal->MaxSampADC(),fEcal->MaxSampADC())
01339   //  (fEcal->MaxCrysEcnaInStex(),fEcal->MaxCrysEcnaInStex()) )
01340   //-----------------------------------------------------------------------
01341   // Determination des tailles multiples de fSectChanSizeX ou fSectSampSizeX
01342 
01343 #define NOUC
01344 #ifndef NOUC
01345 
01346   //*************** channels *************
01347   Int_t justap_chan = 0;
01348   
01349   if( fEcal->MaxCrysEcnaInStex()%fSectChanSizeX == 0 )
01350     {justap_chan = fEcal->MaxCrysEcnaInStex();}
01351   else
01352     {justap_chan=((fEcal->MaxCrysEcnaInStex()/fSectChanSizeX)+1)*fSectChanSizeX;}
01353   
01354   //....................... Allocation fjustap_2d_cc
01355 
01356   if ( i_code == fCodeHfCov || i_code == fCodeHfCor||
01357        i_code == fCodeLfCov || i_code == fCodeLfCor ){
01358     if(fjustap_2d_cc == 0)
01359       {
01360         //................... Allocation
01361         fjustap_2d_cc = new Double_t*[justap_chan];              fCnew++;  
01362         fjustap_1d_cc = new  Double_t[justap_chan*justap_chan];  fCnew++;  
01363         for(Int_t i = 0 ; i < justap_chan ; i++){
01364           fjustap_2d_cc[i] = &fjustap_1d_cc[0] + i*justap_chan;}
01365       }
01366 
01367      //............................... Transfert des valeurs dans fjustap_2d_cc  (=init)
01368     for(Int_t i = 0; i < fEcal->MaxCrysEcnaInStex(); i++){
01369       for(Int_t j = 0; j < fEcal->MaxCrysEcnaInStex(); j++){
01370         if ( i_code == fCodeHfCov ){
01371           fjustap_2d_cc[i][j] = read_matrix(i,j);}
01372         if ( i_code == fCodeHfCor ){
01373           fjustap_2d_cc[i][j] = read_matrix(i,j);}
01374         if ( i_code == fCodeLfCov ){
01375           fjustap_2d_cc[i][j] = read_matrix(i,j);}
01376         if ( i_code == fCodeLfCor ){
01377           fjustap_2d_cc[i][j] = read_matrix(i,j);}
01378       }
01379     }
01380 
01381     //.......................... mise a zero du reste de la matrice (=init)
01382     for(Int_t i = fEcal->MaxCrysEcnaInStex(); i < justap_chan; i++){
01383       for(Int_t j = fEcal->MaxCrysEcnaInStex(); j < justap_chan; j++){
01384         fjustap_2d_cc[i][j] = (Double_t)0.;}}
01385   }
01386 
01387 #endif //NOUC
01388 
01389   //************************************ Samples ***************************
01390   Int_t justap_samp = 0;
01391   
01392   if ( fEcal->MaxSampADC()%fSectSampSizeX == 0 ){
01393     justap_samp = fEcal->MaxSampADC();}
01394   else{
01395     justap_samp=((fEcal->MaxSampADC()/fSectSampSizeX)+1)*fSectSampSizeX;}
01396 
01397   //....................... allocation fjustap_2d_ss
01398 
01399   if (i_code == fCodeCovCss      || i_code == fCodeCorCss ||
01400       i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss){
01401     if(fjustap_2d_ss == 0)
01402       {
01403         //................... Allocation
01404         fjustap_2d_ss = new Double_t*[justap_samp];              fCnew++;  
01405         fjustap_1d_ss = new  Double_t[justap_samp*justap_samp];  fCnew++;  
01406         for(Int_t i = 0 ; i < justap_samp ; i++){
01407           fjustap_2d_ss[i] = &fjustap_1d_ss[0] + i*justap_samp;}
01408       }
01409 
01410   //.............................. Transfert des valeurs dans fjustap_2d_ss (=init)
01411   for(Int_t i = 0; i < fEcal->MaxSampADC(); i++){
01412     for(Int_t j = 0; j < fEcal->MaxSampADC(); j++){
01413       if( i_code == fCodeCovCss ){
01414         fjustap_2d_ss[i][j] = read_matrix(i,j);}
01415       if( i_code == fCodeCorCss ){
01416         fjustap_2d_ss[i][j] = read_matrix(i,j);}
01417       if( i_code == fCodeAvMeanCorss ){
01418         fjustap_2d_ss[i][j] = read_matrix(i,j);}
01419       if( i_code == fCodeAvSigCorss ){
01420         fjustap_2d_ss[i][j] = read_matrix(i,j);}
01421     }
01422   }
01423 
01424   //.......................... mise a zero du reste de la matrice (=init)
01425   for(Int_t i = fEcal->MaxSampADC(); i < justap_samp; i++){
01426     for(Int_t j = fEcal->MaxSampADC(); j < justap_samp; j++){
01427       fjustap_2d_ss[i][j] = (Double_t)0.;}}
01428   }
01429 
01430   //..................... impressions + initialisations selon i_code
01431   
01432   Int_t isx_max = 0;    
01433   Int_t isy_max = 0;
01434 
01435 #define COCC
01436 #ifndef COCC
01437   if(i_code == fCodeHfCov)
01438     {
01439       fFcout_f << "Covariance matrix between channels "
01440                << "for sample number " << fUserSamp;
01441       isx_max = justap_chan;
01442       isy_max = justap_chan;
01443     }
01444   if(i_code == fCodeHfCor)
01445     {
01446       fFcout_f << "*Correlation matrix between channels "
01447                << "for sample number " << fUserSamp;
01448       isx_max = justap_chan;
01449       isy_max = justap_chan;
01450     }
01451   
01452   if(i_code == fCodeLfCov)
01453     {
01454       fFcout_f << "Covariance matrix between channels "
01455                << "averaged on the samples ";
01456       isx_max = justap_chan;
01457       isy_max = justap_chan;
01458     }
01459   if(i_code == fCodeLfCor)
01460     {
01461       fFcout_f << "Correlation matrix between channels "
01462                << "averaged on the samples ";
01463       isx_max = justap_chan;
01464       isy_max = justap_chan;
01465     }
01466 #endif // COCC
01467 
01468   Int_t n1StexStin = 0; 
01469   Int_t i0StinEcha = 0;
01470   Int_t n1StinEcha = 0;
01471   
01472   if( fFlagSubDet == "EB")
01473     {
01474       n1StexStin = fStexStinUser;
01475       i0StinEcha = fEcalNumbering->Get0TowEchaFrom0SMEcha(fStinEchaUser);
01476     }
01477   if( fFlagSubDet == "EE")
01478     {
01479       n1StexStin = fStexStinUser;
01480       n1StinEcha = fEcalNumbering->Get1SCEchaFrom0DeeEcha(fStinEchaUser-1);
01481       
01482       TString sDeeDir = fEcalNumbering->GetDeeDirViewedFromIP(fStexNumber);
01483     }
01484   
01485   if(i_code == fCodeCovCss)
01486     {
01487       if( fFlagSubDet == "EB")
01488         {
01489           fFcout_f << "Covariance matrix between samples "
01490                    << "for channel number " << fStinEchaUser
01491                    << " (" << fStinName << ": " << n1StexStin
01492                    << " , channel in " << fStinName << ": " << i0StinEcha << ")";
01493         }
01494       if( fFlagSubDet == "EE")
01495         {
01496           fFcout_f << "Covariance matrix between samples "
01497                    << "for channel number " << fStinEchaUser
01498                    << " (" << fStinName << ": " << n1StexStin
01499                    << " , channel in " << fStinName << ": " << n1StinEcha << ")";
01500         }
01501       isx_max = justap_samp;
01502       isy_max = justap_samp;
01503     }
01504   if(i_code == fCodeCorCss)
01505     {
01506       if( fFlagSubDet == "EB")
01507         {
01508           fFcout_f << "Correlation matrix between samples "
01509                    << "for channel number " << fStinEchaUser
01510                    << " (" << fStinName << ": " << n1StexStin
01511                    << " , channel in " << fStinName << ": " << i0StinEcha << ")"; 
01512         }
01513       if( fFlagSubDet == "EE")
01514         {
01515           fFcout_f << "Correlation matrix between samples "
01516                    << "for channel number " << fStinEchaUser
01517                    << " (" << fStinName << ": " << n1StexStin
01518                    << " , channel in " << fStinName << ": " << n1StinEcha << ")"; 
01519         }
01520       isx_max = justap_samp;
01521       isy_max = justap_samp;
01522     }
01523  
01524   if(i_code == fCodeAvMeanCorss)
01525     {
01526       if( fFlagSubDet == "EB")
01527         {
01528           fFcout_f << "Correction factors to the covariances "
01529                    << "between samples for channel number " << fStinEchaUser
01530                    << " (" << fStinName << ": " << n1StexStin
01531                    << " , channel in " << fStinName << ": " << i0StinEcha << ")";
01532         }
01533       if( fFlagSubDet == "EE")
01534         {
01535           fFcout_f << "Correction factors to the covariances "
01536                    << "between samples for channel number " << fStinEchaUser
01537                    << " (" << fStinName << ": " << n1StexStin
01538                    << " , channel in " << fStinName << ": " << n1StinEcha << ")";
01539         }
01540       isx_max = justap_samp;
01541       isy_max = justap_samp;
01542     }
01543   
01544   if(i_code == fCodeAvSigCorss)
01545     {
01546       if( fFlagSubDet == "EB")
01547         {
01548           fFcout_f << "Correction factors to the correlations "
01549                    << "between samples for channel number " << fStinEchaUser
01550                    << " ( " << fStinName << ": " << n1StexStin
01551                    << " , channel in " << fStinName << ": " << i0StinEcha << ")";
01552         }
01553       if( fFlagSubDet == "EE")
01554         {
01555           fFcout_f << "Correction factors to the correlations "
01556                    << "between samples for channel number " << fStinEchaUser
01557                    << " ( " << fStinName << ": " << n1StexStin
01558                    << " , channel in " << fStinName << ": " << n1StinEcha << ")";
01559         }
01560       isx_max = justap_samp;
01561       isy_max = justap_samp;
01562     }
01563   
01564   fFcout_f << endl;
01565 
01566   //............... Calcul des nombres de secteurs selon x
01567   //                i_pasx  = taille secteur en x 
01568   //                isx_max = taille de la matrice en x
01569   //                n_sctx  = nombre de secteurs en x
01570   //
01571   if(i_pasx > isx_max){i_pasx = isx_max;}  
01572   Int_t n_sctx;
01573   Int_t max_verix; 
01574   n_sctx = isx_max/i_pasx;
01575   max_verix = n_sctx*i_pasx; 
01576   if(max_verix < isx_max){ n_sctx++;}
01577 
01578   //............... Calcul des nombres de secteurs selon y
01579   //                i_pasy  = taille secteur en y
01580   //                isy_max = taille de la matrice en y
01581   //                n_scty  = nombre de secteurs en x
01582   //
01583   if(i_pasy > isy_max){i_pasy = isy_max;} 
01584   Int_t n_scty;
01585   Int_t max_veriy; 
01586   n_scty = isy_max/i_pasy;
01587   max_veriy = n_scty*i_pasy; 
01588   if(max_veriy < isy_max){ n_scty++;}
01589 
01590 #define NBSC
01591 #ifndef NBSC
01592   //................ Ecriture de la taille et du nombre des secteurs
01593   if( i_code == fCodeCovCss      || i_code == fCodeCorCss ||
01594       i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss)
01595     {
01596       fFcout_f << "sector size = " << fSectSampSizeX 
01597                << " , number of sectors = " << n_sctx << " x " << n_scty
01598                <<endl;
01599     }
01600  if( i_code == fCodeHfCov || i_code == fCodeHfCor ||
01601      i_code == fCodeLfCov || i_code == fCodeLfCor )
01602     {
01603       fFcout_f << "sector size = " << fSectChanSizeX 
01604                << " , number of sectors = " << n_sctx << " x " << n_scty
01605                << endl;
01606     }
01607 #endif // NBSC
01608 
01609   fFcout_f << endl;
01610 
01611   //............... impression matrice par secteurs i_pas x i_pas  
01612   //........................... boucles pour display des secteurs 
01613   Int_t   ix_inf = -i_pasx;
01614   
01615   for(Int_t nsx = 0 ; nsx < n_sctx ; nsx++)
01616     { 
01617       //......................... calcul limites secteur
01618       ix_inf = ix_inf + i_pasx;
01619       Int_t   ix_sup = ix_inf + i_pasx; 
01620       
01621       Int_t   iy_inf = -i_pasy;
01622       
01623       for(Int_t nsy = 0 ; nsy < n_scty ; nsy++)
01624         {       
01625           iy_inf = iy_inf + i_pasy;          
01626           Int_t   iy_sup = iy_inf + i_pasy;
01627           
01628           //......................... display du secteur (nsx,nsy)
01629           
01630           if(i_code == fCodeHfCov || i_code == fCodeCovCss ||
01631              i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss )
01632             {fFcout_f << "        ";}
01633           if(i_code == fCodeHfCor || i_code == fCodeCorCss)
01634             {fFcout_f << "      ";}
01635           
01636           for (Int_t iy_c = iy_inf ; iy_c < iy_sup ; iy_c++)
01637             {
01638               if(i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss ||
01639                  i_code == fCodeAvMeanCorss ||
01640                  i_code == fCodeAvSigCorss)
01641                 {fFcout_f.width(8);}
01642               if(i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss)
01643                 {fFcout_f.width(6);}
01644               fFcout_f << iy_c << "  ";
01645             }     
01646           fFcout_f << endl << endl;
01647           
01648           for (Int_t ix_c = ix_inf ; ix_c < ix_sup ; ix_c++)
01649             { 
01650               if(i_code == fCodeHfCov|| i_code == fCodeLfCov || i_code == fCodeCovCss ||
01651                  i_code == fCodeAvMeanCorss ||
01652                  i_code == fCodeAvSigCorss)
01653                 {fFcout_f.width(8);}
01654               if(i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss)
01655                 {fFcout_f.width(6);}
01656               fFcout_f << ix_c << "   ";
01657               
01658               for (Int_t iy_c = iy_inf ; iy_c < iy_sup ; iy_c++)
01659                 {
01660                   if(i_code == fCodeHfCov  ||
01661                      i_code == fCodeLfCov  ||
01662                      i_code == fCodeCovCss ||
01663                      i_code == fCodeAvMeanCorss || 
01664                      i_code == fCodeAvSigCorss ){
01665                     fFcout_f.width(8);}
01666 
01667                   if(i_code == fCodeHfCor || i_code == fCodeLfCor ||  i_code == fCodeCorCss){
01668                     fFcout_f.width(6);}
01669                   
01670                   if( i_code == fCodeHfCov ||  i_code == fCodeLfCov || i_code == fCodeHfCor){
01671                     fFcout_f << fjustap_2d_cc[ix_c][iy_c] << "  ";}
01672                   
01673                   if ( i_code == fCodeCovCss ||
01674                        i_code == fCodeCorCss ||
01675                        i_code == fCodeAvMeanCorss ||
01676                        i_code == fCodeAvSigCorss )
01677                     {
01678                       fFcout_f << fjustap_2d_ss[ix_c][iy_c] << "  ";
01679                     }
01680                 }
01681               fFcout_f << endl;
01682             }
01683           fFcout_f << endl;
01684         }
01685     }
01686 
01687   //........... closing of the results file
01688   
01689   fFcout_f.close();
01690   
01691   if(fFlagPrint != fCodePrintNoComment)
01692     {
01693       cout << "*TEcnaWrite::fT2dWriteAscii(....)> INFO: "
01694            << "matrix has been written in file: " << endl
01695            << "            " << fAsciiFileName.Data() << endl;
01696     }
01697   
01698 }// end of TEcnaWrite::fT2dWriteAscii
01699 
01700 
01701 //=========================================================================
01702 //
01703 //   ci-dessous: ===> methodes a implementer plus tard?
01704 //
01705 //=========================================================================
01706 #define WASC
01707 #ifndef WASC
01708 //------------------------------------------------------------
01709 //
01710 //      Writing of the expectation values in an ASCII file
01711 //
01712 //------------------------------------------------------------
01713 
01714 void TEcnaWrite::WriteAsciiSampleMeans()
01715 {
01716 //Writing of the expectation values in an ASCII file
01717   
01718   Int_t i_code = fCodeMSp;
01719   fMakeResultsFileName(i_code);
01720   fAsciiFileWriteHeader(i_code);
01721   
01722   Int_t i_lic1 = fNbChanByLine; 
01723   Int_t i_lic2 = fNbSampByLine;
01724   
01725   fT1dWriteAscii(i_code, i_lic1, i_lic2);
01726 }
01727 
01728 //-------------------------------------------------------
01729 //
01730 //      Writing of the sigmas in an ASCII file
01731 //
01732 //-------------------------------------------------------
01733 
01734 void TEcnaWrite::WriteAsciiSampleSigmas()
01735 {
01736 //Writing of the variances in an ASCII file
01737   
01738   Int_t i_code = fCodeVar;  // code for variance   
01739   fMakeResultsFileName(i_code);
01740   fAsciiFileWriteHeader(i_code);
01741   
01742   Int_t i_lic1 = fNbChanByLine;
01743   Int_t i_lic2 = fNbSampByLine;
01744   
01745   fT1dWriteAscii(i_code, i_lic1, i_lic2);
01746 }
01747 #endif // WASC