--- PamelaLevel2/src/PamLevel2.cpp 2007/08/17 16:57:12 1.43 +++ PamelaLevel2/src/PamLevel2.cpp 2007/09/12 09:51:57 1.48 @@ -11,6 +11,8 @@ calo_track = 0; tof_track = 0; candeleteobj = 0; + pscore = 0; + iscore = 0; }; //-------------------------------------- // @@ -60,6 +62,9 @@ calo_track = 0; tof_track = 0; } + pscore = 0; + iscore = 0; + } void PamTrack::Delete(){ // cout << "PamTrack::Delete() "<HasImage()){ ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) @@ -695,8 +725,8 @@ // cout << "its image "<npcfit[1] > 5 && //no. of fit planes on Y view @@ -722,9 +760,14 @@ // else ti_score++; - if( cp->npresh > ci->npresh) tp_score++; - if( cp->npresh < ci->npresh) ti_score++; - else ;//niente + if( cp->npresh > ci->npresh){ + tp_score++; + totp_score++; + }; + if( cp->npresh < ci->npresh){ + ti_score++; + toti_score++; + }; // cout << "CALO "<npmtadc; ih++){ @@ -751,7 +802,7 @@ if ( pl == 2 || pl == 3 || pl == 4 || pl == 5 ) sen += (oi->dedx).At(ih); }; // - if ( sen >= sortthr ){ + if ( sen >= sortthr && false){ // temporary disabled NUCLEI special algorithm since the new one should work for every particle (to be checked!) //printf(" IS A NUCLEUS! en = %f \n",sen); // // is a nucleus use a different algorithm @@ -844,7 +895,7 @@ if( - use_TOF && + (use_TOF || use_S1 || use_S2 || use_S3) && (nphit_p+nphit_i) !=0 && true){ @@ -891,22 +942,32 @@ for (Int_t ih=0; ih < op->npmttdc; ih++){ Int_t pl = tof_obj->GetPlaneIndex( (op->pmttdc).At(ih) ); // if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; - if( (op->tdcflag).At(ih)==0 )nphit_p++; + if ( (use_S1 && ( pl == 0 || pl == 1 )) || (use_S2 && ( pl == 2 || pl == 3 )) || (use_S3 && ( pl == 4 || pl == 5 )) ){ + if( (op->tdcflag).At(ih)==0 )nphit_p++; + }; }; for (Int_t ih=0; ih < oi->npmttdc; ih++){ Int_t pl = tof_obj->GetPlaneIndex( (oi->pmttdc).At(ih) ); // if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; - if( (oi->tdcflag).At(ih)==0 )nphit_i++; + if ( (use_S1 && ( pl == 0 || pl == 1 )) || (use_S2 && ( pl == 2 || pl == 3 )) || (use_S3 && ( pl == 4 || pl == 5 )) ){ + if( (oi->tdcflag).At(ih)==0 )nphit_i++; + }; }; if( (nphit_p+nphit_i) !=0 && true){ - if ( nphit_p > nphit_i) tp_score++; - else if( nphit_p < nphit_i) ti_score++; - else ;//niente + if ( nphit_p != nphit_i ){ + totp_score += nphit_p; + toti_score += nphit_i; + tp_score+=nphit_p; + ti_score+=nphit_i; + }; + // if ( nphit_p > nphit_i) tp_score+=nphit_p; + // else if( nphit_p < nphit_i) ti_score+=nphit_i; + // else ;//niente }; }; // cout << "TOF "<chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; // CHECK 1 : number of points along X - if ( tp->GetNX() >= ti->GetNX() )tp_score++ ; - if ( tp->GetNX() <= ti->GetNX() )ti_score++ ; + if ( tp->GetNX() >= ti->GetNX() ){ + tp_score++ ; + totp_score++ ; + }; + if ( tp->GetNX() <= ti->GetNX() ){ + ti_score++ ; + toti_score++ ; + }; // CHECK 2 : number of points along Y - if ( tp->GetNY() >= ti->GetNY() )tp_score++ ; - if ( tp->GetNY() <= ti->GetNY() )ti_score++ ; + if ( tp->GetNY() >= ti->GetNY() ){ + tp_score++ ; + totp_score++ ; + }; + if ( tp->GetNY() <= ti->GetNY() ){ + ti_score++ ; + toti_score++ ; + }; // CHECK 3 : chi**2 along X // if( tp->GetChi2X() > 0 && (tp->GetChi2X() < ti->GetChi2X() || ti->GetChi2X() <=0) ) tp_score++ ; // if( ti->GetChi2X() > 0 && (ti->GetChi2X() < tp->GetChi2X() || tp->GetChi2X() <=0) ) ti_score++ ; @@ -960,6 +1033,7 @@ ts = ti;//its image!! cs = ci; os = oi; + Int_t totis = toti_score; ti = tp;//its image!! ci = cp; @@ -969,6 +1043,9 @@ cp = cs; op = os; + toti_score = totp_score; + totp_score = totis; + }else { @@ -977,6 +1054,9 @@ }; }else{ + totp_score = 1; + toti_score = 0; + // ts = tp; // cs = cp; // os = op; @@ -990,8 +1070,14 @@ // cout<<"o "<SetPScore(totp_score); + ((PamTrack*)(ttsorted[i]))->SetIScore(toti_score); + ((PamTrack*)(ttimage[i]))->SetPScore(totp_score); + ((PamTrack*)(ttimage[i]))->SetIScore(toti_score); }; if( tsorted->GetEntries() != trk2_obj->GetNTracks() ){ @@ -1980,7 +2066,7 @@ !(abstime >= GetRunInfo()->RUNHEADER_TIME && abstime <= GetRunInfo()->RUNTRAILER_TIME) ) { - printf(" Something very wrong here: cannot find RUN containing absolute time %u \n",abstime); + printf(" Something very wrong here: cannot find RUN containing absolute time %llu \n",abstime); return false; } // @@ -2031,6 +2117,20 @@ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- if(SELLI==0){ + // --------------------------------------------------------------- + // increment dead and live-time counters + // --------------------------------------------------------------- + if( GetTrigLevel2() ){ + totdltime[0]+=GetTrigLevel2()->dltime[0]; + totdltime[1]+=GetTrigLevel2()->dltime[1]; + } + totdltime[2]++; + +// cout << setw(10)<RUNHEADER_TIME; // BARBATRUCCO @@ -2090,6 +2190,43 @@ ) && irun < run_tree->GetEntries() ){ + + + + // ----------------------------------------- + // store dead and live-time of previous run + // ----------------------------------------- + if(fromfirst){ + if(oldrun==irun){ + /// decrement counters + if( GetTrigLevel2()){ + totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time + totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time + } + totdltime[2]--; //event counter + cout << endl; + cout << "n.events : "<GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) + run_tree_clone->GetBranch("DeadLiveTime")->Fill(); + /// reset counters + if( GetTrigLevel2() ){ + totdltime[0]=GetTrigLevel2()->dltime[0];//live-time + totdltime[1]=0; //dead-time + } + totdltime[2]=1; //event counter + } + + irun++; // ------------------------------------ // if the end of run tree is reached... @@ -2117,7 +2254,7 @@ // ------------------------------------------------------------------- if(irun>0)runfirstentry += (GetRunInfo()->NEVENTS)-prevshift; irunentry = 0; - prevshift = 0; + prevshift = 0; run_tree->GetEntry(irun); if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){ cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<=RUNTRAILER_OBT " <1){ +// ULong64_t temp[3]; +// temp[0]=totdltime[0]; +// temp[1]=totdltime[1]; +// temp[2]=totdltime[2]; +// for(int i=oldrun+1; iGetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) +// run_tree_clone->GetBranch("DeadLiveTime")->Fill(); +// } +// totdltime[0]=temp[0]; +// totdltime[1]=temp[1]; +// totdltime[2]=temp[2]; +// } +// /// decrement counters +// if( GetTrigLevel2() ){ +// totdltime[0]-=GetTrigLevel2()->dltime[0];//live-time +// totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time +// } +// totdltime[2]--; //event counter +// /// add an entry +// if(irun>0 ){ +// cout << endl; +// cout << "n.events : "<GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) +// run_tree_clone->GetBranch("DeadLiveTime")->Fill(); +// } +// /// reset counters +// if( GetTrigLevel2() ){ +// totdltime[0]=GetTrigLevel2()->dltime[0];//live-time +// totdltime[1]=0; //dead-time +// } +// totdltime[2]=1; //event counter + + + // -------------------------------------- // ---> exit with TRUE // -------------------------------------- cout << endl << " ))))) UPDATE RUN INFO ((((( @iev "<ID<<" irun "<Branch("DeadLiveTime",totdltime,"dltime[3]/l"); + cout << "Run : branch DeadLiveTime"<Branch("RunEntry",&irun,"runentry/L"); @@ -2957,7 +3154,9 @@ void PamLevel2::WriteCloneTrees(){ cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <GetName()<GetName()<GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) + run_tree_clone->GetBranch("DeadLiveTime")->Fill(); run_tree_clone->Write(); cout << sel_tree_clone->GetName()<Write(); @@ -3297,3 +3496,36 @@ return true; } + +/** + * \Brief Add a friend to the pamela chain. + * @param cname name of the chain to be added + */ + +TChain* PamLevel2::AddFriend(TString cname){ + + if(!GetPamTree()){ + cout << " TChain* PamLevel2::AddFriend(TString cname) --- a pamela tree must be created first"<GetListOfFiles() ); + Int_t nf = 0; + TChainElement* element = 0; + while ((element = (TChainElement*) next())) { + c->Add(element->GetTitle()); + nf++; + } + + GetPamTree()->AddFriend(cname.Data()); + + cout << "external chain created and added to pamela friends :"<