BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcCalibTagDeadOrHot.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3//
4// tag hot channel and dead channel in the Emc Calibration constant file
5//
6// Environment:
7// Software developed for the BESIII Detector at the BEPCII.
8//
9// Author List:
10// Chunxiu Liu
11//
12// Copyright Information:
13// Copyright (C) 2012-04-19 IHEP
14//
15//------------------------------------------------------------------------
16
17//-----------------------
18// This Class's Header --
19//-----------------------
21
22#include <iostream>
23#include <fstream>
24#include <cmath>
25#include <cassert>
26#include <cstdlib>
27//-------------------------------
28// Collaborating Class Headers --
29//-------------------------------
30
31#include "GaudiKernel/MsgStream.h"
32#include "GaudiKernel/AlgFactory.h"
33#include "GaudiKernel/ISvcLocator.h"
34#include "GaudiKernel/SmartDataPtr.h"
35#include "GaudiKernel/IDataProviderSvc.h"
36#include "GaudiKernel/PropertyMgr.h"
37#include "GaudiKernel/DataObject.h"
38
39#include "CLHEP/Vector/ThreeVector.h"
40using namespace std;
41
42using CLHEP::Hep3Vector;
43
44//--------------------
45#include "GaudiKernel/MsgStream.h"
46
47
48#include "TROOT.h"
49#include "TFile.h"
50#include "TTree.h"
51#include "TH1F.h"
52#include "TObjArray.h"
53
54
55
56//----------------
57// Constructors --
58//----------------
59EmcCalibTagDeadOrHot::EmcCalibTagDeadOrHot(const std::string& name, ISvcLocator* pSvcLocator)
60 :Algorithm(name, pSvcLocator),
61 m_fileExt(""),
62 m_fileDir("/ihepbatch/besdata/public/liucx/Calib/"),
63 m_deadIxtal(-999),
64 m_hotIxtal(-999)
65{
66
67 // Declare the properties
68 declareProperty("fileExt", m_fileExt);
69 declareProperty("fileDir", m_fileDir);
70 declareProperty("deadIxtal", m_deadIxtal);
71 declareProperty("hotIxtal", m_hotIxtal);
72
73 m_oldConstants = new double[6240];
74 m_IxtalNumber= new int[6240];
75}
76
77//--------------
78// Destructor --
79//--------------
81
82 if ( 0 != m_oldConstants) {
83 delete [] m_oldConstants;
84 m_oldConstants = 0;
85 }
86 if ( 0 != m_IxtalNumber) {
87 delete [] m_IxtalNumber;
88 m_IxtalNumber = 0;
89 }
90}
91
92// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
94
95 MsgStream log(msgSvc(), name());
96 log << MSG::INFO << "in initialize()" << endreq;
97
98 // use EmcCalibConstSvc
99 StatusCode scCalib;
100 scCalib = Gaudi::svcLocator() -> service("EmcCalibConstSvc", m_emcCalibConstSvc);
101 if( scCalib != StatusCode::SUCCESS){
102 log << MSG::ERROR << "can not use EmcCalibConstSvc" << endreq;
103 }
104 else {
105 std::cout << "Test EmcCalibConstSvc DigiCalibConst(0)= "
106 << m_emcCalibConstSvc -> getDigiCalibConst(0) << std::endl;
107 }
108
109 //init starting values for calibration constants from file or set to 1
110
111 initCalibConst();
112
113 SetDeadOrHotChannel();
114
115 return StatusCode::SUCCESS;
116}
117
118// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
120
121 MsgStream log(msgSvc(), name());
122 log << MSG::DEBUG << "in execute()" << endreq;
123
124 return StatusCode::SUCCESS;
125}
126
127// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
129
130 MsgStream log(msgSvc(), name());
131
132
133 log << MSG::INFO << "in endRun()" << endreq;
134
135
136 return StatusCode::SUCCESS;
137}
138
139
140
141//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
142void
143EmcCalibTagDeadOrHot::initCalibConst( ) {
144
145
146 MsgStream log(msgSvc(), name());
147
148 int nConstEmc;
149
150 nConstEmc= m_emcCalibConstSvc -> getDigiCalibConstNo() ;
151
152 if ( nConstEmc!=6240) cout<<"number of calibconst="<< nConstEmc<<endl;
153
154 for ( int i = 0; i< nConstEmc; i++ ) {
155
156 m_oldConstants[i]=m_emcCalibConstSvc -> getDigiCalibConst(i);
157 m_IxtalNumber[i]=m_emcCalibConstSvc -> getIxtalNumber(i);
158
159 }
160
161 ifstream In;
162 In.open("/ihepbatch/bes/liucx/GrelConstIxtal2013.txt");
163 ofstream out;
164 out.open("thephi.dat");
165 int ixtal,ithe,iphi;
166 double rel;
167 while( !In.eof() ) {
168
169 In >> ixtal>>rel;
170 ithe= m_emcCalibConstSvc -> getThetaIndex(ixtal);
171 iphi= m_emcCalibConstSvc -> getPhiIndex(ixtal);
172 out<<ixtal<<"\t"<<ithe<<"\t"<<iphi<<"\t"<<rel<<endl;
173 }
174 In.close();
175
176 out.close();
177
178 cout<<"1,10,101"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,10,101)<<endl;
179 cout<<"1,30,105"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,30,105)<<endl;
180 cout<<"1,35,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,35,40)<<endl;
181 cout<<"0,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(0,2,40)<<endl;
182 cout<<"2,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(2,2,40)<<endl;
183
184}
185
186
187//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
188void
189EmcCalibTagDeadOrHot::SetDeadOrHotChannel() {
190
191 int Nxtals=6240;
192
193 double DigiConst[6240];
194 int IxtalNumber[6240];
195
196 for(int ind=0; ind < Nxtals; ind++ ) {
197
198 DigiConst[ind]=m_oldConstants[ind];
199 IxtalNumber[ind]=m_IxtalNumber[ind];
200 if (ind==m_deadIxtal) IxtalNumber[ind]=-9;
201 if (ind==m_hotIxtal) IxtalNumber[ind]=-99;
202 // cout<<"ind="<<ind<<"\t"<< DigiConst[ind]<<endl;
203 }
204
205
206 TFile fconst("EmcCalibConst_DeadOrHot.root", "recreate");
207
208 //define tree fill the absolute digicalibconsts into the root-file
209 TTree* constr= new TTree("DigiCalibConst","DigiCalibConst");
210 constr->Branch("DigiCalibConst",DigiConst,"DigiConst[6240]/D");
211 constr->Branch("IxtalNumber",IxtalNumber,"IxtalNumber[6240]/I");
212
213 constr->Fill();
214
215
216 constr->Write();
217
218 delete constr;
219
220 fconst.Close();
221
222 // end tree
223
224
225
226
227
228}
229
230
231
IMessageSvc * msgSvc()
EmcCalibTagDeadOrHot(const std::string &name, ISvcLocator *pSvcLocator)
std::ifstream ifstream
Definition: bpkt_streams.h:44
std::ofstream ofstream
Definition: bpkt_streams.h:42