00001 #include <cstdio>
00002 #include <iostream>
00003 #include "TClonesArray.h"
00004 #include "MessageService/MsgService.h"
00005 #include "Record/RecArrayAllocator.h"
00006 #include "CandNtupleSR/NtpSRRecord.h"
00007 #include "CalDetSI/Helpers.h"
00008 #include "CalDetDST/UberHit.h"
00009 #include "CalDetDST/UberCosmicHit.h"
00010 #include "CalDetDST/UberRecordLite.h"
00011
00012 ClassImp(UberRecordLite)
00013
00014 CVSID("$Id: UberRecordLite.cxx,v 1.4 2005/02/28 12:16:38 kordosky Exp $");
00015 using namespace std;
00016
00017
00018 UberRecordLite::UberRecordLite():
00019 RecRecordImp<UberRecHeader>(),
00020 snarlno(0),
00021 triggerword(0),
00022 triggertime(0.),
00023 nhits(0),
00024 nhitplanes(0),
00025 nhitstrips(0),
00026 ndeadplanes(0),
00027 mindeadplaneno(CalDetConstants::PLANECONST),
00028 sigcorrconv(0.),
00029 totmip(0.),
00030 maxadc(0),
00031 maxnpe(0.),
00032 maxmip(0.),
00033 maxtime(0.),
00034 p0totmip(0.),
00035 p1totmip(0.),
00036 p0stripmaxmip(CalDetConstants::STRIPCONST),
00037 p0maxmiptstamp(0.),
00038 p1stripmaxmip(CalDetConstants::STRIPCONST),
00039 p1maxmiptstamp(0.),
00040 mipweighaveplane(0.),
00041 mipweighcentereven(0.),
00042 mipweighcenterodd(0.),
00043 mipweighrad(0.),
00044 showermax(0),
00045 mipshowermax(0.),
00046 toftime(0.), torbits(0), torok(kFALSE),
00047 cpid(),
00048 shw(0),
00049 trk(0),
00050 evt(0),
00051 fhitindex(0),
00052 hitlist(0),
00053 fcoshitindex(0),
00054 coshitlist(0)
00055 {
00056
00057 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite creator"<<endl;
00058 for(int i=0;i<CalDetConstants::KOVCONST;i++){
00059 ceradc[i]=0;
00060 certime[i]=0.;
00061 }
00062 for(int i=0;i<CalDetConstants::TOFCONST;i++){
00063 toftdc[i]=0;
00064 tofadc[i]=0;
00065 tofhittime[i]=0.;
00066 }
00067
00068 this->Init();
00069 }
00070
00071
00072 UberRecordLite::UberRecordLite(const UberRecHeader& header):
00073 RecRecordImp<UberRecHeader>(header),
00074 snarlno(0),
00075 triggerword(0),
00076 triggertime(0.),
00077 nhits(0),
00078 nhitplanes(0),
00079 nhitstrips(0),
00080 ndeadplanes(0),
00081 mindeadplaneno(CalDetConstants::PLANECONST),
00082 sigcorrconv(0.),
00083 totmip(0.),
00084 maxadc(0),
00085 maxnpe(0.),
00086 maxmip(0.),
00087 maxtime(0.),
00088 p0totmip(0.),
00089 p1totmip(0.),
00090 p0stripmaxmip(CalDetConstants::STRIPCONST),
00091 p0maxmiptstamp(0.),
00092 p1stripmaxmip(CalDetConstants::STRIPCONST),
00093 p1maxmiptstamp(0.),
00094 mipweighaveplane(0.),
00095 mipweighcentereven(0.),
00096 mipweighcenterodd(0.),
00097 mipweighrad(0.),
00098 showermax(0),
00099 mipshowermax(0.),
00100 toftime(0.), torbits(0), torok(kFALSE),
00101 cpid(),
00102 shw(0),
00103 trk(0),
00104 evt(0),
00105 fhitindex(0),
00106 hitlist(0),
00107 fcoshitindex(0),
00108 coshitlist(0)
00109
00110 {
00111
00112 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite creator with header arg"<<endl;
00113 for(int i=0;i<CalDetConstants::KOVCONST;i++){
00114 ceradc[i]=0;
00115 certime[i]=0.;
00116 }
00117 for(int i=0;i<CalDetConstants::TOFCONST;i++){
00118 toftdc[i]=0;
00119 tofadc[i]=0;
00120 tofhittime[i]=0.;
00121 }
00122 this->Init();
00123
00124 }
00125
00126
00127 UberRecordLite::~UberRecordLite()
00128 {
00129
00130 MSG("UberRecordLite",Msg::kDebug)<<"In ~UberRecordLite"<<endl;
00131 RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00132 MSG("UberRecordLite",Msg::kDebug)<<"got instance"<<endl;
00133
00134 if ( hitlist ) { allocator.ReleaseArray( hitlist ); hitlist = 0; }
00135 MSG("UberRecordLite",Msg::kDebug)<<"In released hitlist"<<endl;
00136 if ( coshitlist ) { allocator.ReleaseArray( coshitlist ); coshitlist = 0; }
00137 MSG("UberRecordLite",Msg::kDebug)<<"In released coshitlist"<<endl;
00138 if ( shw ) { allocator.ReleaseArray( shw ); shw = 0; }
00139 MSG("UberRecordLite",Msg::kDebug)<<"In released shw"<<endl;
00140 if ( trk ) { allocator.ReleaseArray( trk ); trk = 0; }
00141 MSG("UberRecordLite",Msg::kDebug)<<"In released trk"<<endl;
00142 if ( evt ) { allocator.ReleaseArray( evt ); evt = 0; }
00143 MSG("UberRecordLite",Msg::kDebug)<<"In released evt"<<endl;
00144
00145
00146 }
00147
00148
00149 void UberRecordLite::Clear(Option_t* ){
00150
00151 hitlist->Clear("C");
00152 trk->Clear("C");
00153 shw->Clear("C");
00154 evt->Clear("C");
00155 }
00156
00157
00158 void UberRecordLite::Init()
00159 {
00160
00161 SetClearable(true);
00162
00163 MSG("UberRecordLite",Msg::kDebug)<<"In Init"<<endl;
00164 RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00165 MSG("UberRecordLite",Msg::kDebug)<<"GOT an allocator? "<<endl;
00166
00167 MSG("UberRecordLite",Msg::kDebug)<<"hitlist "<<hitlist<<endl;
00168 if(!hitlist){
00169 hitlist = allocator.GetArray("UberHit");
00170 MSG("UberRecordLite",Msg::kDebug)<<"MADE NEW HITLIST"<<endl;
00171 }
00172 if(!coshitlist){
00173 coshitlist = allocator.GetArray("UberCosmicHit");
00174 MSG("UberRecordLite",Msg::kDebug)<<"MADE NEW COSHITLIST"<<endl;
00175 }
00176 if(!shw){
00177 shw = allocator.GetArray("NtpSRShower");
00178 MSG("UberRecordLite",Msg::kDebug)<<"MADE NEW SHW"<<endl;
00179 }
00180 if(!trk){
00181 trk = allocator.GetArray("NtpSRTrack");
00182 MSG("UberRecordLite",Msg::kDebug)<<"MADE NEW TRK"<<endl;
00183 }
00184 if(!evt){
00185 evt = allocator.GetArray("NtpSREvent");
00186 MSG("UberRecordLite",Msg::kDebug)<<"MADE NEW EVT"<<endl;
00187 }
00188
00189 }
00190
00191
00192 void UberRecordLite::ResetEvent()
00193 {
00194 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite ResetEvent"<<endl;
00195 hitlist->Clear();
00196 fhitindex=0;
00197 coshitlist->Clear();
00198 fcoshitindex=0;
00199 shw->Clear();
00200 trk->Clear();
00201 evt->Clear();
00202
00203 fhitindex=0;
00204 snarlno=0;
00205 triggerword=0;
00206 triggertime=0.;
00207 nhits=0;
00208 nhitplanes=0;
00209 nhitstrips=0;
00210 ndeadplanes=0;
00211 mindeadplaneno=CalDetConstants::PLANECONST;
00212 sigcorrconv =0.;
00213 totmip=0;
00214 maxadc=0;
00215 maxnpe=0;
00216 maxmip=0;
00217 maxtime=0;
00218 p0totmip=0;
00219 p1totmip=0;
00220 p0stripmaxmip=CalDetConstants::STRIPCONST;
00221 p0maxmiptstamp=0.;
00222 p1stripmaxmip=CalDetConstants::STRIPCONST;
00223 p1maxmiptstamp=0.;
00224 mipweighaveplane=0.;
00225 mipweighcentereven=0.;
00226 mipweighcenterodd=0.;
00227 mipweighrad=0.;
00228 showermax=0;
00229 mipshowermax = 0.;
00230 for(int i=0;i<CalDetConstants::KOVCONST;i++){
00231 ceradc[i]=0;
00232 certime[i]=0.;
00233 }
00234 for(int i=0;i<CalDetConstants::TOFCONST;i++){
00235 toftdc[i]=0;
00236 tofadc[i]=0;
00237 tofhittime[i]=0.;
00238 }
00239 toftime=0;
00240 torbits=0; torok=kFALSE;
00241 cpid.Reset();
00242 }
00243
00244
00245 int UberRecordLite::AddNextHit(UShort_t p, UShort_t s)
00246 {
00247 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite AddNextHit"<<endl;
00248 MSG("UberRecordLite",Msg::kDebug)<<"value of hitlist "<<hitlist
00249 <<" value of fhitindex "<<fhitindex<<endl;
00250 new((*hitlist)[fhitindex]) UberHit();
00251 MSG("UberRecordLite",Msg::kDebug)<<"Made new UberHit element in TClonesArray"<<endl;
00252 UberHit *uh = static_cast<UberHit *>((*hitlist)[fhitindex]);
00253 MSG("UberRecordLite",Msg::kDebug)<<"Cast array element to uberhit"<<endl;
00254 int fhi = fhitindex;
00255 uh->SetPlaneStrip(p,s);
00256
00257 fhitindex++;
00258 return fhi;
00259
00260 }
00261
00262
00263 void UberRecordLite::AddNextHitValues(StripEnd::StripEnd_t se,
00264 Int_t adc, Float_t siglin,Float_t npe,
00265 Float_t mip, Float_t time, Int_t agg)
00266 {
00267 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite AddnextHitValues"<<endl;
00268 UberHit *uh = static_cast<UberHit *>((*hitlist)[fhitindex-1]);
00269 uh->AddValues(se, adc, siglin, npe, mip, time, agg);
00270 return;
00271 }
00272
00273
00274 void UberRecordLite::AddNextCosmicHit(UShort_t p, UShort_t s)
00275 {
00276 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite AddNextHit"<<endl;
00277 new((*coshitlist)[fcoshitindex]) UberCosmicHit();
00278 UberCosmicHit *uch = static_cast<UberCosmicHit *>((*coshitlist)[fcoshitindex]);
00279 uch->SetPlaneStrip(p,s);
00280 fcoshitindex++;
00281 return;
00282
00283 }
00284
00285
00286 void UberRecordLite::AddNextCosmicHitValues(StripEnd::StripEnd_t se,
00287 Int_t adc, Float_t time, Int_t agg)
00288 {
00289 MSG("UberRecordLite",Msg::kDebug)<<"In UberRecordLite AddnextCosmicHitValues"<<endl;
00290 UberCosmicHit *uch = static_cast<UberCosmicHit *>((*coshitlist)[fcoshitindex-1]);
00291 uch->AddValues(se, adc, time, agg);
00292 return;
00293 }
00294
00295
00296 void UberRecordLite::Print(Option_t* ) const
00297 {
00298 UberRecordLite::Print(std::cout);
00299 return;
00300
00301 }
00302
00303
00304
00305 std::ostream& UberRecordLite::Print(std::ostream& os) const
00306 {
00307 os<<"UberRecordLite::Print"<<endl;
00308 RecRecordImp<UberRecHeader>::Print(os);
00309
00310 int i=0;
00311 TObject *obj = 0;
00312 while((obj = hitlist->At(i))){
00313 UberHit *uh = static_cast<UberHit *>(obj);
00314 os<<"HIT "<<i<<endl;
00315 uh->Print();
00316 i++;
00317 }
00318 return os;
00319 }
00320