| 1 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 2 | //  test routines | 
| 3 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 4 |  | 
| 5 |  | 
| 6 | void RootTest(TString filename){ | 
| 7 | Long64_t ntimes = 0; | 
| 8 | inizio: TFile       *calheadFile = 0; | 
| 9 | TFile       *calcalibFile = 0; | 
| 10 | calheadFile = getFile(filename, "CalibCalPed", "Header"); | 
| 11 | calcalibFile = getFile(filename, "CalibCalPed"); | 
| 12 | //Takes the tree of the header file | 
| 13 | char *filen = 0; | 
| 14 | filen = filename; | 
| 15 | //gObjectTable->Print(); | 
| 16 | if ( !calheadFile || !calcalibFile ) { | 
| 17 | if ( calheadFile ) calheadFile->Close(); | 
| 18 | if ( calcalibFile ) calcalibFile->Close(); | 
| 19 | printf(" Not able to open file! %s \n",filen); | 
| 20 | printf(" ntimes = %i\n",(int)ntimes); | 
| 21 | ntimes++; | 
| 22 | goto inizio; | 
| 23 | return; | 
| 24 | }; | 
| 25 | TTree *tr = (TTree*)calheadFile->Get("Pscu"); | 
| 26 | tr->AddFriend("CalibCalPed", calcalibFile); | 
| 27 | //    pamela::calorimeter::CalibCalPedEvent *ce = 0; | 
| 28 | pamela::CalibCalPedEvent *ce = 0; | 
| 29 | pamela::PscuHeader *cph = 0; | 
| 30 | pamela::EventHeader *ceh = 0; | 
| 31 | tr->SetBranchAddress("Header", &ceh); | 
| 32 | tr->SetBranchAddress("Event", &ce); | 
| 33 | Long64_t ncalibs    = tr->GetEntries(); | 
| 34 | calheadFile->Close(); | 
| 35 | calcalibFile->Close(); | 
| 36 | printf(" ntimes = %i\n",(int)ntimes); | 
| 37 | ntimes++; | 
| 38 | goto inizio; | 
| 39 | } | 
| 40 |  | 
| 41 | void RootTestE(TString filename){ | 
| 42 | Long64_t ntimes = 0; | 
| 43 | inizio: | 
| 44 | TString scalheadFile; | 
| 45 | TString scalcalibFile; | 
| 46 | scalheadFile = getEmiFile(filename, "CalibCalPed", "Header"); | 
| 47 | scalcalibFile = getEmiFile(filename, "CalibCalPed","Event"); | 
| 48 | char *prova; | 
| 49 | prova = scalheadFile; | 
| 50 | if ( prova == "nofile" ){ | 
| 51 | printf("nofile\n"); | 
| 52 | goto inizio; | 
| 53 | return; | 
| 54 | }; | 
| 55 | TFile *calheadFile = 0; | 
| 56 | calheadFile = new TFile(scalheadFile); | 
| 57 | TFile *calcalibFile = 0; | 
| 58 | calcalibFile = new TFile(scalcalibFile); | 
| 59 | //    TFile *calheadFile = 0; | 
| 60 | //calheadFile = new TFile(scalheadFile); | 
| 61 | //TFile *calcalibFile = 0; | 
| 62 | //calcalibFile = new TFile(scalcalibFile); | 
| 63 | // | 
| 64 | if ( calheadFile->IsZombie() || calcalibFile->IsZombie() ) { | 
| 65 | if ( !calheadFile->IsZombie() ) calheadFile->Close(); | 
| 66 | if ( !calcalibFile->IsZombie() ) calcalibFile->Close(); | 
| 67 | printf(" Not able to open file! \n"); | 
| 68 | printf(" ntimes = %i\n",ntimes); | 
| 69 | ntimes++; | 
| 70 | goto inizio; | 
| 71 | return; | 
| 72 | }; | 
| 73 | TTree *tr = (TTree*)calheadFile->Get("Pscu"); | 
| 74 | tr->AddFriend("CalibCalPed", calcalibFile); | 
| 75 | //    pamela::calorimeter::CalibCalPedEvent *ce = 0; | 
| 76 | pamela::CalibCalPedEvent *ce = 0; | 
| 77 | pamela::PscuHeader *cph = 0; | 
| 78 | pamela::EventHeader *ceh = 0; | 
| 79 | tr->SetBranchAddress("Header", &ceh); | 
| 80 | tr->SetBranchAddress("Event", &ce); | 
| 81 | Long64_t ncalibs    = tr->GetEntries(); | 
| 82 | calheadFile->Close(); | 
| 83 | calcalibFile->Close(); | 
| 84 | printf(" ntimes = %i\n",ntimes); | 
| 85 | ntimes++; | 
| 86 | goto inizio; | 
| 87 | } | 
| 88 |  | 
| 89 | void RootTest2(TString filename){ | 
| 90 | Long64_t ntimes = 0; | 
| 91 | inizio: TFile calcalibFile(filename); | 
| 92 | if ( calcalibFile.IsZombie() ) { | 
| 93 | if ( !calcalibFile.IsZombie() ) calheadFile.Close(); | 
| 94 | printf(" Not able to open file! \n"); | 
| 95 | printf(" ntimes = %i\n",ntimes); | 
| 96 | ntimes++; | 
| 97 | goto inizio; | 
| 98 | }; | 
| 99 | printf(" ntimes = %i\n",ntimes); | 
| 100 | ntimes++; | 
| 101 | goto inizio; | 
| 102 | } | 
| 103 |  | 
| 104 | void RootTest3(TString filename){ | 
| 105 | Long64_t ntimes = 0; | 
| 106 | inizio:      TFile *calcalibFile = 0; | 
| 107 | calcalibFile = new TFile(filename); | 
| 108 | if ( !calcalibFile ) { | 
| 109 | if ( calcalibFile ) calheadFile.Close(); | 
| 110 | printf(" Not able to open file! \n"); | 
| 111 | printf(" ntimes = %i\n",ntimes); | 
| 112 | ntimes++; | 
| 113 | goto inizio; | 
| 114 | }; | 
| 115 | printf(" ntimes = %i\n",ntimes); | 
| 116 | ntimes++; | 
| 117 | goto inizio; | 
| 118 | } | 
| 119 |  | 
| 120 |  | 
| 121 | TString getEmiFile2(TString base, TString packetType, TString subType){ | 
| 122 | Int_t debug = 0; | 
| 123 | // | 
| 124 | TString newfile; | 
| 125 | stringcopy(newfile,base); | 
| 126 | // | 
| 127 | string fil = base; | 
| 128 | Int_t posiz = fil.find("dw_"); | 
| 129 | Int_t upper = 0; | 
| 130 | if ( posiz == -1 ) { | 
| 131 | posiz = fil.find("DW_"); | 
| 132 | upper = 1; | 
| 133 | }; | 
| 134 | if ( posiz == -1 ) return ""; | 
| 135 | TString fullname; | 
| 136 | stringcopy(fullname,base,posiz,posiz+15); | 
| 137 | stringappend(fullname,"."); | 
| 138 | stringappend(fullname,packetType); | 
| 139 | stringappend(fullname,"."); | 
| 140 | stringappend(fullname,subType); | 
| 141 | stringappend(fullname,".root"); | 
| 142 | // | 
| 143 | stringappend(newfile,"/"); | 
| 144 | stringappend(newfile,packetType); | 
| 145 | stringappend(newfile,"/"); | 
| 146 | stringappend(newfile,fullname); | 
| 147 | //    char *vediamo; | 
| 148 | //vediamo = newfile; | 
| 149 | //printf("filename: %s \n",vediamo); | 
| 150 | //return; | 
| 151 | TFile retfile(newfile); | 
| 152 | if ( retfile.IsZombie() ) { | 
| 153 | return "nofile"; | 
| 154 | } else { | 
| 155 | retfile.Close(); | 
| 156 | return newfile; | 
| 157 | }; | 
| 158 | } | 
| 159 |  | 
| 160 |  | 
| 161 |  | 
| 162 | void RootTestE2(TString filename){ | 
| 163 | Long64_t ntimes = 0; | 
| 164 | Long64_t ncalibs = 0; | 
| 165 | Int_t forever = 1; | 
| 166 | while ( forever ){ | 
| 167 | printf(" ntimes = %i\n",(int)ntimes); | 
| 168 | TFile *calheadFile = 0; | 
| 169 | calheadFile = getEmiFile(filename, "CalibCalPed","Header"); | 
| 170 | TFile *calcalibFile = 0; | 
| 171 | calcalibFile = getEmiFile(filename, "CalibCalPed"); | 
| 172 | // | 
| 173 | //gObjectTable->Print(); | 
| 174 | // | 
| 175 | if ( !calcalibFile || !calheadFile ) { | 
| 176 | printf(" -> not able to open file \n"); | 
| 177 | if ( calheadFile ) calheadFile->Close(); | 
| 178 | if ( calcalibFile ) calcalibFile->Close(); | 
| 179 | } else { | 
| 180 | TTree *tr = (TTree*)calheadFile->Get("Pscu"); | 
| 181 | tr->AddFriend("CalibCalPed", calcalibFile); | 
| 182 | //      pamela::calorimeter::CalibCalPedEvent *ce = 0; | 
| 183 | pamela::CalibCalPedEvent *ce = 0; | 
| 184 | pamela::PscuHeader *cph = 0; | 
| 185 | pamela::EventHeader *ceh = 0; | 
| 186 | tr->SetBranchAddress("Header", &ceh); | 
| 187 | tr->SetBranchAddress("Event", &ce); | 
| 188 | ncalibs    = tr->GetEntries(); | 
| 189 | printf(" -> ncalibs = %i \n",(int)ncalibs); | 
| 190 | calheadFile->Close(); | 
| 191 | calcalibFile->Close(); | 
| 192 | }; | 
| 193 | ntimes++; | 
| 194 | }; | 
| 195 | } | 
| 196 |  | 
| 197 | void trktesting(TString filename){ | 
| 198 | TString startingdir = gSystem->WorkingDirectory(); | 
| 199 | char *bdir; | 
| 200 | char *sdir=gSystem->Getenv("PAM_LIB"); | 
| 201 | // | 
| 202 | // on 64 bit machines Form doesn't work, substitute it with stringstream oss; oss.str(""); oss << sdir << "/libblabla.so"; gSystem->Load(oss.str().c_str()) | 
| 203 | // | 
| 204 | bdir = Form("%s/liboptrklev1.so",sdir); | 
| 205 | gSystem->Load(bdir); | 
| 206 | bdir = Form("%s/liboptrklev1_C.so",sdir); | 
| 207 | gSystem->Load(bdir); | 
| 208 | bdir = Form("%s/libretrklev1.so",sdir); | 
| 209 | gSystem->Load(bdir); | 
| 210 | bdir = Form("%s/libretrklev1_C.so",sdir); | 
| 211 | gSystem->Load(bdir); | 
| 212 | bdir = Form("%s/libcltrklev1.so",sdir); | 
| 213 | gSystem->Load(bdir); | 
| 214 | bdir = Form("%s/libcltrklev1_C.so",sdir); | 
| 215 | gSystem->Load(bdir); | 
| 216 | Int_t trnev = 0; | 
| 217 | struct Tracklev1 trklev1; | 
| 218 | char *name; | 
| 219 | name = filename; | 
| 220 | //char *name2; | 
| 221 | //name2 = filename; | 
| 222 | ////    name = Form("%s",filename); | 
| 223 | //name = name2; | 
| 224 | //trnev = 123; | 
| 225 | //printf("name = %s \n",name); | 
| 226 | //printf("filename = %s \n",name2); | 
| 227 | coptrklev1(name,trklev1,trnev); | 
| 228 | //coptrklev1(); | 
| 229 | printf("The tracker ntuple contains %i events\n",trnev); | 
| 230 | for ( Int_t i = 1; i < trnev+1; i++){ | 
| 231 | cretrklev1(i,trklev1); | 
| 232 | printf("Event number %i ---> OBT %i \n",i,trklev1.obt1); | 
| 233 | printf("                ---> PKTnum %i \n",trklev1.pkt_num1); | 
| 234 | printf("                ---> PKTtype %x \n",trklev1.pkt_type1); | 
| 235 | printf("                ---> nev1 %i \n",trklev1.nev1); | 
| 236 | printf("                ---> good %i \n",trklev1.good1); | 
| 237 | printf("                ---> nclstr %i \n",trklev1.nclstr1); | 
| 238 | }; | 
| 239 | ccltrklev1(trklev1); | 
| 240 | //ccltrklev1(); | 
| 241 | } | 
| 242 |  | 
| 243 | void trktesting2(TString filename){ | 
| 244 | TString startingdir = gSystem->WorkingDirectory(); | 
| 245 | char *bdir; | 
| 246 | char *sdir; | 
| 247 | sdir = startingdir; | 
| 248 | bdir = Form("%s/tracker/liboptrklev2.so",sdir); | 
| 249 | gSystem->Load(bdir); | 
| 250 | bdir = Form("%s/tracker/coptrklev2_C.so",sdir); | 
| 251 | gSystem->Load(bdir); | 
| 252 | bdir = Form("%s/tracker/libretrklev2.so",sdir); | 
| 253 | gSystem->Load(bdir); | 
| 254 | bdir = Form("%s/tracker/cretrklev2_C.so",sdir); | 
| 255 | gSystem->Load(bdir); | 
| 256 | bdir = Form("%s/tracker/libcltrklev2.so",sdir); | 
| 257 | gSystem->Load(bdir); | 
| 258 | bdir = Form("%s/tracker/ccltrklev2_C.so",sdir); | 
| 259 | gSystem->Load(bdir); | 
| 260 | Int_t trnev = 0; | 
| 261 | struct Tracklev2 trklev2; | 
| 262 | char *name; | 
| 263 | name = filename; | 
| 264 | coptrklev2(name,trklev2,trnev); | 
| 265 | printf("The tracker ntuple contains %i events\n",trnev); | 
| 266 | for ( Int_t i = 1; i < trnev+1; i++){ | 
| 267 | cretrklev2(i,trklev2); | 
| 268 | printf("Event number %i ---> OBT %i \n",i,trklev2.obt); | 
| 269 | printf("                ---> PKTnum %i \n",trklev2.pkt_num); | 
| 270 | printf("                ---> PKTtype %x \n",trklev2.pkt_type); | 
| 271 | printf("                ---> nev2 %i \n",trklev2.nev2); | 
| 272 | printf("                ---> good2 %i \n",trklev2.good2); | 
| 273 | printf("                ---> ntrk %i \n",trklev2.ntrk); | 
| 274 | if ( trklev2.ntrk == 1 && trklev2.al[0][4] != 0. ) printf("c-> RIG = %.9f \n",1./trklev2.al[0][4]); | 
| 275 | }; | 
| 276 | ccltrklev2(trklev2); | 
| 277 | //ccltrklev1(); | 
| 278 | } | 
| 279 |  | 
| 280 | void trkhtestlev2(TString filename){ | 
| 281 | //    char *name; | 
| 282 | //name = filename; | 
| 283 | //char *nome; | 
| 284 | //nome = Form("%s/Physics/Level1/",name); | 
| 285 | //    TFile *f = new TFile(nome); | 
| 286 | TFile *f = getFile(filename,"Physics.Level2","Tracker"); | 
| 287 | TFile *caloFile; | 
| 288 | caloFile = getFile(filename, "Physics.Level2", "Calorimeter"); | 
| 289 | TTree *tr = (TTree*) f->Get("TrkLevel2"); | 
| 290 | tr->AddFriend("CaloLevel2", caloFile); | 
| 291 | struct Tracklev2 trk; | 
| 292 | struct CTracklev2 track; | 
| 293 | settrklev2(tr,trk); | 
| 294 | Int_t nevents = tr->GetEntries(); | 
| 295 | CalorimeterLevel2 *calo = new CalorimeterLevel2(); | 
| 296 | tr->SetBranchAddress("CaloLevel2.Event",&calo); | 
| 297 | for ( Int_t i = 0; i<nevents ; i++){ | 
| 298 | tr->GetEntry(i); | 
| 299 | accesstrklev2(trk,track); | 
| 300 | printf("Event %i tracker OBT = %i \n",i,track.obt); | 
| 301 | if ( track.ntrk>0 ) printf("Event %i tracker RIG = %f \n",i,1./track.al[4][0]); | 
| 302 | //      Float_t obt = (float)trk.obt1; | 
| 303 | //printf("Event %i tracker OBT1 = %f \n",i,obt); | 
| 304 | printf("Event %i calo OBT = %i \n",i,calo->OBT); | 
| 305 | }; | 
| 306 | } | 
| 307 |  | 
| 308 | void trkhtest(TString filename){ | 
| 309 | //    char *name; | 
| 310 | //name = filename; | 
| 311 | //char *nome; | 
| 312 | //nome = Form("%s/Physics/Level1/",name); | 
| 313 | //    TFile *f = new TFile(nome); | 
| 314 | TFile *f = getFile(filename,"Physics.Level1","Tracker"); | 
| 315 | TFile *caloFile; | 
| 316 | caloFile = getFile(filename, "Physics.Level2", "Calorimeter"); | 
| 317 | TTree *tr = (TTree*) f->Get("TrkLevel1"); | 
| 318 | tr->AddFriend("CaloLevel2", caloFile); | 
| 319 | struct Tracklev1 trk; | 
| 320 | struct CTracklev1 track; | 
| 321 | settrklev1(tr,trk); | 
| 322 | Int_t nevents = tr->GetEntries(); | 
| 323 | CalorimeterLevel2 *calo = new CalorimeterLevel2(); | 
| 324 | tr->SetBranchAddress("CaloLevel2.Event",&calo); | 
| 325 | for ( Int_t i = 0; i<nevents ; i++){ | 
| 326 | tr->GetEntry(i); | 
| 327 | accesstrklev1(trk,track); | 
| 328 | printf("Event %i tracker OBT1 = %i \n",i,track.obt1); | 
| 329 | //      Float_t obt = (float)trk.obt1; | 
| 330 | //printf("Event %i tracker OBT1 = %f \n",i,obt); | 
| 331 | printf("Event %i calo OBT1 = %i \n",i,calo->OBT); | 
| 332 | }; | 
| 333 | } | 
| 334 |  | 
| 335 |  | 
| 336 | void trkhtest2(TString filename){ | 
| 337 | TFile *f = new TFile(filename); | 
| 338 | TTree *tr = (TTree*) f->Get("TrkLevel1"); | 
| 339 | TrackerLevel1 *trk = new TrackerLevel1(); | 
| 340 | //struct Tracklev1 trk; | 
| 341 | tr->SetBranchAddress("good1", &trk->good1); | 
| 342 | tr->SetBranchAddress("obt1", &trk->obt1); | 
| 343 | tr->SetBranchAddress("pkt_num1", &trk->pkt_num1); | 
| 344 | //tr->SetBranchAddress("obt1", &trk.obt1); | 
| 345 | Int_t nevents = tr->GetEntries(); | 
| 346 | for ( Int_t i = 0; i<nevents ; i++){ | 
| 347 | tr->GetEntry(i); | 
| 348 | printf("Event %i GOOD1 = %i \n",i,trk->good1); | 
| 349 | printf("Event %i PKT_NUM1 = %i \n",i,trk->pkt_num1); | 
| 350 | printf("Event %i OBT1 = %i \n",i,trk->obt1); | 
| 351 | }; | 
| 352 | } |