00001
00002
00003
00004
00005
00006
00008
00009 #include <iostream>
00010 using namespace std;
00011
00012 #include "TClonesArray.h"
00013 #include "Record/RecArrayAllocator.h"
00014 #include "CandNtupleSR/NtpSRRecord.h"
00015 #include "CandNtupleSR/NtpSRSlice.h"
00016 #include "CandNtupleSR/NtpSRCluster.h"
00017 #include "CandNtupleSR/NtpSRShower.h"
00018 #include "CandNtupleSR/NtpSRTrack.h"
00019 #include "CandNtupleSR/NtpSREvent.h"
00020 #include "CandNtupleSR/NtpSRDeadChip.h"
00021 #include "MessageService/MsgService.h"
00022
00023 CVSID("$Id: NtpSRRecord.cxx,v 1.14 2006/06/30 22:01:19 blake Exp $");
00024
00025 ClassImp(NtpSRRecord)
00026
00027 NtpSRRecord::NtpSRRecord() : RecRecordImp<RecCandHeader>(),deadchips(0),vetostp(0),vetoexp(0),stp(0),
00028 slc(0),clu(0),shw(0),trk(0),evt(0) {
00029
00030
00031 MSG("NtpSR",Msg::kVerbose) << "NtpSRRecord def ctor at " << this << endl;
00032 this -> Init();
00033 }
00034
00035 NtpSRRecord::NtpSRRecord(const RecCandHeader& hdr) :
00036 RecRecordImp<RecCandHeader>(hdr),deadchips(0),vetostp(0),vetoexp(0),stp(0),slc(0),clu(0),shw(0),trk(0),
00037 evt(0) {
00038
00039
00040 MSG("NtpSR",Msg::kVerbose) << "NtpSRRecord normal ctor at " << this << endl;
00041 this -> Init();
00042 }
00043
00044 NtpSRRecord::~NtpSRRecord() {
00045
00046
00047 MSG("NtpSR",Msg::kVerbose) << "NtpSRRecord dtor at " << this << endl;
00048
00049
00050 RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00051 if ( deadchips ){ allocator.ReleaseArray(deadchips); deadchips = 0; }
00052 if ( vetostp ) { allocator.ReleaseArray(vetostp); vetostp = 0; }
00053 if ( vetoexp ) { allocator.ReleaseArray(vetoexp); vetoexp = 0; }
00054 if ( stp ) { allocator.ReleaseArray(stp); stp = 0; }
00055 if ( slc ) { allocator.ReleaseArray(slc); slc = 0; }
00056 if ( clu ) { allocator.ReleaseArray(clu); clu = 0; }
00057 if ( shw ) { allocator.ReleaseArray(shw); shw = 0; }
00058 if ( trk ) { allocator.ReleaseArray(trk); trk = 0; }
00059 if ( evt ) { allocator.ReleaseArray(evt); evt = 0; }
00060
00061 }
00062
00063 void NtpSRRecord::Clear(Option_t* ) {
00064
00065
00066
00067 if ( deadchips ) { deadchips->Clear("C"); }
00068 if ( vetostp ) { vetostp -> Clear("C"); }
00069 if ( vetoexp ) { vetoexp -> Clear("C"); }
00070 if ( stp ) { stp -> Clear("C"); }
00071 if ( slc ) { slc -> Clear("C"); }
00072 if ( clu ) { clu -> Clear("C"); }
00073 if ( shw ) { shw -> Clear("C"); }
00074 if ( trk ) { trk -> Clear("C"); }
00075 if ( evt ) { evt -> Clear("C"); }
00076
00077 }
00078
00079 void NtpSRRecord::ClearStrips(Option_t* ) {
00080
00081
00082 if ( vetostp ) { vetostp -> Clear("C"); }
00083 if ( vetoexp ) { vetoexp -> Clear("C"); }
00084 if ( stp ) { stp -> Clear("C"); }
00085
00086 if ( slc ) {
00087 TClonesArray& slicearray = *(slc);
00088 for ( int islc = 0; islc <= slicearray.GetLast(); islc++ ) {
00089 NtpSRSlice* ntpslice = dynamic_cast<NtpSRSlice*>(slicearray.At(islc));
00090 ntpslice -> ClearStrips();
00091 }
00092 }
00093
00094 if( clu ) {
00095 TClonesArray& clusterarray = *(clu);
00096 for ( int iclu = 0; iclu <= clusterarray.GetLast(); iclu++ ) {
00097 NtpSRCluster* ntpcluster =
00098 dynamic_cast<NtpSRCluster*>(clusterarray.At(iclu));
00099 ntpcluster->ClearStrips();
00100 }
00101 }
00102
00103 if ( shw ) {
00104 TClonesArray& showerarray = *(shw);
00105 for ( int ishw = 0; ishw <= showerarray.GetLast(); ishw++ ) {
00106 NtpSRShower* ntpshower=dynamic_cast<NtpSRShower*>(showerarray.At(ishw));
00107 ntpshower -> ClearStrips();
00108 }
00109 }
00110
00111 if ( trk ) {
00112 TClonesArray& trackarray = *(trk);
00113 for ( int itrk = 0; itrk <= trackarray.GetLast(); itrk++ ) {
00114 NtpSRTrack* ntptrack=dynamic_cast<NtpSRTrack*>(trackarray.At(itrk));
00115 ntptrack -> ClearStrips();
00116 }
00117 }
00118
00119 if ( evt ) {
00120 TClonesArray& eventarray = *(evt);
00121 for ( int ievt = 0; ievt <= eventarray.GetLast(); ievt++ ) {
00122 NtpSREvent* ntpevent=dynamic_cast<NtpSREvent*>(eventarray.At(ievt));
00123 ntpevent -> ClearStrips();
00124 }
00125 }
00126 }
00127
00128 void NtpSRRecord::Init() {
00129
00130
00131
00132
00133
00134
00135 SetClearable(true);
00136
00137 RecArrayAllocator& allocator = RecArrayAllocator::Instance();
00138 if ( !deadchips ) deadchips = allocator.GetArray("NtpSRDeadChip");
00139 if ( !vetostp ) vetostp = allocator.GetArray("NtpSRShieldStrip");
00140 if ( !vetoexp ) vetoexp = allocator.GetArray("NtpSRShieldExpected");
00141 if ( !stp ) stp = allocator.GetArray("NtpSRStrip");
00142 if ( !slc ) slc = allocator.GetArray("NtpSRSlice");
00143 if ( !clu ) clu = allocator.GetArray("NtpSRCluster");
00144 if ( !shw ) shw = allocator.GetArray("NtpSRShower");
00145 if ( !trk ) trk = allocator.GetArray("NtpSRTrack");
00146 if ( !evt ) evt = allocator.GetArray("NtpSREvent");
00147
00148 }
00149
00150 std::ostream& NtpSRRecord::Print(std::ostream& os) const {
00151
00152
00153
00154
00155 os << "NtpSRRecord::Print" << endl;
00156 RecRecordImp<RecCandHeader>::Print(os);
00157
00158 evthdr.Print(os);
00159
00160 if ( slc ) {
00161 TClonesArray& slicearray = *(slc);
00162 for ( int islc = 0; islc <= slicearray.GetLast(); islc++ ) {
00163 NtpSRSlice* ntpslice = dynamic_cast<NtpSRSlice*>(slicearray.At(islc));
00164 ntpslice -> Print(os);
00165 }
00166 }
00167
00168 if ( shw ) {
00169 TClonesArray& showerarray = *(shw);
00170 for ( int ishw = 0; ishw <= showerarray.GetLast(); ishw++ ) {
00171 NtpSRShower* ntpshower=dynamic_cast<NtpSRShower*>(showerarray.At(ishw));
00172 ntpshower -> Print(os);
00173 }
00174 }
00175
00176 if ( trk ) {
00177 TClonesArray& trackarray = *(trk);
00178 for ( int itrk = 0; itrk <= trackarray.GetLast(); itrk++ ) {
00179 NtpSRTrack* ntptrack=dynamic_cast<NtpSRTrack*>(trackarray.At(itrk));
00180 ntptrack -> Print(os);
00181 }
00182 }
00183
00184 if ( evt ) {
00185 TClonesArray& eventarray = *(evt);
00186 for ( int ievt = 0; ievt <= eventarray.GetLast(); ievt++ ) {
00187 NtpSREvent* ntpevent=dynamic_cast<NtpSREvent*>(eventarray.At(ievt));
00188 ntpevent -> Print(os);
00189 }
00190 }
00191
00192 return os;
00193
00194 }
00195
00196 void NtpSRRecord::Print(Option_t* ) const {
00197
00198
00199
00200
00201 Print(std::cout);
00202 return;
00203
00204 }
00205
00206
00207
00208