CMS 3D CMS Logo

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