--- PamelaLevel2/src/PamLevel2.cpp 2008/12/10 11:56:35 1.70 +++ PamelaLevel2/src/PamLevel2.cpp 2009/03/25 14:42:36 1.80 @@ -308,8 +308,9 @@ if(t)trk_track = t; if(c)calo_track = c; if(o)tof_track = o; - if(r)orb_track = r; - candeleteobj = 0; + if(r) orb_track = r; + + candeleteobj = 0; }; PamTrack::PamTrack(const PamTrack& track){ @@ -396,17 +397,17 @@ * If no options are specified, the default is assumed. Default is: * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB */ -PamLevel2::PamLevel2(TString ddir,TString list,TString detlist){ +PamLevel2::PamLevel2(TString ddir,TString llist,TString detlist){ Initialize(); - TList* listf = GetListOfLevel2Files(ddir,list); - GetPamTree(listf,detlist); - GetRunTree(listf); + TList* listf = GetListOfLevel2Files(ddir,llist); + if(listf)GetPamTree(listf,detlist); + if(listf)GetRunTree(listf); }; -PamLevel2::PamLevel2(TString ddir,TList *list,TString detlist){ +PamLevel2::PamLevel2(TString ddir,TList *llist,TString detlist){ Initialize(); - GetPamTree(list,detlist); - GetRunTree(list); + GetPamTree(llist,detlist); + GetRunTree(llist); }; /** * Constructor @@ -415,9 +416,9 @@ * Default trees/branches are loaded. Default is: * +TRK2+CAL2+CAL1+TOF+TRG+ND+AC+S4+ORB */ -PamLevel2::PamLevel2(TString ddir,TString list){ +PamLevel2::PamLevel2(TString ddir,TString llist){ Initialize(); - TList* listf = GetListOfLevel2Files(ddir,list); + TList* listf = GetListOfLevel2Files(ddir,llist); GetPamTree(listf,""); GetRunTree(listf); }; @@ -448,6 +449,7 @@ irunt = -1LL; runfirstentry = 0LL; runlastentry = 0LL; + gltsync = 0; // Emiliano l0_file = NULL; l0_tree = NULL; @@ -557,6 +559,8 @@ dbc->Close(); delete dbc; } + + if ( gltsync ) delete gltsync; if(l0_file)l0_file->Close(); // if(pam_tree)pam_tree->Delete();; @@ -736,11 +740,11 @@ if(trig_obj && trig_obj->unpackError != 0) goodev = false; if(s4_obj && s4_obj->unpackError != 0) goodev = false; if(nd_obj && nd_obj->unpackError != 0) goodev = false; - if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>3)&1) || ((ac_obj->status[0]>>3)&1)) ) goodev = false; + if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>2)&1) || ((ac_obj->status[1]>>2)&1)) ) goodev = false; // if(orb_obj) } else { if(nd_obj && nd_obj->unpackError != 0) goodev = false; - if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>3)&1) || ((ac_obj->status[0]>>3)&1)) ) goodev = false; + if(ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0]>>2)&1) || ((ac_obj->status[1]>>2)&1)) ) goodev = false; }; return(goodev); }; @@ -808,10 +812,17 @@ if(!ac_obj) ac_obj = new AcLevel2(); return &ac_obj; }; - if(!objname.CompareTo("OrbitalInfo")){ - if(!orb_obj) orb_obj = new OrbitalInfo(); + if(!objname.CompareTo("OrbitalInfo")) { + if(!orb_obj){ + orb_obj = new OrbitalInfo(); + orb_obj->Set(); + } return &orb_obj; }; +// if(!objname.CompareTo("OrbitalInfo")){ +// if(!orb_obj) orb_obj = new OrbitalInfo(); +// return &orb_obj; +// }; if(!objname.CompareTo("GPamela")){ if(!gp_obj) gp_obj = new GPamela(); return &gp_obj; @@ -900,9 +911,41 @@ if( !orb_obj )return 0; + if( orb_obj->OrbitalInfo::ntrk()==0 ){ - cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no OrbitalInfo tracks are stored"<OrbitalInfoTrk; +// for(Int_t nt=0; nt < tof_obj->ToFLevel2::ntrk(); nt++){ +// // +// ToFTrkVar *ptt = tof_obj->ToFLevel2::GetToFTrkVar(nt); +// if ( ptt->trkseqno != -1 ){ +// // +// r->trkseqno = ptt->trkseqno; +// // +// r->Eij = 0; +// // +// r->Sij = 0; +// // +// r->pitch = -1000.; +// // +// r->cutoff = -1000.; +// // +// new(tor[nn]) OrbitalInfoTrkVar(*r); +// nn++; +// // +// r->Clear(); +// // +// }; +// }; +// delete r; +// OrbitalInfoTrkVar *c = 0; +// c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0); +// return c; +// //TRICK END + cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no OrbitalInfo tracks are stored"<>> Found selection-list <<<"<>> Found selection-list <<<"<cd(); @@ -1824,9 +1867,7 @@ TList* PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){ TString wdir = gSystem->WorkingDirectory(); - - // if(ddir=="")ddir = wdir; -// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); + if ( ddir != ""){ cout << "Level2 data directory : "<< ddir << endl; } else { @@ -1835,21 +1876,21 @@ TList *contents = new TList; // create output list contents->SetOwner(); -// char *fullpath; -// const char *fullpath; - - // if no input file list is given: + // -------------------------------------- + // case 1 : input file/file-list provided + // -------------------------------------- if ( flisttxt != "" ){ -// if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ -// if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){ -// cout <<"File "<ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); + TString dir = gSystem->DirName(flisttxt); +// cout << " List directory "<ConcatFileName(wdir.Data(),gSystem->BaseName(flisttxt)); +// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); if( !gSystem->ChangeDirectory(ddir) ){ cout << "Cannot change directory : "< ERROR opening the file "<ChangeDirectory(wdir); // back to the working directory return 0; } int line=0; + // ........................... + // loop over file-list records + // ........................... while (1) { TString file; in >> file; if (!in.good()) break; line++; -// cout <<"(1) " << file << endl; + cout <<"(*) " << file << endl; if(file.IsNull()){ cout << "-- list interrupted at line "<IsFileInIncludePath(file,&fullpath) ){ -// if( (fullpath = gSystem->FindFile(ddir,file)) ){ + // + // take only root files + // if( file.EndsWith(".root") ){ TString filedir; + cout << ddir << endl; if (ddir != ""){ filedir = ddir; // take the input dir } else { gSystem->ChangeDirectory(wdir); // back to the working directory filedir = gSystem->DirName(file); // this will take the path if exist in the list otherwise it will return automatically the working dir }; + filedir.Append("/"); char *fullpath = gSystem->ConcatFileName(gSystem->DirName(filedir),gSystem->BaseName(file)); contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list + cout << fullpath << endl; delete fullpath; } // }else{ @@ -1896,12 +1943,18 @@ // }; }; in.close(); + // -------------------------------------- + // a single root file given as input + // -------------------------------------- } else { if(flisttxt.Contains("#"))flisttxt = flisttxt(0,flisttxt.First("#")); char *fullpath = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list delete fullpath; }; + // --------------------------------------------------------------------------------- + // case 2 : no input file/file-list provided --> read all files insede the directory + // --------------------------------------------------------------------------------- }else{ cout << "No input file list given."<BaseName(ddir),ddir); TList *temp = datadir->GetListOfFiles(); + if(!temp)return 0; // temp->Print(); // cout << "*************************************" << endl; @@ -2592,25 +2646,30 @@ prevshift = 0; run_tree->GetEntry(irun); if( !GetOrbitalInfo() )cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated "<IsConnected()) )SetDBConnection(); //Emiliano + gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0,"ID",dbc,false); //Emiliano // the "false" means not to use level0 file (not necessary here) + if ( dbc ) dbc->Close();// Emiliano }; // --------------------------------------------------------------- // retrieve OBT and absolute time of the event // --------------------------------------------------------------- ULong64_t abstime = 0LL; - ULong64_t obt = 0LL; + // ULong64_t obt = 0LL; // Emiliano + Long64_t obt = 0LL; // Emiliano, Long64_t GL_TIMESYNC::DBobt(UInt_t obt) since depending on the situation OBT is lowered or boosted if( GetOrbitalInfo() ){ abstime = GetOrbitalInfo()->absTime; - obt = GetOrbitalInfo()->OBT; + obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano }else{ abstime = GetRunInfo()->RUNHEADER_TIME; - obt = GetRunInfo()->RUNHEADER_OBT; + obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano } // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- // if it is a full file (not preselected) // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - if(SELLI==0){ + if(SELLI==0 || SELLI==2){ // Emiliano // --------------------------------------------------------------- // increment dead and live-time counters @@ -2643,8 +2702,8 @@ !(abstime >= GetRunInfo()->RUNHEADER_TIME && // check on absolute time (s) abstime <= GetRunInfo()->RUNTRAILER_TIME) || - !(obt >= GetRunInfo()->RUNHEADER_OBT && // additional check on OBT (ms) - obt <= GetRunInfo()->RUNTRAILER_OBT) + !(obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) && // additional check on OBT (ms) // Emiliano + obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) // Emiliano || GetRunInfo()->NEVENTS==0 // || !(irunentry < GetRunInfo()->NEVENTS-1-prevshift) // ERRORE!!! fa saltare i run con 1 evento @@ -2667,6 +2726,7 @@ // store dead and live-time of previous run // ----------------------------------------- // if(SELLI==0){ + if(SELLI!=2){ if(fromfirst){ if(oldrun==irun){ /// decrement counters @@ -2675,15 +2735,17 @@ totdltime[1]-=GetTrigLevel2()->dltime[1];//dead-time } totdltime[2]--; //event counter - cout << endl; - cout << "n.events : "<GetEntry(irun);//update runinfo irunt = irun - irunoffset[run_tree->GetTreeNumber()]; - if(GetRunInfo()->RUNHEADER_OBT>GetRunInfo()->RUNTRAILER_OBT ){ + if ( gltsync ) delete gltsync; // Emiliano + if(!dbc || (dbc && !dbc->IsConnected()) )SetDBConnection(); //Emiliano + gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0,"ID",dbc,false); // Emiliano + if ( dbc ) dbc->Close(); // Emiliano + if(gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT)>gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ){ // Emiliano cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun "<=RUNTRAILER_OBT " <GetListOfKeys(); + if(!lk)return; TIter next(lk); TKey *key =0; @@ -3391,7 +3459,7 @@ if(GP){ Int_t nevt = ((TTree*)f->Get("h20"))->GetEntries(); if( nev && nevt!=nev){ - cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<GetName() <<" discarded ---- h20 tree has "<Branch("DeadLiveTime",totdltime,"dltime[3]/l"); - cout << "Run : branch DeadLiveTime"<Branch("DeadLiveTime",totdltime,"dltime[3]/l"); + cout << "Run : branch DeadLiveTime"<Branch("RunEntry",&irun,"runentry/L"); - sel_tree_clone->Branch("RunEntry",&irunt,"runentry/L");//NEWNEW - sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); - + sel_tree_clone = new TTree("SelectionList","List of selected events "); + // sel_tree_clone->Branch("RunEntry",&irun,"runentry/L"); + sel_tree_clone->Branch("RunEntry",&irunt,"runentry/L");//NEWNEW + sel_tree_clone->Branch("EventEntry",&irunentry,"eventry/L"); + }; Int_t i=0; if(TRK1||TRK2||TRKh){ @@ -3675,14 +3744,14 @@ }; // OrbitalInfo if(ORB) { - pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA oribital info "); + pam_tree_clone[i] = new TTree("OrbitalInfo","PAMELA orbital info "); pam_tree_clone[i]->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); cout << "OrbitalInfo : branch OrbitalInfo"<Branch("GPamela","GPamela", GetPointerTo("GPamela"),32000,1);//split cout << "OrbitalInfo : branch OrbitalInfo"<GetName()<GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) + if ( SELLI != 2){// Emiliano + if(run_tree_clone->GetBranch("DeadLiveTime")->GetEntries() < run_tree->GetEntries()) run_tree_clone->GetBranch("DeadLiveTime")->Fill(); + }; run_tree_clone->Write(); - cout << sel_tree_clone->GetName()<Write(); + if ( SELLI != 2){ //Emiliano + cout << sel_tree_clone->GetName()<Write(); + }; for(Int_t i=0; iGetName()<GetEntry(ii) ){ - cout << " Int_t PamLevel2::GetEntry(Int_t) -- ERROR -- error reading pam tree"<Fill(); // cout << "PamLevel2::GetEntry("<