BOSS 8.0.0
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 <cassert>
23#include <cmath>
24#include <cstdlib>
25#include <fstream>
26#include <iostream>
27//-------------------------------
28// Collaborating Class Headers --
29//-------------------------------
30
31#include "GaudiKernel/DataObject.h"
32#include "GaudiKernel/IDataProviderSvc.h"
33#include "GaudiKernel/ISvcLocator.h"
34#include "GaudiKernel/MsgStream.h"
35#include "GaudiKernel/PropertyMgr.h"
36#include "GaudiKernel/SmartDataPtr.h"
37
38#include "CLHEP/Vector/ThreeVector.h"
39using namespace std;
40
41using CLHEP::Hep3Vector;
42
43//--------------------
44#include "GaudiKernel/MsgStream.h"
45
46#include "TFile.h"
47#include "TH1F.h"
48#include "TObjArray.h"
49#include "TROOT.h"
50#include "TTree.h"
51
53//----------------
54// Constructors --
55//----------------
56EmcCalibTagDeadOrHot::EmcCalibTagDeadOrHot( const std::string& name, ISvcLocator* pSvcLocator )
57 : Algorithm( name, pSvcLocator )
58 , m_fileExt( "" )
59 , m_fileDir( "/home/besdata/public/liucx/Calib/" )
60 , m_deadIxtal( -999 )
61 , m_hotIxtal( -999 ) {
62
63 // Declare the properties
64 declareProperty( "fileExt", m_fileExt );
65 declareProperty( "fileDir", m_fileDir );
66 declareProperty( "deadIxtal", m_deadIxtal );
67 declareProperty( "hotIxtal", m_hotIxtal );
68
69 m_oldConstants = new double[6240];
70 m_IxtalNumber = new int[6240];
71}
72
73//--------------
74// Destructor --
75//--------------
77
78 if ( 0 != m_oldConstants )
79 {
80 delete[] m_oldConstants;
81 m_oldConstants = 0;
82 }
83 if ( 0 != m_IxtalNumber )
84 {
85 delete[] m_IxtalNumber;
86 m_IxtalNumber = 0;
87 }
88}
89
90// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
92
93 MsgStream log( msgSvc(), name() );
94 log << MSG::INFO << "in initialize()" << endmsg;
95
96 // use EmcCalibConstSvc
97 StatusCode scCalib;
98 scCalib = Gaudi::svcLocator()->service( "EmcCalibConstSvc", m_emcCalibConstSvc );
99 if ( scCalib != StatusCode::SUCCESS )
100 { log << MSG::ERROR << "can not use EmcCalibConstSvc" << endmsg; }
101 else
102 {
103 std::cout << "Test EmcCalibConstSvc DigiCalibConst(0)= "
104 << m_emcCalibConstSvc->getDigiCalibConst( 0 ) << std::endl;
105 }
106
107 // init starting values for calibration constants from file or set to 1
108
109 initCalibConst();
110
111 SetDeadOrHotChannel();
112
113 return StatusCode::SUCCESS;
114}
115
116// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
118
119 MsgStream log( msgSvc(), name() );
120 log << MSG::DEBUG << "in execute()" << endmsg;
121
122 return StatusCode::SUCCESS;
123}
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
127
128 MsgStream log( msgSvc(), name() );
129
130 log << MSG::INFO << "in endRun()" << endmsg;
131
132 return StatusCode::SUCCESS;
133}
134
135//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
136void EmcCalibTagDeadOrHot::initCalibConst() {
137
138 MsgStream log( msgSvc(), name() );
139
140 int nConstEmc;
141
142 nConstEmc = m_emcCalibConstSvc->getDigiCalibConstNo();
143
144 if ( nConstEmc != 6240 ) cout << "number of calibconst=" << nConstEmc << endl;
145
146 for ( int i = 0; i < nConstEmc; i++ )
147 {
148
149 m_oldConstants[i] = m_emcCalibConstSvc->getDigiCalibConst( i );
150 m_IxtalNumber[i] = m_emcCalibConstSvc->getIxtalNumber( i );
151 }
152 /*
153 ifstream In;
154 In.open("/home/bes/liucx/GrelConstIxtal2013.txt");
155 ofstream out;
156 out.open("thephi.dat");
157 int ixtal,ithe,iphi;
158 double rel;
159 while( !In.eof() ) {
160
161 In >> ixtal>>rel;
162 ithe= m_emcCalibConstSvc -> getThetaIndex(ixtal);
163 iphi= m_emcCalibConstSvc -> getPhiIndex(ixtal);
164 out<<ixtal<<"\t"<<ithe<<"\t"<<iphi<<"\t"<<rel<<endl;
165 }
166 In.close();
167
168 out.close();
169
170 cout<<"1,10,101"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,10,101)<<endl;
171 cout<<"1,30,105"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,30,105)<<endl;
172 cout<<"1,35,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(1,35,40)<<endl;
173 cout<<"0,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(0,2,40)<<endl;
174 cout<<"2,2,40"<<"\t"<<m_emcCalibConstSvc -> getIndex(2,2,40)<<endl;
175 */
176}
177
178//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
179void EmcCalibTagDeadOrHot::SetDeadOrHotChannel() {
180
181 int Nxtals = 6240;
182
183 double DigiConst[6240];
184 int IxtalNumber[6240];
185
186 for ( int ind = 0; ind < Nxtals; ind++ )
187 {
188
189 DigiConst[ind] = m_oldConstants[ind];
190 IxtalNumber[ind] = m_IxtalNumber[ind];
191 if ( ind == m_deadIxtal ) IxtalNumber[ind] = -9;
192 if ( ind == m_hotIxtal ) IxtalNumber[ind] = -99;
193 // cout<<"ind="<<ind<<"\t"<< DigiConst[ind]<<endl;
194 }
195
196 TFile fconst( "EmcCalibConst_DeadOrHot.root", "recreate" );
197
198 // define tree fill the absolute digicalibconsts into the root-file
199 TTree* constr = new TTree( "DigiCalibConst", "DigiCalibConst" );
200 constr->Branch( "DigiCalibConst", DigiConst, "DigiConst[6240]/D" );
201 constr->Branch( "IxtalNumber", IxtalNumber, "IxtalNumber[6240]/I" );
202
203 constr->Fill();
204
205 constr->Write();
206
207 delete constr;
208
209 fconst.Close();
210
211 // end tree
212}
DECLARE_COMPONENT(BesBdkRc)
IMessageSvc * msgSvc()
EmcCalibTagDeadOrHot(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