NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcEvent.cxx
Go to the documentation of this file.
1
31
33
282
283#include "NcEvent.h"
284#include "Riostream.h"
285
286ClassImp(NcEvent); // Class implementation to enable ROOT I/O
287
290{
297
298 fRun=0;
299 fEvent=0;
300 fWeight=1;
301 fSelectLevel=0;
302 fDetector=0;
303 fDevices=0;
304 fDevCopy=0;
305 fHits=0;
306 fOrdered=0;
307 fDisplay=0;
308 fDevs=0;
309}
310
312{
319
320 if (n<=0)
321 {
322 cout << " *** This NcVertex initialisation was invoked via the NcEvent ctor." << endl;
323 }
324 fRun=0;
325 fEvent=0;
326 fWeight=1;
327 fSelectLevel=0;
328 fDetector=0;
329 fDevices=0;
330 fDevCopy=0;
331 fHits=0;
332 fOrdered=0;
333 fDisplay=0;
334 fDevs=0;
335}
336
338{
344
345 if (fDetector)
346 {
347 if (fDevCopy) delete fDetector;
348 fDetector=0;
349 }
350
351 if (fDevices)
352 {
353 delete fDevices;
354 fDevices=0;
355 }
356 if (fHits)
357 {
358 delete fHits;
359 fHits=0;
360 }
361 if (fOrdered)
362 {
363 delete fOrdered;
364 fOrdered=0;
365 }
366 if (fDisplay)
367 {
368 delete fDisplay;
369 fDisplay=0;
370 }
371 if (fDevs)
372 {
373 delete fDevs;
374 fDevs=0;
375 }
376}
377
379{
385
386 fRun=evt.fRun;
387 fEvent=evt.fEvent;
388 fWeight=evt.fWeight;
390 fDevCopy=evt.fDevCopy;
391
392 fHits=0;
393 fOrdered=0;
394 fDisplay=0;
395 fDevs=0;
396
397 fDetector=0;
398 NcDetector* dx=evt.fDetector;
399 if (dx)
400 {
401 if (fDevCopy)
402 {
403 fDetector=(NcDetector*)dx->Clone();
404 }
405 else
406 {
407 fDetector=dx;
408 }
409 }
410
411 fDevices=0;
412 Int_t ndevs=0;
413 if (evt.fDevices) ndevs=(evt.fDevices)->GetEntries();
414 if (ndevs)
415 {
416 fDevices=new TObjArray(ndevs);
417 if (fDevCopy) fDevices->SetOwner();
418 for (Int_t i=1; i<=ndevs; i++)
419 {
420 NcDevice* dev=evt.GetDevice(i);
421 if (dev)
422 {
423 if (fDevCopy)
424 {
425 fDevices->Add(dev->Clone());
426 }
427 else
428 {
429 fDevices->Add(dev);
430 }
431 }
432 }
433 }
434}
435
437{
448
450
452 fRun=0;
453 fEvent=0;
454 fWeight=1;
455 fSelectLevel=0;
456
457 if (fDetector)
458 {
459 if (fDevCopy) delete fDetector;
460 fDetector=0;
461 }
462
463 if (fDevices)
464 {
465 delete fDevices;
466 fDevices=0;
467 }
468 if (fHits)
469 {
470 delete fHits;
471 fHits=0;
472 }
473 if (fOrdered)
474 {
475 delete fOrdered;
476 fOrdered=0;
477 }
478 if (fDisplay)
479 {
480 delete fDisplay;
481 fDisplay=0;
482 }
483 if (fDevs)
484 {
485 delete fDevs;
486 fDevs=0;
487 }
488}
489
490void NcEvent::SetOwner(Bool_t own)
491{
514
515 Int_t mode=1;
516 if (!own) mode=0;
517 if (fDetector) fDetector->SetDevCopy(mode);
518 if (fDevices) fDevices->SetOwner(own);
519 fDevCopy=mode;
520
522}
523
524void NcEvent::SetDayTime(TTimeStamp& stamp)
525{
540
541 Set(stamp.GetDate(),stamp.GetTime(),0,kTRUE,0);
542}
543
544void NcEvent::SetDayTime(TDatime& stamp)
545{
558
559 Set(stamp.GetDate(),stamp.GetTime(),0,kFALSE,0);
560}
561
563{
569
570 fRun=run;
571}
572
574{
580
581 fEvent=evt;
582}
583
584void NcEvent::SetWeight(Double_t weight)
585{
592
593 fWeight=weight;
594}
595
596void NcEvent::SetSelectLevel(Int_t level)
597{
604
605 fSelectLevel=level;
606}
607
608TTimeStamp NcEvent::GetDayTime() const
609{
622
623 return (TTimeStamp)(*this);
624}
625
627{
633
634 return fRun;
635}
636
638{
644
645 return fEvent;
646}
647
648Double_t NcEvent::GetWeight() const
649{
655
656 return fWeight;
657}
658
660{
666
667 return fSelectLevel;
668}
669
670void NcEvent::SetProjectile(Int_t a,Int_t z,Double_t pnuc,Int_t id)
671{
684
685 Int_t newdev=0;
686
687 NcDevice* beam=GetDevice("Beam");
688
689 if (!beam)
690 {
691 beam=new NcDevice();
692 beam->SetNameTitle("Beam","Beam and target specifications");
693 newdev=1;
694 }
695
696 if (a || z)
697 {
698 beam->AddNamedSlot("Aproj");
699 beam->SetSignal(a,"Aproj");
700 beam->AddNamedSlot("Zproj");
701 beam->SetSignal(z,"Zproj");
702 }
703 beam->AddNamedSlot("Pnucproj");
704 beam->SetSignal(pnuc,"Pnucproj");
705 if (id)
706 {
707 beam->AddNamedSlot("Idproj");
708 beam->SetSignal(id,"Idproj");
709 }
710
711 if (newdev)
712 {
713 AddDevice(beam);
714 if (fDevCopy) delete beam;
715 }
716}
717
718void NcEvent::SetProjectile(Int_t a,Int_t z,Nc3Vector& p,Int_t id)
719{
732
733 Int_t newdev=0;
734
735 NcDevice* beam=GetDevice("Beam");
736
737 if (!beam)
738 {
739 beam=new NcDevice();
740 beam->SetNameTitle("Beam","Beam and target specifications");
741 newdev=1;
742 }
743
744 Double_t px=p.GetX(1,"car");
745 Double_t py=p.GetX(2,"car");
746 Double_t pz=p.GetX(3,"car");
747 Double_t pnuc=p.GetNorm();
748
749 if (a || z)
750 {
751 beam->AddNamedSlot("Aproj");
752 beam->SetSignal(a,"Aproj");
753 beam->AddNamedSlot("Zproj");
754 beam->SetSignal(z,"Zproj");
755 }
756 beam->AddNamedSlot("Pnucproj");
757 beam->SetSignal(pnuc,"Pnucproj");
758 beam->AddNamedSlot("Pxnucproj");
759 beam->SetSignal(px,"Pxnucproj");
760 beam->AddNamedSlot("Pynucproj");
761 beam->SetSignal(py,"Pynucproj");
762 beam->AddNamedSlot("Pznucproj");
763 beam->SetSignal(pz,"Pznucproj");
764 if (id)
765 {
766 beam->AddNamedSlot("Idproj");
767 beam->SetSignal(id,"Idproj");
768 }
769
770 if (newdev)
771 {
772 AddDevice(beam);
773 if (fDevCopy) delete beam;
774 }
775}
776
778{
784
785 Int_t val=0;
786 NcDevice* beam=GetDevice("Beam");
787 if (beam) val=int(beam->GetSignal("Aproj"));
788 return val;
789}
790
792{
798
799 Int_t val=0;
800 NcDevice* beam=GetDevice("Beam");
801 if (beam) val=int(beam->GetSignal("Zproj"));
802 return val;
803}
804
806{
812
813 Double_t val=0;
814 NcDevice* beam=GetDevice("Beam");
815 if (beam) val=beam->GetSignal("Pnucproj");
816 return val;
817}
818
820{
826
827 Int_t val=0;
828 NcDevice* beam=GetDevice("Beam");
829 if (beam) val=int(beam->GetSignal("Idproj"));
830 return val;
831}
832
833void NcEvent::SetTarget(Int_t a,Int_t z,Double_t pnuc,Int_t id)
834{
847
848 Int_t newdev=0;
849
850 NcDevice* beam=GetDevice("Beam");
851
852 if (!beam)
853 {
854 beam=new NcDevice();
855 beam->SetNameTitle("Beam","Beam and target specifications");
856 newdev=1;
857 }
858
859 if (a || z)
860 {
861 beam->AddNamedSlot("Atarg");
862 beam->SetSignal(a,"Atarg");
863 beam->AddNamedSlot("Ztarg");
864 beam->SetSignal(z,"Ztarg");
865 }
866 beam->AddNamedSlot("Pnuctarg");
867 beam->SetSignal(pnuc,"Pnuctarg");
868 if (id)
869 {
870 beam->AddNamedSlot("Idtarg");
871 beam->SetSignal(id,"Idtarg");
872 }
873
874 if (newdev)
875 {
876 AddDevice(beam);
877 if (fDevCopy) delete beam;
878 }
879}
880
881void NcEvent::SetTarget(Int_t a,Int_t z,Nc3Vector& p,Int_t id)
882{
895
896 Int_t newdev=0;
897
898 NcDevice* beam=GetDevice("Beam");
899
900 if (!beam)
901 {
902 beam=new NcDevice();
903 beam->SetNameTitle("Beam","Beam and target specifications");
904 newdev=1;
905 }
906
907 Double_t px=p.GetX(1,"car");
908 Double_t py=p.GetX(2,"car");
909 Double_t pz=p.GetX(3,"car");
910 Double_t pnuc=p.GetNorm();
911
912 if (a || z)
913 {
914 beam->AddNamedSlot("Atarg");
915 beam->SetSignal(a,"Atarg");
916 beam->AddNamedSlot("Ztarg");
917 beam->SetSignal(z,"Ztarg");
918 }
919 beam->AddNamedSlot("Pnuctarg");
920 beam->SetSignal(pnuc,"Pnuctarg");
921 beam->AddNamedSlot("Pxnuctarg");
922 beam->SetSignal(px,"Pxnuctarg");
923 beam->AddNamedSlot("Pynuctarg");
924 beam->SetSignal(py,"Pynuctarg");
925 beam->AddNamedSlot("Pznuctarg");
926 beam->SetSignal(pz,"Pznuctarg");
927 if (id)
928 {
929 beam->AddNamedSlot("Idtarg");
930 beam->SetSignal(id,"Idtarg");
931 }
932
933 if (newdev)
934 {
935 AddDevice(beam);
936 if (fDevCopy) delete beam;
937 }
938}
939
941{
947
948 Int_t val=0;
949 NcDevice* beam=GetDevice("Beam");
950 if (beam) val=int(beam->GetSignal("Atarg"));
951 return val;
952}
953
955{
961
962 Int_t val=0;
963 NcDevice* beam=GetDevice("Beam");
964 if (beam) val=int(beam->GetSignal("Ztarg"));
965 return val;
966}
967
969{
975
976 Double_t val=0;
977 NcDevice* beam=GetDevice("Beam");
978 if (beam) val=beam->GetSignal("Pnuctarg");
979 return val;
980}
981
983{
989
990 Int_t val=0;
991 NcDevice* beam=GetDevice("Beam");
992 if (beam) val=int(beam->GetSignal("Idtarg"));
993 return val;
994}
995
997{
1003
1004 const char* name=GetName();
1005 const char* title=GetTitle();
1006 cout << " *" << ClassName() << "::Data*";
1007 if (strlen(name)) cout << " Name : " << GetName();
1008 if (strlen(title)) cout << " Title : " << GetTitle();
1009 cout << endl;
1010 Date(1);
1011 cout << " Run : " << fRun << " Event : " << fEvent
1012 << " Weight : " << fWeight << " SelectLevel : " << fSelectLevel << endl;
1013 ShowDevices(0,kFALSE);
1014 ShowTracks(0);
1015}
1016
1017void NcEvent::Data(TString f,TString u)
1018{
1031
1032 HeaderData();
1033 NcVertex::Data(f,u);
1034}
1035
1037{
1051
1052 if (fDetector)
1053 {
1054 cout << " *" << ClassName() << "::SetDetector* A detector structure is already present --> No action taken." << endl;
1055 return;
1056 }
1057
1058 if (fDevices)
1059 {
1060 cout << " *" << ClassName() << "::SetDetector* Internal storage already contains devices --> No action taken." << endl;
1061 return;
1062 }
1063
1064 // Store this detector structure
1065 if (fDevCopy)
1066 {
1068 }
1069 else
1070 {
1071 fDetector=&d;
1072 }
1073}
1074
1076{
1082
1083 return fDetector;
1084}
1085
1087{
1096
1097 NcDetector* d=new NcDetector("Detector","Default detector structure");
1098 if (fDevCopy) d->SetDevCopy(1);
1099 fDevCopy=1;
1100 fDetector=d;
1101}
1102
1104{
1110
1111 Int_t ndevs=0;
1112
1113 // Investigate the detector structure (if present)
1114 if (fDetector)
1115 {
1116 ndevs=fDetector->GetNdevices(kTRUE);
1117 return ndevs;
1118 }
1119
1120 // Investigate the internal storage array (if present)
1121 // for backward compatibility with old data files
1122 if (fDevices) ndevs=fDevices->GetEntries();
1123 return ndevs;
1124}
1125
1126Int_t NcEvent::GetNdevices(TString classname,TObjArray* hits) const
1127{
1142
1143 Int_t ndevs=0;
1144
1145 // Investigate the detector structure (if present)
1146 if (fDetector)
1147 {
1148 ndevs=fDetector->GetNdevices(classname,kTRUE,hits);
1149 return ndevs;
1150 }
1151
1152 // Investigate the internal storage array (if present)
1153 // for backward compatibility with old data files
1154
1155 if (!hits) // Investigate the stored devices
1156 {
1157 for (Int_t idev=1; idev<=GetNdevices(); idev++)
1158 {
1159 NcDevice* dev=GetDevice(idev);
1160 if (!dev) continue;
1161 if (dev->InheritsFrom(classname)) ndevs++;
1162 }
1163 }
1164 else // Investigate the provided hit array
1165 {
1166 Int_t nh=hits->GetEntries();
1167 if (!nh) return 0;
1168
1169 // Check for the encountered unique device identifiers of the specified class
1170 TArrayI devids(nh);
1171 Int_t idxmax=0;
1172 Int_t jdev=0;
1173 Int_t match=0;
1174 for (Int_t ih=0; ih<nh; ih++)
1175 {
1176 TObject* obj=hits->At(ih);
1177 if (!obj) continue;
1178
1179 NcSignal* sx=0;
1180 if (obj->InheritsFrom("NcSignal")) sx=(NcSignal*)obj;
1181 if (!sx) continue;
1182
1183 NcDevice* dev=sx->GetDevice();
1184 if (!dev) continue;
1185 if (!(dev->InheritsFrom(classname))) continue;
1186
1187 // Update the number of devices
1188 jdev=dev->GetUniqueID();
1189 match=0;
1190 idxmax=ndevs;
1191 for (Int_t idx=0; idx<idxmax; idx++)
1192 {
1193 if (jdev==devids.At(idx))
1194 {
1195 match=1;
1196 break;
1197 }
1198 }
1199 if (!match) // Device number was not present in array
1200 {
1201 ndevs++;
1202 devids.AddAt(jdev,ndevs-1);
1203 }
1204 }
1205 }
1206
1207 return ndevs;
1208}
1209
1211{
1236
1237 if (d.InheritsFrom("NcDetector"))
1238 {
1239 if (fDetector)
1240 {
1241 cout << " *" << ClassName() << "::AddDevice* A detector structure is already present --> No action taken." << endl;
1242 }
1243 else
1244 {
1245 NcDetector* dx=(NcDetector*)&d;
1246 SetDetector(*dx);
1247 }
1248 return;
1249 }
1250
1251 // Create a default detector structure if needed
1252 if (!fDetector && !fDevices) CreateDetector();
1253
1254 if (fDevices && d.InheritsFrom("NcDetectorUnit"))
1255 {
1256 cout << " *" << ClassName() << "::AddDevice* Storage of NcDetectorUnit not supported in backward compatibility mode." << endl;
1257 return;
1258 }
1259
1260 // Use the NcDetector structure to store all devices
1261 if (fDetector)
1262 {
1263 fDetector->AddDevice(d);
1264 return;
1265 }
1266
1267 // Use the old internal device storage for backward compatiblity
1268 if (!fDevices)
1269 {
1270 cout << " *" << ClassName() << "::AddDevice* Internal storage array created for backward compatibility." << endl;
1271 fDevices=new TObjArray();
1272 if (fDevCopy) fDevices->SetOwner();
1273 }
1274
1275 // Add the device to the internal storage of this event
1276 if (fDevCopy)
1277 {
1278 fDevices->Add(d.Clone());
1279 }
1280 else
1281 {
1282 fDevices->Add(&d);
1283 }
1284}
1285
1287{
1293
1294 if (!d) return;
1295
1296 if (fDetector)
1297 {
1298 fDetector->RemoveDevice(d);
1299 return;
1300 }
1301
1302 if (fDevices)
1303 {
1304 TObject* obj=fDevices->Remove(d);
1305 if (obj)
1306 {
1307 if (fDevCopy) delete obj;
1308 fDevices->Compress();
1309 }
1310 }
1311}
1312
1314{
1338
1339 if (!fDevices)
1340 {
1341 if (j==0 || j==1)
1342 {
1343 fDevCopy=j;
1344 }
1345 else
1346 {
1347 cout << " *" << ClassName() << "::SetDevCopy* Invalid argument : " << j << endl;
1348 }
1349 }
1350 else
1351 {
1352 cout << " *" << ClassName() << "::SetDevCopy* Storage already contained devices."
1353 << " ==> DevCopy mode not changed." << endl;
1354 }
1355}
1356
1358{
1376
1377 return fDevCopy;
1378}
1379
1381{
1388
1389 if (fDetector)
1390 {
1391 return fDetector->GetDevice(i);
1392 }
1393
1394 if (!fDevices)
1395 {
1396 return 0;
1397 }
1398 else
1399 {
1400 Int_t ndevs=fDevices->GetEntries();
1401 if (i<=0 || i>ndevs)
1402 {
1403 cout << " *" << ClassName() << "::GetDevice* Invalid argument i : " << i
1404 << " ndevs = " << ndevs << endl;
1405 return 0;
1406 }
1407 else
1408 {
1409 return (NcDevice*)fDevices->At(i-1);
1410 }
1411 }
1412}
1413
1414NcDevice* NcEvent::GetDevice(TString name) const
1415{
1421
1422 // Investigate the detector structure
1423 if (fDetector)
1424 {
1425 return fDetector->GetDevice(name,kTRUE);
1426 }
1427
1428 // Investigate the internal storage array
1429 if (!fDevices)
1430 {
1431 return 0;
1432 }
1433 else
1434 {
1435 TString s;
1436 Int_t ndevs=fDevices->GetEntries();
1437 for (Int_t i=0; i<ndevs; i++)
1438 {
1439 NcDevice* dev=(NcDevice*)fDevices->At(i);
1440 if (dev)
1441 {
1442 s=dev->GetName();
1443 if (s == name) return dev;
1444 }
1445 }
1446
1447 return 0; // No matching name found
1448 }
1449}
1450
1451NcDevice* NcEvent::GetIdDevice(Int_t id,TObjArray* devs) const
1452{
1462
1463 // Investigate the detector structure
1464 if (fDetector)
1465 {
1466 return fDetector->GetIdDevice(id,kTRUE,devs);
1467 }
1468
1469 // Investigate the internal storage aray
1470 TObjArray* arr=devs;
1471 if (!arr) arr=fDevices;
1472
1473 if (!arr || id<0) return 0;
1474
1475 Int_t idx=0;
1476 for (Int_t i=0; i<arr->GetSize(); i++)
1477 {
1478 TObject* obj=arr->At(i);
1479 NcDevice* dev=0;
1480 if (obj->InheritsFrom("NcDevice")) dev=(NcDevice*)obj;
1481 if (dev)
1482 {
1483 idx=dev->GetUniqueID();
1484 if (idx==id) return dev;
1485 }
1486 }
1487 return 0; // No matching id found
1488}
1489
1490NcDevice* NcEvent::GetIdDevice(Int_t id,TString classname) const
1491{
1501
1502 // Investigate the detector structure
1503 if (fDetector)
1504 {
1505 return fDetector->GetIdDevice(id,classname,kTRUE);
1506 }
1507
1508 // Investigate the internal storage array
1509 if (!fDevices || id<0) return 0;
1510
1511 if (classname=="*") classname="NcDevice";
1512
1513 Int_t idx=0;
1514 for (Int_t i=0; i<fDevices->GetEntries(); i++)
1515 {
1516 NcDevice* dev=(NcDevice*)fDevices->At(i);
1517 if (dev)
1518 {
1519 idx=dev->GetUniqueID();
1520 if (idx==id && dev->InheritsFrom(classname)) return dev;
1521 }
1522 }
1523 return 0; // No matching id found for the specified class
1524}
1525
1526void NcEvent::ShowDevices(Int_t mode,Bool_t header) const
1527{
1541
1542 // Investigate the detector structure
1543 if (fDetector)
1544 {
1545 fDetector->ShowDevices(mode,header);
1546 return;
1547 }
1548
1549 // Investigate the internal device storage for backward compatiblity
1550 // with old data files
1551 Int_t ndevs=GetNdevices();
1552 if (ndevs)
1553 {
1554 if (!mode)
1555 {
1556 cout << " There are " << ndevs << " devices available." << endl;
1557 }
1558 else
1559 {
1560 cout << " The following " << ndevs << " devices are available :" << endl;
1561 Int_t nh=0;
1562 Int_t nw=0;
1563 Int_t ns=0;
1564 for (Int_t i=1; i<=ndevs; i++)
1565 {
1566 NcDevice* dev=GetDevice(i);
1567 if (dev)
1568 {
1569 const char* name=dev->GetName();
1570 cout << " Device number : " << i;
1571 cout << " Class : " << dev->ClassName() << " Id : " << dev->GetUniqueID();
1572 if (strlen(name)) cout << " Name : " << name;
1573 nh=dev->GetNhits();
1574 if (nh) cout << " Nhits : " << nh;
1575 nw=dev->GetNwaveforms();
1576 if (nw) cout << " Nwaveforms : " << nw;
1577 ns=dev->GetNsamples();
1578 if (ns) cout << " Nsamples : " << ns;
1579 cout << endl;
1580 }
1581 }
1582 }
1583 }
1584 else
1585 {
1586 cout << " No devices present for this event." << endl;
1587 }
1588}
1589
1590void NcEvent::ShowDevices(TString classname,Int_t mode,Bool_t header) const
1591{
1606
1607 // Investigate the detector structure
1608 if (fDetector)
1609 {
1610 fDetector->ShowDevices(classname,mode,header);
1611 return;
1612 }
1613
1614 // Investigate the internal device storage for backward compatibility
1615 // with old data files
1616 if (classname=="*") classname="NcDevice";
1617 Int_t ndevs=GetNdevices();
1618 if (ndevs)
1619 {
1620 Int_t ndevs2=GetNdevices(classname);
1621 if (!mode || !ndevs2)
1622 {
1623 cout << " There are " << ndevs2 << " selected devices available." << endl;
1624 }
1625 else
1626 {
1627 cout << " The following " << ndevs2 << " selected devices are available :" << endl;
1628 Int_t nh=0,nw=0;
1629 for (Int_t i=1; i<=ndevs; i++)
1630 {
1631 NcDevice* dev=GetDevice(i);
1632 if (dev)
1633 {
1634 if (dev->InheritsFrom(classname))
1635 {
1636 const char* name=dev->GetName();
1637 cout << " Device number : " << i;
1638 cout << " Class : " << dev->ClassName() << " Id : " << dev->GetUniqueID();
1639 if (strlen(name)) cout << " Name : " << name;
1640 nh=dev->GetNhits();
1641 if (nh) cout << " Nhits : " << nh;
1642 nw=dev->GetNwaveforms();
1643 if (nw) cout << " Nwaveforms : " << nw;
1644 cout << endl;
1645 }
1646 }
1647 }
1648 }
1649 }
1650 else
1651 {
1652 cout << " No devices present for this event." << endl;
1653 }
1654}
1655
1656TObjArray* NcEvent::GetDevices(TString classname,TObjArray* devices)
1657{
1676
1677 // Investigate the detector structure
1678 if (fDetector)
1679 {
1680 TObjArray* devs=fDetector->GetDevices(classname,1,devices);
1681 return devs;
1682 }
1683
1684 // Investigate the internal device storage for backward compatibility
1685 // with old data files
1686 if (devices)
1687 {
1688 devices->Clear();
1689 }
1690 else
1691 {
1692 if (fDevs)
1693 {
1694 fDevs->Clear();
1695 }
1696 else
1697 {
1698 fDevs=new TObjArray();
1699 }
1700 }
1701
1702 Int_t ndev=fDevices->GetEntries();
1703 for (Int_t idev=1; idev<=ndev; idev++)
1704 {
1705 NcDevice* dev=GetDevice(idev);
1706 if (!dev) continue;
1707
1708 if (dev->InheritsFrom(classname))
1709 {
1710 if (devices)
1711 {
1712 devices->Add(dev);
1713 }
1714 else
1715 {
1716 fDevs->Add(dev);
1717 }
1718 }
1719 }
1720
1721 if (devices)
1722 {
1723 return 0;
1724 }
1725 else
1726 {
1727 return fDevs;
1728 }
1729}
1730
1731Int_t NcEvent::GetNhits(TString classname)
1732{
1744
1745 Int_t nhits=0;
1746
1747 // Investigate the detector structure
1748 if (fDetector)
1749 {
1750 nhits=fDetector->GetNhitsDevices(classname,kTRUE,kTRUE);
1751 return nhits;
1752 }
1753
1754 // Investigate the internal storage for backward compatibility
1755 // with old data files
1756 if (classname=="*") classname="NcDevice";
1757 TObjArray hits;
1758 GetHits(classname,&hits);
1759 nhits=hits.GetEntries();
1760 return nhits;
1761}
1762
1763TObjArray* NcEvent::GetHits(TString classname,TObjArray* hits,TString name,Int_t mode,Int_t opt)
1764{
1802
1803 // Investigate the detector structure
1804 if (fDetector)
1805 {
1806 TObjArray* arr;
1807 arr=fDetector->GetHitsDevices(classname,kTRUE,kTRUE,hits,name,mode,opt);
1808 return arr;
1809 }
1810
1811 // Investigate the internal storage for backward compatibility
1812 // with old data files
1813 if (classname=="*") classname="NcDevice";
1814
1815 LoadHits(classname,hits);
1816
1817 // Check for further hit selection criteria
1818 if (name!="none")
1819 {
1820 NcDevice selector;
1821 TObjArray* selected=hits;
1822 if (!selected) selected=fHits;
1823 TObjArray ahits(*selected);
1824 selector.GetHits(*selected,name,mode,opt,&ahits);
1825 }
1826
1827 if (hits)
1828 {
1829 return 0;
1830 }
1831 else
1832 {
1833 return fHits;
1834 }
1835}
1836
1837NcSignal* NcEvent::GetIdHit(Int_t id,TString classname)
1838{
1845
1846 if (id<0) return 0;
1847
1848 NcSignal* sx=0;
1849
1850 // Investigate the detector structure
1851 if (fDetector)
1852 {
1853 sx=fDetector->GetIdHit(id,classname,kTRUE,kTRUE);
1854 return sx;
1855 }
1856
1857 // Investigate the internal storage array for backward compatibility
1858 // with old data files
1859 if (classname=="*") classname="NcDevice";
1860
1861 TObjArray hits;
1862 LoadHits(classname,&hits);
1863
1864 Int_t nhits=hits.GetEntries();
1865
1866 if (!nhits) return 0;
1867
1868 Int_t sid=0;
1869 for (Int_t i=0; i<nhits; i++)
1870 {
1871 sx=(NcSignal*)hits.At(i);
1872 if (sx)
1873 {
1874 sid=sx->GetUniqueID();
1875 if (id==sid) return sx;
1876 }
1877 }
1878 return 0; // No matching id found
1879}
1880
1881void NcEvent::LoadHits(TString classname,TObjArray* hits)
1882{
1900
1901 if (classname=="*") classname="NcDevice";
1902
1903 if (hits)
1904 {
1905 hits->Clear();
1906 }
1907 else
1908 {
1909 if (fHits)
1910 {
1911 fHits->Clear();
1912 }
1913 else
1914 {
1915 fHits=new TObjArray();
1916 }
1917 }
1918
1919 for (Int_t idev=1; idev<=fDevices->GetEntries(); idev++)
1920 {
1921 NcDevice* dev=GetDevice(idev);
1922 if (!dev) continue;
1923
1924 if (!(dev->InheritsFrom(classname))) continue;
1925
1926 for (Int_t ih=1; ih<=dev->GetNhits(); ih++)
1927 {
1928 NcSignal* sx=dev->GetHit(ih);
1929 if (!sx) continue;
1930 if (hits)
1931 {
1932 hits->Add(sx);
1933 }
1934 else
1935 {
1936 fHits->Add(sx);
1937 }
1938 }
1939 }
1940}
1941
1942TObjArray* NcEvent::SortHits(TString classname,Int_t idx,Int_t mode,Int_t mcal,Int_t deadcheck,TObjArray* ordered)
1943{
1983
1984 // Investigate the detector structure
1985 if (fDetector)
1986 {
1987 TObjArray* arr=fDetector->SortHits(classname,kTRUE,kTRUE,idx,mode,mcal,deadcheck,ordered);
1988 return arr;
1989 }
1990
1991 // Investigate the internal storage array for backward compatibility
1992 // with old data files
1993 if (classname=="*") classname="NcDevice";
1994
1995 if (ordered) ordered->Clear();
1996
1997 if (idx<=0 || abs(mode)!=1) return 0;
1998
1999 TObjArray hits;
2000 LoadHits(classname,&hits);
2001
2002 NcDevice dev;
2003 TObjArray* arr=dev.SortHits(idx,mode,&hits,mcal,deadcheck,ordered);
2004
2005 if (ordered) return 0;
2006
2007 if (fHits)
2008 {
2009 delete fHits;
2010 fHits=0;
2011 }
2012 if (arr) fHits=new TObjArray(*arr);
2013 return fHits;
2014}
2015
2016TObjArray* NcEvent::SortHits(TString classname,TString name,Int_t mode,Int_t mcal,Int_t deadcheck,TObjArray* ordered)
2017{
2057
2058 // Investigate the detector structure
2059 if (fDetector)
2060 {
2061 TObjArray* arr=fDetector->SortHits(classname,kTRUE,kTRUE,name,mode,mcal,deadcheck,ordered);
2062 return arr;
2063 }
2064
2065 // Investigate the internal storage array for backward compatibility
2066 // with old data files
2067 if (classname=="*") classname="NcDevice";
2068
2069 if (ordered) ordered->Clear();
2070
2071 if (abs(mode)!=1) return 0;
2072
2073 TObjArray hits;
2074 LoadHits(classname,&hits);
2075
2076 NcDevice dev;
2077 TObjArray* arr=dev.SortHits(name,mode,&hits,mcal,deadcheck,ordered);
2078
2079 if (ordered) return 0;
2080
2081 if (fHits)
2082 {
2083 delete fHits;
2084 fHits=0;
2085 }
2086 if (arr) fHits=new TObjArray(*arr);
2087 return fHits;
2088}
2089
2090Nc3Vector NcEvent::GetHitPath(TObjArray* hits,Int_t pos) const
2091{
2109
2110 NcDevice d;
2111 Nc3Vector v=d.GetHitPath(hits,pos);
2112
2113 return v;
2114}
2115
2116NcPosition NcEvent::GetCOG(TObjArray* hits,Int_t pos,TString slotname,Int_t mode) const
2117{
2135
2136 NcDevice d;
2137 NcPosition cog=d.GetCOG(hits,pos,slotname,mode);
2138
2139 return cog;
2140}
2141
2142Double_t NcEvent::GetCVAL(TObjArray* hits,TString obsname,TString weightname,Int_t mode,Int_t type) const
2143{
2160
2161 Double_t cval=0;
2162
2163 NcDevice d;
2164 cval=d.GetCVAL(hits,obsname,weightname,mode,type);
2165
2166 return cval;
2167}
2168
2169void NcEvent::GetExtremes(TString classname,Float_t& vmin,Float_t& vmax,Int_t idx,Int_t mode,Int_t deadcheck)
2170{
2192
2193 if (classname=="*") classname="NcDevice";
2194
2195 if (idx<=0) return;
2196
2197 TObjArray hits;
2198 GetHits(classname,&hits);
2199
2200 NcDevice dev;
2201 dev.GetExtremes(vmin,vmax,idx,&hits,mode,deadcheck);
2202}
2203
2204void NcEvent::GetExtremes(TString classname,Float_t& vmin,Float_t& vmax,TString name,Int_t mode,Int_t deadcheck)
2205{
2226
2227 if (classname=="*") classname="NcDevice";
2228
2229 TObjArray hits;
2230 GetHits(classname,&hits);
2231
2232 NcDevice dev;
2233 dev.GetExtremes(vmin,vmax,name,&hits,mode,deadcheck);
2234}
2235
2236void NcEvent::DisplayHits(TString classname,Int_t idx,Float_t scale,Int_t dp,Int_t mode,Int_t mcol)
2237{
2272
2273 if (idx<=0) return;
2274
2275 if (classname=="*") classname="NcDevice";
2276
2277 TObjArray hits;
2278 GetHits(classname,&hits);
2279
2280 NcDevice* dev=new NcDevice();
2281 dev->DisplayHits(idx,scale,&hits,dp,mode,mcol);
2282
2283 if (fDisplay)
2284 {
2285 delete fDisplay;
2286 fDisplay=0;
2287 }
2288 fDisplay=dev;
2289}
2290
2291void NcEvent::DisplayHits(TString classname,TString name,Float_t scale,Int_t dp,Int_t mode,Int_t mcol)
2292{
2329
2330 if (classname=="*") classname="NcDevice";
2331
2332 TObjArray hits;
2333 GetHits(classname,&hits);
2334
2335 NcDevice* dev=new NcDevice();
2336 dev->DisplayHits(name,scale,&hits,dp,mode,mcol);
2337
2338 if (fDisplay)
2339 {
2340 delete fDisplay;
2341 fDisplay=0;
2342 }
2343 fDisplay=dev;
2344}
2345
2346void NcEvent::ShowHits(TString classname,Int_t mode,TString f,TString u)
2347{
2365
2366 if (classname=="*") classname="NcDevice";
2367
2368 // Investigate the detector structure
2369 if (fDetector)
2370 {
2371 fDetector->ShowHits(classname,kTRUE,kTRUE,mode,f,u);
2372 return;
2373 }
2374
2375 // Investigate the internal storage array for backward compatibility
2376 // with old data files
2377 TObjArray hits;
2378 GetHits(classname,&hits);
2379
2380 Int_t nhits=hits.GetEntries();
2381
2382 cout << " *" << ClassName() << "::ShowHits* There are " << nhits
2383 << " hits recorded for device class " << classname << endl;
2384
2385 if (!nhits || !mode) return;
2386
2387 NcPosition r;
2388 for (Int_t i=0; i<hits.GetEntries(); i++)
2389 {
2390 NcSignal* sx=(NcSignal*)hits.At(i);
2391 if (sx) sx->Data(f,u);
2392 if (mode==2)
2393 {
2394 NcDevice* dev=(NcDevice*)sx->GetDevice();
2395 if (!dev) continue;
2396 r=dev->GetPosition();
2397 cout << " Device Position";
2398 r.Data(f,u);
2399 }
2400 }
2401}
2402
2403TObjArray* NcEvent::SortDevices(TString classname,TString name,Int_t mode,Int_t mcal,Int_t deadcheck,TObjArray* ordered)
2404{
2443
2444 if (classname=="*") classname="NcDevice";
2445
2446 if (ordered) ordered->Clear();
2447
2448 TObjArray hits;
2449 SortHits(classname,name,mode,mcal,deadcheck,&hits);
2450
2451 TObjArray* devs=SortDevices(&hits,"*",0,mcal,deadcheck,ordered);
2452
2453 if (ordered)
2454 {
2455 return 0;
2456 }
2457 else
2458 {
2459 return devs;
2460 }
2461}
2462
2463TObjArray* NcEvent::SortDevices(TString classname,Int_t idx,Int_t mode,Int_t mcal,Int_t deadcheck,TObjArray* ordered)
2464{
2503
2504 if (ordered) ordered->Clear();
2505
2506 if (classname=="*") classname="NcDevice";
2507
2508 TObjArray hits;
2509 SortHits(classname,idx,mode,mcal,deadcheck,&hits);
2510
2511 TObjArray* devs=SortDevices(&hits,0,0,mcal,deadcheck,ordered);
2512
2513 if (ordered)
2514 {
2515 return 0;
2516 }
2517 else
2518 {
2519 return devs;
2520 }
2521}
2522
2523TObjArray* NcEvent::SortDevices(TObjArray* hits,TString name,Int_t mode,Int_t mcal,Int_t deadcheck,TObjArray* ordered)
2524{
2564
2565 if (ordered)
2566 {
2567 ordered->Clear();
2568 }
2569 else
2570 {
2571 if (fOrdered)
2572 {
2573 fOrdered->Clear();
2574 }
2575 else
2576 {
2577 fOrdered=new TObjArray();
2578 }
2579 }
2580
2581 if (!hits) return 0;
2582
2583 TObjArray* sorthits=new TObjArray(*hits);
2584 NcDevice dev;
2585 if (mode) dev.SortHits(name,mode,hits,mcal,deadcheck,sorthits);
2586
2587 TObjArray* arr=0; // Generic array pointer to be used in the logic below
2588
2589 if (ordered)
2590 {
2591 arr=ordered;
2592 }
2593 else
2594 {
2595 arr=fOrdered;
2596 }
2597
2598 Int_t nhits=sorthits->GetEntries();
2599 Int_t exist=0;
2600 for (Int_t ih=0; ih<nhits; ih++)
2601 {
2602 NcSignal* sx=(NcSignal*)sorthits->At(ih);
2603 if (!sx) continue;
2604 NcDevice* dx=sx->GetDevice();
2605 exist=0;
2606 for (Int_t id=0; id<arr->GetEntries(); id++)
2607 {
2608 NcDevice* odx=(NcDevice*)arr->At(id);
2609 if (dx==odx)
2610 {
2611 exist=1;
2612 break;
2613 }
2614 }
2615 if (!exist) arr->Add(dx);
2616 }
2617
2618 delete sorthits;
2619
2620 if (ordered)
2621 {
2622 return 0;
2623 }
2624 else
2625 {
2626 return fOrdered;
2627 }
2628}
2629
2630TObjArray* NcEvent::SortDevices(TObjArray* hits,Int_t idx,Int_t mode,Int_t mcal,Int_t deadcheck,TObjArray* ordered)
2631{
2671
2672 if (ordered)
2673 {
2674 ordered->Clear();
2675 }
2676 else
2677 {
2678 if (fOrdered)
2679 {
2680 fOrdered->Clear();
2681 }
2682 else
2683 {
2684 fOrdered=new TObjArray();
2685 }
2686 }
2687
2688 if (!hits) return 0;
2689
2690 TObjArray* sorthits=new TObjArray(*hits);
2691 NcDevice dev;
2692 if (mode) dev.SortHits(idx,mode,hits,mcal,deadcheck,sorthits);
2693
2694 TObjArray* arr=0; // Generic array pointer to be used in the logic below
2695
2696 if (ordered)
2697 {
2698 arr=ordered;
2699 }
2700 else
2701 {
2702 arr=fOrdered;
2703 }
2704
2705 Int_t nhits=sorthits->GetEntries();
2706 Int_t exist=0;
2707 for (Int_t ih=0; ih<nhits; ih++)
2708 {
2709 NcSignal* sx=(NcSignal*)sorthits->At(ih);
2710 if (!sx) continue;
2711 NcDevice* dx=sx->GetDevice();
2712 exist=0;
2713 for (Int_t id=0; id<arr->GetEntries(); id++)
2714 {
2715 NcDevice* odx=(NcDevice*)arr->At(id);
2716 if (dx==odx)
2717 {
2718 exist=1;
2719 break;
2720 }
2721 }
2722 if (!exist) arr->Add(dx);
2723 }
2724
2725 delete sorthits;
2726
2727 if (ordered)
2728 {
2729 return 0;
2730 }
2731 else
2732 {
2733 return fOrdered;
2734 }
2735}
2736
2737TObject* NcEvent::Clone(const char* name) const
2738{
2750
2751 NcEvent* evt=new NcEvent(*this);
2752 if (name)
2753 {
2754 if (strlen(name)) evt->SetName(name);
2755 }
2756 return evt;
2757}
2758
2759
ClassImp(NcEvent)
Double_t GetX(Int_t i, TString f, TString u="rad")
Double_t GetNorm()
void AddNamedSlot(TString s)
Creation and investigation of an NCFS generic detector structure.
Definition NcDetector.h:12
virtual TObject * Clone(const char *name="") const
void SetDevCopy(Int_t j)
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
TObjArray * GetHits()
Definition NcDevice.cxx:573
NcPosition GetCOG(TObjArray *hits, Int_t pos=0, TString slotname="none", Int_t mode=0) const
Nc3Vector GetHitPath(TObjArray *hits, Int_t pos=0) const
virtual TObject * Clone(const char *name="") const
void DisplayHits(TString name, Float_t scale=-1, TObjArray *hits=0, Int_t dp=0, Int_t mode=1, Int_t mcol=4)
Double_t GetCVAL(TObjArray *hits, TString obsname, TString weightname="none", Int_t mode=0, Int_t type=1) const
Int_t GetNhits() const
Definition NcDevice.cxx:437
NcSignal * GetHit(Int_t j) const
Definition NcDevice.cxx:489
void GetExtremes(Float_t &vmin, Float_t &vmax, Int_t idx=1, TObjArray *hits=0, Int_t mode=1, Int_t deadcheck=1) const
Definition NcDevice.cxx:721
TObjArray * SortHits(TString name, Int_t mode=-1, TObjArray *hits=0, Int_t mcal=1, Int_t deadcheck=1, TObjArray *ordered=0)
Definition NcDevice.cxx:984
Creation and investigation of an NCFS generic event structure.
Definition NcEvent.h:15
NcPosition GetCOG(TObjArray *hits, Int_t pos=0, TString slotname="none", Int_t mode=0) const
Definition NcEvent.cxx:2116
Int_t GetProjectileId() const
Definition NcEvent.cxx:819
TObjArray * fDevs
! Temp. array to hold references to user selected devices
Definition NcEvent.h:96
NcDetector * fDetector
Definition NcEvent.h:90
NcDevice * GetIdDevice(Int_t id, TObjArray *devs=0) const
Definition NcEvent.cxx:1451
TObjArray * SortDevices(TString classname, TString name, Int_t mode=-1, Int_t mcal=1, Int_t deadcheck=1, TObjArray *ordered=0)
Definition NcEvent.cxx:2403
TObjArray * SortHits(TString classname, TString name, Int_t mode=-1, Int_t mcal=1, Int_t deadcheck=1, TObjArray *ordered=0)
Definition NcEvent.cxx:2016
void SetProjectile(Int_t a, Int_t z, Double_t pnuc, Int_t id=0)
Definition NcEvent.cxx:670
Double_t fWeight
Definition NcEvent.h:88
Double_t GetTargetPnuc() const
Definition NcEvent.cxx:968
virtual void Reset()
Definition NcEvent.cxx:436
Int_t GetDevCopy() const
Definition NcEvent.cxx:1357
void AddDevice(NcDevice &d)
Definition NcEvent.cxx:1210
void LoadHits(TString classname, TObjArray *hits=0)
Definition NcEvent.cxx:1881
TObject * fDisplay
! Temp. pointer to hold objects which serve event displays
Definition NcEvent.h:95
Int_t GetEventNumber() const
Definition NcEvent.cxx:637
void GetExtremes(TString classname, Float_t &vmin, Float_t &vmax, Int_t idx=1, Int_t mode=1, Int_t deadcheck=1)
Definition NcEvent.cxx:2169
Int_t fSelectLevel
Definition NcEvent.h:89
Int_t fDevCopy
Definition NcEvent.h:92
TObjArray * fHits
! Temp. array to hold references to the registered NcDevice hits
Definition NcEvent.h:93
void SetEventNumber(Int_t evt)
Definition NcEvent.cxx:573
Int_t GetRunNumber() const
Definition NcEvent.cxx:626
Double_t GetWeight() const
Definition NcEvent.cxx:648
virtual TObject * Clone(const char *name="") const
Definition NcEvent.cxx:2737
void RemoveDevice(NcDevice *d)
Definition NcEvent.cxx:1286
void ShowDevices(Int_t mode=1, Bool_t header=kTRUE) const
Definition NcEvent.cxx:1526
TObjArray * fDevices
Definition NcEvent.h:91
NcDetector * GetDetector() const
Definition NcEvent.cxx:1075
virtual void HeaderData()
Definition NcEvent.cxx:996
void SetDevCopy(Int_t j)
Definition NcEvent.cxx:1313
Int_t GetSelectLevel() const
Definition NcEvent.cxx:659
virtual void Data(TString f="car", TString u="rad")
Definition NcEvent.cxx:1017
void SetSelectLevel(Int_t level)
Definition NcEvent.cxx:596
void SetDayTime(TTimeStamp &stamp)
Definition NcEvent.cxx:524
Double_t GetCVAL(TObjArray *hits, TString obsname, TString weightname="none", Int_t mode=0, Int_t type=1) const
Definition NcEvent.cxx:2142
void SetTarget(Int_t a, Int_t z, Double_t pnuc, Int_t id=0)
Definition NcEvent.cxx:833
Int_t GetProjectileA() const
Definition NcEvent.cxx:777
TObjArray * fOrdered
! Temp. array to hold references to various ordered objects
Definition NcEvent.h:94
Int_t fEvent
Definition NcEvent.h:87
Int_t GetProjectileZ() const
Definition NcEvent.cxx:791
NcSignal * GetIdHit(Int_t id, TString classname)
Definition NcEvent.cxx:1837
Int_t GetNdevices() const
Definition NcEvent.cxx:1103
NcDevice * GetDevice(Int_t i) const
Definition NcEvent.cxx:1380
void DisplayHits(TString classname, TString name, Float_t scale=-1, Int_t dp=0, Int_t mode=1, Int_t mcol=4)
Definition NcEvent.cxx:2291
void SetWeight(Double_t weight)
Definition NcEvent.cxx:584
virtual ~NcEvent()
Definition NcEvent.cxx:337
Int_t GetNhits(TString classname)
Definition NcEvent.cxx:1731
TObjArray * GetDevices(TString classname, TObjArray *devices=0)
Definition NcEvent.cxx:1656
TTimeStamp GetDayTime() const
Definition NcEvent.cxx:608
void SetDetector(NcDetector d)
Definition NcEvent.cxx:1036
virtual void SetOwner(Bool_t own=kTRUE)
Definition NcEvent.cxx:490
Double_t GetProjectilePnuc() const
Definition NcEvent.cxx:805
Int_t fRun
Definition NcEvent.h:86
Int_t GetTargetId() const
Definition NcEvent.cxx:982
void SetRunNumber(Int_t run)
Definition NcEvent.cxx:562
Int_t GetTargetA() const
Definition NcEvent.cxx:940
TObjArray * GetHits(TString classname, TObjArray *hits=0, TString name="none", Int_t mode=0, Int_t opt=0)
Definition NcEvent.cxx:1763
Int_t GetTargetZ() const
Definition NcEvent.cxx:954
void CreateDetector()
Definition NcEvent.cxx:1086
void ShowHits(TString classname, Int_t mode=1, TString f="car", TString u="rad")
Definition NcEvent.cxx:2346
Nc3Vector GetHitPath(TObjArray *hits, Int_t pos=0) const
Definition NcEvent.cxx:2090
void ShowTracks(Int_t mode=1, TString f="car", TString u="rad", TObjArray *tracks=0)
Definition NcJet.cxx:1159
void GetPosition(Double_t *r, TString f, TString u="rad", Float_t s=-1) const
virtual void Data(TString f="car", TString u="rad") const
Generic handling of (extrapolated) detector signals.
Definition NcSignal.h:23
Int_t GetNwaveforms() const
virtual void SetSignal(Double_t sig, Int_t j=1)
Definition NcSignal.cxx:516
NcDevice * GetDevice() const
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
Int_t GetNsamples() const
virtual void Data(TString f="car", TString u="rad") const
Definition NcSignal.cxx:959
void SetSystemTime()
void Date(Int_t mode=3, Double_t offset=0)
virtual void Reset()
Definition NcVertex.cxx:423
virtual void Data(TString f="car", TString u="rad")
Definition NcVertex.cxx:637
virtual void SetOwner(Bool_t own=kTRUE)
Definition NcVertex.cxx:265