#include <CalHit.h>
Inheritance diagram for calhit::CalHit:

Public Member Functions | |
| CalHit (const char *version) | |
| virtual | ~CalHit () |
| jobc::Result | Reco (edm::EventHandle &evt) |
| read/write access to event | |
| void | Update (const cfg::Config &) |
Protected Member Functions | |
| virtual jobc::Result | ADC2PEHit (recobase::CellHit *) |
| base clase convertor | |
| virtual jobc::Result | ADC2PEACHit (recobase::CellHit *) |
| base clase convertor | |
| virtual jobc::Result | ADC2MIPHit (recobase::CellHit *) |
| base clase convertor | |
| virtual jobc::Result | TDC2NSHit (recobase::CellHit *) |
| base clase convertor | |
| virtual jobc::Result | TDC2TT0Hit (recobase::CellHit *) |
| base clase convertor | |
| virtual jobc::Result | TDC2TTransHit (recobase::CellHit *) |
| base clase convertor | |
| virtual void | AddAttCorr (recobase::CellHit *) |
| add cell hit to attenuation info | |
Private Member Functions | |
| jobc::Result | GetData (edm::EventHandle &) |
| get input data as needed | |
| jobc::Result | AddToData (edm::EventHandle &) |
| add calibrated information | |
| jobc::Result | SaveData (edm::EventHandle &) |
| save modified data to the record | |
| void | PrintCalibs () |
| print out calibration status | |
| jobc::Result | Raw (edm::EventHandle &evt) |
| create new CalHits | |
| jobc::Result | Read (edm::EventHandle &evt) |
| read in existing CalHits | |
| bool | DoCalib (recobase::CellHit_t, int=-1) |
| Check or set whether calib type is requested. | |
Private Attributes | |
| std::string | fInputFolder |
| folder input | |
| std::string | fOutputFolder |
| folder for output | |
| int | fDoCalib |
| bool | fWarnedPE |
| bool | fWarnedPEAC |
| bool | fWarnedMIP |
| bool | fWarnedNS |
| bool | fWarnedTT0 |
| bool | fWarnedTTrans |
| std::vector< recobase::CellHit * > | fCellVec |
| Working vector of cell hits. | |
| std::vector< const recobase::CellHit * > | fCellInput |
| const buffer of vector of cell hits | |
Definition at line 20 of file CalHit.h.
|
|
create calibrated hits. This is a base class that does most of the work, expect for higher levels of refinement in the calibration techniques reflected in the derived classes. Definition at line 12 of file CalHit.cxx. References jobc::Module::SetCfgVersion().
00012 : 00013 jobc::Module("CalHit"), 00014 fInputFolder("."), 00015 fOutputFolder("Hits"), 00016 fDoCalib(1), 00017 fWarnedPE(false), 00018 fWarnedPEAC(false), 00019 fWarnedMIP(false), 00020 fWarnedNS(false), 00021 fWarnedTT0(false), 00022 fWarnedTTrans(false) 00023 { 00024 00025 this->SetCfgVersion(version); 00026 } |
|
|
Definition at line 28 of file CalHit.cxx.
00029 {
00030
00031 }
|
|
|
base clase convertor
Definition at line 293 of file CalHit.cxx. References ADC2PEACHit(), fWarnedMIP, recobase::CellHit::PEAC(), jobc::Result, and recobase::CellHit::SetMIP(). Referenced by AddToData().
00294 {
00295 // Boneheaded base clase - represents MIP-corrected ph
00296
00297 if (!fWarnedMIP) {
00298 std::cerr<<"\nWarning! Using baseclass CalHit::ADC2MIPHit. "<<
00299 " Do not use this for Physics!"<<std::endl;
00300 fWarnedMIP=true;
00301 }
00302
00303
00304 // require PE attcor'd number before converting to MIPs
00305 float pe;
00306 if (!ch->PEAC(pe)) {
00307 if (!ADC2PEACHit(ch)) return jobc::kFailed;
00308 ch->PEAC(pe);
00309 }
00310 ch->SetMIP(pe/30.);
00311
00312 return jobc::kPassed;
00313
00314 } // ADC2MIPHit
|
|
|
base clase convertor
Reimplemented in calhit::MyHit. Definition at line 270 of file CalHit.cxx. References ADC2PEHit(), fWarnedPEAC, recobase::CellHit::PE(), jobc::Result, and recobase::CellHit::SetPEAC(). Referenced by ADC2MIPHit(), and AddToData().
00271 {
00272 // Boneheaded base clase - represents attenuation-corrected PEs
00273
00274 if (!fWarnedPEAC) {
00275 std::cerr<<"\nWarning! Using baseclass CalHit::ADC2PEACHit. "<<
00276 " Do not use this for Physics!"<<std::endl;
00277 fWarnedPEAC=true;
00278 }
00279
00280
00281 // require PE number before applying attenuation correction
00282 float pe;
00283 if (!ch->PE(pe)) {
00284 if (!ADC2PEHit(ch)) return jobc::kFailed;
00285 ch->PE(pe);
00286 }
00287 ch->SetPEAC(pe/0.55);
00288
00289 return jobc::kPassed;
00290
00291 } // ADC2PEACHit
|
|
|
base clase convertor
Definition at line 248 of file CalHit.cxx. References recobase::CellHit::ADC(), recobase::CellHit::Channel(), fWarnedPE, jobc::Result, and recobase::CellHit::SetPE(). Referenced by calhit::MyHit::ADC2PEACHit(), ADC2PEACHit(), and AddToData().
00249 {
00250 // Boneheaded base clase
00251 if (!fWarnedPE) {
00252 std::cerr<<"\nWarning! Using baseclass CalHit::ADC2PEHit. "<<
00253 " Do not use this for Physics!"<<std::endl;
00254 fWarnedPE=true;
00255 }
00256
00257
00258 unsigned short adc;
00259 if (!ch->ADC(adc)) {
00260 std::cerr<<"CalHit::ADC2PEHit(): raw adc not set in cell hit for channel "<<
00261 ch->Channel()<<std::endl;
00262 return jobc::kFailed;
00263 }
00264 ch->SetPE(adc/4.095);// dummy value
00265
00266 return jobc::kPassed;
00267
00268 } // ADC2PEHit
|
|
|
add cell hit to attenuation info
Definition at line 239 of file CalHit.cxx. Referenced by Raw(), and Read().
00240 {
00241 // add this cell to attenuation correction
00242
00243 // but a dummy for the time being...
00244
00245
00246 }
|
|
|
add calibrated information
Definition at line 154 of file CalHit.cxx. References ADC2MIPHit(), ADC2PEACHit(), ADC2PEHit(), DoCalib(), fCellVec, jobc::Result, TDC2NSHit(), TDC2TT0Hit(), and TDC2TTransHit(). Referenced by Reco().
00155 {
00156
00157 std::vector<recobase::CellHit*>::iterator iter=fCellVec.begin();
00158 while (iter!=fCellVec.end())
00159 {
00160 recobase::CellHit* ch=*iter;
00161
00162 // create Photo Electron equivalent ADC
00163 if (DoCalib(recobase::kPE))
00164 if (ADC2PEHit(ch)==jobc::kFailed) return jobc::kFailed;
00165
00166 //... with Attenuation correction
00167 if (DoCalib(recobase::kPEAC))
00168 if (ADC2PEACHit(ch)==jobc::kFailed) return jobc::kFailed;
00169
00170 //... in MIP units
00171 if (DoCalib(recobase::kMIP))
00172 if (ADC2MIPHit(ch)==jobc::kFailed) return jobc::kFailed;
00173
00174 // tdc in ns
00175 if (DoCalib(recobase::kTNS))
00176 if (TDC2NSHit(ch)==jobc::kFailed) return jobc::kFailed;
00177
00178 // tdc in ns, with transit time correction
00179 if (DoCalib(recobase::kTTrans))
00180 if (TDC2TTransHit(ch)==jobc::kFailed) return jobc::kFailed;
00181
00182 // tdc in ns, with transit time correction, from a T0
00183 if (DoCalib(recobase::kTT0))
00184 if (TDC2TT0Hit(ch)==jobc::kFailed) return jobc::kFailed;
00185
00186 iter++;
00187 }
00188
00189 return jobc::kPassed;
00190
00191 }
|
|
||||||||||||
|
Check or set whether calib type is requested.
Definition at line 220 of file CalHit.cxx. References recobase::CellHit_t, and fDoCalib. Referenced by AddToData(), GetData(), PrintCalibs(), Raw(), Read(), and Update().
00221 {
00222 // if set<0, then caller is asking what calibrations are done
00223 // set=0, caller wants to turn off a calibration
00224 // set>0, caller wants to turn on a calibration
00225
00226 if (set < 0 ) {
00227 return (fDoCalib & (1<<level) );
00228 } else if (set == 0 ) {
00229 fDoCalib = fDoCalib&=(~(1<<level));
00230 return false;
00231 } else {
00232 fDoCalib = fDoCalib|=(1<<level);
00233 return true;
00234 }
00235
00236 }
|
|
|
get input data as needed
Definition at line 59 of file CalHit.cxx. References DoCalib(), fCellInput, fCellVec, Raw(), Read(), and jobc::Result. Referenced by Reco().
00060 {
00061 // clear the local copy
00062 fCellVec.clear();
00063 fCellInput.clear();
00064
00065 // get the data from the appropriate place
00066 if (DoCalib(recobase::kRAW)) {
00067
00068 // create cal hits, and copy over raw data
00069 if (Raw(evt)==jobc::kFailed) return jobc::kFailed;
00070
00071 } else {
00072
00073 // start with existing cal hits
00074 if (Read(evt)==jobc::kFailed) return jobc::kFailed;
00075
00076 }
00077
00078 return jobc::kPassed;
00079 }
|
|
|
print out calibration status
Definition at line 433 of file CalHit.cxx. References DoCalib(). Referenced by Update().
00434 {
00435 std::cerr<<"Calibrations Requested:"<<std::endl;
00436
00437 std::cerr<<" Starting from Raw Data: " ;
00438 if (DoCalib(recobase::kRAW)) std::cerr<<" Yes"<<std::endl; else
00439 std::cerr<<" NO"<<std::endl;
00440
00441 std::cerr<<" PE Units: ";
00442 if (DoCalib(recobase::kPE)) std::cerr<<" Yes"<<std::endl; else
00443 std::cerr<<" NO"<<std::endl;
00444
00445 std::cerr<<" Attenuation Correction (to PEs): ";
00446 if (DoCalib(recobase::kPEAC)) std::cerr<<" Yes"<<std::endl; else
00447 std::cerr<<" NO"<<std::endl;
00448
00449 std::cerr<<" MIP Units: ";
00450 if (DoCalib(recobase::kMIP)) std::cerr<<" Yes"<<std::endl; else
00451 std::cerr<<" NO"<<std::endl;
00452
00453 std::cerr<<" Time in ns units: " ;
00454 if (DoCalib(recobase::kTNS)) std::cerr<<" Yes"<<std::endl; else
00455 std::cerr<<" NO"<<std::endl;
00456
00457 std::cerr<<" T-zero corrected time in ns: " ;
00458 if (DoCalib(recobase::kTT0)) std::cerr<<" Yes"<<std::endl; else
00459 std::cerr<<" NO"<<std::endl;
00460
00461 std::cerr<<" Transit time corrected time in ns: " ;
00462 if (DoCalib(recobase::kTTrans)) std::cerr<<" Yes"<<std::endl; else
00463 std::cerr<<" NO"<<std::endl;
00464 }
|
|
|
create new CalHits
Definition at line 81 of file CalHit.cxx. References rawdata::RawDigit::ADC(), AddAttCorr(), rawdata::RawDigit::Channel(), DoCalib(), fCellVec, fInputFolder, rawdata::RawDigit::GetCell(), rawdata::RawDigit::GetPlane(), edm::EventHandle::Raw(), jobc::Result, recobase::CellHit::SetCell(), recobase::CellHit::SetPlane(), and rawdata::RawDigit::TDC(). Referenced by GetData().
00082 {
00083 // get raw data
00084
00085 std::vector<const rawdata::RawDigit*> diglist;
00086 try {
00087 evt.Raw().Get(fInputFolder.c_str(),diglist);
00088 } catch (edm::Exception e) {
00089 std::cerr << "Error retrieving digit list, while looking for raw "<<
00090 "digits in CalHit::Raw()"<<std::endl;
00091 return jobc::kFailed;
00092 }
00093
00094 // loop over all raw digits, and create basic calibrated hits in local
00095 // record
00096 std::vector<const rawdata::RawDigit*>::iterator iter=diglist.begin();
00097 while (iter!=diglist.end())
00098 {
00099 const rawdata::RawDigit *rd=*iter;
00100 recobase::CellHit* ch=new recobase::CellHit(rd->Channel(),
00101 rd->ADC(0),rd->TDC(0));
00102
00103
00104 //printf("%d %d\n",rd->GetCell(),rd->GetPlane());
00105
00106 //printf("%d ",rd->ADC(0));
00107
00108 ch->SetCell(rd->GetCell());
00109 ch->SetPlane(rd->GetPlane());
00110 fCellVec.push_back(ch);
00111
00112 // if we'll be doing an attenuation correction, collect
00113 // necessary information here
00114 if (DoCalib(recobase::kPEAC)) AddAttCorr(ch);
00115 iter++;
00116 }
00117
00118 return jobc::kPassed;
00119
00120 }
|
|
|
read in existing CalHits
Definition at line 122 of file CalHit.cxx. References AddAttCorr(), DoCalib(), fCellInput, fCellVec, fInputFolder, edm::EventHandle::Reco(), and jobc::Result. Referenced by GetData().
00123 {
00124 // get existing CalHit's
00125
00126 try {
00127 evt.Reco().Get(fInputFolder.c_str(),fCellInput);
00128 } catch (edm::Exception e) {
00129 std::cerr << "Error retrieving CellHit list in "<<fInputFolder.c_str()
00130 <<std::endl;
00131 return jobc::kFailed;
00132 }
00133
00134
00135 // if we will need attenuation correction, accumulate necessary info
00136 // here
00137 std::vector<const recobase::CellHit*>::iterator iter=fCellInput.begin();
00138 std::cerr<<"Found "<<fCellInput.size()<<" cell hits in input"<<std::endl;
00139 while (iter!=fCellInput.end())
00140 {
00141 const recobase::CellHit* oldch=*iter;
00142 recobase::CellHit* ch=new recobase::CellHit(*oldch);
00143 fCellVec.push_back(ch);
00144 if (DoCalib(recobase::kPEAC))
00145 {
00146 AddAttCorr(ch);
00147 }
00148 iter++;
00149 }
00150
00151 return jobc::kPassed;
00152 }
|
|
|
read/write access to event
Reimplemented from jobc::Module. Definition at line 33 of file CalHit.cxx. References AddToData(), GetData(), jobc::Result, and SaveData().
00034 {
00035
00036 // base class Reco method.
00037
00038 if (jobc::kFailed==GetData(evt)) {
00039 std::cerr <<"CalHit::GetData failed. Returning"<<std::endl;
00040 return jobc::kFailed;
00041 }
00042
00043 if (jobc::kFailed==AddToData(evt)) {
00044 std::cerr <<"CalHit::AddToData failed. Returning"<<std::endl;
00045 return jobc::kFailed;
00046 }
00047
00048 if (jobc::kFailed==SaveData(evt)) {
00049 std::cerr <<"CalHit::SaveData failed. Returning"<<std::endl;
00050 return jobc::kFailed;
00051 }
00052
00053
00054 return jobc::kPassed;
00055
00056 }
|
|
|
save modified data to the record
Definition at line 193 of file CalHit.cxx. References fCellVec, fOutputFolder, edm::EventHandle::Reco(), and jobc::Result. Referenced by Reco().
00194 {
00195 if (evt.Reco().GetFolder(fOutputFolder.c_str())) {
00196 std::cerr << "Output Folder reco/"<<fOutputFolder.c_str()<<
00197 " already exists"<<std::endl;
00198 return jobc::kFailed;
00199 }
00200
00201 TFolder* folder=evt.Reco().MakeFolder(fOutputFolder.c_str());
00202
00203 int nsave=evt.Reco().PutVector(fCellVec,fOutputFolder.c_str());
00204 if (nsave!=fCellVec.size())
00205 {
00206 std::cerr <<"CalHit::SaveData: wrong number CellHits saved: "<<
00207 nsave<<" instead of expected "<<fCellVec.size()<<std::endl;
00208 return jobc::kFailed;
00209 }
00210 float pe,peac;
00211 fCellVec[0]->PE(pe);
00212 fCellVec[0]->PEAC(peac);
00213 std::cerr << "saved "<<nsave<<" CellHits. first pe="<<pe<<", atcor="<<peac<<
00214 std::endl;
00215
00216 return jobc::kPassed;
00217
00218 }
|
|
|
base clase convertor < CALIB_HOOK Definition at line 316 of file CalHit.cxx. References recobase::CellHit::Channel(), fWarnedNS, jobc::Result, recobase::CellHit::SetTNS(), and recobase::CellHit::TDC(). Referenced by AddToData(), and TDC2TT0Hit().
00317 {
00318 // Boneheaded base clase - represents time in ns
00319 if (!fWarnedNS) {
00320 std::cerr<<"\nWarning! Using baseclass CalHit::TDC2NSHit. "<<
00321 " Do not use this for Physics!"<<std::endl;
00322 fWarnedNS=true;
00323 }
00324
00325
00326 unsigned short tdc;
00327 if (!ch->TDC(tdc)) {
00328 std::cerr<<"CalHit::TDC2NSHit(): raw tdc not set in cell hit for channel "<<
00329 ch->Channel()<<std::endl;
00330 return jobc::kFailed;
00331 }
00332 ch->SetTNS(tdc*1.5e3);
00333
00334 return jobc::kPassed;
00335
00336 } // TDC2NSHit
|
|
|
base clase convertor < CALIB_HOOK Definition at line 338 of file CalHit.cxx. References fWarnedTT0, jobc::Result, recobase::CellHit::SetTT0(), TDC2NSHit(), and recobase::CellHit::TNS(). Referenced by AddToData(), and TDC2TTransHit().
00339 {
00340 // Boneheaded base clase - represents hit times corrected for global event
00341 // t0
00342
00343 if (!fWarnedTT0) {
00344 std::cerr<<"\nWarning! Using baseclass CalHit::TDC2TT0Hit. "<<
00345 " Do not use this for Physics!"<<std::endl;
00346 fWarnedTT0=true;
00347 }
00348
00349
00350 // require NS number before applying t0
00351 double ns;
00352 if (!ch->TNS(ns)) {
00353 if (!TDC2NSHit(ch)) return jobc::kFailed;
00354 ch->TNS(ns); // should be there now...
00355 }
00356 ch->SetTT0(ns+24.6);
00357
00358 return jobc::kPassed;
00359
00360 } // TDC2TT0Hit
|
|
|
base clase convertor < CALIB_HOOK Definition at line 362 of file CalHit.cxx. References fWarnedTTrans, jobc::Result, recobase::CellHit::SetTTrans(), TDC2TT0Hit(), and recobase::CellHit::TT0(). Referenced by AddToData().
00363 {
00364 // Boneheaded base clase - represents transit-time corrected hits
00365
00366 if (!fWarnedTTrans) {
00367 std::cerr<<"\nWarning! Using baseclass CalHit::TDC2TTransHit. "<<
00368 " Do not use this for Physics!"<<std::endl;
00369 fWarnedTTrans=true;
00370 }
00371
00372 // require t0-corrected time before handling transit time
00373 double tt0;
00374 if (!ch->TT0(tt0)) {
00375 if (!TDC2TT0Hit(ch)) return jobc::kFailed; // try setting ns
00376 ch->TT0(tt0); // should be there now...
00377 }
00378 ch->SetTTrans(tt0-7.5*5);
00379
00380 return jobc::kPassed;
00381
00382 } // TDC2TTransHit
|
|
|
Implements cfg::Observer. Definition at line 384 of file CalHit.cxx. References DoCalib(), fDoCalib, fInputFolder, fOutputFolder, and PrintCalibs().
00385 {
00386 c("Input"). Get(fInputFolder);
00387 c("Output"). Get(fOutputFolder);
00388
00389
00390
00391 if (fInputFolder==fOutputFolder) {
00392 std::cerr<<"CalHit::CalHit() - output folder ("<<fOutputFolder.c_str()<<
00393 ") is not allowed to equal input folder ("<<fInputFolder.c_str()
00394 <<")"<< std::endl;
00395 assert(0);
00396 }
00397
00398 std::cerr<<"Set Input Folder ="<<fInputFolder.c_str()<<std::endl;
00399 std::cerr<<"Set Output Folder ="<<fOutputFolder.c_str()<<std::endl;
00400
00401
00402 // zero out calibrations
00403 fDoCalib=0;
00404
00405 std::string calibs;
00406 c("Calibs"). Get(calibs);
00407
00408 // set calibrations according to the string
00409 std::istringstream icalibs(calibs);
00410 while (icalibs.good())
00411 {
00412 std::string tmp;
00413 icalibs>>tmp;
00414 if (tmp=="RAW") DoCalib(recobase::kRAW,1);
00415 else if (tmp=="PE") DoCalib(recobase::kPE,1);
00416 else if (tmp=="PEAC") DoCalib(recobase::kPEAC,1);
00417 else if (tmp=="MIP") DoCalib(recobase::kMIP,1);
00418 else if (tmp=="TNS") DoCalib(recobase::kTNS,1);
00419 else if (tmp=="TT0") DoCalib(recobase::kTT0,1);
00420 else if (tmp=="TTRANS") DoCalib(recobase::kTTrans,1);
00421 else {
00422 std::cerr<<"Unknown calibration requested: "<<tmp.c_str()<<std::endl;
00423 abort();
00424 }
00425
00426
00427 } // parse calibration string
00428
00429 PrintCalibs();
00430
00431
00432 }
|
|
|
const buffer of vector of cell hits
|
|
|
Working vector of cell hits.
Definition at line 63 of file CalHit.h. Referenced by AddToData(), GetData(), Raw(), Read(), and SaveData(). |
|
|
|
|
|
folder input
|
|
|
folder for output
Definition at line 52 of file CalHit.h. Referenced by SaveData(), and Update(). |
|
|
Definition at line 58 of file CalHit.h. Referenced by ADC2MIPHit(). |
|
|
Definition at line 59 of file CalHit.h. Referenced by TDC2NSHit(). |
|
|
Definition at line 56 of file CalHit.h. Referenced by ADC2PEHit(). |
|
|
Definition at line 57 of file CalHit.h. Referenced by ADC2PEACHit(). |
|
|
Definition at line 60 of file CalHit.h. Referenced by TDC2TT0Hit(). |
|
|
Definition at line 61 of file CalHit.h. Referenced by TDC2TTransHit(). |
1.3.5