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/UberRecord.h"
00011
00012 ClassImp(UberRecord)
00013
00014 CVSID("$Id: UberRecord.cxx,v 1.10 2008/03/08 06:28:31 rhatcher Exp $");
00015 using namespace std;
00016
00017
00018 UberRecord::UberRecord():
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 totmipposeven(0.),
00047 totmipposodd(0.),
00048 totmipnegeven(0.),
00049 totmipnegodd(0.),
00050 toftime(0.), torbits(0), torok(kFALSE),
00051 cpid(),
00052 nshw(0),
00053 ntrk(0),
00054
00055 shw(),
00056 trk(),
00057
00058 fhitindex(0),
00059 hitlist(0)
00060
00061
00062
00063 {
00064
00065 MSG("UberRecord",Msg::kDebug)<<"In UberRecord creator"<<endl;
00066 for(int i=0;i<CalDetConstants::KOVCONST;i++){
00067 ceradc[i]=0;
00068 certime[i]=0.;
00069 }
00070 for(int i=0;i<CalDetConstants::TOFCONST;i++){
00071 toftdc[i]=0;
00072 tofadc[i]=0;
00073 tofhittime[i]=0.;
00074 }
00075 for(int i=0;i<CalDetConstants::PLANECONST;i++){
00076 summip[i]=0.;
00077 }
00078
00079 this->Init();
00080 }
00081
00082
00083 UberRecord::UberRecord(const UberRecHeader& header):
00084 RecRecordImp<UberRecHeader>(header),
00085 snarlno(0),
00086 triggerword(0),
00087 triggertime(0.),
00088 nhits(0),
00089 nhitplanes(0),
00090 nhitstrips(0),
00091 ndeadplanes(0),
00092 mindeadplaneno(CalDetConstants::PLANECONST),
00093 sigcorrconv(0.),
00094 totmip(0.),
00095 maxadc(0),
00096 maxnpe(0.),
00097 maxmip(0.),
00098 maxtime(0.),
00099 p0totmip(0.),
00100 p1totmip(0.),
00101 p0stripmaxmip(CalDetConstants::STRIPCONST),
00102 p0maxmiptstamp(0.),
00103 p1stripmaxmip(CalDetConstants::STRIPCONST),
00104 p1maxmiptstamp(0.),
00105 mipweighaveplane(0.),
00106 mipweighcentereven(0.),
00107 mipweighcenterodd(0.),
00108 mipweighrad(0.),
00109 showermax(0),
00110 mipshowermax(0.),
00111 totmipposeven(0.),
00112 totmipposodd(0.),
00113 totmipnegeven(0.),
00114 totmipnegodd(0.),
00115 toftime(0.), torbits(0), torok(kFALSE),
00116 cpid(),
00117 nshw(0),
00118 ntrk(0),
00119
00120 shw(),
00121 trk(),
00122
00123 fhitindex(0),
00124 hitlist(0)
00125
00126
00127
00128 {
00129
00130 MSG("UberRecord",Msg::kDebug)<<"In UberRecord creator with header arg"<<endl;
00131 for(int i=0;i<CalDetConstants::KOVCONST;i++){
00132 ceradc[i]=0;
00133 certime[i]=0.;
00134 }
00135 for(int i=0;i<CalDetConstants::TOFCONST;i++){
00136 toftdc[i]=0;
00137 tofadc[i]=0;
00138 tofhittime[i]=0.;
00139 }
00140 for(int i=0;i<CalDetConstants::PLANECONST;i++){
00141 summip[i]=0.;
00142 }
00143
00144 this->Init();
00145
00146 }
00147
00148
00149 UberRecord::~UberRecord()
00150 {
00151
00152 MSG("UberRecord",Msg::kDebug)<<"In ~UberRecord"<<endl;
00153 RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00154 MSG("UberRecord",Msg::kDebug)<<"got instance"<<endl;
00155
00156 if ( hitlist ) { allocator.ReleaseArray( hitlist ); hitlist = 0; }
00157 MSG("UberRecord",Msg::kDebug)<<"In released hitlist"<<endl;
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 }
00169
00170
00171 void UberRecord::Clear(Option_t* ){
00172
00173
00174 hitlist->Clear("C");
00175 trk.Clear();
00176 shw.Clear();
00177
00178
00179
00180
00181 }
00182
00183 void UberRecord::Init()
00184 {
00185
00186 SetClearable(true);
00187
00188 MSG("UberRecord",Msg::kDebug)<<"In Init"<<endl;
00189 RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00190 MSG("UberRecord",Msg::kDebug)<<"GOT an allocator? "<<endl;
00191
00192 MSG("UberRecord",Msg::kDebug)<<"hitlist "<<hitlist<<endl;
00193 if(!hitlist){
00194 hitlist = allocator.GetArray("UberHit");
00195 MSG("UberRecord",Msg::kDebug)<<"MADE NEW HITLIST"<<endl;
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 }
00221
00222
00223 void UberRecord::ResetEvent()
00224 {
00225 MSG("UberRecord",Msg::kDebug)<<"In UberRecord ResetEvent"<<endl;
00226 hitlist->Clear();
00227 fhitindex=0;
00228
00229
00230 shw.Clear();
00231 trk.Clear();
00232
00233
00234 fhitindex=0;
00235 snarlno=0;
00236 triggerword=0;
00237 triggertime=0.;
00238 nhits=0;
00239 nhitplanes=0;
00240 nhitstrips=0;
00241 ndeadplanes=0;
00242 mindeadplaneno=CalDetConstants::PLANECONST;
00243 sigcorrconv =0.;
00244 totmip=0;
00245 maxadc=0;
00246 maxnpe=0;
00247 maxmip=0;
00248 maxtime=0;
00249 p0totmip=0;
00250 p1totmip=0;
00251 p0stripmaxmip=CalDetConstants::STRIPCONST;
00252 p0maxmiptstamp=0.;
00253 p1stripmaxmip=CalDetConstants::STRIPCONST;
00254 p1maxmiptstamp=0.;
00255 mipweighaveplane=0.;
00256 mipweighcentereven=0.;
00257 mipweighcenterodd=0.;
00258 mipweighrad=0.;
00259 showermax=0;
00260 mipshowermax = 0.;
00261 totmipposeven=0.;
00262 totmipposodd=0.;
00263 totmipnegeven=0.;
00264 totmipnegodd=0.;
00265
00266 for(int i=0;i<CalDetConstants::KOVCONST;i++){
00267 ceradc[i]=0;
00268 certime[i]=0.;
00269 }
00270 for(int i=0;i<CalDetConstants::TOFCONST;i++){
00271 toftdc[i]=0;
00272 tofadc[i]=0;
00273 tofhittime[i]=0.;
00274 }
00275 toftime=0;
00276 for(int i=0;i<CalDetConstants::PLANECONST;i++){
00277 summip[i]=0.;
00278 }
00279
00280 nshw=0;
00281 ntrk=0;
00282
00283 torbits=0; torok=0;
00284 cpid.Reset();
00285 }
00286
00287
00288 int UberRecord::AddNextHit(UShort_t p, UShort_t s)
00289 {
00290 MSG("UberRecord",Msg::kDebug)<<"In UberRecord AddNextHit"<<endl;
00291 MSG("UberRecord",Msg::kDebug)<<"value of hitlist "<<hitlist
00292 <<" value of fhitindex "<<fhitindex<<endl;
00293 new((*hitlist)[fhitindex]) UberHit();
00294 MSG("UberRecord",Msg::kDebug)<<"Made new UberHit element in TClonesArray"<<endl;
00295 UberHit *uh = static_cast<UberHit *>((*hitlist)[fhitindex]);
00296 MSG("UberRecord",Msg::kDebug)<<"Cast array element to uberhit"<<endl;
00297 int fhi = fhitindex;
00298 uh->SetPlaneStrip(p,s);
00299
00300 fhitindex++;
00301 return fhi;
00302
00303 }
00304
00305
00306 void UberRecord::AddNextHitValues(StripEnd::StripEnd_t se,
00307 Int_t adc, Float_t siglin,Float_t npe,
00308 Float_t mip, Float_t time, Int_t agg)
00309 {
00310 MSG("UberRecord",Msg::kDebug)<<"In UberRecord AddnextHitValues"<<endl;
00311 UberHit *uh = static_cast<UberHit *>((*hitlist)[fhitindex-1]);
00312 uh->AddValues(se, adc, siglin, npe, mip, time, agg);
00313 return;
00314 }
00315
00316
00317 void UberRecord::AddNextCosmicHit(UShort_t , UShort_t )
00318 {
00319
00320
00321
00322
00323
00324
00325
00326 return;
00327
00328 }
00329
00330
00331 void UberRecord::AddNextCosmicHitValues(StripEnd::StripEnd_t ,
00332 Int_t , Float_t , Int_t )
00333 {
00334
00335
00336
00337
00338
00339
00340 return;
00341 }
00342
00343
00344 void UberRecord::Print(Option_t* ) const
00345 {
00346 UberRecord::Print(std::cout);
00347 return;
00348
00349 }
00350
00351
00352
00353 std::ostream& UberRecord::Print(std::ostream& os) const
00354 {
00355 os<<"UberRecord::Print"<<endl;
00356 RecRecordImp<UberRecHeader>::Print(os);
00357
00358 int i=0;
00359 TObject *obj = 0;
00360 while((obj = hitlist->At(i))){
00361 UberHit *uh = static_cast<UberHit *>(obj);
00362 os<<"HIT "<<i<<endl;
00363 uh->Print();
00364 i++;
00365 }
00366 return os;
00367 }
00368