Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

UberRecord.cxx

Go to the documentation of this file.
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 //  nevt(0),
00055   shw(),
00056   trk(),
00057 //  evt(),
00058   fhitindex(0),
00059   hitlist(0)
00060 
00061 //  fcoshitindex(0),
00062 //  coshitlist(0)
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 }//end UberRecord()
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 //  nevt(0),
00120   shw(),
00121   trk(),
00122 //  evt(),
00123   fhitindex(0),
00124   hitlist(0)
00125 //  fcoshitindex(0),
00126 //  coshitlist(0)
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 }//end UberRecord(const UberRecHeader& header)
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    // Allocated memory is retrieved via object Clear call
00156    if ( hitlist ) { allocator.ReleaseArray( hitlist ); hitlist = 0; }
00157    MSG("UberRecord",Msg::kDebug)<<"In released hitlist"<<endl;
00158 //   if ( coshitlist ) { allocator.ReleaseArray( coshitlist ); coshitlist = 0; }
00159 //   MSG("UberRecord",Msg::kDebug)<<"In released coshitlist"<<endl;
00160 //   if ( shw ) { allocator.ReleaseArray( shw ); shw = 0; }
00161 //   MSG("UberRecord",Msg::kDebug)<<"In released shw"<<endl;
00162 //   if ( trk ) { allocator.ReleaseArray( trk ); trk = 0; }
00163 //   MSG("UberRecord",Msg::kDebug)<<"In released trk"<<endl;
00164 //   if ( evt ) { allocator.ReleaseArray( evt ); evt = 0; }
00165 //   MSG("UberRecord",Msg::kDebug)<<"In released evt"<<endl;
00166    
00167    
00168 }//end ~UberRecord()
00169 //________________________________________________________________________________
00170 
00171 void UberRecord::Clear(Option_t* /* option */){
00172 //  std::cout<<"UberRecord::Clear()"<<std::endl;
00173   // Function added MAK - Feb 28, 2005  
00174   hitlist->Clear("C");
00175   trk.Clear();
00176   shw.Clear();
00177   //
00178   //  RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00179   //  allocator.Print(std::cout);
00180   //  evt.Clear();
00181 }
00182 
00183 void UberRecord::Init()
00184 {
00185   // Added MAK - Feb 28, 2005
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    if(!coshitlist){
00202       coshitlist = allocator.GetArray("UberCosmicHit");
00203       MSG("UberRecord",Msg::kDebug)<<"MADE NEW COSHITLIST"<<endl;
00204    }
00205 
00206    if(!shw){
00207       shw = allocator.GetArray("NtpSRShower");
00208       MSG("UberRecord",Msg::kDebug)<<"MADE NEW SHW"<<endl;
00209    }   
00210    if(!trk){
00211       trk = allocator.GetArray("NtpSRTrack");
00212       MSG("UberRecord",Msg::kDebug)<<"MADE NEW TRK"<<endl;
00213    }  
00214    if(!evt){
00215       evt = allocator.GetArray("NtpSREvent");
00216       MSG("UberRecord",Msg::kDebug)<<"MADE NEW EVT"<<endl;
00217    }
00218 */
00219 //   hitlist->Print();
00220 }//end Init()
00221 //________________________________________________________________________________
00222 
00223 void UberRecord::ResetEvent()
00224 {
00225   MSG("UberRecord",Msg::kDebug)<<"In UberRecord ResetEvent"<<endl;
00226   hitlist->Clear();
00227   fhitindex=0;
00228 //  coshitlist->Clear();
00229 //  fcoshitindex=0;
00230   shw.Clear();
00231   trk.Clear();
00232 //  evt.Clear();
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 //  nevt=0;
00283   torbits=0; torok=0;
00284   cpid.Reset();
00285 }//end ResetEvent()
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 //  uh->Print();
00300   fhitindex++;
00301   return fhi;
00302 
00303 }//end AddNextHit()
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 }//end AddNextHitValues()
00315 //________________________________________________________________________________
00316 
00317 void UberRecord::AddNextCosmicHit(UShort_t /*p*/, UShort_t /*s*/)
00318 {
00319 /*does nothing nowadays
00320   MSG("UberRecord",Msg::kDebug)<<"In UberRecord AddNextHit"<<endl;
00321   new((*coshitlist)[fcoshitindex]) UberCosmicHit();
00322   UberCosmicHit *uch = static_cast<UberCosmicHit *>((*coshitlist)[fcoshitindex]);
00323   uch->SetPlaneStrip(p,s);
00324   fcoshitindex++;
00325 */
00326   return;
00327 
00328 }//end AddNextCosmicHit()
00329 //________________________________________________________________________________
00330 
00331 void UberRecord::AddNextCosmicHitValues(StripEnd::StripEnd_t /*se*/,
00332                                         Int_t /*adc*/, Float_t /*time*/, Int_t /*agg*/)
00333 {
00334 
00335 /*Does nothing nowadays
00336   MSG("UberRecord",Msg::kDebug)<<"In UberRecord AddnextCosmicHitValues"<<endl;
00337   UberCosmicHit *uch = static_cast<UberCosmicHit *>((*coshitlist)[fcoshitindex-1]);
00338   uch->AddValues(se, adc, time, agg);
00339 */
00340   return;
00341 }//end AddNextCosmicHitValues()
00342 //________________________________________________________________________________
00343 
00344 void UberRecord::Print(Option_t* /* option */) 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 }//end Print()
00368 //________________________________________________________________________________

Generated on Mon Feb 15 11:07:48 2010 for loon by  doxygen 1.3.9.1