--- eventviewer/flight/src/FEVdetector.cpp 2006/08/01 08:39:40 1.2 +++ eventviewer/flight/src/FEVdetector.cpp 2007/11/29 15:53:10 1.25 @@ -46,6 +46,8 @@ #include #include #include +#include +#include // #include #include @@ -67,6 +69,7 @@ #include #include #include +#include // extern Bool_t existfile(TString); // @@ -80,14 +83,30 @@ thefigure = &figure; checkctrlword(); var.selex = false; + var.showall = false; + + var.showsi = false; + var.shownd = false; + var.shows4 = false; + var.showorb = false; + var.showtof = false; + var.showtrg = false; + var.showtrk = false; + var.showcal = false; + var.showrun = false; + var.showac = false; } void FEVdetector::checkctrlword(){ var.SHOWDEC = 0; var.TOF = 0; var.AC = 0; + var.RUN = 1; var.TRK = 0; + var.ORB = 1; + var.TRG = 1; var.CALO = 0; + var.CALOT = 0; var.S4 = 0; var.ND = 0; var.INFOS = 0; @@ -122,21 +141,47 @@ }; } +void FEVdetector::SetDDEC(TString de){ + ddec=de; +}; + void FEVdetector::GetWindow(){ - otr->GetEntry(maxevent); + // + if ( level.file == 2 ){ + // printf("0qui\n"); + L2->GetEntry(minevent); + } else { + otr->GetEntry(minevent); + } if ( level.file < 2 ){ ph = eh->GetPscuHeader(); - lastevno = (int)ph->Counter; + firstevno = (int)ph->Counter; } else { - lastevno = oinfoL2->pkt_num; // to be changed as soon as we will have pkt_counter in the level2 file! + if ( var.ORB ){ + firstevno = L2->GetOrbitalInfo()->pkt_num; + } else { + firstevno = 0; + }; }; - otr->GetEntry(minevent); + // + if ( level.file == 2 ){ + // printf("1qui\n"); + L2->GetEntry(maxevent); + } else { + otr->GetEntry(maxevent); + } + // if ( level.file < 2 ){ ph = eh->GetPscuHeader(); - firstevno = (int)ph->Counter; + lastevno = (int)ph->Counter; } else { - firstevno = oinfoL2->pkt_num; // to be changed as soon as we will have pkt_counter in the level2 file! + if ( var.ORB ){ + lastevno = L2->GetOrbitalInfo()->pkt_num; + } else { + lastevno = 0; + }; }; + // } void FEVdetector::ClearVariables(){ @@ -159,8 +204,58 @@ } void FEVdetector::GetEntry(Int_t i){ - thisentry = i; - otr->GetEntry(i); + thisentry = i; + if ( level.file == 2 ){ + L2->Clear(); + // printf("qui\n"); + L2->GetEntry(i); + if ( var.showall ){ + ShowInfo("RunInfo"); + ShowInfo("SoftInfo"); + ShowInfo("OrbitalInfo"); + ShowInfo("TrigLevel2"); + ShowInfo("ToFLevel2"); + ShowInfo("TrkLevel2"); + ShowInfo("AcLevel2"); + ShowInfo("CaloLevel2"); + ShowInfo("CaloLevel1"); + ShowInfo("S4Level2"); + ShowInfo("NDLevel2"); + } else { + if ( var.showrun ) ShowInfo("RunInfo"); + if ( var.showsi ) ShowInfo("SoftInfo"); + if ( var.showorb ) ShowInfo("OrbitalInfo"); + if ( var.showtrg ) ShowInfo("TrigLevel2"); + if ( var.showtof ) ShowInfo("ToFLevel2"); + if ( var.showtrk ) ShowInfo("TrkLevel2"); + if ( var.showac ) ShowInfo("AcLevel2"); + if ( var.showcal ) ShowInfo("CaloLevel2"); + if ( var.showcal ) ShowInfo("CaloLevel1"); + if ( var.shows4 ) ShowInfo("S4Level2"); + if ( var.shownd ) ShowInfo("NDLevel2"); + }; + } else { + otr->GetEntry(i); + if ( var.showall ){ + ShowInfo("Pscu"); + ShowInfo("Trigger"); + ShowInfo("Tof"); + ShowInfo("Tracker"); + ShowInfo("Anticounter"); + ShowInfo("Calorimeter"); + ShowInfo("S4"); + ShowInfo("Neutron"); + } else { + if ( var.showorb ) ShowInfo("Pscu"); + if ( var.showtrg ) ShowInfo("Trigger"); + if ( var.showtof ) ShowInfo("Tof"); + if ( var.showtrk ) ShowInfo("Tracker"); + if ( var.showac ) ShowInfo("Anticounter"); + if ( var.showcal ) ShowInfo("Calorimeter"); + if ( var.shows4 ) ShowInfo("S4"); + if ( var.shownd ) ShowInfo("Neutron"); + }; + }; } void FEVdetector::SetEntry(Int_t i){ @@ -173,7 +268,7 @@ return((int)ph->Counter); } else { // return(thisentry); // to be changed as soon as we will have pkt_counter in the level2 file! - return((int)oinfoL2->pkt_num); // to be changed as soon as we will have pkt_counter in the level2 file! + return((int)L2->GetOrbitalInfo()->pkt_num); // to be changed as soon as we will have pkt_counter in the level2 file! }; } @@ -281,6 +376,478 @@ }; } +void FEVdetector::ShowInfo(TString detector){ + // + TBranch *b1 = 0; + // TBranch *b3 = 0; + TObjArray *branch_array = 0; + // TObjArray *leaf_array = 0; + // + if ( !strcmp(detector.Data(),"RunInfo") || !strcmp(detector.Data(),"SoftInfo") ){ + if ( L2->GetRunTree() ) b1 = L2->GetRunTree()->FindBranch(detector.Data()); + } else { + b1 = otr->FindBranch(detector.Data()); + }; + // + if ( !b1 ) return; + // + Int_t dlen = 10; + // + char o[200000]; + char col[13]; + char col2[13]; + // + setcolor(col,RESET, GREEN, WHITE); + sprintf(o,"%s======> EVENT:%i\n",col, thisentry); + // + setcolor(col,RESET, RED, WHITE); + sprintf(o,"%s%sBranch %s\n",o,col,b1->GetName()); + setcolor(col,RESET, BLACK, WHITE); + sprintf(o,"%s%s",o,col); + // + branch_array = b1->GetListOfBranches(); + // + Int_t j = 0; + // + for(Int_t l=0;l<(branch_array->GetLast()+1);l++){ + // + TBranchElement *tb = (TBranchElement*)branch_array->At(l); + Int_t type = tb->GetType(); + Int_t atype = tb->GetStreamerType() - 20; + Int_t len = (tb->GetInfo()->GetLengths())[tb->GetID()]; + Int_t length = min(len,dlen); + // + // printf("Branches : type is %i type is %i tb getname %s slen %i slength %i\n",atype,type,tb->GetName(),len,length); + switch (type){ + case 0: + // + // IS A VARIABLE + // + // + // NAME + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %-15s%s =",o,col,((TBranch*)branch_array->At(l))->GetName(),col2); + // + j = 0; + // + // VALUES + // + // + // Integer + // + if ( atype == 3 || atype == -17 ){ + while ( j < length ){ + if ( j < length -1 ){ + sprintf(o,"%s %i ,",o,(Int_t)tb->GetValue(j,0)); + } else { + sprintf(o,"%s %i",o,(Int_t)tb->GetValue(j,0)); + }; + j++; + }; + }; + // + // Unsigned integer + // + if ( atype == -7 || atype == 13 || atype == -9 || atype == -8 || atype == 12 ){ + while ( j < length ){ + if ( j < length -1 ){ + sprintf(o,"%s %u ,",o,(UInt_t)tb->GetValue(j,0)); + } else { + sprintf(o,"%s %u",o,(UInt_t)tb->GetValue(j,0)); + }; + j++; + }; + }; + // + // Float + // + if ( atype == -15 || atype == 5 ){ + while ( j < length ){ + if ( j < length -1 ){ + sprintf(o,"%s %f ,",o,tb->GetValue(j,0)); + } else { + sprintf(o,"%s %f",o,tb->GetValue(j,0)); + }; + j++; + }; + }; + // + // Strings + // + if ( atype == 45 ){ + // TObjArray *cl = (TObjArray*)(tb->GetInfo()->GetOffsets())[tb->GetID()];//tb->GetValuePointer(); + // TString *stringa = (TString*)(*cl)[0]; + // TBranchElement *utb = (TBranchElement*)tb->GetBranchCount(); + // TString** stringa = (TString*)(&tb->GetValuePointer()); + //TStreamerElement *tste = (TStreamerElement*)tb->GetInfo()->GetCurrentElement(); + + // char *ladd; + // ladd = tb->GetValuePointer() + // TString *stringa = (TString*)((tste->GetOffset())); + // TString& mstr = *stringa; + // printf(" la mia stringa %s \n",mstr.Data()); + // printf(" offset %i \n",(Int_t)utb->GetValue(0,0)); + // int pointer = (tb->GetInfo()->GetOffsets())[tb->GetID()]; + // TString *stringa = (TString*)(tb->GetInfo()->GetOffsets())[tb->GetID()]; +// TString *stringa = (TString*)tb->GetAddress(); +// printf(" address 0x%X \n",tb->GetAddress()); +// printf(" pointer 0x%X \n",tb->GetValuePointer()); +// printf(" object 0x%X \n",tb->GetObject()); +// printf("stringa %s lung %i\n",stringa.Data(),stringa.Length()); + // TLeaf *striglia = tb->FindLeaf(tb->GetName()); +// if ( striglia ){ +// char *pointer = (char *)striglia->GetValuePointer(); +// TString *pr= (TString*)pointer; +// printf("ciao %s \n",pr->Data()); +// }; + sprintf(o,"%s TString - not implemented yet -",o); + }; + // + // TArray + // + if ( atype == 42 ){ + // +// TObjArray *cl = (TObjArray*)tb->GetObject(); +// // +// TClass *myc = cl->IsA(); +// // +// printf("qui \n"); +// // +// // determine offset to fetch data +// // +// int thisoffset = 0; +// TRealData *rd = myc->GetRealData(tb->GetName()); +// if ( rd ){ +// thisoffset = rd->GetThisOffset(); +// }; +// Int_t niente = 0; +// TStreamerElement *tste = tb->GetInfo()->GetStreamerElement(rd->GetName(),niente); +// printf(" typename %s \n",tste->GetTypeName()); +// // +// // TArrayI +// // +// if ( !strcmp(tste->GetTypeName(),"TArrayI") ){ +// // +// printf("qua \n"); +// char *pointer = (char*)cl->At(0); +// // char *pu = thisoffset + pointer; +// int pu = (int)tste->GetTObjectOffset(); +// TArrayI arr = (TArrayI)*pu; +// // TArrayI arr = (TArrayI)(thisoffset); +// //TArrayI *arr = (TArrayI*)pu; +// //TArraI arr = (TArrayI) +// Int_t jj=0; +// j=0; +// printf("quii \n"); +// Int_t arlen = min(arr.GetSize(),dlen); +// // +// printf("que \n"); +// setcolor(col,RESET, BLUE, WHITE); +// setcolor(col2,RESET, BLACK, WHITE); +// sprintf(o,"%s%s %s[%i]%s = ",o,col,tb->GetName(),arr.GetSize(),col2); +// // +// // while ( j < tb->GetNdata() ){ +// // +// printf("quo \n"); +// // pointer = (char*)cl->UncheckedAt(j); +// // pu = pointer + thisoffset; +// // arr = (TArrayI*)(thisoffset); +// // +// while ( jj < arlen ){ +// if ( jj < arlen-1 ){ +// sprintf(o,"%s %i ,",o,arr.At(jj)); +// } else { +// sprintf(o,"%s %i",o,arr.At(jj)); +// }; +// jj++; +// }; +// // if ( j < tb->GetNdata() -1 ) sprintf(o,"%s ,",o); +// // j++; +// // }; +// }; +// // +// // TArrayF +// // +// if ( !strcmp(tste->GetTypeName(),"TArrayF") ){ +// // +// char *pointer = (char*)cl->UncheckedAt(0); +// char *pu = pointer + thisoffset; +// TArrayF *arr = (TArrayF*)(pu); +// Int_t jj=0; +// Int_t arlen = min(arr->GetSize(),dlen); +// // +// setcolor(col,RESET, BLUE, WHITE); +// setcolor(col2,RESET, BLACK, WHITE); +// sprintf(o,"%s%s %s[%i]%s = ",o,col,tb->GetName(),arr->GetSize(),col2); +// // +// while ( j < tb->GetNdata() ){ +// // +// pointer = (char*)cl->UncheckedAt(j); +// pu = pointer + thisoffset; +// arr = (TArrayF*)(pu); +// // +// while ( jj < arlen ){ +// if ( jj < arlen-1 ){ +// sprintf(o,"%s %f ,",o,arr->At(jj)); +// } else { +// sprintf(o,"%s %f",o,arr->At(jj)); +// }; +// jj++; +// }; +// if ( j < tb->GetNdata() -1 ) sprintf(o,"%s ,",o); +// j++; +// }; +// }; +// sprintf(o,"%s\n",o); + // + sprintf(o,"%s TArray - not implemented yet -",o); + // + }; + // + sprintf(o,"%s\n",o); + break; + case 3: + // + // IS A TCLONESARRAY + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %-15s%s = %d\n",o,col,tb->GetName(), col2, tb->GetNdata()); + + // + if ( tb->GetNdata() ){ + // + TClonesArray *cl = (TClonesArray*)tb->GetObject(); + // + TClass *myc = cl->GetClass(); + // + TList *lme = myc->GetListOfDataMembers(); + TIter next(lme); + TBranchElement *tb2 = 0; + // + while ( (tb2 = (TBranchElement*)next()) ){ + // + const char *name = tb2->GetName(); + TBranch *foglia = tb->FindBranch(name); + if ( foglia ){ + // + TBranchElement *stb = (TBranchElement*)tb->FindBranch(name); + Int_t stype = stb->GetType(); + Int_t satype = stb->GetStreamerType() - 20; + Int_t slen = (stb->GetInfo()->GetLengths())[stb->GetID()]; + Int_t slength = min(slen,dlen); + // printf("SubBranches : atype is %i type is %i tb getname %s slen %i slength %i\n",satype,stype,stb->GetName(),slen,slength); + switch (stype){ + case 31: + // + // IS A VARIABLE + // + // + // NAME + // + j = 0; + // + // VALUES + // + if ( satype == 41 || satype == 44){ + // + // skip TRef + // + break; + }; + // + // Integer + // + if ( satype == -17 || satype == -9 ){ + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %-15s%s = ",o,col,foglia->GetName(),col2); + while ( j < cl->GetEntriesFast() ){ + if ( j < cl->GetEntriesFast() -1 ){ + sprintf(o,"%s %i ,",o,(Int_t)stb->GetValue(j,slength)); + } else { + sprintf(o,"%s %i",o,(Int_t)stb->GetValue(j,slength)); + }; + j++; + }; + }; + // + // Float + // + if ( satype == -15 ){ + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %-15s%s = ",o,col,foglia->GetName(),col2); + while ( j < cl->GetEntriesFast() ){ + if ( j < cl->GetEntriesFast() -1 ){ + sprintf(o,"%s %f ,",o,stb->GetValue(j,slength)); + } else { + sprintf(o,"%s %f",o,stb->GetValue(j,slength)); + }; + j++; + }; + }; + // + // Array of float + // + if ( satype == 5 ){ + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %-15s%s = ",o,col,foglia->GetName(),col2); + Bool_t bold = true; + while ( j < tb->GetNdata() ){ + if ( bold ){ + setcolor(col,RESET, BLACK, WHITE); + sprintf(o,"%s%s",o,col); + } else { + setcolor(col,BOLD, BLACK, WHITE); + sprintf(o,"%s%s",o,col); + }; + Int_t jj = 0; + while ( jj < slength ){ + if ( jj < slength-1 ){ + sprintf(o,"%s %f ,",o,stb->GetValue(j,jj,true)); + } else { + sprintf(o,"%s %f",o,stb->GetValue(j,jj,true)); + }; + jj++; + }; + if ( j < tb->GetNdata() -1 ) sprintf(o,"%s ,",o); + if ( !bold ){ + bold = true; + } else { + bold = false; + }; + j++; + }; + if ( bold ){ + setcolor(col,RESET, BLACK, WHITE); + sprintf(o,"%s%s",o,col); + }; + }; + // + // Array of integers + // + if ( satype == 3 ){ + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %-15s%s = ",o,col,foglia->GetName(),col2); + while ( j < tb->GetNdata() ){ + Int_t jj = 0; + while ( jj < slength ){ + if ( jj < slength-1 ){ + sprintf(o,"%s %i ,",o,(Int_t)stb->GetValue(j,jj,true)); + } else { + sprintf(o,"%s %i",o,(Int_t)stb->GetValue(j,jj,true)); + }; + jj++; + }; + if ( j < tb->GetNdata() -1 ) sprintf(o,"%s ,",o); + j++; + }; + }; + + // + // TArray + // + if ( satype == 42 ){ + // + // determine offset to fetch data + // + int thisoffset = 0; + TRealData *rd = myc->GetRealData(foglia->GetName()); + if ( rd ){ + thisoffset = rd->GetThisOffset(); + }; + Int_t niente = 0; + TStreamerElement *tste = stb->GetInfo()->GetStreamerElement(rd->GetName(),niente); + // + // TArrayI + // + if ( !strcmp(tste->GetTypeName(),"TArrayI") ){ + // + char *pointer = (char*)cl->UncheckedAt(0); + char *pu = pointer + thisoffset; + TArrayI *arr = (TArrayI*)(pu); + Int_t jj=0; + Int_t arlen = min(arr->GetSize(),dlen); + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %s[%i]%s = ",o,col,foglia->GetName(),arr->GetSize(),col2); + // + while ( j < tb->GetNdata() ){ + // + pointer = (char*)cl->UncheckedAt(j); + pu = pointer + thisoffset; + arr = (TArrayI*)(pu); + // + while ( jj < arlen ){ + if ( jj < arlen-1 ){ + sprintf(o,"%s %i ,",o,arr->At(jj)); + } else { + sprintf(o,"%s %i",o,arr->At(jj)); + }; + jj++; + }; + if ( j < tb->GetNdata() -1 ) sprintf(o,"%s ,",o); + j++; + }; + }; + // + // TArrayF + // + if ( !strcmp(tste->GetTypeName(),"TArrayF") ){ + // + char *pointer = (char*)cl->UncheckedAt(0); + char *pu = pointer + thisoffset; + TArrayF *arr = (TArrayF*)(pu); + Int_t jj=0; + Int_t arlen = min(arr->GetSize(),dlen); + // + setcolor(col,RESET, BLUE, WHITE); + setcolor(col2,RESET, BLACK, WHITE); + sprintf(o,"%s%s %s[%i]%s = ",o,col,foglia->GetName(),arr->GetSize(),col2); + // + while ( j < tb->GetNdata() ){ + // + pointer = (char*)cl->UncheckedAt(j); + pu = pointer + thisoffset; + arr = (TArrayF*)(pu); + // + while ( jj < arlen ){ + if ( jj < arlen-1 ){ + sprintf(o,"%s %f ,",o,arr->At(jj)); + } else { + sprintf(o,"%s %f",o,arr->At(jj)); + }; + jj++; + }; + if ( j < tb->GetNdata() -1 ) sprintf(o,"%s ,",o); + j++; + }; + }; + }; + sprintf(o,"%s\n",o); + break; + }; + }; + }; + }; + break; + }; + }; + // pamgui->DIALOG(0,o); + printf("%s\n",o); +}; + + void FEVdetector::GetGeneralInfo(){ // // Get Orbital Time information and header event number @@ -290,7 +857,7 @@ headcold = headc; headc = ph->Counter; var.headc = (int)ph->Counter; - OBT = ph->OrbitalTime; + OBT = (UInt_t)ph->OrbitalTime; DOBT = OBT - OOBT; OOBT = OBT; if ( thisentry == minevent || DOBT < 0 || (headc-headcold-1)!=0 ) DOBT = 0; @@ -326,28 +893,42 @@ trcs = (TString)trc.str().c_str(); } else { headcold = headc; - headc = oinfoL2->pkt_num; // to be changed as soon as we will have obt in the level2 file! - OBT = oinfoL2->OBT; // to be changed as soon as we will have obt in the level2 file! - DOBT = OBT - OOBT; - OOBT = OBT; - if ( thisentry == minevent || DOBT < 0 || (headc-headcold-1)!=0 ) DOBT = 0; - var.etime = OBT; + if ( var.RUN ){ + var.idrun = L2->GetRunInfo()->ID; + var.idroot = L2->GetRunInfo()->ID_ROOT_L0; + var.EVF = L2->GetRunInfo()->EV_FROM; + }; + if ( var.ORB ){ + headc = L2->GetOrbitalInfo()->pkt_num; + OBT = L2->GetOrbitalInfo()->OBT; + DOBT = OBT - OOBT; + OOBT = OBT; + if ( thisentry == minevent || DOBT < 0 || (headc-headcold-1)!=0 ) DOBT = 0; + var.etime = OBT; + } else { + var.etime = 0; + }; // // who gave the trigger? // - calotrig = 0; - if ( L2->patterntrig[0] ) calotrig = 1; - toftrig = 0; - if ( L2->patterntrig[2] || L2->patterntrig[3] || L2->patterntrig[4] || L2->patterntrig[5] ) toftrig = 1; - s4pulser = 0; - if ( L2->patterntrig[1] & (1<<0) ) s4pulser = 1; - // - // TOF and calorimeter when giving a trigger will always set this flag since the time window of the signal is greater than 100 ns. - // S4 sometimes could not set the flag even if the trigger is given. This is a workaround to fix this "bug": - // - if ( !calotrig && !toftrig ) s4pulser = 1; - // - Int_t trigconf = L2->trigconf; + Int_t trigconf = 0; + if ( var.TRG ){ + calotrig = 0; + if ( L2->GetTrigLevel2()->patterntrig[0] ) calotrig = 1; + toftrig = 0; + if ( L2->GetTrigLevel2()->patterntrig[2] || L2->GetTrigLevel2()->patterntrig[3] || L2->GetTrigLevel2()->patterntrig[4] || L2->GetTrigLevel2()->patterntrig[5] ) toftrig = 1; + s4pulser = 0; + if ( L2->GetTrigLevel2()->patterntrig[1] & (1<<0) ) s4pulser = 1; + // + // TOF and calorimeter when giving a trigger will always set this flag since the time window of the signal is greater than 100 ns. + // S4 sometimes could not set the flag even if the trigger is given. This is a workaround to fix this "bug": + // + if ( !calotrig && !toftrig ) s4pulser = 1; + // + trigconf = L2->GetTrigLevel2()->trigconf; + } else { + trigconf = 0; + } stringstream trc; trc.str(""); if ( trigconf & (1<<0) ) trc << "TOF1"; @@ -456,7 +1037,8 @@ // if ( level.file == -1 ) isOK = gApplication->ProcessLine("filter((TTree *)otr,-1,(Variables &)var);"); // - if ( level.file == 2 ) isOK = gApplication->ProcessLine("filter((PamLevel2 *)L2,2);"); + // if ( level.file == 2 ) isOK = gApplication->ProcessLine("filter((PamLevel2 *)L2,2);"); + if ( level.file == 2 ) isOK = gApplication->ProcessLine("filter();"); // // progress bar in text window // @@ -469,24 +1051,32 @@ // } -void FEVdetector::Load(TTree &mainotr, TFile &mainfile){ - file = &mainfile; - otr = &mainotr; - L2 = new PamLevel2(); +TChain* FEVdetector::Load(TString file){ + // + // file = &mainfile; // if ( level.file == 2 ){ - otr = L2->LoadPamTrees(file); - // ******************** - // load magnetic field - // ******************** - const char *pam_calib = pathtocalibration(); // - stringstream magfie; - magfie.str(""); - magfie << pam_calib; - magfie << "/trk-param/field_param-0/"; + printf(" %s \n",ddec.Data()); + if ( !L2 ){ + L2 = new PamLevel2("",file.Data(),ddec.Data()); + otr = L2->GetPamTree(); + printf(" l2 constructor\n"); + // printf(" abst %u obt %u qtot %f \n",L2->GetOrbitalInfo()->absTime,L2->GetOrbitalInfo()->OBT,L2->GetCaloLevel2()->qtot); + } else { + // + printf(" l2 already exist \n"); + otr = L2->GetPamTree(gSystem->DirName(file.Data()),file.Data(),ddec.Data()); + L2->GetRunTree(gSystem->DirName(file.Data()),file.Data()); + // + }; + // + // + if ( !otr ) return(0); + // + // otr->CanDeleteRefs(true); + // if ( runtree ) runtree->CanDeleteRefs(true); // - L2->LoadField(magfie.str().c_str()); } else { // // load calorimeter ADC2MIP conversion file @@ -526,30 +1116,26 @@ // }; // - // - trigger = new pamela::trigger::TriggerEvent(); - eh = new pamela::EventHeader(); - ph = new pamela::PscuHeader(); - oinfoL2 = new OrbitalInfo(); - runinfo = new ItoRunInfo(file); - // - de = new pamela::calorimeter::CalorimeterEvent(); - trk = new pamela::tracker::TrackerEvent(); - ne = new pamela::neutron::NeutronEvent(); - ace = new pamela::anticounter::AnticounterEvent(); - s4 = new pamela::S4::S4Event(); - tof = new pamela::tof::TofEvent(); + // Load level0 file if the case // if ( level.file == 0 || level.file == -1 ){ + // + trigger = new pamela::trigger::TriggerEvent(); + eh = new pamela::EventHeader(); + ph = new pamela::PscuHeader(); + de = new pamela::calorimeter::CalorimeterEvent(); + trk = new pamela::tracker::TrackerEvent(); + ne = new pamela::neutron::NeutronEvent(); + ace = new pamela::anticounter::AnticounterEvent(); + s4 = new pamela::S4::S4Event(); + tof = new pamela::tof::TofEvent(); + // + otr = new TChain("Physics"); + otr->Add(file.Data(),-1); otr->SetBranchAddress("Trigger", &trigger); otr->SetBranchAddress("Header", &eh); }; - if ( level.file == 2 ){ - otr->AddFriend("OrbitalInfo", file); - otr->SetBranchAddress("OrbitalInfo", &oinfoL2); - runinfo->Read(0ULL); - }; // if ( var.TRK ) { if ( level.file == 0 || level.file == -1 ){ @@ -621,6 +1207,12 @@ printf("Show the Time of Flight detector, LEVEL2 data \n"); }; }; + // + if ( !otr ){ + return(0); + }; + // + return otr; // } @@ -696,9 +1288,9 @@ text->DrawLatex(0.33,txthi,testo.str().c_str()); txthi -= 0.03; testo2.str(""); - testo2 << "On Board Time: " << (int)OBT; + testo2 << "On Board Time: " << (unsigned int)OBT; if ( DOBT > 0 ) { - testo2 << " (delta: " << (int)DOBT; + testo2 << " (delta: " << (unsigned int)DOBT; testo2 << ")"; }; testo2 << " [ms]"; @@ -856,10 +1448,10 @@ text->DrawLatex(var.xxvc+0.17*var.sfx,var.yxvc-0.08*var.sfy,"CAS1"); text->DrawLatex(var.xyvc-0.192*var.sfx,var.yyvc-0.08*var.sfy,"CAS4"); text->DrawLatex(var.xyvc+0.17*var.sfx,var.yyvc-0.08*var.sfy,"CAS3"); - text->DrawLatex(var.xxvc-0.192*var.sfx,var.yxvc+0.48*var.sfy,"CARD2"); - text->DrawLatex(var.xxvc+0.155*var.sfx,var.yxvc+0.48*var.sfy,"CARD3"); - text->DrawLatex(var.xyvc-0.170*var.sfx,var.yyvc+0.48*var.sfy,"CARD1"); - text->DrawLatex(var.xyvc+0.13*var.sfx,var.yyvc+0.48*var.sfy,"CARD4"); + text->DrawLatex(var.xxvc-0.222*var.sfx,var.yxvc+0.48*var.sfy,"CARD2"); + text->DrawLatex(var.xxvc+0.185*var.sfx,var.yxvc+0.48*var.sfy,"CARD3"); + text->DrawLatex(var.xyvc-0.190*var.sfx,var.yyvc+0.48*var.sfy,"CARD1"); + text->DrawLatex(var.xyvc+0.16*var.sfx,var.yyvc+0.48*var.sfy,"CARD4"); text->DrawLatex(var.xxvc-0.192*var.sfx,var.yxvc+0.39*var.sfy,"CAT3"); text->DrawLatex(var.xxvc+0.155*var.sfx,var.yxvc+0.39*var.sfy,"CAT4"); text->DrawLatex(var.xyvc-0.170*var.sfx,var.yyvc+0.39*var.sfy,"CAT2"); @@ -987,6 +1579,7 @@ // // print infos on terminal // + // if ( !var.selex ){ printf(" File: %s \n",var.thefilename.Data()); if ( !s4pulser && !calotrig ){ printf(" Pkt_num: %i - Progressive number: %i \n",(int)headc,thisentry+1); @@ -997,7 +1590,7 @@ if ( calotrig ){ printf(" Pkt_num: %i - Progressive number: %i - CALO trigger -\n",(int)headc,thisentry+1); }; - printf(" On Board Time: %i (delta %i) [ms]\n",OBT,DOBT); + printf(" On Board Time: %u (delta %i) [ms]\n",OBT,DOBT); const char *trc2 = trcs; printf(" TRIGGER: %s \n",trc2); printf(" AC: CARD hit = %i CAT hit = %i CAS hit = %i \n",var.hcard,var.hcat,var.hcas); @@ -1009,6 +1602,7 @@ printf(" CALO: NSTRIP = %i QTOT = %i [MIP]\n",var.nstrip,var.qtot); printf(" S4: %.2f [MIP] TOF: beta = %.2f \n",var.s4sig,var.beta[4]); printf(" ND: Trigger: neutrons = %i - Background: upper = %i lower = %i \n",var.trup,var.bkup,var.bkbo); + // }; // } @@ -1316,10 +1910,10 @@ void FEVdetector::ShowTOF(){ // // - // if ( !var.TOF ) return; // Int_t tt = 0; + Int_t rj = 0; // // force level0, i.e. show patterntrig variable! // @@ -1513,7 +2107,9 @@ Float_t s12p = 0.055; ocolo = 10; TPolyLine *ftof12ya[6]; + rj=6; for ( Int_t j=0; j<6; j++){ + rj--; Float_t xc1[4]={ (s12p*j), s12p*(j), s12p*(j+1), (s12p*j)}; Float_t yc1[4]={ -ws13, 0., 0., -ws13}; Float_t xc[4]; @@ -1529,10 +2125,10 @@ } else { colo = 1; }; - ColorMIP(ms12a[j],colo); + ColorMIP(ms12a[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt12[0][j] == 4095. ) colo = noadc; + if ( mt12[0][rj] == 4095. ) colo = noadc; // ftof12ya[j]->SetFillColor(colo); ftof12ya[j]->SetLineWidth(1); @@ -1542,7 +2138,9 @@ // B s12p = 0.055; TPolyLine *ftof12yb[6]; + rj=6; for ( Int_t j=0; j<6; j++){ + rj--; Float_t xc1[4]={ (s12p*j), s12p*(j+1), s12p*(j+1), (s12p*j)}; Float_t yc1[4]={ -ws13, -ws13, 0., -ws13}; Float_t xc[4]; @@ -1558,10 +2156,10 @@ } else { colo = 1; }; - ColorMIP(ms12b[j],colo); + ColorMIP(ms12b[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt12[1][j] == 4095. ) colo = noadc; + if ( mt12[1][rj] == 4095. ) colo = noadc; // ftof12yb[j]->SetFillColor(colo); ftof12yb[j]->SetLineWidth(1); @@ -1595,7 +2193,9 @@ Float_t s21p = 0.075; ocolo = 10; TPolyLine *ftof21ya[2]; + rj=2; for ( Int_t j=0; j<2; j++){ + rj--; Float_t xc1[4]={ s21p*(j-1), s21p*(j-1), s21p*j, s21p*(j-1)}; Float_t yc1[4]={ 0., ws2, ws2, 0.}; Float_t xc[4]; @@ -1611,10 +2211,10 @@ } else { colo = 1; }; - ColorMIP(ms21a[j],colo); + ColorMIP(ms21a[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt21[0][j] == 4095. ) colo = noadc; + if ( mt21[0][rj] == 4095. ) colo = noadc; // ftof21ya[j]->SetFillColor(colo); ftof21ya[j]->SetLineWidth(1); @@ -1624,7 +2224,9 @@ // B s21p = 0.075; TPolyLine *ftof21yb[2]; + rj=2; for ( Int_t j=0; j<2; j++){ + rj--; Float_t xc1[4]={ s21p*(j-1), s21p*j, s21p*j, s21p*(j-1)}; Float_t yc1[4]={ 0., 0., ws2, 0.}; Float_t xc[4]; @@ -1640,10 +2242,10 @@ } else { colo = 1; }; - ColorMIP(ms21b[j],colo); + ColorMIP(ms21b[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt21[1][j] == 4095. ) colo = noadc; + if ( mt21[1][rj] == 4095. ) colo = noadc; // ftof21yb[j]->SetFillColor(colo); ftof21yb[j]->SetLineWidth(1); @@ -1758,7 +2360,9 @@ Float_t s31p = 0.060; ocolo = 10; TPolyLine *ftof31xa[3]; + rj=3; for ( Int_t j=0; j<3; j++){ + rj--; Float_t xc1[4]={ (s31p*j), (s31p*j), s31p*(j+1), (s31p*j)}; Float_t yc1[4]={ 0., ws13, ws13, 0.}; Float_t xc[4]; @@ -1774,10 +2378,10 @@ } else { colo = 1; }; - ColorMIP(ms31a[j],colo); + ColorMIP(ms31a[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt31[0][j] == 4095. ) colo = noadc; + if ( mt31[0][rj] == 4095. ) colo = noadc; // ftof31xa[j]->SetFillColor(colo); ftof31xa[j]->SetLineWidth(1); @@ -1787,7 +2391,9 @@ // B s31p = 0.060; TPolyLine *ftof31xb[3]; + rj=3; for ( Int_t j=0; j<3; j++){ + rj--; Float_t xc1[4]={ (s31p*j), s31p*(j+1), s31p*(j+1), (s31p*j)}; Float_t yc1[4]={ 0., 0., ws13, 0.}; Float_t xc[4]; @@ -1803,10 +2409,10 @@ } else { colo = 1; }; - ColorMIP(ms31b[j],colo); + ColorMIP(ms31b[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt31[1][j] == 4095. ) colo = noadc; + if ( mt31[1][rj] == 4095. ) colo = noadc; // ftof31xb[j]->SetFillColor(colo); ftof31xb[j]->SetLineWidth(1); @@ -1838,7 +2444,9 @@ Float_t s32p = 0.050; ocolo = 10; TPolyLine *ftof32ya[3]; + rj=3; for ( Int_t j=0; j<3; j++){ + rj--; Float_t xc1[4]={ (s32p*j), (s32p*j), s32p*(j+1), (s32p*j)}; Float_t yc1[4]={ -ws13, 0., 0., -ws13}; Float_t xc[4]; @@ -1854,10 +2462,10 @@ } else { colo = 1; }; - ColorMIP(ms32a[j],colo); + ColorMIP(ms32a[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt32[0][j] == 4095. ) colo = noadc; + if ( mt32[0][rj] == 4095. ) colo = noadc; // ftof32ya[j]->SetFillColor(colo); ftof32ya[j]->SetLineWidth(1); @@ -1866,7 +2474,9 @@ }; s32p = 0.050; TPolyLine *ftof32yb[3]; + rj=3; for ( Int_t j=0; j<3; j++){ + rj--; Float_t xc1[4]={ (s32p*j), s32p*(j+1), s32p*(j+1), (s32p*j)}; Float_t yc1[4]={ -ws13, -ws13, 0., -ws13}; Float_t xc[4]; @@ -1882,10 +2492,10 @@ } else { colo = 1; }; - ColorMIP(ms32b[j],colo); + ColorMIP(ms32b[rj],colo); // if ( colo != 10 ) ocolo = colo; - if ( mt32[1][j] == 4095. ) colo = noadc; + if ( mt32[1][rj] == 4095. ) colo = noadc; // ftof32yb[j]->SetFillColor(colo); ftof32yb[j]->SetLineWidth(1); @@ -2022,7 +2632,8 @@ ms11b[i] = 0.; } else { ms11b[i] = 1.; - }; }; + }; + }; for ( Int_t i = 0; i<6; i++ ) { mt12[0][i] = tof->tdc[ch12a[i]][hb12a[i]]; mt12[1][i] = tof->tdc[ch12b[i]][hb12b[i]]; @@ -2116,13 +2727,15 @@ // Bool_t repeat = true; Int_t numtr = 1; +// Int_t numtr = 0; Int_t repuntil = 0; // // var.tofraw = 0; // - repuntil = L2->ToFLevel2::ntrk(); + if ( level.file == 2 ) repuntil = L2->GetToFLevel2()->ntrk(); // printf("repuntil = %i \n",repuntil); + //if ( level.file == 2 ) repuntil = L2->GetTrkLevel2()->GetNTracks(); //repuntil = L2->GetNTracks(); // while ( repeat ){ @@ -2132,18 +2745,27 @@ // // ToFTrkVar *ptt = 0; +// PamTrack *ptrack = 0; + Float_t adc[4][12]; + Float_t tdc[4][12]; + memset(adc,0,4*12*sizeof(Float_t)); + memset(tdc,0,4*12*sizeof(Float_t)); // // + // if ( repuntil == 0 || var.tofraw ){ if ( repuntil == 1 || var.tofraw ){ numtr = 0; - ptt = L2->GetToFTrkVar(0); + ptt = L2->GetToFLevel2()->GetToFTrkVar(0); repeat = false; } else { // // if ( numtr >= repuntil-1 ) repeat = false; // - ptt = L2->GetToFTrkVar(numtr); + // printf(" numtr is %i \n",numtr); + ptt = L2->GetToFLevel2()->GetToFTrkVar(numtr); + //ptrack = L2->GetTrack(numtr); + //ptt = ptrack->GetToFTrack(); }; // xp11[0] = 0.; @@ -2157,10 +2779,10 @@ // ii = 2; // - Float_t adc[4][12]; - Float_t tdc[4][12]; - L2->GetMatrix(numtr,adc,tdc); - + Int_t myseq = ptt->trkseqno + 1; + L2->GetToFLevel2()->GetMatrix(myseq,adc,tdc); + // + // printf(" qua \n"); // for ( Int_t i = 0; i<8; i++ ) { if ( adc[ch11a[i]][hb11a[i]] < 1000. ){ @@ -2317,15 +2939,20 @@ ftof11y->Draw(); TPolyLine *sftof11[8]; tt = 1; - if ( level.file == -1 ) tt = 8; + rj=1; + if ( level.file == -1 ){ + tt = 8; + rj = 8; + }; for ( Int_t j=0; j 0.164 ) higp = 0.164; - if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp11[j] != 0.))){ + if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp11[rj] != 0.))){ Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp}; Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015}; Float_t nxc[5]; @@ -2350,7 +2977,9 @@ Float_t s12p = 0.055; ocolo = 10; TPolyLine *ftof12y[6]; + rj = 6; for ( Int_t j=0; j<6; j++){ + rj--; Float_t nxc1[5]={ (s12p*j), (s12p*j), s12p*(j+1), s12p*(j+1), (s12p*j)}; Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13}; Float_t nxc[5]; @@ -2367,9 +2996,9 @@ colo = 1; }; if ( level.file == -1 ){ - ColorMIP(ms12a[j]+ms12b[j],colo); + ColorMIP(ms12a[rj]+ms12b[rj],colo); } else { - ColorTOFMIP(ms12a[j]+ms12b[j],colo); + ColorTOFMIP(ms12a[rj]+ms12b[rj],colo); }; // if ( colo != 10 ) ocolo = colo; @@ -2436,7 +3065,9 @@ Float_t s21p = 0.075; ocolo = 10; TPolyLine *ftof21y[2]; + rj=2; for ( Int_t j=0; j<2; j++){ + rj--; Float_t nxc1[5]={ s21p*(j-1), s21p*(j-1), s21p*j,s21p*j, s21p*(j-1)}; Float_t nyc1[5]={ 0., ws2, ws2, 0., 0.}; Float_t nxc[5]; @@ -2453,9 +3084,9 @@ colo = 1; }; if ( level.file == -1 ){ - ColorMIP(ms21a[j]+ms21b[j],colo); + ColorMIP(ms21a[rj]+ms21b[rj],colo); } else { - ColorTOFMIP(ms21a[j]+ms21b[j],colo); + ColorTOFMIP(ms21a[rj]+ms21b[rj],colo); }; // if ( colo != 10 ) ocolo = colo; @@ -2572,16 +3203,21 @@ ftof22y->Draw(); TPolyLine *sftof22[2]; tt = 1; - if ( level.file == -1 ) tt = 2; + rj = 1; + if ( level.file == -1 ){ + tt = 2; + rj = 2; + }; for (Int_t j=0; j 0.074 ) higp = 0.074; - if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp22[j] != 0.))){ + if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp22[rj] != 0.))){ Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp}; Float_t nyc1[5]={ -0.0015, -0.0015, -ws2+0.0015, -ws2+0.0015, -0.0015}; Float_t nxc[5]; @@ -2601,7 +3237,7 @@ }; }; // - + //daquiinbasso // // S31 X-view // @@ -2658,16 +3294,21 @@ ftof31y->Draw(); TPolyLine *sftof31[3]; tt = 1; - if ( level.file == -1 ) tt = 3; + rj = 1; + if ( level.file == -1 ){ + tt = 3; + rj = 3; + }; for (Int_t j=0; j 0.074 ) higp = 0.074; - if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp31[j] != 0.))){ + if ( lowp < higp && ( level.file == -1 || (level.file == 2 && xp31[rj] != 0.))){ Float_t nxc1[5]={ lowp, higp, higp, lowp, lowp}; Float_t nyc1[5]={ 0.0015, 0.0015, ws13-0.0015, ws13-0.0015, 0.0015}; Float_t nxc[5]; @@ -2694,7 +3335,9 @@ Float_t s32p = 0.050; ocolo = 10; TPolyLine *ftof32y[3]; + rj = 3; for ( Int_t j=0; j<3; j++){ + rj--; Float_t nxc1[5]={ (s32p*j), (s32p*j), s32p*(j+1),s32p*(j+1), (s32p*j)}; Float_t nyc1[5]={ -ws13, 0., 0., -ws13, -ws13}; Float_t nxc[5]; @@ -2711,9 +3354,9 @@ colo = 1; }; if ( level.file == -1 ){ - ColorMIP(ms32a[j]+ms32b[j],colo); + ColorMIP(ms32a[rj]+ms32b[rj],colo); } else { - ColorTOFMIP(ms32a[j]+ms32b[j],colo); + ColorTOFMIP(ms32a[rj]+ms32b[rj],colo); }; // if ( colo != 10 ) ocolo = colo; @@ -2803,10 +3446,10 @@ // full infos from ac // if ( level.file == 2 ){ - hitmapA = L2->hitmap[0]; - hitmapB = L2->hitmap[1]; - hitstatusA = L2->hitstatus[0]; - hitstatusB = L2->hitstatus[1]; + hitmapA = L2->GetAcLevel2()->hitmap[0]; + hitmapB = L2->GetAcLevel2()->hitmap[1]; + hitstatusA = L2->GetAcLevel2()->hitstatus[0]; + hitstatusB = L2->GetAcLevel2()->hitstatus[1]; }; // // @@ -3680,7 +4323,9 @@ pcasp4b->Draw("f"); pcasp4b->Draw(); }; - Float_t alfa = 1.2020334; + // Float_t alfax = 1.2020334; + Float_t alfax = 1.22157778; + Float_t alfay = 1.27393111; Float_t lcrd = 0.1815/2.; Float_t wcrd = 0.008; if ( true ){ @@ -3891,12 +4536,16 @@ // // Float_t cardcx = 0.143168*var.sfx; //Float_t cardcy = 0.1475*var.sfy; - Float_t cardcx = 0.153168*var.sfx; - Float_t cardcy = 0.1575*var.sfy; - Float_t acrdx[4] = {-lcrd*cos(alfa), lcrd*cos(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)}; - Float_t acrdy[4] = {-lcrd*sin(alfa), lcrd*sin(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)}; - Float_t bcrdx[4] = { lcrd*cos(alfa), lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), lcrd*cos(alfa)}; - Float_t bcrdy[4] = { lcrd*sin(alfa), lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), lcrd*sin(alfa)}; + // + // Float_t cardcx = 0.153168*var.sfx; + // + Float_t cardcx = (0.19123*(1.-lcrd*cos(alfax)))*var.sfx; + // Float_t cardcy = 0.1575*var.sfy; + Float_t cardcy = (0.179212*(1.-lcrd*sin(alfax)))*var.sfy; + Float_t acrdx[4] = {-lcrd*cos(alfax), lcrd*cos(alfax), -lcrd*cos(alfax)+wcrd*sin(alfax), -lcrd*cos(alfax)}; + Float_t acrdy[4] = {-lcrd*sin(alfax), lcrd*sin(alfax), -lcrd*sin(alfax)-wcrd*cos(alfax), -lcrd*sin(alfax)}; + Float_t bcrdx[4] = { lcrd*cos(alfax), lcrd*cos(alfax)+wcrd*sin(alfax), -lcrd*cos(alfax)+wcrd*sin(alfax), lcrd*cos(alfax)}; + Float_t bcrdy[4] = { lcrd*sin(alfax), lcrd*sin(alfax)-wcrd*cos(alfax), -lcrd*sin(alfax)-wcrd*cos(alfax), lcrd*sin(alfax)}; // // CARD3 X/ Y @@ -3956,15 +4605,18 @@ }; if ( true ){ - Float_t acrdx[4] = {-lcrd*cos(alfa), lcrd*cos(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)}; - Float_t acrdy[4] = {-lcrd*sin(alfa), lcrd*sin(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)}; - Float_t bcrdx[4] = { lcrd*cos(alfa), lcrd*cos(alfa)+wcrd*sin(alfa), -lcrd*cos(alfa)+wcrd*sin(alfa), lcrd*cos(alfa)}; - Float_t bcrdy[4] = { lcrd*sin(alfa), lcrd*sin(alfa)-wcrd*cos(alfa), -lcrd*sin(alfa)-wcrd*cos(alfa), lcrd*sin(alfa)}; + Float_t acrdx[4] = {-lcrd*cos(alfay), lcrd*cos(alfay), -lcrd*cos(alfay)+wcrd*sin(alfay), -lcrd*cos(alfay)}; + Float_t acrdy[4] = {-lcrd*sin(alfay), lcrd*sin(alfay), -lcrd*sin(alfay)-wcrd*cos(alfay), -lcrd*sin(alfay)}; + Float_t bcrdx[4] = { lcrd*cos(alfay), lcrd*cos(alfay)+wcrd*sin(alfay), -lcrd*cos(alfay)+wcrd*sin(alfay), lcrd*cos(alfay)}; + Float_t bcrdy[4] = { lcrd*sin(alfay), lcrd*sin(alfay)-wcrd*cos(alfay), -lcrd*sin(alfay)-wcrd*cos(alfay), lcrd*sin(alfay)}; // // CARD - Y-view // - Float_t cardcx = 0.12*var.sfx; - Float_t cardcy = 0.1475*var.sfy; + // Float_t cardcx = 0.12*var.sfx; + Float_t cardcx = (0.16014*(1.-lcrd*cos(alfay)))*var.sfx; + // Float_t cardcy = 0.178818*var.sfy; + Float_t cardcy = (0.178818*(1.-lcrd*sin(alfay)))*var.sfy; + // Float_t cardcy = 0.1475*var.sfy; // // CARD4 X Y/ // @@ -4063,7 +4715,7 @@ // if ( level.file == 2 ){ for ( Int_t j = 0; j<3; j++ ) { - if ( L2->S4adc != 32. ) ms4[j] = L2->S4calibrated; + if ( L2->GetS4Level2()->S4adc != 32. ) ms4[j] = L2->GetS4Level2()->S4calibrated; }; }; // @@ -4148,9 +4800,9 @@ }; }; if ( level.file == 2 ){ - yUpperTrig = (Int_t)L2->trigPhysics; - yUpperBk = (Int_t)L2->upperBack; - yBottomBk = (Int_t)L2->bottomBack; + yUpperTrig = (Int_t)L2->GetNDLevel2()->trigPhysics; + yUpperBk = (Int_t)L2->GetNDLevel2()->upperBack; + yBottomBk = (Int_t)L2->GetNDLevel2()->bottomBack; }; // var.trup = yUpperTrig; @@ -4418,9 +5070,9 @@ for (Int_t m = 0; m<3; m++){ if ( trk->signcluster[l][m] != 0. ){ if ( planeno == 10 ) { - x = 1024 - trk->addrcluster[l][m]; - } else { x = trk->addrcluster[l][m]; + } else { + x = 1024 - trk->addrcluster[l][m]; }; linea = new TLine(14.+x,0.01,14.+x,0.3); linea->SetLineWidth(2); @@ -4457,8 +5109,8 @@ // // singlets X // - for (Int_t sing = 0; sing < L2->nclsx(); sing++){ - TClonesArray &t = *(L2->SingletX); + for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsx(); sing++){ + TClonesArray &t = *(L2->GetTrkLevel2()->SingletX); TrkSinglet *singlet = (TrkSinglet*)t[sing]; x = (singlet->coord[0]+singlet->coord[1])/2.; // @@ -4482,15 +5134,15 @@ // // singlets Y // - for (Int_t sing = 0; sing < L2->nclsy(); sing++){ - TClonesArray &t = *(L2->SingletY); + for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsy(); sing++){ + TClonesArray &t = *(L2->GetTrkLevel2()->SingletY); TrkSinglet *singlet = (TrkSinglet*)t[sing]; // Int_t planepad = (singlet->plane - 1)* 2; trkpad[planepad]->cd(); trkpad[planepad]->Range(-7.05,0.,7.05,8.); for (Int_t img=0; img<2; img++){ - x = singlet->coord[img]; + x = -singlet->coord[img]; Float_t xsig = singlet->sgnl; if ( xsig > 8. ) xsig = 8.; // @@ -4528,9 +5180,10 @@ dcol = 2; }; // - if ( L2->GetNTracks() > 0 ){ - for (Int_t nt = 0; nt < L2->GetNTracks(); nt++){ - TrkTrack *track = L2->GetTrack(nt); + if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){ + for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){ + PamTrack *ptrack= L2->GetTrack(nt); + TrkTrack *track = ptrack->GetTrkTrack(); if ( nt == 0 ){ var.rig = 0.; if ( track->al[4] != 0. ) var.rig = 1./track->al[4]; @@ -4546,7 +5199,7 @@ // x = track->xm[plane]; Float_t xsig = track->dedx_x[plane]; - if ( track->xgood[plane] ){ + if ( track->XGood(plane) ){ //if ( x > -100 ){ if ( xsig > 8. ) xsig = 8.; if ( var.bw ){ @@ -4574,9 +5227,9 @@ planepad = plane * 2; trkpad[planepad]->cd(); trkpad[planepad]->Range(-7.05,0.,7.05,8.); - x = track->ym[plane]; + x = -track->ym[plane]; xsig = track->dedx_y[plane]; - if ( track->ygood[plane] ){ + if ( track->YGood(plane) ){ // if ( x > -100 ){ if ( xsig > 8. ) xsig = 8.; if ( var.bw ){ @@ -4626,17 +5279,21 @@ // // first of all plot crosses relatives to tracks // - if ( L2->GetNTracks() > 0 ){ - for (Int_t nt = 0; nt < L2->GetNTracks(); nt++){ - TrkTrack *track = L2->GetTrack(nt); + if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){ +// for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){ +// TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt); + for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){ + PamTrack *ptrack= L2->GetTrack(nt); + TrkTrack *track = ptrack->GetTrkTrack(); + // for (Int_t plane = 0; plane<6; plane++){ // x = track->xm[plane]; - Float_t y = track->ym[plane]; + Float_t y = -track->ym[plane]; Float_t xsig = track->dedx_x[plane]; Float_t ysig = track->dedx_y[plane]; // if ( x > -100 && y > -100. ){ - if ( track->xgood[plane] && track->ygood[plane] ){ + if ( track->XGood(plane) && track->YGood(plane) ){ if ( var.bw ){ sigcol1 = -1; sigcol2 = -1; @@ -4674,7 +5331,7 @@ // // try to plot crosses relative to singlets // - if ( L2->nclsx() > 0 && L2->nclsy() > 0 ){ + if ( L2->GetTrkLevel2()->nclsx() > 0 && L2->GetTrkLevel2()->nclsy() > 0 ){ for (Int_t plane = 1; plane<7; plane++){ // // count how many singlet in the x and y view for this plane: @@ -4688,8 +5345,8 @@ TArrayF *array2 = new TArrayF(5000); TArrayF *sigarrax = new TArrayF(5000); TArrayF *sigarray = new TArrayF(5000); - for (Int_t sing = 0; sing < L2->nclsx(); sing++){ - TClonesArray &t = *(L2->SingletX); + for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsx(); sing++){ + TClonesArray &t = *(L2->GetTrkLevel2()->SingletX); TrkSinglet *singlet = (TrkSinglet*)t[sing]; if ( singlet->plane == plane ){ arrax->AddAt(((singlet->coord[0]+singlet->coord[1])/2.),totsx); @@ -4718,8 +5375,8 @@ totsx++; }; }; - for (Int_t sing = 0; sing < L2->nclsy(); sing++){ - TClonesArray &t = *(L2->SingletY); + for (Int_t sing = 0; sing < L2->GetTrkLevel2()->nclsy(); sing++){ + TClonesArray &t = *(L2->GetTrkLevel2()->SingletY); TrkSinglet *singlet = (TrkSinglet*)t[sing]; if ( singlet->plane == plane ){ array1->AddAt(singlet->coord[0],totsy); @@ -4754,8 +5411,8 @@ for (Int_t sing = 0; sing < min(totsx,totsy); sing++){ // x = arrax->At(orderx->At(sing)); - Float_t y1 = array1->At(ordery->At(sing)); - Float_t y2 = array2->At(ordery->At(sing)); + Float_t y1 = -array1->At(ordery->At(sing)); + Float_t y2 = -array2->At(ordery->At(sing)); Float_t xsig = sigarrax->At(orderx->At(sing)); Float_t ysig = sigarray->At(ordery->At(sing)); if ( x > -100 && y1 > -100. ){ @@ -4848,14 +5505,14 @@ for (Int_t m = 0; m<3; m++){ if ( trk->signcluster[l][m] != 0. ){ if ( planeno == 10 ) { - x = 1024 - trk->addrcluster[l][m]; - } else { x = trk->addrcluster[l][m]; + } else { + x = 1024 - trk->addrcluster[l][m]; }; x += 1024.; if ( trk->signcluster[l][m]> ysig ){ ysig = trk->signcluster[l][m]; - yh1[ncro] = x-1024.; + yh1[ncro] = x - 1024.; yh2[ncro] = x; }; }; @@ -4883,14 +5540,14 @@ for (Int_t m = 0; m<3; m++){ if ( trk->signcluster[e][m] != 0. ){ if ( planeno == 10 ) { - x = 1024 - trk->addrcluster[e][m]; - } else { x = trk->addrcluster[e][m]; + } else { + x = 1024 - trk->addrcluster[e][m]; }; x += 1024.; if ( trk->signcluster[e][m]> ysig ){ ysig = trk->signcluster[e][m]; - yh1[ncro] = x-1024.; + yh1[ncro] = x - 1024.; yh2[ncro] = x; }; }; @@ -4942,13 +5599,115 @@ void FEVdetector::ShowTrack(){ // + if ( level.file != 2 ) return; // // - if ( !var.TRK || level.file != 2 ) return; // - if ( L2->GetNTracks() > 0 ){ - for (Int_t nt = 0; nt < L2->GetNTracks(); nt++){ - TrkTrack *track = L2->GetTrack(nt); + if ( var.CALO && var.CALOT ){ + if ( L2->GetCaloLevel2()->npcfit[0] > 0 && L2->GetCaloLevel2()->npcfit[1] > 0 ){ + Float_t calx[22]; + Float_t caly[22]; + Float_t calzx[22]; + Float_t calzy[22]; + Float_t zpiano[22]; + zpiano[0] = (CTZ+118.)*var.sfy/1000.; + for (Int_t plane = 1; plane < 22; plane++){ + if ( !(plane%2) ){ + zpiano[plane] = zpiano[plane-1] - 8.09*var.sfy/1000.; + }else { + zpiano[plane] = zpiano[plane-1] - 10.09*var.sfy/1000.; + }; + }; + for (Int_t plane = 0; plane < 22; plane++){ + calx[plane] = (L2->GetCaloLevel2()->cbar[plane][0]/100.)*var.sfx + var.xxvc;; + caly[plane] = (-L2->GetCaloLevel2()->cbar[plane][1]/100.)*var.sfx + var.xyvc; + // calzx[plane] = zpiano[plane] -5.81*var.sfy/1000. + var.yxvc; + calzx[plane] = zpiano[plane] + var.yxvc; + calzy[plane] = zpiano[plane] + var.yyvc; + // printf(" calx %f caly %f calzx %f calzy %f \n",calx[plane],caly[plane],calzx[plane],calzy[plane]); + }; + // + // Calorimeter track + // + Int_t trcol = 30; + if ( var.bw ){ + trcol = 14; + } else { + trcol = 44; + }; + thefigure->cd(); + TPolyLine *trakx = new TPolyLine(22,calx,calzx); + trakx->SetLineColor(trcol); + if ( L2->GetCaloLevel2()->fitmode[0] == 1 ) trakx->SetLineStyle(3); + if ( L2->GetCaloLevel2()->fitmode[0] == 2 ) trakx->SetLineStyle(4); + trakx->SetLineWidth(2); + trakx->Draw(); + TPolyLine *traky = new TPolyLine(22,caly,calzy); + traky->SetLineColor(trcol); + if ( L2->GetCaloLevel2()->fitmode[1] == 1 ) traky->SetLineStyle(3); + if ( L2->GetCaloLevel2()->fitmode[1] == 2 ) traky->SetLineStyle(4); + traky->SetLineWidth(2); + traky->Draw(); + }; + if ( L2->GetCaloLevel2()->npcfit[2] > 0 ){ + Float_t calx[22]; + Float_t caly[22]; + Float_t calzx[22]; + Float_t calzy[22]; + Float_t zpiano[22]; + zpiano[0] = (CTZ+118.)*var.sfy/1000.; + for (Int_t plane = 1; plane < 22; plane++){ + if ( !(plane%2) ){ + zpiano[plane] = zpiano[plane-1] - 8.09*var.sfy/1000.; + }else { + zpiano[plane] = zpiano[plane-1] - 10.09*var.sfy/1000.; + }; + }; + // + // + CaloTrkVar *ctra = L2->GetCaloStoredTrack(-1); + // + for (Int_t plane = 0; plane < 22; plane++){ + calx[plane] = (ctra->tbar[plane][0]/100.)*var.sfx + var.xxvc;; + caly[plane] = (-ctra->tbar[plane][1]/100.)*var.sfx + var.xyvc; + // calzx[plane] = zpiano[plane] -5.81*var.sfy/1000. + var.yxvc; + calzx[plane] = zpiano[plane] + var.yxvc; + calzy[plane] = zpiano[plane] + var.yyvc; + // printf(" calx %f caly %f calzx %f calzy %f \n",calx[plane],caly[plane],calzx[plane],calzy[plane]); + }; + // + // Calorimeter track + // + Int_t trcol = 30; + if ( var.bw ){ + trcol = 16; + } else { + trcol = 46; + }; + thefigure->cd(); + TPolyLine *trakx = new TPolyLine(22,calx,calzx); + trakx->SetLineColor(trcol); + trakx->SetLineStyle(3); + trakx->SetLineWidth(2); + trakx->Draw(); + TPolyLine *traky = new TPolyLine(22,caly,calzy); + traky->SetLineColor(trcol); + traky->SetLineStyle(3); + traky->SetLineWidth(2); + traky->Draw(); + }; + }; + // + if ( !var.TRK ) return; + // + if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){ + for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){ + + // TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt); + // printf("qui \n"); + PamTrack *ptrack = L2->GetTrack(nt); + TrkTrack *track = ptrack->GetTrkTrack(); + // printf("qua \n"); Int_t npoint = 100; Float_t zin[100]; Double_t xout[100]; @@ -5002,22 +5761,23 @@ if ( !ifail ){ for ( Int_t e = 0; e < npoint ; e++) { tx[e] = ((float)tr->x[e]/100.)*var.sfx + var.xxvc; - ty[e] = ((float)tr->y[e]/100.)*var.sfx + var.xyvc; + ty[e] = (-(float)tr->y[e]/100.)*var.sfx + var.xyvc; if ( e < 50 ) { - ptx1[e] = ((float)tr->y[e]/100.)*var.sfx + var.xcat; + ptx1[e] = (-(float)tr->y[e]/100.)*var.sfx + var.xcat; pty1[e] = ((float)tr->x[e]/100.)*var.sfy + var.ycat; } else { - ptx2[e-50] = ((float)tr->y[e]/100.)*var.sfx + var.xcat; + ptx2[e-50] = (-(float)tr->y[e]/100.)*var.sfx + var.xcat; pty2[e-50] = ((float)tr->x[e]/100.)*var.sfy + var.ycat; }; if ( e > 84 ) { tx1[e-85] = ((float)tr->x[e]/100.)*var.nds4 + var.xxvc; - ty1[e-85] = ((float)tr->y[e]/100.)*var.nds4 + var.xyvc; + ty1[e-85] = (-(float)tr->y[e]/100.)*var.nds4 + var.xyvc; tzx1[e-85] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yxvc; tzy1[e-85] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yyvc; }; tzx[e] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yxvc; tzy[e] = (0.112)*var.sfy+((float)zin[e]/100.)*var.sfy + var.yyvc; + // printf("tx[e] %f ty [e] %f tzx %f tzy %f \n",tx[e],ty[e],tzx[e],tzy[e]); }; // // From S1 to CALO @@ -5155,8 +5915,8 @@ Int_t se = 5; if ( !l && m%2 == 0 ) se = 3; if ( !l && m%2 != 0 ) se = 2; - if ( l && m%2 == 0 ) se = 1; - if ( l && m%2 != 0 ) se = 0; + if ( l && m%2 != 0 ) se = 1; + if ( l && m%2 == 0 ) se = 0; // // determine what kind of event we are going to analyze // @@ -5251,7 +6011,7 @@ Xview->Draw("box same"); }; if ( l == 1 ) { - Yview->Fill(n,21-m,1.); + Yview->Fill(95-n,21-m,1.); pd2->cd(); Yview->Draw("box same"); }; @@ -5271,7 +6031,7 @@ // // Define variables // - Int_t etime = var.etime; + UInt_t etime = var.etime; Float_t estrip[2][22][96], ener, basel,sdexy[2][22][96],sdexyc[2][22][96]; Int_t badstrip = 0; qtot = 0.; @@ -5343,7 +6103,7 @@ if ( calib.ttime[s][b[s]+1] && calib.time[s][b[s]] ){ while ( etime > calib.time[s][b[s]] && calib.time[s][b[s]] != 0 ){ printf(" CALORIMETER: \n" ); - printf(" - Section %i, event at time %i while old calibration time limit at %i. Use new calibration at time %i -\n",s,etime,calib.time[s][b[s]],calib.ttime[s][b[s]+1]); + printf(" - Section %i, event at time %u while old calibration time limit at %u. Use new calibration at time %u -\n",s,(UInt_t)etime,(UInt_t)calib.time[s][b[s]],(UInt_t)calib.ttime[s][b[s]+1]); printf(" END CALORIMETER. \n\n" ); b[s]++; CaloPede(s); @@ -5363,8 +6123,8 @@ Int_t se = 5; if (l == 0 && m%2 == 0) se = 3; if (l == 0 && m%2 != 0) se = 2; - if (l == 1 && m%2 == 0) se = 1; - if (l == 1 && m%2 != 0) se = 0; + if (l == 1 && m%2 != 0) se = 1; + if (l == 1 && m%2 == 0) se = 0; // // determine what kind of event we are going to analyze // @@ -5480,7 +6240,7 @@ Xview->Draw("box same"); }; if ( l == 1 ) { - Yview->Fill(n,21-m,1.); + Yview->Fill(96-n,21-m,1.); pd2->cd(); Yview->Draw("box same"); }; @@ -5567,12 +6327,12 @@ // stringstream xvev; stringstream yvev; - for (Int_t ii = 0; ii < L2->nstrip; ii++){ + for (Int_t ii = 0; ii < L2->GetCaloLevel2()->nstrip; ii++){ Int_t colo; Int_t l; Int_t m; Int_t n; - Float_t mip = L2->DecodeEstrip(ii,l,m,n); + Float_t mip = L2->GetCaloLevel1()->DecodeEstrip(ii,l,m,n); if ( var.bw ){ colo = -1; } else { @@ -5599,15 +6359,15 @@ gDirectory->Delete(yvev.str().c_str()); TH2F *Yview = new TH2F(yvev.str().c_str(),"",96,-0.5,95.5,22,-0.5,21.5); Yview->SetFillColor(colo); - Yview->Fill(n,21-m,1.); + Yview->Fill(96-n,21-m,1.); pd2->cd(); Yview->Draw("box same"); }; }; pd1->Update(); pd2->Update(); - var.qtot=(int)L2->qtot; - var.nstrip=(int)L2->nstrip; + var.qtot=(int)L2->GetCaloLevel2()->qtot; + var.nstrip=(int)L2->GetCaloLevel2()->nstrip; }; } @@ -5648,17 +6408,17 @@ for (Int_t d = 0; d<48; d++){ if ( calib.ttime[s][d] != 0 ) calibex++; if ( calib.time[s][0] != 0 ){ - if ( d == 0 ) printf(" Section %i from time 0 to time %i use calibration at time %i \n",s,calib.time[s][d],calib.ttime[s][d]); + if ( d == 0 ) printf(" Section %i from time 0 to time %u use calibration at time %u \n",s,calib.time[s][d],calib.ttime[s][d]); if ( calib.time[s][d+1] != 0 ) { - printf(" Section %i from time %i to time %i use calibration at time %i \n",s,calib.time[s][d],calib.time[s][d+1],calib.ttime[s][d+1]); + printf(" Section %i from time %u to time %u use calibration at time %u \n",s,calib.time[s][d],calib.time[s][d+1],calib.ttime[s][d+1]); } else { if ( !stop ){ - printf(" Section %i from time %i use calibration at time %i \n",s,calib.time[s][d],calib.ttime[s][d+1]); + printf(" Section %i from time %u use calibration at time %u \n",s,calib.time[s][d],calib.ttime[s][d+1]); stop = 1; }; }; } else { - if ( calib.ttime[s][d] != 0 ) printf(" Section %i from time 0 use calibration at time %i \n",s,calib.ttime[s][d]); + if ( calib.ttime[s][d] != 0 ) printf(" Section %i from time 0 use calibration at time %u \n",s,calib.ttime[s][d]); }; }; printf("\n"); @@ -5723,7 +6483,7 @@ calib.ttime[s][inter] = 0; if ( ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { //calib.ttime[s][inter] = cph->GetOrbitalTime(); - calib.ttime[s][inter] = cph->OrbitalTime; + calib.ttime[s][inter] = (UInt_t)cph->OrbitalTime; inter++; } else { if ( ce->cstwerr[s] != 0 && ce->cperror[s] != 0 ) { @@ -5777,7 +6537,7 @@ tr->GetEntry(ci); cph = ceh->GetPscuHeader(); //if ( atime == cph->GetOrbitalTime()){ - if ( atime == cph->OrbitalTime){ + if ( atime == (UInt_t)cph->OrbitalTime){ // calib.iev = ce->iev; if (ce->cstwerr[s] != 0 && ce->cperror[s] == 0 ) { for ( Int_t d=0 ; d<11 ;d++ ){