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