Fixes for Coverity warnings (M. van Leeuwen)
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSPDscanMeanTh.cxx
CommitLineData
b15de2d2 1////////////////////////////////////////////////////////////
2// Author: Henrik Tydesjo //
3// Interface class to the containers of an online mean //
4// threshold scan. //
5////////////////////////////////////////////////////////////
6
7#include <TFile.h>
8#include "AliITSOnlineSPDscanMeanTh.h"
9#include "AliITSOnlineSPDscanInfoMeanTh.h"
10
6ddf3d66 11AliITSOnlineSPDscanMeanTh::AliITSOnlineSPDscanMeanTh(const Char_t *fileName, Bool_t readFromGridFile) {
b15de2d2 12 // constructor
53ae21ce 13 fFileName=fileName;
6ddf3d66 14 fModified=kFALSE;
15 fInfoModified=kFALSE;
b15de2d2 16 // look for a previously saved info object
17 // (if file not found create a new one and return, else read)
6ddf3d66 18
19 Bool_t bRead = readFromGridFile;
20
21 if (!bRead) {
22 FILE* fp0 = fopen(fFileName.Data(), "r");
23 if (fp0 != NULL) {
24 bRead=kTRUE;
25 fclose(fp0);
26 }
27 }
28
29 if (bRead) { // open file for reading
30 fFile = TFile::Open(fFileName.Data(), "READ");
31 if (fFile==NULL) { // grid file not found, create new local default file
32 printf("ERROR: AliITSOnlineSPDscan: File %s not found! Creating 'test999.root' file instead\n",fFileName.Data());
33 // create default empty file:
34 fFileName = "test999.root";
35 fScanInfo = new AliITSOnlineSPDscanInfoMeanTh();
36 fInfoModified=kTRUE;
37 fFile = new TFile(fFileName.Data(), "RECREATE");
38 fWrite=kTRUE;
39 }
40 else { // read from file (grid or local)
41 fWrite=kFALSE;
42 fFile->GetObject("AliITSOnlineSPDscanInfo", fScanInfo);
43 }
44 }
45 else { // create new local file
b15de2d2 46 fScanInfo = new AliITSOnlineSPDscanInfoMeanTh();
6ddf3d66 47 fInfoModified=kTRUE;
53ae21ce 48 fFile = new TFile(fFileName.Data(), "RECREATE");
b15de2d2 49 fWrite=kTRUE;
50 }
6ddf3d66 51
b15de2d2 52 Init();
53}
54
55AliITSOnlineSPDscanMeanTh::AliITSOnlineSPDscanMeanTh(const AliITSOnlineSPDscanMeanTh& scan) :
56 AliITSOnlineSPDscanMultiple(scan)
57{}
58
59AliITSOnlineSPDscanMeanTh::~AliITSOnlineSPDscanMeanTh() {}
60
61AliITSOnlineSPDscanMeanTh& AliITSOnlineSPDscanMeanTh::operator=(const AliITSOnlineSPDscanMeanTh& scan) {
62 // assignment operator (should not be used)
63 printf("This object should not be copied!");
64 if (this!=&scan) {
65 // still do nothing...
66 }
67 return *this;
68}
69
b15de2d2 70UInt_t AliITSOnlineSPDscanMeanTh::AddScanStep() {
71 CreateNewStep();
72 return ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->AddScanStep();
73}
74
75void AliITSOnlineSPDscanMeanTh::SetDacLow(UInt_t nsi, UInt_t hs, Int_t val) {
76 // set dac low value for step nsi and half stave hs
77 SwitchToStep(nsi);
78 ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->SetDacLow(nsi,hs,val);
79 fInfoModified=kTRUE;
80}
81void AliITSOnlineSPDscanMeanTh::SetDacHigh(UInt_t nsi, UInt_t hs, Int_t val) {
82 // set dac high value for step nsi and half stave hs
83 SwitchToStep(nsi);
84 ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->SetDacHigh(nsi,hs,val);
85 fInfoModified=kTRUE;
86}
87void AliITSOnlineSPDscanMeanTh::SetTPAmp(UInt_t nsi, UInt_t hs, Int_t val) {
88 // set test pulse amplitude for step nsi and half stave hs
89 SwitchToStep(nsi);
90 ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->SetTPAmp(nsi,hs,val);
91 fInfoModified=kTRUE;
92}
93
94Int_t AliITSOnlineSPDscanMeanTh::GetDacLow(UInt_t nsi, UInt_t hs) {
95 return ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->GetDacLow(nsi,hs);
96}
97Int_t AliITSOnlineSPDscanMeanTh::GetDacHigh(UInt_t nsi, UInt_t hs) {
98 return ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->GetDacHigh(nsi,hs);
99}
100Int_t AliITSOnlineSPDscanMeanTh::GetTPAmp(UInt_t nsi, UInt_t hs) {
101 return ((AliITSOnlineSPDscanInfoMeanTh*)fScanInfo)->GetTPAmp(nsi,hs);
102}