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