23 const double pi=3.14159265358979323846;
28 TTileTripReader::TTileTripReader(
const char*
name)
66 if(eta!=-99.9 && phi!=-99.9)
70 (
unsigned int)
event));
76 if(phi>
pi)phi=phi-2*
pi;
79 size_t ntrips=trips.size();
80 for(
size_t i=0;
i<ntrips;++
i){
83 double dx2=
pow(eta-
x,2);
85 double deltaR12 = fabs(phi -
y);
87 deltaR12 = 2.0 *
pi - deltaR12;
88 double dy2=
pow(deltaR12,2);
91 tripArea+=0.1*
width/4.;
95 double jetArea=
pi*dR*dR;
96 return tripArea/jetArea;
109 int nTrees=((TChain*)
m_trips)->GetNtrees();
111 int mapentries=
m_runMap->GetEntries();
112 for(
int i=0;
i<mapentries;++
i){
119 msg<<
"Searching for "<<findRun<<
" starting from "<<
124 while(
m_Run!=findRun){
125 if(!
m_trips->GetEntry(tripEntry)){
126 msg<<
"Overshot the end of the TTree!\n";
136 m_trips->SetBranchStatus(
"*",0);
140 TTree* currentTree=
m_trips->GetTree();
144 m_trips->SetBranchStatus(
"*",1);
150 size_t ntrips=tripRegions.size();
151 if(phi>
pi)phi=phi-2.*
pi;
153 msg<<
"Checking region eta= "<<eta<<
", phi="<<phi<<
" for run "<<
run<<
157 for(
size_t i=0;
i<ntrips;++
i){
158 if(tripRegions[
i].
eta1==0 || tripRegions[
i].
eta1==-0.9){
164 double deltaR12 = fabs(phi - tripPhiCenter);
166 deltaR12 = 2.0 *
pi - deltaR12;
179 double deltaR12 = fabs(phi - tripPhiCenter);
181 deltaR12 = 2.0 *
pi - deltaR12;
196 msg<<
"Checking bad event for run= "<<
run<<
", lbn="<<lbn<<
" event "<<
201 map<unsigned short,unsigned int>&
lumi=(*itr).second;
203 if(litr!=
lumi.end()){
206 msg<<
"run= "<<
run<<
", lbn="<<lbn<<
" event "<<
207 event<<
" pass check = "<<(
evt!=
event)<<endl;
212 msg<<
"run= "<<
run<<
", lbn="<<lbn<<
" event "<<
213 event<<
" pass check = "<<
true<<endl;
218 msg<<
"run= "<<
run<<
", lbn="<<lbn<<
" event "<<
219 event<<
" pass check = "<<
true<<endl;
227 size_t ntrips=tripRegions.size();
228 if(phi>
pi)phi=phi-2.*
pi;
230 msg<<
"Checking region eta= "<<eta<<
", phi="<<phi<<
" for run "<<
run<<
233 for(
size_t i=0;
i<ntrips;++
i){
235 double dPhi=tripRegions[
i].phi2+delPhi-tripRegions[
i].phi1+delPhi;
237 double tripPhiCenter=fabs(
dPhi+tripRegions[
i].phi1-delPhi) <=
pi ?
238 dPhi+tripRegions[
i].phi1-delPhi : tripRegions[
i].phi2+delPhi -
dPhi;
239 double deltaR12 = fabs(phi - tripPhiCenter);
241 deltaR12 = 2.0 *
pi - deltaR12;
243 if(tripRegions[
i].
eta1-delEta<=eta && tripRegions[
i].
eta2+delEta>=eta &&
244 tripRegions[
i].phi1-delPhi<=phi && tripRegions[
i].phi2+delPhi>=phi )
265 for(
size_t i=0;
i<nOffsets;++
i){
273 msg<<
"Problem! Can't find proper offset\n";
276 int offIdx=
m_runMap->GetTreeNumber();
282 msg<<
"Problem! Can't find proper offset\n";
309 msg<<
"Trip list for run "<<
run<<endl;
313 msg<<
" Run returned = "<<
m_Run<<endl;
318 size_t ntrips=lbend.size();
319 for(
size_t i=0;
i<ntrips;++
i){
321 setfill(
'0')<<setw(2)<<(
int)
mod[
i]+1<<setw(4)<<
337 msg<<
"Trip regions found for run "<<
run<<
" lbn "<<lbn<<endl;
339 for(
size_t i=0;
i<ntrips;++
i){
350 vector<TripRegion> emptyTrips;
351 msg<<
"Run not contained in chain!\n";
358 msg<<
"Generating trip regions found for run "<<
run<<
" lbn "<<lbn<<
362 msg<<
"Run not contained in trip chain!\n";
369 size_t ntrips=lbend.size();
371 for(
size_t i=0;
i<ntrips;++
i){
375 msg<<tripRegions.back().eta1<<
" <= eta <= "<<
376 tripRegions.back().eta2<<endl<<
" "<<
377 tripRegions.back().phi1<<
" <= phi <= "<<
378 tripRegions.back().phi2<<endl;
386 msg<<
"Run not contained in trip chain!\n";
396 m_accept.
addCut(
"InTrip",
"true if eta phi fall inside a powered off module");
403 TChain* tripMap=(TChain*)
m_trips;
405 m_trips=
new TTree(
"TripList_Mem",
"Memory loaded TripList");
406 m_runMap=
new TTree(
"RunMap_Mem",
"Starting entry for each run in TripList");
422 while(runMap->GetEntry(
entry)){
427 while(tripMap->GetEntry(
entry)){
458 msg<<
"Bad partition value passed!\n";
474 msg<<
"Bad module value passed!\n";
489 " region "<<region.
eta1<<
" <= eta <= "<<region.
eta2<<
" "<<
490 region.
phi1<<
" <= phi <= "<<region.
phi2<<endl;
501 if(tileError!=1)
return;
505 msg<<
"Total masked before reading tileFlags = "<<ntrips<<endl;
511 int consecBad = (tileFlags>>16) & 0xF;
512 int badMod1 = (tileFlags>>20) & 0x3F;
513 int badMod2= (badMod1 + consecBad - 1);
514 int part = ((tileFlags>>26) & 0x3);
518 greaterMod=badMod2-64;
522 int currentMod=badMod1;
523 while(currentMod<=badMod2){
526 bool inDCSlist=
false;
527 for(
size_t i=0;
i<ntrips;++
i){
545 msg<<
"Read masked module "<<
partition[
part]<<setfill(
'0')<<setw(2)<<currentMod+1<<
546 " region "<<
trip.eta1<<
" <= eta <= "<<
trip.eta2<<
" "<<
547 trip.phi1<<
" <= phi <= "<<
trip.phi2<<endl;
555 msg<<
"Total masked after reading tileFlags = "<<ntrips<<endl;
556 for(
size_t i=0;
i<ntrips;++
i){
558 msg<<
"Region "<<
i<<
" "<<
trip.eta1<<
" <= eta <= "<<
trip.eta2<<
" "<<
559 trip.phi1<<
" <= phi <= "<<
trip.phi2<<endl;
563 if(greaterMod<0)
return;
565 while(currentMod<=greaterMod){
568 bool inDCSlist=
false;
569 for(
size_t i=0;
i<ntrips;++
i){
587 msg<<
"Read masked module "<<
partition[
part]<<setfill(
'0')<<setw(2)<<currentMod+1<<
588 " region "<<
trip.eta1<<
" <= eta <= "<<
trip.eta2<<
" "<<
589 trip.phi1<<
" <= phi <= "<<
trip.phi2<<endl;
597 msg<<
"Total masked after reading tileFlags = "<<ntrips<<endl;
598 for(
size_t i=0;
i<ntrips;++
i){
600 msg<<
"Region "<<
i<<
" "<<
trip.eta1<<
" <= eta <= "<<
trip.eta2<<
" "<<
601 trip.phi1<<
" <= phi <= "<<
trip.phi2<<endl;
609 msg<<
"ERROR: Cannot add more trip files to the chain after you have closed the file and loaded it into memory!\n";
612 int files_connected=0;
615 msg<<
"Connected file missmatch.\n";
633 return files_connected;