--- calo/flight/CaloPreSampler/src/CaloPreSampler.cpp 2009/02/24 09:18:05 1.12 +++ calo/flight/CaloPreSampler/src/CaloPreSampler.cpp 2014/01/23 11:23:54 1.19 @@ -14,6 +14,11 @@ Clear(); } +void CaloPreSampler::SetCaloLevel2Pointer(CaloLevel2 *cl2p){ + if ( pcalo ) delete pcalo; + pcalo = cl2p; +} + CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){ // L2 = l2p; @@ -36,12 +41,14 @@ sel = true; cont = false; emulate18 = true; + usepl18x = false; simulation = false; withtrk = true; rigdefault = 50.; nox = false; noy = false; forcecalo = false; + forcefitmode = -1; memset(mask,0,2*22*sizeof(Int_t)); // Clear(); @@ -71,6 +78,15 @@ // } +CaloTrkVar* CaloPreSampler::GetCaloTrack(Int_t t){ + this->Process(); + if ( t < 0 ) return pcalo->GetCaloStoredTrack(t); + if ( L2->GetTrack(t) ){ + return pcalo->GetCaloStoredTrack(L2->GetTrack(t)->GetTrkTrack()->GetSeqNo()); + }; + return NULL; +} + void CaloPreSampler::SetNoWpreSampler(Int_t n){ if ( NC+n < 23 ){ N = n; @@ -153,10 +169,20 @@ // Clear structures used to communicate with fortran // event->ClearStructs();//ELENA + if ( forcefitmode > 0 ){ + if ( forcefitmode != 1000 && forcefitmode != 1001 && forcefitmode != 1002 ){ + printf(" ERROR! forcefitmode=%i \n Use forcefitmode = 1000 for fit mode 0, 1001 fit mode 1, 1002 fit mode 3\n",forcefitmode); + forcefitmode = -1; + } else { + event->clevel2->fmode[0] = forcefitmode; + event->clevel2->fmode[1] = forcefitmode; + }; + }; // Bool_t newentry = false; // if ( L2->IsORB() ){ + if ( debug ) printf(" I am here, we have orbital infos \n"); if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || sel != ssel ){ newentry = true; OBT = L2->GetOrbitalInfo()->OBT; @@ -184,12 +210,10 @@ Bool_t st = true; Int_t ntrkentry = 0; TrkLevel2 *trk = L2->GetTrkLevel2(); - Bool_t filled = false; + // Bool_t filled = false; // if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); // - this->Clear(); - // // find out if we have trkseqno = -1, -2 or -3 // Bool_t m1 = false; @@ -202,6 +226,18 @@ }; if ( !withtrk ) m3 = true; // + // copy variables calculated during calibration process which is skipped here... this has been moved before this->Clear() for reprocessing purpose + // + event->clevel2->good = L2->GetCaloLevel2()->good; + memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); + memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); + memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); + event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; + // + // + this->Clear(); // moved after all calls to L2->GetCaloLevel2() since pcalo could be the same as L2->GetCaloLevel2() !!! + // + // if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n"); // // Fill the estrip matrix @@ -215,6 +251,8 @@ // mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip); // + if ( !usepl18x && view==0 && plane==18 ) mip = 0.; + // // Mask x or y view if nox and/or noy are true (default false) // if ( mask[view][plane] ) mip = 0.; @@ -307,13 +345,13 @@ // event->clevel1->good2 = 1; // - // copy variables calculated during calibration process which is skipped here... + // copy variables calculated during calibration process which is skipped here... this has to be moved before this->Clear() for reprocessing purpose // - event->clevel2->good = L2->GetCaloLevel2()->good; - memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); - memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); - memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); - event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; +// event->clevel2->good = L2->GetCaloLevel2()->good; +// memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr)); +// memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr)); +// memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc)); +// event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger; // // Calculate variables common to all tracks (qtot, nstrip, etc.) // @@ -329,7 +367,7 @@ // ntrkentry = 0; // - filled = false; + // filled = false; // // Run over tracks (tracker or calorimeter ) // @@ -366,7 +404,7 @@ ntrkentry++; - filled = true; + // filled = true; // }; // loop on all the tracks }; @@ -411,7 +449,7 @@ if ( debug ) printf("-3 a Call FillTrkVar() \n"); event->FillTrkVar(pcalo,ntrkentry); ntrkentry++; - filled = true; + // filled = true; // } else { if ( debug ) printf(" Selftrigger: problems with event \n"); @@ -458,7 +496,7 @@ if ( debug ) printf("-2 a Call FillTrkVar() \n"); event->FillTrkVar(pcalo,ntrkentry); ntrkentry++; - filled = true; + // filled = true; // } else { if ( debug ) printf(" Selftrigger: problems with event \n"); @@ -504,7 +542,7 @@ if ( debug ) printf("-1 a Call FillTrkVar() \n"); event->FillTrkVar(pcalo,ntrkentry); ntrkentry++; - filled = true; + // filled = true; // } else { if ( debug ) printf(" Selftrigger: problems with event \n");