X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FMUONCheckDI.C;h=8dfd2681766b597505349695804e6c5c22ce60e5;hb=7b830a3f346276d0ae359b9c7ce942f8372b332a;hp=75ab7791e9af30a3301bdcac7f3f9208844ecf11;hpb=61fed964c394ed12c1f33fa26e4d556a581c6893;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/MUONCheckDI.C b/MUON/MUONCheckDI.C index 75ab7791e9a..8dfd2681766 100644 --- a/MUON/MUONCheckDI.C +++ b/MUON/MUONCheckDI.C @@ -15,20 +15,16 @@ /* $Id$ */ -// -// Macro for checking AliMUONDataInterface and AliMUONMCDataInterface. -// By Bruce Becker, DAPNIA/SPhN/CEA Saclay -// -// Modified to updated versions of data interfaces. -// Artur Szostak (University of Cape Town) -// +/// \ingroup macros +/// \file MUONCheckDI.C +/// \brief Macro for checking AliMUONDataInterface and AliMUONMCDataInterface. +/// +/// \author Bruce Becker, DAPNIA/SPhN/CEA Saclay +/// +/// Modified to updated versions of data interfaces +/// by Artur Szostak (University of Cape Town) #if !defined(__CINT__) || defined(__MAKECINT__) -#include -#include -#include -#include -#include #include "AliMUONHit.h" #include "AliMUONVDigit.h" #include "AliMUONVCluster.h" @@ -37,12 +33,23 @@ #include "AliMUONGlobalTrigger.h" #include "AliMUONMCDataInterface.h" #include "AliMUONDataInterface.h" +#include "AliMUONVHitStore.h" #include "AliMUONVDigitStore.h" #include "AliMUONVClusterStore.h" #include "AliMUONVTriggerStore.h" #include "AliMpConstants.h" #include "AliMpDEManager.h" + +#include "AliCDBManager.h" + +#include +#include +#include +#include +#include + #include + #endif @@ -60,7 +67,19 @@ Int_t Compare(const TObject* a, const TObject* b) } else if (a->IsA() == AliMUONRegionalTrigger::Class() && b->IsA() == AliMUONRegionalTrigger::Class()) { - result = memcmp(a, b, sizeof(AliMUONRegionalTrigger)); + const AliMUONRegionalTrigger* ra = static_cast(a); + const AliMUONRegionalTrigger* rb = static_cast(b); + if (ra->GetId() < rb->GetId()) return -1; + if (ra->GetId() > rb->GetId()) return 1; + if (ra->GetLocalOutput(0) < rb->GetLocalOutput(0)) return -1; + if (ra->GetLocalOutput(0) > rb->GetLocalOutput(0)) return 1; + if (ra->GetLocalOutput(1) < rb->GetLocalOutput(1)) return -1; + if (ra->GetLocalOutput(1) > rb->GetLocalOutput(1)) return 1; + if (ra->GetLocalMask() < rb->GetLocalMask()) return -1; + if (ra->GetLocalMask() > rb->GetLocalMask()) return 1; + if (ra->GetOutput() < rb->GetOutput()) return -1; + if (ra->GetOutput() > rb->GetOutput()) return 1; + return 0; } else if (a->IsA() == AliMUONGlobalTrigger::Class() && b->IsA() == AliMUONGlobalTrigger::Class()) { @@ -85,17 +104,18 @@ Int_t Compare(const TObject* a, const TObject* b) * The arrays and objects are then compared to each other. The arrays and objects * should contain the same information if everything is working correctly with * AliMUONMCDataInterface. If not then the difference is printed together with an - * error message and kFALSE is returned. + * error message and false is returned. */ bool SimTriggersOk() { - AliMUONMCDataInterface data; + AliMUONMCDataInterface data("generated/galice.root"); for (Int_t event = 0; event < data.NumberOfEvents(); event++) { TObjArray localsFromStore, regionalsFromStore; localsFromStore.SetOwner(kTRUE); regionalsFromStore.SetOwner(kTRUE); AliMUONVTriggerStore* store = data.TriggerStore(event); + if (store == NULL) return false; AliMUONGlobalTrigger* globalFromStore = static_cast(store->Global()->Clone()); TIter nextLocal(store->CreateLocalIterator()); AliMUONLocalTrigger* localTrig; @@ -195,6 +215,274 @@ bool SimTriggersOk() regionalsByIndex[i]->Print(); return false; } + regionalsFromStore[i]->Print(); + regionalsByIndex[i]->Print(); + } + } + return true; +} + +/** + * This method fills internal arrays with s-digits returned by the AliMUONMCDataInterface. + * For each set of interface methods available a TObjArray is filled with copies of + * the s-digits. These arrays are sorted and then compared to each other. The arrays + * should contain the same s-digit information if everything is working correctly with + * AliMUONMCDataInterface. If not then the difference is printed together with an + * error message and false is returned. + */ +bool SimSDigitsOk() +{ + AliMUONMCDataInterface data("generated/galice.root"); + for (Int_t event = 0; event < data.NumberOfEvents(); event++) + { + TObjArray digitsFromStore; + digitsFromStore.SetOwner(kTRUE); + AliMUONVDigitStore* store = data.SDigitStore(event); + if (store == NULL) return false; + TIter next(store->CreateIterator()); + AliMUONVDigit* digit; + while ( (digit = static_cast( next() )) != NULL ) + { + digitsFromStore.Add(digit->Clone()); + } + digitsFromStore.Sort(); + + TObjArray digitsByDetElem; + digitsByDetElem.SetOwner(kTRUE); + data.GetEvent(event); + for (Int_t detElem = 0; detElem < 1500; detElem++) + { + if (! AliMpDEManager::IsValidDetElemId(detElem)) continue; + Int_t ndigits = data.NumberOfSDigits(detElem); + for (Int_t i = 0; i < ndigits; i++) + { + AliMUONVDigit* digit = data.SDigit(detElem, i); + digitsByDetElem.Add(digit->Clone()); + } + } + digitsByDetElem.Sort(); + + TObjArray digitsByChamber; + digitsByChamber.SetOwner(kTRUE); + data.GetEvent(event); + for (Int_t chamber = 0; chamber < AliMpConstants::NofChambers(); chamber++) + for (Int_t cathode = 0; cathode < 2; cathode++) + { + Int_t ndigits = data.NumberOfSDigits(chamber, cathode); + for (Int_t i = 0; i < ndigits; i++) + { + AliMUONVDigit* digit = data.SDigit(chamber, cathode, i); + digitsByChamber.Add(digit->Clone()); + } + } + digitsByChamber.Sort(); + + // Now check that all the lists of s-digits contain the same results. + // They must. If they do not then something is wrong with the implementation + // of AliMUONMCDataInterface. + if (digitsFromStore.GetEntriesFast() != digitsByDetElem.GetEntriesFast() + || digitsFromStore.GetEntriesFast() != digitsByChamber.GetEntriesFast()) + { + Error( "SimSDigitsOk", + "The AliMUONMCDataInterface does not return all the s-digits correctly" + " through all its user interface methods. We got the following" + " numbers of s-digits: %d, %d and %d", + digitsFromStore.GetEntriesFast(), + digitsByDetElem.GetEntriesFast(), + digitsByChamber.GetEntriesFast() + ); + return false; + } + for (Int_t i = 0; i < digitsFromStore.GetEntriesFast(); i++) + { + if (digitsFromStore[i]->Compare(digitsByDetElem[i]) != 0 + || digitsFromStore[i]->Compare(digitsByChamber[i]) != 0) + { + Error( "SimSDigitsOk", + "The AliMUONMCDataInterface does not return identical s-digits" + " through all its user interface methods. The incorrect" + " s-digit has index %d after sorting.", + i + ); + digitsFromStore[i]->Print(); + digitsByChamber[i]->Print(); + digitsByDetElem[i]->Print(); + return false; + } + } + } + return true; +} + +/** + * This method fills internal arrays with digits returned by the AliMUONMCDataInterface. + * For each set of interface methods available a TObjArray is filled with copies of + * the digits. These arrays are sorted and then compared to each other. The arrays + * should contain the same digit information if everything is working correctly with + * AliMUONMCDataInterface. If not then the difference is printed together with an + * error message and false is returned. + */ +bool SimDigitsOk() +{ + AliMUONMCDataInterface data("generated/galice.root"); + for (Int_t event = 0; event < data.NumberOfEvents(); event++) + { + TObjArray digitsFromStore; + digitsFromStore.SetOwner(kTRUE); + AliMUONVDigitStore* store = data.DigitStore(event); + if (store == NULL) return false; + TIter next(store->CreateIterator()); + AliMUONVDigit* digit; + while ( (digit = static_cast( next() )) != NULL ) + { + digitsFromStore.Add(digit->Clone()); + } + digitsFromStore.Sort(); + + TObjArray digitsByDetElem; + digitsByDetElem.SetOwner(kTRUE); + data.GetEvent(event); + for (Int_t detElem = 0; detElem < 1500; detElem++) + { + if (! AliMpDEManager::IsValidDetElemId(detElem)) continue; + Int_t ndigits = data.NumberOfDigits(detElem); + for (Int_t i = 0; i < ndigits; i++) + { + AliMUONVDigit* digit = data.Digit(detElem, i); + digitsByDetElem.Add(digit->Clone()); + } + } + digitsByDetElem.Sort(); + + TObjArray digitsByChamber; + digitsByChamber.SetOwner(kTRUE); + data.GetEvent(event); + for (Int_t chamber = 0; chamber < AliMpConstants::NofChambers(); chamber++) + for (Int_t cathode = 0; cathode < 2; cathode++) + { + Int_t ndigits = data.NumberOfDigits(chamber, cathode); + for (Int_t i = 0; i < ndigits; i++) + { + AliMUONVDigit* digit = data.Digit(chamber, cathode, i); + digitsByChamber.Add(digit->Clone()); + } + } + digitsByChamber.Sort(); + + // Now check that all the lists of digits contain the same results. + // They must. If they do not then something is wrong with the implementation + // of AliMUONMCDataInterface. + if (digitsFromStore.GetEntriesFast() != digitsByDetElem.GetEntriesFast() + || digitsFromStore.GetEntriesFast() != digitsByChamber.GetEntriesFast()) + { + Error( "SimDigitsOk", + "The AliMUONMCDataInterface does not return all the digits correctly" + " through all its user interface methods. We got the following" + " numbers of digits: %d, %d and %d", + digitsFromStore.GetEntriesFast(), + digitsByDetElem.GetEntriesFast(), + digitsByChamber.GetEntriesFast() + ); + return false; + } + for (Int_t i = 0; i < digitsFromStore.GetEntriesFast(); i++) + { + if (digitsFromStore[i]->Compare(digitsByDetElem[i]) != 0 + || digitsFromStore[i]->Compare(digitsByChamber[i]) != 0) + { + Error( "SimDigitsOk", + "The AliMUONMCDataInterface does not return identical digits" + " through all its user interface methods. The incorrect" + " digit has index %d after sorting.", + i + ); + digitsFromStore[i]->Print(); + digitsByChamber[i]->Print(); + digitsByDetElem[i]->Print(); + return false; + } + } + } + return true; +} + +/** + * This method fills internal arrays with hits returned by the AliMUONMCDataInterface. + * For each set of interface methods available a TObjArray is filled with copies of + * the hits. These arrays are then compared to each other. The arrays should contain + * the same hit information if everything is working correctly with AliMUONMCDataInterface. + * If not then the difference is printed together with an error message and false is returned. + */ +bool SimHitsOk() +{ + AliMUONMCDataInterface data("generated/galice.root"); + for (Int_t event = 0; event < data.NumberOfEvents(); event++) + { + if (data.NumberOfTracks(event) != data.NumberOfTracks()) + { + Error( "SimHitsOk", + "The AliMUONMCDataInterface does not return the same number of tracks" + " through all its user interface methods. We got the following" + " numbers of tracks: %d and %d", + data.NumberOfTracks(event), + data.NumberOfTracks() + ); + return false; + } + + for (Int_t track = 0; track < data.NumberOfTracks(); track++) + { + TObjArray hitsFromStore; + hitsFromStore.SetOwner(kTRUE); + AliMUONVHitStore* store = data.HitStore(event, track); + if (store == NULL) return false; + TIter next(store->CreateIterator()); + AliMUONHit* hit; + while ( (hit = static_cast( next() )) != NULL ) + { + hitsFromStore.Add(hit->Clone()); + } + //hitsFromStore.Sort(); // Unfortunately hits do not implement the Compare method. + + TObjArray hitsByMethod; + hitsByMethod.SetOwner(kTRUE); + data.GetEvent(event); + for (Int_t i = 0; i < data.NumberOfHits(track); i++) + { + AliMUONHit* hit = data.Hit(track, i); + hitsByMethod.Add(hit->Clone()); + } + //hitsByMethod.Sort(); // Unfortunately hits do not implement the Compare method. + + // Now check that both lists of hits contain the same results. + // They must. If they do not then something is wrong with the implementation + // of AliMUONMCDataInterface. + if (hitsFromStore.GetEntriesFast() != hitsByMethod.GetEntriesFast()) + { + Error( "SimHitsOk", + "The AliMUONMCDataInterface does not return all the hits correctly" + " through all its user interface methods. We got the following" + " numbers of hits: %d and %d", + hitsFromStore.GetEntriesFast(), + hitsByMethod.GetEntriesFast() + ); + return false; + } + for (Int_t i = 0; i < hitsFromStore.GetEntriesFast(); i++) + { + if (Compare(hitsFromStore[i], hitsByMethod[i]) != 0) + { + Error( "SimHitsOk", + "The AliMUONMCDataInterface does not return identical hits" + " through all its user interface methods. The incorrect" + " hit has index %d after sorting, for track %d.", + i, track + ); + hitsFromStore[i]->Print(); + hitsByMethod[i]->Print(); + return false; + } + } } } return true; @@ -206,7 +494,7 @@ bool SimTriggersOk() * the digits. These arrays are sorted and then compared to each other. The arrays * should contain the same digit information if everything is working correctly with * AliMUONDataInterface. If not then the difference is printed together with an - * error message and kFALSE is returned. + * error message and false is returned. */ bool RecDigitsOk() { @@ -216,6 +504,7 @@ bool RecDigitsOk() TObjArray digitsFromStore; digitsFromStore.SetOwner(kTRUE); AliMUONVDigitStore* store = data.DigitStore(event); + if (store == NULL) return false; TIter next(store->CreateIterator()); AliMUONVDigit* digit; while ( (digit = static_cast( next() )) != NULL ) @@ -297,7 +586,7 @@ bool RecDigitsOk() * filled with copies of the raw clusters. These arrays are sorted and then compared * to each other. The arrays should contain the same information if everything is * working correctly with AliMUONDataInterface. If not then the difference is printed - * together with an error message and kFALSE is returned. + * together with an error message and false is returned. */ bool RawClustersOk() { @@ -307,6 +596,7 @@ bool RawClustersOk() TObjArray clustersFromStore; clustersFromStore.SetOwner(kTRUE); AliMUONVClusterStore* store = data.ClusterStore(event); + if (store == NULL) return false; TIter next(store->CreateIterator()); AliMUONVCluster* cluster; while ( (cluster = static_cast( next() )) != NULL ) @@ -371,7 +661,7 @@ bool RawClustersOk() * The arrays and objects are then compared to each other. The arrays and objects * should contain the same information if everything is working correctly with * AliMUONDataInterface. If not then the difference is printed together with an - * error message and kFALSE is returned. + * error message and false is returned. */ bool TriggersOk() { @@ -382,6 +672,7 @@ bool TriggersOk() localsFromStore.SetOwner(kTRUE); regionalsFromStore.SetOwner(kTRUE); AliMUONVTriggerStore* store = data.TriggerStore(event); + if (store == NULL) return false; AliMUONGlobalTrigger* globalFromStore = static_cast(store->Global()->Clone()); TIter nextLocal(store->CreateLocalIterator()); AliMUONLocalTrigger* localTrig; @@ -497,24 +788,48 @@ bool TriggersOk() * confirmation message is printed, if not then kFALSE is returned with the failure * reason printed to screen. */ -bool MUONCheckDI() +bool MUONCheckDI(bool checkSim = true, bool checkRec = true) { - // TODO: complete checking AliMUONMCDataInterface. - //cout << "Checking simulated triggers..." << endl; - //if (! SimTriggersOk()) return false; - //cout << "Simulated triggers look OK." << endl; + AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + + // Note: we do not bother checking the AliMUONMCDataInterface::Particle, + // AliMUONMCDataInterface::Stack and AliMUONMCDataInterface::TrackRefs methods + // because they are trivial enough to validate from a quick inspecition of + // the source code. - cout << "Checking reconstructed digits..." << endl; - if (! RecDigitsOk()) return false; - cout << "Reconstructed digits look OK." << endl; + if (checkSim) + { + cout << "Checking simulated hits..." << endl; + if (! SimHitsOk()) return false; + cout << "Simulated hits look OK." << endl; + + cout << "Checking simulated s-digits..." << endl; + if (! SimSDigitsOk()) return false; + cout << "Simulated s-digits look OK." << endl; + + cout << "Checking simulated digits..." << endl; + if (! SimDigitsOk()) return false; + cout << "Simulated digits look OK." << endl; + + cout << "Checking simulated triggers..." << endl; + if (! SimTriggersOk()) return false; + cout << "Simulated triggers look OK." << endl; + } - cout << "Checking raw clusters..." << endl; - if (! RawClustersOk()) return false; - cout << "Raw clusters look OK." << endl; - - cout << "Checking reconstructed triggers..." << endl; - if (! TriggersOk()) return false; - cout << "Reconstructed triggers look OK." << endl; + if (checkRec) + { + cout << "Checking reconstructed digits..." << endl; + if (! RecDigitsOk()) return false; + cout << "Reconstructed digits look OK." << endl; + + cout << "Checking raw clusters..." << endl; + if (! RawClustersOk()) return false; + cout << "Raw clusters look OK." << endl; + + cout << "Checking reconstructed triggers..." << endl; + if (! TriggersOk()) return false; + cout << "Reconstructed triggers look OK." << endl; + } return true; }