CDF II
CDF KITS
source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Architecture: i386 ]
Version: 4.10.4 ] [ 4.10.5 ] [ 4.8.4 ] [ 4.8.4l3s ] [ 4.8.5 ] [ 4.9.0 ] [ 4.9.1 ] [ 4.9.1.hpt3 ] [ 4.9.1hpt3 ] [ 4.9.1top1 ] [ 5.0.0 ] [ 5.1.0 ] [ 5.1.0beamonly ] [ 5.1.1 ] [ 5.2.0 ] [ 5.3.0 ] [ 5.3.1 ] [ 5.3.1dsp ] [ 5.3.3 ] [ 5.3.3_nt ] [ 5.3.4 ] [ 6.1.1 ] [ 6.1.1b ] [ 6.1.2 ] [ 6.1.3 ] [ 6.1.4 ] [ 6.1.4int3 ] [ 6.1.4mc ] [ 6.1.4mc_a ] [ 6.1.6 ] [ development ]

001 
002 //_____________________________________________________________________________
003 // Module to fit reconstructed top events to parameterized templates
004 //_____________________________________________________________________________
005 
006 
007 #include <iostream>
008 
009 #include "xftsim_only.hh"
010 #include "TObjectTable.h"
011 #include "Helix.hh"
012 //#include "XFTSimRoot.hh"
013 #include "TLorentzVector.h"
014 using namespace std;
015 
016         float konst = 0.00014989*14.116;
017         float halfpi = 0.5*3.14159;
018         float twopi = 2.0*3.14159;
019         float speedLight = 29.98;     // Speed of light in cm/nsec
020 
021     float OFFPT_THRESHOLD = 1.5;
022     float OFFPT_MINIMUM = 1.2;
023 // wire variables...
024         int nsn = 12;
025 //      float dwlr = 0.5*0.762;// half distance between  wires
026         float dwlr = 0.5*0.7112;
027 // Number of pixels
028         int npix_cell[] = {6,12,6,12,6,6,6,6};  
029 // Number of cells
030         /*0, 168, 192 , 240,  288  , 336,  384,  432,   480*/  
031         int ncl[] = {42*4, 48*4, 60*4, 72*4, 84*4, 96*4, 108*4, 120*4};
032         float rsns[] = {46.0, 58.534, 70.0, 82.055, 94.0, 105.575, 119.0, 129.096};
033 //      float[] rsns = {46.0, 58.0, 70.0, 82.0, 94.0, 106.0, 119.0, 131.0};
034                                         /*  .0374,             .0327        .0262          .0218*/
035         float dclw[] = {twopi/ncl[0],  twopi/ncl[1],  twopi/ncl[2],  twopi/ncl[3],
036                                                 /* .0187       .016           */
037                       twopi/ncl[4],  twopi/ncl[5],  twopi/ncl[6],  twopi/ncl[7]};
038         float pixPhi[] = {twopi/(ncl[0]*npix_cell[0]),  twopi/(ncl[1]*npix_cell[1]),  
039                                                         twopi/(ncl[2]*npix_cell[2]),  twopi/(ncl[3]*npix_cell[3]),
040                      twopi/(ncl[4]*npix_cell[4]),  twopi/(ncl[5]*npix_cell[5]),  
041                                                         twopi/(ncl[6]*npix_cell[6]),  twopi/(ncl[7]*npix_cell[7])};
042 
043 
044         float ang = 35.0 * twopi / 360.0; /* .61 */
045         float drift = 0.0088;       // drift = 100 microns/nsec
046         float phz0 = 0.0;
047 // These variables set constants for the XFT
048         float wireEfficiency = 1.00;
049         float promptTime = 44.0;
050         float delayedTime = 88.0;
051         float cutoffTime = 132.0;
052 
053     int nfid = 0;
054     int nfid_matched = 0;
055     int index_match = 0;
056   int nlink;
057   int nlink3;
058   int numPix[4][3];
059 
060 //_____________________________________________________________________________
061 xftsim::~xftsim() {
062 }
063 //_____________________________________________________________________________
064 xftsim::xftsim(){
065    debug = false;
066    getTrig = true;
067    cotd_input = true;
068 }
069 
070 
071 //______________________________________________________________________________
072 void xftsim::Ana()
073 {
074 int prt = 0;
075 //
076 // Setup the COT constancts
077    setCOTconstants();
078 
079    // Running 
080   doxhit = true;
081   doxtrk = true;
082   dootrk = true;
083 
084 
085   checkSimDataHits = false;  // 1st - looks for cell disagreement between sim and data
086   findDisagreeSimData = false;  // 2nd - finds agreement between predefined hits
087 
088   int maxEvPrint = 10;
089 //
090 // Get the number of entries. 
091    Int_t nentries = Int_t(mytree->fChain->GetEntries());
092    printf("Total number of entries: %d\n",nentries);
093    printf("Total number of events to loop over: %d\n",topNumEvents);fflush(stdout);
094 //
095 // Are the nnumber of events to analyze restricted?
096    if ((topNumEvents > 0) && (topNumEvents <= nentries)) {
097       nentries = topNumEvents;
098    }
099 
100    //   getTrig = true;
101 //
102 // Look for the Jet 20 trigger
103 //   GetTriggerBitL1("JET_20");
104 //   GetTriggerBitL2("JET_20");
105    TString names[19] = {"JET_20","JET_50","JET_70","JET_100","DIPHOTON",
106                   "TWO_JET","NOTRACK","DIFF","MULTI_JET",
107                   "MINBIAS","MET45","MET_PEM","MET_L3",
108                   "DIJET","PHOTON_10","PHOTON_15",
109                   "PHOTON_25_ISO_v7","ULTRA","TRIPHO"};
110    //   if (getTrig) GetTriggerBitL3(19,names);
111 //   if (getTrig) GetTriggerBitL3("JET_50");
112    
113 
114    printf("Making XFTSys\n");fflush(stdout);
115    //XFTSim *myXftSim = new XFTSim(mytree);
116    myXftSim = new XFTSim(mytree);
117    myXftSim->setDataFlag(dataFlag);
118    myXftSim->setShift(shift_flag);
119    myXftSim->setBrdShift(startBrdShiftDB);
120    myXftSim->setMinHits(minHitsReqDB);
121    myXftSim->setCotdInput(cotd_input);
122    printf("Done making XFTSys\n");fflush(stdout);
123    myXftSim->beginJob();
124    myXftSim->beginRun();
125    
126    Int_t nbytes = 0, nb = 0;
127 
128    int lastRunNumber = -999;
129    
130    //------------------------------------------------------------------------
131    //   DeadWireInputVal = 1   Needs to be run just once to generate
132    //    deadwire list for a given run
133    //        It will get a list of run numbers, 
134    //      then will run script XFTSimRoot/getDeadWireLists.tcsh
135    //      if sqlplus is available
136    //------------------------------------------------------------------------
137    if (DeadWireInputVal == 1) {
138     char pathRuns[200];
139     sprintf(pathRuns,"%s/XFTSim/root/runs.txt",getenv("PROJECT_DIR"));
140     FILE *runs = fopen(pathRuns,"w");
141     for (Int_t jentry=0; jentry<nentries;jentry++) {
142       nEvents++;
143       if (nEvents%100 == 0) {printf("Now at entry %d\n",jentry);fflush(stdout);}
144       LoadData(jentry);
145        nbytes += nb;
146        if (mytree->evt_runNumber[0] != lastRunNumber) {
147          lastRunNumber = mytree->evt_runNumber[0];
148          fprintf(runs,"%d\n",lastRunNumber);
149        }
150      }
151      fclose(runs);
152      exit(1);
153    }  // DeadWireInputVal = 1
154 
155    // If you have a deadwire file you are confident in,  you can load its run number 
156    if (DeadWireInputVal > 2) {
157      int runNumberDeadWireList = DeadWireInputVal;
158      myXftSim->setBadWireRun(runNumberDeadWireList);
159    }
160 
161 
162    //--------------------
163    //   EVENT LOOP
164    //--------------------
165   for (Int_t jentry=0; jentry<nentries;jentry++) {
166 //
167                 nEvents++;
168         if (nEvents%100 == 0) {printf("Now at Loop entry %d\n",jentry);fflush(stdout);}
169 //
170       // Get the info from each data block for this entry
171                 LoadData(jentry);
172       nbytes += nb;
173       if (debug) { cout << " Loaded Data " << endl; fflush(stdout); }
174       if (getTrig) {
175         if (mytree->evt_runNumber[0] != lastRunNumber) {
176           // Get list of triggers
177           GetTriggerBitL3Run(19,names);
178           lastRunNumber = mytree->evt_runNumber[0];
179           cout << " New Run number detected " << lastRunNumber << endl; 
180           if (DeadWireInputVal == 2) {
181             myXftSim->setBadWireRun(lastRunNumber);
182           }
183         }
184       }
185 
186 //
187 // Send hits to xftsim
188       myXftSim->event();
189       
190    } // loop nentries
191 } // Ana()
192 
193 
194 //_____________________________________________________________________________
195 void xftsim::BeginJob() {
196 //
197 // Initialization
198 //
199 // Initialization
200    maxRunNumbers = 1000;
201    totalRunNumbers = 0;
202    totalRunNumbersL1 = 0;
203    totalRunNumbersL2 = 0;
204    totalRunNumbersL3 = 0;
205 //
206 // Define Histos        
207 
208   //
209   // Read in the road database for 4 layer roads
210   char filename[200];
211   sprintf(filename,"%s/%s",
212           getenv("PROJECT_DIR"),
213           "/XFTSim/XFTDatabase/Linker4LayerRoads_090099.dat");
214   roadFile(filename);
215   //
216   // Read in the road database for 3 layer roads
217   char filename3[200];
218   sprintf(filename3,"%s/%s",
219           getenv("PROJECT_DIR"),
220           "/XFTSim/XFTDatabase/Linker3LayerRoads_050100.dat");
221   road3File(filename3);
222        
223 
224   // Read in the cot database
225   char filenameCOT[200];
226   sprintf(filenameCOT,"%s/%s",
227           getenv("PROJECT_DIR"),
228           "/XFTSim/XFTDatabase/xft_cot_geom.dat");
229   cotGeom(filenameCOT);
230 
231 
232    //
233    //   Here set the wires to check in cot, xft sim, and xft data
234    //
235    bSL[0] = 1;  bC[0] = 89;  bW[0] = 10;   // these wires had lots of hits in data 
236    bSL[1] = 1;  bC[1] = 89;  bW[1] = 11;   // but none in simulation
237    bSL[2] = 1;  bC[2] = 90;  bW[2] = 2; 
238    bSL[3] = 1;  bC[3] = 90;  bW[3] = 4; 
239    bSL[4] = 2;  bC[4] = 74;  bW[4] = 0; 
240    bSL[5] = 3;  bC[5] = 165;  bW[5] = 2; 
241    bSL[6] = 3;  bC[6] = 54;  bW[6] = 0; 
242    bSL[7] = 4;  bC[7] = 326;  bW[7] = 2; 
243 
244    bSL[8] = 2;  bC[8] = 94;  bW[8] = 11;  // these wires had lots of hits in simulation
245    bSL[9] = 3;  bC[9] = 300;  bW[9] = 9;  // but none in data
246    bSL[10] = 4;  bC[10] = 16;  bW[10] = 7; 
247    bSL[11] = 4;  bC[11] = 18;  bW[11] = 10; 
248    bSL[12] = 4;  bC[12] = 152;  bW[12] = 9; 
249    bSL[13] = 4;  bC[13] = 263;  bW[13] = 4; 
250    bSL[14] = 4;  bC[14] = 332;  bW[14] = 1; 
251    bSL[15] = 4;  bC[15] = 373;  bW[15] = 0; 
252    bSL[16] = 4;  bC[16] = 409;  bW[16] = 0; 
253 
254    bSL[17] = 1;  bC[17] = 25;  bW[17] = 3;  // controls
255    bSL[18] = 2;  bC[18] = 25;  bW[18] = 3; 
256    bSL[19] = 3;  bC[19] = 25;  bW[19] = 3; 
257    bSL[20] = 4;  bC[20] = 25;  bW[20] = 3; 
258 
259 //
260 // Init
261 //
262 }
263 
264 //_____________________________________________________________________________
265 void xftsim::LoadData(int jentry) {
266    Int_t ientry;
267    Int_t nb;
268    ientry = mytree->LoadTree(jentry); //in case of a TChain, ientry is the entry number in the current file
269    sprintf(newDataFileName,"%s",mytree->fChain->GetCurrentFile()->GetName());
270    TString aTry = mytree->fChain->GetCurrentFile()->GetName();
271    TString aDir = mytree->fChain->GetDirectory()->GetName();
272    int compare = aTry.CompareTo(newDataFileName);
273    // when this is 1, it is a new file
274    compare = aTry.CompareTo(oldDataFileName);
275    if (compare == 1) {
276      // call switch file method for simulation
277      myXftSim->switchSimFile(aTry);
278    }
279    sprintf(oldDataFileName,"%s",aTry.Data());
280    nb = mytree->fChain->GetEntry(jentry);   
281 }
282 
283 //_____________________________________________________________________________
284 void xftsim::setInputFile(const char* fname) {
285 //
286         if (inputFiles == 0) {
287 //
288       const Text_t* ffname = fname;
289       printf("Setting initial input file: %s\n",ffname);
290       mytree = new topTree(ffname);
291                 mytree->fChain->Add(ffname);
292    } else {
293       printf("Adding input file: %s\n",fname);
294                 mytree->fChain->Add(fname);
295    }
296    inputFiles++;
297 //
298 }
299 //_____________________________________________________________________________
300 void xftsim::SetOutputHistFile(const char* name) {
301 //
302 // Make the output histogram file
303   histFile = new TFile(name,"RECREATE","test file");
304 //
305 }
306 
307 
308 //_____________________________________________________________________________
309 void xftsim::EndJob() {
310 //
311 
312 // Now close the histogram file
313    histFile->Write();
314    histFile->Close();
315 
316    myXftSim->endJob();
317 
318 }
319 
320 
321 //---------------------------------------------------------------------------------------------
322 // CONVERT XFT PT BIN TO A VALUE IN GeV/c.
323 //  Apply corrections for shifted beamspot here if necessary.
324 
325 void xftsim::cotGeom(char* pathName)
326 {
327   // Setup the Input file Stream
328   // ---------------------------
329   std::ifstream f1(pathName);
330 
331 
332   // Read in the header pixels per cell for each layer
333   // -------------------------------------------------
334   float rtemp1,rtemp2,rtemp3,rtemp4,rtemp5;
335   int itemp1,itemp2,itemp3;
336   for(int sl=0; sl < 8; sl++)
337     {
338       for(int wire=0; wire<12; wire++) {
339         f1 >> itemp1
340            >> itemp2
341            >> itemp3
342            >> rtemp1
343            >> rtemp2
344            >> rtemp3
345            >> wire_r[sl][wire]
346            >> wire_phi[sl][wire]
347            >> rtemp4
348            >> rtemp5;
349         printf("sl %i wire %i radius %f phi %f\n",sl,wire,
350                wire_r[sl][wire],
351                wire_phi[sl][wire]);
352         //            printf(" %i %i %i %f %f %f %f %f %f %f \n",
353         //         sl,cell,wire,x,y,r,lrad,phi,dlwr,delphi);
354         
355         }
356     }
357   f1.close();
358 }//End method
359 
360 
361 
362 
363 
364 
365 void xftsim::setCOTconstants() {
366 
367 // Drift Speed:  0.005100
368 // Signal Speed: 29.000000
369 // Tilt Angle:   0.610865
370 // SL 0  Radius: 46.449984  Tilt  0.611058
371 // SL 1  Radius: 58.509000  Tilt  0.611034
372 // SL 2  Radius: 70.063649  Tilt  0.611085
373 // SL 3  Radius: 82.054100  Tilt  0.611152
374 // SL 4  Radius: 93.677196  Tilt  0.611195
375 // SL 5  Radius: 105.593500  Tilt  0.611264
376 // SL 6  Radius: 117.249798  Tilt  0.611376
377 // SL 7  Radius: 129.123600  Tilt  0.611516
378 // 0 0 0 43.244937 -2.279069 43.304951 43.323341 -0.052653 0.000000 0.000000
379   wire_x[0][0]=43.244937;
380   wire_y[0][0]=-2.279069;
381   wire_r[0][0]=43.323341;
382   wire_phi[0][0]=-0.052653;
383 // 0 0 1 43.827440 -1.871029 43.867359 43.882784 -0.042665 0.711200 0.611058
384   wire_x[0][1]=43.827440;
385   wire_y[0][1]=-1.871029;
386   wire_r[0][1]=43.882784;
387   wire_phi[0][1]=-0.042665;
388   // 0 0 2 44.409942 -1.462989 44.434033 44.446422 -0.032931 0.711200 0.611058
389   wire_x[0][2]=44.409942;
390   wire_y[0][2]=-1.462989;
391   wire_r[0][2]=44.446422;
392   wire_phi[0][2]=-0.032931;
393   // 0 0 3 44.992444 -1.054950 45.004810 45.014099 -0.023443 0.711200 0.611058
394   wire_x[0][3]=44.992444;
395   wire_y[0][3]=-1.054950;
396   wire_r[0][3]=45.014099;
397   wire_phi[0][3]=-0.023443;
398   // 0 0 4 45.574947 -0.646910 45.579538 45.585663 -0.014193 0.711200 0.611058
399   wire_x[0][4]=45.574947;
400   wire_y[0][4]=-0.646910;
401   wire_r[0][4]=45.585663;
402   wire_phi[0][4]=-0.014193;
403   // 0 0 5 46.157449 -0.238870 46.158067 46.160970 -0.005175 0.711200 0.611058
404   wire_x[0][5]=46.157449;
405   wire_y[0][5]=-0.238870;
406   wire_r[0][5]=46.160970;
407   wire_phi[0][5]=-0.005175;
408   // 0 0 6 46.739951 0.169170 46.740257 46.739883 0.003619 0.711200 0.611058
409   wire_x[0][6]=46.739951;
410   wire_y[0][6]=0.169170;
411   wire_r[0][6]=46.739883;
412   wire_phi[0][6]=0.003619;
413   // 0 0 7 47.322453 0.577210 47.325974 47.322267 0.012197 0.711200 0.611058
414   wire_x[0][7]=47.322453;
415   wire_y[0][7]=0.577210;
416   wire_r[0][7]=47.322267;
417   wire_phi[0][7]=0.012197;
418   // 0 0 8 47.904956 0.985250 47.915086 47.907998 0.020564 0.711200 0.611058
419   wire_x[0][8]=47.904956;
420   wire_y[0][8]=0.985250;
421   wire_r[0][8]=47.907998;
422   wire_phi[0][8]=0.020564;
423   // 0 0 9 48.487458 1.393289 48.507472 48.496954 0.028727 0.711200 0.611058
424   wire_x[0][9]=48.487458;
425   wire_y[0][9]=1.393289;
426   wire_r[0][9]=48.496954;
427   wire_phi[0][9]=0.028727;
428   // 0 0 10 49.069960 1.801329 49.103012 49.089018 0.036693 0.711200 0.611058
429   wire_x[0][10]=49.069960;
430   wire_y[0][10]=1.801329;
431   wire_r[0][10]=49.089018;
432   wire_phi[0][10]=0.036693;
433   // 0 0 11 49.652463 2.209369 49.701593 49.684080 0.044467 0.711200 0.611058
434   wire_x[0][11]=49.652463;
435   wire_y[0][11]=2.209369;
436   wire_r[0][11]=49.684080;
437   wire_phi[0][11]=0.044467;
438   //  Radius of Sl 0 is 46.449162
439   // 1 0 0 55.305084 -2.278042 55.351980 55.350295 -0.041167 0.000000 0.000000
440   wire_x[1][0]=55.305084;
441   wire_y[1][0]=-2.278042;
442   wire_r[1][0]=55.350295;
443   wire_phi[1][0]=-0.041167;
444   // 1 0 1 55.887596 -1.870016 55.918873 55.917525 -0.033448 0.711200 0.611034
445   wire_x[1][1]=55.887596;
446   wire_y[1][1]=-1.870016;
447   wire_r[1][1]=55.917525;
448   wire_phi[1][1]=-0.033448;
449   // 1 0 2 56.470108 -1.461991 56.489030 56.488013 -0.025884 0.711200 0.611034
450   wire_x[1][2]=56.470108;
451   wire_y[1][2]=-1.461991;
452   wire_r[1][2]=56.488013;
453   wire_phi[1][2]=-0.025884;
454   // 1 0 3 57.052620 -1.053965 57.062354 57.061662 -0.018471 0.711200 0.611034
455   wire_x[1][3]=57.052620;
456   wire_y[1][3]=-1.053965;
457   wire_r[1][3]=57.061662;
458   wire_phi[1][3]=-0.018471;
459   // 1 0 4 57.635132 -0.645939 57.638751 57.638377 -0.011207 0.711200 0.611034
460   wire_x[1][4]=57.635132;
461   wire_y[1][4]=-0.645939;
462   wire_r[1][4]=57.638377;
463   wire_phi[1][4]=-0.011207;
464   // 1 0 5 58.217644 -0.237913 58.218130 58.218067 -0.004087 0.711200 0.611034
465   wire_x[1][5]=58.217644;
466   wire_y[1][5]=-0.237913;
467   wire_r[1][5]=58.218067;
468   wire_phi[1][5]=-0.004087;
469   // 1 0 6 58.800156 0.170113 58.800402 58.800644 0.002893 0.711200 0.611034
470   wire_x[1][6]=58.800156;
471   wire_y[1][6]=0.170113;
472   wire_r[1][6]=58.800644;
473   wire_phi[1][6]=0.002893;
474   // 1 0 7 59.382668 0.578139 59.385482 59.386024 0.009736 0.711200 0.611034
475   wire_x[1][7]=59.382668;
476   wire_y[1][7]=0.578139;
477   wire_r[1][7]=59.386024;
478   wire_phi[1][7]=0.009736;
479   // 1 0 8 59.965180 0.986165 59.973289 59.974124 0.016444 0.711200 0.611034
480   wire_x[1][8]=59.965180;
481   wire_y[1][8]=0.986165;
482   wire_r[1][8]=59.974124;
483   wire_phi[1][8]=0.016444;
484   // 1 0 9 60.547692 1.394191 60.563742 60.564864 0.023022 0.711200 0.611034
485   wire_x[1][9]=60.547692;
486   wire_y[1][9]=1.394191;
487   wire_r[1][9]=60.564864;
488   wire_phi[1][9]=0.023022;
489   // 1 0 10 61.130204 1.802216 61.156765 61.158169 0.029473 0.711200 0.611034
490   wire_x[1][10]=61.130204;
491   wire_y[1][10]=1.802216;
492   wire_r[1][10]=61.158169;
493   wire_phi[1][10]=0.029473;
494   // 1 0 11 61.712716 2.210242 61.752284 61.753965 0.035800 0.711200 0.611034
495   wire_x[1][11]=61.712716;
496   wire_y[1][11]=2.210242;
497   wire_r[1][11]=61.753965;
498   wire_phi[1][11]=0.035800;
499   //  Radius of Sl 1 is 58.509266
500   // 2 0 0 66.860904 -2.274414 66.899577 66.906728 -0.034004 0.000000 0.000000
501   wire_x[2][0]=66.860904;
502   wire_y[2][0]=-2.274414;
503   wire_r[2][0]=66.906728;
504   wire_phi[2][0]=-0.034004;
505   // 2 0 1 67.443394 -1.866357 67.469213 67.474938 -0.027666 0.711200 0.611088
506   wire_x[2][1]=67.443394;
507   wire_y[2][1]=-1.866357;
508   wire_r[2][1]=67.474938;
509   wire_phi[2][1]=-0.027666;
510   // 2 0 2 68.025884 -1.458300 68.041513 68.045790 -0.021434 0.711200 0.611087
511   wire_x[2][2]=68.025884;
512   wire_y[2][2]=-1.458300;
513   wire_r[2][2]=68.045790;
514   wire_phi[2][2]=-0.021434;
515   // 2 0 3 68.608374 -1.050243 68.616412 68.619219 -0.015307 0.711200 0.611088
516   wire_x[2][3]=68.608374;
517   wire_y[2][3]=-1.050243;
518   wire_r[2][3]=68.619219;
519   wire_phi[2][3]=-0.015307;
520   // 2 0 4 69.190865 -0.642186 69.193845 69.195161 -0.009281 0.711200 0.611088
521   wire_x[2][4]=69.190865;
522   wire_y[2][4]=-0.642186;
523   wire_r[2][4]=69.195161;
524   wire_phi[2][4]=-0.009281;
525   // 2 0 5 69.773355 -0.234129 69.773748 69.773553 -0.003356 0.711200 0.611088
526   wire_x[2][5]=69.773355;
527   wire_y[2][5]=-0.234129;
528   wire_r[2][5]=69.773553;
529   wire_phi[2][5]=-0.003356;
530   // 2 0 6 70.355845 0.173929 70.356060 70.354336 0.002472 0.711200 0.611087
531   wire_x[2][6]=70.355845;
532   wire_y[2][6]=0.173929;
533   wire_r[2][6]=70.354336;
534   wire_phi[2][6]=0.002472;
535   // 2 0 7 70.938335 0.581986 70.940723 70.937450 0.008204 0.711200 0.611088
536   wire_x[2][7]=70.938335;
537   wire_y[2][7]=0.581986;
538   wire_r[2][7]=70.937450;
539   wire_phi[2][7]=0.008204;
540   // 2 0 8 71.520826 0.990043 71.527678 71.522838 0.013842 0.711200 0.611088
541   wire_x[2][8]=71.520826;
542   wire_y[2][8]=0.990043;
543   wire_r[2][8]=71.522838;
544   wire_phi[2][8]=0.013842;
545   // 2 0 9 72.103316 1.398100 72.116869 72.110446 0.019388 0.711200 0.611088
546   wire_x[2][9]=72.103316;
547   wire_y[2][9]=1.398100;
548   wire_r[2][9]=72.110446;
549   wire_phi[2][9]=0.019388;
550   // 2 0 10 72.685806 1.806157 72.708243 72.700218 0.024844 0.711200 0.611087
551   wire_x[2][10]=72.685806;
552   wire_y[2][10]=1.806157;
553   wire_r[2][10]=72.700218;
554   wire_phi[2][10]=0.024844;
555   // 2 0 11 73.268296 2.214214 73.301746 73.292104 0.030211 0.711200 0.611088
556   wire_x[2][11]=73.268296;
557   wire_y[2][11]=2.214214;
558   wire_r[2][11]=73.292104;
559   wire_phi[2][11]=0.030211;
560   //  Radius of Sl 2 is 70.064904
561   // 3 0 0 78.852748 -2.271370 78.885455 78.881818 -0.028797 0.000000 0.000000
562   wire_x[3][0]=78.852748;
563   wire_y[3][0]=-2.271370;
564   wire_r[3][0]=78.881818;
565   wire_phi[3][0]=-0.028797;
566   // 3 0 1 79.435212 -1.863276 79.457062 79.453694 -0.023452 0.711200 0.611152
567   wire_x[3][1]=79.435212;
568   wire_y[3][1]=-1.863276;
569   wire_r[3][1]=79.453694;
570   wire_phi[3][1]=-0.023452;
571   // 3 0 2 80.017676 -1.455181 80.030907 80.027804 -0.018184 0.711200 0.611152
572   wire_x[3][2]=80.017676;
573   wire_y[3][2]=-1.455181;
574   wire_r[3][2]=80.027804;
575   wire_phi[3][2]=-0.018184;
576   // 3 0 3 80.600140 -1.047087 80.606941 80.604099 -0.012990 0.711200 0.611152
577   wire_x[3][3]=80.600140;
578   wire_y[3][3]=-1.047087;
579   wire_r[3][3]=80.604099;
580   wire_phi[3][3]=-0.012990;
581   // 3 0 4 81.182604 -0.638992 81.185119 81.182535 -0.007871 0.711200 0.611152
582   wire_x[3][4]=81.182604;
583   wire_y[3][4]=-0.638992;
584   wire_r[3][4]=81.182535;
585   wire_phi[3][4]=-0.007871;
586   // 3 0 5 81.765068 -0.230897 81.765394 81.763064 -0.002824 0.711200 0.611152
587   wire_x[3][5]=81.765068;
588   wire_y[3][5]=-0.230897;
589   wire_r[3][5]=81.763064;
590   wire_phi[3][5]=-0.002824;
591   // 3 0 6 82.347532 0.177197 82.347723 82.345643 0.002152 0.711200 0.611152
592   wire_x[3][6]=82.347532;
593   wire_y[3][6]=0.177197;
594   wire_r[3][6]=82.345643;
595   wire_phi[3][6]=0.002152;
596   // 3 0 7 82.929996 0.585292 82.932061 82.930229 0.007058 0.711200 0.611152
597   wire_x[3][7]=82.929996;
598   wire_y[3][7]=0.585292;
599   wire_r[3][7]=82.930229;
600   wire_phi[3][7]=0.007058;
601   // 3 0 8 83.512460 0.993387 83.518368 83.516779 0.011895 0.711200 0.611152
602   wire_x[3][8]=83.512460;
603   wire_y[3][8]=0.993387;
604   wire_r[3][8]=83.516779;
605   wire_phi[3][8]=0.011895;
606   // 3 0 9 84.094924 1.401481 84.106601 84.105253 0.016664 0.711200 0.611152
607   wire_x[3][9]=84.094924;
608   wire_y[3][9]=1.401481;
609   wire_r[3][9]=84.105253;
610   wire_phi[3][9]=0.016664;
611   // 3 0 10 84.677388 1.809576 84.696721 84.695610 0.021367 0.711200 0.611152
612   wire_x[3][10]=84.677388;
613   wire_y[3][10]=1.809576;
614   wire_r[3][10]=84.695610;
615   wire_phi[3][10]=0.021367;
616   // 3 0 11 85.259852 2.217670 85.288688 85.287811 0.026005 0.711200 0.611152
617   wire_x[3][11]=85.259852;
618   wire_y[3][11]=2.217670;
619   wire_r[3][11]=85.287811;
620   wire_phi[3][11]=0.026005;
621   //  Radius of Sl 3 is 82.056558
622   // 4 0 0 90.475547 -2.270411 90.504030 90.505768 -0.025089 0.000000 0.000000
623   wire_x[4][0]=90.475547;
624   wire_y[4][0]=-2.270411;
625   wire_r[4][0]=90.505768;
626   wire_phi[4][0]=-0.025089;
627   // 4 0 1 91.057993 -1.862291 91.077035 91.078149 -0.020449 0.711200 0.611196
628   wire_x[4][1]=91.057993;
629   wire_y[4][1]=-1.862291;
630   wire_r[4][1]=91.078149;
631   wire_phi[4][1]=-0.020449;
632   // 4 0 2 91.640439 -1.454171 91.651976 91.652457 -0.015867 0.711200 0.611196
633   wire_x[4][2]=91.640439;
634   wire_y[4][2]=-1.454171;
635   wire_r[4][2]=91.652457;
636   wire_phi[4][2]=-0.015867;
637   // 4 0 3 92.222885 -1.046051 92.228817 92.228656 -0.011342 0.711200 0.611196
638   wire_x[4][3]=92.222885;
639   wire_y[4][3]=-1.046051;
640   wire_r[4][3]=92.228656;
641   wire_phi[4][3]=-0.011342;
642   // 4 0 4 92.805331 -0.637930 92.807524 92.806710 -0.006874 0.711200 0.611196
643   wire_x[4][4]=92.805331;
644   wire_y[4][4]=-0.637930;
645   wire_r[4][4]=92.806710;
646   wire_phi[4][4]=-0.006874;
647   // 4 0 5 93.387777 -0.229810 93.388060 93.386586 -0.002461 0.711200 0.611196
648   wire_x[4][5]=93.387777;
649   wire_y[4][5]=-0.229810;
650   wire_r[4][5]=93.386586;
651   wire_phi[4][5]=-0.002461;
652   // 4 0 6 93.970223 0.178310 93.970392 93.968249 0.001898 0.711200 0.611196
653   wire_x[4][6]=93.970223;
654   wire_y[4][6]=0.178310;
655   wire_r[4][6]=93.968249;
656   wire_phi[4][6]=0.001898;
657   // 4 0 7 94.552669 0.586430 94.554488 94.551667 0.006202 0.711200 0.611196
658   wire_x[4][7]=94.552669;
659   wire_y[4][7]=0.586430;
660   wire_r[4][7]=94.551667;
661   wire_phi[4][7]=0.006202;
662   // 4 0 8 95.135115 0.994551 95.140313 95.136806 0.010454 0.711200 0.611196
663   wire_x[4][8]=95.135115;
664   wire_y[4][8]=0.994551;
665   wire_r[4][8]=95.136806;
666   wire_phi[4][8]=0.010454;
667   // 4 0 9 95.717561 1.402671 95.727838 95.723636 0.014653 0.711200 0.611196
668   wire_x[4][9]=95.717561;
669   wire_y[4][9]=1.402671;
670   wire_r[4][9]=95.723636;
671   wire_phi[4][9]=0.014653;
672   // 4 0 10 96.300007 1.810791 96.317030 96.312126 0.018801 0.711200 0.611196
673   wire_x[4][10]=96.300007;
674   wire_y[4][10]=1.810791;
675   wire_r[4][10]=96.312126;
676   wire_phi[4][10]=0.018801;
677   // 4 0 11 96.882453 2.218911 96.907860 96.902246 0.022899 0.711200 0.611196
678   wire_x[4][11]=96.882453;
679   wire_y[4][11]=2.218911;
680   wire_r[4][11]=96.902246;
681   wire_phi[4][11]=0.022899;
682   //  Radius of Sl 4 is 93.679226
683   // 5 0 0 102.395002 -2.266282 102.420078 102.413883 -0.022129 0.000000 0.000000
684   wire_x[5][0]=102.395002;
685   wire_y[5][0]=-2.266282;
686   wire_r[5][0]=102.413883;
687   wire_phi[5][0]=-0.022129;
688   // 5 0 1 102.977420 -1.858122 102.994182 102.988247 -0.018042 0.711200 0.611265
689   wire_x[5][1]=102.977420;
690   wire_y[5][1]=-1.858122;
691   wire_r[5][1]=102.988247;
692   wire_phi[5][1]=-0.018042;
693   // 5 0 2 103.559838 -1.449961 103.569988 103.564309 -0.014000 0.711200 0.611265
694   wire_x[5][2]=103.559838;
695   wire_y[5][2]=-1.449961;
696   wire_r[5][2]=103.564309;
697   wire_phi[5][2]=-0.014000;
698   // 5 0 3 104.142255 -1.041801 104.147466 104.142041 -0.010003 0.711200 0.611265
699   wire_x[5][3]=104.142255;
700   wire_y[5][3]=-1.041801;
701   wire_r[5][3]=104.142041;
702   wire_phi[5][3]=-0.010003;
703   // 5 0 4 104.724673 -0.633641 104.726590 104.721416 -0.006050 0.711200 0.611265
704   wire_x[5][4]=104.724673;
705   wire_y[5][4]=-0.633641;
706   wire_r[5][4]=104.721416;
707   wire_phi[5][4]=-0.006050;
708   // 5 0 5 105.307091 -0.225480 105.307332 105.302407 -0.002141 0.711200 0.611265
709   wire_x[5][5]=105.307091;
710   wire_y[5][5]=-0.225480;
711   wire_r[5][5]=105.302407;
712   wire_phi[5][5]=-0.002141;
713   // 5 0 6 105.889509 0.182680 105.889666 105.884987 0.001725 0.711200 0.611265
714   wire_x[5][6]=105.889509;
715   wire_y[5][6]=0.182680;
716   wire_r[5][6]=105.884987;
717   wire_phi[5][6]=0.001725;
718   // 5 0 7 106.471927 0.590841 106.473566 106.469130 0.005549 0.711200 0.611265
719   wire_x[5][7]=106.471927;
720   wire_y[5][7]=0.590841;
721   wire_r[5][7]=106.469130;
722   wire_phi[5][7]=0.005549;
723   // 5 0 8 107.054345 0.999001 107.059006 107.054810 0.009331 0.711200 0.611265
724   wire_x[5][8]=107.054345;
725   wire_y[5][8]=0.999001;
726   wire_r[5][8]=107.054810;
727   wire_phi[5][8]=0.009331;
728   // 5 0 9 107.636762 1.407161 107.645960 107.642002 0.013072 0.711200 0.611265
729   wire_x[5][9]=107.636762;
730   wire_y[5][9]=1.407161;
731   wire_r[5][9]=107.642002;
732   wire_phi[5][9]=0.013072;
733   // 5 0 10 108.219180 1.815322 108.234405 108.230683 0.016773 0.711200 0.611265
734   wire_x[5][10]=108.219180;
735   wire_y[5][10]=1.815322;
736   wire_r[5][10]=108.230683;
737   wire_phi[5][10]=0.016773;
738   // 5 0 11 108.801598 2.223482 108.824315 108.820826 0.020433 0.711200 0.611265
739   wire_x[5][11]=108.801598;
740   wire_y[5][11]=2.223482;
741   wire_r[5][11]=108.820826;
742   wire_phi[5][11]=0.020433;
743   //  Radius of Sl 5 is 105.598499
744   // 6 0 0 114.052953 -2.262791 114.075398 114.070677 -0.019837 0.000000 0.000000
745   wire_x[6][0]=114.052953;
746   wire_y[6][0]=-2.262791;
747   wire_r[6][0]=114.070677;
748   wire_phi[6][0]=-0.019837;
749   // 6 0 1 114.635326 -1.854565 114.650326 114.645348 -0.016177 0.711200 0.611377
750   wire_x[6][1]=114.635326;
751   wire_y[6][1]=-1.854565;
752   wire_r[6][1]=114.645348;
753   wire_phi[6][1]=-0.016177;
754   // 6 0 2 115.217698 -1.446340 115.226775 115.221535 -0.012552 0.711200 0.611377
755   wire_x[6][2]=115.217698;
756   wire_y[6][2]=-1.446340;
757   wire_r[6][2]=115.221535;
758   wire_phi[6][2]=-0.012552;
759   // 6 0 3 115.800070 -1.038114 115.804723 115.799214 -0.008964 0.711200 0.611377
760   wire_x[6][3]=115.800070;
761   wire_y[6][3]=-1.038114;
762   wire_r[6][3]=115.799214;
763   wire_phi[6][3]=-0.008964;
764   // 6 0 4 116.382442 -0.629888 116.384146 116.378364 -0.005412 0.711200 0.611377
765   wire_x[6][4]=116.382442;
766   wire_y[6][4]=-0.629888;
767   wire_r[6][4]=116.378364;
768   wire_phi[6][4]=-0.005412;
769   // 6 0 5 116.964814 -0.221663 116.965024 116.958962 -0.001895 0.711200 0.611377
770   wire_x[6][5]=116.964814;
771   wire_y[6][5]=-0.221663;
772   wire_r[6][5]=116.958962;
773   wire_phi[6][5]=-0.001895;
774   // 6 0 6 117.547186 0.186563 117.547334 117.540988 0.001587 0.711200 0.611377
775   wire_x[6][6]=117.547186;
776   wire_y[6][6]=0.186563;
777   wire_r[6][6]=117.540988;
778   wire_phi[6][6]=0.001587;
779   // 6 0 7 118.129558 0.594788 118.131056 118.124419 0.005035 0.711200 0.611377
780   wire_x[6][7]=118.129558;
781   wire_y[6][7]=0.594788;
782   wire_r[6][7]=118.124419;
783   wire_phi[6][7]=0.005035;
784   // 6 0 8 118.711930 1.003014 118.716167 118.709236 0.008449 0.711200 0.611377
785   wire_x[6][8]=118.711930;
786   wire_y[6][8]=1.003014;
787   wire_r[6][8]=118.709236;
788   wire_phi[6][8]=0.008449;
789   // 6 0 9 119.294302 1.411240 119.302649 119.295418 0.011829 0.711200 0.611377
790   wire_x[6][9]=119.294302;
791   wire_y[6][9]=1.411240;
792   wire_r[6][9]=119.295418;
793   wire_phi[6][9]=0.011829;
794   // 6 0 10 119.876674 1.819465 119.890481 119.882945 0.015177 0.711200 0.611377
795   wire_x[6][10]=119.876674;
796   wire_y[6][10]=1.819465;
797   wire_r[6][10]=119.882945;
798   wire_phi[6][10]=0.015177;
799   // 6 0 11 120.459047 2.227691 120.479643 120.471797 0.018491 0.711200 0.611377
800   wire_x[6][11]=120.459047;
801   wire_y[6][11]=2.227691;
802   wire_r[6][11]=120.471797;
803   wire_phi[6][11]=0.018491;
804   //  Radius of Sl 6 is 117.256179
805   // 7 0 0 125.927363 -2.257883 125.947604 125.939391 -0.017928 0.000000 0.000000
806   wire_x[7][0]=125.927363;
807   wire_y[7][0]=-2.257883;
808   wire_r[7][0]=125.939391;
809   wire_phi[7][0]=-0.017928;
810   // 7 0 1 126.509679 -1.849577 126.523199 126.515304 -0.014619 0.711200 0.611515
811   wire_x[7][1]=126.509679;
812   wire_y[7][1]=-1.849577;
813   wire_r[7][1]=126.515304;
814   wire_phi[7][1]=-0.014619;
815   // 7 0 2 127.091995 -1.441271 127.100167 127.092587 -0.011340 0.711200 0.611515
816   wire_x[7][2]=127.091995;
817   wire_y[7][2]=-1.441271;
818   wire_r[7][2]=127.092587;
819   wire_phi[7][2]=-0.011340;
820   // 7 0 3 127.674311 -1.032965 127.678489 127.671221 -0.008090 0.711200 0.611515
821   wire_x[7][3]=127.674311;
822   wire_y[7][3]=-1.032965;
823   wire_r[7][3]=127.671221;
824   wire_phi[7][3]=-0.008090;
825   // 7 0 4 128.256626 -0.624659 128.258148 128.251188 -0.004870 0.711200 0.611515
826   wire_x[7][4]=128.256626;
827   wire_y[7][4]=-0.624659;
828   wire_r[7][4]=128.251188;
829   wire_phi[7][4]=-0.004870;
830   // 7 0 5 128.838942 -0.216353 128.839124 128.832471 -0.001679 0.711200 0.611515
831   wire_x[7][5]=128.838942;
832   wire_y[7][5]=-0.216353;
833   wire_r[7][5]=128.832471;
834   wire_phi[7][5]=-0.001679;
835   // 7 0 6 129.421258 0.191953 129.421400 129.415051 0.001483 0.711200 0.611515
836   wire_x[7][6]=129.421258;
837   wire_y[7][6]=0.191953;
838   wire_r[7][6]=129.415051;
839   wire_phi[7][6]=0.001483;
840   // 7 0 7 130.003574 0.600259 130.004959 129.998911 0.004617 0.711200 0.611515
841   wire_x[7][7]=130.003574;
842   wire_y[7][7]=0.600259;
843   wire_r[7][7]=129.998911;
844   wire_phi[7][7]=0.004617;
845   // 7 0 8 130.585889 1.008565 130.589784 130.584035 0.007723 0.711200 0.611515
846   wire_x[7][8]=130.585889;
847   wire_y[7][8]=1.008565;
848   wire_r[7][8]=130.584035;
849   wire_phi[7][8]=0.007723;
850   // 7 0 9 131.168205 1.416871 131.175857 131.170404 0.010802 0.711200 0.611515
851   wire_x[7][9]=131.168205;
852   wire_y[7][9]=1.416871;
853   wire_r[7][9]=131.170404;
854   wire_phi[7][9]=0.010802;
855   // 7 0 10 131.750521 1.825177 131.763163 131.758002 0.013852 0.711200 0.611515
856   wire_x[7][10]=131.750521;
857   wire_y[7][10]=1.825177;
858   wire_r[7][10]=131.758002;
859   wire_phi[7][10]=0.013852;
860   // 7 0 11 132.332837 2.233483 132.351683 132.346814 0.016876 0.711200 0.611515
861   wire_x[7][11]=132.332837;
862   wire_y[7][11]=2.233483;
863   wire_r[7][11]=132.346814;
864   wire_phi[7][11]=0.016876;
865   //  Radius of Sl 7 is 129.130262
866 
867  }
868 
869 
870  //===================================================================
871  //
872  // topTree::GetTriggerOffsets() 
873  //
874  //===================================================================
875 void xftsim::GetTriggerBit(const char* L1Name,
876       const char* L2Name, const char* L3Name) {
877    Int_t nb;
878 
879    Int_t nentries = Int_t(mytree->fChain->GetEntries());
880 //   TBranch *trigName = mytree->fChain->GetBranch("trigName");
881 //   mytree->fChain->SetBranchStatus("*",0);
882 //   mytree->fChain->SetBranchStatus("trigName",1);
883     
884 
885    bool found = false;
886    int jentry=0;
887    printf("Number of entries %d\n",nentries);
888    printf("Looking for L1: %s %s %s\n",L1Name,L2Name,L3Name);
889    int numFoundL1 = 0;
890    int numFoundL2 = 0;
891    int numFoundL3 = 0;
892    while ((totalRunNumbers<maxRunNumbers) && jentry<nentries) {
893       
894       int ientry = mytree->LoadTree(jentry); //in case of a TChain, ientry is the entry number in the current file
895       int test = mytree->fChain->GetEntry(jentry);   
896 //      int test = trigName->GetEntry(ientry);
897       if (mytree->trigName > 0) {
898         printf("jentry %d runnumber %d L1 triggers %d \n",jentry,
899             mytree->trigName_RunNumber[0],
900             mytree->trigName_NumL1Triggers[0]);
901          RunNumber[totalRunNumbers] = mytree->trigName_RunNumber[0];
902          L1Bit[totalRunNumbers] = -1;
903          L2Bit[totalRunNumbers] = -1;
904          numL3Bit[totalRunNumbers] = 0;
905 //
906 // Check L1
907          for (int j=0; j<64; j++) {
908             printf("   L1 Trigger bit %d name %s\n",
909                   mytree->trigName_L1Bit[0][j],
910                   mytree->trigName_L1Name[0][j]);
911             TString nameTrigger = TString(mytree->trigName_L1Name[0][j]);
912             if (nameTrigger.Contains(L1Name, TString::kIgnoreCase)) {
913                L1Bit[totalRunNumbers] = mytree->trigName_L1Bit[0][j];
914 //               printf("found trigger %s bit %d\n",
915 //                  (const char*)nameTrigger,mytree->trigName_L1Bit[0][j]);
916                numFoundL1++;
917             }
918          }
919 //
920 // Check L2
921          for (int j=0; j<mytree->trigName_NumL2Triggers[0]; j++) {
922             printf("   L2 Trigger bit %d name %s\n",
923                   mytree->trigName_L2Bit[0][j],
924                   mytree->trigName_L2Name[0][j]);
925             TString nameTrigger = TString(mytree->trigName_L2Name[0][j]);
926             if (nameTrigger.Contains(L2Name, TString::kIgnoreCase)) {
927                L2Bit[totalRunNumbers] = mytree->trigName_L2Bit[0][j];
928 //               printf("found trigger %s bit %d\n",
929 //                  (const char*)nameTrigger,mytree->trigName_L2Bit[0][j]);
930                numFoundL2++;
931             }
932             
933          }
934 //
935 // Check L3
936          for (int j=0; j<mytree->trigName_NumL3Triggers[0]; j++) {
937             printf("   L3 Trigger bit %d name %s\n",
938                   mytree->trigName_L3Bit[0][j],
939                   mytree->trigName_L3Name[0][j]);
940             TString nameTrigger = TString(mytree->trigName_L3Name[0][j]);
941             if (nameTrigger.Contains(L3Name, TString::kIgnoreCase)) {
942                L3Bit[totalRunNumbers][numL3Bit[totalRunNumbers]] 
943                   = mytree->trigName_L3Bit[0][j];
944                numL3Bit[totalRunNumbers]++;
945 //               printf("found trigger %s bit %d\n",
946 //                  (const char*)nameTrigger,mytree->trigName_L3Bit[0][j]);
947                numFoundL3++;
948             }
949             
950          }
951             
952          totalRunNumbers++;
953       }
954       jentry++;
955    }
956    printf("Number of Runs %d found L1 %d L2 %d L3 %d \n",totalRunNumbers,
957             numFoundL1,numFoundL2,numFoundL3);
958 
959 //   mytree->fChain->SetBranchStatus("*",1);
960 
961 }
962 
963 //===================================================================
964  //
965  // topTree::GetTriggerOffsets() 
966  //
967  //===================================================================
968 void xftsim::GetTriggerBitL1(const char* L1Name) {
969    Int_t nb;
970 
971    Int_t nentries = Int_t(mytree->fChain->GetEntries());
972     
973 
974    bool found = false;
975    int jentry=0;
976    printf("Number of entries %d\n",nentries);
977    printf("Looking for L1: %s \n",L1Name);
978    int numFoundL1 = 0;
979    while ((totalRunNumbersL1<maxRunNumbers) && jentry<nentries) {
980       
981       int ientry = mytree->LoadTree(jentry); //in case of a TChain, ientry is the entry number in the current file
982       int test = mytree->fChain->GetEntry(jentry);   
983       if (mytree->trigName > 0) {
984         printf("jentry %d runnumber %d L1 triggers %d \n",jentry,
985             mytree->trigName_RunNumber[0],
986             mytree->trigName_NumL1Triggers[0]);
987          RunNumberL1[totalRunNumbersL1] = mytree->trigName_RunNumber[0];
988          L1Bit[totalRunNumbersL1] = -1;
989 //
990 // Check L1
991          for (int j=0; j<64; j++) {
992             printf("   L1 Trigger bit %d name %s\n",
993                   mytree->trigName_L1Bit[0][j],
994                   mytree->trigName_L1Name[0][j]);
995             TString nameTrigger = TString(mytree->trigName_L1Name[0][j]);
996             if (nameTrigger.Contains(L1Name, TString::kIgnoreCase)) {
997                L1Bit[totalRunNumbersL1] = mytree->trigName_L1Bit[0][j];
998                numFoundL1++;
999             }
1000          }
1001             
1002          totalRunNumbersL1++;
1003       }
1004       jentry++;
1005    }
1006    printf("Number of Runs %d found L1 %d \n",totalRunNumbersL1,
1007             numFoundL1);
1008 
1009    mytree->fChain->SetBranchStatus("*",1);
1010 
1011 }
1012 
1013 //===================================================================
1014  //
1015  // topTree::GetTriggerOffsets() 
1016  //
1017  //===================================================================
1018 void xftsim::GetTriggerBitL2(const char* L2Name) {
1019    Int_t nb;
1020 
1021    Int_t nentries = Int_t(mytree->fChain->GetEntries());
1022 
1023    bool found = false;
1024    int jentry=0;
1025    printf("Number of entries %d %d\n",nentries);
1026    printf("Looking for L2: %s \n",L2Name);
1027    int numFoundL2 = 0;
1028    while ((totalRunNumbersL2<maxRunNumbers) && jentry<nentries) {
1029       
1030       int ientry = mytree->LoadTree(jentry); //in case of a TChain, ientry is the entry number in the current file
1031       int test = mytree->fChain->GetEntry(jentry);   
1032       if (mytree->trigName > 0) {
1033         printf("jentry %d runnumber %d L1 triggers %d \n",jentry,
1034             mytree->trigName_RunNumber[0],
1035             mytree->trigName_NumL1Triggers[0]);
1036          RunNumberL2[totalRunNumbersL2] = mytree->trigName_RunNumber[0];
1037          L2Bit[totalRunNumbersL2] = -1;
1038 //
1039 // Check L2
1040          for (int j=0; j<mytree->trigName_NumL2Triggers[0]; j++) {
1041             printf("   L2 Trigger bit %d name %s\n",
1042                   mytree->trigName_L2Bit[0][j],
1043                   mytree->trigName_L2Name[0][j]);
1044             TString nameTrigger = TString(mytree->trigName_L2Name[0][j]);
1045             if (nameTrigger.Contains(L2Name, TString::kIgnoreCase)) {
1046                L2Bit[totalRunNumbersL2] = mytree->trigName_L2Bit[0][j];
1047 //               printf("found trigger %s bit %d\n",
1048 //                  (const char*)nameTrigger,mytree->trigName_L2Bit[0][j]);
1049                numFoundL2++;
1050             }
1051             
1052          }
1053             
1054          totalRunNumbersL2++;
1055       }
1056       jentry++;
1057    }
1058    printf("Number of Runs %d found L2 %d \n",totalRunNumbersL2,
1059             numFoundL2);
1060 
1061 
1062 }
1063 
1064 
1065 void xftsim::GetTriggerBitL3(int numTrigs, TString* L3Name) {
1066    Int_t nb;
1067 
1068    Int_t nentries = Int_t(mytree->fChain->GetEntries());
1069 
1070    bool found = false;
1071    int jentry=0;
1072    printf("GetTriggerBit: Number of entries %d\n",nentries);fflush(stdout);
1073    for (int i=0; i<numTrigs; i++) {
1074      printf("in trig name loop \n");fflush(stdout);
1075      //     printf("Looking for L3: %s\n",L3Name[i]);   fflush(stdout);
1076    }
1077    printf("out of trig name loop \n");fflush(stdout);
1078    int numFoundL3 = 0;
1079    bool printDone = false;
1080    while ((totalRunNumbersL3<maxRunNumbers) && jentry<nentries) {
1081 
1082       int ientry = mytree->LoadTree(jentry); //in case of a TChain, ientry is the entry number in the current file
1083       printf("ientry %d\n",ientry);fflush(stdout);
1084       int test = mytree->fChain->GetEntry(jentry);   
1085 //      int test = trigName->GetEntry(ientry);
1086       if (mytree->trigName > 0) {
1087 //        printf("jentry %d runnumber %d L1 triggers %d \n",jentry,
1088 //            mytree->trigName_RunNumber[0],
1089 //            mytree->trigName_NumL1Triggers[0]);
1090          RunNumberL3[totalRunNumbersL3] = mytree->trigName_RunNumber[0];
1091          numL3Bit[totalRunNumbersL3] = 0;
1092 //
1093 // Check L3
1094          for (int j=0; j<mytree->trigName_NumL3Triggers[0]; j++) {
1095             if (!printDone) printf("   L3 Trigger bit %d name %s\n",
1096                   mytree->trigName_L3Bit[0][j],
1097                   mytree->trigName_L3Name[0][j]);fflush(stdout);
1098             TString nameTrigger = TString(mytree->trigName_L3Name[0][j]);
1099             for (int i=0; i<numTrigs; i++) {
1100                if (nameTrigger.Contains(L3Name[i], TString::kIgnoreCase)) {
1101                   printf("found bit %d %s\n",
1102                         mytree->trigName_L3Bit[0][j],
1103                         mytree->trigName_L3Name[0][j]);
1104                   L3Bit[totalRunNumbersL3][numL3Bit[totalRunNumbersL3]] 
1105                      = mytree->trigName_L3Bit[0][j];
1106                   numL3Bit[totalRunNumbersL3]++;
1107                   numFoundL3++;
1108                }
1109             }
1110             
1111          }
1112          
1113          printDone = true;
1114             
1115          totalRunNumbersL3++;
1116       }
1117       jentry++;
1118    }
1119    printf("Number of Runs %d found L3 %d \n",totalRunNumbersL3,
1120             numFoundL3);
1121 
1122 
1123 }
1124 
1125 
1126 void xftsim::GetTriggerBitL3Run(int numTrigs, TString* L3Name) {
1127 
1128    bool found = false;
1129 
1130    int numFoundL3 = 0;
1131    bool printDone = false;
1132    //   while ((totalRunNumbersL3<maxRunNumbers) && jentry<nentries) {
1133 
1134    // int ientry = mytree->LoadTree(jentry); //in case of a TChain, ientry is the entry number in the current file
1135    //printf("ientry %d\n",ientry);fflush(stdout);
1136       //int test = mytree->fChain->GetEntry(jentry);   
1137 //      int test = trigName->GetEntry(ientry);
1138       if (mytree->trigName > 0) {
1139 //        printf("jentry %d runnumber %d L1 triggers %d \n",jentry,
1140 //            mytree->trigName_RunNumber[0],
1141 //            mytree->trigName_NumL1Triggers[0]);
1142          RunNumberL3[totalRunNumbersL3] = mytree->trigName_RunNumber[0];
1143          numL3Bit[totalRunNumbersL3] = 0;
1144 //
1145 // Check L3
1146          for (int j=0; j<mytree->trigName_NumL3Triggers[0]; j++) {
1147             if (!printDone) printf("   L3 Trigger bit %d name %s\n",
1148                   mytree->trigName_L3Bit[0][j],
1149                   mytree->trigName_L3Name[0][j]);fflush(stdout);
1150             TString nameTrigger = TString(mytree->trigName_L3Name[0][j]);
1151             for (int i=0; i<numTrigs; i++) {
1152                if (nameTrigger.Contains(L3Name[i], TString::kIgnoreCase)) {
1153                   printf("found bit %d %s\n",
1154                         mytree->trigName_L3Bit[0][j],
1155                         mytree->trigName_L3Name[0][j]);
1156                   L3Bit[totalRunNumbersL3][numL3Bit[totalRunNumbersL3]] 
1157                      = mytree->trigName_L3Bit[0][j];
1158                   numL3Bit[totalRunNumbersL3]++;
1159                   numFoundL3++;
1160                }
1161             }
1162             
1163          }
1164          
1165          printDone = true;
1166             
1167          totalRunNumbersL3++;
1168       }
1169       // jentry++;
1170       //  } // while
1171    printf("Number of Runs %d found L3 %d \n",totalRunNumbersL3,
1172             numFoundL3);
1173 
1174 
1175 }
1176 
1177 bool xftsim::testTriggerBit(int runNumber) {
1178    bool found = false;
1179    bool pass1 = false;
1180    bool pass2 = false;
1181    bool pass3 = false;
1182    int iRun = 0;
1183 //   printf("testTriggerL1Bit run number %d\n",runNumber);
1184    while ((iRun < totalRunNumbers) && !found) {
1185       if (RunNumber[iRun] == runNumber) {
1186          found = true;
1187 
1188 //
1189 // Test Level 1
1190          int bitPos = L1Bit[iRun];
1191          printf("Trigger bit %d trigger words %x %x\n",
1192             bitPos,mytree->trigInfo_L1W1NoPS[0],
1193                mytree->trigInfo_L1W1NoPS[1]);
1194          if (bitPos <= 31) {
1195             if (((1<<bitPos) & mytree->trigInfo_L1W1NoPS[0]) > 0) pass1 = true;
1196          } else {
1197             bitPos -= 32;
1198             if (((1<<bitPos) & mytree->trigInfo_L1W2NoPS[0]) > 0) pass1 = true;
1199          }
1200 //
1201 // Test Level 2
1202          bitPos = L2Bit[iRun];
1203          int tbitPos = bitPos;
1204          if (bitPos <= 31) {
1205             if (((1<<tbitPos) & mytree->trigInfo_L2W1[0]) > 0) pass2 = true;
1206          } else if (bitPos <= 63) {
1207             tbitPos -= 32;
1208             if (((1<<tbitPos) & mytree->trigInfo_L2W2[0]) > 0) pass2 = true;
1209          } else if (bitPos <= 95) {
1210             tbitPos -= 64;
1211             if (((1<<tbitPos) & mytree->trigInfo_L2W3[0]) > 0) pass2 = true;
1212          } else if (bitPos <= 127) {
1213             tbitPos -= 96;
1214             if (((1<<tbitPos) & mytree->trigInfo_L2W4[0]) > 0) pass2 = true;
1215          }
1216 //
1217 // Test Level 3
1218          for (int i=0; i< numL3Bit[iRun]; i++) {
1219             bitPos = L3Bit[iRun][i];
1220             tbitPos = bitPos;
1221             if (bitPos <= 31) {
1222                if (((1<<tbitPos) & mytree->trigInfo_L3W1[0]) > 0) pass3 = true;
1223             } else if (bitPos <= 63) {
1224                tbitPos -= 32;
1225                if (((1<<tbitPos) & mytree->trigInfo_L3W2[0]) > 0) pass3 = true;
1226             } else if (bitPos <= 95) {
1227                tbitPos -= 64;
1228                if (((1<<tbitPos) & mytree->trigInfo_L3W3[0]) > 0) pass3 = true;
1229             } else if (bitPos <= 127) {
1230                tbitPos -= 96;
1231                if (((1<<tbitPos) & mytree->trigInfo_L3W4[0]) > 0) pass3 = true;
1232             } else if (bitPos <= 159) {
1233                tbitPos -= 128;
1234                if (((1<<tbitPos) & mytree->trigInfo_L3W5[0]) > 0) pass3 = true;
1235             } else if (bitPos <= 181) {
1236                tbitPos -= 160;
1237                if (((1<<tbitPos) & mytree->trigInfo_L3W6[0]) > 0) pass3 = true;
1238             }
1239          }
1240 
1241       }
1242       iRun++;
1243    }  
1244 
1245    return pass1&&pass2&&pass3; 
1246 
1247 }
1248 
1249 
1250 bool xftsim::testTriggerBitL1(int runNumber) {
1251    bool found = false;
1252    bool pass1 = false;
1253    int iRun = 0;
1254 //   printf("testTriggerL1Bit run number %d\n",runNumber);
1255    while ((iRun < totalRunNumbersL1) && !found) {
1256       if (RunNumberL1[iRun] == runNumber) {
1257          found = true;
1258 
1259 //
1260 // Test Level 1
1261          int bitPos = L1Bit[iRun];
1262          printf("Trigger bit %d trigger words %x %x\n",
1263             bitPos,mytree->trigInfo_L1W1NoPS[0],
1264                mytree->trigInfo_L1W1NoPS[1]);
1265          if (bitPos <= 31) {
1266             if (((1<<bitPos) & mytree->trigInfo_L1W1NoPS[0]) > 0) pass1 = true;
1267          } else {
1268             bitPos -= 32;
1269             if (((1<<bitPos) & mytree->trigInfo_L1W2NoPS[0]) > 0) pass1 = true;
1270          }
1271       }
1272       iRun++;
1273    }  
1274 
1275    return pass1; 
1276 
1277 }
1278 
1279 bool xftsim::testTriggerBitL2(int runNumber) {
1280    bool found = false;
1281    bool pass2 = false;
1282    int iRun = 0;
1283 //   printf("testTriggerL1Bit run number %d\n",runNumber);
1284    while ((iRun < totalRunNumbersL2) && !found) {
1285       if (RunNumberL2[iRun] == runNumber) {
1286          found = true;
1287 //
1288 // Test Level 2
1289          int bitPos = L2Bit[iRun];
1290          int tbitPos = bitPos;
1291          if (bitPos <= 31) {
1292             if (((1<<tbitPos) & mytree->trigInfo_L2W1[0]) > 0) pass2 = true;
1293          } else if (bitPos <= 63) {
1294             tbitPos -= 32;
1295             if (((1<<tbitPos) & mytree->trigInfo_L2W2[0]) > 0) pass2 = true;
1296          } else if (bitPos <= 95) {
1297             tbitPos -= 64;
1298             if (((1<<tbitPos) & mytree->trigInfo_L2W3[0]) > 0) pass2 = true;
1299          } else if (bitPos <= 127) {
1300             tbitPos -= 96;
1301             if (((1<<tbitPos) & mytree->trigInfo_L2W4[0]) > 0) pass2 = true;
1302          }
1303       }
1304       iRun++;
1305    }  
1306 
1307    return pass2; 
1308 
1309 }
1310 
1311 bool xftsim::testTriggerBitL3(int runNumber) {
1312    bool found = false;
1313    bool pass3 = false;
1314    int iRun = 0;
1315    while ((iRun < totalRunNumbersL3) && !found) {
1316       if (RunNumberL3[iRun] == runNumber) {
1317          found = true;
1318          
1319          if (!found) {printf("WARNING TRIGGERS NOT in LIST for this run %d\n",runNumber);return false;}
1320 //
1321 // Test Level 3
1322          for (int i=0; i< numL3Bit[iRun]; i++) {
1323             int bitPos = L3Bit[iRun][i];
1324             int tbitPos = bitPos;
1325 //             if (debug)
1326 //               printf("Trigger bit %d trigger words %x %x %x %x %x %x\n",bitPos,
1327 //                      mytree->trigInfo_L3W1[0],
1328 //                      mytree->trigInfo_L3W2[0],
1329 //                      mytree->trigInfo_L3W3[0],
1330 //                      mytree->trigInfo_L3W4[0],
1331 //                      mytree->trigInfo_L3W5[0],
1332 //                      mytree->trigInfo_L3W6[0]);
1333 
1334             if (bitPos <= 31) {
1335                if (((1<<tbitPos) & mytree->trigInfo_L3W1[0]) > 0) pass3 = true;
1336             } else if (bitPos <= 63) {
1337                tbitPos -= 32;
1338                if (((1<<tbitPos) & mytree->trigInfo_L3W2[0]) > 0) pass3 = true;
1339             } else if (bitPos <= 95) {
1340                tbitPos -= 64;
1341                if (((1<<tbitPos) & mytree->trigInfo_L3W3[0]) > 0) pass3 = true;
1342             } else if (bitPos <= 127) {
1343                tbitPos -= 96;
1344                if (((1<<tbitPos) & mytree->trigInfo_L3W4[0]) > 0) pass3 = true;
1345             } else if (bitPos <= 159) {
1346                tbitPos -= 128;
1347                if (((1<<tbitPos) & mytree->trigInfo_L3W5[0]) > 0) pass3 = true;
1348             } else if (bitPos <= 181) {
1349                tbitPos -= 160;
1350                if (((1<<tbitPos) & mytree->trigInfo_L3W6[0]) > 0) pass3 = true;
1351             }
1352          }
1353       }
1354       iRun++;
1355    }  
1356 
1357    return pass3; 
1358 
1359 }
1360 
1361 
1362 //-----------------------------------------------
1363 // 4 layer road files
1364 //-----------------------------------------------
1365 void xftsim::roadFile(char* pathName)
1366 {
1367   int index = 0;
1368   int ipix_cell[4];
1369   int mcpix[4];
1370   int nPtbins = 0;
1371   
1372   // Setup the Input file Stream
1373   // ---------------------------
1374   std::ifstream f1(pathName);
1375   
1376   
1377   // Read in the header pixels per cell for each layer
1378   // -------------------------------------------------
1379   for(index=0; index < 4; index++)
1380     {
1381       f1 >> ipix_cell[index];
1382     }
1383   // Read in the core pixels per layer
1384   // ---------------------------------
1385   index = 0;
1386         for(index=0; index < 4; index++)
1387           {
1388             f1 >> mcpix[index];
1389             numPix[index][1] = mcpix[index];
1390           }
1391         
1392         
1393         // Read in the number of linkers
1394         // -----------------------------
1395         f1 >> nlink;
1396         
1397         // Read in the number of Pt bins
1398         // -----------------------------
1399         f1 >> nPtbins;
1400         
1401         // Read in the Pt bins
1402         // -------------------
1403         int temp;
1404         for(index=0; index < nPtbins; index++)
1405           {
1406             f1 >> temp;
1407             f1 >> ptbins[index];
1408             printf("4pt bin %d pt value %g \n",index,ptbins[index]);
1409           }
1410         f1.close();
1411 }//End method
1412 
1413 
1414 // ------------------------------
1415 // 3 layer Road Files
1416 // ------------------------------
1417 void xftsim::road3File(char* pathName)
1418 {
1419   int index = 0;
1420   int ipix_cell[4];
1421   int mcpix[4];
1422   int nPtbins = 0;
1423   
1424   std::ifstream f1(pathName);
1425   
1426   // Read in the header pixels per cell for each layer
1427   // -------------------------------------------------
1428   for(index=0; index < 4; index++)
1429     {
1430       f1>>ipix_cell[index];
1431     }
1432   // Read in the core pixels per layer
1433   // ---------------------------------
1434   for(index=0; index < 4; index++)
1435     {
1436       f1 >> mcpix[index];
1437     }
1438   // Read in the number of linkers
1439   // -----------------------------
1440   f1>>nlink3;
1441   if(nlink3 != nlink) 
1442     printf("**** WARNING **** 4-layer and 3-layer roads databases have different number of linkers\n");
1443   // Read in the number of Pt bins
1444   // -----------------------------
1445   f1 >> nPtbins;
1446   // Read in the Pt bins
1447   // -------------------
1448   int temp;
1449   for(index=0; index < nPtbins; index++)
1450     {
1451       f1 >> temp;
1452       f1 >> ptbins3[index];
1453       printf("3pt bin %d pt value %g \n",index,ptbins3[index]);
1454     }
1455   f1.close();
1456 }
1457 

source navigation ] diff markup ] identifier search ] freetext search ] file search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!

Send problems or questions to cdfcode@fnal.gov