00001
00002
00003
00004
00005
00006
00007
00008
00009
00011 #include <MCMerge/ConcatArrays.h>
00012
00013 #ifdef EVENT_KINEMATICS_PKGS
00014 #include <EventKinematics/NuEvtKin.h>
00015 #include <EventKinematics/StdHepUtil.h>
00016 using namespace StdHepUtil;
00017 #endif
00018
00019 #include <Digitization/DigiScintHit.h>
00020 #include <REROOT_Classes/REROOT_StdHep.h>
00021 #include <REROOT_Classes/REROOT_StdHepHead.h>
00022 #include <REROOT_Classes/REROOT_NeuKin.h>
00023 #include <REROOT_Classes/REROOT_FluxInfo.h>
00024 #include <REROOT_Classes/REROOT_FluxWgt.h>
00025 #include "TParticle.h"
00026 #include "TMath.h"
00027
00028 #include "Riostream.h"
00029 #include "TClass.h"
00030
00031
00032
00033
00034 void ConcatArrays::ConcatDigiScintHits(TClonesArray* addList,
00035 TClonesArray* permList,
00036 Int_t permStdHepSz) {
00037
00038
00039
00040 if (!addList || !permList) return;
00041
00042 const Int_t oldSize = permList->GetEntriesFast();
00043 const Int_t newSize = oldSize + addList->GetEntriesFast();
00044
00045 for (Int_t i = oldSize; i < newSize; i++) {
00046 DigiScintHit* tempHit =
00047 dynamic_cast<DigiScintHit*>(addList->At(i-oldSize));
00048
00049 if (tempHit) {
00050 Int_t oldId = tempHit->TrackId();
00051 Int_t newId = (oldId < 0)? oldId - permStdHepSz : oldId + permStdHepSz ;
00052 tempHit->SetTrackId( newId );
00053
00054 new( (*permList)[i] ) DigiScintHit( *tempHit );
00055 }
00056 }
00057
00058 }
00059
00060 void ConcatArrays::ConcatFluxInfo(TClonesArray* addList,
00061 TClonesArray* permList){
00062
00063
00064 if (!addList || !permList) return;
00065
00066 const Int_t oldSize = permList->GetEntriesFast();
00067 const Int_t newSize = oldSize + addList->GetEntriesFast();
00068
00069 for (Int_t i = oldSize; i < newSize; i++)
00070 new( (*permList)[i] ) REROOT_FluxInfo( *dynamic_cast<REROOT_FluxInfo*>(addList->At(i-oldSize)) );
00071
00072 }
00073
00074 void ConcatArrays::ConcatFluxWgt(TClonesArray* addList,
00075 TClonesArray* permList){
00076
00077
00078 if (!addList || !permList) return;
00079
00080 const Int_t oldSize = permList->GetEntriesFast();
00081 const Int_t newSize = oldSize + addList->GetEntriesFast();
00082
00083 for (Int_t i = oldSize; i < newSize; i++)
00084 new( (*permList)[i] ) REROOT_FluxWgt( *dynamic_cast<REROOT_FluxWgt*>(addList->At(i-oldSize)) );
00085
00086 }
00087
00088 void ConcatArrays::ConcatNuEvtKin(TClonesArray* addList,
00089 TClonesArray* permList,
00090 TClonesArray* stdhepList){
00091
00092
00093 if (!addList || !permList || !stdhepList) return;
00094
00095 #ifdef EVENT_KINEMATICS_PKGS
00096 const Int_t oldSize = permList->GetEntriesFast();
00097 const Int_t newSize = oldSize + addList->GetEntriesFast();
00098
00099 for (Int_t i = oldSize; i < newSize; i++)
00100 new( (*permList)[i] ) NuEvtKin( *dynamic_cast<NuEvtKin*>(addList->At(i-oldSize)) );
00101
00102 #endif
00103
00104 }
00105
00106 void ConcatArrays::ConcatNuKin(TClonesArray* addList,
00107 TClonesArray* permList){
00108
00109
00110 if (!addList || !permList) return;
00111
00112 const Int_t oldSize = permList->GetEntriesFast();
00113 const Int_t newSize = oldSize + addList->GetEntriesFast();
00114
00115 for (Int_t i = oldSize; i < newSize; i++)
00116 new( (*permList)[i] ) REROOT_NeuKin( *dynamic_cast<REROOT_NeuKin*>(addList->At(i-oldSize)) );
00117
00118 }
00119
00120 void ConcatArrays::ConcatStdHep(TClonesArray* addList,
00121 TClonesArray* permList) {
00122
00123
00124
00125
00126
00127
00128 if (!addList || !permList ) return;
00129
00130 const Int_t oldSize = permList->GetEntriesFast();
00131 const Int_t newSize = oldSize + addList->GetEntriesFast();
00132
00133 for (Int_t i = oldSize; i < newSize; i++) {
00134 TParticle* thisPart = new( (*permList)[i] ) TParticle( *dynamic_cast<TParticle*>(addList->At(i-oldSize)) );
00135
00136 if ( thisPart ) {
00137
00138 for (Int_t j = 0; j < 2; j++) {
00139 if (thisPart->GetMother(j) >= 0)
00140 thisPart->SetMother( j, thisPart->GetMother(j) + oldSize );
00141 if (thisPart->GetDaughter(j) >= 0)
00142 thisPart->SetDaughter(j, thisPart->GetDaughter(j) + oldSize );
00143 }
00144 }
00145 }
00146
00147 }
00148
00149
00150
00151 void ConcatArrays::OffsetTime(TClonesArray* tcarr, Float_t offsetns){
00152
00153 if ( !tcarr ) {
00154 return;
00155 }
00156
00157
00158 if ( tcarr->GetClass()->InheritsFrom("DigiScintHit") ) {
00159
00160 UInt_t tempSize = tcarr->GetEntriesFast();
00161
00162 for ( UInt_t i = 0; i < tempSize ; i++) {
00163 DigiScintHit* tempHit = dynamic_cast<DigiScintHit*>(tcarr->At(i));
00164
00165 Float_t newT1 = tempHit->T1() + offsetns*1.e-9;
00166 Float_t newT2 = tempHit->T2() + offsetns*1.e-9;
00167
00168 tempHit->SetT1(newT1);
00169 tempHit->SetT2(newT2);
00170 }
00171
00172 return;
00173 }
00174
00175
00176 if ( tcarr->GetClass()->InheritsFrom("TParticle") ) {
00177 for ( Int_t i = 0; i < tcarr->GetEntriesFast() ; i++) {
00178 TParticle* oldPart = dynamic_cast<TParticle*>(tcarr->At(i));
00179 oldPart->SetProductionVertex(oldPart->Vx(), oldPart->Vy(),
00180 oldPart->Vz(), oldPart->T()+offsetns*1.e-9);
00181 }
00182 return;
00183 }
00184
00185
00186 if ( ( tcarr->GetClass()->InheritsFrom("REROOT_NeuKin" ) ||
00187 tcarr->GetClass()->InheritsFrom("NeuKin" ) ) ||
00188 ( tcarr->GetClass()->InheritsFrom("NuEvtKin" ) ) ||
00189 ( tcarr->GetClass()->InheritsFrom("REROOT_FluxInfo") ||
00190 tcarr->GetClass()->InheritsFrom("FluxInfo" ) ) ||
00191 ( tcarr->GetClass()->InheritsFrom("REROOT_FluxWgt" ) ||
00192 tcarr->GetClass()->InheritsFrom("FluxWgt" ) ) ) {
00193
00194 return;
00195 }
00196
00197
00198
00199 cout << "=E= ConcatArrays: "
00200 << std::string(tcarr->At(0)->ClassName())
00201 << " is not a recognized SimSnarlRecord component: "
00202 << "this should really *never ever* happen, so you "
00203 << "probably broke something!"
00204 << endl;
00205
00206 }
00207
00208