00001 #include "Calibration/EcalTBTools/interface/TB06TreeH2.h"
00002 #include "TFile.h"
00003 #include "TTree.h"
00004 #include "Calibration/EcalTBTools/interface/TB06RecoH2.h"
00005
00006 #include <iostream>
00007
00008
00009 TB06TreeH2::TB06TreeH2 (const std::string & fileName,
00010 const std::string & treeName):
00011 m_file (0), m_tree (0), m_data (0), m_dataSize (0)
00012 {
00013 TDirectory *dir = gDirectory ;
00014 m_file = new TFile (fileName.c_str (),"RECREATE") ;
00015 m_file->cd () ;
00016 m_tree = new TTree (treeName.c_str(),"Analysis tree") ;
00017 m_tree->SetAutoSave (10000000) ;
00018 dir->cd () ;
00019
00020
00021 m_data = new TClonesArray (TB06RecoH2::Class (), 1) ;
00022 m_data->ExpandCreateFast (1) ;
00023
00024
00025 m_tree->Branch ("TB06O", &m_data, 64000, 2) ;
00026 m_tree->Print () ;
00027
00028 }
00029
00030
00031
00032
00033 TB06TreeH2::~TB06TreeH2 ()
00034 {
00035 std::cout << "[TB06TreeH2][dtor] saving TTree " << m_tree->GetName ()
00036 << " with " << m_tree->GetEntries () << " entries"
00037 << " on file: " << m_file->GetName () << std::endl ;
00038
00039 m_file->Write () ;
00040 delete m_tree ;
00041 m_file->Close () ;
00042 delete m_file ;
00043 delete m_data ;
00044 }
00045
00046
00047
00048
00050 void TB06TreeH2::store (const int & tableIsMoving,
00051 const int & run, const int & event,
00052 const int & S6adc ,
00053 const double & xhodo, const double & yhodo,
00054 const double & xslope, const double & yslope,
00055 const double & xquality, const double & yquality,
00056 const int & icMax,
00057 const int & ietaMax, const int & iphiMax,
00058 const double & beamEnergy,
00059 const double ampl[49],
00060 const int &wcAXo,const int &wcAYo,
00061 const int &wcBXo,const int &wcBYo,
00062 const int &wcCXo,const int &wcCYo,
00063 const double & xwA, const double & ywA,
00064 const double & xwB, const double & ywB,
00065 const double & xwC, const double & ywC,
00066 const float &S1adc, const float &S2adc,
00067 const float &S3adc, const float &S4adc,
00068 const float &VM1,const float &VM2,const float &VM3,
00069 const float &VM4,const float &VM5,const float &VM6,
00070 const float &VM7,const float &VM8,const float &VMF,
00071 const float &VMB,
00072 const float &CK1,const float &CK2, const float &CK3,
00073 const float &BH1,const float &BH2,const float &BH3,
00074 const float &BH4,
00075 const float &TOF1S, const float &TOF2S,
00076 const float &TOF1J,const float &TOF2J
00077 )
00078 {
00079
00080 m_data->Clear () ;
00081 TB06RecoH2 * entry = static_cast<TB06RecoH2*> (m_data->AddrAt (0)) ;
00082
00083 entry->reset () ;
00084
00085
00086 entry->tableIsMoving = tableIsMoving ;
00087 entry->run = run ;
00088 entry->event = event ;
00089 entry->S6ADC = S6adc ;
00090
00091 entry->MEXTLindex = icMax ;
00092 entry->MEXTLeta = ietaMax ;
00093 entry->MEXTLphi = iphiMax ;
00094 entry->MEXTLenergy = ampl[24] ;
00095 entry->beamEnergy = beamEnergy ;
00096
00097 for (int eta = 0 ; eta<7 ; ++eta)
00098 for (int phi = 0 ; phi<7 ; ++phi)
00099 {
00100
00101
00102 entry->localMap[eta][phi] = ampl[eta*7+phi] ;
00103 }
00104
00105
00106 entry->S1uncalib_ = ampl[24];
00107
00108
00109 for (int eta = 1 ; eta<6 ; ++eta)
00110 for (int phi = 1 ; phi<6 ; ++phi)
00111 {
00112 entry->S25uncalib_ += entry->localMap[eta][phi] ;
00113 }
00114
00115
00116 for (int eta = 0 ; eta<7 ; ++eta)
00117 for (int phi = 0 ; phi<7 ; ++phi)
00118 {
00119 entry->S49uncalib_ += entry->localMap[eta][phi] ;
00120 }
00121
00122
00123 for (int eta = 2 ; eta<5 ; ++eta)
00124 for (int phi = 2 ; phi<5 ; ++phi)
00125 {
00126 entry->S9uncalib_ += entry->localMap[eta][phi] ;
00127 }
00128
00129 entry->xHodo = xhodo ;
00130 entry->yHodo = yhodo ;
00131 entry->xSlopeHodo = xslope ;
00132 entry->ySlopeHodo = yslope ;
00133 entry->xQualityHodo = xquality ;
00134 entry->yQualityHodo = yquality ;
00135 entry->wcAXo_ = wcAXo;
00136 entry->wcAYo_ = wcAYo;
00137 entry->wcBXo_ = wcBXo;
00138 entry->wcBYo_ = wcBYo;
00139 entry->wcCXo_ = wcCXo;
00140 entry->wcCYo_ = wcCYo;
00141 entry->xwA_ = xwA;
00142 entry->ywA_ = ywA;
00143 entry->xwB_ = xwB;
00144 entry->ywB_ = ywB;
00145 entry->xwC_ = xwC;
00146 entry->ywC_ = ywC;
00147 entry->S1adc_ = S1adc;
00148 entry->S2adc_ = S2adc;
00149 entry->S3adc_ = S3adc;
00150 entry->S4adc_ = S4adc;
00151 entry->VM1_ = VM1;
00152 entry->VM2_ = VM2;
00153 entry->VM3_ = VM3;
00154 entry->VM4_ = VM4;
00155 entry->VM5_ = VM5;
00156 entry->VM6_ = VM6;
00157 entry->VM7_ = VM7;
00158 entry->VM8_ = VM8;
00159 entry->VMF_ = VMF;
00160 entry->VMB_ = VMB;
00161 entry->CK1_ = CK1;
00162 entry->CK2_ = CK2;
00163 entry->CK3_ = CK3;
00164 entry->BH1_ = BH1;
00165 entry->BH2_ = BH2;
00166 entry->BH3_ = BH3;
00167 entry->BH4_ = BH4;
00168 entry->TOF1S_ = TOF1S;
00169 entry->TOF2S_ = TOF2S;
00170 entry->TOF1J_ = TOF1J;
00171 entry->TOF2J_ = TOF2J;
00172
00173 entry->convFactor = 0. ;
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 m_tree->Fill () ;
00195 }
00196
00197
00198
00199
00200
00201 void TB06TreeH2::reset (float crystal[11][21])
00202 {
00203 for (int eta =0 ; eta<11 ; ++eta)
00204 {
00205 for (int phi =0 ; phi<21 ; ++phi)
00206 {
00207 crystal[eta][phi] = -999. ;
00208 }
00209 }
00210 }
00211
00212
00213
00214
00215
00216 void TB06TreeH2::check ()
00217 {
00218 TB06RecoH2 * entry = static_cast<TB06RecoH2*> (m_data->AddrAt (0)) ;
00219
00220 std::cout << "[TB06TreeH2][check]reading . . . \n" ;
00221 std::cout << "[TB06TreeH2][check] entry->run: " << entry->run << "\n" ;
00222 std::cout << "[TB06TreeH2][check] entry->event: " << entry->event << "\n" ;
00223 std::cout << "[TB06TreeH2][check] entry->tableIsMoving: " << entry->tableIsMoving << "\n" ;
00224 std::cout << "[TB06TreeH2][check] entry->MEXTLeta: " << entry->MEXTLeta << "\n" ;
00225 std::cout << "[TB06TreeH2][check] entry->MEXTLphi: " << entry->MEXTLphi << "\n" ;
00226 std::cout << "[TB06TreeH2][check] entry->MEXTLenergy: " << entry->MEXTLenergy << "\n" ;
00227
00228 for (int eta = 0 ; eta<7 ; ++eta)
00229 for (int phi = 0 ; phi<7 ; ++phi)
00230 std::cout << "[TB06TreeH2][check] entry->localMap[" << eta
00231 << "][" << phi << "]: "
00232 << entry->localMap[eta][phi] << "\n" ;
00233
00234 std::cout << "[TB06TreeH2][check] entry->xHodo: " << entry->xHodo << "\n" ;
00235 std::cout << "[TB06TreeH2][check] entry->yHodo: " << entry->yHodo << "\n" ;
00236 std::cout << "[TB06TreeH2][check] entry->xSlopeHodo: " << entry->xSlopeHodo << "\n" ;
00237 std::cout << "[TB06TreeH2][check] entry->ySlopeHodo: " << entry->ySlopeHodo << "\n" ;
00238 std::cout << "[TB06TreeH2][check] entry->xQualityHodo: " << entry->xQualityHodo << "\n" ;
00239 std::cout << "[TB06TreeH2][check] entry->yQualityHodo: " << entry->yQualityHodo << "\n" ;
00240 std::cout << "[TB06TreeH2][check] entry->convFactor: " << entry->convFactor << "\n" ;
00241
00242
00243
00244
00245
00246 }
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275