--- calo/flight/CaloPreSampler/src/CaloPreSampler.cpp 2008/04/07 13:51:52 1.9 +++ calo/flight/CaloPreSampler/src/CaloPreSampler.cpp 2010/03/10 12:11:11 1.17 @@ -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; @@ -95,6 +111,18 @@ }; } +void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){ + this->SetNoWcalo(0); + this->SetNoWpreSampler(0); + if ( NoWpreSampler < NoWcalo ){ + this->SetNoWpreSampler(NoWpreSampler); + this->SetNoWcalo(NoWcalo); + } else { + this->SetNoWcalo(NoWcalo); + this->SetNoWpreSampler(NoWpreSampler); + }; +} + void CaloPreSampler::Clear(){ // pcalo->Clear(); @@ -138,9 +166,23 @@ return; }; // + // 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; @@ -199,12 +241,16 @@ // 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.; if ( nox && view == 0 ) mip = 0.; if ( noy && view == 1 ) mip = 0.; // + if ( emulate18 && view == 0 && plane == 18 ) mip = 0.; + // // Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19 // included so plane < (22 - 2) // @@ -492,10 +538,11 @@ if ( debug ) printf(" Selftrigger: problems with event \n"); }; }; - // - // Clear structures used to communicate with fortran - // - event->ClearStructs(); +// // +// // Clear structures used to communicate with fortran +// // +// event->ClearStructs(); +// ELENA: moved @ beginning // // // @@ -503,3 +550,50 @@ if ( debug ) printf(" exit \n"); // } + +// +// Method to add a calorimeter track, evaluated around a tracker track defined by a status vector. +// (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection ) +// +// +CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){ + + int ntrkentry = pcalo->ntrk(); + // + for (Int_t nt=0; nt < ntrkentry; nt++){ + if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){ + cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"< trktag = "<clevel1->good2 = 1; //is a trk track + event->clevel1->trkchi2 = 0; + event->clevel1->hzn = 0; + // + // Copy the alpha vector in the input structure + // + for (Int_t e = 0; e < 5 ; e++){ + event->clevel1->al_p[e][0] = al[e]; + }; + // + // Get tracker related variables for this track + // + if ( debug ) printf("track %i Call GetTrkVar() \n",trktag); + event->GetTrkVar(); + if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l); + // + // Save tracker track sequence number + // + event->trkseqno = trktag; + // + // Copy values in the class ca from the structure clevel2 + // + if ( debug ) printf("track %i Call FillTrkVar() \n",trktag); + event->FillTrkVar(pcalo,ntrkentry); + + return pcalo->GetCaloTrkVar(ntrkentry); + + +};//ELENA