BOSS 7.1.1
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//-----------------------
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
54DECLARE_COMPONENT(EmcCalibModLowHigh)
55
56//----------------
57// Constructors --
58//----------------
59EmcCalibModLowHigh::EmcCalibModLowHigh(const std::string& name, ISvcLocator* pSvcLocator)
60 :Algorithm(name, pSvcLocator),
61 m_fileExt(""),
62 m_inputFileDir("../InputData/"),
63 m_fileDir("/home/besdata/public/liucx/Calib/"),
64 m_deadIxtal(-999),
65 m_hotIxtal(-999)
66{
67
68 // Declare the properties
69 declareProperty("fileExt", m_fileExt);
70 declareProperty("inputFileDir", m_inputFileDir);
71 declareProperty("fileDir", m_fileDir);
72 declareProperty("deadIxtal", m_deadIxtal);
73 declareProperty("hotIxtal", m_hotIxtal);
74
75 m_oldConstants = new double[6240];
76 m_IxtalNumber= new int[6240];
77}
78
79//--------------
80// Destructor --
81//--------------
83
84 if ( 0 != m_oldConstants) {
85 delete [] m_oldConstants;
86 m_oldConstants = 0;
87 }
88 if ( 0 != m_IxtalNumber) {
89 delete [] m_IxtalNumber;
90 m_IxtalNumber = 0;
91 }
92}
93
94// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
96
97 MsgStream log(msgSvc(), name());
98 log << MSG::INFO << "in initialize()" << endreq;
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" << endreq;
105 }
106 else {
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()" << endreq;
125
126 return StatusCode::SUCCESS;
127}
128
129// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
131
132 MsgStream log(msgSvc(), name());
133
134
135 log << MSG::INFO << "in endRun()" << endreq;
136
137
138 return StatusCode::SUCCESS;
139}
140
141
142
143//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
144void
145EmcCalibModLowHigh::initCalibConst( ) {
146
147
148 MsgStream log(msgSvc(), name());
149
150 int nConstEmc;
151
152 nConstEmc= m_emcCalibConstSvc -> getDigiCalibConstNo() ;
153
154 if ( nConstEmc!=6240) cout<<"number of calibconst="<< nConstEmc<<endl;
155
156 for ( int i = 0; i< nConstEmc; i++ ) {
157
158 m_oldConstants[i]=m_emcCalibConstSvc -> getDigiCalibConst(i);
159 m_IxtalNumber[i]=m_emcCalibConstSvc -> getIxtalNumber(i);
160
161 }
162 /*
163 ifstream In;
164 In.open("/home/bes/liucx/GrelConstIxtal2013.txt");
165 ofstream out;
166 out.open("thephi.dat");
167 int ixtal,ithe,iphi;
168 double rel;
169 while( !In.eof() ) {
170
171 In >> ixtal>>rel;
172 ithe= m_emcCalibConstSvc -> getThetaIndex(ixtal);
173 iphi= m_emcCalibConstSvc -> getPhiIndex(ixtal);
174 out<<ixtal<<"\t"<<ithe<<"\t"<<iphi<<"\t"<<rel<<endl;
175 }
176 In.close();
177
178 out.close();
179
180 cout<<"1,10,101"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,10,101)<<endl;
181 cout<<"1,30,105"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,30,105)<<endl;
182 cout<<"1,35,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,35,40)<<endl;
183 cout<<"0,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(0,2,40)<<endl;
184 cout<<"2,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(2,2,40)<<endl;
185 */
186}
187
188
189//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
190void
191EmcCalibModLowHigh::SetModLowHighChannel() {
192
193 /*
194 ifstream EIn;
195 std::string EFile = m_inputFileDir;
196 EFile += "calibixtal.conf";
197 EIn.open(EFile.c_str());
198
199 double gixtal[6240],gi;
200
201 int ixtal;
202 for(int i=0;i<6240;i++) {
203 EIn>>ixtal>>gi;
204 gixtal[ixtal]=gi;
205 cout<<gixtal[ixtal]<<"SetModLowHighChannel"<<endl;
206 }
207 EIn.close();
208 */
209 //////////////////////////////
210 int Nxtals=6240;
211
212 double DigiConst[6240];
213 int IxtalNumber[6240];
214
215 for(int ind=0; ind < Nxtals; ind++ ) {
216
217
218 DigiConst[ind]=m_oldConstants[ind];
219 //DigiConst[ind]=m_oldConstants[ind]*gixtal[ind];
220 //DigiConst[ind]=1.0;
221 IxtalNumber[ind]=m_IxtalNumber[ind];
222
223 //DigiConst[ind]=m_oldConstants[ind]*2.368/2.37; //Ebeam from 2.37 to 2.368 GeV
224 // DigiConst[ind]=m_oldConstants[ind]*2.421/2.418; //Ebeam from 2.418 to 2.421 GeV
225 //DigiConst[ind]=m_oldConstants[ind]*2.459/2.457; //Ebeam from 2.457 to 2.459 GeV
226 //DigiConst[ind]=m_oldConstants[ind]*2.475/2.472; //Ebeam from 2.472 to 2.475 GeV
227
228 //Low energy crystal
229 //if (ind==428) DigiConst[ind]=m_oldConstants[ind]*1.55;
230 //if (ind==431) DigiConst[ind]=m_oldConstants[ind]*1.73;
231 /*
232 if (ind==2346) DigiConst[ind]=m_oldConstants[ind]*2.8;
233 if (ind==2347) DigiConst[ind]=m_oldConstants[ind]*1.3;
234 if (ind==4782) DigiConst[ind]=m_oldConstants[ind]*1.2;
235
236 if (ind==4803) DigiConst[ind]=m_oldConstants[ind]*1.2;
237 if (ind==4923) DigiConst[ind]=m_oldConstants[ind]*1.9;
238 if (ind==4993) DigiConst[ind]=m_oldConstants[ind]*1.5;
239 if (ind==5199) DigiConst[ind]=m_oldConstants[ind]*2.1;
240 if (ind==5643) DigiConst[ind]=m_oldConstants[ind]*1.3;
241
242 if (ind==825) DigiConst[ind]=m_oldConstants[ind]*1.8;
243 if (ind==917) DigiConst[ind]=m_oldConstants[ind]*1.4;
244 if (ind==936) DigiConst[ind]=m_oldConstants[ind]*1.28;
245
246 if (ind==937) DigiConst[ind]=m_oldConstants[ind]*1.7;
247 if (ind==943) DigiConst[ind]=m_oldConstants[ind]*1.9;
248 if (ind==4922) DigiConst[ind]=m_oldConstants[ind]*1.18;
249 if (ind==4923) DigiConst[ind]=m_oldConstants[ind]*1.8;
250 if (ind==5379) DigiConst[ind]=m_oldConstants[ind]*1.4;
251 if (ind==5497) DigiConst[ind]=m_oldConstants[ind]*1.3;
252 if (ind==5498) DigiConst[ind]=m_oldConstants[ind]*1.28;
253 */
254
255 //High energy crystal
256 // if (ind==4303) DigiConst[ind]=m_oldConstants[ind]*0.55;
257 //if (ind==4311) DigiConst[ind]=m_oldConstants[ind]*0.7;
258 //if (ind==4783) DigiConst[ind]=m_oldConstants[ind]*0.7;
259 //if (ind==4922) DigiConst[ind]=m_oldConstants[ind]*0.6;
260 // if (ind==5850) DigiConst[ind]=m_oldConstants[ind]*0.54;
261 //if (ind==5947) DigiConst[ind]=m_oldConstants[ind]*0.56;
262 // if (ind==1892) DigiConst[ind]=m_oldConstants[ind]/0.94*0.92;
263 // if (ind==2011) DigiConst[ind]=m_oldConstants[ind]/0.94*0.923;
264 // if (ind==113) DigiConst[ind]=DigiConst[ind]*0.957;//m_oldConstants[ind]*0.95;
265 //if (ind==3142) DigiConst[ind]=m_oldConstants[ind]*0.95;
266 if (ind==2884) DigiConst[ind]=m_oldConstants[ind]*1.6923;
267
268 // cout<<"ind="<<ind<<"\t"<< DigiConst[ind]<<endl;
269 }
270
271 TFile fconst("EmcCalibConst_ModLowHigh.root", "recreate");
272
273 //define tree fill the absolute digicalibconsts into the root-file
274 TTree* constr= new TTree("DigiCalibConst","DigiCalibConst");
275 constr->Branch("DigiCalibConst",DigiConst,"DigiConst[6240]/D");
276 constr->Branch("IxtalNumber",IxtalNumber,"IxtalNumber[6240]/I");
277
278 constr->Fill();
279
280
281 constr->Write();
282
283 delete constr;
284
285 fconst.Close();
286
287 // end tree
288
289
290
291
292
293}
294
295
296
IMessageSvc * msgSvc()