BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcCalibModLowHigh.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//-----------------------
20#include "EmcCalibModLowHigh.h"
21
22#include <cassert>
23#include <cmath>
24#include <cstdlib>
25#include <fstream>
26#include <iostream>
27//-------------------------------
28// Collaborating Class Headers --
29//-------------------------------
30
31
32#include "GaudiKernel/DataObject.h"
33#include "GaudiKernel/IDataProviderSvc.h"
34#include "GaudiKernel/ISvcLocator.h"
35#include "GaudiKernel/MsgStream.h"
36#include "GaudiKernel/PropertyMgr.h"
37#include "GaudiKernel/SmartDataPtr.h"
38
39#include "CLHEP/Vector/ThreeVector.h"
40using namespace std;
41
42using CLHEP::Hep3Vector;
43
44//--------------------
45#include "GaudiKernel/MsgStream.h"
46
47#include "TFile.h"
48#include "TH1F.h"
49#include "TObjArray.h"
50#include "TROOT.h"
51#include "TTree.h"
52
54
55//----------------
56// Constructors --
57//----------------
58EmcCalibModLowHigh::EmcCalibModLowHigh( const std::string& name, ISvcLocator* pSvcLocator )
59 : Algorithm( name, pSvcLocator )
60 , m_fileExt( "" )
61 , m_inputFileDir( "../InputData/" )
62 , m_fileDir( "/home/besdata/public/liucx/Calib/" )
63 , m_deadIxtal( -999 )
64 , m_hotIxtal( -999 ) {
65
66 // Declare the properties
67 declareProperty( "fileExt", m_fileExt );
68 declareProperty( "inputFileDir", m_inputFileDir );
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 {
84 delete[] m_oldConstants;
85 m_oldConstants = 0;
86 }
87 if ( 0 != m_IxtalNumber )
88 {
89 delete[] m_IxtalNumber;
90 m_IxtalNumber = 0;
91 }
92}
93
94// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
96
97 MsgStream log( msgSvc(), name() );
98 log << MSG::INFO << "in initialize()" << endmsg;
99
100 // use EmcCalibConstSvc
101 StatusCode scCalib;
102 scCalib = Gaudi::svcLocator()->service( "EmcCalibConstSvc", m_emcCalibConstSvc );
103 if ( scCalib != StatusCode::SUCCESS )
104 { log << MSG::ERROR << "can not use EmcCalibConstSvc" << endmsg; }
105 else
106 {
107 std::cout << "Test EmcCalibConstSvc DigiCalibConst(0)= "
108 << m_emcCalibConstSvc->getDigiCalibConst( 0 ) << std::endl;
109 }
110
111 // init starting values for calibration constants from file or set to 1
112
113 initCalibConst();
114
115 SetModLowHighChannel();
116
117 return StatusCode::SUCCESS;
118}
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
122
123 MsgStream log( msgSvc(), name() );
124 log << MSG::DEBUG << "in execute()" << endmsg;
125
126 return StatusCode::SUCCESS;
127}
128
129// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
131
132 MsgStream log( msgSvc(), name() );
133
134 log << MSG::INFO << "in endRun()" << endmsg;
135
136 return StatusCode::SUCCESS;
137}
138
139//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
140void EmcCalibModLowHigh::initCalibConst() {
141
142 MsgStream log( msgSvc(), name() );
143
144 int nConstEmc;
145
146 nConstEmc = m_emcCalibConstSvc->getDigiCalibConstNo();
147
148 if ( nConstEmc != 6240 ) cout << "number of calibconst=" << nConstEmc << endl;
149
150 for ( int i = 0; i < nConstEmc; i++ )
151 {
152
153 m_oldConstants[i] = m_emcCalibConstSvc->getDigiCalibConst( i );
154 m_IxtalNumber[i] = m_emcCalibConstSvc->getIxtalNumber( i );
155 }
156 /*
157 ifstream In;
158 In.open("/home/bes/liucx/GrelConstIxtal2013.txt");
159 ofstream out;
160 out.open("thephi.dat");
161 int ixtal,ithe,iphi;
162 double rel;
163 while( !In.eof() ) {
164
165 In >> ixtal>>rel;
166 ithe= m_emcCalibConstSvc -> getThetaIndex(ixtal);
167 iphi= m_emcCalibConstSvc -> getPhiIndex(ixtal);
168 out<<ixtal<<"\t"<<ithe<<"\t"<<iphi<<"\t"<<rel<<endl;
169 }
170 In.close();
171
172 out.close();
173
174 cout<<"1,10,101"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,10,101)<<endl;
175 cout<<"1,30,105"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,30,105)<<endl;
176 cout<<"1,35,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,35,40)<<endl;
177 cout<<"0,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(0,2,40)<<endl;
178 cout<<"2,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(2,2,40)<<endl;
179 */
180}
181
182//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
183void EmcCalibModLowHigh::SetModLowHighChannel() {
184
185 /*
186 ifstream EIn;
187 std::string EFile = m_inputFileDir;
188 EFile += "calibixtal.conf";
189 EIn.open(EFile.c_str());
190
191 double gixtal[6240],gi;
192
193 int ixtal;
194 for(int i=0;i<6240;i++) {
195 EIn>>ixtal>>gi;
196 gixtal[ixtal]=gi;
197 cout<<gixtal[ixtal]<<"SetModLowHighChannel"<<endl;
198 }
199 EIn.close();
200 */
201 //////////////////////////////
202 int Nxtals = 6240;
203
204 double DigiConst[6240];
205 int IxtalNumber[6240];
206
207 for ( int ind = 0; ind < Nxtals; ind++ )
208 {
209
210 DigiConst[ind] = m_oldConstants[ind];
211 // DigiConst[ind]=m_oldConstants[ind]*gixtal[ind];
212 // DigiConst[ind]=1.0;
213 IxtalNumber[ind] = m_IxtalNumber[ind];
214
215 // DigiConst[ind]=m_oldConstants[ind]*2.368/2.37; //Ebeam from 2.37 to 2.368 GeV
216 // DigiConst[ind]=m_oldConstants[ind]*2.421/2.418; //Ebeam from 2.418 to 2.421 GeV
217 // DigiConst[ind]=m_oldConstants[ind]*2.459/2.457; //Ebeam from 2.457 to 2.459 GeV
218 // DigiConst[ind]=m_oldConstants[ind]*2.475/2.472; //Ebeam from 2.472 to 2.475 GeV
219
220 // Low energy crystal
221 // if (ind==428) DigiConst[ind]=m_oldConstants[ind]*1.55;
222 // if (ind==431) DigiConst[ind]=m_oldConstants[ind]*1.73;
223 /*
224 if (ind==2346) DigiConst[ind]=m_oldConstants[ind]*2.8;
225 if (ind==2347) DigiConst[ind]=m_oldConstants[ind]*1.3;
226 if (ind==4782) DigiConst[ind]=m_oldConstants[ind]*1.2;
227
228 if (ind==4803) DigiConst[ind]=m_oldConstants[ind]*1.2;
229 if (ind==4923) DigiConst[ind]=m_oldConstants[ind]*1.9;
230 if (ind==4993) DigiConst[ind]=m_oldConstants[ind]*1.5;
231 if (ind==5199) DigiConst[ind]=m_oldConstants[ind]*2.1;
232 if (ind==5643) DigiConst[ind]=m_oldConstants[ind]*1.3;
233
234 if (ind==825) DigiConst[ind]=m_oldConstants[ind]*1.8;
235 if (ind==917) DigiConst[ind]=m_oldConstants[ind]*1.4;
236 if (ind==936) DigiConst[ind]=m_oldConstants[ind]*1.28;
237
238 if (ind==937) DigiConst[ind]=m_oldConstants[ind]*1.7;
239 if (ind==943) DigiConst[ind]=m_oldConstants[ind]*1.9;
240 if (ind==4922) DigiConst[ind]=m_oldConstants[ind]*1.18;
241 if (ind==4923) DigiConst[ind]=m_oldConstants[ind]*1.8;
242 if (ind==5379) DigiConst[ind]=m_oldConstants[ind]*1.4;
243 if (ind==5497) DigiConst[ind]=m_oldConstants[ind]*1.3;
244 if (ind==5498) DigiConst[ind]=m_oldConstants[ind]*1.28;
245 */
246
247 // High energy crystal
248 // if (ind==4303) DigiConst[ind]=m_oldConstants[ind]*0.55;
249 // if (ind==4311) DigiConst[ind]=m_oldConstants[ind]*0.7;
250 // if (ind==4783) DigiConst[ind]=m_oldConstants[ind]*0.7;
251 // if (ind==4922) DigiConst[ind]=m_oldConstants[ind]*0.6;
252 // if (ind==5850) DigiConst[ind]=m_oldConstants[ind]*0.54;
253 // if (ind==5947) DigiConst[ind]=m_oldConstants[ind]*0.56;
254 // if (ind==1892) DigiConst[ind]=m_oldConstants[ind]/0.94*0.92;
255 // if (ind==2011) DigiConst[ind]=m_oldConstants[ind]/0.94*0.923;
256 // if (ind==113) DigiConst[ind]=DigiConst[ind]*0.957;//m_oldConstants[ind]*0.95;
257 // if (ind==3142) DigiConst[ind]=m_oldConstants[ind]*0.95;
258 if ( ind == 2884 ) DigiConst[ind] = m_oldConstants[ind] * 1.6923;
259
260 // cout<<"ind="<<ind<<"\t"<< DigiConst[ind]<<endl;
261 }
262
263 TFile fconst( "EmcCalibConst_ModLowHigh.root", "recreate" );
264
265 // define tree fill the absolute digicalibconsts into the root-file
266 TTree* constr = new TTree( "DigiCalibConst", "DigiCalibConst" );
267 constr->Branch( "DigiCalibConst", DigiConst, "DigiConst[6240]/D" );
268 constr->Branch( "IxtalNumber", IxtalNumber, "IxtalNumber[6240]/I" );
269
270 constr->Fill();
271
272 constr->Write();
273
274 delete constr;
275
276 fconst.Close();
277
278 // end tree
279}
DECLARE_COMPONENT(BesBdkRc)
IMessageSvc * msgSvc()
EmcCalibModLowHigh(const std::string &name, ISvcLocator *pSvcLocator)
virtual int getDigiCalibConstNo() const =0
virtual double getDigiCalibConst(int No) const =0
virtual int getIxtalNumber(int No) const =0