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