CMS 3D CMS Logo

TEcnaWrite.cc
Go to the documentation of this file.
1 //----------Author's Name: B.Fabbro DSM/IRFU/SPP CEA-Saclay
2 //----------Copyright: Those valid for CEA sofware
3 //----------Modified: 30/01/2014
4 
6 
7 //--------------------------------------
8 // TEcnaWrite.cc
9 // Class creation: 19 May 2005
10 // Documentation: see TEcnaWrite.h
11 //--------------------------------------
12 
14 //______________________________________________________________________________
15 //
16 
18  //destructor
19 
20  //if (fEcal != 0){delete fEcal; fCdelete++;}
21  //if (fEcalNumbering != 0){delete fEcalNumbering; fCdelete++;}
22  //if (fCnaParPaths != 0){delete fCnaParPaths; fCdelete++;}
23  //if (fCnaParCout != 0){delete fCnaParCout; fCdelete++;}
24 
25  // std::cout << "[Info Management] CLASS: TEcnaWrite. DESTROY OBJECT: this = " << this << std::endl;
26 }
27 
28 //===================================================================
29 //
30 // Constructors
31 //
32 //===================================================================
34  // std::cout << "[Info Management] CLASS: TEcnaWrite. CREATE OBJECT: this = " << this << std::endl;
35 
36  Init();
37 }
38 
39 TEcnaWrite::TEcnaWrite(TEcnaObject* pObjectManager, const TString& SubDet) {
40  // std::cout << "[Info Management] CLASS: TEcnaWrite. CREATE OBJECT: this = " << this << std::endl;
41 
42  Init();
43  Long_t i_this = (Long_t)this;
44  pObjectManager->RegisterPointer("TEcnaWrite", i_this);
45 
46  //............................ fCnaParCout
47  fCnaParCout = nullptr;
48  Long_t iCnaParCout = pObjectManager->GetPointerValue("TEcnaParCout");
49  if (iCnaParCout == 0) {
50  fCnaParCout = new TEcnaParCout(pObjectManager); /*fCnew++*/
51  } else {
52  fCnaParCout = (TEcnaParCout*)iCnaParCout;
53  }
55 
56  //............................ fCnaParPaths
57  fCnaParPaths = nullptr;
58  Long_t iCnaParPaths = pObjectManager->GetPointerValue("TEcnaParPaths");
59  if (iCnaParPaths == 0) {
60  fCnaParPaths = new TEcnaParPaths(pObjectManager); /*fCnew++*/
61  } else {
62  fCnaParPaths = (TEcnaParPaths*)iCnaParPaths;
63  }
64 
65  //fCfgResultsRootFilePath = fCnaParPaths->ResultsRootFilePath();
66  //fCfgHistoryRunListFilePath = fCnaParPaths->HistoryRunListFilePath();
67 
70 
71  //............................ fEcal => should be changed in fParEcal
72  fEcal = nullptr;
73  Long_t iParEcal = pObjectManager->GetPointerValue("TEcnaParEcal");
74  if (iParEcal == 0) {
75  fEcal = new TEcnaParEcal(pObjectManager, SubDet.Data()); /*fCnew++*/
76  } else {
77  fEcal = (TEcnaParEcal*)iParEcal;
78  }
79 
80  //............................ fEcalNumbering
81  fEcalNumbering = nullptr;
82  Long_t iEcalNumbering = pObjectManager->GetPointerValue("TEcnaNumbering");
83  if (iEcalNumbering == 0) {
84  fEcalNumbering = new TEcnaNumbering(pObjectManager, SubDet.Data()); /*fCnew++*/
85  } else {
86  fEcalNumbering = (TEcnaNumbering*)iEcalNumbering;
87  }
88 
89  SetEcalSubDetector(SubDet.Data());
90 }
91 
93  TEcnaParPaths* pCnaParPaths,
94  TEcnaParCout* pCnaParCout,
95  TEcnaParEcal* pEcal,
96  TEcnaNumbering* pEcalNumbering) {
97  // std::cout << "[Info Management] CLASS: TEcnaWrite. CREATE OBJECT: this = " << this << std::endl;
98 
99  Init();
100 
101  //----------------------------- Object management
102  fCnaParPaths = nullptr;
103  if (pCnaParPaths == nullptr) {
104  fCnaParPaths = new TEcnaParPaths(); /*fCnew++*/
105  ;
106  } else {
107  fCnaParPaths = pCnaParPaths;
108  }
109 
110  //................. Get paths from ECNA directory
111 
114 
115  fCnaParCout = nullptr;
116  if (pCnaParCout == nullptr) {
117  fCnaParCout = new TEcnaParCout(); /*fCnew++*/
118  ;
119  } else {
120  fCnaParCout = pCnaParCout;
121  }
123 
124  fEcal = nullptr;
125  if (pEcal == nullptr) {
126  fEcal = new TEcnaParEcal(SubDet.Data()); /*fCnew++*/
127  ;
128  } else {
129  fEcal = pEcal;
130  }
131 
132  fEcalNumbering = nullptr;
133  if (pEcalNumbering == nullptr) {
134  fEcalNumbering = new TEcnaNumbering(SubDet.Data(), fEcal); /*fCnew++*/
135  ;
136  } else {
137  fEcalNumbering = pEcalNumbering;
138  }
139 
141 }
142 
144  //----------------------------- Parameters values
145  fTTBELL = '\007';
146 
147  fgMaxCar = (Int_t)512; // max number of characters in TStrings
148  fCodeHeaderAscii = 0;
149  fCodeRoot = 1;
150 
151  //------------------------------------------- Codes
152  //................. presently used codes
153  fCodeNbOfEvts = 101;
154  fCodePed = 102;
155  fCodeTno = 103;
156  fCodeLfn = 104;
157  fCodeHfn = 105;
158  fCodeMeanCorss = 106;
159  fCodeSigCorss = 107;
160 
161  fCodeCovCss = 201;
162  fCodeCorCss = 202;
163 
164  //................. not yet used codes
165  //fCodeAdcEvt = 3;
166  //fCodeMSp = 4;
167  //fCodeSSp = 5;
168 
169  //fCodeAvPed = 17;
170  //fCodeAvTno = 6;
171  //fCodeAvMeanCorss = 18;
172  //fCodeAvSigCorss = 19;
173 
174  //fCodeLfCov = 11;
175  //fCodeLfCor = 12;
176  //fCodeHfCov = 9;
177  //fCodeHfCor = 10;
178 
179  //fCodeLFccMoStins = 13;
180  //fCodeHFccMoStins = 14;
181 
182  //----------------------------------------
183 
184  fUserSamp = 0;
185  fStexStinUser = 0;
186  fStinEchaUser = 0;
187 
188  fjustap_2d_ev = nullptr;
189  fjustap_1d_ev = nullptr;
190 
191  fjustap_2d_var = nullptr;
192  fjustap_1d_var = nullptr;
193 
194  fjustap_2d_cc = nullptr;
195  fjustap_1d_cc = nullptr;
196 
197  fjustap_2d_ss = nullptr;
198  fjustap_1d_ss = nullptr;
199 }
200 // end of Init()
201 
202 //===================================================================
203 //
204 // Methods
205 //
206 //===================================================================
207 
209  // Set Subdetector (EB or EE)
210 
211  Int_t MaxCar = fgMaxCar;
212  fFlagSubDet.Resize(MaxCar);
214 
215  //........................................................................
216  //
217  // (for ASCII files writing methods only) ...
218  //
219  // DEFINITION OF THE SECTOR SIZES
220  // FOR THE CORRELATION AND COVARIANCE MATRICES DISPLAY
221  //
222  // MUST BE A DIVISOR OF THE TOTAL NUMBER.
223  // ======================================
224  //
225  // Examples:
226  //
227  // (1) 25 channels => size = 25 or 5 (divisors of 25)
228  //
229  // 25 => matrix = 1 x 1 sector of size (25 x 25)
230  // = (1 x 1) x (25 x 25) = 1 x 625 = 625
231  // 5 => matrix = 5 x 5 sectors of size (5 x 5)
232  // = (5 x 5) x ( 5 x 5) = 25 x 25 = 625
233  //
234  // (2) 10 samples => size = 10, 5 or 2 (divisors of 10)
235  //
236  // 10 => matrix = 1 X 1 sectors of size (10 x 10)
237  // = (1 x 1) x (10 x 10) = 1 x 100 = 100
238  // 5 => matrix = 2 x 2 sectors of size (5 x 5)
239  // = (2 x 2) x ( 5 x 5) = 4 x 25 = 100
240  // 2 => matrix = 5 x 5 sectors of size (2 x 2)
241  // = (5 x 5) x ( 2 x 2) = 25 x 4 = 100
242  //
243  //........................................................................
248 
249  //........................................................................
250  //
251  // DEFINITION OF THE NUMBER OF VALUES BY LINE
252  // for the Expectation Values, Variances and.
253  // Event distributions by (channel,sample)
254  //
255  // MUST BE A DIVISOR OF THE TOTAL NUMBER.
256  // ======================================
257  //
258  // Examples:
259  // 1) For expectation values and variances:
260  //
261  // 25 channels => size = 5
262  // => sample sector = 5 lines of 5 values
263  // = 5 x 5 = 25 values
264  //
265  // 10 samples => size = 10
266  // => channel sector = 1 lines of 10 values
267  // = 1 x 10 = 10 values
268  //
269  // 2) For event distributions:
270  //
271  // 100 bins => size = 10
272  // => sample sector = 10 lines of 10 values
273  // = 10 x 10 = 100 values
274  //
275  //........................................................................
278 } //---------- (end of SetEcalSubDetector) ------------------
279 
280 void TEcnaWrite::SetEcalSubDetector(const TString& SubDet, TEcnaParEcal* pEcal, TEcnaNumbering* pEcalNumbering) {
281  // Set Subdetector (EB or EE)
282 
283  fEcal = nullptr;
284  if (pEcal == nullptr) {
285  fEcal = new TEcnaParEcal(SubDet.Data());
286  fCnew++;
287  } else {
288  fEcal = pEcal;
289  }
290 
291  Int_t MaxCar = fgMaxCar;
292  fFlagSubDet.Resize(MaxCar);
294 
295  fEcalNumbering = nullptr;
296  if (pEcalNumbering == nullptr) {
297  fEcalNumbering = new TEcnaNumbering(SubDet.Data(), fEcal);
298  fCnew++;
299  } else {
300  fEcalNumbering = pEcalNumbering;
301  }
302 
303  //........................................................................
304  //
305  // (for ASCII files writing methods only) ...
306  //
307  // DEFINITION OF THE SECTOR SIZES
308  // FOR THE CORRELATION AND COVARIANCE MATRICES DISPLAY
309  //
310  // MUST BE A DIVISOR OF THE TOTAL NUMBER.
311  // ======================================
312  //
313  // Examples:
314  //
315  // (1) 25 channels => size = 25 or 5 (divisors of 25)
316  //
317  // 25 => matrix = 1 x 1 sector of size (25 x 25)
318  // = (1 x 1) x (25 x 25) = 1 x 625 = 625
319  // 5 => matrix = 5 x 5 sectors of size (5 x 5)
320  // = (5 x 5) x ( 5 x 5) = 25 x 25 = 625
321  //
322  // (2) 10 samples => size = 10, 5 or 2 (divisors of 10)
323  //
324  // 10 => matrix = 1 X 1 sectors of size (10 x 10)
325  // = (1 x 1) x (10 x 10) = 1 x 100 = 100
326  // 5 => matrix = 2 x 2 sectors of size (5 x 5)
327  // = (2 x 2) x ( 5 x 5) = 4 x 25 = 100
328  // 2 => matrix = 5 x 5 sectors of size (2 x 2)
329  // = (5 x 5) x ( 2 x 2) = 25 x 4 = 100
330  //
331  //........................................................................
336 
337  //........................................................................
338  //
339  // DEFINITION OF THE NUMBER OF VALUES BY LINE
340  // for the Expectation Values, Variances and.
341  // Event distributions by (channel,sample)
342  //
343  // MUST BE A DIVISOR OF THE TOTAL NUMBER.
344  // ======================================
345  //
346  // Examples:
347  // 1) For expectation values and variances:
348  //
349  // 25 channels => size = 5
350  // => sample sector = 5 lines of 5 values
351  // = 5 x 5 = 25 values
352  //
353  // 10 samples => size = 10
354  // => channel sector = 1 lines of 10 values
355  // = 1 x 10 = 10 values
356  //
357  // 2) For event distributions:
358  //
359  // 100 bins => size = 10
360  // => sample sector = 10 lines of 10 values
361  // = 10 x 10 = 100 values
362  //
363  //........................................................................
366 } //---------- (end of SetEcalSubDetector) ------------------
367 
368 //-------------------------------------------------------------------------
369 //
370 // Get methods for different run or file parameters
371 //
372 // W A R N I N G : some of these methods are called by external code
373 //
374 // D O N ' T S U P P R E S S !
375 //
376 //
377 // TString fRootFileNameShort
378 // TString fAnaType = typ_ana
379 // Int_t fRunNumber = run_number
380 // Int_t fFirstReqEvtNumber = nfirst
381 // Int_t fReqNbOfEvts = nevents
382 // Int_t fStexNumber = super_module
383 //
384 //-------------------------------------------------------------------------
385 const TString& TEcnaWrite::GetAsciiFileName() const { return fAsciiFileName; }
386 const TString& TEcnaWrite::GetRootFileName() const { return fRootFileName; }
387 const TString& TEcnaWrite::GetRootFileNameShort() const { return fRootFileNameShort; }
388 const TString& TEcnaWrite::GetAnalysisName() const { return fAnaType; }
394 
395 //---------------------------------------------------------------------------------------------------
396 //
397 // NumberOfEventsAnalysis(...) : Analyses the number of events found in data
398 // channel by channel OR sample by sample
399 // an output ERROR message is delivered if differences are detected
400 //
401 // channel by channel: called by TEcnaRead object (3 arguments)
402 // sample by sample : called by TEcnaRun object (4 arguments)
403 //
404 // This method must be a TEcnaWrite method since it can be called by objects
405 // of class TEcnaRead OR TEcnaRun
406 //
407 //---------------------------------------------------------------------------------------------------
408 //.............................................................................................
409 Int_t TEcnaWrite::NumberOfEventsAnalysis(Int_t* ArrayNbOfEvts,
410  const Int_t& MaxArray,
411  const Int_t& NbOfReqEvts,
412  const Int_t& StexNumber) {
413  // CHECK THE NUMBER OF FOUND EVENTS, return rNumberOfEvents (NumberOfEvents())
414  // (number used to compute the average values over the events)
415  //
416  // 1D array: called by TEcnaRead object
417 
418  Int_t rNumberOfEvents = 0;
419  Int_t PresentNumber = 0;
420  Int_t EmptyChannel = 0;
421  Int_t DifferentMinusValue = 0;
422  Int_t DifferentPlusValue = 0;
423 
424  //........................................................ i_SSoSE = StexStin or StinEcha
425  for (Int_t i_SSoSE = 0; i_SSoSE < MaxArray; i_SSoSE++) {
426  Int_t NbOfEvts = ArrayNbOfEvts[i_SSoSE];
427 
428  if (NbOfEvts > 0) {
429  if (PresentNumber == 0) // first channel
430  {
431  PresentNumber = NbOfEvts;
432  } else // current channel
433  {
434  if (NbOfEvts > PresentNumber) // warning
435  {
436  PresentNumber = NbOfEvts;
437  DifferentPlusValue++;
438  }
439  if (NbOfEvts < PresentNumber) // warning
440  {
441  DifferentMinusValue++;
442  }
443  }
444  } else {
445  EmptyChannel++;
446  }
447  }
448 
449  rNumberOfEvents = PresentNumber;
450 
451  if (EmptyChannel > 0) {
452  if (MaxArray == fEcal->MaxCrysInSM()) // (EB)
453  {
454  std::cout << "!TEcnaWrite::NumberOfEventsAnalysis()> *** WARNING *** " << EmptyChannel
455  << " empty channels detected in SM " << StexNumber << " (EB "
456  << fEcalNumbering->PlusMinusSMNumber(StexNumber) << ")" << std::endl;
457  }
458  if (MaxArray == fEcal->MaxCrysEcnaInDee()) // (EE)
459  {
461  if (EmptyChannel > 0) {
462  std::cout << "!TEcnaWrite::NumberOfEventsAnalysis()> *** WARNING *** " << EmptyChannel
463  << " empty channels detected in Dee " << StexNumber << std::endl;
464  }
465  }
466  }
467 
468  if (DifferentMinusValue > 0 || DifferentPlusValue > 0) {
469  std::cout << "!TEcnaWrite::NumberOfEventsAnalysis()> " << std::endl;
470 
471  if (MaxArray == fEcal->MaxCrysInSM()) // (EB)
472  {
473  std::cout << "************** W A R N I N G : NUMBER OF EVENTS NOT CONSTANT FOR SM " << StexNumber << " (EB "
474  << fEcalNumbering->PlusMinusSMNumber(StexNumber) << ") *********************";
475  }
476 
477  if (MaxArray == fEcal->MaxCrysEcnaInDee()) // (EE)
478  {
479  std::cout << "****************** W A R N I N G : NUMBER OF EVENTS NOT CONSTANT FOR Dee " << StexNumber
480  << " **************************";
481  }
482 
483  std::cout
484  << std::endl
485  << " Result ROOT file: " << fRootFileName << std::endl
486  << " The number of events is not the same for all the non-empty channels." << std::endl
487  << " The maximum number (" << rNumberOfEvents << ") is considered as the number of events for calculations "
488  << std::endl
489  << " of pedestals, noises and correlations." << std::endl
490  << " Number of channels with 0 < nb of evts < " << rNumberOfEvents << " : " << DifferentMinusValue
491  << std::endl
492  // << " Number of channels with nb of evts > " << rNumberOfEvents << " = " << DifferentPlusValue << std::endl
493  << " Number of empty channels : " << EmptyChannel << std::endl
494  << " Some values of pedestals, noises and correlations may be wrong for channels" << std::endl
495  << " with number of events different from " << rNumberOfEvents << "." << std::endl
496  << " Please, check the histogram 'Numbers of events'." << std::endl
497  << "*******************************************************************************************************"
498  << std::endl;
499  } else {
501  if (rNumberOfEvents < NbOfReqEvts) {
502  std::cout << "*TEcnaWrite::NumberOfEventsAnalysis()> *** INFO *** Number of events found in data = "
503  << rNumberOfEvents << ": less than number of requested events ( = " << NbOfReqEvts << ")"
504  << std::endl;
505  }
506  }
507  }
508  return rNumberOfEvents;
509 }
510 
511 //.............................................................................................
512 Int_t TEcnaWrite::NumberOfEventsAnalysis(Int_t** T2d_NbOfEvts,
513  const Int_t& MaxCrysEcnaInStex,
514  const Int_t& MaxNbOfSamples,
515  const Int_t& NbOfReqEvts) {
516  // CHECK OF THE NUMBER OF FOUND EVENTS, return rNumberOfEvents (NumberOfEvents())
517  // (number used to compute the average values over the events)
518  //
519  // 2D array: called by TEcnaRun object
520 
521  Int_t rNumberOfEvents = 0;
522  Int_t PresentNumber = 0;
523  Int_t DifferentMinusValue = 0;
524  Int_t DifferentPlusValue = 0;
525 
526  for (Int_t i0StexEcha = 0; i0StexEcha < MaxCrysEcnaInStex; i0StexEcha++) {
527  for (Int_t i_samp = 0; i_samp < MaxNbOfSamples; i_samp++) {
528  Int_t NbOfEvts = T2d_NbOfEvts[i0StexEcha][i_samp];
529 
530  if (NbOfEvts > 0) {
531  if (PresentNumber == 0) {
532  PresentNumber = NbOfEvts;
533  } else {
534  if (NbOfEvts > PresentNumber) {
535  PresentNumber = NbOfEvts;
536  DifferentPlusValue++;
537  }
538  if (NbOfEvts < PresentNumber) {
539  DifferentMinusValue++;
540  }
541  }
542  }
543  }
544  }
545  //............................................................. (NumberOfEvents())
546  rNumberOfEvents = PresentNumber;
547 
548  if (DifferentMinusValue > 0 || DifferentPlusValue > 0) {
549  std::cout
550  << "!TEcnaWrite::NumberOfEventsAnalysis()> " << std::endl
551  << "****************** W A R N I N G : NUMBER OF EVENTS NOT CONSTANT ! *********************************"
552  << std::endl
553  << " Result ROOT file: " << fRootFileName << std::endl
554  << " The number of events is not the same for all the non-empty channels" << std::endl
555  << " The maximum number (" << rNumberOfEvents << ") is considered as the number of events " << std::endl
556  << " for calculations of pedestals, noises and correlations." << std::endl
557  << " Number of channels with 0 < nb of evts < " << rNumberOfEvents << " : " << DifferentMinusValue
558  << std::endl
559  // << " Number of channels with nb of evts > " << rNumberOfEvents << " : " << DifferentPlusValue << std::endl
560  // << " Number of empty channels : " << EmptyChannel << std::endl
561  << " Some values of pedestals, noises and correlations may be wrong for channels" << std::endl
562  << " with number of events different from " << rNumberOfEvents << "." << std::endl
563  << " Please, check the histogram 'Numbers of events'." << std::endl
564  << "*******************************************************************************************************"
565  << std::endl;
566  } else {
568  if (rNumberOfEvents < NbOfReqEvts) {
569  std::cout << "*TEcnaWrite::NumberOfEventsAnalysis()> *** INFO *** Number of events found in data = "
570  << rNumberOfEvents << ": less than number of requested events ( = " << NbOfReqEvts << ")"
571  << std::endl;
572  }
573  }
574  }
575  return rNumberOfEvents;
576 
577 } //----- ( end of NumberOfEvents(...) ) ----------------
578 
579 void TEcnaWrite::RegisterFileParameters(const TString& ArgAnaType,
580  const Int_t& ArgNbOfSamples,
581  const Int_t& ArgRunNumber,
582  const Int_t& ArgFirstReqEvtNumber,
583  const Int_t& ArgLastReqEvtNumber,
584  const Int_t& ArgReqNbOfEvts,
585  const Int_t& ArgStexNumber) {
586  fAnaType = ArgAnaType;
587  fNbOfSamples = ArgNbOfSamples;
588  fRunNumber = ArgRunNumber;
589  fFirstReqEvtNumber = ArgFirstReqEvtNumber;
590  fLastReqEvtNumber = ArgLastReqEvtNumber;
591  fReqNbOfEvts = ArgReqNbOfEvts;
592  fStexNumber = ArgStexNumber;
593 }
594 
595 void TEcnaWrite::RegisterFileParameters(const TString& ArgAnaType,
596  const Int_t& ArgNbOfSamples,
597  const Int_t& ArgRunNumber,
598  const Int_t& ArgFirstReqEvtNumber,
599  const Int_t& ArgLastReqEvtNumber,
600  const Int_t& ArgReqNbOfEvts,
601  const Int_t& ArgStexNumber,
602  const TString& ArgStartDate,
603  const TString& ArgStopDate,
604  const time_t ArgStartTime,
605  const time_t ArgStopTime) {
606  fAnaType = ArgAnaType;
607  fNbOfSamples = ArgNbOfSamples;
608  fRunNumber = ArgRunNumber;
609  fFirstReqEvtNumber = ArgFirstReqEvtNumber;
610  fLastReqEvtNumber = ArgLastReqEvtNumber;
611  fReqNbOfEvts = ArgReqNbOfEvts;
612  fStexNumber = ArgStexNumber;
613  fStartDate = ArgStartDate;
614 
615  fStopDate = ArgStopDate;
616  fStartTime = ArgStartTime;
617  fStopTime = ArgStopTime;
618 }
619 //=======================================================================
620 //
621 // FILE NAMES MANAGEMENT
622 //
623 //=======================================================================
624 //==============================================================================
625 //
626 // Results Filename Making (private)
627 //
628 //==============================================================================
630 void TEcnaWrite::fMakeResultsFileName(const Int_t& i_code) {
631  //Results filename making (private)
632 
633  //----------------------------------------------------------------------
634  //
635  // Making of the name of the result file from the parameters set
636  // by call to RegisterFileParameters(...)
637  //
638  // Put the names in the following class attributes:
639  //
640  // fRootFileName, fRootFileNameShort,
641  // fAsciiFileName, fAsciiFileNameShort
642  //
643  // (Short means: without the directory path)
644  //
645  // set indications (run number, type of quantity, ...)
646  // and add the extension ".ascii" or ".root"
647  //
648  // ROOT: only one ROOT file: i_code = fCodeRoot.
649  // All the types of quantities
650  //
651  // ASCII: several ASCII files: i_code = code for one type of quantity
652  // each i_code which is not equal to fCodeRoot is also implicitly
653  // a code "fCodeAscii" (this last attribute is not in the class)
654  //
655  //----------------------------------------------------------------------
656 
657  char* f_in = new char[fgMaxCar];
658  fCnew++;
659  char* f_in_short = new char[fgMaxCar];
660  fCnew++;
661 
662  Int_t MaxCar = fgMaxCar;
663  fStexName.Resize(MaxCar);
664  fStexName = "SM or Dee?";
665 
666  MaxCar = fgMaxCar;
667  fStinName.Resize(MaxCar);
668  fStinName = "tower or SC?";
669 
670  if (fFlagSubDet == "EB") {
671  fStexName = "SM";
672  fStinName = "tower";
673  }
674  if (fFlagSubDet == "EE") {
675  fStexName = "Dee";
676  fStinName = "SC";
677  }
678 
679  // switch (i_code){
680 
681  //=================================== R O O T ========================= (fMakeResultsFileName)
682  TString sPointInterrog = "?";
683  TString sDollarHome = "$HOME";
684 
685  if (i_code == fCodeRoot) {
686  if (fCnaParPaths->ResultsRootFilePath().Data() == sPointInterrog.Data()) {
687  std::cout << "!TEcnaWrite::fMakeResultsFileName> * * * W A R N I N G * * * " << std::endl
688  << std::endl
689  << " Path for results .root file not defined. Default option will be used here:" << std::endl
690  << " your results files will be written in your HOME directory." << std::endl
691  << std::endl
692  << " In order to write the .root results file in a specific directory," << std::endl
693  << " you have to create a file named path_results_root in a subdirectory named ECNA" << std::endl
694  << " previously created in your home directory." << std::endl
695  << " This file must have only one line containing the path of the directory" << std::endl
696  << " where must be the .root result files." << std::endl
697  << std::endl;
698 
699  TString home_path = gSystem->Getenv("HOME");
700  fCnaParPaths->SetResultsRootFilePath(home_path.Data());
701  }
702 
703  if (fCnaParPaths->BeginningOfResultsRootFilePath().Data() == sDollarHome.Data()) {
705  const Text_t* t_file_nohome = (const Text_t*)fCnaParPaths->ResultsRootFilePath().Data(); // /scratch0/cna/...
706 
707  TString home_path = gSystem->Getenv("HOME");
708  fCnaParPaths->SetResultsRootFilePath(home_path.Data()); // /afs/cern.ch/u/USER
709  fCnaParPaths->AppendResultsRootFilePath(t_file_nohome); // /afs/cern.ch/u/USER/scratch0/cna/...
710  }
711 
712  sprintf(f_in,
713  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d",
715  fAnaType.Data(),
716  fNbOfSamples,
717  fRunNumber,
720  fReqNbOfEvts,
721  fStexName.Data(),
722  fStexNumber);
723  sprintf(f_in_short,
724  "%s_S1_%d_R%d_%d_%d_%d_%s%d",
725  fAnaType.Data(),
726  fNbOfSamples,
727  fRunNumber,
730  fReqNbOfEvts,
731  fStexName.Data(),
732  fStexNumber);
733  }
734 
735  //=================================== A S C I I ==================== (fMakeResultsFileName)
736  //fCnaParPaths->GetPathForResultsAsciiFiles();
737  if (i_code != fCodeRoot) {
738  if (i_code == fCodeHeaderAscii) {
739  if (fCnaParPaths->ResultsAsciiFilePath().Data() == sPointInterrog.Data()) {
740  std::cout << "!TEcnaWrite::fMakeResultsFileName> * * * W A R N I N G * * * " << std::endl
741  << std::endl
742  << " Path for results .ascii file not defined. Default option will be used here:" << std::endl
743  << " your results files will be written in your HOME directory." << std::endl
744  << std::endl
745  << " In order to write the .ascii results file in a specific directory," << std::endl
746  << " you have to create a file named path_results_ascii in a subdirectory named ECNA" << std::endl
747  << " previously created in your home directory." << std::endl
748  << " This file must have only one line containing the path of the directory" << std::endl
749  << " where must be the .ascii result files." << std::endl
750  << std::endl;
751 
752  TString home_path = gSystem->Getenv("HOME");
753  fCnaParPaths->SetResultsAsciiFilePath(home_path.Data());
754  }
755 
756  if (fCnaParPaths->BeginningOfResultsAsciiFilePath().Data() == sDollarHome.Data()) {
758  const Text_t* t_file_nohome = (const Text_t*)fCnaParPaths->ResultsAsciiFilePath().Data(); // /scratch0/cna/...
759 
760  TString home_path = gSystem->Getenv("HOME");
761  fCnaParPaths->SetResultsAsciiFilePath(home_path.Data()); // /afs/cern.ch/u/USER
762  fCnaParPaths->AppendResultsAsciiFilePath(t_file_nohome); // /afs/cern.ch/u/USER/scratch0/cna/...
763  }
764  }
765 
766  sprintf(f_in,
767  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_header",
769  fAnaType.Data(),
770  fNbOfSamples,
771  fRunNumber,
774  fReqNbOfEvts,
775  fStexName.Data(),
776  fStexNumber);
777  sprintf(f_in_short,
778  "%s_S1_%d_R%d_%d_%d_%d_%s%d_header",
779  fAnaType.Data(),
780  fNbOfSamples,
781  fRunNumber,
784  fReqNbOfEvts,
785  fStexName.Data(),
786  fStexNumber);
787  }
788 
789  //-------------------------------------------------------------- (fMakeResultsFileName)
790  if (i_code == fCodeNbOfEvts) {
791  sprintf(f_in,
792  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_NbOfEvents",
794  fAnaType.Data(),
795  fNbOfSamples,
796  fRunNumber,
799  fReqNbOfEvts,
800  fStexName.Data(),
801  fStexNumber);
802  sprintf(f_in_short,
803  "%s_S1_%d_R%d_%d_%d_%d_%s%d_NbOfEvents",
804  fAnaType.Data(),
805  fNbOfSamples,
806  fRunNumber,
809  fReqNbOfEvts,
810  fStexName.Data(),
811  fStexNumber);
812  }
813 
814  if (i_code == fCodePed) {
815  sprintf(f_in,
816  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Pedestals",
818  fAnaType.Data(),
819  fNbOfSamples,
820  fRunNumber,
823  fReqNbOfEvts,
824  fStexName.Data(),
825  fStexNumber);
826  sprintf(f_in_short,
827  "%s_S1_%d_R%d_%d_%d_%d_%s%d_Pedestals",
828  fAnaType.Data(),
829  fNbOfSamples,
830  fRunNumber,
833  fReqNbOfEvts,
834  fStexName.Data(),
835  fStexNumber);
836  }
837 
838  if (i_code == fCodeTno) {
839  sprintf(f_in,
840  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_TotalNoise",
842  fAnaType.Data(),
843  fNbOfSamples,
844  fRunNumber,
847  fReqNbOfEvts,
848  fStexName.Data(),
849  fStexNumber);
850  sprintf(f_in_short,
851  "%s_S1_%d_R%d_%d_%d_%d_%s%d_TotalNoise",
852  fAnaType.Data(),
853  fNbOfSamples,
854  fRunNumber,
857  fReqNbOfEvts,
858  fStexName.Data(),
859  fStexNumber);
860  }
861 
862  if (i_code == fCodeLfn) {
863  sprintf(f_in,
864  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LFNoise",
866  fAnaType.Data(),
867  fNbOfSamples,
868  fRunNumber,
871  fReqNbOfEvts,
872  fStexName.Data(),
873  fStexNumber);
874  sprintf(f_in_short,
875  "%s_S1_%d_R%d_%d_%d_%d_%s%d_LFNoise",
876  fAnaType.Data(),
877  fNbOfSamples,
878  fRunNumber,
881  fReqNbOfEvts,
882  fStexName.Data(),
883  fStexNumber);
884  }
885 
886  if (i_code == fCodeHfn) {
887  sprintf(f_in,
888  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_HFNoise",
890  fAnaType.Data(),
891  fNbOfSamples,
892  fRunNumber,
895  fReqNbOfEvts,
896  fStexName.Data(),
897  fStexNumber);
898  sprintf(f_in_short,
899  "%s_S1_%d_R%d_%d_%d_%d_%s%d_HFNoise",
900  fAnaType.Data(),
901  fNbOfSamples,
902  fRunNumber,
905  fReqNbOfEvts,
906  fStexName.Data(),
907  fStexNumber);
908  }
909 
910  if (i_code == fCodeMeanCorss) {
911  sprintf(f_in,
912  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_MeanCorss",
914  fAnaType.Data(),
915  fNbOfSamples,
916  fRunNumber,
919  fReqNbOfEvts,
920  fStexName.Data(),
921  fStexNumber);
922  sprintf(f_in_short,
923  "%s_S1_%d_R%d_%d_%d_%d_%s%d_MeanCorss",
924  fAnaType.Data(),
925  fNbOfSamples,
926  fRunNumber,
929  fReqNbOfEvts,
930  fStexName.Data(),
931  fStexNumber);
932  }
933 
934  if (i_code == fCodeSigCorss) {
935  sprintf(f_in,
936  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SigmaCorss",
938  fAnaType.Data(),
939  fNbOfSamples,
940  fRunNumber,
943  fReqNbOfEvts,
944  fStexName.Data(),
945  fStexNumber);
946  sprintf(f_in_short,
947  "%s_S1_%d_R%d_%d_%d_%d_%s%d_SigmaCorss",
948  fAnaType.Data(),
949  fNbOfSamples,
950  fRunNumber,
953  fReqNbOfEvts,
954  fStexName.Data(),
955  fStexNumber);
956  }
957 
958  if (i_code == fCodeCovCss) {
959  sprintf(f_in,
960  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Covss_%s%d_Channel_%d",
962  fAnaType.Data(),
963  fNbOfSamples,
964  fRunNumber,
967  fReqNbOfEvts,
968  fStexName.Data(),
969  fStexNumber,
970  fStinName.Data(),
972  fStinEchaUser);
973  sprintf(f_in_short,
974  "%s_S1_%d_R%d_%d_%d_%d_%s%d_Covss_%s%d_Channel_%d",
975  fAnaType.Data(),
976  fNbOfSamples,
977  fRunNumber,
980  fReqNbOfEvts,
981  fStexName.Data(),
982  fStexNumber,
983  fStinName.Data(),
985  fStinEchaUser);
986  }
987 
988  if (i_code == fCodeCorCss) {
989  sprintf(f_in,
990  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_Corss_%s%d_Channel_%d",
992  fAnaType.Data(),
993  fNbOfSamples,
994  fRunNumber,
997  fReqNbOfEvts,
998  fStexName.Data(),
999  fStexNumber,
1000  fStinName.Data(),
1001  fStexStinUser,
1002  fStinEchaUser);
1003  sprintf(f_in_short,
1004  "%s_S1_%d_R%d_%d_%d_%d_%s%d_Corss_%s%d_Channel_%d",
1005  fAnaType.Data(),
1006  fNbOfSamples,
1007  fRunNumber,
1010  fReqNbOfEvts,
1011  fStexName.Data(),
1012  fStexNumber,
1013  fStinName.Data(),
1014  fStexStinUser,
1015  fStinEchaUser);
1016  }
1017 
1018  //------- (not used yet)
1019 #define OCOD
1020 #ifndef OCOD
1021  if (i_code == fCodeMSp) {
1022  sprintf(f_in,
1023  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleMeans",
1025  fAnaType.Data(),
1026  fNbOfSamples,
1027  fRunNumber,
1030  fReqNbOfEvts,
1031  fStexName.Data(),
1032  fStexNumber);
1033  sprintf(f_in_short,
1034  "%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleMeans",
1035  fAnaType.Data(),
1036  fNbOfSamples,
1037  fRunNumber,
1040  fReqNbOfEvts,
1041  fStexName.Data(),
1042  fStexNumber);
1043  }
1044 
1045  if (i_code == fCodeSSp) {
1046  sprintf(f_in,
1047  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleSigmas",
1049  fAnaType.Data(),
1050  fNbOfSamples,
1051  fRunNumber,
1054  fReqNbOfEvts,
1055  fStexName.Data(),
1056  fStexNumber);
1057  sprintf(f_in_short,
1058  "%s_S1_%d_R%d_%d_%d_%d_%s%d_SampleSigmas",
1059  fAnaType.Data(),
1060  fNbOfSamples,
1061  fRunNumber,
1064  fReqNbOfEvts,
1065  fStexName.Data(),
1066  fStexNumber);
1067  }
1068 
1069  if (i_code == fCodeAvTno) {
1070  sprintf(f_in,
1071  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageTotalNoise_c%d",
1073  fAnaType.Data(),
1074  fNbOfSamples,
1075  fRunNumber,
1078  fReqNbOfEvts,
1079  fStexName.Data(),
1080  fStexNumber,
1081  fStinEchaUser);
1082  sprintf(f_in_short,
1083  "%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageTotalNoise_c%d",
1084  fAnaType.Data(),
1085  fNbOfSamples,
1086  fRunNumber,
1089  fReqNbOfEvts,
1090  fStexName.Data(),
1091  fStexNumber,
1092  fStinEchaUser);
1093  }
1094 
1095  if (i_code == fCodeLfCov) {
1096  sprintf(f_in,
1097  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cov",
1099  fAnaType.Data(),
1100  fNbOfSamples,
1101  fRunNumber,
1104  fReqNbOfEvts,
1105  fStexName.Data(),
1106  fStexNumber);
1107  sprintf(f_in_short,
1108  "%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cov",
1109  fAnaType.Data(),
1110  fNbOfSamples,
1111  fRunNumber,
1114  fReqNbOfEvts,
1115  fStexName.Data(),
1116  fStexNumber);
1117  }
1118 
1119  if (i_code == fCodeLfCor) {
1120  sprintf(f_in,
1121  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cor",
1123  fAnaType.Data(),
1124  fNbOfSamples,
1125  fRunNumber,
1128  fReqNbOfEvts,
1129  fStexName.Data(),
1130  fStexNumber);
1131  sprintf(f_in_short,
1132  "%s_S1_%d_R%d_%d_%d_%d_%s%d_LF_cor",
1133  fAnaType.Data(),
1134  fNbOfSamples,
1135  fRunNumber,
1138  fReqNbOfEvts,
1139  fStexName.Data(),
1140  fStexNumber);
1141  }
1142 
1143  if (i_code == fCodeAvPed) {
1144  sprintf(f_in,
1145  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragePedestals",
1147  fAnaType.Data(),
1148  fNbOfSamples,
1149  fRunNumber,
1152  fReqNbOfEvts,
1153  fStexName.Data(),
1154  fStexNumber);
1155  sprintf(f_in_short,
1156  "%s_S1_%d_R%d_%d_%d_%d_%s%d_AveragePedestals",
1157  fAnaType.Data(),
1158  fNbOfSamples,
1159  fRunNumber,
1162  fReqNbOfEvts,
1163  fStexName.Data(),
1164  fStexNumber);
1165  }
1166 
1167  if (i_code == fCodeAvMeanCorss) {
1168  sprintf(f_in,
1169  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageMeanCorss%d",
1171  fAnaType.Data(),
1172  fNbOfSamples,
1173  fRunNumber,
1176  fReqNbOfEvts,
1177  fStexName.Data(),
1178  fStexNumber,
1179  fStinEchaUser);
1180  sprintf(f_in_short,
1181  "%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageMeanCorss%d",
1182  fAnaType.Data(),
1183  fNbOfSamples,
1184  fRunNumber,
1187  fReqNbOfEvts,
1188  fStexName.Data(),
1189  fStexNumber,
1190  fStinEchaUser);
1191  }
1192 
1193  if (i_code == fCodeAvSigCorss) {
1194  sprintf(f_in,
1195  "%s/%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageSigmaCorss%d",
1197  fAnaType.Data(),
1198  fNbOfSamples,
1199  fRunNumber,
1202  fReqNbOfEvts,
1203  fStexName.Data(),
1204  fStexNumber,
1205  fStinEchaUser);
1206  sprintf(f_in_short,
1207  "%s_S1_%d_R%d_%d_%d_%d_%s%d_AverageSigmaCorss%d",
1208  fAnaType.Data(),
1209  fNbOfSamples,
1210  fRunNumber,
1213  fReqNbOfEvts,
1214  fStexName.Data(),
1215  fStexNumber,
1216  fStinEchaUser);
1217  }
1218 #endif // OCOD
1219 
1220  //----------------------------------------------------------- (fMakeResultsFileName)
1221 
1222  // default:
1223  // std::cout << "*TEcnaWrite::fMakeResultsFileName(const Int_t& i_code)> "
1224  // << "wrong header code , i_code = " << i_code << std::endl;
1225  // }
1226 
1227  //======================================= f_name
1228 
1229  char* f_name = new char[fgMaxCar];
1230  fCnew++;
1231 
1232  for (Int_t i = 0; i < fgMaxCar; i++) {
1233  f_name[i] = '\0';
1234  }
1235 
1236  Int_t ii = 0;
1237  for (Int_t i = 0; i < fgMaxCar; i++) {
1238  if (f_in[i] != '\0') {
1239  f_name[i] = f_in[i];
1240  ii++;
1241  } else {
1242  break;
1243  } // va directement a if ( ii+5 < fgMaxCar ) puis... f_name[ii] = '.';
1244  }
1245 
1246  if (ii + 5 < fgMaxCar) {
1247  //.......... writing of the file extension (.root or .ascii) (fMakeResultsFileName)
1248 
1249  //------------------------------------------- extension .ascii
1250  if (i_code != fCodeRoot || i_code == fCodeNbOfEvts) {
1251  f_name[ii] = '.';
1252  f_name[ii + 1] = 'a';
1253  f_name[ii + 2] = 's';
1254  f_name[ii + 3] = 'c';
1255  f_name[ii + 4] = 'i';
1256  f_name[ii + 5] = 'i';
1257 
1258  fAsciiFileName = f_name;
1259  }
1260  //------------------------------------------- extension .root
1261  if (i_code == fCodeRoot) {
1262  f_name[ii] = '.';
1263  f_name[ii + 1] = 'r';
1264  f_name[ii + 2] = 'o';
1265  f_name[ii + 3] = 'o';
1266  f_name[ii + 4] = 't';
1267 
1268  fRootFileName = f_name;
1269  }
1270  } else {
1271  std::cout << "*TEcnaWrite::fMakeResultsFileName(...)> Name too long (for f_name)."
1272  << " No room enough for the extension. (ii = " << ii << ")" << fTTBELL << std::endl;
1273  }
1274 
1275  //====================================== f_name_short (fMakeResultsFileName)
1276 
1277  char* f_name_short = new char[fgMaxCar];
1278  fCnew++;
1279 
1280  for (Int_t i = 0; i < fgMaxCar; i++) {
1281  f_name_short[i] = '\0';
1282  }
1283 
1284  ii = 0;
1285  for (Int_t i = 0; i < fgMaxCar; i++) {
1286  if (f_in_short[i] != '\0') {
1287  f_name_short[i] = f_in_short[i];
1288  ii++;
1289  } else {
1290  break;
1291  } // va directement a f_name_short[ii] = '.';
1292  }
1293 
1294  if (ii + 5 < fgMaxCar) {
1295  //.......... writing of the file extension (.root or .ascii)
1296 
1297  //-------------------------------------------extension .ascii
1298  if (i_code != fCodeRoot || i_code == fCodeNbOfEvts) {
1299  f_name_short[ii] = '.';
1300  f_name_short[ii + 1] = 'a';
1301  f_name_short[ii + 2] = 's';
1302  f_name_short[ii + 3] = 'c';
1303  f_name_short[ii + 4] = 'i';
1304  f_name_short[ii + 5] = 'i';
1305 
1306  fAsciiFileNameShort = f_name_short;
1307  }
1308 
1309  //-------------------------------------------- extension .root
1310  if (i_code == fCodeRoot) {
1311  f_name_short[ii] = '.';
1312  f_name_short[ii + 1] = 'r';
1313  f_name_short[ii + 2] = 'o';
1314  f_name_short[ii + 3] = 'o';
1315  f_name_short[ii + 4] = 't';
1316 
1317  fRootFileNameShort = f_name_short;
1318  }
1319  } else {
1320  std::cout << "*TEcnaWrite::fMakeResultsFileName(...)> Name too long (for f_name_short)."
1321  << " No room enough for the extension. (ii = " << ii << ")" << fTTBELL << std::endl;
1322  }
1323  delete[] f_name;
1324  f_name = nullptr;
1325  fCdelete++;
1326  delete[] f_name_short;
1327  f_name_short = nullptr;
1328  fCdelete++;
1329 
1330  delete[] f_in;
1331  f_in = nullptr;
1332  fCdelete++;
1333  delete[] f_in_short;
1334  f_in_short = nullptr;
1335  fCdelete++;
1336 
1337 } // end of fMakeResultsFileName
1338 
1339 //==========================================================================================
1340 //
1341 //
1342 //
1343 //==========================================================================================
1344 
1345 void TEcnaWrite::fAsciiFileWriteHeader(const Int_t& i_code) {
1346  //Ascii results file header writing (private). Called by the WriteAscii...() methods
1347 
1348  //-----------------------------------------------
1349  //
1350  // opening of the ASCII results file
1351  // and writing of its header
1352  //
1353  //-----------------------------------------------
1354 
1355  if (fAsciiFileName.BeginsWith("$HOME")) {
1356  fAsciiFileName.Remove(0, 5);
1357  TString EndOfAsciiFileName = fAsciiFileName;
1358  const Text_t* t_file_nohome = (const Text_t*)EndOfAsciiFileName.Data(); // const Text_t* -> EndOfAsciiFileName
1359  // ( /scratch0/cna/... )
1360  TString home_path = gSystem->Getenv("HOME");
1361  fAsciiFileName = home_path; // fAsciiFileName = absolute HOME path ( /afs/cern.ch/u/USER )
1362  fAsciiFileName.Append(t_file_nohome); // Append (const Text_t* -> EndOfAsciiFileName) to fAsciiFileName
1363  // ( /afs/cern.ch/u/USER/scratch0/cna/... )
1364  }
1365 
1366  fFcout_f.open(fAsciiFileName.Data());
1367 
1368  fFcout_f << "*** File: " << fAsciiFileName << " *** " << std::endl << std::endl;
1369  fFcout_f << "*Analysis name : " << fAnaType << std::endl;
1370  fFcout_f << "*First-Last samples : 1 - " << fNbOfSamples << std::endl;
1371  fFcout_f << "*Run number : " << fRunNumber << std::endl;
1372  fFcout_f << "*First requested event number : " << fFirstReqEvtNumber << std::endl;
1373  fFcout_f << "*Last requested event number : " << fLastReqEvtNumber << std::endl;
1374  fFcout_f << "*Requested number of events : " << fReqNbOfEvts << std::endl;
1375  if (fFlagSubDet == "EB") {
1376  fFcout_f << "*SuperModule number : " << fStexNumber << std::endl;
1377  }
1378  if (fFlagSubDet == "EE") {
1379  fFcout_f << "*Dee number : " << fStexNumber << std::endl;
1380  }
1381  fFcout_f << "*Date first requested event : " << fStartDate;
1382  fFcout_f << "*Date last requested event : " << fStopDate << std::endl;
1383  fFcout_f << std::endl;
1384 
1385  //=========================================================================
1386  // closing of the results file if i_code = fCodeHeaderAscii only.
1387  // closing is done in the fT1dWriteAscii() and fT2dWriteAscii() methods
1388  // except for i_code = fCodeHeaderAscii
1389  //=========================================================================
1390  if (i_code == fCodeHeaderAscii) {
1391  fFcout_f.close();
1392  }
1393 }
1394 
1395 //=========================================================================
1396 //
1397 // W R I T I N G M E T H O D S : R O O T F I L E S
1398 //
1399 // The root files are written by TEcnaRun since the arrays are computed
1400 // by this class (arrays fT2d_..., fT1d_..) and are private attributes.
1401 // No writing method in ROOT file here.
1402 // Just the making of the file name
1403 //
1404 //=========================================================================
1405 
1406 //=========================================================================
1407 //
1408 // W R I T I N G M E T H O D S : A S C I I F I L E S
1409 //
1410 // Ascii file are treated on the same footing as plots in the
1411 // TEcnaHistos methods.
1412 // The arrays are TVectorD or TMatrixD and are arguments of the
1413 // writting methods (WriteAsciiHisto, fT2dWriteAscii)
1414 //
1415 //=========================================================================
1416 //
1417 // In the following, we describe:
1418 //
1419 // (1) The method which gets the path for the results ASCII files
1420 // from a "cna-configuration" file
1421 // (2) The codification for the names of the ASCII files
1422 // (3) The methods which writes the results in the ASCII files
1423 //
1424 //
1425 //
1426 // (1)-----------> Method to set the path for the results ASCII files
1427 //
1428 // void MyCnaRun->GetPathForResultsAsciiFiles(pathname);
1429 //
1430 // TString pathname = name of a "cna-config" file located
1431 // in the user's HOME directory and containing one line which
1432 // specifies the path where must be written the .ascii result files.
1433 // (no slash at the end of the string)
1434 //
1435 // DEFAULT:
1436 // void MyCnaRun->GetPathForResultsAsciiFiles();
1437 // If there is no argument, the "cna-config" file must be named
1438 // "path_results_ascii.ecna" and must be located in the user's HOME
1439 // directory
1440 //
1441 //
1442 // (2)-----------> Codification for the names of the ASCII files (examples):
1443 //
1444 // aaa_nnnS_Rrrr_fff_ttt_SMnnn_pedestals.ascii OR aaa_nnnS_Rrrr_fff_ttt_Deennn_pedestals.ascii
1445 // aaa_nnnS_Rrrr_fff_ttt_SMnnn_HF_noise.ascii OR aaa_nnnS_Rrrr_fff_ttt_Deennn_HF_noise.ascii
1446 // aaa_nnnS_Rrrr_fff_ttt_SMnnn_corss_cCCC.ascii OR aaa_nnnS_Rrrr_fff_ttt_Deennn_corss_cCCC.ascii
1447 // etc...
1448 //
1449 // with:
1450 // aaa = Analysis name
1451 // rrr = Run number
1452 // fff = First requested event number
1453 // ttt = Number of requested events
1454 // CCC = Electronic Channel number in Stex
1455 // nnn = SM number or Dee number
1456 //
1457 // Examples:
1458 // StdPed12_10S_R66689_1_50_SM1_pedestals.ascii
1459 // StdPed6_10S_R66689_1_50_Dee3_cor_ss_c2234.ascii
1460 //
1461 //
1462 // (3)-----------> Methods which write the ASCII files:
1463 //
1464 // The methods which write the ASCII files are the following:
1465 //
1466 // void WriteAsciiCovariancesBetweenSamples(Channel, MatrixSize, TMatrixD matrix);
1467 // void WriteAsciiCorrelationsBetweenSamples(Channel, MatrixSize, TMatrixD matrix);
1468 // void fT2dWriteAscii(code, px, py, MatrixSize, TMatrixD matrix) [private]
1469 // void WriteAsciiHisto(CodeHisto, HistoSize, TVectorD histo)
1470 //
1471 // Each of these methods corresponds to a "calculation method" of TEcnaRun.
1472 // The calculation method of TEcnaRun must have been been called before
1473 // using the writing method of TEcnaWrite.
1474 //==========================================================================================
1475 
1476 //-------------------------------------------------------------------------------------------
1477 //
1478 // WriteAsciiHisto()
1479 //
1480 // Stex = SM or Dee , Stin = Tower or SC
1481 //
1482 //-------------------------------------------------------------------------------------------
1483 void TEcnaWrite::WriteAsciiHisto(const TString& HistoCode, const Int_t& HisSize, const TVectorD& read_histo) {
1484  //Write histo with correspondance CNA-channel <-> xtal number in SM or Dee
1485 
1486  // BuildCrysTable() is called in the method Init() which is called by the constructor
1487 
1488  Int_t i_code = fCodeNbOfEvts;
1489 
1490  //--------------------------------------------------------------------------------
1491  if (HistoCode == "D_NOE_ChNb") {
1492  i_code = fCodeNbOfEvts;
1493  }
1494  if (HistoCode == "D_Ped_ChNb") {
1495  i_code = fCodePed;
1496  }
1497  if (HistoCode == "D_TNo_ChNb") {
1498  i_code = fCodeTno;
1499  }
1500  if (HistoCode == "D_LFN_ChNb") {
1501  i_code = fCodeLfn;
1502  }
1503  if (HistoCode == "D_HFN_ChNb") {
1504  i_code = fCodeHfn;
1505  }
1506  if (HistoCode == "D_MCs_ChNb") {
1507  i_code = fCodeMeanCorss;
1508  }
1509  if (HistoCode == "D_SCs_ChNb") {
1510  i_code = fCodeSigCorss;
1511  }
1512 
1513  fMakeResultsFileName(i_code); // => Making of the results .ascii file name
1514  fAsciiFileWriteHeader(i_code); // => Open of the file associated with stream fFcout_f
1515 
1516  //..................................... format numerical values
1517  fFcout_f << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1518  fFcout_f << std::setprecision(3) << std::setw(6);
1519  fFcout_f.setf(std::ios::dec, std::ios::basefield);
1520  fFcout_f.setf(std::ios::fixed, std::ios::floatfield);
1521  fFcout_f.setf(std::ios::left, std::ios::adjustfield);
1522  fFcout_f.setf(std::ios::right, std::ios::adjustfield);
1523 
1524  std::cout << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1525  std::cout << std::setprecision(3) << std::setw(6);
1526  std::cout.setf(std::ios::dec, std::ios::basefield);
1527  std::cout.setf(std::ios::fixed, std::ios::floatfield);
1528  std::cout.setf(std::ios::left, std::ios::adjustfield);
1529  std::cout.setf(std::ios::right, std::ios::adjustfield);
1530 
1531  //........................................................ WriteAsciiHisto
1532  TString aStexName;
1533  Int_t MaxCar = fgMaxCar;
1534  aStexName.Resize(MaxCar);
1535  aStexName = "SM or Dee?";
1536 
1537  TString aStinName;
1538  MaxCar = fgMaxCar;
1539  aStinName.Resize(MaxCar);
1540  aStinName = "Tower or SC?";
1541 
1542  TString aHoco;
1543  MaxCar = fgMaxCar;
1544  aHoco.Resize(MaxCar);
1545  aHoco = "Eta or IX?";
1546 
1547  TString aVeco;
1548  MaxCar = fgMaxCar;
1549  aVeco.Resize(MaxCar);
1550  aVeco = "Phi or IY?";
1551 
1552  TString aSpecifa;
1553  MaxCar = fgMaxCar;
1554  aSpecifa.Resize(MaxCar);
1555  aSpecifa = " ";
1556 
1557  TString aSpecifc;
1558  MaxCar = fgMaxCar;
1559  aSpecifc.Resize(MaxCar);
1560  aSpecifc = " ";
1561 
1562  TString aSpecifd;
1563  MaxCar = fgMaxCar;
1564  aSpecifd.Resize(MaxCar);
1565  aSpecifd = " ";
1566 
1567  TString aSpecife;
1568  MaxCar = fgMaxCar;
1569  aSpecife.Resize(MaxCar);
1570  aSpecife = " ";
1571 
1572  TString aSpecif1;
1573  MaxCar = fgMaxCar;
1574  aSpecif1.Resize(MaxCar);
1575  aSpecif1 = " ";
1576 
1577  TString aSpecif2;
1578  MaxCar = fgMaxCar;
1579  aSpecif2.Resize(MaxCar);
1580  aSpecif2 = " ";
1581 
1582  if (fFlagSubDet == "EB") {
1583  aStexName = "SM ";
1584  aStinName = "tower";
1585  aSpecifa = " channel# ";
1586  aHoco = " Eta ";
1587  aVeco = " Phi ";
1588  aSpecifc = " channel# ";
1589  aSpecifd = " crystal# ";
1590  aSpecife = "SM ";
1591  }
1592  if (fFlagSubDet == "EE") {
1593  aStexName = "Dee ";
1594  aStinName = " SC ";
1595  aSpecifa = " Sector# ";
1596  aHoco = " IX ";
1597  aVeco = " IY ";
1598  aSpecifc = " crystal# ";
1599  aSpecifd = " SC # ";
1600  aSpecife = "Sector";
1601  }
1602 
1603  //.............................................................. WriteAsciiHisto
1604  for (Int_t i0StexEcha = 0; i0StexEcha < HisSize; i0StexEcha++) {
1605  Int_t n1StexStin = 0;
1606  Int_t StexStinEcna = 0;
1607  Int_t i0StinEcha = 0;
1608  Int_t n1StinEcha = 0;
1609  Int_t n1StexCrys = 0;
1610  Int_t n1DataSector = 0;
1611  Int_t n1SCinDS = 0;
1612 
1613  if (fFlagSubDet == "EB") {
1614  n1StexStin = fEcalNumbering->Get1SMTowFrom0SMEcha(i0StexEcha);
1615  StexStinEcna = n1StexStin;
1616  i0StinEcha = fEcalNumbering->Get0TowEchaFrom0SMEcha(i0StexEcha);
1617  n1StexCrys = fEcalNumbering->Get1SMCrysFrom1SMTowAnd0TowEcha(n1StexStin, i0StinEcha);
1618  }
1619  if (fFlagSubDet == "EE") {
1620  StexStinEcna = fEcalNumbering->Get1DeeSCEcnaFrom0DeeEcha(i0StexEcha);
1621  n1DataSector = fEcalNumbering->GetDSFrom1DeeSCEcna(fStexNumber, StexStinEcna);
1622  n1SCinDS = fEcalNumbering->GetDSSCFrom1DeeSCEcna(fStexNumber, StexStinEcna);
1623  n1StexStin = fEcalNumbering->GetDeeSCConsFrom1DeeSCEcna(fStexNumber, StexStinEcna);
1624  n1StinEcha = fEcalNumbering->Get1SCEchaFrom0DeeEcha(i0StexEcha);
1625  }
1626 
1627  if (n1StexStin > 0) {
1628  if ((fFlagSubDet == "EB" && i0StinEcha == 0) || (fFlagSubDet == "EE" && n1StinEcha == 1)) {
1629  if (HistoCode == "D_NOE_ChNb") {
1630  aSpecif1 = "Number of";
1631  aSpecif2 = " events (requested)";
1632  }
1633  if (HistoCode == "D_Ped_ChNb") {
1634  aSpecif1 = "Pedestals";
1635  aSpecif2 = " ";
1636  }
1637  if (HistoCode == "D_TNo_ChNb") {
1638  aSpecif1 = " Total ";
1639  aSpecif2 = " noise ";
1640  }
1641  if (HistoCode == "D_MCs_ChNb") {
1642  aSpecif1 = " Mean ";
1643  aSpecif2 = " cor(s,s) ";
1644  }
1645  if (HistoCode == "D_LFN_ChNb") {
1646  aSpecif1 = " Low Fq";
1647  aSpecif2 = " noise ";
1648  }
1649  if (HistoCode == "D_HFN_ChNb") {
1650  aSpecif1 = " High Fq";
1651  aSpecif2 = " noise ";
1652  }
1653  if (HistoCode == "D_SCs_ChNb") {
1654  aSpecif1 = " Sigma of";
1655  aSpecif2 = " cor(s,s) ";
1656  }
1657 
1658  fFcout_f << std::endl;
1659 
1660  fFcout_f << aSpecifa.Data() << " " << aStinName.Data() << "# " << aSpecifc.Data() << aSpecifd.Data()
1661  << aHoco.Data() << aVeco.Data() << aSpecif1.Data() << std::endl;
1662 
1663  fFcout_f << " in " << aStexName.Data() << " in " << aStexName.Data() << " in " << aStinName.Data() << " in "
1664  << aSpecife.Data() << " in " << aStexName.Data() << " in " << aStexName.Data() << aSpecif2.Data()
1665  << std::endl
1666  << std::endl;
1667  }
1668 
1669  Double_t value = read_histo(i0StexEcha);
1670 
1671  if (fFlagSubDet == "EB") {
1672  fFcout_f << std::setw(7) << i0StexEcha << std::setw(8) << n1StexStin << std::setw(11)
1673  << i0StinEcha // (Electronic channel number in tower)
1674  << std::setw(10) << n1StexCrys << std::setw(10)
1675  << (Int_t)fEcalNumbering->GetEta(fStexNumber, StexStinEcna, i0StinEcha) << std::setw(10)
1676  << (Int_t)fEcalNumbering->GetPhiInSM(fStexNumber, StexStinEcna, i0StinEcha);
1677  }
1678  if (fFlagSubDet == "EE") {
1679  Int_t n1StinEcha_m = n1StinEcha - 1;
1680  fFcout_f << std::setw(7) << n1DataSector << std::setw(8) << n1StexStin << std::setw(11)
1681  << n1StinEcha // (Xtal number for construction in SC)
1682  << std::setw(10) << n1SCinDS << std::setw(10)
1683  << fEcalNumbering->GetIXCrysInDee(fStexNumber, StexStinEcna, n1StinEcha_m) << std::setw(10)
1684  << fEcalNumbering->GetJYCrysInDee(fStexNumber, StexStinEcna, n1StinEcha_m);
1685  }
1686 
1687  if (HistoCode == "D_NOE_ChNb") {
1688  Int_t ivalue = (Int_t)value;
1689  fFcout_f << std::setw(13) << ivalue;
1690  fFcout_f << std::setw(4) << "(" << std::setw(6) << fReqNbOfEvts << ")";
1691  } else {
1692  fFcout_f << std::setw(13) << value;
1693  }
1694 
1695  fFcout_f << std::endl;
1696  }
1697  } // end of loop: for (Int_t i0StexEcha=0; i0StexEcha<HisSize; i0StexEcha++)
1698 
1699  fFcout_f.close();
1700 
1701  // if(fFlagPrint != fCodePrintNoComment)
1702  // {
1703  std::cout << "*TEcnaWrite::WriteAsciiHisto(...)> INFO: "
1704  << "histo has been written in file: " << std::endl
1705  << " " << fAsciiFileName.Data() << std::endl;
1706  // }
1707 } // end of TEcnaWrite::WriteAsciiHisto
1708 
1709 //================================================================================
1710 //
1711 // W R I T I N G O F T H E C O V A N D C O R M A T R I C E S
1712 //
1713 //================================================================================
1714 
1715 //--------------------------------------------------------------------------------
1716 //
1717 // Writing of the covariances between samples
1718 // for a given StexEcha in an ASCII file
1719 //
1720 //--------------------------------------------------------------------------------
1721 void TEcnaWrite::WriteAsciiCovariancesBetweenSamples(const Int_t& user_StexStin,
1722  const Int_t& user_StinEcha,
1723  const Int_t& MatSize,
1724  const TMatrixD& read_matrix) {
1725  //Writing of the covariances between samples for a given StexEcha in an ASCII file
1726 
1727  if (fFlagSubDet == "EB") {
1728  fStexStinUser = user_StexStin;
1729  }
1730  if (fFlagSubDet == "EE") {
1732  }
1733 
1734  if (fFlagSubDet == "EB") {
1735  fStinEchaUser = user_StinEcha;
1736  }
1737  if (fFlagSubDet == "EE") {
1738  fStinEchaUser = user_StinEcha + 1;
1739  }
1740 
1741  Int_t i_code = fCodeCovCss; // code for covariances between samples
1742  fMakeResultsFileName(i_code);
1743  fAsciiFileWriteHeader(i_code);
1744 
1745  Int_t i_pasx = fSectSampSizeX;
1746  Int_t i_pasy = fSectSampSizeY;
1747 
1748  fT2dWriteAscii(i_code, i_pasx, i_pasy, MatSize, read_matrix);
1749 }
1750 
1751 //---------------------------------------------------------------------------------
1752 //
1753 // Writing of the correlations between samples
1754 // for a given StexEcha in an ASCII file
1755 //
1756 //---------------------------------------------------------------------------------
1758  const Int_t& user_StinEcha,
1759  const Int_t& MatSize,
1760  const TMatrixD& read_matrix) {
1761  //Writing of the correlations between samples for a given StexEcha in an ASCII file
1762 
1763  if (fFlagSubDet == "EB") {
1764  fStexStinUser = user_StexStin;
1765  }
1766  if (fFlagSubDet == "EE") {
1768  }
1769 
1770  if (fFlagSubDet == "EB") {
1771  fStinEchaUser = user_StinEcha;
1772  }
1773  if (fFlagSubDet == "EE") {
1774  fStinEchaUser = user_StinEcha + 1;
1775  }
1776 
1777  Int_t i_code = fCodeCorCss; // code for correlations between samples
1778  fMakeResultsFileName(i_code);
1779  fAsciiFileWriteHeader(i_code);
1780 
1781  Int_t i_pasx = fSectSampSizeX;
1782  Int_t i_pasy = fSectSampSizeY;
1783 
1784  fT2dWriteAscii(i_code, i_pasx, i_pasy, MatSize, read_matrix);
1785 }
1786 
1787 //----------------------------------------------------------------------
1788 //
1789 // fT2dWriteAscii: Array 2D of (n_sctx , n_scty) sectors
1790 // of size: i_pasx_arg * i_pasy_arg
1791 //
1792 // (private)
1793 //
1794 //----------------------------------------------------------------------
1795 
1796 void TEcnaWrite::fT2dWriteAscii(const Int_t& i_code,
1797  const Int_t& i_pasx_arg,
1798  const Int_t& i_pasy_arg,
1799  const Int_t& MatSize,
1800  const TMatrixD& read_matrix) {
1801  //Writing of a matrix by sectors (private)
1802 
1803  Int_t i_pasx = i_pasx_arg; // taille secteur en x
1804  Int_t i_pasy = i_pasy_arg; // taille secteur en y
1805 
1806  //------------ formatage des nombres en faisant appel a la classe ios
1807 
1808  fFcout_f << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1809  fFcout_f.setf(std::ios::dec, std::ios::basefield);
1810  fFcout_f.setf(std::ios::fixed, std::ios::floatfield);
1811  fFcout_f.setf(std::ios::left, std::ios::adjustfield);
1812  fFcout_f.setf(std::ios::right, std::ios::adjustfield);
1813  fFcout_f << std::setprecision(3) << std::setw(6);
1814 
1815  std::cout << std::setiosflags(std::ios::showpoint | std::ios::uppercase);
1816  std::cout.setf(std::ios::dec, std::ios::basefield);
1817  std::cout.setf(std::ios::fixed, std::ios::floatfield);
1818  std::cout.setf(std::ios::left, std::ios::adjustfield);
1819  std::cout.setf(std::ios::right, std::ios::adjustfield);
1820  std::cout << std::setprecision(3) << std::setw(6);
1821 
1822  //--------------------- fin du formatage standard C++ -------------------
1823 
1824  //-----------------------------------------------------------------------
1825  // Reservation dynamique d'un array Double_t** de dimensions
1826  // les multiples de 5 juste au-dessus des dimensions de l'array 2D
1827  // a ecrire ( array de dimensions
1828  // (fEcal->MaxSampADC(),fEcal->MaxSampADC())
1829  // (fEcal->MaxCrysEcnaInStex(),fEcal->MaxCrysEcnaInStex()) )
1830  //-----------------------------------------------------------------------
1831  // Determination des tailles multiples de fSectChanSizeX ou fSectSampSizeX
1832 
1833 #define NOUC
1834 #ifndef NOUC
1835 
1836  //*************** channels *************
1837  Int_t justap_chan = 0;
1838 
1839  if (fEcal->MaxCrysEcnaInStex() % fSectChanSizeX == 0) {
1840  justap_chan = fEcal->MaxCrysEcnaInStex();
1841  } else {
1842  justap_chan = ((fEcal->MaxCrysEcnaInStex() / fSectChanSizeX) + 1) * fSectChanSizeX;
1843  }
1844 
1845  //....................... Allocation fjustap_2d_cc
1846 
1847  if (i_code == fCodeHfCov || i_code == fCodeHfCor || i_code == fCodeLfCov || i_code == fCodeLfCor) {
1848  if (fjustap_2d_cc == 0) {
1849  //................... Allocation
1850  fjustap_2d_cc = new Double_t*[justap_chan];
1851  fCnew++;
1852  fjustap_1d_cc = new Double_t[justap_chan * justap_chan];
1853  fCnew++;
1854  for (Int_t i = 0; i < justap_chan; i++) {
1855  fjustap_2d_cc[i] = &fjustap_1d_cc[0] + i * justap_chan;
1856  }
1857  }
1858 
1859  //............................... Transfert des valeurs dans fjustap_2d_cc (=init)
1860  for (Int_t i = 0; i < fEcal->MaxCrysEcnaInStex(); i++) {
1861  for (Int_t j = 0; j < fEcal->MaxCrysEcnaInStex(); j++) {
1862  if (i_code == fCodeHfCov) {
1863  fjustap_2d_cc[i][j] = read_matrix(i, j);
1864  }
1865  if (i_code == fCodeHfCor) {
1866  fjustap_2d_cc[i][j] = read_matrix(i, j);
1867  }
1868  if (i_code == fCodeLfCov) {
1869  fjustap_2d_cc[i][j] = read_matrix(i, j);
1870  }
1871  if (i_code == fCodeLfCor) {
1872  fjustap_2d_cc[i][j] = read_matrix(i, j);
1873  }
1874  }
1875  }
1876 
1877  //.......................... mise a zero du reste de la matrice (=init)
1878  for (Int_t i = fEcal->MaxCrysEcnaInStex(); i < justap_chan; i++) {
1879  for (Int_t j = fEcal->MaxCrysEcnaInStex(); j < justap_chan; j++) {
1880  fjustap_2d_cc[i][j] = (Double_t)0.;
1881  }
1882  }
1883  }
1884 
1885 #endif //NOUC
1886 
1887  //************************************ Samples ***************************
1888  Int_t justap_samp = 0;
1889 
1890  if (fEcal->MaxSampADC() % fSectSampSizeX == 0) {
1891  justap_samp = fEcal->MaxSampADC();
1892  } else {
1893  justap_samp = ((fEcal->MaxSampADC() / fSectSampSizeX) + 1) * fSectSampSizeX;
1894  }
1895 
1896  //....................... allocation fjustap_2d_ss
1897 
1898  if (i_code == fCodeCovCss || i_code == fCodeCorCss || i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss) {
1899  if (fjustap_2d_ss == nullptr) {
1900  //................... Allocation
1901  fjustap_2d_ss = new Double_t*[justap_samp];
1902  fCnew++;
1903  fjustap_1d_ss = new Double_t[justap_samp * justap_samp];
1904  fCnew++;
1905  for (Int_t i = 0; i < justap_samp; i++) {
1906  fjustap_2d_ss[i] = &fjustap_1d_ss[0] + i * justap_samp;
1907  }
1908  }
1909 
1910  //.............................. Transfert des valeurs dans fjustap_2d_ss (=init)
1911  for (Int_t i = 0; i < fEcal->MaxSampADC(); i++) {
1912  for (Int_t j = 0; j < fEcal->MaxSampADC(); j++) {
1913  if (i_code == fCodeCovCss) {
1914  fjustap_2d_ss[i][j] = read_matrix(i, j);
1915  }
1916  if (i_code == fCodeCorCss) {
1917  fjustap_2d_ss[i][j] = read_matrix(i, j);
1918  }
1919  if (i_code == fCodeAvMeanCorss) {
1920  fjustap_2d_ss[i][j] = read_matrix(i, j);
1921  }
1922  if (i_code == fCodeAvSigCorss) {
1923  fjustap_2d_ss[i][j] = read_matrix(i, j);
1924  }
1925  }
1926  }
1927 
1928  //.......................... mise a zero du reste de la matrice (=init)
1929  for (Int_t i = fEcal->MaxSampADC(); i < justap_samp; i++) {
1930  for (Int_t j = fEcal->MaxSampADC(); j < justap_samp; j++) {
1931  fjustap_2d_ss[i][j] = (Double_t)0.;
1932  }
1933  }
1934  }
1935 
1936  //..................... impressions + initialisations selon i_code
1937 
1938  Int_t isx_max = 0;
1939  Int_t isy_max = 0;
1940 
1941 #define COCC
1942 #ifndef COCC
1943  if (i_code == fCodeHfCov) {
1944  fFcout_f << "Covariance matrix between channels "
1945  << "for sample number " << fUserSamp;
1946  isx_max = justap_chan;
1947  isy_max = justap_chan;
1948  }
1949  if (i_code == fCodeHfCor) {
1950  fFcout_f << "*Correlation matrix between channels "
1951  << "for sample number " << fUserSamp;
1952  isx_max = justap_chan;
1953  isy_max = justap_chan;
1954  }
1955 
1956  if (i_code == fCodeLfCov) {
1957  fFcout_f << "Covariance matrix between channels "
1958  << "averaged on the samples ";
1959  isx_max = justap_chan;
1960  isy_max = justap_chan;
1961  }
1962  if (i_code == fCodeLfCor) {
1963  fFcout_f << "Correlation matrix between channels "
1964  << "averaged on the samples ";
1965  isx_max = justap_chan;
1966  isy_max = justap_chan;
1967  }
1968 #endif // COCC
1969 
1970  Int_t n1StexStin = 0;
1971  Int_t i0StinEcha = 0;
1972  Int_t n1StinEcha = 0;
1973 
1974  if (fFlagSubDet == "EB") {
1975  n1StexStin = fStexStinUser;
1977  }
1978  if (fFlagSubDet == "EE") {
1979  n1StexStin = fStexStinUser;
1980  Int_t fStinEchaUser_m = fStinEchaUser - 1;
1981  n1StinEcha = fEcalNumbering->Get1SCEchaFrom0DeeEcha(fStinEchaUser_m);
1982 
1983  TString sDeeDir = fEcalNumbering->GetDeeDirViewedFromIP(fStexNumber);
1984  }
1985 
1986  if (i_code == fCodeCovCss) {
1987  if (fFlagSubDet == "EB") {
1988  fFcout_f << "Covariance matrix between samples "
1989  << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
1990  << fStinName << ": " << i0StinEcha << ")";
1991  }
1992  if (fFlagSubDet == "EE") {
1993  fFcout_f << "Covariance matrix between samples "
1994  << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
1995  << fStinName << ": " << n1StinEcha << ")";
1996  }
1997  isx_max = justap_samp;
1998  isy_max = justap_samp;
1999  }
2000  if (i_code == fCodeCorCss) {
2001  if (fFlagSubDet == "EB") {
2002  fFcout_f << "Correlation matrix between samples "
2003  << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
2004  << fStinName << ": " << i0StinEcha << ")";
2005  }
2006  if (fFlagSubDet == "EE") {
2007  fFcout_f << "Correlation matrix between samples "
2008  << "for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin << " , channel in "
2009  << fStinName << ": " << n1StinEcha << ")";
2010  }
2011  isx_max = justap_samp;
2012  isy_max = justap_samp;
2013  }
2014 
2015  if (i_code == fCodeAvMeanCorss) {
2016  if (fFlagSubDet == "EB") {
2017  fFcout_f << "Correction factors to the covariances "
2018  << "between samples for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin
2019  << " , channel in " << fStinName << ": " << i0StinEcha << ")";
2020  }
2021  if (fFlagSubDet == "EE") {
2022  fFcout_f << "Correction factors to the covariances "
2023  << "between samples for channel number " << fStinEchaUser << " (" << fStinName << ": " << n1StexStin
2024  << " , channel in " << fStinName << ": " << n1StinEcha << ")";
2025  }
2026  isx_max = justap_samp;
2027  isy_max = justap_samp;
2028  }
2029 
2030  if (i_code == fCodeAvSigCorss) {
2031  if (fFlagSubDet == "EB") {
2032  fFcout_f << "Correction factors to the correlations "
2033  << "between samples for channel number " << fStinEchaUser << " ( " << fStinName << ": " << n1StexStin
2034  << " , channel in " << fStinName << ": " << i0StinEcha << ")";
2035  }
2036  if (fFlagSubDet == "EE") {
2037  fFcout_f << "Correction factors to the correlations "
2038  << "between samples for channel number " << fStinEchaUser << " ( " << fStinName << ": " << n1StexStin
2039  << " , channel in " << fStinName << ": " << n1StinEcha << ")";
2040  }
2041  isx_max = justap_samp;
2042  isy_max = justap_samp;
2043  }
2044 
2045  fFcout_f << std::endl;
2046 
2047  //............... Calcul des nombres de secteurs selon x
2048  // i_pasx = taille secteur en x
2049  // isx_max = taille de la matrice en x
2050  // n_sctx = nombre de secteurs en x
2051  //
2052  if (i_pasx > isx_max) {
2053  i_pasx = isx_max;
2054  }
2055  Int_t n_sctx = 1;
2056  Int_t max_verix;
2057  if (i_pasx > 0) {
2058  n_sctx = isx_max / i_pasx;
2059  }
2060  max_verix = n_sctx * i_pasx;
2061  if (max_verix < isx_max) {
2062  n_sctx++;
2063  }
2064 
2065  //............... Calcul des nombres de secteurs selon y
2066  // i_pasy = taille secteur en y
2067  // isy_max = taille de la matrice en y
2068  // n_scty = nombre de secteurs en x
2069  //
2070  if (i_pasy > isy_max) {
2071  i_pasy = isy_max;
2072  }
2073  Int_t n_scty = 1;
2074  Int_t max_veriy;
2075  if (i_pasy > 0) {
2076  n_scty = isy_max / i_pasy;
2077  }
2078  max_veriy = n_scty * i_pasy;
2079  if (max_veriy < isy_max) {
2080  n_scty++;
2081  }
2082 
2083 #define NBSC
2084 #ifndef NBSC
2085  //................ Ecriture de la taille et du nombre des secteurs
2086  if (i_code == fCodeCovCss || i_code == fCodeCorCss || i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss) {
2087  fFcout_f << "sector size = " << fSectSampSizeX << " , number of sectors = " << n_sctx << " x " << n_scty << endl;
2088  }
2089  if (i_code == fCodeHfCov || i_code == fCodeHfCor || i_code == fCodeLfCov || i_code == fCodeLfCor) {
2090  fFcout_f << "sector size = " << fSectChanSizeX << " , number of sectors = " << n_sctx << " x " << n_scty
2091  << std::endl;
2092  }
2093 #endif // NBSC
2094 
2095  fFcout_f << std::endl;
2096 
2097  //............... impression matrice par secteurs i_pas x i_pas
2098  //........................... boucles pour display des secteurs
2099  Int_t ix_inf = -i_pasx;
2100 
2101  for (Int_t nsx = 0; nsx < n_sctx; nsx++) {
2102  //......................... calcul limites secteur
2103  ix_inf = ix_inf + i_pasx;
2104  Int_t ix_sup = ix_inf + i_pasx;
2105 
2106  Int_t iy_inf = -i_pasy;
2107 
2108  for (Int_t nsy = 0; nsy < n_scty; nsy++) {
2109  iy_inf = iy_inf + i_pasy;
2110  Int_t iy_sup = iy_inf + i_pasy;
2111 
2112  //......................... display du secteur (nsx,nsy)
2113 
2114  if (i_code == fCodeHfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss || i_code == fCodeAvSigCorss) {
2115  fFcout_f << " ";
2116  }
2117  if (i_code == fCodeHfCor || i_code == fCodeCorCss) {
2118  fFcout_f << " ";
2119  }
2120 
2121  for (Int_t iy_c = iy_inf; iy_c < iy_sup; iy_c++) {
2122  if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss ||
2123  i_code == fCodeAvSigCorss) {
2124  fFcout_f.width(8);
2125  }
2126  if (i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss) {
2127  fFcout_f.width(6);
2128  }
2129  fFcout_f << iy_c << " ";
2130  }
2131  fFcout_f << std::endl << std::endl;
2132 
2133  for (Int_t ix_c = ix_inf; ix_c < ix_sup; ix_c++) {
2134  if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss ||
2135  i_code == fCodeAvSigCorss) {
2136  fFcout_f.width(8);
2137  }
2138  if (i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss) {
2139  fFcout_f.width(6);
2140  }
2141  fFcout_f << ix_c << " ";
2142 
2143  for (Int_t iy_c = iy_inf; iy_c < iy_sup; iy_c++) {
2144  if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeCovCss || i_code == fCodeAvMeanCorss ||
2145  i_code == fCodeAvSigCorss) {
2146  fFcout_f.width(8);
2147  }
2148 
2149  if (i_code == fCodeHfCor || i_code == fCodeLfCor || i_code == fCodeCorCss) {
2150  fFcout_f.width(6);
2151  }
2152 
2153  if (i_code == fCodeHfCov || i_code == fCodeLfCov || i_code == fCodeHfCor) {
2154  fFcout_f << fjustap_2d_cc[ix_c][iy_c] << " ";
2155  }
2156 
2157  if (i_code == fCodeCovCss || i_code == fCodeCorCss || i_code == fCodeAvMeanCorss ||
2158  i_code == fCodeAvSigCorss) {
2159  fFcout_f << fjustap_2d_ss[ix_c][iy_c] << " ";
2160  }
2161  }
2162  fFcout_f << std::endl;
2163  }
2164  fFcout_f << std::endl;
2165  }
2166  }
2167 
2168  //........... closing of the results file
2169 
2170  fFcout_f.close();
2171 
2173  std::cout << "*TEcnaWrite::fT2dWriteAscii(....)> INFO: "
2174  << "matrix has been written in file: " << std::endl
2175  << " " << fAsciiFileName.Data() << std::endl;
2176  }
2177 
2178 } // end of TEcnaWrite::fT2dWriteAscii
2179 
2180 //=========================================================================
2181 //
2182 // ci-dessous: ===> methodes a implementer plus tard?
2183 //
2184 //=========================================================================
2185 #define WASC
2186 #ifndef WASC
2187 //------------------------------------------------------------
2188 //
2189 // Writing of the expectation values in an ASCII file
2190 //
2191 //------------------------------------------------------------
2192 
2193 void TEcnaWrite::WriteAsciiSampleMeans() {
2194  //Writing of the expectation values in an ASCII file
2195 
2196  Int_t i_code = fCodeMSp;
2197  fMakeResultsFileName(i_code);
2198  fAsciiFileWriteHeader(i_code);
2199 
2200  Int_t i_lic1 = fNbChanByLine;
2201  Int_t i_lic2 = fNbSampByLine;
2202 
2203  fT1dWriteAscii(i_code, i_lic1, i_lic2);
2204 }
2205 
2206 //-------------------------------------------------------
2207 //
2208 // Writing of the sigmas in an ASCII file
2209 //
2210 //-------------------------------------------------------
2211 
2212 void TEcnaWrite::WriteAsciiSampleSigmas() {
2213  //Writing of the variances in an ASCII file
2214 
2215  Int_t i_code = fCodeVar; // code for variance
2216  fMakeResultsFileName(i_code);
2217  fAsciiFileWriteHeader(i_code);
2218 
2219  Int_t i_lic1 = fNbChanByLine;
2220  Int_t i_lic2 = fNbSampByLine;
2221 
2222  fT1dWriteAscii(i_code, i_lic1, i_lic2);
2223 }
2224 #endif // WASC
void fAsciiFileWriteHeader(const Int_t &)
Definition: TEcnaWrite.cc:1345
Int_t fCodeHfn
Definition: TEcnaWrite.h:69
Double_t ** fjustap_2d_cc
Definition: TEcnaWrite.h:110
Int_t MaxCrysInSM()
Int_t NumberOfEventsAnalysis(Int_t **, const Int_t &, const Int_t &, const Int_t &)
Definition: TEcnaWrite.cc:512
ClassImp(TEcnaWrite)
Int_t fSectSampSizeY
Definition: TEcnaWrite.h:95
Int_t fCodeAvPed
Definition: TEcnaWrite.h:80
Int_t fStinEchaUser
Definition: TEcnaWrite.h:101
Int_t MaxCrysEcnaInDee()
void Init()
Definition: TEcnaWrite.cc:143
Int_t GetStexNumber()
Definition: TEcnaWrite.cc:393
Int_t fgMaxCar
Definition: TEcnaWrite.h:41
void WriteAsciiCovariancesBetweenSamples(const Int_t &, const Int_t &, const Int_t &, const TMatrixD &)
Definition: TEcnaWrite.cc:1721
Int_t MaxCrysVecoInStin()
void RegisterFileParameters(const TString &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const Int_t &, const TString &, const TString &, const time_t, const time_t)
Definition: TEcnaWrite.cc:595
Int_t fNbSampByLine
Definition: TEcnaWrite.h:98
Double_t * fjustap_1d_ev
Definition: TEcnaWrite.h:105
TString GetDeeDirViewedFromIP(const Int_t &)
Int_t fCodePrintNoComment
Definition: TEcnaWrite.h:50
Int_t Get1DeeSCEcnaFrom0DeeEcha(const Int_t &)
TString fFlagSubDet
Definition: TEcnaWrite.h:53
Int_t fCodeHfCov
Definition: TEcnaWrite.h:87
Int_t Get1SCEchaFrom0DeeEcha(const Int_t &)
TString fStexName
Definition: TEcnaWrite.h:131
Double_t ** fjustap_2d_ev
Definition: TEcnaWrite.h:104
TString BeginningOfResultsRootFilePath()
Double_t ** fjustap_2d_var
Definition: TEcnaWrite.h:107
Double_t ** fjustap_2d_ss
Definition: TEcnaWrite.h:113
Int_t fNbChanByLine
Definition: TEcnaWrite.h:97
TEcnaParPaths * fCnaParPaths
Definition: TEcnaWrite.h:56
TString fAnaType
Definition: TEcnaWrite.h:124
Int_t fStexNumber
Definition: TEcnaWrite.h:130
void AppendResultsAsciiFilePath(const Text_t *)
TString fAsciiFileNameShort
Definition: TEcnaWrite.h:142
Int_t fStexStinUser
Definition: TEcnaWrite.h:100
TEcnaParEcal * fEcal
Definition: TEcnaWrite.h:52
Bool_t RegisterPointer(const TString &, const Long_t &)
Definition: TEcnaObject.cc:100
const TString & ResultsAsciiFilePath() const
Int_t fRunNumber
Definition: TEcnaWrite.h:126
TString fRootFileNameShort
Definition: TEcnaWrite.h:138
const TString & GetAnalysisName() const
Definition: TEcnaWrite.cc:388
const TString & GetRootFileNameShort() const
Definition: TEcnaWrite.cc:387
Int_t Get0TowEchaFrom0SMEcha(const Int_t &)
Int_t GetFirstReqEvtNumber()
Definition: TEcnaWrite.cc:391
Int_t fCdelete
Definition: TEcnaWrite.h:38
Int_t fCnew
Definition: TEcnaWrite.h:38
Int_t fUserSamp
Definition: TEcnaWrite.h:99
Int_t GetJYCrysInDee(const Int_t &, const Int_t &, const Int_t &)
Int_t fCodePed
Definition: TEcnaWrite.h:66
Int_t fCodeAvTno
Definition: TEcnaWrite.h:81
TString fRootFileName
Definition: TEcnaWrite.h:139
Int_t fCodeAvMeanCorss
Definition: TEcnaWrite.h:82
TString fTTBELL
Definition: TEcnaWrite.h:43
void SetResultsRootFilePath(const TString &)
Int_t fCodePrintAllComments
Definition: TEcnaWrite.h:50
TString BeginningOfResultsAsciiFilePath()
Int_t fCodeSigCorss
Definition: TEcnaWrite.h:71
Int_t Get1SMTowFrom0SMEcha(const Int_t &)
Int_t GetDSSCFrom1DeeSCEcna(const Int_t &, const Int_t &, const Int_t &)
Definition: value.py:1
void fT2dWriteAscii(const Int_t &, const Int_t &, const Int_t &, const Int_t &, const TMatrixD &)
Definition: TEcnaWrite.cc:1796
Int_t fFlagPrint
Definition: TEcnaWrite.h:49
Double_t * fjustap_1d_cc
Definition: TEcnaWrite.h:111
Int_t GetRunNumber()
Definition: TEcnaWrite.cc:390
Int_t fCodeRoot
Definition: TEcnaWrite.h:63
Int_t fCodeMSp
Definition: TEcnaWrite.h:77
Int_t fNbOfSamples
Definition: TEcnaWrite.h:125
Bool_t GetPathForResultsRootFiles()
Int_t GetDSFrom1DeeSCEcna(const Int_t &, const Int_t &)
TString fStopDate
Definition: TEcnaWrite.h:135
ii
Definition: cuy.py:589
Int_t GetDeeSCConsFrom1DeeSCEcna(const Int_t &, const Int_t &)
Double_t * fjustap_1d_ss
Definition: TEcnaWrite.h:114
Int_t fCodeHeaderAscii
Definition: TEcnaWrite.h:62
void WriteAsciiHisto(const TString &, const Int_t &, const TVectorD &)
Definition: TEcnaWrite.cc:1483
Int_t fFirstReqEvtNumber
Definition: TEcnaWrite.h:127
Double_t GetEta(const Int_t &, const Int_t &, const Int_t &)
Int_t Get1SMCrysFrom1SMTowAnd0TowEcha(const Int_t &, const Int_t &)
Int_t fSectChanSizeX
Definition: TEcnaWrite.h:94
Int_t GetReqNbOfEvts()
Definition: TEcnaWrite.cc:392
std::ofstream fFcout_f
Definition: TEcnaWrite.h:59
Int_t fCodeMeanCorss
Definition: TEcnaWrite.h:70
void SetEcalSubDetector(const TString &)
Definition: TEcnaWrite.cc:208
TString fStinName
Definition: TEcnaWrite.h:132
const TString & GetRootFileName() const
Definition: TEcnaWrite.cc:386
Double_t GetPhiInSM(const Int_t &, const Int_t &, const Int_t &)
void TruncateResultsRootFilePath(const Int_t &, const Int_t &)
Int_t fCodeLfCov
Definition: TEcnaWrite.h:85
Int_t fCodeTno
Definition: TEcnaWrite.h:67
Double_t * fjustap_1d_var
Definition: TEcnaWrite.h:108
Int_t GetCodePrint(const TString &)
Definition: TEcnaParCout.cc:66
Int_t MaxCrysEcnaInStex()
Int_t fCodeLfn
Definition: TEcnaWrite.h:68
Int_t MaxCrysHocoInStin()
Int_t fCodeAvSigCorss
Definition: TEcnaWrite.h:83
Int_t GetNbOfSamples()
Definition: TEcnaWrite.cc:389
Int_t MaxSampADC()
Int_t GetIXCrysInDee(const Int_t &, const Int_t &, const Int_t &)
TEcnaParCout * fCnaParCout
Definition: TEcnaWrite.h:57
TString fAsciiFileName
Definition: TEcnaWrite.h:141
Int_t fSectChanSizeY
Definition: TEcnaWrite.h:94
void WriteAsciiCorrelationsBetweenSamples(const Int_t &, const Int_t &, const Int_t &, const TMatrixD &)
Definition: TEcnaWrite.cc:1757
Int_t PlusMinusSMNumber(const Int_t &)
Int_t fCodeCovCss
Definition: TEcnaWrite.h:73
Int_t fCodeNbOfEvts
Definition: TEcnaWrite.h:65
time_t fStopTime
Definition: TEcnaWrite.h:136
Int_t fCodeCorCss
Definition: TEcnaWrite.h:74
Int_t fLastReqEvtNumber
Definition: TEcnaWrite.h:128
Int_t fSectSampSizeX
Definition: TEcnaWrite.h:95
Int_t fCodeLfCor
Definition: TEcnaWrite.h:86
TString GetEcalSubDetector()
TString fStartDate
Definition: TEcnaWrite.h:135
void fMakeResultsFileName()
Definition: TEcnaWrite.cc:629
void TruncateResultsAsciiFilePath(const Int_t &, const Int_t &)
void AppendResultsRootFilePath(const Text_t *)
const TString & GetAsciiFileName() const
Definition: TEcnaWrite.cc:385
Int_t fCodeHfCor
Definition: TEcnaWrite.h:88
Bool_t GetPathForResultsAsciiFiles()
Long_t GetPointerValue(const TString &)
Definition: TEcnaObject.cc:209
Int_t fReqNbOfEvts
Definition: TEcnaWrite.h:129
TEcnaNumbering * fEcalNumbering
Definition: TEcnaWrite.h:55
~TEcnaWrite() override
Definition: TEcnaWrite.cc:17
Int_t EmptyChannelsInDeeMatrixIncompleteSCIncluded()
Int_t fCodeSSp
Definition: TEcnaWrite.h:78
time_t fStartTime
Definition: TEcnaWrite.h:136
const TString & ResultsRootFilePath() const
void SetResultsAsciiFilePath(const TString &)